I am having problems with the following few lines of code. The first
time through the outer while loop, everything is rendered properly. My
image (gps_map) is displayed, and if I add any text to the buffer
(buffer) beforehand, it is displayed. However, when I handle an event
that adds text to the buffer, setting the dirty flag to true, the
program seg faults on the SDL_Flip(screen) call. I know that screen is
not null because I tested it just before the call that seg faults. What
am I missing here?
while(!done){
if(dirty){
SDL_Rect dest;
dest.x = 52;
dest.y = 20;
dest.w = gps_map->w;
dest.h = gps_map->h;
SDL_BlitSurface(gps_map, NULL, screen, &dest);
dest.x = 0;
dest.y = 0;
text = TTF_RenderText_Solid(font, buffer->getBuffer(),
white);
SDL_BlitSurface(text, NULL, screen, &dest);
SDL_FreeSurface(text);
SDL_Flip(screen);
dirty = false;
}
// Handle events . . . set dirty flag if event changes display
.
.
.
}//end while
Christian
Hi!
Maybe your surface named “text” is NULL. Try adding a test against NULL
around the code that blits the text surface. I have added this text
below in your example.
Best regards,
Henrik Algestam
I am having problems with the following few lines of code. The first
time through the outer while loop, everything is rendered properly.
My image (gps_map) is displayed, and if I add any text to the buffer
(buffer) beforehand, it is displayed. However, when I handle an event
that adds text to the buffer, setting the dirty flag to true, the
program seg faults on the SDL_Flip(screen) call. I know that screen
is not null because I tested it just before the call that seg faults.
What am I missing here?
while(!done){
if(dirty){
SDL_Rect dest;
dest.x = 52;
dest.y = 20;
dest.w = gps_map->w;
dest.h = gps_map->h;
SDL_BlitSurface(gps_map, NULL, screen, &dest);
dest.x = 0;
dest.y = 0;
text = TTF_RenderText_Solid(font, buffer->getBuffer(),
white);
if(text)
{
SDL_BlitSurface(text, NULL, screen, &dest);
SDL_FreeSurface(text);
}On Fri, 12 Mar 2004 12:50:17 -0500 Christian Allgood <callgood at vt.edu> wrote:
SDL_Flip(screen);
dirty = false;
}
// Handle events . . . set dirty flag if event changes display
.
.
.
}//end while
Christian
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
Try using another function then TTF_RenderText_Solid.
I have had some problems with that function in some of my applications, I
replaced it with TTF_RenderText_Blended and then everything worked.
// Alexander BussmanOn Saturday 13 March 2004 07.57, Henrik Algestam wrote:
Hi!
Maybe your surface named “text” is NULL. Try adding a test against NULL
around the code that blits the text surface. I have added this text
below in your example.
Best regards,
Henrik Algestam
On Fri, 12 Mar 2004 12:50:17 -0500 Christian Allgood wrote:
I am having problems with the following few lines of code. The first
time through the outer while loop, everything is rendered properly.
My image (gps_map) is displayed, and if I add any text to the buffer
(buffer) beforehand, it is displayed. However, when I handle an event
that adds text to the buffer, setting the dirty flag to true, the
program seg faults on the SDL_Flip(screen) call. I know that screen
is not null because I tested it just before the call that seg faults.
What am I missing here?
while(!done){
if(dirty){
SDL_Rect dest;
dest.x = 52;
dest.y = 20;
dest.w = gps_map->w;
dest.h = gps_map->h;
SDL_BlitSurface(gps_map, NULL, screen, &dest);
dest.x = 0;
dest.y = 0;
text = TTF_RenderText_Solid(font, buffer->getBuffer(),
white);
if(text)
{
SDL_BlitSurface(text, NULL, screen, &dest);
SDL_FreeSurface(text);
}
SDL_Flip(screen);
dirty = false;
}
// Handle events . . . set dirty flag if event changes display
.
.
.
}//end while
Christian
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
I tried that before. Debugging how I usually do, I commented out
everything except what I was testing, and slowly uncommented things
one-by-one. Turns out that when I comment out handling a joystick
buttonup event, there is no seg fault. Weird thing is that I didn’t do
anything during the joystick up event. Is this some sort of timing or
locking issue?
It seems to work fine now. I don’t really need to handle a joystick
buttonup event. Just confused as to what the problem was.
ChristianOn Sat, 2004-03-13 at 01:57, Henrik Algestam wrote:
Hi!
Maybe your surface named “text” is NULL. Try adding a test against NULL
around the code that blits the text surface. I have added this text
below in your example.
Best regards,
Henrik Algestam
On Fri, 12 Mar 2004 12:50:17 -0500 Christian Allgood <@Christian_Allgood> wrote:
I am having problems with the following few lines of code. The first
time through the outer while loop, everything is rendered properly.
My image (gps_map) is displayed, and if I add any text to the buffer
(buffer) beforehand, it is displayed. However, when I handle an event
that adds text to the buffer, setting the dirty flag to true, the
program seg faults on the SDL_Flip(screen) call. I know that screen
is not null because I tested it just before the call that seg faults.
What am I missing here?
while(!done){
if(dirty){
SDL_Rect dest;
dest.x = 52;
dest.y = 20;
dest.w = gps_map->w;
dest.h = gps_map->h;
SDL_BlitSurface(gps_map, NULL, screen, &dest);
dest.x = 0;
dest.y = 0;
text = TTF_RenderText_Solid(font, buffer->getBuffer(),
white);
if(text)
{
SDL_BlitSurface(text, NULL, screen, &dest);
SDL_FreeSurface(text);
}
SDL_Flip(screen);
dirty = false;
}
// Handle events . . . set dirty flag if event changes display
.
.
.
}//end while
Christian
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl