Expose stencil buffer to render code.
The intention is to provide a layer for tracking shadow rendering, so a single bit is sufficient for now.
This commit is contained in:
@@ -53,6 +53,9 @@ namespace OpenRA.FileFormats.Graphics
|
||||
|
||||
void EnableDepthBuffer();
|
||||
void DisableDepthBuffer();
|
||||
|
||||
void EnableStencilBuffer();
|
||||
void DisableStencilBuffer();
|
||||
}
|
||||
|
||||
public interface IVertexBuffer<T>
|
||||
|
||||
@@ -198,5 +198,17 @@ namespace OpenRA.Graphics
|
||||
Flush();
|
||||
Device.DisableDepthBuffer();
|
||||
}
|
||||
|
||||
public void EnableStencilBuffer()
|
||||
{
|
||||
Flush();
|
||||
Device.EnableStencilBuffer();
|
||||
}
|
||||
|
||||
public void DisableStencilBuffer()
|
||||
{
|
||||
Flush();
|
||||
Device.DisableStencilBuffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@ namespace OpenRA.Renderer.Null
|
||||
public void EnableDepthBuffer() { }
|
||||
public void DisableDepthBuffer() { }
|
||||
|
||||
public void EnableStencilBuffer() { }
|
||||
public void DisableStencilBuffer() { }
|
||||
|
||||
public void Clear() { }
|
||||
public void Present() { }
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace OpenRA.Renderer.SdlCommon
|
||||
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_GREEN_SIZE, 8 );
|
||||
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_BLUE_SIZE, 8 );
|
||||
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_ALPHA_SIZE, 0 );
|
||||
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_STENCIL_SIZE, 1 );
|
||||
|
||||
int windowFlags = 0;
|
||||
switch (window)
|
||||
@@ -133,6 +134,24 @@ namespace OpenRA.Renderer.SdlCommon
|
||||
ErrorHandler.CheckGlError();
|
||||
}
|
||||
|
||||
public void EnableStencilBuffer()
|
||||
{
|
||||
Gl.glClear(Gl.GL_STENCIL_BUFFER_BIT);
|
||||
ErrorHandler.CheckGlError();
|
||||
Gl.glEnable(Gl.GL_STENCIL_TEST);
|
||||
ErrorHandler.CheckGlError();
|
||||
Gl.glStencilFunc(Gl.GL_NOTEQUAL, 1, 1);
|
||||
ErrorHandler.CheckGlError();
|
||||
Gl.glStencilOp(Gl.GL_KEEP, Gl.GL_KEEP, Gl.GL_INCR);
|
||||
ErrorHandler.CheckGlError();
|
||||
}
|
||||
|
||||
public void DisableStencilBuffer()
|
||||
{
|
||||
Gl.glDisable(Gl.GL_STENCIL_TEST);
|
||||
ErrorHandler.CheckGlError();
|
||||
}
|
||||
|
||||
public void EnableDepthBuffer()
|
||||
{
|
||||
Gl.glClear(Gl.GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
Reference in New Issue
Block a user