Allow to momentarily disable multisample antialiasing. Used for UI and fullscreen quad rendering.

This commit is contained in:
Lasse Öörni 2014-10-20 22:17:29 +03:00
Родитель 6099f0aafd
Коммит 59d48c1a43
7 изменённых файлов: 54 добавлений и 10 удалений

Просмотреть файл

@ -406,6 +406,7 @@ void DebugRenderer::Render()
graphics->SetColorWrite(true);
graphics->SetCullMode(CULL_NONE);
graphics->SetDepthWrite(true);
graphics->SetDrawAntialiased(true);
graphics->SetScissorTest(false);
graphics->SetStencilTest(false);
graphics->SetShaders(vs, ps);

Просмотреть файл

@ -1795,6 +1795,16 @@ void Graphics::SetDepthWrite(bool enable)
depthWrite_ = enable;
}
}
void Graphics::SetDrawAntialiased(bool enable)
{
if (enable != drawAntialiased_)
{
impl_->device_->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, enable ? TRUE : FALSE);
drawAntialiased_ = enable;
}
}
void Graphics::SetFillMode(FillMode mode)
{
if (mode != fillMode_)
@ -2767,6 +2777,7 @@ void Graphics::ResetCachedState()
stencilCompareMask_ = M_MAX_UNSIGNED;
stencilWriteMask_ = M_MAX_UNSIGNED;
useClipPlane_ = false;
drawAntialiased_ = true;
impl_->blendEnable_ = FALSE;
impl_->srcBlend_ = D3DBLEND_ONE;
impl_->destBlend_ = D3DBLEND_ZERO;

Просмотреть файл

@ -202,6 +202,8 @@ public:
void SetDepthTest(CompareMode mode);
/// Set depth write on/off.
void SetDepthWrite(bool enable);
/// Set antialiased drawing mode on/off. Default is on if the backbuffer is multisampled. Has no effect when backbuffer is not multisampled.
void SetDrawAntialiased(bool enable);
/// Set polygon fill mode.
void SetFillMode(FillMode mode);
/// Set scissor test.
@ -337,6 +339,8 @@ public:
CompareMode GetDepthTest() const { return depthTestMode_; }
/// Return whether depth write is enabled.
bool GetDepthWrite() const { return depthWrite_; }
/// Return whether antialiased drawing mode is enabled.
bool GetDrawAntialiased() const { return drawAntialiased_; }
/// Return polygon fill mode.
FillMode GetFillMode() const { return fillMode_; }
/// Return whether stencil test is enabled.
@ -566,16 +570,18 @@ private:
StencilOp stencilFail_;
/// Stencil operation on depth fail.
StencilOp stencilZFail_;
/// Stencil test enable flag.
bool stencilTest_;
/// Stencil test reference value.
unsigned stencilRef_;
/// Stencil compare bitmask.
unsigned stencilCompareMask_;
/// Stencil write bitmask.
unsigned stencilWriteMask_;
/// Stencil test enable flag.
bool stencilTest_;
/// Custom clip plane enable flag.
bool useClipPlane_;
/// Draw antialiased mode flag.
bool drawAntialiased_;
/// Default texture filtering mode.
TextureFilterMode defaultTextureFilterMode_;
/// Remembered shader parameter sources.

Просмотреть файл

@ -244,8 +244,8 @@ Graphics::Graphics(Context* context_) :
dummyColorFormat_(0),
shadowMapFormat_(GL_DEPTH_COMPONENT16),
hiresShadowMapFormat_(GL_DEPTH_COMPONENT24),
defaultTextureFilterMode_(FILTER_BILINEAR),
releasingGPUObjects_(false),
defaultTextureFilterMode_(FILTER_BILINEAR),
shaderPath_("Shaders/GLSL/"),
shaderExtension_(".glsl"),
orientations_("LandscapeLeft LandscapeRight")
@ -1755,6 +1755,20 @@ void Graphics::SetDepthWrite(bool enable)
}
}
void Graphics::SetDrawAntialiased(bool enable)
{
if (enable != drawAntialiased_)
{
#ifndef GL_ES_VERSION_2_0
if (enable)
glEnable(GL_MULTISAMPLE);
else
glDisable(GL_MULTISAMPLE);
#endif
drawAntialiased_ = enable;
}
}
void Graphics::SetFillMode(FillMode mode)
{
#ifndef GL_ES_VERSION_2_0
@ -2936,8 +2950,9 @@ void Graphics::ResetCachedState()
stencilRef_ = 0;
stencilCompareMask_ = M_MAX_UNSIGNED;
stencilWriteMask_ = M_MAX_UNSIGNED;
lastInstanceOffset_ = 0;
useClipPlane_ = false;
drawAntialiased_ = true;
lastInstanceOffset_ = 0;
impl_->activeTexture_ = 0;
impl_->enabledAttributes_ = 0;
impl_->boundFbo_ = impl_->systemFbo_;

Просмотреть файл

@ -206,6 +206,8 @@ public:
void SetDepthTest(CompareMode mode);
/// Set depth write on/off.
void SetDepthWrite(bool enable);
/// Set antialiased drawing mode on/off. Default is on if the backbuffer is multisampled. Has no effect when backbuffer is not multisampled.
void SetDrawAntialiased(bool enable);
/// Set polygon fill mode.
void SetFillMode(FillMode mode);
/// Set scissor test.
@ -345,6 +347,8 @@ public:
CompareMode GetDepthTest() const { return depthTestMode_; }
/// Return whether depth write is enabled.
bool GetDepthWrite() const { return depthWrite_; }
/// Return whether antialiased drawing mode is enabled.
bool GetDrawAntialiased() const { return drawAntialiased_; }
/// Return polygon fill mode.
FillMode GetFillMode() const { return fillMode_; }
/// Return whether stencil test is enabled.
@ -568,14 +572,20 @@ private:
StencilOp stencilFail_;
/// Stencil operation on depth fail.
StencilOp stencilZFail_;
/// Stencil test enable flag.
bool stencilTest_;
/// Stencil test reference value.
unsigned stencilRef_;
/// Stencil compare bitmask.
unsigned stencilCompareMask_;
/// Stencil write bitmask.
unsigned stencilWriteMask_;
/// Stencil test enable flag.
bool stencilTest_;
/// Custom clip plane enable flag.
bool useClipPlane_;
/// Draw antialiased mode flag.
bool drawAntialiased_;
/// Releasing GPU objects flag.
bool releasingGPUObjects_;
/// Last used instance data offset.
unsigned lastInstanceOffset_;
/// Default texture filtering mode.
@ -588,10 +598,6 @@ private:
Matrix3 tempMatrices3_[NUM_TEMP_MATRICES];
/// Temp matrices for transposing shader parameters.
Matrix4 tempMatrices4_[NUM_TEMP_MATRICES];
/// Custom clip plane enable flag.
bool useClipPlane_;
/// Releasing GPU objects flag.
bool releasingGPUObjects_;
/// Base directory for shaders.
String shaderPath_;
/// File extension for shaders.

Просмотреть файл

@ -1464,6 +1464,7 @@ void View::ExecuteRenderPathCommands()
SetRenderTargets(command);
SetTextures(command);
graphics_->SetDrawAntialiased(true);
graphics_->SetFillMode(camera_->GetFillMode());
graphics_->SetClipPlane(camera_->GetUseClipping(), camera_->GetClipPlane(), camera_->GetView(), camera_->GetProjection());
batchQueues_[command.pass_].Draw(this, command.markToStencil_, false);
@ -1498,6 +1499,7 @@ void View::ExecuteRenderPathCommands()
}
SetTextures(command);
graphics_->SetDrawAntialiased(true);
graphics_->SetFillMode(camera_->GetFillMode());
graphics_->SetClipPlane(camera_->GetUseClipping(), camera_->GetClipPlane(), camera_->GetView(), camera_->GetProjection());
@ -1703,6 +1705,7 @@ void View::RenderQuad(RenderPathCommand& command)
graphics_->SetBlendMode(BLEND_REPLACE);
graphics_->SetDepthTest(CMP_ALWAYS);
graphics_->SetDepthWrite(false);
graphics_->SetDrawAntialiased(false);
graphics_->SetFillMode(FILL_SOLID);
graphics_->SetClipPlane(false);
graphics_->SetScissorTest(false);
@ -2796,6 +2799,7 @@ void View::RenderShadowMap(const LightBatchQueue& queue)
graphics_->SetTexture(TU_SHADOWMAP, 0);
graphics_->SetColorWrite(false);
graphics_->SetDrawAntialiased(true);
graphics_->SetFillMode(FILL_SOLID);
graphics_->SetClipPlane(false);
graphics_->SetStencilTest(false);

Просмотреть файл

@ -699,6 +699,7 @@ void UI::Render(VertexBuffer* buffer, const PODVector<UIBatch>& batches, unsigne
graphics_->SetCullMode(CULL_CCW);
graphics_->SetDepthTest(CMP_ALWAYS);
graphics_->SetDepthWrite(false);
graphics_->SetDrawAntialiased(false);
graphics_->SetStencilTest(false);
graphics_->ResetRenderTargets();
graphics_->SetVertexBuffer(buffer);