SDL_Surface passing
Posted: Sat May 15, 2010 10:43 am
Do you prefer to send a pointer to the buffer to an object each time, like this:
Or do you prefer to have a static pointer to an SDL_Surface in the object's class, like this:
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.
What do you think?
Code: Select all
//In main loop
player.Draw(system.buffer)
Code: Select all
//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;
}
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.
What do you think?