I have a “3D” isometric tile graphic which is loaded as a SDL_Texture that looks like this:
I want to do transformations of the SDL_FLIP_HORIZONTAL/VERTICIAL variety. The issue is I only want the top “isometric” face to be transformed not the bottom base (so imagine flipping the beach vertically so that water is on top instead on the bottom)
Is it possible to do this using SDL2? The only thing I can think of is to write a custom function that loops through the texture pixel by pixel and identify the rhombus on which the top face sits and flip it manually. Is that even possible?
Can’t you use two textures? One for the top and one for the base.
That’s an interesting idea! I never thought about it. I will give it a try. My only caveat right is now that I am drawing a lot of tiles on screen I have noticed the primary burden on FPS in my game is performing these drawing operations.
I think you can also get something like this with SDL_RenderGeometry. You need to specify the vertices according to the corners of the rhombus and in the right order to get the desired result. And then do the same with the “base” of this platform (these brown bars at the bottom).
However, this is not a good idea, because it will save some memory (fewer textures), but the code will become significantly more complicated — you will have to write a lot more code. Besides, this texture is pixel art and it is not known if the driver will render it correctly (whether the edges will look like in the original texture).
Therefore, IMO, the best solution will be to create two textures (rhombus with the content of different platforms and a separate texture with the base of the rhombus), and render each one with SDL_RenderCopyEx. Even more so if the base of each platform is the same — one texture is enough for it, so it saves memory.