shouldn’t TTF_Init be called before TTF_OpenFont?On Fri, Nov 26, 2010 at 3:19 PM, Andreas Schiffler wrote:
Things that come to mind:
- add SDL_Init
- check font for NULL
The “official” sample code you can use as reference can be found here:
http://hg.libsdl.org/SDL_ttf/file/c1f5f19d8fa9/showfont.c–Andreas
On 11/26/10 9:54 AM, Lars Br?mer wrote:
Hi List,
its quiet an expert list and I feel a little clumbsy to post here…
AnywayI`ve got Vsiual C express working.
It compiles SDL programms and it can make use of the SDL_mixer(the sound
mixer).I think I have included the SDL_ttf files at the right location because it
seems pretty much
the same procedure than SDL_mixer.The includes and the SDL_ttf initialisation works.
But when I start withtext = TTF_RenderText_Solid( font, “Space…”, textcolor );
The program compiles, links, starts but
I got an exeption and a untreated access
Unbehandelte Ausnahme bei 0x6f4c27f4 in TTF_test.exe: 0xC0000005:
Zugriffsverletzung beim Lesen an Position 0x00000000.(sorry its German)
Here is a minimum program to document my trouble…
It has not even the text blitted and it stops where the trouble starts
#include “stdafx.h”
#include “TTF_test.h”
#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
#include “SDL_ttf.h”int main(int argc, char *argv[])
{
?? SDL_Surface? *screen;
?? SDL_Surface *text = NULL;
?? TTF_Font *font;
?? SDL_Color textcolor? = { 128, 88, 77 };?? //font=TTF_OpenFont(“font.ttf”, 16);
?? font=TTF_OpenFont(“C:/winnt/Fonts/Verdana.ttf”,18);? // both works?? screen = SDL_SetVideoMode(640, 480, 24,SDL_SWSURFACE);
?? TTF_Init();
?? //When I uncomment this line, the error happens…so far it works
? //text = TTF_RenderText_Solid( font, “Space…”, textcolor );? SDL_Delay(500);
? TTF_CloseFont(font);
? TTF_Quit();
}
It would be very nice if somebody could have a look on it because I like to
do something on alternate OSand SDL seems to be a very nice API.
Thanks you very much,
Lars
SDL mailing list
SDL at lists.libsdl.org
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
–
David