Gamestudio Links
Zorro Links
Newest Posts
CSV to Tick import problem
by pcz
Today at 16:40
An Introduction to Algorithmic Trading: Basic to Advanced Strate
by yosoytrader
Today at 16:25
Square Root Rule & Additional Investment
by DdlV
Today at 15:15
What are you working on?
by painkiller
Today at 12:55
Support and Resistance Zones/Cluster
by sdh309795gaas
Today at 05:22
AUM Magazine
Latest Screens
Triton Wing
ZeaL
Computer Repair Simulator
Collider (working title)
Space Rider
Who's Online
15 registered (Denn15, painkiller, MatPed, Fiber, alibaba, firecrest, 3dgamelight, Iglarion, Matt_Aufderheide, pcz), 465 Guests and 5 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
Marce, pascalx, SpaceNL, onlinejack, johnnyp
17716 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: 304
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: 68
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: 304
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: 68
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: 612
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: 994
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
Senior Member

Registered: 05/12/05
Posts: 499
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 Offline
User

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

Registered: 05/12/05
Posts: 499
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