nothing happens......??

I’ve been trying to put video into my program and what i have just gives me a blank quadrilateral with no frames on it:

int DrawGLScene(GLvoid)
{
GLfloat ztrans = -zpos;

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-1.0f);

glTranslatef(0.0f, 0.0f, ztrans);

if (GetAVIFrame( VINDEX )) //stores frame data into (GLubyte *)Frame using AVIStreamGetFrame
{
glBindTexture (GL_TEXTURE_2D, AVItexture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, aviInfo.dwWidth,
aviInfo.dwHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE,
Frame);

  glBegin (GL_QUADS);																
  	//draw quad with dimensions of original AVI
  	glTexCoord2f(0.0f, 0.0f); 
  	glVertex3f(0.0f, 0.0f, 0.0f); 
  	
  	glTexCoord2f((float)(aviInfo.dwWidth / 100), 0.0f); 
  	glVertex3f((float)(aviInfo.dwWidth / 100), 0.0f, 0.0f); 
  	
  	glTexCoord2f((float)(aviInfo.dwWidth / 100), (float)(aviInfo.dwHeight / 100)); 
  	glVertex3f((float)(aviInfo.dwWidth / 100), (float)(aviInfo.dwHeight / 100), 0.0f); 
  	
  	glTexCoord2f(0.0f, (float)(aviInfo.dwHeight / 100)); 
  	glVertex3f(0.0f, (float)(aviInfo.dwHeight / 100), 0.0f); 
  glEnd();	

}

glRasterPos2f(-0.45f, -0.35f);
glPrint(“%d”, VINDEX);

++VINDEX;
if (VINDEX >= aviInfo.dwLength)
{
VINDEX = 0;
}

glFlush();
return TRUE;
}

Is there anything wrong with this code?
I use the following functions to load the AVI data:

PAVIFILE aviFile;
AVIFILEINFO aviInfo;
PAVISTREAM aviStream;
PGETFRAME aviFrame;
LPCTSTR szFileName;
GLubyte *Frame;
GLuint VINDEX = 0;
GLuint AVItexture;

bool OpenAVI (LPCTSTR FileName)
{
szFileName = FileName;

AVIFileInit();
switch ( AVIFileOpen( &aviFile, szFileName, OF_SHARE_DENY_WRITE, NULL ) ) {
case AVIERR_BADFORMAT:
MessageBox(NULL,“The file couldn’t be read, indicating a corrupt file or an unrecognized format.”,“ERROR”,MB_OK|MB_ICONEXCLAMATION);
return false;
break;
case AVIERR_MEMORY:
MessageBox(NULL,“The file could not be opened because of insufficient memory.”,“ERROR”,MB_OK|MB_ICONEXCLAMATION);
return false;
break;
case AVIERR_FILEREAD:
MessageBox(NULL,“A disk error occurred while reading the file.”,“ERROR”,MB_OK|MB_ICONEXCLAMATION);
return false;
break;
case AVIERR_FILEOPEN:
MessageBox(NULL,“A disk error occurred while opening the file.”,“ERROR”,MB_OK|MB_ICONEXCLAMATION);
return false;
break;
case REGDB_E_CLASSNOTREG:
MessageBox(NULL,"According to the registry, the type of file specified in AVIFileOpen does not have a handler to process it. ",“ERROR”,MB_OK|MB_ICONEXCLAMATION);
return false;
break;
default:
break;
}

if (AVIFileInfo( aviFile, &aviInfo, sizeof( aviInfo ) ))
{
MessageBox(NULL,“file info error”,“ERROR”,MB_OK|MB_ICONEXCLAMATION);
return false;
}

switch (AVIFileGetStream( aviFile, &aviStream, streamtypeVIDEO, 0 )) {
case AVIERR_NODATA:
MessageBox(NULL,“AVIERR_NODATA”,“ERROR”,MB_OK|MB_ICONEXCLAMATION);
return false;
break;
case AVIERR_MEMORY:
MessageBox(NULL,“AVIERR_MEMORY”,“ERROR”,MB_OK|MB_ICONEXCLAMATION);
return false;
break;
default:
break;
}

if ( (aviFrame = AVIStreamGetFrameOpen( aviStream, NULL )) == NULL)
{
MessageBox(NULL,“cannot find a decompressor that can decompress the stream to the given format”,“ERROR”,MB_OK|MB_ICONEXCLAMATION);
return false;
}

return true;
}

void CloseAVI()
{
AVIStreamGetFrameClose( aviFrame );
AVIStreamRelease( aviStream );
AVIFileRelease( aviFile );
AVIFileExit();
}

bool GetAVIFrame (int whichframe)
{

Frame = (GLubyte *)AVIStreamGetFrame( aviFrame, whichframe );
if (Frame = NULL)
{
MessageBox(NULL,“unsuccessful frame retrieval”,“ERROR”,MB_OK|MB_ICONEXCLAMATION);
return false;
}

Frame += sizeof( BITMAPINFOHEADER );

return true;
}

Any help would be greatly appreciated.

Most probably, your AVI dimensions are not a power of 2 (textures dimensions with OpenGL must be a power of 2 if you forget about some extensions).

To quickly check for that, replace your glTexImage2D with gluBuild2DMipmaps.

If this does not work, I will have to look more deeply into your code.

Regards.

Eric

He is using glTexSubImage2D to replace a part of the texture, which I believe you should do in cases like this, for fast updates of the texture. When uploading new parts, they don’t have to be a power of two, so that shouldn’t be a problem.

But the power-of-two-thingie can still be the problem. When you first create the texture (I suppose you do that somewhere), THEN you need power of two dimensions.

I agree with you Bob but I raised the problem because that is exactly the mistake I made when first using AVIs as textures: I tried to create a non-power of 2-dimesions textures… Then, of course, gluBuild2DMimaps is just to check if this is the problem !!! The way to go for fast results IS glTexSubImage2D !!!

I just thought about something else: have you checked your texture filtering ? The default for GL_TEXTURE_MIN_FILTER assumes your are using mimaps which you might not do in this specific case…

Well, if you can post the code that creates the texture object, we will be able to give you the exact answer !

Regards.

Eric

Thanks for the help!
I know about the fact that glTexSubImage2D makes up for the dimensions. Um, as for creating the textures i believe i posted it in my code. I call the function GetAVIFrame and it stores the data in the form GLubyte into the array called Frame. I use that as the data in the glTexSubImage2D function. I create the texture in InitGL():

glGenTextures(1, &AVItexture);

And then all of the other texture creation stuff is in DrawGLScene() because i load a new texture each frame.
I tried to use the build mipmap function, but i think i’m conceptually not understanding what it does. this is how i called it:

  gluBuild2DMipmaps (GL_TEXTURE_2D, 3, aviInfo.dwWidth, aviInfo.dwHeight,
  			GL_RGB, GL_UNSIGNED_BYTE, frame);

I placed it right under the glTexSubImage2D, which is edited out. When I run the program it gives me the windows illegal operation deal and it terminates.