SDL_TTF



  • hi, ich wollte mit der sdl_ttf einen text in einem SDL-Fenster schreiben.
    leider bekomme ich sofort eine schwere Fehlermeldung und werde vor die wahl gestellt das programm zu beenden oder zu debuggen.
    leider weiss ich nicht, woher der fehler kommt, alle libs sind eingebunden usw.
    so sieht das ganze aus:

    #include <stdlib.h>
    #include <SDL.h>
    #include <SDL_TTF.h>
    
    int __stdcall WinMain(void * pInstance, void * pPrevInstance, char * szCommandLine, int nShowMode)
    {
        SDL_Surface *screen,*Text;
        SDL_Init(SDL_INIT_VIDEO);
    	SDL_Color color;
    	TTF_Init();
    	TTF_Font *Font;
        screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
    	SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,255));
    	atexit(SDL_Quit);
    	Font = TTF_OpenFont("tahoma.ttf",12);
    	color.r = color.g=color.b = 255;
    	Text = TTF_RenderText_Solid(Font,"Test",color);
    	SDL_BlitSurface(Text,NULL,screen,NULL);
    	SDL_UpdateRects(screen,1,0);
    	SDL_FreeSurface(Text);
    	TTF_CloseFont(Font);
    	TTF_Quit();
    	SDL_FreeSurface(screen);
        return 0;
    }
    

    hab dann mal auf debuggen geklickt, dann erscheint unten im visual c++ fenster bei debug folgendes:

    Loaded symbols for 'D:\Programme\Microsoft Visual Studio\MyProjects\Blablubb\Debug\Blablubb.exe'
    Loaded 'D:\WINDOWS.1\system32\ntdll.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\kernel32.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system\SDL.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\winmm.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\user32.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\gdi32.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\advapi32.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\rpcrt4.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\msvcrt.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\SDL_ttf.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\ddraw.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\dciman32.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\dinput.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\hid.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\setupapi.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\apphelp.dll', no matching symbolic information found.
    Loaded 'D:\WINDOWS.1\system32\version.dll', no matching symbolic information found.
    The thread 0xC80 has exited with code 0 (0x0).
    The thread 0xC8C has exited with code -1073741819 (0xC0000005).
    The thread 0xC4C has exited with code -1073741819 (0xC0000005).
    The program 'D:\Programme\Microsoft Visual Studio\MyProjects\Blablubb\Debug\Blablubb.exe' has exited with code -1073741819 (0xC0000005).
    

    weiss jemand von euch, woran das liegen könnte? hab schon das ganze forum durchsucht, vor knapp einem jahr hatte einer das gleiche problem, leider wurde nie eine antwort gepostet.

    gruss micha



  • Sorry, dass ich das Thema nochmal bumpe, aber da ich weiß, wie scheiße es ist, keine Antwort zu kriegen, geb ich ihm eine 😉
    Bist du auch sicher, dass das Programm die "tahoma.ttf" richtig lädt?

    Probier mal diesen Code :

    #include <stdlib.h>
    #include <SDL.h>
    #include <SDL_TTF.h>
    
    int __stdcall WinMain(void * pInstance, void * pPrevInstance, char * szCommandLine, int nShowMode)
    {
        SDL_Surface *screen,*Text;
    
        if(SDL_Init(SDL_INIT_VIDEO) < 0) {
            fprintf(stderr, "Fehler beim Initialisieren");
            return 0;
        }
    
        SDL_Color color;
    
        TTF_Init();
        TTF_Font *Font;
    
        screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
        if(!screen) {
            fprintf(stderr, "Fehler beim Setzen des Videomodus!");
            return 0;
        }
    
        SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,255));
        atexit(SDL_Quit);
    
        Font = TTF_OpenFont("tahoma.ttf",12);
        if(!font) {
            fprintf(stderr, "Fehler beim Laden von 'tahoma.tff'");
            return 0;
        }
        color.r = color.g=color.b = 255;
    
        Text = TTF_RenderText_Solid(Font,"Test",color);
    
        SDL_BlitSurface(Text,NULL,screen,NULL);
        SDL_UpdateRects(screen,1,0);
    
        SDL_FreeSurface(screen);
        SDL_FreeSurface(Text);
    
        TTF_CloseFont(Font);
        TTF_Quit();
    
        return 0;
    }
    

    Führ das mal aus und sag was kommt.

    Achja, bitte meckert nicht, weil ich
    "if(bla) {
    nukeAmerica;
    }"

    statt

    "if(bla)
    {
    nukeAmerica;
    }"

    Hab's mir so angewöhnt.

    Gruß,
    😃 Domme



  • Meiner Meinung sieht das so aus, als ob die SDL Libs zum Linken fehlen.

    Dark schrieb:

    ...
    Achja, bitte meckert nicht, weil ich
    "if(bla) {
    nukeAmerica;
    }"

    statt

    "if(bla)
    {
    nukeAmerica;
    }"

    Hab's mir so angewöhnt.
    ...

    Ich finde das ist guter Programmierstil.



  • HAR schrieb:

    Meiner Meinung sieht das so aus, als ob die SDL Libs zum Linken fehlen.

    Würde es denn dann fehlerlos kompiliert werden?

    Gruß,
    😕 Domme



  • Am linken scheitert es sicher nicht.

    Loaded 'D:\WINDOWS.1\system32\dciman32.dll', no matching symbolic information found.

    deutet darauf hin, dass die Library keine Debuginformationen enthält, was auch sicher erwünscht sein dürfte.


Anmelden zum Antworten