Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Inconsistant Text Sizes

Author
Message
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 29th Oct 2011 15:06
This really is a noob issue. Cant beleive i cant work out whats happening with this one but if i get an explanation i might understand.

The desired effect is a text size which is consistant in proportion with the screen resolution. If i just set the text size it would be the same for everyone which is no good as folk with huge monitors would struggle more to see smaller text.
When using maximize window it stretches the text (whether i use print of text so ive used print for ease of example)

Maximize Window
Print "Hello"
Wait Key

This is ugly as sin on my 1900 X 1200 24" monitor but does make text bigger so in effect works. How can i do something like this but keep it neat and consitantly proportionate without it looking shockingly ugly. The aim is for it to be readable and look good on all monitor and resolution types while staying within bounadries (for example if i broke the screen up with lines in the middle using each side as its own individual "page")

Thanks in advance.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 29th Oct 2011 17:26
Assuming a default resolution of 1024x768 you could do something like
SET TEXT SIZE 16.0 * (SCREEN WIDTH() / 1024)
if you like the text to represent the same width as 16px on a 1024 pixels wide display.

Since resolutions may differ in the aspect ratio as well, you'd have to decide on using either the width or the height since (with the built-in text functions) you can't edit their width and height independently.


"Why do programmers get Halloween and Christmas mixed up?"
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 29th Oct 2011 18:08
You could always force them to all use the same resolution with the SET DISPLAY MODE command. With full screen working (non-windows mode) not many people would notice the resolution was different than their normal setting.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 30th Oct 2011 01:01
Unfortunately i could not get it to look any better using that equation. As Screen Width / 1024 (or desktop width if that were the case) is 0 so it wasnt changing anything.

You see the problem i have is i cant figure out what the text will look like when its displayed on different resolutions. Arial 12 for example should be bigger on screens that are larger even if they are running much higher resolutions. There must be something more solid.
When i play i game (i have a 24" running at 1920 * 1200) all the text would be different on something like an RTS than it would on my small 15" laptop with completely different resolution, screen size AND aspect ratio, but for some reason the text would be in proportion. If i had some stats hovering over an rts tank when you click on it for instance it might look a bit mad if the text were big and bulky on one machine, but might look nice and neat on another. How do you get consistant proportional sizes yet allow the user to pick his own resolution.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 30th Oct 2011 01:19
I'm not sure why 1920 / 1024 became 0; but generally you need to convert the numbers to floats. 1000 / 2000 will be zero, 1000.0 / 2000.0 will be 0.5. Multiply 0.5 by the default font size and you have a half sized font.

If you are after something more perfect, along the lines of character labels and event indicators that tracks the position and distance of players and provides information about them; standard text commands will not look as good as text printed on textures on 3d plains or the antialiased text in the D3DFunc plugin.

Wide screen monitors will still cause the font to look wider even if you use D3DFunc; you have to size up the width and the height seperately to make it perfect. Obviously that needs image manipulation. Functions for adjusting the font width just wasn't provided.

At least with 3d plains, there is no need to resize fonts; since the 3d is going to be in proportion to the camera and the character distance. You just make the textured plain above the character. With these you have to draw text to a bitmap and convert it into a texture; or map a series of letters to different UV coordinates every time a new character appears; or before the game.

I feel that most people use either 4:3 ratio or a widescreen; so another option could be to use two seperate fonts, it's up to you really.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 30th Oct 2011 11:25
What is that D3dFunc. I found this http://forum.thegamecreators.com/?m=forum_view&t=69221&b=5 but dont really understand how it is used or what uses it has.

I think i understand about how to do what you said though to a degree. Make the appropriate text. Turn it into a texture, texture a plain with it and position the plane above the object. Not sure how it would be transparent though if thats what you wanted, so you only see the text and not the shape of the plane that is holding it. also wouldnt be sure how to calculate how big the plane needs to be to hold the text properly as longer text would obviously require a bigger plane.

My comp runs at 1920 X 1200 so thats a 16:10 ratio which is less common than 16:9 (which on monitors i hate, i now use my 22" 16:9 for a second monitor that is rarely used as it just sometimes looks silly) or 4:3 so i suppose i would perhaps have to find out beforehand what ratio someone was running out of the 3 then base everything around that. I see what you mean about the different ratios causing different effects no matter what as width cant be changed, so as long as everything was roughly in proportion i would be happy. I wouldnt want something to look good on mine but totally mess up (or be half off the screen or anything) on other peoples.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 30th Oct 2011 13:15
D3DFUNC is a plugin DLL by Cloggy which has antialiased text functions to replace the standard pixelated text functions. It also has additinal drawing functions and text functions that work faster than the DBPRo drawing commands. (It also has some extra 3d commands; it stands for Direct3d Functions because it calls the DirectX 3d commands directly, instead of going through DBPRO. Advanced2d (Box2d) seems like it has smooth text drawing as well, but I have never used it; only because I'm not using DBPRO for my game; but it also has text paragraph formatting functions, a nice feature for a complex GUI.

Quote: "how it would be transparent though if thats what you wanted, so you only see the text and not the shape of the plane that is holding it"


You have to use a transparent bitmap mode (24 or 32bit) to draw on; and you have to set [SET OBJECT TRANSPARENCY] on the plane. I get the feeling they use this tecnique in WOW, not that I play it but because its screenshots contain character label sizes according to object distance; if they do use functions to resize fonts in 2d I'd be shocked because there can be 100s of characters on the screen at once.

There is a mathematical problem with this however, you have to rotate the plain according to the camera angle; not just a matter of using Point Object. You'd need to locate the Billboard algorythm on the forum to handle that. I do not know it; but I did see one used in one of the Shader packs. The extends plugin and the particle effects use them too.

Quote: "wouldnt be sure how to calculate how big the plane needs to be"

The engine will work it out for you; in texture coordinates you work with ratios not pixels. So with UV ratios, position 0,0 is top left, 1,1 is bottom right, 2,2 would paste 2 textures across and 2 down on a surface, and so on. So you just create your texture, and the engine will stretch the texture to the plane size; which can be set as the Text Width(), Text Height() results * desired scale; or you can paste the text inside a texture and workout the ratio and use [scale object texture].

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 30th Oct 2011 13:29
Thanks for the info Chris, seem to be learning quite a lot lately hoping to put some things together soon enough.

Just a simple question about UV co ordinates. Im not 100% sure what they are but hear them mentioned a lot. From what i have gathered they are the x, y position of a 2d image that wraps itself onto a 3d object and so called U and V and not x, y because x, y is already taken by the 3d objects x, y position in space. Is this correct?
If it is im still a little unsure of why you need to know them or what you can do with this knowledge of whatever the U and V co-ordinate is on an object. I just thought you slap a texture on a surface (the face of a polygon) and thats that, obviously its a little more complex than that.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 30th Oct 2011 15:56
Yeah, the U V are the X and Y of texture coordinates.

You can just make sure your text spans the width of the texture.

Every vertex has a UV setting, so if your text on the left of the texture is half the size of the texture, it will fill half the plane unless you scale the texture down; thus the U coordinate on the right edge which is 1.0, will become U 0.5, which is the same as the horizontal middle pixel in your texture.

But this is not important, because if you central align your text in the texture, there is no need to mess around with UV coordinates, the player does not know that he/she is looking at a plane, as far as they can see it is text; or a progress bar or what ever yo draw on a transparent object.

If you need to learn more about UV coordinates, it is best understood when you play around with scale object texture function and UV editing in Blender (which for reference is what you use).

Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 30th Oct 2011 17:58 Edited at: 30th Oct 2011 17:59
You can always just disable the maximize window button >=)

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 30th Oct 2011 18:22
Quote: "If you need to learn more about UV coordinates, it is best understood when you play around with scale object texture function and UV editing in Blender (which for reference is what you use)."
I look forward to that when i get up to that part of my blender training, it will hopefully give me a little bit of insight into what is going on with the relationship between textures and their models. Thanks.
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 30th Oct 2011 22:11
Text is relative to the resolution Screen Width()/height(). So when you maximize it, you stretch it. Best option is to detect the best resolution (Takes around 7 lines of untruncated code) then set display mode to that. Then place your text. If you need to upscale your fonts, set your text size relative to the resolution (like what was mentioned earlier in this thread). But remember that the default font ALWAYS looks really ugly at large sizes. Arial's the best option in terms of appearance vs compatibility. Set it to Arial and try up-scaling it.

Login to post a reply

Server time is: 2024-11-22 12:06:02
Your offset time is: 2024-11-22 12:06:02