Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 945 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to display text with different resolutions? #465298
04/16/17 08:27
04/16/17 08:27
Joined: Sep 2005
Posts: 352
Germany
preacherX Offline OP
Senior Member
preacherX  Offline OP
Senior Member

Joined: Sep 2005
Posts: 352
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?

Re: How to display text with different resolutions? [Re: preacherX] #465300
04/16/17 09:00
04/16/17 09:00
Joined: Aug 2003
Posts: 118
Deutschland
E
Ezzett Offline
Member
Ezzett  Offline
Member
E

Joined: Aug 2003
Posts: 118
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.

Re: How to display text with different resolutions? [Re: Ezzett] #465322
04/18/17 08:55
04/18/17 08:55
Joined: Sep 2005
Posts: 352
Germany
preacherX Offline OP
Senior Member
preacherX  Offline OP
Senior Member

Joined: Sep 2005
Posts: 352
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?

Re: How to display text with different resolutions? [Re: preacherX] #465324
04/18/17 10:32
04/18/17 10:32
Joined: Aug 2003
Posts: 118
Deutschland
E
Ezzett Offline
Member
Ezzett  Offline
Member
E

Joined: Aug 2003
Posts: 118
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.

Re: How to display text with different resolutions? [Re: Ezzett] #465332
04/18/17 14:03
04/18/17 14:03
Joined: Jul 2010
Posts: 283
Germany
J
jenGs Offline
Member
jenGs  Offline
Member
J

Joined: Jul 2010
Posts: 283
Germany
you could use a bitmap font. They can be scaled. But of course they are forced monospaced .

Re: How to display text with different resolutions? [Re: jenGs] #465337
04/18/17 18:41
04/18/17 18:41
Joined: Oct 2008
Posts: 679
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 679
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)

Re: How to display text with different resolutions? [Re: Ayumi] #465338
04/19/17 05:07
04/19/17 05:07
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
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.

Re: How to display text with different resolutions? [Re: Ayumi] #465386
04/22/17 20:46
04/22/17 20:46
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline
User
Dooley  Offline
User

Joined: May 2005
Posts: 868
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?

Re: How to display text with different resolutions? [Re: Dooley] #465387
04/22/17 22:59
04/22/17 22:59
Joined: Oct 2008
Posts: 679
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 679
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);


Re: How to display text with different resolutions? [Re: Ayumi] #465390
04/24/17 03:49
04/24/17 03:49
Joined: May 2005
Posts: 868
Chicago, IL
Dooley Offline
User
Dooley  Offline
User

Joined: May 2005
Posts: 868
Chicago, IL
Thanks, I will try this out!


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1