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.

How to get monitor width and height

Postby Asimov » Tue Oct 10, 2017 11:33 pm

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?
User avatar
Posts: 221
Joined: Thu Dec 04, 2014 7:41 pm

Re: How to get monitor width and height

Postby CuteAlien » Wed Oct 11, 2017 12:49 am

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:

cpp 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 = 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
Code snippets, patches&stuff:
Free racer created with Irrlicht:
User avatar
Posts: 8468
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Return to Beginners Help

Who is online

Users browsing this forum: No registered users and 1 guest