Screen sizes and 2D graphics

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:

Screen sizes and 2D graphics

Post by Asimov »

Hi all,

In previous games I have made I have stuck to a rigid screen size because that is easier.

Now this new game I am making I have so far got a screen size of 800 * 600 which is good size for a game where you want to play it on the side while doing
other things, but I am thinking of giving other screen size options.

Now the problems are I am thinking mouse coordinates. Say I set up an icon for clicking on and then change screen dimensions, then the mouse would no longer be detected in that range?

Also is it best for set sizes. I mean if you went full screen, you are never going to know the clients screen size. The game might look great one one screen and how would you know how to size 2D images to the screen size, and positioning and stuff, also again the mouse coordintes.

I wonder if anyone has thoughts on this? Before I start making all my 2D images for the game.

I don't think I will be using the built in gui system, be cause I want my menu to look different from the standard gui.
Plus I haven't worked out how to do the gui yet LOL.

I built everything from scratch in a prevous engine where I made a missile command game.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Screen sizes and 2D graphics

Post by hendu »

Don't use absolute coordinates, use relative coordinates and scale your UI. So this image is always 10% screen height, mouse coords from 0 to 1, and so on.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Screen sizes and 2D graphics

Post by CuteAlien »

You can make the built in gui look pretty different. Before you start doing the stuff like resizing and handling mouse-clicks all by hand... the gui does just that. Thought I would recommend using svn trunk of Irrlicht which has improved the 2d image drawing and button drawing a lot compared to Irrlicht 1.8 (I needed some more features myself, so I had added some stuff a few months ago).

The Irrlicht gui-elements have support for different layout sizes. The idea is that you have one background element - and all it's children elements are resized together with. The way of resizing depends on alignment flags which you can set for each corner of each element. So you can say elements scale with the parent. Or you can say an element always stays at the same distance to the border.

And if you need custom gui-elements at some point you can still add them - the Irrlicht gui-system allows for that.

The only part which will be some trouble is rotating images - Irrlicht gui has no support for that so far.
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
Asimov
Posts: 246
Joined: Thu Dec 04, 2014 7:41 pm
Contact:

Re: Screen sizes and 2D graphics

Post by Asimov »

Hi CuteAlien,

Thanks. I haven't really played with the gui yet. Will make it my next port of call I think.
I know how to size my screen when the game first starts up, but can I say put in a menu for choosing screen size, and then change it on the fly?

@Hendu:

I presume what you mean is if I have a screen which 800px wide and my image is at 400px then that is 50%, and then my screen changes to a 1000px wide, 50% of that is 500px.
Not sure how the graphics would scale in that instance though.

I think I am going to look into this gui now.

Oh and I have to get text and fonts to work next as well LOL.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Screen sizes and 2D graphics

Post by CuteAlien »

Changing resolution on the fly is hard - especially in fullscreen mode. There are 2 ways to do that. One is to save every information you need - and then destroy and restart your device and re-create whatever you had before. The other way is to use the screenresolution of the desktop, but to render to a textures in other resolutions. And then in the last step always show that texture fullscreen - so it scales. Thought I don't know if the gui will handle that well (I never did that yet myself).

My own solution so far is - I save the resolution change to a config file and tell the user to restart the game. I know it's not nice... but well, it works. Will code it nice when I have lot's of time (next life or so...).
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