Gamestudio Links
Zorro Links
Newest Posts
How to keep track of Memory usage
by jumpman
Today at 04:55
Zorro 1.58 trades in phantom mode instead of demo?
by jrath
Today at 02:51
DeepLearn: How to add more signals? (> 20 signals)
by Se7en
Yesterday at 23:54
Are M1 history price still updated from FXCM
by ytc
Yesterday at 23:54
More than One "File_Open_Read" - Problem?
by Dooley
Yesterday at 23:51
AUM Magazine
Latest Screens
Triton Wing
ZeaL
Computer Repair Simulator
Collider (working title)
Space Rider
Who's Online
15 registered (Ayumi, 20BN, Calli, Dooley, mk_1, pegamode, PadMalcom, Dalla, 3 invisible), 422 Guests and 4 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
defghi296516, serran0, michal_p, francismake, sqirtle
17663 Registered Users
Topic Options
Rate This Topic
#465298 - 04/16/17 10:27 How to display text with different resolutions?
preacherX Offline
Member

Registered: 09/09/05
Posts: 288
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 Offline
Junior Member

Registered: 08/26/03
Posts: 61
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
Member

Registered: 09/09/05
Posts: 288
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 Offline
Junior Member

Registered: 08/26/03
Posts: 61
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: 247
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 Online
User

Registered: 10/12/08
Posts: 599
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
User

Registered: 06/13/07
Posts: 979
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 Online
Senior Member

Registered: 05/12/05
Posts: 461
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 Steam:
http://store.steampowered.com/app/502720/Star_Explorers/

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 Online
User

Registered: 10/12/08
Posts: 599
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 Online
Senior Member

Registered: 05/12/05
Posts: 461
Loc: Chicago, IL
Thanks, I will try this out!
_________________________
Check out "Star Explorers" on Steam:
http://store.steampowered.com/app/502720/Star_Explorers/

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 | beta features

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