Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  The Last Word in Text Rendering  (Read 12622 times)
0 Members and 1 Guest are viewing this topic.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #30 - Posted 2007-01-09 02:19:24 »

It's easy enough to transform screen-coordinated to world-coordinates yourself.

The text is on a plane, just translate/scale/rotate until it fits your needs. (if you render the text at 0,0 it's easiest)


Let's say the bounding-rectangle of the text in screenspace is: (0, 0) (250x24)
Normalize vertices to (0, 0) (1x1) by scaling (1/w, 1/h)
As we're dealing with 3D now, we can as well add the Z (it is 0), (0, 0, 0) (1x1x0)
Which size do we want in world-coordinates? Let's say: 0x105x11cm, positioned at 143x168x78cm from the origin

1  
2  
3  
4  
5  
6  
7  
glPushMatrix();
glTranslate(1.43f, 1.68f, 0.78f);
glRotatef(90, 0, 1, 0);
glScalef(1.0f, 1.0f/250, 1.0f/24);
glScalef(1.0f, 1.05f, 0.11f);
   renderText();
glPopMatrix();

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #31 - Posted 2007-01-09 04:21:24 »

My basic point is this: what should the specification of the class say about the units in use in this scenario, compared to the orthographic, unscaled case? Do you want to specify a scale factor to be applied to both the width and height of the 3D rectangle? If you don't specify one (for example, if you normalize the rectangle to size (1, 1)), different lines of text will be rendered with different scales. What exactly should the new draw3D() method take as arguments, and what should the javadoc specification look like?
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #32 - Posted 2007-01-09 04:59:56 »

You don't normalize (0, 0, xEnd, yEnd) which results into each line having another scale (y axis)
if you normalize (xOff, yOff, xEnd, yEnd) to (0, 0, 1, 1), all lines have the same Y-scale.



The TextRenderer utility-class maybe shouldn't be too generic?
If people want text in their scene, they probably need 3d text anyway, or if they
want to project it: RTT using TextRenderer without any transformations.

(alpha blended) 2d text in the middle of your scene looks crap anyway.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #33 - Posted 2007-01-09 20:53:37 »

BTW, bienator, I couldn't PM you (full inbox? I've notified the admin) but send me an email with no attachment if you sent me something and didn't get a reply. My work email blocks mail with .zip attachments, for example.
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #34 - Posted 2007-01-13 22:36:27 »

A new TextFlow demo has been checked in to the jogl-demos workspace which shows how to do dynamic text layout and how the TextRenderer handles it. A significant number of bug fixes and robustness improvements have gone into the TextRenderer and implementing classes as a side-effect of this, and it hopefully should "just work" in many more cases.

emzic: if you have a chance, could you retry your program with a nightly build dated 1/14 or later? I'd like to make sure I didn't introduce a bug which impacts your app.

We'll look into the issue of 2D text placement in 3D soon, hopefully next week.
Offline emzic

Senior Duke





« Reply #35 - Posted 2007-01-14 13:44:51 »

ok, i will give it a try soon and report back here. thanks for the update!

edit: ok it works. nothing seems to be different as before. is there anything special i should look out for?

www.embege.com - personal website
webstart blendinspect - OpenGL BlendingModes visualization.
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #36 - Posted 2007-01-16 07:09:12 »

edit: ok it works. nothing seems to be different as before. is there anything special i should look out for?

No, just making sure nothing was broken. Thanks.
Offline zingbat

Senior Duke




Java games rock!


« Reply #37 - Posted 2007-01-17 16:32:37 »

This is exactly what i was looking for, but how good is it? For example, can we render small sharp text with pixel precision like the letters in this post and do you have any screenshots?
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #38 - Posted 2007-01-17 17:24:19 »

A picture is worth a thousand words...



This demo is checked in to the jogl-demos workspace under demos.j2d.TextFlow. On-line web start demos of this and other new stuff are coming.
Offline zingbat

Senior Duke




Java games rock!


« Reply #39 - Posted 2007-01-17 18:32:25 »

Thats really Impressive. Congratulations.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #40 - Posted 2007-01-17 18:37:22 »

Thanks. Please try it and let us know how it works for you.

By the way, if anyone wants to see how the caching algorithm works, run the TextFlow demo with -Djogl.debug.TextRenderer and it will display both the on-screen rendering results as well as the contents of the backing store in a second window. It's interesting to watch.
Offline bienator

Senior Duke




OutOfCoffeeException


« Reply #41 - Posted 2007-01-17 19:44:20 »

Good work!

I have tested the demo (and added some random numbers as separate text Grin) and its running very smooth. The only thing I noticed is that the caching algorithm resizes the texture sometimes very often in a short period of time. To prevent this I would recommend to add (if possible) a time delay before the cache texture size could be decreased next time.
but again good work Wink

Offline Ken Russell

JGO Coder




Java games rock!


« Reply #42 - Posted 2007-01-17 21:47:07 »

The only thing I noticed is that the caching algorithm resizes the texture sometimes very often in a short period of time. To prevent this I would recommend to add (if possible) a time delay before the cache texture size could be decreased next time.

Thanks for the suggestion. I've filed Issue 261 to track this. If you have a modified test case which shows the poor behavior, please attach it to the bug report.
Offline zingbat

Senior Duke




Java games rock!


« Reply #43 - Posted 2007-01-19 19:27:19 »

This is probably a naive question but do you think that your render algorithm will work with Unicode fonts?

I presume that eclipse can work with unicode chars but i never tested it myself.

For a list of free unicode fonts check this pages:

http://en.wikipedia.org/wiki/Unicode_fonts
http://en.wikipedia.org/wiki/List_of_typefaces#Unicode_fonts

This one looks nice:

http://en.wikipedia.org/wiki/DejaVu_fonts
http://dejavu.sourceforge.net/wiki/index.php/Testing
http://dejavu.sourceforge.net/wiki/index.php/PDF_samples
http://dejavu.sourceforge.net/wiki/index.php/Main_Page

It's allways nice to know that we can translate our game or application to a load of different languages in their native charset.


Offline Ken Russell

JGO Coder




Java games rock!


« Reply #44 - Posted 2007-01-19 21:36:50 »

A major goal of this TextRenderer was complete Unicode support and I can basically guarantee that it will work properly. The String-by-String caching algorithm has been vetted by Sun's Java 2D font expert, Phil Race, and was informed by his advice. It would be possible to also get complete Unicode support by dynamically caching individual rendered glyphs, but the algorithms involved are more complicated and we haven't yet seen a strong need to go this route. For the cases where the String-by-String approach works well, it will also be faster than glyph-by-glyph caching and rendering.
Pages: 1 [2]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (41 views)
2014-10-17 03:59:02

Norakomi (33 views)
2014-10-16 15:22:06

Norakomi (26 views)
2014-10-16 15:20:20

lcass (30 views)
2014-10-15 16:18:58

TehJavaDev (59 views)
2014-10-14 00:39:48

TehJavaDev (60 views)
2014-10-14 00:35:47

TehJavaDev (50 views)
2014-10-14 00:32:37

BurntPizza (66 views)
2014-10-11 23:24:42

BurntPizza (38 views)
2014-10-11 23:10:45

BurntPizza (80 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!