Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

danne89

Problem w/SDL_ttf

This topic is 5283 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Grettings! I'm trying to use SDL_ttf, but I get empty error messages. Also, code like this:
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include <iostream>

int main()
{

        if (SDL_Init(SDL_INIT_VIDEO) != 0)
        {
                std::cout << "Error "  << SDL_GetError() << std::endl;
                return -1;
        }

        if (TTF_Init() != 0)
        {
                std::cout << "Error " << TTF_GetError() << std::endl;
                return -1;
        }

        Uint32 flags = SDL_DOUBLEBUF | SDL_HWSURFACE;
        SDL_Surface* screen = SDL_SetVideoMode(640, 480, 8, flags);
        if (screen == NULL)
        {
                std::cout << "Error "  << SDL_GetError() << std::endl;
                return -1;
        }

        TTF_Font* font = TTF_OpenFont("font.ttf", 12);
        if (font == NULL)
        {
                std::cout << "Error " << TTF_GetError() << std::endl;
                return -1;
        }


        SDL_Color color;
        color.r = 255;
        color.g = 0;
        color.b = 0;
        SDL_Surface *text_surface;
        if(!(text_surface = TTF_RenderText_Solid(font,"Hello World!", color)))
        {
                std::cout << "Error " << TTF_GetError() << std::endl;
                return -1;
        }


        SDL_BlitSurface(text_surface, 0, screen, 0);

        while(1);


        TTF_CloseFont(font);
        TTF_Quit();
        SDL_Quit();

        return 0;
}
does'nt work for me. I got a error in TTF_Init and TTF_GetError does'nt print any message. I'm using Linux. http://www.cis.gsu.edu/~shong/oojokes/ [edited by - danne89 on June 3, 2004 1:15:45 AM] [edited by - danne89 on June 3, 2004 1:16:35 AM]

Share this post


Link to post
Share on other sites
Advertisement
I have the exact same problem with empty error messages:

My Thread

I also posted this question in the SDL mailing list...if I get a reply I''ll update this thread with the info (or infaux as it may be).

Regards,
Jeff


[ CodeDread ]

Share this post


Link to post
Share on other sites
Hmm, do you also use linux? Which version of SDL_ttf do you have? I don't think my font file is corrupt. The showfont test program displays it nice and smooth.

http://www.cis.gsu.edu/~shong/oojokes/

[edited by - danne89 on June 3, 2004 1:31:54 AM]

Share this post


Link to post
Share on other sites
I''m using it in Windows and the font is displayable in Windows everwhere as well. I don''t think it''s a corrupt font file, just threw that in there...


[ CodeDread ]

Share this post


Link to post
Share on other sites
no wonder you don''t get it working..

SDL_ttf.h:

/* Initialize the TTF engine - returns 0 if successful, -1 on error */
extern DECLSPEC int SDLCALL TTF_Init(void);


God luck / Jezper Blixt

Share this post


Link to post
Share on other sites
I don''t understand what you mean. Can you explain a little more in detail, please?

http://www.cis.gsu.edu/~shong/oojokes/

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!