(GULP!) mixing OpenGL and DirectDraw
okay, i know there are alot of people out there that dont think it can be done, but i know it can. i know so because people have been able to use OpenGL and allegro (which uses ddraw) together, so i researched it on MSDN and i think i have a way to do it. OpenGL can be setup to render simply to a device context and just use PFD_DRAW_TO_BITMAP instead of PFD_DRAW_TO_WINDOW. the only problem is, i dont know how to setup that device context to hold a bitmap. MSDN''s method just doesnt make sense. anyone know how? and feel free to tell me if this wont work before i go through the headaches of trying to make it work if it wont.
And I don''t believe it''s a very good idea either. It would probably work on some cards, and not work on others, depending on the driver implementation.
If all you want is a simple (and portable) way of setting up a window for OpenGL rendering use GLUT or SDL.
If all you want is a simple (and portable) way of setting up a window for OpenGL rendering use GLUT or SDL.
Don''t try it, its a lost cause.
You might be able to make it work on some video cards but it will fail on others. And any method you figure out to make it work on more than one card is bound to cause all sorts of inefficiencies that totally negate any benefits. If you want to use OpenGL, use it for 2D drawing as well, there''s tons of tutorials online that explain how to use OpenGL to do 2D blitting using ortho projected quads. (Stay away from the drawPixel interface, its generally slow as hell on most PC OpenGL drivers).
I have no experience with Allegro, but I''d guess (assuming the people who wrote it aren''t crazy) that when its being used with OpenGL it doesn''t actually use DirectDraw, but falls back to GDI or using OpenGL to do its 2D operations. I know this is what SDL does.
Any headaches caused by trying to mix OpenGL and DirectDraw are your own problem, you''ve been warned!
You might be able to make it work on some video cards but it will fail on others. And any method you figure out to make it work on more than one card is bound to cause all sorts of inefficiencies that totally negate any benefits. If you want to use OpenGL, use it for 2D drawing as well, there''s tons of tutorials online that explain how to use OpenGL to do 2D blitting using ortho projected quads. (Stay away from the drawPixel interface, its generally slow as hell on most PC OpenGL drivers).
I have no experience with Allegro, but I''d guess (assuming the people who wrote it aren''t crazy) that when its being used with OpenGL it doesn''t actually use DirectDraw, but falls back to GDI or using OpenGL to do its 2D operations. I know this is what SDL does.
Any headaches caused by trying to mix OpenGL and DirectDraw are your own problem, you''ve been warned!
To select a bitmap to an device context go like this:
HBITMAP hBitmap = NULL;
HDC hBitmapDC = CreateCompatibleDC(NULL);
hBitmap = (HBITMAP)LoadImage(NULL, "bitmap.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
SelectObject(hBitmapDC, hBitmap);
HBITMAP hBitmap = NULL;
HDC hBitmapDC = CreateCompatibleDC(NULL);
hBitmap = (HBITMAP)LoadImage(NULL, "bitmap.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
SelectObject(hBitmapDC, hBitmap);
The reason not to use DDraw + OpenGL is because some drivers do it internally. You will conflict, it will complain.
See the developer FAQ at OpenGL.org for more information (also available on GameDev).
In conclusion, don''t do it!
~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
See the developer FAQ at OpenGL.org for more information (also available on GameDev).
In conclusion, don''t do it!
~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
okay okay, i knew i was gonna get some negative feedback. however, i know it can be done. your right, there COULD be some problems mixing the two, but if it can be done in two applications (running an OpenGL app in one window and a DDraw App in another), why cant it be done in the same program? btw, when i talked about using WAGL (WinAllegroGL), it does not fallback on all opengl, allegro still uses ddraw.
heres how i plan to do it:
1. Create (in memory, not from loading an image) to an HDC so that opengl can render to it (<-- dont know how to do this)
2. Setup opengl same way as for a window, except use the created HDC instead of using GetDC() for the window''s HDC
3. when choosing a pixel format, use the flags PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI (do NOT use double buffering or window)
4. use opengl to draw to that bitmap, then when i want the image opengl has drawn, flip the back buffer to a GDI surface, and BitBlt the opengl HDC to the back buffer of ddraw
im pretty sure it will work, albiet slow, and i have no idea if some video cards will be able to handle it while others cant. so what. i wanna see what happens
can anybody tell me how to setup the HDC so opengl can render to it? not load an image to an HDC, im saying actually create it at runtime
heres how i plan to do it:
1. Create (in memory, not from loading an image) to an HDC so that opengl can render to it (<-- dont know how to do this)
2. Setup opengl same way as for a window, except use the created HDC instead of using GetDC() for the window''s HDC
3. when choosing a pixel format, use the flags PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI (do NOT use double buffering or window)
4. use opengl to draw to that bitmap, then when i want the image opengl has drawn, flip the back buffer to a GDI surface, and BitBlt the opengl HDC to the back buffer of ddraw
im pretty sure it will work, albiet slow, and i have no idea if some video cards will be able to handle it while others cant. so what. i wanna see what happens
can anybody tell me how to setup the HDC so opengl can render to it? not load an image to an HDC, im saying actually create it at runtime
yes it can be done, but so what? it''s a pain in the ass. you can use OpenGL for 2D stuff just as good as DDraw if that''s the problem.
How many Microsoft employees does it take to screw in a light bulb?
None, they just declare drakness as a new standard.
How many Microsoft employees does it take to screw in a light bulb?
None, they just declare drakness as a new standard.
Lots of things could be done but shouldn''t. You''d be much better off spending your time trying to invent something new, or learn more useful programming techniques than you would trying to kludge together two APIs that aren''t meant to work together.
Why spend time making something work when the best you can hope for is an unsupported kludge that will run much slower than normal and will likely have unforseen problems with some systems?
And, lastly, the source code for WAGL seems to be available (did a quick search on google), why don''t you just download it and see how they do it first hand?
Why spend time making something work when the best you can hope for is an unsupported kludge that will run much slower than normal and will likely have unforseen problems with some systems?
And, lastly, the source code for WAGL seems to be available (did a quick search on google), why don''t you just download it and see how they do it first hand?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement