PDA

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



chirri11
03-10-2005, 05:23 AM
Hi,

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);

setWindowPixelFormat(m_hDC,1);

m_hGLContext = wglCreateContext(m_hDC);

}

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

Some code:

{

m_pOpengl->setCurrent();

glFlush();

glReadBuffer(GL_FRONT);

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);

bmp.save("c:\\bmpDebugAvi.bmp");

res=m_pAviGenerator->AddFrame(bmBits);

}

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.