Choosing a Renderer

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
pex
Posts: 16
Joined: Sun Mar 28, 2004 11:51 am

Choosing a Renderer

Post by pex »

Hi.
I want my game will find the best renderer automatically, so i took the GetDXVersion function from my old DX9.0b sdk.
The problem is that it doesnt work (i copied-and pasted it to the game project).
thats how i call it: GetDXVersion(&dwDXVersion,0,0).

So I was thinking...what happen if the user has DX8.1 and I create the device with EDT_DIRECTX9?
I mean, does it return NULL and what happen in the program itself? it won't crash or slow down a lot, right?

Last thing, OpenGL must be at least 1.2 so createDevice won't return 0 (when setting to EDT_OPENGL)?
And DirectX must be at least 8.1 in EDT_DIRECTX8 and 9.0c in EDT_DIRECTX9?
or, for example EDT_DIRECTX8 will work on 8.0 and EDT_DIRECTX9 may work on 9.0a?

Thanks,
pex.
Guest

Post by Guest »

how about:
(psuedo code)

if(!(createdevice(DX9)) // if failed
if(!(createdevice(DX8)) // if failed
if(!(createdevice(OGL))//if failed
// error message OR fallback to software.

This way you specify the order of preference for the driver. If DX9 is not found dx8 is tried then OGL and as a last resort software.. though it would probably be better to just quit the app with an error message there as software probably won't do what you want your game to do.

the if statements (!) not - will be true if the creation failed (which it will if the dx version is not found) and automatically try the next.
Picard
Posts: 9
Joined: Sun Jul 03, 2005 2:59 pm

Post by Picard »

hi
I recommend that you let the user decide which renderer he wishes to use..
I do this with a config-file

config.cfg:

Code: Select all

[video]
; select a driver typ:
; driver_type = SOFTWARE | DIRECTX8 | DIRECTX9 | OPENGL
driver_type=DIRECTX9

; supported resolutions:(800x600 | 1024x768)
; only integer values are allowed!
screen_width = 800
screen_height = 600

;this should have value 16 oder 32
screen_bpp =32

fullscreen=false
stencilbuffer=true
on the web I`ve found a very nice config read-class that is very easy to implement: http://www.adp-gmbh.ch/cpp/config_file.html

for example... read out the video mode:

Code: Select all

ConfigFile cf("config.cfg");
std::string videomode;
videomode = cf.Value("video","driver_type");
now the string "videomode" contains the value... play around with that, it`s very amazing ;)
pex
Posts: 16
Joined: Sun Mar 28, 2004 11:51 am

Post by pex »

@Guest, I know this. thats why i asked if it won't crash or slow down. so i guess it won't, thanks!
@Picard, When the user is first run the game I dont want to decide what renderer it'll use or let him choose himself (not from config.ini, its possible that he won't understand what is a renderer or which to pick up or what is 'that' renderer. and i dont know someone who open config.ini before the game itself :) ), so the game will have to choose the renderer automatically at first.
Picard
Posts: 9
Joined: Sun Jul 03, 2005 2:59 pm

Post by Picard »

pex wrote:and i dont know someone who open config.ini before the game itself :)
me ^^
but in your case guest`s solution would be the best one ;)
TheRLG
Posts: 372
Joined: Thu Oct 07, 2004 11:20 pm

Post by TheRLG »

Well I pretty much use one of two approaches that you generally see in most commercial video games, so here's how I would do it.

You have the main game application, mmk?
Well have another application just for the basic config.
On the first time the game is run.. check to see if theyve configged yet, can store than in a simple variable in a text file or whatever.
If they haven't configged, you run the config application and quit the game.
Then, they go thru the config application and can run the game.
Now in this config application, u should do ur auto-detection crap and see which renderer u can use, and highlight the preferred one in a list box or something.

other option being just running the config thing every time u play the game like in MOHPA.
Post Reply