/************
**************
main.cpp starts edu
*************
************/
#include "Edu.h"
int main()
{
Edu edu;
edu.Init(640, 480, 32, "Edu");
return 0;
}
/*******
Edu.h Class edu(main part of engine)
*******/
#ifndef EDU_H
#define EDU_H
#include "SDL/SDL.h"
#include <string>
class Edu
{
public:
Edu();
virtual ~Edu();
void Init(); // initializes sdl with default settings
void Init(int, int, int, std::string); //initializes sdl with custom settings
SDL_Event MainEvent;
protected:
private:
SDL_Surface * MainScreen; //screem surface
void Run();
void CleanUp();
bool Quit;
};
#endif // EDU_H
/******
Edu.cpp
Edu class definitions
*******/
#include "Edu.h"
Edu::Edu()
{
}
Edu::~Edu()
{
}
void Edu::Init()
{
SDL_Init(SDL_INIT_EVERYTHING);
MainScreen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
SDL_WM_SetCaption("Window", NULL);
Quit = false;
Run();
}
void Edu::Init(int WindowWidth, int WindowHeight, int WindowMode, std::string WindowName)
{
SDL_Init(SDL_INIT_EVERYTHING);
MainScreen = SDL_SetVideoMode(WindowWidth, WindowHeight, WindowMode, SDL_SWSURFACE);
SDL_WM_SetCaption(WindowName.c_str(), NULL);
Quit = false;
Run();
}
void Edu::Run()
{
while(!Quit)
{
while(SDL_PollEvent(&MainEvent))
{
if(MainEvent.type == SDL_QUIT)
{
Quit = true;
SDL_Quit();
}
}
}
CleanUp();
}
void Edu::CleanUp()
{
SDL_FreeSurface(MainScreen);
}
SDL segfaults on exit
Okay so im not quite sure why it is doing this. The following code compiles just fine, but when I try to add a new int into the Edu class it segfaults on exit. I've been trying to avoid posting but i honestly cannot figure this out.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement