Transfer of a Direct Draw surface to OpenGl

I need to do a very fast transfer of a
Direct Draw surface to the OpenGL buffer.
The reason - I use Direct Show for video
decompression witch us a DirectDraw
surface (off screen) as the result.
I need to transfer the content of this
buffer to OpenGl at video framerate.
Is it possible to get e.g. the pointer to
the RGB values in the DirectDraw surface
and to transfer them by glCopyPixels or
so to OpenGL ? Sample code will be highy apreciated …

DirectDrawSurface has a method called Lock which allows you to access its properties. Lock() fills DDSURFACEDESC* structure with informations about surface. Look at its description in DXSDK help. There is void *lpSurface in DDSURFACEDESC which is a pointer to the pixels table. But remember to unlock surface after locking it, and that you have an access to the RGB values only between Lock() - Unlock() calls. DirectDraw surface’s RGB format depends on video card’s pixel format so make sure to check its bit depth and RGB order. And before calling Lock() set DDSURFACEDESC to 0 and set its dwSize to sizeof(YOUR_DDSURFACEDESC).

I hope this will help, but I cannot guarantee it will work.

PS. Don’t remember about DDSURFACEDESC.lPitch

Thank . The method described by you works perfectly !