Original Post
I'm programming a game using SDL and SDL_ttf, I'm doing it in C++ using NetBeans in a Linux system (Ubuntu specifically). I've read over here that SDL have some problems when you use it in C++, but I haven't had any (until now). Well, the thing is that my game compiles and executes just perfectly on the IDE, the problem comes when I compile an executable and try to run it directly (the one it makes in dist/Release/...).
When I do it, it gives me a segment violation. I've been isolating the fail, and it's in this code of block:
The exact problem is in the function TTF_RenderTextSolid();
As you can see, I load the font directly in the function, I used to give it to the function in the arguments (the first one), but I thought that could be causing the problem so I changed it, but nothing changed in the result.
color is defined in the same file but outside the function, like this:
SDL_Color color;
Can you see any problems that may be causing this?
Thanks in advance.
When I do it, it gives me a segment violation. I've been isolating the fail, and it's in this code of block:
void dibujarmenu(TTF_Font *font1, SDL_Surface **screen, controlador *contr) {
TTF_Font *font = TTF_OpenFont("FreeSans.ttf", 10);
dibujarseleccionado(screen, contr);
//Left menu first because of being smaller
//QUIT
color = (SDL_Color) {150,150,150,255};
if ((text = TTF_RenderText_Solid(font, "QUIT", color))==NULL)
cout << TTF_GetError() << endl;
rect = (SDL_Rect) {712,584,88,13};
SDL_BlitSurface(text, NULL, *screen, ▭);The exact problem is in the function TTF_RenderTextSolid();
As you can see, I load the font directly in the function, I used to give it to the function in the arguments (the first one), but I thought that could be causing the problem so I changed it, but nothing changed in the result.
color is defined in the same file but outside the function, like this:
SDL_Color color;
Can you see any problems that may be causing this?
Thanks in advance.