Seg Fault in coding

I’m building an application class for my app and during the app->init
function I run SDL_Init and SDL_SetVideo. These operations are
performed on a default surface which is a private member of my app
class. What stupidity am I doing?

Thanks,
David Wood

Code Fragments> class CApplication {

private:
int appstate;
SDL_Surface *screen;

public:
int Init();
int Run();
int DeInit();
CApplication();
virtual ~CApplication();

};

int CApplication::Init() {

printf(“The Application is Initialized\n”);
SDL_Init(SDL_INIT_VIDEO);

screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE);

return 0;
}

Hiya,

DW> I’m building an application class for my app and during the app->init
DW> function I run SDL_Init and SDL_SetVideo. These operations are
DW> performed on a default surface which is a private member of my app
DW> class. What stupidity am I doing?

int CApplication::Init() {

  printf("The Application is Initialized\n");
  SDL_Init(SDL_INIT_VIDEO);

  screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE);
  
  return 0;

}

I’d suspect it to be because you used printf() before initialising
SDL…

May I take this opportunity to wish everyone on the list a Merry
Christmas/Happy Holidays and I hope SDL continues to get better and
better through the new year and beyond. :slight_smile:

Neil.

What’s your destructor look like? Are you manually freeing the surface
by mistake at the end? You really probably should check to make sure
that each worked and print the errors if either SDL_Init or
SDL_SetVideoMode failed.On Mon, 2001-12-24 at 13:30, David Wood wrote:

I’m building an application class for my app and during the app->init
function I run SDL_Init and SDL_SetVideo. These operations are
performed on a default surface which is a private member of my app
class. What stupidity am I doing?

Thanks,
David Wood

Code Fragments

class CApplication {

private:
  int	appstate;
  SDL_Surface *screen;

public:
  int Init();
  int Run();
  int DeInit();
  CApplication();
  virtual ~CApplication();

};

int CApplication::Init() {

printf("The Application is Initialized\n");
SDL_Init(SDL_INIT_VIDEO);

screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE);

return 0;

}


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

End of Rant.

Jimmy
JimmysWorld.org