lethal-guitar / RigelEngine

A modern re-implementation of the classic DOS game Duke Nukem II
GNU General Public License v2.0
911 stars 60 forks source link

SDL renderer backend #920

Open mardy opened 5 months ago

mardy commented 5 months ago

Hi there! I was considering the idea of porting this game to the Nintendo Wii, but it looks like it isn't doable right now, since there is no OpenGL library for the Wii.

I had a look at the renderer.hpp file, and at first sight I didn't find anything in there that would not be possible to implement using the SDL_Renderer API (please correct me if I'm wrong). It would be nice if the renderer was reimplemented using the SDL_Renderer API, because then it would be portable to any platform which supports SDL2. I found issue #907 about the 3DS, for instance.

lethal-guitar commented 5 months ago

Hi, nice, that'd be really cool to see it running on a Wii 🙂 It would indeed be great to have the option for solely SDL-based rendering for increased portability. It's not quite as straightforward as it may seem at first though:

I had a look at the renderer.hpp file, and at first sight I didn't find anything in there that would not be possible to implement using the SDL_Renderer API

While the majority of the interface could easily be implemented using SDL_Renderer, there are certain special effects (white damage flash for sprites, underwater effect, cloak powerup translucency effect) which need custom shaders. On top of that, map tile rendering uses VBOs for efficiency.

For reference, see: https://github.com/lethal-guitar/RigelEngine/blob/master/src/engine/graphical_effects.cpp https://github.com/lethal-guitar/RigelEngine/blob/6f762298cf78fba25fc552e469f2d702da14f925/src/engine/map_renderer.cpp#L132

That being said, there are definitely ways around this. The tile rendering used to be more straightforward earlier in the project, so you could revert that part of the code to before the changes were made (the relevant commit: https://github.com/lethal-guitar/RigelEngine/commit/3fe48b8a9e8967d186b092029758e98cf4f81a2f).

As for the special effects, those could also be implemented on the CPU to avoid the need for dedicated shaders.