Jump to content

View more

Image of the Day

#ld38 #screenshotsaturday Mimosa Fizz action gif #2 https://t.co/TUzdppvfUL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

GUI Scaling

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 James Leighe   Members   


Posted 24 June 2013 - 03:50 AM

I'm wondering what the best way to scale GUI elements to different resolutions would be.

I'm using relative sizing and all that for the elements, but the problem is the fonts. I cannot just simply scale the fonts as it will make them look very blurry in all but the 'correct' resolution (or x2 etc.) unless maybe the fonts are very large.


The only thing I can think of at the moment would be to have multiple pre-configured gui sizes that you have set up and tweaked and choose the closest one to the current resolution, but then again you are going to end up with slightly different gui sizes between the presets and it will be somewhat inconsistent even still because of how fonts tend to look different at different point sizes.


Any ideas would be much appriciated!


I guess another option is to just not worry about it and create a GUI for a common middle-ground resolution and let it get big/small depending on the user end resolution.

Edited by James Leighe, 24 June 2013 - 03:51 AM.

#2 Waterlimon   Members   


Posted 24 June 2013 - 05:06 AM

You could just use the biggest font that is smaller than the ideal size for the asked gui.

So if i just realize a bit the font won't change and will just take less space, but if i reside more it will eventually switch to a larger size.


#3 Aressera   Members   


Posted 24 June 2013 - 08:45 PM

My resolution-independent GUI uses a dynamic texture atlas of glyphs which is automatically populated with the most recently used characters as they are needed. I use Freetype to generate the glyph textures and they are placed in atlas textures corresponding to the desired font size, generally with a separate atlas for 8pt, 16pt, 32pt, etc fonts.


At runtime, the renderer picks the smallest previously cached glyph to use (or adds a new glyph to the atlas) that is not more than double the requested font size. You need a hash map cache from character ID to glyph entries, each of which contains a list of pointers to the atlas textures for the different sizes for the glyph. The renderer then builds a vertex buffer of quads/texture coordinates which it renders.


This way, you can build your GUI at some standard resolution, and then apply a scale factor to all sizes/positions when operating at different resolutions that produces a pixel-perfect result.

#4 Norman Barrows   Members   


Posted 26 June 2013 - 08:06 AM

i discovered that d3dxfonts are SLOW, so i replaced them with d3dxsprites, which scale quite nicely and are much faster.


one approach to resolution independant GUI components:


a virtual 10000x10000 screen coordinate system. all gui routines (sprites, text, etc) convert the virtual coords to current rez before drawing.


so you code:

txt(5000,5000,"Hello world");

and it draws "Hello world" in the middle of the screen, whether you're in 1024x768, 1200x900, or whatever.


this really is the slickest way to go. but usually a project has already been hardcoded to some rez, which means fixing a lot of rez dependent code.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"







#5 Vortez   Members   


Posted 27 June 2013 - 03:31 PM

I generally use a FBO for this (OpenGL). Render the scene at a fixed resolution, then render the screen texture to a quad that stretch to the entire screen.

Might not work for old computer though.

Edited by Vortez, 27 June 2013 - 03:32 PM.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.