[Feat] (ProgramState): Implement more Global-GL-State functions.

- These functions were implemented:
  - glBlendFunc
  - glBlendFuncSeparate
  - glClear
  - glClearColor
  - glClearDepth
  - glColorMask
  - glDepthFunc
  - glDepthMask
  - glDisable
  - glEnable
  - glViewport
This commit is contained in:
BZLZHH
2025-05-04 02:09:25 +08:00
parent 16559291a3
commit 0e7483bdd4
8 changed files with 326 additions and 17 deletions
+40
View File
@@ -10,11 +10,51 @@
class CommonState {
private:
// Pixel storage parameters
std::unordered_map<GLenum, GLint> pixelStoreParams;
// Blend state
GLenum blendSrcRGB = GL_ONE;
GLenum blendDstRGB = GL_ZERO;
GLenum blendSrcAlpha = GL_ONE;
GLenum blendDstAlpha = GL_ZERO;
// Clear state
GLfloat clearColor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
GLfloat clearDepth = 1.0f;
// Color mask
GLboolean colorMask[4] = {GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE};
// Depth state
GLenum depthFunc = GL_LESS;
GLboolean depthMask = GL_TRUE;
// Viewport
GLint viewport[4] = {0, 0, 0, 0};
// Capability enables
std::unordered_map<GLenum, bool> capabilities;
public:
CommonState();
// Return: the validity of the operation, according to OpenGL 3 standard
GLenum SetPixelStoreInt(GLenum pname, GLint param);
GLenum Enable(GLenum cap);
GLenum Disable(GLenum cap);
GLenum BlendFunc(GLenum sfactor, GLenum dfactor);
GLenum BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
GLenum srcAlpha, GLenum dstAlpha);
GLenum Clear(GLbitfield mask);
GLenum ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
GLenum ClearDepth(GLfloat depth);
GLenum ColorMask(GLboolean red, GLboolean green,
GLboolean blue, GLboolean alpha);
GLenum DepthFunc(GLenum func);
GLenum DepthMask(GLboolean flag);
GLenum Viewport(GLint x, GLint y, GLsizei width, GLsizei height);
GLint QueryPixelStoreInt(GLenum pname);
};