View Full Version : Generate .Avi File with Memory HDC (random pixels)

03-10-2005, 04:23 AM

I'm try to render in a off-buffer for generating a file .AVI. I create this off-buffer with a memory DC and a DIB section associate a this memory DC. So, I can do other things in my computer while the .avi file are generating.

Here I write some code:

fun for creating HDC memory and the context RC.
m_hDib = ::CreateDIBSection(hDC, &m_bmi, DIB_RGB_COLORS, &m_pBitmapBits, NULL, (DWORD)0);

m_hDC = CreateCompatibleDC(NULL);

SelectObject(m_hDC, m_hDib);


m_hGLContext = wglCreateContext(m_hDC);


After, I read the front buffer int orden to add the bitmap to the .avi file.

Some code:





glReadPixels(0,0,m_rectClient.Width(),m_rectClient .Height(),GL_BGR_EXT,GL_UNSIGNED_BYTE,bmBits);

CBmp bmp; // (debug) for viewing the bmp I read from front buffer

bmp.createBmp(m_rectClient.Width(),m_rectClient.He ight(),bmBits,m_rectClient.Width()*m_rectClient.He ight()*3);




In the file bmpDebugAvi.bmp I can see some random pixel (blue pixel, red pixel, yellow pixel,....) with colors that it's part of my render. The wrong pixel aren't always in same place. For each render they are in other place. I believe the wrong pixel are locate with the render triangle are far from the camera.

I believe my code is ok, and opengl and memory DC don't work well whe the triangles are far from the camera. I have develop a simple sample for testing this, and I don't seem this random pixels in random places in the render window.

I'll estimate all sugerencies.

Thank you.

Regards from Spain.