Run graphics rendering on a dedicated thread.
The main game thread can offload some of the CPU cost to the rendering thread, freeing up its time to run more logic and render ticks.
This commit is contained in:
committed by
Paul Chote
parent
ea068a36f7
commit
bb536ee4fc
@@ -18,12 +18,12 @@ namespace OpenRA.Platforms.Default
|
||||
{
|
||||
sealed class FrameBuffer : ThreadAffine, IFrameBuffer
|
||||
{
|
||||
readonly Texture texture;
|
||||
readonly ITexture texture;
|
||||
readonly Size size;
|
||||
uint framebuffer, depth;
|
||||
bool disposed;
|
||||
|
||||
public FrameBuffer(Size size)
|
||||
public FrameBuffer(Size size, ITextureInternal texture)
|
||||
{
|
||||
this.size = size;
|
||||
if (!Exts.IsPowerOf2(size.Width) || !Exts.IsPowerOf2(size.Height))
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Platforms.Default
|
||||
OpenGL.CheckGLError();
|
||||
|
||||
// Color
|
||||
texture = new Texture();
|
||||
this.texture = texture;
|
||||
texture.SetEmpty(size.Width, size.Height);
|
||||
OpenGL.glFramebufferTexture2D(OpenGL.FRAMEBUFFER_EXT, OpenGL.COLOR_ATTACHMENT0_EXT, OpenGL.GL_TEXTURE_2D, texture.ID, 0);
|
||||
OpenGL.CheckGLError();
|
||||
@@ -120,14 +120,9 @@ namespace OpenRA.Platforms.Default
|
||||
}
|
||||
}
|
||||
|
||||
~FrameBuffer()
|
||||
{
|
||||
Game.RunAfterTick(() => Dispose(false));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Game.RunAfterTick(() => Dispose(true));
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user