Sign in to follow this  
chbrules

[C++/SDL]Passing a pointer to a pointer of the screen object

Recommended Posts

chbrules    170
I define my screen object in an engine class of mine, then I have a getter functoin to pass the pointer to other functions that need to use it. I debugged (MSVC++ .NET 2003) it and found that it was getting the proper values to initialize and all that, but when I try to pass it, nothing happens. Here's my function:
inline SDL_Surface* getScreen(){ return screen; }
Then I simply call it to a SDL_Surface pointer variable in another class:
SDL_Surface *screen = Engine->getScreen();
I get ziltch. I check the debugger, the new screen object in the other class has empty value and my program crashes. It's late and maybe I'm going crazy right now, but I think that getter function is how you pass the screen pointer object, right?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Quote:
Original post by rip-off
theres a lovely function in SDL called

SDL_GetVideoSurface().

it returns the current acve video surface.
no messing about creating functions that do exactly the same thing!


I agree. Try that.

However, according to the code you gave us, it should work! Exactly how are you initializing it? Maybe you initialized it after you get the screen?

Can you maybe show us how you initialize it? Other than that, you could just use SDL_GetVideoSurface().

C++

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this