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.

Thanks!

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


  • Similar Content

    • By mister345
      Hi, can somebody please tell me in clear simple steps how to debug and step through an hlsl shader file?
      I already did Debug > Start Graphics Debugging > then captured some frames from Visual Studio and
      double clicked on the frame to open it, but no idea where to go from there.
       
      I've been searching for hours and there's no information on this, not even on the Microsoft Website!
      They say "open the  Graphics Pixel History window" but there is no such window!
      Then they say, in the "Pipeline Stages choose Start Debugging"  but the Start Debugging option is nowhere to be found in the whole interface.
      Also, how do I even open the hlsl file that I want to set a break point in from inside the Graphics Debugger?
       
      All I want to do is set a break point in a specific hlsl file, step thru it, and see the data, but this is so unbelievably complicated
      and Microsoft's instructions are horrible! Somebody please, please help.
       
       
       

    • By Aggrojag
      Hello!
      I'm working on a game that is quite personal to me. It touches on my own depression, obsessions, phobias, etc. It's a narrative driven dark comedy with some small aspects of platforming and puzzle solving. The project is rather small as well. It touches on topics such as suicide, mental illness, family, corruption, free-will, and redemption.
      First, I'm looking for a 2D animator that can compliment the style of the attached image. The player character's animations will be a bit more extensive than a typical platformer. There will be many death animations, and some other strange dealings with the character that will need animation. Other items will include some objects in the world that are in need of animation. All static pieces of art will be handled by the artist that drew the attached image.
      Second, I'm looking for a male voice actor. There will be at minimum two characters that will need to be brought to life through vocals. They are a very core part of the game, though they will never be shown on screen. As a reminder, this is a rather dark comedy, so be prepared for some insanity in your portrayal of these characters. The first voice is that of a game show host's voice, while the other will be a devilish voice (without SFX, I think it cheapens it, does not necessarily need to be a low voice, this is more about the portrayal than how the voice sounds).
      Last, I would love to have an editor on board. More than just avoiding disaster in the writing, I'm looking for someone that can elevate it. There is not a ton of writing that will be in the final project, but it's important enough of an aspect to be trying to bring someone in to help with it.
      To those interested:
      I have a crappy prototype that exists, along with a couple game design docs. More than anything, I'd like to present the project through a voice chat via discord to any interested. Discord - Bobdul Thundercuck#4590
      I do plan to post this on itch.io and wherever else I can put it that makes sense. I fully expect to make nothing off this project, as should you. However, in the case that money is made, a rev share model will be in place.

       
      Edit: Editor position has been filled, title has been changed to reflect this, and crossed out the section detailing this.
    • By Kirlim
      I'm working a lot with identifiers types to help me while debugging or managing collections of instances in my code. Previously, I had using directives as the following example code:
      using AnimalId = unsigned int; using TreeId = unsigned int;  
      After a while, I accidentally mixed AnimalId and TreeId in my logic, so I've decided to use structs in order to make the identifiers strong typed. To avoid code duplications, I've created a template
      template <typename TypeTag, typename ValueType> struct IdType { ValueType value; // Methods for comparison and hashes };  
      However, I believe there's two different ways of using this template:
      // Using directive struct AnimalIdTag {} using AnimalId = IdType<AnimalIdTag, unsigned int>; // Inheritance struct TreeId : IdType<TreeId, unsigned int>;  
      And here is where I got in doubt. It seems both ways are valid, but there should be some differences. For example, with inheritance I can forward declare the TreeId on headers, which doesn't seem really feasible (in a painless way) with AnimalId. However, TreeId uses inheritance, and my knowledge on how inheritance and templates works "in background" is too weak to say, but it feels like there might be some hidden drawback.
      Are there differences to make deciding which one to use easier? Or there's currently no drawbacks (besides being able to forward declare or not)?
    • By komires
      We are pleased to announce the release of Matali Physics 4.0, the fourth major version of Matali Physics engine.
      What is Matali Physics?
      Matali Physics is an advanced, multi-platform, high-performance 3d physics engine intended for games, virtual reality and physics-based simulations. Matali Physics and add-ons form physics environment which provides complex physical simulation and physics-based modeling of objects both real and imagined. The engine is available across multiple platforms:
              Android         *BSD         iOS         Linux         OS X         SteamOS         Windows 10 UAP/UWP         Windows 7/8/8.1/10         Windows XP/Vista What's new in version 4.0?
               One extended edition of Matali Physics engine          Support for Android 8.0 Oreo, iOS 11.x and macOS High Sierra (version 10.13.x) as well as support for the latest IDEs          Matali Render 3.0 add-on with physically-based rendering (PBR), screen space ambient occlusion (SSAO) and support for Vulkan API          Matali Games add-on  
      Main benefits of using Matali Physics:
              Stable, high-performance solution supplied together with the rich set of add-ons for all major mobile and desktop platforms (both 32 and 64 bit)         Advanced samples ready to use in your own games         New features on request         Dedicated technical support         Regular updates and fixes
      The engine history in a nutshell
      Matali Physics was built in 2009 as a dedicated solution for XNA. The first complete version of the engine was released in November 2010, and it was further developed to July 2014 forming multi-platform, fully manage solution for .NET and Mono. In the meantime, from October 2013 to July 2014, was introduced simultaneous support for C++. A significant change occurred in July 2014 together with the release of version 3.0. Managed version of the engine has been abandoned, and the engine was released solely with a new native core written entirely in modern C++. Currently the engine is intensively developed as an advanced, cross-platform, high-performance 3d physics solution.
       
      If you have questions related to the latest update or use of Matali Physics engine as a stable physics solution in your projects, please don't hesitate to contact us.

      View full story
    • By Manumeq
      Hello everyone.
      Me and a bunch of classmates are making a videogame from scratch in c++. We are currently using the Irrlicht Engine in our code, but will begin to develop our own engine in a couple of weeks. One of our concerns right now is the User Interface.
      After doing some research, I found several libraries for creating a GUI in c++, problem is in the past we have spent more time learning and figuring out how to make things work with libraries than we would have if we actually made the entire code from scratch ourselves.
      So, I wanted to ask more experienced game programmers out there, what would be your preferred choice? using a library or writting the code from scratch when making an UI, and in case of the libraries, which ones would you use?.
      Heres what we will most likely do:
      Healthbars Displaying numbers in HUD Displaying icons (images) in HUD Drawing game menu elements (text and rectangles) Also, we are currently working in linux, more specifically Manjaro KDE and without IDE's (using our own make file and the console).
      PD: Sorry in advance is this is in the wrong topic, It's my first time asking a question in GameDev.net
  • Popular Now