SDL2 - Draw fully-transparent circle on a texture
<p>I'm developing a 2D game in SDL 2.0 and I'm having am trouble with my lighting system. I want to fill the screen with fog and create a transparent circle around the player (lower-left). I know how to make a dark room with a tinted light using SDL_BLENDMODE_MOD (lower-right), but I cannot make the fog. I have tried layering multiple textures over the screen with every combination of SDL_SetRenderDrawBlendMode() and SDL_SetTextureBlendMode() I can think of.</p>

<p><img src="https://i.stack.imgur.com/YmX59.png" alt="image"></p>

<p>I have searched and found solutions on StackOverflow like <a href="https://stackoverflow.com/questions/13654753/sdl-drawing-negative-circles-fog-of-war">this</a>, but they use SDL surfaces and pre-made light images. I am going to be dynamically changing the shape and size of my input image (upper-right) so I need something more flexible.</p>

<p>Solution 1: Instead of a white circle and black background, I use a black circle and navy background. I then blend this using <a href="https://en.wikipedia.org/wiki/Blend_modes#Screen" rel="nofollow noreferrer">screen blending</a> and get my fog (I've tested this in an image editor to get the lower-left image). Unfortunately, SDL does not have a SDL_BLENDMODE_SCREEN.</p>

<p>Solution 2: Create a semitransparent fog layer and punch a fully-transparent hole in it. Unfortunately, I don't know how to overwrite a texture with a transparent hole. I have tried setting my <a href="https://wiki.libsdl.org/SDL_SetRenderDrawBlendMode" rel="nofollow noreferrer">drawing mode</a> to SDL_BLENDMODE_NONE and drawing a fully-transparent circle, but it only creates fully-opaque ones. The documentation says I can replace the destination alpha but that doesn't seem to work...</p>