Error using SDL_ttf

Hello!

writing a very little game to start to learn SDL and the expansion
libraries, I want to use SDL_ttf to write text in the screen.

In the url http://rafb.net/paste/results/JvGj4S85.html I have a unknow error
in the line 38.
TTF_GetError not return any information about the error_________________________________________________________________
Dale rienda suelta a tu tiempo libre. Encuentra mil ideas para exprimir tu
ocio con MSN Entretenimiento. http://entretenimiento.msn.es/

Hi!

Try changing

if (Fuente1<0)

to

if (Fuente1 == NULL)

and see if it fails. How can a pointer be less than 0?

Sebastian

ALTAIR - wrote:>

Hello!

writing a very little game to start to learn SDL and the expansion
libraries, I want to use SDL_ttf to write text in the screen.

In the url http://rafb.net/paste/results/JvGj4S85.html I have a unknow
error in the line 38.
TTF_GetError not return any information about the error


Dale rienda suelta a tu tiempo libre. Encuentra mil ideas para exprimir
tu ocio con MSN Entretenimiento. http://entretenimiento.msn.es/


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

hi
try this

#include <stdlib.h>
#include “SDL.h”
#include “SDL_ttf.h”

TTF_Font *Fuente1;
SDL_Color Color1;
SDL_Surface *text_surface;
SDL_Rect Rectangulo;
SDL_Surface *Pantalla;
SDL_Event event;
int Salir;
int Orden;

int main (int argc, char *argv[]){

if(SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO ) < 0) {
printf(“Unable to init SDL: %s\n”, SDL_GetError());
exit(1);
}

Pantalla = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE );
    if ( Pantalla == NULL ) {
    fprintf(stderr, "Couldn't set video mode: %s\n",
    SDL_GetError());
    exit(1);
}

Orden=TTF_Init();
if (Orden<0) { printf("\nError inicializando TTF"); }

Fuente1=TTF_OpenFont(“Fuentes/arial.ttf”,26);
if (Fuente1 == NULL) { printf("\nTTF_OpenFont: %s\n", TTF_GetError()); }

TTF_SetFontStyle(Fuente1,TTF_STYLE_BOLD);

Color1.r=200;
Color1.g=70;
Color1.b=50;

text_surface=TTF_RenderText_Solid(Fuente1,“Hello World!”,Color1);
if (text_surface==NULL){
printf("\nError: %s\n", TTF_GetError());
}

Rectangulo.x=100;
Rectangulo.y=100;
Rectangulo.w=text_surface->w;
Rectangulo.h=text_surface->h;
SDL_FillRect(Pantalla, NULL, SDL_MapRGB(Pantalla->format, 128, 128, 128));
SDL_BlitSurface(text_surface, NULL, Pantalla, &Rectangulo);
SDL_UpdateRect(Pantalla,0, 0, 0, 0);

Salir=0;
while (Salir<1)
{

while (SDL_PollEvent(&event))
{
if (event.type==SDL_KEYDOWN) Salir=1;
}
}
return 0;
}

ppap_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.com/

Not run, again._________________________________________________________________
Moda para esta temporada. Ponte al d?a de todas las tendencias.
http://www.msn.es/Mujer/moda/default.asp