Jump to content
  • Advertisement
Sign in to follow this  
chbrules

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

This topic is 4736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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!

Share this post


Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!