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.