Any way to render sdl_ttf without using sdl_surface? |
Naith
|
Well, you can always use a bitmap font to render your text, instead of using SDL_TTF. More information: http://lazyfoo.net/tutorials/SDL/41_bitmap_fonts/index.php
|
|||||||||||
|
jsalina
|
As far as I can tell the 2.0.14 SDL_TTF API render calls only return an SDL_Surface type. The underlying code would need to be modified to return an SDL_Texture.
If you really know what you're doing you can download the source code and make new versions of these that return an SDL_texture and re-compile. extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font, const char *text, SDL_Color fg); extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid(TTF_Font *font,const char *text, SDL_Color fg); extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid(TTF_Font *font, const Uint16 *text, SDL_Color fg); |
|||||||||||
|
jsalina
|
FYI - I always use this to convert the surface to texture before rendering. I haven't found a quicker way short of what I described above.
SDL_CreateTextureFromSurface( SDL_Renderer, SDL_Surface ); |
|||||||||||
|
Any way to render sdl_ttf without using sdl_surface? |
Jonny D
|
It sounds like he just wants a wrapper that does the work already.
Check out SDL_FontCache, one of my libraries: https://github.com/grimfang4/SDL_FontCache Jonny D On Thu, Apr 7, 2016 at 10:44 AM, jsalina wrote:
|
|||||||||||||
|
Any way to render sdl_ttf without using sdl_surface? |
MrOzBarry
|
I think a bigger question needs to be asked; what are you hoping to achieve by rendering to anything but `SDL_Surface*`? If this is for some sort of optimization on your render calls, you might want to look into caching surfaces/textures so you're not building them from scratch each loop.Â
On Thu, Apr 7, 2016 at 10:52 AM, jsalina wrote:
|
|||||||||||||
|
Any way to render sdl_ttf without using sdl_surface? |
MrOzBarry
|
I haven't test this, but I created a small library to manage caching text generated by TTF_RenderUTF8 called TextCache. It does do some automation to convert the surface to a texture, and might achieve what you're after.
On Thu, Apr 7, 2016 at 11:34 AM, Alex Barry wrote:
|
|||||||||||||||
|