[Feat] (GL_State/RenderState): implement ClearStencil

This commit is contained in:
2026-02-17 08:17:26 +08:00
parent 781bda2573
commit f8f3d6e657
6 changed files with 30 additions and 6 deletions
+2 -2
View File
@@ -721,7 +721,7 @@ namespace MobileGL {
*params = 0; // TODO
break;
case GL_STENCIL_CLEAR_VALUE:
*params = 0; // TODO
*params = MG_State::pGLContext->GetClearStencil();
break;
case GL_STENCIL_FAIL:
*params = 0; // TODO
@@ -922,4 +922,4 @@ namespace MobileGL {
return MG_Util::ConvertErrorCodeToGLEnum(errorCode);
}
} // namespace MG_Impl::GLImpl
} // namespace MobileGL
} // namespace MobileGL
@@ -261,7 +261,7 @@ namespace MobileGL {
}
void ClearStencil_State(GLint s) {
// TODO: implement
MG_State::pGLContext->SetClearStencil(static_cast<Int>(s));
}
void ClearDepth_State(GLclampd depth) {
+9 -1
View File
@@ -312,6 +312,14 @@ namespace MobileGL {
return m_renderState.GetClearDepth();
}
void GLContext::SetClearStencil(Int stencil) {
m_renderState.SetClearStencil(stencil);
}
Int GLContext::GetClearStencil() const {
return m_renderState.GetClearStencil();
}
void GLContext::SetPixelStoreParam(PixelStoreParam param, Int value) {
m_renderState.SetPixelStoreParam(param, value);
}
@@ -432,4 +440,4 @@ namespace MobileGL {
GLState::GLContext* pGLContext;
} // namespace MG_State
} // namespace MobileGL
} // namespace MobileGL
+3 -1
View File
@@ -111,6 +111,8 @@ namespace MobileGL {
const FloatVec4& GetClearColor() const;
void SetClearDepth(Float depth);
Float GetClearDepth() const;
void SetClearStencil(Int stencil);
Int GetClearStencil() const;
void SetPixelStoreParam(PixelStoreParam param, Int value);
Int GetPixelStoreParam(PixelStoreParam param) const;
PixelStoreParameters GetPixelStoreParameters(Bool isUnpack) const;
@@ -161,4 +163,4 @@ namespace MobileGL {
extern GLState::GLContext* pGLContext;
} // namespace MG_State
} // namespace MobileGL
} // namespace MobileGL
@@ -222,6 +222,17 @@ namespace MobileGL {
return m_parameters.ClearDepth;
}
void RenderState::SetClearStencil(Int stencil) {
if (m_parameters.ClearStencil == stencil) return;
m_parameters.ClearStencil = stencil;
++m_version;
}
Int RenderState::GetClearStencil() const {
return m_parameters.ClearStencil;
}
// -------------------- Pixel Store --------------------
void RenderState::SetPixelStoreParam(PixelStoreParam param, Int value) {
#define SET_PIXEL_STORE_PARAM(paramNameHead, paramNameTail, val) \
@@ -154,6 +154,7 @@ namespace MobileGL {
// Clear State
FloatVec4 ClearColor = FloatVec4(0.0f, 0.0f, 0.0f, 1.0f);
Float ClearDepth = 1.0f;
Int ClearStencil = 0;
// Cull Face
Bool CullFaceEnabled = false;
@@ -207,6 +208,8 @@ namespace MobileGL {
const FloatVec4& GetClearColor() const;
void SetClearDepth(Float depth);
Float GetClearDepth() const;
void SetClearStencil(Int stencil);
Int GetClearStencil() const;
// Pixel Store
void SetPixelStoreParam(PixelStoreParam param, Int value);
@@ -231,4 +234,4 @@ namespace MobileGL {
};
} // namespace GLState
} // namespace MG_State
} // namespace MobileGL
} // namespace MobileGL