Jump to content
  • Advertisement

Archived

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

Cyberdrek

SDL & Classes problems...

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

Hey all, anybody here had any problems with SDL_Surface pointers when encapsulating SDL in classes?? Here''s a piece of code:
  
int HSSprite::draw( HSSurface screen )
{
   SDL_Surface *tmpSurface = screen.getSurface();
   SDL_Rect    tmpRect = screen.getRect();

   screen.changeRectW( image->w );
	screen.changeRectH( image->h );

   // **

   // ** Palettized screen modes will have a default palette (a standard

   // ** 8*8*4 colour cube), but if the image is palettized as well we can

   // ** use that palette for a nicer colour matching

   // **

   if ( image->format->palette && tmpSurface->format->palette )//screen.getSurface()->format->palette )

	{
	   SDL_SetColors( tmpSurface, image->format->palette->colors, 0,
                     image->format->palette->ncolors );
   }

   // ** Blit onto the screen surface   

   if( SDL_BlitSurface( image, NULL, tmpSurface, &tmpRect ) < 0 )//&(screen.getRect()) ) < 0 )

       fprintf( stderr, "BlitSurface error: %s\n", SDL_GetError() );

   // ** Update modified rectangles

   SDL_UpdateRect( tmpSurface, 0, 0, image->w, image->h );

   return( 1 );
};
  
Now, the problem is, that function works fine the first time the program calls it, the second time it gives me this in the stderr.txt file: Fatal signal: Segmentation Fault (SDL Parachute Deployed) Can anybody see anything wrong in my this function? I''ve been trying to debug this code for 3 days now and can''t seem to figure out what''s wrong... I know that the error occurs somewhere in the SDL_BlitSurface function but I can''t seem to put my hand on what the exact problem is. Just so you know, HSSurface is simply an SDL_Surface *surface and an SDL_Rect rect. I encapsulated them in classes... "And that''s the bottom line cause I said so!" ** I WANT TO BE THE MODERATOR FOR THE LINUX FORUM ** Cyberdrek Headhunter Soft A division of DLC Multimedia
Resist Windows XP''s Invasive Production Activation Technology! "gitty up" -- Kramer /(bb|[^b]{2})/ that is the Question -- ThinkGeek.com

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!