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 (575)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Java AWT Font and JOGL: 3D text with display lists and VBO's  (Read 4725 times)
0 Members and 1 Guest are viewing this topic.
Offline Aaron_Anderson

Senior Newbie




perception is reality


« Posted 2006-07-09 19:32:03 »

I have been messing around with using Java Fonts and rendering them using JOGL. I got a lot of ideas from the code at http://lwjgl.org/forum/viewtopic.php?t=1430 I use a PathIterator from  GlyphVector from the text/font combo to get an outline and use a GLUtessellator to create the polygon text.  For 3D text a mirror of the polygon text is writen at depth z and then the sides are drawn based on the outline.

I have a display list for 2D text  and display lists and VBO's for 3D extruded text. I am going to attempt to refactor the tesselator callback to store all the vertices in one big array and then use seperate array indices for the top, bottom, and sides of the text since the current implmentation uses triangle arrays so there is effectively no vertice reuse. Rename the txt file to zip and rename the packages as needed.



Offline Aaron_Anderson

Senior Newbie




perception is reality


« Reply #1 - Posted 2006-07-14 17:48:02 »

I have updated this code by dropping the display list and the single vertex use VBO. Now There is a VBO vertex array that contains the vertices for the text polygon at z=0 and the vertices for the text at z=depth. There is also now a seperate index array VBO that contains triangle array vertices for the text at z=0, z=depth, and indices for the sides. Together these two VBO's are used to draw the triangles to the screen in hopefully a bit more efficient manor. I have also added 2D functionality.

Instead of straight depth based extrusion I would have liked to have use evaluators for nice curved 3D text but that is beyond my capabilities so this is pretty much it. Save VBOFontTesselator.txt as a .zip


Offline bahuman

Junior Duke





« Reply #2 - Posted 2006-07-15 13:33:52 »

First off, thanks for your code!
I'm very interested in your VBOFont classes, because I want to learn about VBO's and I want to learn about having fonts inside my apps  Smiley

I decided to do some stresstesting, and I fed a 9K text to your tesselator.
I must admit I'm too lazy to get a profiler going at it  Roll Eyes but I peppered your code with a few System.currentTimeMillis()
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
before read file: 1152966958906
after read file: 1152966958921
before create glyphVector: 1152966959078
after create glyphVector: 1152966959125
after getOutLine: 1152966978359
after path iterator: 1152967186109
#closes = 9875
#cubics = 0
#lines = 41342
#moves = 9875
#quads = 88350


It takes the tesselateText() method in your class about 3.4 minutes to complete the file   Shocked The framerate was still acceptable, though (2800+ CPU, NVidia GF4ti)
I wonder where I could take some shortcuts to speed up the process? setting the "curvePoints" parameter lower than 2 created nonsensical glyphs Smiley

And secondly, if I want real, raw performance, should I stay away from truetype fonts, or pre-render them into a bitmap ? I suspect half-life 2 uses them for the console, so it can't be that slow!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Schabby

Junior Duke




The Receding Brow Worm will eat your code!


« Reply #3 - Posted 2006-07-16 09:53:42 »

Cool stuff! Congratulations!

Quote
And secondly, if I want real, raw performance, should I stay away from truetype fonts, or pre-render them into a bitmap ? I suspect half-life 2 uses them for the console, so it can't be that  slow!

yeah, Arons code is wonderful for creating 3D text, but if you only need to render 2D text it is faster to pre-render all characters on a texture. We do exactely that in FengGUI (http://fenggui.java.net). You will also find some handy tools for loading/saving fonts and pre-rendering characters (anti-aliased, outlined, filled with a pattern, etc.). I am currently playing around with some Klingon fonts in the webstart demo.

Johannes

Offline Aaron_Anderson

Senior Newbie




perception is reality


« Reply #4 - Posted 2006-07-19 21:45:44 »

Wow that is a lot of time!

Off hand I used arraylists to store the vertices before putting them into a VBO so I could create the NIO buffer to size. If during tesselation the arraylist needed to be constantly resized that could cause extreme delays. I also ran this code on an AMD64 bit machine so I used doubles instead of floats for better percision so it may run much slower on a 32 bit machine. Really the VBO code is best for 3D extruded text and Schabby is right in rendering 2D text to a FBO for reuse would be less taxing on the GPU. I will work on some FBO JOGL code and see if I can an example working.
Offline Aaron_Anderson

Senior Newbie




perception is reality


« Reply #5 - Posted 2006-07-19 23:00:44 »

Wow Schabby your https://fenggui.dev.java.net/ project rocks! You need to get the word out  Smiley
Offline Schabby

Junior Duke




The Receding Brow Worm will eat your code!


« Reply #6 - Posted 2006-07-20 09:20:09 »

Quote
Wow Schabby your https://fenggui.dev.java.net/ project rocks! You need to get the word out

Thanks! I am glad you like it!

Johannes

Offline Aaron_Anderson

Senior Newbie




perception is reality


« Reply #7 - Posted 2006-07-31 02:15:31 »

Here is some code for rendering text to a Frame Buffer Object (FBO)
Rename .txt to .zip
Offline Schabby

Junior Duke




The Receding Brow Worm will eat your code!


« Reply #8 - Posted 2006-09-05 18:11:53 »

Ah cool! I look into it ASAP. Thanks again for posting the code!

I have been pretty busy with other stuff lately such that I had to put FengGUI into stasis for a few weeks. That's also the reason why I have been absent on the forum. I resume development at the WE. However I am quite happy with our current font solution and I am not sure when (and if) we integrate your code. There are pressing things like deeper XMLization, animated textures, nicer table Widget, missing Widgets and lethal bugs that I need to tackle first.

Johannes

Pages: [1]
  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 (34 views)
2014-10-17 03:59:02

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

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

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

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

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

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

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

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

BurntPizza (74 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!