Archived

This topic is now archived and is closed to further replies.

Leroy1891

DrawDibDraw draws to screen,not texture

Recommended Posts

Leroy1891    122
i am trying to put lesson 35 into a class for easy use. however when drawdibdraw is called it draws the frame to screen instead of the texture. also it flickers even when i tell it to stay on the first frame. i went through and commented out all the opengl drawing in lesson 35 figuring that i would see the frame drawn to screen like in my class but it doesn''t draw anything. this is why i believe it is drawing to the wrong thing. do i have to set something to a certain value to get drawdibdraw to draw to a texture instead?

Share this post


Link to post
Share on other sites
v_d_d    122
Just do like in the lesson 35... it draws to a texture. DrawDibDraw draws in a buffer first and that buffer is set to a opengl texture.

Share this post


Link to post
Share on other sites
Leroy1891    122
I am using the same code from lesson 35 to do this. my drawframe
function looks like this:
void AVIFile::DrawFrame(int Frame)
{
LPBITMAPINFOHEADER Lpbi;
Lpbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(Pgf, Frame);
Pdata=(char *)Lpbi+Lpbi->biSize+Lpbi->biClrUsed * sizeof(RGBQUAD);

DrawDibDraw (Hdd, Hdc, 0, 0, 256, 256, Lpbi, Pdata, 0, 0, Width, Height,0);

glTexSubImage2D (GL_TEXTURE_2D, 0, 0,StartY, 256, 256, GL_RGB, GL_UNSIGNED_BYTE, Data);

glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0); glVertex3f(-0.5,-0.5,-2.0);
glTexCoord2f(1.0,0.0); glVertex3f(0.5,-0.5,-2.0);
glTexCoord2f(1.0,1.0); glVertex3f(0.5,0.5,-2.0);
glTexCoord2f(0.0,1.0); glVertex3f(-0.5,0.5,-2.0);
glEnd();
}

Share this post


Link to post
Share on other sites
v_d_d    122
Did you create a dib section first and did you do a SelectObject() on the hdc and the hbitmap returned by CreateDIBSection()?

Share this post


Link to post
Share on other sites
Leroy1891    122
yes i did. here are the lines if you want to look at them

HBitmap = CreateDIBSection (Hdc, (BITMAPINFO*)(&Bmih), DIB_RGB_COLORS, (void**)(&Data), NULL, NULL);
SelectObject (Hdc, HBitmap);

Share this post


Link to post
Share on other sites
v_d_d    122
If it still draws to the screen, then it is probably because the hdc == 0.

Step debug the line:

DrawDibDraw (Hdd, Hdc, 0, 0, 256, 256, Lpbi, Pdata, 0, 0, Width, Height,0);

and check the value of Hdc. It must not be zero.

Hdc must have been created with CreateCompatibleDC(0) first.

Share this post


Link to post
Share on other sites
Leroy1891    122
that got it so it doesn''t draw to the screen anymore but it still won''t draw to the texture. i checked my hdc right before
getting the frame and it is not 0.

Share this post


Link to post
Share on other sites