OpenGL + DirectDraw

Started by
13 comments, last by Psico 24 years, 3 months ago
this's about opengl + directdraw, first is'nt impossible because i did it (well almost), there are some things to know first: 1.- Double buffering: you hace to use DD for this, that mean that you have to use opengl with a single buffer 2.- the code is something like this: - Get the HDC from the secundary buffer using DD - use wglMakeCurrent() to use that hdc with the rendering context - Do all the drawing with opengl - wglMakeCurrent(NULL,NULL) - Release the hdc. i did prove ligthing and texture and everything work just fine. The only problema that i found is when you have a 3d acelerator, whe is present, dd work fine, but opengl don't, i guess it's becuase both want to use the hardware. I triying to solve this. When the video card is a no-acelerator, all this works. if anyone has any question or can help me with that problema put a message o write me directly (connor@cantv.net). note: please forgive my english Edited by - Psico on 1/30/00 4:43:47 PM Edited by - Psico on 1/30/00 4:47:19 PM
Advertisement
I have seen the code somewhere on
http://members.xoom.com/vba51/ or http://www.chez.com/scribe

You have to go looking through the various downloads sections within that page. I think it is on the OpenGL section, but it is written in Visual Basic
Alright, I''ve heard this type of thing a few times on various boards. There has always been 1 thing I wanted to know. WHY. what possible gain can be achieved by using them both? opengl uses that hardware when its available, and seems to do quite a commendable job of it. i also dont understand why anyone would want to use ddraw (which is a 2D accel ONLY) with opengl (which is supposed to accell 2D AND 3D) it just doesnt make sense to me. and being able to vait for a verticle retrace is no excuse. Quake 2 (and some other programs i''m sure) has the option to wait for the retrace, and it doesnt use ddraw. now, that doesnt mean i know how they do it mind you, but it can be done.
quote:Original post by HitScan

Alright, I''ve heard this type of thing a few times on various boards. There has always been 1 thing I wanted to know. WHY. what possible gain can be achieved by using them both? opengl uses that hardware when its available, and seems to do quite a commendable job of it. i also dont understand why anyone would want to use ddraw (which is a 2D accel ONLY) with opengl (which is supposed to accell 2D AND 3D) it just doesnt make sense to me. and being able to vait for a verticle retrace is no excuse. Quake 2 (and some other programs i''m sure) has the option to wait for the retrace, and it doesnt use ddraw. now, that doesnt mean i know how they do it mind you, but it can be done.


well , the answer is simply, because with directdraw you can do a lot of stuff with bitmaps (buttons, scrolls, slidebars)in a easier and faster way than opengl. Even opengl can draw bitmaps that''s not it''s primal objetive. For example, if you want a background with two layers,a couple of buttons, a graphics menu and a 3d dog moving around, the best way is to use ddraw to manipulate the background, the button and the menu and let opengl do what it do best, the 3d rendering and animation of the dog, as you can see the idea is to bring the best of the two worlds (2d and 3d) together...
Isn''t it pointless to use both DD and OpenGL at the same time if you can only get hardware accel from *one* of them. Why even bother then? The whole point of using GL is so that you get 3D hardware Accell -- without that you might as well write your own renderer.

--TheGoop
quote:Original post by TheGoop

Isn''t it pointless to use both DD and OpenGL at the same time if you can only get hardware accel from *one* of them. Why even bother then? The whole point of using GL is so that you get 3D hardware Accell -- without that you might as well write your own renderer.

--TheGoop

well, that''s not true, because, you get hardware accel for both of them, and actually i solve the problema i had with accelerator (the one i post first), here is how it work
- use opengl to render to a bitmap in memory instead of the front buffer, this rendering is hardware accel (all the math, matrix manipulation even the rendering is done by hardware).
- then use directdraw to blt the bitmap into a ddraw back buffer (this mean you need gdi), do all the drawing with ddraw in the back buffer and finally do the page flipping...as you see, this last part has hardware accel because ddraw is working with only a bitmap, not directly with opengl, and opengl isn''t working with directdraw directly...there are to thing to keep in mind: Pixel formats (of the surface and the bitmap, they has to match to get good quality and the use of gdi, i know is a bit slow, but isn''t that slooow, and if you hace hardware support the sacrifice is almost nothing)...
quote:Original post by Psico

this''s about opengl + directdraw, first is''nt impossible because i did it (well almost), there are some things to know first:

1.- Double buffering: you hace to use DD for this, that mean that you have to use opengl with a single buffer

2.- the code is something like this:
- Get the HDC from the secundary buffer using DD
- use wglMakeCurrent() to use that hdc with the
rendering context
- Do all the drawing with opengl
- wglMakeCurrent(NULL,NULL)
- Release the hdc.
i did prove ligthing and texture and everything work just fine. The only problema that i found is when you have a 3d acelerator, whe is present, dd work fine, but opengl don''t, i guess it''s becuase both want to use the hardware. I triying to solve this. When the video card is a no-acelerator, all this works. if anyone has any question or can help me with that problema put a message o write me directly (connor@cantv.net).
note: please forgive my english

Edited by - Psico on 1/30/00 4:43:47 PM

Edited by - Psico on 1/30/00 4:47:19 PM


Finally i did it, all the problems solved (at least for now), i run a simple sample using dddraw and opengl with hardware acceleration...how i did it?, well look down in the post for a reply i did to someone...there i explain everything...
quote:Original post by Psico

this''s about opengl + directdraw, first is''nt impossible because i did it (well almost), there are some things to know first:

1.- Double buffering: you hace to use DD for this, that mean that you have to use opengl with a single buffer

2.- the code is something like this:
- Get the HDC from the secundary buffer using DD
- use wglMakeCurrent() to use that hdc with the
rendering context
- Do all the drawing with opengl
- wglMakeCurrent(NULL,NULL)
- Release the hdc.
i did prove ligthing and texture and everything work just fine. The only problema that i found is when you have a 3d acelerator, whe is present, dd work fine, but opengl don''t, i guess it''s becuase both want to use the hardware. I triying to solve this. When the video card is a no-acelerator, all this works. if anyone has any question or can help me with that problema put a message o write me directly (connor@cantv.net).
note: please forgive my english

Edited by - Psico on 1/30/00 4:43:47 PM

Edited by - Psico on 1/30/00 4:47:19 PM


Finally i did it, all the problems solved (at least for now), i run a simple sample using dddraw and opengl with hardware acceleration...how i did it?, well look down in the post for a reply i did to someone...there i explain everything...
I had tried this a long time ago but faile miserably at it

I had the idea of getting the HDC of the surface, then making it curent to opengl drawing all the stuff on the buffer then realessing it in the right order.
Hardcore Until The End.
I had tried this a long time ago but faile miserably at it

I had the idea of getting the HDC of the surface, then making it curent to opengl drawing all the stuff on the buffer then realessing it in the right order.

This way you can either draw dd stuu first and then opengl or vice versa but it kept crashing on me so either I did my init code wrong or who knows what!
Hardcore Until The End.

This topic is closed to new replies.

Advertisement