SDL_ttf and SDL_gfx in SDL 2

Hi all,
I’m new user of SDL, and before start using SDL, I have some question
to ensure the features as I hope.

  • Is SDL_ttf and SDL_gfx is compatible with SDL 2?
  • Is SDL_ttf and SDL_gfx use hardware rendering because as I read in
    http://wiki.libsdl.org/moin.cgi/MigrationGuide, only using textures
    will use hardware rendered, and SDL_ttf/SDL_gfx use surfaces to
    drawing?

Thanks in advance.

SDL_gfx is not compatible with SDL2. It works fine with SDL-1.2 but does
for the most part not leverage any hardware acceleration.
–AndreasOn 8/17/2012 8:25 PM, wahono sri wrote:

Hi all,
I’m new user of SDL, and before start using SDL, I have some question
to ensure the features as I hope.

  • Is SDL_ttf and SDL_gfx is compatible with SDL 2?
  • Is SDL_ttf and SDL_gfx use hardware rendering because as I read in
    http://wiki.libsdl.org/moin.cgi/MigrationGuide, only using textures
    will use hardware rendered, and SDL_ttf/SDL_gfx use surfaces to
    drawing?

Thanks in advance.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDK_ttf is compatible you might need to download it from Mercurial to get the latest. Everything is pretty much the same you just need to convert the SDL_Surface to SDL_Texture with

example:

char buf[256]
SDL_Color foregroundColor = { 255, 255, 255 };
SDL_Color backgroundColor = { 0, 0, 0 };
SDL_Rect TextLoacation;

snprintf(buf,256,“TESTING”);
SDL_Surface *textSurface= TTF_RenderText_Shaded(font, buf,
foregroundColor, backgroundColor);

if(testSurface)
{
temp_texture = SDL_CreateTextureFromSurface(renderer, textSurface);
TextLocation.h = textSurface->h;
TextLocation.w = textSurface->w;
TextLocation.x = 100;
TextLocation.y = 100;
}

wahono sri wrote:> Hi all,

I’m new user of SDL, and before start using SDL, I have some question
to ensure the features as I hope.

  • Is SDL_ttf and SDL_gfx is compatible with SDL 2?
  • Is SDL_ttf and SDL_gfx use hardware rendering because as I read in
    http://wiki.libsdl.org/moin.cgi/MigrationGuide, only using textures
    will use hardware rendered, and SDL_ttf/SDL_gfx use surfaces to
    drawing?

Thanks in advance.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

You’ll have to do a custom compile of SDL_ttf with SDL2 installed - in my
case (without SDL 1.2 installed in mingw, which should be roughly the same
on linux), it was literally me doing an hg clone of SDL2, ./configure &&
make && sudo make install, then going into SDL2, ./configure (confirm that
it does get SDL2 in there) && make && sudo make install

Note that instead of building SDL_ttf, with SDL2 it will build SDL2_ttf - I
am assuming that this is the general naming convention that Sam would like
to see with other SDL contrib. libraries (compatible with SDL 1.2 = SDL_,
SDL2 = SDL2_
)

As far as I’m aware, SDL_gfx needs to be updated to deal with SDL2 properly

  • Andreas mentioned in another thread that he’s planning on working on an
    SDL2-compatible version.

Take care,
-AlexOn Sat, Aug 18, 2012 at 4:06 AM, stevo5800 wrote:

**
SDK_ttf is compatible you might need to download it from Mercurial to get
the latest. Everything is pretty much the same you just need to convert the
SDL_Surface to SDL_Texture with

example:

char buf[256]
SDL_Color foregroundColor = { 255, 255, 255 };
SDL_Color backgroundColor = { 0, 0, 0 };
SDL_Rect TextLoacation;

snprintf(buf,256,“TESTING”);
SDL_Surface *textSurface= TTF_RenderText_Shaded(font, buf,
foregroundColor, backgroundColor);

if(testSurface)
{
temp_texture = SDL_CreateTextureFromSurface(renderer, textSurface);
TextLocation.h = textSurface->h;
TextLocation.w = textSurface->w;
TextLocation.x = 100;
TextLocation.y = 100;
}

wahono sri wrote:

Hi all,
I’m new user of SDL, and before start using SDL, I have some question
to ensure the features as I hope.

  • Is SDL_ttf and SDL_gfx is compatible with SDL 2?
  • Is SDL_ttf and SDL_gfx use hardware rendering because as I read in
    http://wiki.libsdl.org/moin.cgi/MigrationGuide, only using textures
    will use hardware rendered, and SDL_ttf/SDL_gfx use surfaces to
    drawing?

Thanks in advance.


SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hmm, I think SDL 2 is in heavy progress about hardware acceleration, and
others SDL tools need to be upgrade to SDL 2 with same way. I’m in doubt
about switching from surfaces to textures to speed up acceleration using
new renderer in SDL 2.

What about cairo? Is cairo can use sdl as backend. If yes, cairo can be
simplified sdl_ttf and sdl_gfx in one library only.

Thanks for all responses

Cairo is fundamentally different than SDL_gfx and certainly more
complicated than the combination of SDL_gfx and SDL_ttf. It’s vector-based
rather than raster-based. It does work with SDL with a little effort. In
my experience, performance is not great, but if you use a OpenGL/SDL2
backend, it is probably a lot better.

Jonny D