Ive been having a problem with faults and im not sure what exactly its coming from.
I know that SDL_Flip(MainScreen) is causing it. bdround.Draw() is the only thing that changes MainScreen but i get the segfault even if i take that out.

/*******

Edu.h Class edu(main part of engine)

*******/


#ifndef EDU_H
#define EDU_H
#include "SDL/SDL.h"
#include "Background.h"



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();
    void Draw();

    Background bground;
    bool Quit;

};

#endif // EDU_H





/******

Edu.cpp
Edu class definitions

*******/


#include "Edu.h"
Edu::Edu(): bground(MainScreen)
{
}

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();
            }
        }
        Draw();
    }
    CleanUp();
}

void Edu::CleanUp()
{

}

void Edu::Draw()
{
    bground.Draw();
    SDL_Flip(MainScreen);
}

put SDL_Quit(); inside your CleanUp() function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.