[SDL] TTF_Font (¿forward declaration?)

Edward Byard e_byard at yahoo.co.uk
Tue Jun 19 07:47:12 PDT 2007


Hello

OK, two things:

1. TTF_RenderText_Blended returns a type SDL_Surface, not TTF_Font

2. When finished with the surface, use SDL_FreeSurface to release the memory

TTF_Font *font;
SDL_Surface *text_surface;

    if(TTF_Init()==-1) 
    {
        printf_s("TTF_Init: %s\n", TTF_GetError());
    }
    font=TTF_OpenFont("images\\segoepr.ttf",52);
    if(!font) 
    {
        printf_s("TTF_OpenFont: %s\n", TTF_GetError());
    // handle error
    }


    if(!(text_surface=TTF_RenderText_Blended(font,buffer,color))) 
    {
        // ERROR!!
    }
    else
    {
        SDL_BlitSurface(text_surface, NULL, dest, &rect);
        SDL_UpdateRect(dest,rect.x,rect.y,rect.w,rect.h);
        SDL_FreeSurface(text_surface);
    }

TTF_CloseFont(font);

Hope this helps
Ed

----- Original Message ----
From: Zaka E-Lab <shanatorio at gmail.com>
To: Lista SDL. <sdl at lists.libsdl.org>
Sent: Tuesday, 19 June, 2007 3:35:59 PM
Subject: [SDL] TTF_Font (¿forward declaration?)

Hello all!!

I'm doing some stuff in SDL, and now I've started with SDL_ttf.

The thing is that I have these (is a lot of code to reproduce it as a 
whole):
TTF_Font *fuente = NULL;
...........
fuente = TTF_RenderText_Blended(.........);
...........
delete fuente;(

When a compile a got the next messages:(that one are in Spanish, so i'll 
try to translate it)

(SP)--->Dibujante.cpp:202: aviso: se detectó un posible problema en la 
invocación del operador delete:
(EN)--->Dibujante.cpp:202: warning: possible trouble detected in the use 
of delete operator:

(SP)--->Dibujante.cpp:162: aviso: ‘fuente’ tiene un tipo de dato incompleto
(EN)--->Dibujante.cpp:162: warning: 'fuente' has an incomplete type data.

(EN)--->/usr/include/SDL/SDL_ttf.h:42: aviso: forward declaration of 
‘struct _TTF_Font’

(SP)--->Dibujante.cpp:202: nota: no se llamará ni al destructor ni al 
operador delete específico de la clase, aún si se declaran cuando se 
defina la clase.
(EN)--->Dibujante.cpp:202: note: It will be called neither to the 
destructor nor the specific delete operator of the class, even if they 
are declared when the class is defined.

I'dont understand that messages cause i think that the use that I'm 
doing of the type TTF_Font and the operator "delete" is "legal". If 
somebody can help me with that, I'll appreciate it.

(Sorry for my English)

Thanks for advance.

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







	
	
		
___________________________________________________________ 
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes. 
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070619/7d7177fa/attachment.htm 


More information about the SDL mailing list