Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
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  
  TextRenderer speed  (Read 2843 times)
0 Members and 1 Guest are viewing this topic.
Offline numknuf

Senior Newbie




bompi


« Posted 2008-03-26 16:47:40 »

I'm rendering approximately 150 different labels where each letter is rendered on a curve. My solution has been to render each letter separately but this is horribly slow (4 fps). Is there any way of speeding this up?
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #1 - Posted 2008-03-26 19:56:12 »

You're not calling beginRendering()  / endRendering() between each letter, are you? If you don't do this then you should get good performance.
Offline numknuf

Senior Newbie




bompi


« Reply #2 - Posted 2008-03-26 20:16:43 »

I do this for each label:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
private void renderLabel(GL gl, TextRenderer textRenderer, String label, float[] color) {
        gl.glPushMatrix();
        textRenderer.setColor(color[0], color[1], color[2], color[3]);
        textRenderer.begin3DRendering();

        float maxW = 0.0f;
        float span = 0;
        for (int i = 0; i < label.length(); i++) {
            float w = textRenderer.getCharWidth(label.charAt(i));
            if (w > maxW) {
                maxW = w;
            }
            span += w;
        }


        float angle = span * 180.0f / 2500.0f;
        float step = angle / span;
        float rotate = 0.0f;
        gl.glRotatef(-(180.0f - angle) / 2.0f, 0, 0, 1);

        for (int i = 0; i < label.length(); i++) {

            char c = label.charAt(i);
            float w = textRenderer.getCharWidth(c);

            gl.glPushMatrix();

            gl.glRotatef(-rotate, 0, 0, 1);
            gl.glTranslatef(-0.86f, 0, 0);
            gl.glRotatef(90, 0, 0, 1);
            textRenderer.draw3D("" + c, 0, 0, 0, 0.001f);
            textRenderer.flush();
            gl.glPopMatrix();
            rotate += step * w;
        }

        textRenderer.end3DRendering();
        gl.glPopMatrix();
}


TextRenderer is made once. The code is not optimal and there are some magic numbers but this was the only way I could make it work
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline numknuf

Senior Newbie




bompi


« Reply #3 - Posted 2008-03-27 17:23:46 »

I reworked the algorithm to only call begin3DRendering() and end3DRendering() once for all labels, but there is no improvement on speed.

I profiled the application using JProfiler and it seems more than half of the slow rendering time is spent in flush()
Offline emzic

Senior Devvie





« Reply #4 - Posted 2008-03-28 08:28:34 »

just try not calling flush() at all. i think it is automatically called in the end3Drendering()
Offline numknuf

Senior Newbie




bompi


« Reply #5 - Posted 2008-03-28 08:41:19 »

If I don't call flush() then the translate and rotate transformations are not applied to each letter.
Offline emzic

Senior Devvie





« Reply #6 - Posted 2008-03-28 09:12:47 »

are you using the latest version of jogl (RC8) ?

try changing the value of:
setUseVertexArrays(true/false)
Offline numknuf

Senior Newbie




bompi


« Reply #7 - Posted 2008-03-28 09:24:37 »

I updated to the current nightly build and tried setting setUseVertexArrays(true/false) but the results are the same.
Offline Ken Russell

JGO Coder




Java games rock!


« Reply #8 - Posted 2008-03-29 12:48:31 »

Can you email me a complete test case? kenneth dot russell at sun dot com .
Offline numknuf

Senior Newbie




bompi


« Reply #9 - Posted 2008-04-02 14:08:58 »

I was in the process of making a test case when I retried setting setUseVertexArrays(false)   and now it was fast.  Huh
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 
Ecumene (49 views)
2017-09-30 02:57:34

theagentd (74 views)
2017-09-26 18:23:31

cybrmynd (183 views)
2017-08-02 12:28:51

cybrmynd (181 views)
2017-08-02 12:19:43

cybrmynd (188 views)
2017-08-02 12:18:09

Sralse (195 views)
2017-07-25 17:13:48

Archive (745 views)
2017-04-27 17:45:51

buddyBro (878 views)
2017-04-05 03:38:00

CopyableCougar4 (1428 views)
2017-03-24 15:39:42

theagentd (1317 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
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!