Jump to content
  • Advertisement

Archived

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

Qa303asmGuru

Switching between OpenGL and DirectDraw/3D at runtime?

This topic is 5561 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

I was just wondering if anybody new of any references or tutorials on a good way to switch between the two for graphics. I''ve done a google search and found a few things, but I find that asking here usually points me to a much better resource, or answers my question directly. I was thinking for my game that I''d either ask the user to pick a renderer on the first run of the game and save the configuration in a file for subsequent runs, or start the app in DirectDraw and then let the player decide which renderer to use before the game actually starts. Then just create a new window with the chosen renderer for the actual game, and subsequent menu screens. Any references or advice would be greatly appreciated. -Q

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Implement the game first using just one of them.

When that''s done, you can go through the game, re-factor it, and pull the rendering pieces into a separate interface, which you can then instantiate from separate DLLs based on config files.

However, most people break down on the first part -- no need worrying about part 2 until you''ve got part 1 done.

Share this post


Link to post
Share on other sites
Ha, I hear you about the first part. I''m actually a good 40% of the way through my first PC game attempt. If you are interested, check out the thread (a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=143731">here. I hope to get another update for the thread in by next week.

Currently the entire game is rendered with OpenGL, but due to lack of performance on some machines (not everybody has an OpenGL friendly card/drivers), I wanted to give the game DirectGraphics capabilities so those players could have a better game experience.

Thanks for your advice though AP. Anyone else?

-Q

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Anonymous Poster
Implement the game first using just one of them.

When that''s done, you can go through the game, re-factor it, and pull the rendering pieces into a separate interface, which you can then instantiate from separate DLLs based on config files.

However, most people break down on the first part -- no need worrying about part 2 until you''ve got part 1 done.


Bad bad idea. Implementing things this way will only lead to a much longer development time, and some very ugly code.

A much better idea would be to set up your code so that you can add on a seperate rendering interface later, and only work with one API to begin with. Create the rendering interface to abstract the API then start writing your engine code. Some minor modifications will be required when either plugging in DX or OpenGL but they will be fairly minimal in comparison to ripping out API specific calls and replacing them with an abstraction layer at a later time.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
As just posted above, I would also strongly suggest you to create unique functions and classes to represent the different aspects of your game engine. SetScreen for just that etc... then you can apply whatever API you want to that. Naturally it means that you will initially have to select one api over the other during development but adding support for the other will be much easier later.

Share this post


Link to post
Share on other sites
Do a little research on the other API, regarding setting rendering states, setting up textures, rendering models, matrix stacks, pushing and popping rendering states (if you plan to support that), etc. and try to establish a common denominator between them that allows all the functionality you want to use.

If you initially set up interface functions purely for OpenGL, it's unlikely you can just add Direct3D support just by writing the corresponding functions using Direct3D. You'll likely have to split some things apart, and if you have to modify your OpenGL interface, you'll have to redo the calling of those functions in your game code, for every game you wrote using them.

Consider yourself cautioned, and good luck.


[edited by - Waverider on April 1, 2003 12:15:32 PM]

Share this post


Link to post
Share on other sites
I would say (and forgive me if this is to radical) when the game is executed, load a dialog box which asks you to choose which graphics api you would like to use. In fact, it wouldnt even have to be a dialog, just a message box would do.

------------
"You can do anything you set your mind to." Bollocks! What about the guy born with no legs who wants to be a footballer?

Spam Spam Spam

www.themattgreen.com

Share this post


Link to post
Share on other sites
Firstly, you obviously can''t switch between D3D/OpenGL without shutting what you''re currently running down and starting up the other. The data that you''re passing to the renderer remains unchanged. Just thought I''d get that out of the way

I would recommend picking a default renderer yourself (if you''re really l33t you could have your installer do a hardware test.. but that''s a bit overkill) - probably Direct3D. Then, in the Options menu of your game, have the option to change the renderer to OpenGL.

The player doesn''t want to have to select renderers and screen modes when she''s just unwrapped your spinkee new game - she wants to get in there and play it, ASAP. She many not even know what a renderer is, so the question would confuse her. You should use as many defaults as you can - but try and pick them intelligently.

Also - it''s very hard to write a generic low-level interface to both OpenGL and Direct3D. The higher you go, the easier it gets - for example, giving each renderer a DrawBSPNode() function will be easier than giving each a DoVertex() function - while OpenGL would be fine with it, Direct3D would need you to buffer the vertices until a call to EndPrimitive() - very inefficient.

Obviously, you need to know what your engine is going to do pretty damn well, if you want to go high level.

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.

Share this post


Link to post
Share on other sites
I''ve started to use wxWindows (www.wxwindows.org) which includes a wrapper for GUI controls across many platforms. With it it is really easy to make good dialog boxes so I''d recomend looking at it.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!