basic question on textures |
basic question on textures |
Jonas Kulla
Guest
|
2014-04-04 18:29 GMT+02:00 catslap:
Regarding 1) This is a hint to the graphics driver to limit and sync your redraw rate to your monitor's refresh rate (in most cases 60Hz). RenderPresent will delay the execution of your program until the next monitor refresh (thus creating the frame limit without you having to do any manual timer shenanigans). You should _not_ change any part in your code when requesting vsync. Just keep on drawing and calling RenderPresent. Using vsync prevents screen tearing, and also stops your application from wasting cycles drawing stuff that your user won't see anyway; on the other hand, your game logic might be very slightly delayed. Note that this is only a hint. The driver is always free to override it and force vsync on or off depending on other factors. Some platforms don't support it at all. |
|||||||||||||
|
basic question on textures |
Jeffrey Carpenter
Guest
|
In regards to question two,
As I understand it, the general idea is basically best -- in terms of efficiency -- is to use surfaces for anytime you need pixel-level manipulation (think: post processing some effect, collision detection, rescaling and so on). So, if after loading the texture map, if all that you need to do is render to display, then yes, straight to texture is best. Otherwise, do your processing effects while it is still a surface, and then render as a texture -- you can think of textures as a "ready to render" data type. Surfaces are CPU bound, whereas textures are GPU bound. The biggest expense with textures tends to be the moment of uploading said texture to the GPU, so anytime you can minimize this, the better off you are (think: sprite sheets / atlas pages). Lastly, do especially note on the SDL2 wiki docs page for SDL_LockTexture under remarks -- "As an optimization, the pixels made available for editing don't necessarily contain the old texture data. This is a write-only operation, and if you need to keep a copy of the texture data you should do that at the application level." AKA you should never count on the pixels read from a texture to necessarily be accurate (sorry, I don't know the details as to why, when and what not). As per the migration docs, "SDL_TEXTUREACCESS_STREAMING" type textures can be used for uploading fully-rendered frames onto the screen, which sounds like it may be the type you are interested in. I hope that my detail helped somewhat, I'm still getting the hang of SDL2 and the concept of GPU textures, too. Cheers, Jeffrey Carpenter On 2014/04/ 04, at 11:29, catslap wrote:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
catslap
|
Thank you!
|
|||||||||||
|