Using OpenGL to display DIB (from buffer, not from file!)

Hi

I’m writing a program based on VFW to get pics from a webcam. This pics are on DIB format, and stored on a buffer.

Now I want to use OpenGL (through glDrawPixels for instance) to display (I’m using the Qt GUI, and for this I think OpenGL is the best for displaying video).

The thing is that I don’t know how to do it. Could anybody give me a hand?

Thanks!

glDrawPixels is pretty simple to use, so I assume you want to know how to create OpenGL context and use it for drawing.
I would start from google’ing for some component. I’m using wxWidgets and there is a GL canvas component. I’m pretty sure someone did something similar for Qt.

Well I have used glDrawPixels before on Qt, to display IplImages (from the OpenCV libraries) and it worked fine.

But I’m trying to use the same concept now and I get no picture.

The thing is that on VFW you use a callback function in which you can get a LPVIDEOHDR structure, as follows:

typedef struct videohdr_tag {
LPBYTE lpData; /* Pointer to buffer. /
DWORD dwBufferLength; /
Length of buffer. /
DWORD dwBytesUsed; /
Bytes actually used. /
DWORD dwTimeCaptured; /
Timefrom start of stream. /
DWORD dwUser;
DWORD dwFlags; /
Flags. */
DWORD dwReserved[4];
}

And as far as I know, I have to use lpData to display, which is declared as a WORD and supposedly points to a buffer with the new frame on DIB format.

But I don’t know exactly what to do so that glDrawPixels works.

I hope I explained mysellf. Thanks!

Blast from the past: Here are some of my post from about seven years ago about doing this from an AVI.
http://www.opengl.org/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic;f=3;t=011343
(Cool old forum layout. :wink: )

If you have a similar way to get the pointer to the DIB-bits from within VFW that should do the trick.