示例#1
0
/*
---------------------------------------------------------------------------------------
- Grabs A Frame From The Stream
---------------------------------------------------------------------------------------
*/
void AviVideoRenderer::GrabAVIFrame(int frame)
{
	LPBITMAPINFOHEADER lpbi;									// Holds The Bitmap Header Information
	lpbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(_AVR_pgf, frame);	// Grab Data From The AVI Stream
	char* _tex_pdata=(char *)lpbi+lpbi->biSize+lpbi->biClrUsed * sizeof(RGBQUAD);	// Pointer To Data Returned By AVIStreamGetFrame

	// Convert Data To Requested Bitmap Format
	DrawDibDraw (_AVR_hdd, _AVR_hdc, 0, 0,  _heights[0], _widths[0], lpbi, _tex_pdata, 0, 0, _video_width, _video_height, 0);

	flipIt(_img_data, _heights[0], _widths[0]);	// Swap The Red And Blue Bytes (GL Compatability)

	// Update The Texture
	glBindTexture(GL_TEXTURE_2D, _textures[0]);
	glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,  _heights[0], _widths[0], GL_RGB, GL_UNSIGNED_BYTE, _img_data);


}
示例#2
0
void AVI :: Set(float time)									// Grabs A Frame From The Stream
{
	// anything to do?
	if(!tman || mpf==0)
		NTHROW("AVI :: Set - Video not created before call to set.");

	// move position forward by time
	pos+=time;
	// get the frame number
	int frame=(int)((float)pos/mpf);

	// have we gone past the end?
	if(frame>=lastframe)
	{
		if(loop)
		{
			pos=0.0f;
			frame=0;				// reset the animation
		}else
			frame=lastframe-1;		// hold at the last frame
	}

	LPBITMAPINFOHEADER lpbi;											// Holds The Bitmap Header Information
	lpbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, frame);			// Grab Data From The AVI Stream
	pdata=(BYTE *)lpbi+lpbi->biSize+lpbi->biClrUsed * sizeof(RGBQUAD);	// Pointer To Data Returned By AVIStreamGetFrame

	// Convert Data To Requested Bitmap Format
	DrawDibDraw (hdd, hdc, 0, 0, 256, 256, lpbi, pdata, 0, 0, width, height, 0);

	flipIt(data);												// Swap The Red And Blue Bytes (GL Compatability)

	// set our texture
	tman->Set(texid);

	// Update The Texture
	glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 256, 256, GL_RGB, GL_UNSIGNED_BYTE, data);
}