So Expensive!

Started by
9 comments, last by UltimaX 20 years, 9 months ago
I was finally profiling my demo to test out my engine and I found that most of the time spent is in the text drawing routine. Heres the results of the text drawing routine: The Direct3D rendering engine:

Time	 | Profile Name
--------------------------------------------------------------------
14.000000 | 3D Sound Update
1.000000 | Direct3D Set Matrices
1.000000 | Direct3D Set States
3.000000 | Direct3D Render Object
0.000000 | Direct3D Set Text Parameters
3.000000 | Direct3D Show 3D Text
13.000000 | Show FPS
The OpenGL rendering engine:

Time	 | Profile Name
--------------------------------------------------------------------
14.000000 | 3D Sound Update
0.000000 | OpenGL Set Text Parameters
224.000000 | OpenGL Show 3D Text
37.000000 | Show FPS
I chopped the OpenGL version more and found that glCallLists(strlen(Output), GL_UNSIGNED_BYTE, Output); is the problem. So my question is: Is there a way around calling glCallLists() for font routines? If anyone could give me any suggestions that would be great! Thanks for your time. -UltimaX- "You wished for a white christmas... Now go shovel your wishes!"
Advertisement
where did u get the font drawing routine from? try using one of the NeHe tutorial ones. first, run the app in profiler and see if theirs is better than urs, and if it is, see what they did differently.

as far as i can remember atm, glCallLists function executes pre-made commands (which are located on the vidio card''s memory) and it should be much faster since it''s all done on the video card.

but then again, i could be mistaken since it''s been so long (damn cs). =\ try looking it up in the red book (there are free online versions, go to google). i can''t because i have to go in 1 minute. or just wait for some1 more knowledgable to help you.

---
shurcool
wwdev
Thanks shurcool, I checked out how NeHe did it and it's alomst the same setup. I'll check the Red Book and see if theres anything different.

-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"

[edited by - UltimaX on July 7, 2003 12:38:58 AM]
Check that you''re not switching into ortho and back out again for each character thats displayed, and only for the whole sentance.
the problem with the NeHe text function is that every time you want to render a string you need to rebind the text texture.

try collecting all the strings you want to render and then render them all in one go so you only have bind the texture once
I burn cold
the problem with the NeHe text function is that every time you want to render a string you need to rebind the text texture.

try collecting all the strings you want to render and then render them all in one go so you only have bind the texture once
I burn cold
Thank you all for the replies. I''ll take a look at it and see what I can come up with. If I can''t find another way I''m going to have to redo it. I''m not going to use a font that costs more then every other rendering function combined.

Thanks agian.

-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"
Ahhh found it!!

I found a way around the whole wiggle structure. No more glCallLists()!

Thanks everyone.



-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"
Are you going to share this newfound knowledge, or are you just going to keep it to yourself?
It''s not newfound at all. Since my engine handle both Direct3D and openGL, I just conbined the text drawing routines.

So instead of having say:
if(GACTIVEENGINEID == 0x0000){    //--Initialize Direct3D Engine Text    //--Using memory texture}else if(GACTIVEENGINEID == 0x0001){    //--Initialize OpenGL Engine Text    //--Using wiggle}else if(GACTIVEENGINEID == 0x0002){    //--Initialize XSoft3D Engine Text}


I changed it around so OpenGL could use the memory texture:
Something like:
if(GACTIVEENGINEID == 0x0002){    //--Initialize XSoft3D Engine Text}else{    //--Initialize/Create memory texture    if(GACTIVEENGINEID == 0x0001)    {        //--Create Direct3D Texture    }    else    {        //--Create OpenGL Texture    }    //--Free memory}


In other words, instead of using wiggle, it uses a bitmap font without the glCallLists(). Ususally the OpenGL bitmap fonts use glCallLists(), but theres ways around it. Just render quads and adjust the texture coords to fit the character that needs rendered.

Simple and so far a little faster.


-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"

This topic is closed to new replies.

Advertisement