Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

xtrmntr

OpenGL can opengl and d3d play nicely together?

This topic is 5725 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The title is a tad misleading but but i thought it might attract more attention (good and bad). This is not a post about which is better, in fact its almost the exact opposite. With that said let me tell you what my question is. Me and a friend our writing a game. This will be my first time writing one in 3D. I have been spending my time reading and playing with openGL while the other guy has only done 3d programming in Direct3D. We have agreed to do it in both languages since our schedules are sort of hectic with our lives/work. So right now i have the initial windowing code and a settings dialog to let the user initial choose which 3d lib to use and what resolution they wish to play in. I have also studied and modified one of the articles here that allows you to dynamically load either openGL or D3D at runtime. Both of these portions are working just fine but i have hit a wall so to speak. My question: is there a way/design method to make the different calls to either library? The way it is now the programmer is given a pointer to a renderer. This pointer could signify either OpenGL or Direct3D. Is their some other way to structure this without having to wrapper every call that would be similar to each library into a function that this pointer can call? Is there a different OO ideology to handling something of this nature? Thanks for listening. And by all means ask me as much as you need to try to help me out here.

Share this post


Link to post
Share on other sites
Advertisement
You'll need wrappers for all functions. There's no way around that. From a design point of view, you'd have some abstract base class and then derive an OpenGL-specific class and a Direct3D-specific class.

For a proof of concept see my engine http://xengine.sourceforge.net which pretty much does all that.
Note that the engine is still in alpha stage of development, although the core render system works pretty well already. Thus there is no downloadable release yet and you'll have to get everything out of CVS.

Cheers.


[edited by - Asgard on November 3, 2002 11:05:33 AM]

Share this post


Link to post
Share on other sites
Thank you very much for the link Asgard. Though your implementation is more complicated than I need to make it, It will definitely be a good reference for me.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I used a dynamic .dll file for mine. Basically, the main engine loads a given .dll file, and sets the appropriate pointers to functions. The benefits of this, is that I can have any type of .dll file... direct x, opengl, glide, software, etc... and you can add/modify them without changing the main program at all. I had mine doing the creation of the window, drawing of primitives, display of vertex buffers, multi-texturing (automagically did single or multi-pass based on some params, so my program didn''t have to worry about it), setting the colors, etc.

Billy - BillyB@mrsnj.com

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I think that the best is to choose only one API (I choose OpenGL because of portability), but you can use a wrapper that emulate DirectX calls with OpenGL or OpenGL calls with DirectX...

Share this post


Link to post
Share on other sites
If you're pressed for time the last thing you should do is program for both APIs. Unless there's some other reason why you'd like to support both APIs just pick one and stick with it. Decide which one of you will do the graphics programming and choose the API accordingly. Let the other person work on a different part of the game.

[edited by - chronos on November 8, 2002 12:04:22 AM]

Share this post


Link to post
Share on other sites
I agree with chronos. My engine supports both DLLs through an abstract wrapper, and while I think it''s great fun writing the wrapper, it does certainly slow things down. Programming it isn''t the hard part, designing it is - the wrapper has to be fairly high-level to support both APIs well.

~CGameProgrammer( );

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!