Jump to content
  • Advertisement
Sign in to follow this  
Yelnats

SDL_ttf Access violation

This topic is 3169 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

Whenever I try to link code that has TTF_RenderText_Solid(), I get an access violation error. I tried to compile and run the code from this website http://sites.google.com/site/sdlgamer/beginner/lesson-11, because I thought it was my code that caused the Access Violation. It seems that I get this error every time there is TFF_RenderText_Solid(). Does anyone know a fix? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
The code you posted above does not check for failure when loading the font. My bet is that you don't have the font arial.ttf in the working directory you are running the game from; although, I could be wrong. The first thing you should probably do though is check the return value of TTF_OpenFont().

Good luck,
-Zael-

Share this post


Link to post
Share on other sites
You are right, It couldn't load a font. But the font is in the game folder, under a folder called font. This is a snippet of the code
TTF_Font *font; // Declare a SDL_ttf font : font
TTF_Init(); // Initilize SDL_ttf
font = TTF_OpenFont("./font/arial.ttf",24); // Open a font & set the font size
if (font == NULL){
return 1;
}
It returns 1.

Share this post


Link to post
Share on other sites
Well at this point, it is probably a safe bet that TTF_OpenFont isn't finding the font. You might want to get rid of the ./ in front. I don't know if it is causing any problems, but either way it isn't necessary. I don't know what OS you are running on, but remember that in both Mac OS X and Linux case matters in the filename.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!