[Refactor] (MG_State/RenderState): Separate RenderStateParameters from RenderState.

This commit is contained in:
BZLZHH
2026-02-03 17:29:55 +08:00
parent 522d5ad9f7
commit afa89772e7
2 changed files with 103 additions and 100 deletions
@@ -7,9 +7,8 @@
// End of Source File Header
#pragma once
#include "MG_Util/Math/VectorTypes.h"
#include "MG_Util/Types.h"
#include <Includes.h>
#include <MG_Util/Math/VectorTypes.h>
namespace MobileGL {
enum class BlendFactor {
@@ -128,6 +127,42 @@ namespace MobileGL {
Int Alignment = 4;
};
struct RenderStateParameters {
// Rasterization
IntVec4 Viewport = IntVec4(0, 0, 0, 0); // x, y, width, height
// Blending
Bool BlendEnabled = false;
BlendFactor SrcFactorRGB = BlendFactor::One;
BlendFactor DstFactorRGB = BlendFactor::Zero;
BlendFactor SrcFactorAlpha = BlendFactor::One;
BlendFactor DstFactorAlpha = BlendFactor::Zero;
// Depth
Bool DepthTestEnabled = false;
DepthTestFunc DepthFunc = DepthTestFunc::Less;
Bool DepthMask = true;
// Color Mask
BoolVec4 ColorMask = BoolVec4(true, true, true, true);
// Clear State
FloatVec4 ClearColor = FloatVec4(0.0f, 0.0f, 0.0f, 1.0f);
Float ClearDepth = 1.0f;
// Pixel Store
PixelStoreParameters PackParameters;
PixelStoreParameters UnpackParameters;
// Cull Face
Bool CullFaceEnabled = false;
CullFaceMode CullFaceModeSetting = CullFaceMode::Back;
// Scissor
Bool ScissorTestEnabled = false;
IntVec4 ScissorBox = IntVec4(0, 0, 0, 0); // x, y, width, height
};
namespace MG_State {
namespace GLState {
class RenderState {
@@ -177,39 +212,7 @@ namespace MobileGL {
const IntVec4& GetScissorBox() const; // x, y, width, height
private:
// Rasterization
IntVec4 m_viewport = IntVec4(0, 0, 0, 0); // x, y, width, height
// Blending
Bool m_blendEnabled = false;
BlendFactor m_srcFactorRGB = BlendFactor::One;
BlendFactor m_dstFactorRGB = BlendFactor::Zero;
BlendFactor m_srcFactorAlpha = BlendFactor::One;
BlendFactor m_dstFactorAlpha = BlendFactor::Zero;
// Depth
Bool m_depthTestEnabled = false;
DepthTestFunc m_depthFunc = DepthTestFunc::Less;
Bool m_depthMask = true;
// Color Mask
BoolVec4 m_colorMask = BoolVec4(true, true, true, true);
// Clear State
FloatVec4 m_clearColor = FloatVec4(0.0f, 0.0f, 0.0f, 1.0f);
Float m_clearDepth = 1.0f;
// Pixel Store
PixelStoreParameters m_packParameters;
PixelStoreParameters m_unpackParameters;
// Cull Face
Bool m_cullFaceEnabled = false;
CullFaceMode m_cullFaceMode = CullFaceMode::Back;
// Scissor
Bool m_scissorTestEnabled = false;
IntVec4 m_scissorBox = IntVec4(0, 0, 0, 0); // x, y, width, height
RenderStateParameters m_parameters;
};
} // namespace GLState
} // namespace MG_State