I’m new to SDL, and finding it a little hard finding examples and on SDL2 rather than the previous version, so thanks in advance for the help.
I’m trying to get my head around using the hardware acceleration and so trying to recode a game I have in Flash in SDL using C++, while using SDL 1.2 examples updating them to SDL2. I’m in a bit of a tangle.
It’s an overhead view RPG type thing, nothing new, but have a map of tiles and a camera view that shows part of it, centred over he player character.
I got it working by manipulating all the parts of surfaces in local memory then doing an SDL_UpdateTexture() and SDL_Present(). I want to be using textures I think, it’s very SDL 1 rather than SDL2 (if that makes sense)
I thought that by adding SDL_RENDERER_PRESENTVSYNC to the SDL_CreateRenderer flags I’d be able to remove some code from my main loop (the call to UpdateTexture I was previously calling 65 times a second, or the call the RenderPresent()). I can’t - what does the flag actually do if I still have to update and present manually?
This one is more important! I’m trying to change it so that it’s working from textures, but is this more correct than building surfaces then passing a texture over? Currently I’m changing it so as it loads each graphic it converts it straight to a texture, then I’m trying to build the map from those as the camera moves around. Is the idea to get everything as textures then manipulate them in GPU memory? Have I made a silly mistake in understanding what needs to be done?
All I can find are simple examples to put an image on the screen, which use textures (but without any worry of performance as simply 4 tiles, not the few 10 - 1000 that I need) and lots of old SDL 1.2 code which prepares images as surfaces then ‘Flips’ (?) them to the screen.
Thanks, help much appreciated.