So I have three classes Application, DrawMgr and Cube. In Application.cpp is my main loop in which I call DrawMgr::DrawCube in which I call Cube::Draw.
Application.cpp
while (!quit)
{
//Draw Background
gDrawMgr.DrawBackground();
gDrawMgr.DrawCube();
//UpdateScreen
gDrawMgr.UpdateScreen();
//Handle events on queue
while (SDL_PollEvent(&e) != 0)
{
//User requests quit
if (e.type == SDL_QUIT || e.key.keysym.sym == SDLK_ESCAPE)
{
quit = true;
}
}
}
DrawMgr.cpp
SDL_Surface* screenSurface;
void DrawMgr::DrawCube()
{
gCube.Draw(screenSurface);
}
Cube.cpp
void Cube::Draw( SDL_Surface* destination )
{
SDL_Rect offset;
offset.x = 100;
offset.y = 100;
SDL_FillRect(cube, NULL, SDL_MapRGB( cube->format, 0, 0, 0 ) );
SDL_BlitSurface( cube, NULL, destination, &offset);
}
When I run the program, the cube doesn't appear, what am I doing wrong?