How to get monitor width and height

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
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

How to get monitor width and height

Post by Asimov »

I have been running my game at 800*500 in a window, so recently I tried full screen mode.
Now my laptop monitor is 1600*900 so I set my full screen to this and the resolution looks excellent.

My question is this. Is it possible to get the monitor resolution so full screen will work on any size monitor?
Can you change the size of resolution with some kind of menu from within the game?

What are the best practices for going full screen on a monitor you have no idea of the size?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: How to get monitor width and height

Post by CuteAlien »

You can create a null device (video::EDT_NULL) first (which doesn't create a Window but allows you to call some stuff). And from that you can get the info, like that:

Code: Select all

 
IrrlichtDevice *dummyDevice = 0;
dummyDevice = createDevice(video::EDT_NULL,core::dimension2d<u32>(100,100),false,false);
if ( dummyDevice )
{
    video::IVideoModeList *videoModes = dummyDevice->getVideoModeList();
    core::dimension2d<u32> desktopRes = videoModes->getDesktopResolution();
    s32 desktopDepth = videoModes->getDesktopDepth();
    
    dummyDevice->closeDevice();
    dummyDevice->clearSystemMessages();
    dummyDevice->drop();
    dummyDevice = 0;
}
 
You can't change fullscreen resolution without creating a new device. But you can always create the size of the desktop. And then render any resolution you want to a render-target texture (RTT). Then in next step you put that rendertargettexture on node which has fullscreen size. (check XEffects - it should have that kind of node - if not ask again - there was some node like that on forum in code-snippets from Hendu I think - but I'd have to search myself first as I don't rember name right now).
Actually this way will also be useful in the long run if you decide to add any kind of fullscreen effects (like bloom or similar stuff).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply