Code:
Main.cpp
#include "CSDL.h"
CSDL sdl;
int main(int argc, char *argv[])
{
SDL_Surface *screen;
sdl.InitSDL();
sdl.SetVidMode(screen);
sdl.FillRect(screen, 0, 0, _WIDTH, _HEIGHT, 45, 45, 45);
sdl.UpdateScreen(screen);
return 0;
}
Code:
FillRect function
//Fills a rect (x, y, w, h) with color (r, g, b) on screen (screen)
void CSDL::FillRect(SDL_Surface *screen, int x, int y, int w, int h, Uint8 r, Uint8 g, Uint8 b)
{
dst.x = x;
dst.y = y;
dst.w = w;
dst.h = h;
SDL_FillRect(screen, &dst, SDL_MapRGB(screen->format, r, g, b));
return;
}
I get a segmentation fault on calls to sdl.FillRect();
Any ideas why?
Full Source: