Skip to main content
GameDev.net gamedev.net
🔒 Locked

OpenGL + DirectDraw

Started by RWarden Jun 27, 2000 at 9:23 PM 2 replies 650+ views
Original Post
RWarden
RWarden
Is it possible to get OpenGL to render to a DirectDraw surface (create the RC from the surface''s DC), and if so, how much of a performance hit would it cause? It seems to me that the best option for drawing the 2d elements of a game (i.e. user interface) would be using DirectDraw, but I''d rather not use Direct3d and I haven''t been able to find any information about using DirectDraw with OpenGL. Thanks.. -RWarden (roberte@maui.net)
Julio
Julio
it''s very possible. been done many times. never understood why somebody would want to though. probably not much change in performance. I don''t know.

JoeMont001@aol.com
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
RWarden
RWarden
Using DirectDraw allows the app to switch between OpenGL, Direct3d, and a software rasterizer, without redoing any of the 2d UI code. Anyway, here''s the problem I''m running into: to create the rendering context you need a DC, but when you call IDirectDrawSurface7::GetDC, it locks the surface, which freezes everything until the surface is unlocked. And if you get the DC, create the RC from it, then release the DC, it seems to invalidate the RC and cause a bad, bad crash. The code:

g_lpDDSDraw->GetDC ( &hdc );
g_hRC = wglCreateContext ( hdc );
wglMakeCurrent ( hdc, g_hRC )
g_lpDDSDraw->ReleaseDC ( hdc );

-RWarden (roberte@maui.net)
Lars W.
Lars W.
Don''t know if it helps, but there is an DDCAPS2 Parameter that you can use when creating the surface, it is called DDSCAPS_OWNDC , the docs say it is for surfaces that contain an DC for a long period of time.
Maybe the getDC works different on such surfaces, and does not lock it, or it is valid even after ReleaseDC.
I know it works to use DirectDraw with OpenGL, cause i read about it, and i think many games are using it.

Lars

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.