//In main file
Player::Initialize(system.buffer);
Player player;
//In main loop
player.Draw();
//player.h
static void Initialize(SDL_Surface *surface);
static SDL_Surface *surface;
//player.cpp
SDL_Surface *Text::surface;
void Player::Initialize(SDL_Surface *buffer)
{
surface = buffer;
}
Does it make any difference in efficiency or usefulness?
I think it could, because you don't have to pass a reference to the buffer every time you want to draw something to the screen.
XianForce wrote:Personally, I have the window as a global singleton, because almost everything needs access to it.
I like that idea, do you have a static getInstance() function to access it?
Well... Yes and no I suppose... Basically I have an ApplicationSystem. The ApplicationSystem is the only global I have in the project, and holds pointers to a VideoSystem, AudioSystem, StateMachine, and a ResourceSystem (as soon as I finish the ResourceSystem at least). The VideoSystem holds the window, so anything I want to render, I use the VideoSystem for. I also have some macros so I can just do this: