A question about how to generate AVI from OpenGL directly

Started by
0 comments, last by Kuei_ling 21 years, 11 months ago
I want to create AVI out of my OpenGL applications directly without generating thousands of pictures. The following is my key program: //===================================================== HDC hdc = ::GetDC(¶ÇCurrent windows handle); static PIXELFORMATDESCRIPTOR pfd; int nPixelFormat; nPixelFormat = GetPixelFormat(hdc); if (DescribePixelFormat(hdc, nPixelFormat, sizeof(PIXELFORMATDESCRIPTOR),&pfd) == 0) {// DescribePixelFormat error return; } HGLRC hRC; hRC = ::wglCreateContext(hdc); ::wglMakeCurrent(hdc, hRC); BYTE* bmBits; //³]©wbmBits¡K¡K glReadBuffer(GL_BACK); CAVIGenerator AVIGenerator; //Do some AVI setting¡K for(int i = 1; i < 10; i ++) { //Changing openGL data¡K ¡K. //ReDrawWin(); //To redraw window, cause the OpenGL data has changed. And the window will call SwapBuffer, to refresh buffer and pixels data. glReadPixels(0,0,bmpheader->biWidth, bmpheader ->biHeight,GL_BGR_EXT,GL_UNSIGNED_BYTE,bmBits); AVIGenerator .Add Frames(); } glReadBuffer(GL_FRONT); //=========================================================== 1.When de-active ReDrawWin() function, glReadPixels() could get one frame. But what I get is look like just before into the ¡§for¡¨ loop. (I think this is because the OpenGL data didn¡¦t refresh yet.) And the following frames in the ¡§for¡¨ loop seems didn¡¦t get successfully. Open AVI file and just see the same frame. (I am not sure that isn¡¦t success, or all success but look like the same.) So I suppose that my problem is that I didn¡¦t refresh my OpenGL data. Then I add the ReDrawWin() function. 2.When active ReDrawWin() function, and just add frames in the ¡§for¡¨ loop, the whole frames are all dark. Nothing I can see. I wonder know why the first frame I can get? But the following can¡¦t? Is there any wrong with OpenGL or Windows settings? Please tell me where my problem is.
Advertisement
I am not sure how to answer your question but I do have a bit of advice about your post.

You got some international characters in there that aint getting translated properly. You might wanna stick with english characters when you post.

It is things like this
¡§for¡¨  


Landsknecht
My sig used to be, "God was my co-pilot but we crashed in the mountains and I had to eat him..."
But folks whinned and I had to change it.

This topic is closed to new replies.

Advertisement