Video Mode Selection Screen (using irrXML)

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.

Video Mode Selection Screen (using irrXML)

Postby REDDemon » Sat Nov 27, 2010 10:55 am

This is a PopUp window that is shown when starting an irrlicht applications. It allows to choose screen resolution (and color depth of course).

When screen ratio match the ratio of your screen it is also possible to enable FullScreen and Vsync.
Actually I have implemented only several screen ratios wich are enumered:

4:3
16:9
15:9
20:9
unknown. (you can easily add more screen ratios if I forget some one)

When running your game in debug mode
(so when _DEBUG is defined) the full screen mode is turned off automatically. (this is usefull because lots of IDEs can have problem or crash while calling break points using DX drivers)

All you have todo is download the following package:
http://sourceforge.net/projects/agametemplate/files/VideoModeSelectionScreen.zip/download

All the files have to be included. main.cpp is only an example file so you don't need it.

if you want to know if something goes wrong when running this code you need only to search for "BREAK_POINT" keywords and set up a break point there with your IDE.

Image

HOW TO USE?

This is very simple.
1) Import files in your project
2) Set up break points (optional) as explained immediatly above


3) this is an example code using this class:

main.cpp:
Code: Select all
#include <irrlicht.h>
#include "IChoiceScreen.h"

//using namespaces is not obbligatory now

irr::s32 main()
{
   isgf::IChoiceScreen set;
   if(!set.choiceScreen()) //show the Video Mode selection screen
         return -1; //BREAK_POINT you exited the app

   IrrlichtDevice *device=set.createDeviceFromMe();
//now irrlicht device is initied and you can do what you want

//...

   return 0;
}


FEATURES:
the popup window is rendered with burnings video and you can select the option to don't show it again. All settings are loaded (and saved too) from a "config.xml" file wich contains additional infos about your pc.

So you can choose your favourite settings and then never warry again about that. When debugging your game, full screen is disabled. You can also set up the name of your game in the config file specifing your license type.

THANKS:

in the code there are some additional thanks to people who contributed directly or indirectly to this class.. If you want to be removed from thanks just tell me

There are lots of improvements that can be done to this class. Any suggestion from experienced programmers is wellcome. ;-)

LICENSE:
Zlib

COMPABILITY:
this code should work with any platform supported by irrlicht. If you use a compiled version without certain drivers, checkboxs referring to unsupported drivers are removed by pre-compiler directives.

An example config file generated by this code:
Code: Select all
<?xml version="1.0"?>
<config>
   <game Name="myGame" Version="0.1" Author="me" License="Zlib" />
   <screen Width="800" Height="600" ColorDepth="32" FullScreen="1" />
   <options VSync="0" Shadows="0" AntiAlias="0" ShowNextTime="0" />
   <driver Type="d3d9" />

<!--supported drivers are: d3d8, d3d9, opengl, burn, software-->

<!--
   Your System Info:
      OS version: Microsoft Windows Vista Personal Service Pack 2 (Build 6002)
      CPU speed: 2000 MHz
      Memory available: 1174836 / 2097151 KiloBytes
      Irrlicht version: 1.7.1 (Irrlicht is Copyright (C) by Nikolaus Gebhardt)
-->
</config>
Last edited by REDDemon on Mon Mar 14, 2011 12:39 pm, edited 1 time in total.
OpenGL is not hard. What you have to do is just explained in specifications. What is hard is dealing with poor OpenGL implementations.
User avatar
REDDemon
 
Posts: 832
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Postby gabdab » Fri Mar 11, 2011 8:56 am

Very nice idea.
How comes you removed files from your account on sourceforge ?
gabdab
 
Posts: 42
Joined: Fri May 12, 2006 5:11 pm

Postby Sudi » Fri Mar 11, 2011 12:24 pm

That snippet should be either added to the engine or at least be used in all tutorials that allow driver choice.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
User avatar
Sudi
 
Posts: 1603
Joined: Fri Aug 26, 2005 8:38 pm

Postby gabdab » Fri Mar 11, 2011 3:51 pm

I've been looking for a simple way to show a configuration menu .
I am afraid the only way I came up with is to restart the engine (close/reopen window) to apply screen res , driver .. user's choices.
I would use the software renderer for showing the menu ,of course.
gabdab
 
Posts: 42
Joined: Fri May 12, 2006 5:11 pm

Postby REDDemon » Mon Mar 14, 2011 8:02 am

gabdab wrote:Very nice idea.
How comes you removed files from your account on sourceforge ?


sorry i removed them since i'm working on a new version of them for irrsolid. They will be added as soon as possible. I had few problems (now solved) with source forge.
OpenGL is not hard. What you have to do is just explained in specifications. What is hard is dealing with poor OpenGL implementations.
User avatar
REDDemon
 
Posts: 832
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Postby REDDemon » Mon Mar 14, 2011 12:36 pm

gabdab wrote:I've been looking for a simple way to show a configuration menu .
I am afraid the only way I came up with is to restart the engine (close/reopen window) to apply screen res , driver .. user's choices.
I would use the software renderer for showing the menu ,of course.


Ok added the new download. It is the one I'm using in SL world editor, but with the next release of IrrSolid i will change something. Anyway there are no problems using that. IChoiceScreen is a stand alone class.

http://sourceforge.net/projects/agametemplate/files/VideoModeSelectionScreen.zip/download

You just need to include "IChoiceScreen"..

there is an example "main.cpp" in the zip folder.

this class use by default Burning video drivers . buy you can easily change to EDT_Software for a few milliseconds speed up when showing the dialog window.

edit:
updated the first post
OpenGL is not hard. What you have to do is just explained in specifications. What is hard is dealing with poor OpenGL implementations.
User avatar
REDDemon
 
Posts: 832
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Postby gabdab » Tue Mar 15, 2011 9:53 am

Very cool, thanks..
It works fluelessly, perfect.
I was trying to code a very modest imitation of yours , but didn't find a better option than using pthreads library.
I am happy to see that your implementation other than avoiding pthreads is very well coded and documented , good job.
Again thanks.
gabdab
 
Posts: 42
Joined: Fri May 12, 2006 5:11 pm

Postby serengeor » Tue Mar 15, 2011 10:12 am

It may be useful in the future 8)
Working on game: Marrbles (Currently stopped).
User avatar
serengeor
 
Posts: 1701
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania


Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 0 guests