Help with TTF

Hi everyone, i have a strange problem:

why does this work:

Code:

text=TTF_RenderText_Solid(font, test, textcolor);

SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();

and this doesnt:

Code:

SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();

text=TTF_RenderText_Solid(font, test, textcolor);

[quote]

the only thing that changes as u can see is that i set the text after starting TTF_Init() on the second code. and btw test is a char [].

The 2? code compiles but it exits right away, and doesnt even get to my “while” but in the 1? code it goes fine[/quote]

ShiroAisu wrote:

Hi everyone, i have a strange problem:

why does this work:

Code:

text=TTF_RenderText_Solid(font, test, textcolor);

SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();

and this doesnt:

Code:

SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();

text=TTF_RenderText_Solid(font, test, textcolor);

the only thing that changes as u can see is that i set the text after starting TTF_Init() on the second code. and btw test is a char [].

The 2? code compiles but it exits right away, and doesnt even get to my “while” but in the 1? code it goes fine
[/code][/quote]

By “work” in the first case you don’t really mean that you can actually see rendered text displayed on the screen, do you?

  1. Post more code
  2. What is probably happening: in (1) TTF_RenderText_Solid has no way of working correctly and simply returns NULL early because SDL/SDL_ttf are not initialized yet. In (2) OTOH TTF_RenderText_Solid actually tries to renderer your text, and “exits” (crashes?) because of invalid parameters - either font or test.

Init first. Check for errors. Load font. Check for errors. Make sure you pass correctly initialized (’\0’ ended) string. Render. Check for errors.

Hi,

it’s just a guess. Perhaps checks SDL_ttf whether the Graphics subsystem
is initialized or not. You don’t have set up den display surface, too.

ShiroAisu wrote:

Hi everyone, i have a strange problem:

why does this work:

  Code:

text=TTF_RenderText_Solid(font, test, textcolor);

SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();

and this doesnt:

  Code:

SDL_Init(SDL_INIT_EVERYTHING);
TTF_Init();

text=TTF_RenderText_Solid(font, test, textcolor);

the only thing that changes as u can see is that i set the text after
starting TTF_Init() on the second code. and btw test is a char [].

The 2? code compiles but it exits right away, and doesnt even get to my
"while" but in the 1? code it goes fine

[/code][/quote]

By “work” in the first case you don’t really mean that you can actually
see rendered text displayed on the screen, do you?

  1. Post more code
  2. What is probably happening: in (1) TTF_RenderText_Solid has no way
    of
    working correctly and simply returns NULL early because SDL/SDL_ttf are
    not initialized yet. In (2) OTOH TTF_RenderText_Solid actually tries to
    renderer your text, and “exits” (crashes?) because of invalid parameters
  • either font or test.

Init first. Check for errors. Load font. Check for errors. Make sure
youOn Fri, 11 Jun 2010 01:27:06 -0700, “hardcoder” wrote:
pass correctly initialized (’’ ended) string. Render. Check for errors.


Christoph Nelles

E-Mail : @Christoph_Nelles
Jabber : eazrael at evilazrael.net ICQ : 78819723

PGP-Key : ID 0x424FB55B on subkeys.pgp.net
or http://evilazrael.net/pgp.txt

If you have 2 pieces of code, and one works? What is the problem?On Fri, Jun 11, 2010 at 3:27 AM, Christoph Nelles wrote:

Hi,

it’s just a guess. Perhaps checks SDL_ttf whether the Graphics subsystem
is initialized or not. You don’t have set up den display surface, too.

On Fri, 11 Jun 2010 01:27:06 -0700, “hardcoder” wrote:

ShiroAisu wrote:

?Hi everyone, i have a strange problem:

?why does this work:

? ? ? ? ? ? ? Code:

?text=TTF_RenderText_Solid(font, test, textcolor);

?SDL_Init(SDL_INIT_EVERYTHING);
?TTF_Init();

?and this doesnt:

? ? ? ? ? ? ? Code:

?SDL_Init(SDL_INIT_EVERYTHING);
?TTF_Init();

?text=TTF_RenderText_Solid(font, test, textcolor);

?the only thing that changes as u can see is that i set the text after
starting TTF_Init() on the second code. and btw test is a char [].

?The 2? code compiles but it exits right away, and doesnt even get to my
"while" but in the 1? code it goes fine

[/code][/quote]

?By “work” in the first case you don’t really mean that you can actually
see rendered text displayed on the screen, do you?

?1. Post more code
?2. What is probably happening: in (1) TTF_RenderText_Solid has no way
of
working correctly and simply returns NULL early because SDL/SDL_ttf are
not initialized yet. In (2) OTOH TTF_RenderText_Solid actually tries to
renderer your text, and “exits” (crashes?) because of invalid parameters

  • either font or test.

?Init first. Check for errors. Load font. Check for errors. Make sure
you
pass correctly initialized (’’ ended) string. Render. Check for errors.


Christoph Nelles

E-Mail ? ?: evilazrael at evilazrael.de
Jabber ? ?: eazrael at evilazrael.net ? ? ?ICQ ? ? ? : 78819723

PGP-Key ? : ID 0x424FB55B on subkeys.pgp.net
? ? ? ? ? ?or http://evilazrael.net/pgp.txt


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