An enchanting engine where magic and technology intertwine
Rendering wall textures and change to level configuration
created: 2025-03-11 04:36:33 UTC last updated: 2025-03-11 04:36:48 UTC
I am now rendering textures to the wall appropriately! Screenshot 2025-03-10 at 9.28.33 PM.png616 KB As shown above, we have walls consisting of different textures as defined by the map below.
One major change is in the sprites. I maintain two unordered_maps, one for sprites and one for wall textures. The wall textures are keyed off of the id. So in the map above, a wall Id of 1 maps to the redbrick, Id 2maps to the graystone and so forth. So when a ray hits a wall that is a 2, the ray store that 2. During wall rendering, we query the unordered_map for wall textures for the texture with the Id 2 which will return the SDL_Surface.
That is another change I made. SDL_Texture utilize the GPU hardware and therefore, are not directly accessible via a buffer of pixels. Changing to storing textures in memory as an SDL_Surface make the pixel buffer accessible to the CPU. The SDL_Textures are more performant, but that is more of utilizing the GPU on the machine. Since I am going for a Wolfenstein style engine, we want to render strictly from the CPU. At least unless I decided to convert the rendering to using SDL_gpu, but as of right now, that is not my intention so far.