[SDL2_TTF]-Text Rendering Slow? How To Make Faster? |
[SDL2_TTF]-Text Rendering Slow? How To Make Faster? |
Jonny D
|
This is a pretty common issue when using SDL_ttf. If you want better performance, you need to cache your renderings. That way you don't have to allocate and free 4 chunks of memory every time you draw, as you are.
So, to be more specific, you should write a structure that holds onto the rendered text textures so that you can reuse them. If your text is dynamic and changes every frame, then you can render each glyph to a texture and arrange them as needed in the draw call. I have a font class that does this, but I haven't made a plain SDL2 codepath for it yet. Jonny D On Thu, Nov 13, 2014 at 11:28 AM, JeZ-l-Lee wrote:
|
|||||||||||||
|
[SDL2_TTF]-Text Rendering Slow? How To Make Faster? |
javierecf
|
Jon, the people want NFont for SDL2 and SDL_gpu =D
2014-11-13 10:04 GMT-07:00 Jonathan Dearborn:
-- Javier Flores - @javierecf |
|||||||||||||||
|
[SDL2_TTF]-Text Rendering Slow? How To Make Faster? |
Jonny D
|
Well, I was sorta planning on it...
Jonny D On Thu, Nov 13, 2014 at 12:47 PM, Javier Flores wrote:
|
|||||||||||||||||
|
mr_tawan
|
I think it slow because of the Freetype 2 which is used internally by SDL_ttf. TrueType processing is quite complicated and it takes time to compute. The best way of using SDL_ttf would be to create a new texture only when text changes (caching).
Anyway try profiling the code. It probably somewhere else . |
|||||||||||
|
[SDL2_TTF]-Text Rendering Slow? How To Make Faster? |
Jonny D
|
Alright, I put together a version of NFont that uses SDL_Renderer (NFontR). You can check it out on the Google Code page:
https://code.google.com/p/nfont/ It does all the stuff you should expect!  Caching, alignment, line feed, UTF-8, coloring, and a permissive license. The only catch is that I haven't updated the C version in a long time, so C++ only. I hope you like it, Jonny D |
|||||||||||
|
[SDL2_TTF]-Text Rendering Slow? How To Make Faster? |
javierecf
|
nice!, im gonna give it a try. (i could totally use some caching on my in game editor)
2014-11-14 10:03 GMT-07:00 Jonathan Dearborn:
-- Javier Flores - @javierecf |
|||||||||||||
|
[SDL2_TTF]-Text Rendering Slow? How To Make Faster? |
Eric Wing
Guest
|
On 11/14/14, Jonathan Dearborn wrote:
Neat! Though, just so you know there is demand, I would be very interested in the C version. I ship libraries as binaries and do a lot with scripting language bindings, so the stable and predictable ABI of C is really important to me. Thanks, Eric -- Beginning iPhone Games Development http://playcontrol.net/iphonegamebook/ _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
[SDL2_TTF]-Text Rendering Slow? How To Make Faster? |
javierecf
|
Same here, C++ is a mess, i only use classes when absolutely neccesary, and a modern stable nfont version for c would be great!.
2014-11-14 13:46 GMT-07:00 Eric Wing:
-- Javier Flores - @javierecf |
|||||||||||||||
|
JeZ-l-Lee
|
Hi,
Mark this topic SOLVED! I've released a beta of our SDL2 game: "TetriCrisis 4 110% A.I. Turbo" here: http://forums.libsdl.org/viewtopic.php?t=10833 Game uses our new TTF text optimization and is open-source! Enjoy... JeZxLee |
|||||||||||
|