Gamestudio Links
Zorro Links
Newest Posts
hold key code returns very high value instead of 0 or 1
by 3run
Today at 16:08
oldschool fps project
by 3run
Today at 15:46
Sam Foster Sound | Experienced Indie Game Composer for Hire
by titanicpiano14
Today at 15:02
Project Aum - Winter Contest 2017 - Update
by Ayumi
Yesterday at 22:34
[ALL STYLES] 2D Videogame Artist (pixel, vector, painted)
by DesixStudios
Yesterday at 14:45
Easy question
by jcl
Yesterday at 13:47
Cheap bouncing shells/gibs
by 3run
Yesterday at 00:36
AUM Magazine
Latest Screens
RPG PARTY
Triton Wing now available on Steam
AckCon'17: Lotter vs The World
Triton Wing
Who's Online
17 registered (Ch40zzC0d3r, Ezzett, Lobo, Hredot, AndrewAMD, 3run, alibaba, ChrstphFr, firecrest, 2 invisible), 454 Guests and 5 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
Amocfx, cme, pataba, byano, Tuguldur717
17834 Registered Users
Topic Options
Rate This Topic
#465298 - 04/16/17 10:27 How to display text with different resolutions?
preacherX Offline
Senior Member

Registered: 09/09/05
Posts: 334
Loc: Germany
What do you think would be the best way to use text in a way that it won't change its size or position when changing the resolution of the game?

Top
#465300 - 04/16/17 11:00 Re: How to display text with different resolutions? [Re: preacherX]
Ezzett Online
Junior Member

Registered: 08/26/03
Posts: 80
Loc: Deutschland
To position an object independent from the screen resolution you have to place it inside a range from 0 to 1 and multiply it by the current screen resolution.

For example, to place the upper left corner of a text at the center of the screen you would do:

pos_x = 0.5 * screen_size.x;
pos_y = 0.5 * screen_size.y;

To cut off decimals you also need to use integer:

pos_x = integer (0.5 * screen_size.x);
pos_y = integer (0.5 * screen_size.y);

I think you need to create a new font for each resolution and change it with the old font after the resolution was changed.

Top
#465322 - 04/18/17 10:55 Re: How to display text with different resolutions? [Re: Ezzett]
preacherX Offline
Senior Member

Registered: 09/09/05
Posts: 334
Loc: Germany
Thanks for the info! But the thing with the fonts is bad cause there so many different resolutions today... Is that really the only way?

Top
#465324 - 04/18/17 12:32 Re: How to display text with different resolutions? [Re: preacherX]
Ezzett Online
Junior Member

Registered: 08/26/03
Posts: 80
Loc: Deutschland
That's a general problem. When I'm creating Android apps I have to create many different layouts. For different display sizes, for landscape and normal mode and for different pixel densities. It's a pain.

Top
#465332 - 04/18/17 16:03 Re: How to display text with different resolutions? [Re: Ezzett]
jenGs Offline
Member

Registered: 07/22/10
Posts: 254
Loc: Germany
you could use a bitmap font. They can be scaled. But of course they are forced monospaced .

Top
#465337 - 04/18/17 20:41 Re: How to display text with different resolutions? [Re: jenGs]
Ayumi Offline
User

Registered: 10/12/08
Posts: 618
Loc: Germany
One way would be to change the font at runtime (with Window Fonts).

FONT* font = ...define default

... and change it, after resolution is changed

font = font_create("Arial#14"); -> if 1024
font = font_create("Arial#12"); -> if 800 (i.e)

Top
#465338 - 04/19/17 07:07 Re: How to display text with different resolutions? [Re: Ayumi]
txesmi Offline
Serious User

Registered: 06/13/07
Posts: 1054
Loc: Hiporope and its pain
If you own a commercial or higher license, you might render the panels of the largest resolution over their render targets, scale them down by a shader and show those downsampled bitmaps on other panels. Buttons and sliders should be set on last panels.

Top
#465386 - 04/22/17 22:46 Re: How to display text with different resolutions? [Re: Ayumi]
Dooley Offline
User

Registered: 05/12/05
Posts: 518
Loc: Chicago, IL
Originally Posted By: Ayumi
One way would be to change the font at runtime (with Window Fonts).

FONT* font = ...define default

... and change it, after resolution is changed

font = font_create("Arial#14"); -> if 1024
font = font_create("Arial#12"); -> if 800 (i.e)


Hmmmm.... I can't seem to get this to work. Have you done this successfully?
_________________________
Check out "Star Explorers" on Indiegogo:
https://www.indiegogo.com/projects/star-explorers-space/x/17324659#/

Anomalies released on Steam: http://store.steampowered.com/app/546780


Top
#465387 - 04/23/17 00:59 Re: How to display text with different resolutions? [Re: Dooley]
Ayumi Offline
User

Registered: 10/12/08
Posts: 618
Loc: Germany
Sure

Code:
#include <acknex.h>
#include <default.c>
#include <atypes.h>
#include <d3d9.h>
#include <litec.h>

// Call this, if your font is not default Window Font like Arial...
void AddFontType(STRING* name)
{
 	int res = AddFontResource(name);
   if(!res)
        printf("Font %s not found....", name);
}

// ...in Main function
AddFontType("XerosTheorem.ttf");

// Declare your Fonts
FONT* FontMenuMain = "Xero's Theorem#36";
FONT* FontMenuSub = "Xero's Theorem#28";


// Call this after switched Resolution
// MnuSettings.Resolution is an integer in a struct (7,8,9...)
// Override Fonts 
void CreateFont()
{
	// Fonts für den Auflösungswechsel neu erstellen
	
	switch(MnuSettings.Resolution)
	{
		case 1:
		case 2:
			FontMenuMain = font_create("Xero's Theorem#29");
			FontMenuSub = font_create("Xero's Theorem#23");	
			break;
		
		case 3:
			FontMenuMain = font_create("Xero's Theorem#36");
			FontMenuSub = font_create("Xero's Theorem#28");			
			break;
	}	
}


// Use it at runtime like this...
pan_setdigits(MnuPMainScreen, mainDigNum[0], mainDigPosXY[0][0],mainDigPosXY[0][1],StrBtnMnuMission, FontMenuMain,1,0);


Top
#465390 - 04/24/17 05:49 Re: How to display text with different resolutions? [Re: Ayumi]
Dooley Offline
User

Registered: 05/12/05
Posts: 518
Loc: Chicago, IL
Thanks, I will try this out!
_________________________
Check out "Star Explorers" on Indiegogo:
https://www.indiegogo.com/projects/star-explorers-space/x/17324659#/

Anomalies released on Steam: http://store.steampowered.com/app/546780


Top


Moderator:  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | resources | magazine | manual | support faq | bugs

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) 3dgamestudio.net