could someone plz help me with glcopyteximage2d

could someone show me some code on how to geta snapshot of the screen (framebuffer). iv been tryin to work on this for a week now and i just dont know whatz goin wrong. herez what im doing :

glPixelStoref pxsUnpackAlignment, 1
glPixelTransferf pxtMapColor, True
glGenTextures 1, intSnapShot

tempwidth = Fix(Log(picOpengl.ScaleWidth) / Log(2))
tempheight = Fix(Log(Abs(picOpengl.ScaleHeight)) / Log(2))
tempwidth = 2 ^ tempwidth
tempheight = 2 ^ tempheight
Text3.Text = tempwidth & " " & tempheight
glReadBuffer rbmBack
glBindTexture glTexture2D, intSnapShot
glTexParameterf glTexture2D, tpnTextureWrapS, GL_CLAMP
glTexParameterf glTexture2D, tpnTextureWrapT, GL_CLAMP
glTexParameterf glTexture2D, tpnTextureMagFilter, GL_LINEAR
glTexParameterf glTexture2D, tpnTextureMinFilter, GL_LINEAR
glTexEnvf tetTextureEnv, tenTextureEnvMode, tepDecal
glCopyTexImage2D GL_TEXTURE_2D, 0, ifRGBA8, 0, 0, tempwidth, tempheight, 0