Jump to content
  • Advertisement

Recommended Posts

Question about SDL_Rect scope.

Say I have a member function like so.

void drawRect(int x, int y, int w, int y) {
    SDL_Rect r = {x, y, w, h};
    SDL_RenderDrawRect(m_renderer, &r);

Will it cause problems if SDL_Rect goes out of scope before calling SDL_RenderPresent?

I cannot tell if the values are copied from SDL_Rect when calling SDL_RenderDrawRect or if internally SDL is storing the pointer until SDL_RenderPresent is called.


Share this post

Link to post
Share on other sites

What you are doing is fine. SDL_RenderDrawRect copies out what it needs from the passed rectangle, and sends that data along to SDL_RenderDrawLines. 

Share this post

Link to post
Share on other sites

That's great! Thanks for your help. Is this the case for all render APIs? I.e. Point, Line, Copy. Or do some hold the pointer to the object until RenderPresent is called?

Thanks again.

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

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