C++ OpenGL - 2D Lighting Around Object in a Pitch-Black Environment

by jadenPete   Last Updated August 03, 2016 08:05 AM

I am making a 2D game in C++ with OpenGL where a maze is generated and you have to move the character through the maze and get it to the end. I have achieved all this, but now I want to make it more challenging by having everything pitch-black but a small light around the character. How can I achieve this? I don't want the light to be complicated and I don't want it to only go through the tunnels. I just want a simple light around the character to illuminate that area of the maze.



Answers 1


You can use the stencil buffer:

https://en.m.wikibooks.org/wiki/OpenGL_Programming/Stencil_buffer http://learnopengl.com/#!Advanced-OpenGL/Stencil-testing

This is what you are looking for?

Naor Hadar
Naor Hadar
August 03, 2016 11:06 AM

Related Questions


Incorrect Normal Matrix

Updated April 19, 2015 20:05 PM

GL_SPOT_CUTOFF not working properly

Updated April 22, 2015 04:05 AM

Handling light bounding volume

Updated May 29, 2016 08:05 AM

How to generate a multiplier map for radiosity

Updated August 27, 2016 08:05 AM

Negating directional light's direction

Updated January 27, 2017 14:05 PM