where is wrong? help!

I have created the checkImage ( 5122564)
and I want to get the image(come from the live image) using glTexSubImage2d()
but I got no image , and I am sure the format of the image is RGBA(A == 1)
here is the code , where is wrong?
glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glBindTexture( GL_TEXTURE_2D, glid );
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA8,TestWidth,TestHeight,0,GL_RGBA,GL_UNSIGNED_BYTE,checkImage);

glBegin(GL_QUADS );
  glTexCoord2f( 0.0, 0.0 ); glVertex2f( 0,0  );
  glTexCoord2f(  0, 1 ); glVertex2f(0,256 );     
  glTexCoord2f( 1,1 ); glVertex2f( 512, 256 );
  glTexCoord2f(   1,0 ); glVertex2f(  512,0 );
glEnd();


glBindTexture( GL_TEXTURE_2D, glid );
glTexSubImage2D( GL_TEXTURE_2D, 0, 0,0, 320,240, GL_RGBA, GL_UNSIGNED_BYTE,image);
glBegin(GL_QUADS );
glTexCoord2f( 0.0, 0.0 ); glVertex2f( 0,0 );
glTexCoord2f( 0, 1 ); glVertex2f(0,gImYsize);
glTexCoord2f( 1,1 ); glVertex2f( gImXsize, gImYsize );
glTexCoord2f( 1,0 ); glVertex2f( gImXsize,0 );

glEnd();

Thanks in advance

If that’s all your code that program won’t work as expected.

  1. You haven’t setup a projection and modelview matrix which would show vertices with your coordinates. The default shows only coordinates from -1 to 1.

  2. You have not adjusted the texture object defaults. Default filter is GL_LINEAR_MIPMAP_NEAREST for minification, so you either have to download mipmaps or set it to GL_NEAREST or GL_LINEAR for each new texture object. See OpenGL specs 1.2.1 paragraph 3.8.7 for more defaults.

  3. The texture coordinates for the 320*240 need to be adjusted to 320/512 and 240/256 to display only the sub image on the whole quad.

  4. The texture matrix is the identity by default. No need to set it.

  5. You should specify the vertices and texture coordinates of the quad counterclockwise in case you want to work with culling defaults.

[This message has been edited by Relic (edited 07-10-2000).]

Did you use glGenTextures() to actually allocate a texture?

Yes, I have done
glGenTextures(1, &glid);
glBindTexture( GL_TEXTURE_2D, glid );
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
before the code I have posted , and I have got the glTexSubImage2d work by using another
image instead the live camera image, for the
live camera image , I only got a gray quad, no live image, at the same time, I can use
gldrawpixel() to display the live image , what do you think ?

Thanks

hi, thanks
I have found the reason.