From e77b01ac84b51669b715d76d47504eec8911a235 Mon Sep 17 00:00:00 2001 From: BZLZHH Date: Fri, 3 Oct 2025 13:16:42 +0800 Subject: [PATCH] [Feat] (MG_Impl/RenderState): Implement some RenderState GL functions. --- CMakeLists.txt | 2 +- .../MG_Impl/GLImpl/Exporting/Definitions.cpp | 75 ++-- .../GLImpl/RenderState/GL_RenderState.cpp | 393 ++++++++++++++++++ .../GLImpl/RenderState/GL_RenderState.h | 45 ++ MobileGL/MG_State/GLState/Core.cpp | 4 +- MobileGL/MG_State/GLState/Core.h | 4 +- .../GLState/RenderState/RenderState.cpp | 4 +- .../GLState/RenderState/RenderState.h | 10 +- .../GLToMG/RenderStateEnumConverter.cpp | 20 +- .../GLToMG/RenderStateEnumConverter.h | 2 +- .../MGToGL/RenderStateEnumConverter.cpp | 18 +- .../MGToGL/RenderStateEnumConverter.h | 2 +- .../MGToStr/RenderStateEnumConverter.cpp | 18 +- .../MGToStr/RenderStateEnumConverter.h | 2 +- 14 files changed, 519 insertions(+), 80 deletions(-) create mode 100644 MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp create mode 100644 MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.h diff --git a/CMakeLists.txt b/CMakeLists.txt index ecd6d090..88d3682e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ set(SOURCE_FILES MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp # @INSERTION_POINT:SOURCE_FILE_GLIMPL@ # - #MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp + MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp MobileGL/MG_Impl/GLImpl/Framebuffer/Validators.cpp MobileGL/MG_Impl/GLImpl/Framebuffer/GL_Framebuffer.cpp MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp diff --git a/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp b/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp index 349ddbac..15f6cdb1 100644 --- a/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp +++ b/MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp @@ -3,6 +3,7 @@ #include "../Getter/GL_Getter.h" #include "../Program/GL_Program.h" #include "../Texture/GL_Texture.h" +#include "../RenderState/GL_RenderState.h" #include "../Framebuffer/GL_Framebuffer.h" #include "../VertexArray/GL_VertexArray.h" @@ -34,7 +35,7 @@ MOBILEGL_GL_API type gl##name(__VA_ARGS__) { DECLARE_GL_FUNCTION_HEAD(const GLubyte*, GetStringi, GLenum name, GLuint index) DECLARE_GL_FUNCTION_END(const GLubyte*, GetStringi, name, index) DECLARE_GL_FUNCTION_HEAD(const GLubyte*, GetString, GLenum name) DECLARE_GL_FUNCTION_END(const GLubyte*, GetString, name) DECLARE_GL_FUNCTION_HEAD(void*, MapBuffer, GLenum target, GLenum access) DECLARE_GL_FUNCTION_END(void*, MapBuffer, target, access) -DECLARE_GL_FUNCTION_STUB_HEAD(void, ClearDepth, GLclampd depth) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ClearDepth, depth) +DECLARE_GL_FUNCTION_HEAD(void, ClearDepth, GLclampd depth) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ClearDepth, depth) DECLARE_GL_FUNCTION_HEAD(void, ActiveTexture, GLenum texture) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ActiveTexture, texture) DECLARE_GL_FUNCTION_STUB_HEAD(void, AttachShader, GLuint program, GLuint shader) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, AttachShader, program, shader) DECLARE_GL_FUNCTION_STUB_HEAD(void, BindAttribLocation, GLuint program, GLuint index, const GLchar* name) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BindAttribLocation, program, index, name) @@ -42,19 +43,19 @@ DECLARE_GL_FUNCTION_HEAD(void, BindBuffer, GLenum target, GLuint buffer) DECLARE DECLARE_GL_FUNCTION_HEAD(void, BindFramebuffer, GLenum target, GLuint framebuffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindFramebuffer, target, framebuffer) DECLARE_GL_FUNCTION_HEAD(void, BindRenderbuffer, GLenum target, GLuint renderbuffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindRenderbuffer, target, renderbuffer) DECLARE_GL_FUNCTION_HEAD(void, BindTexture, GLenum target, GLuint texture) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindTexture, target, texture) -DECLARE_GL_FUNCTION_STUB_HEAD(void, BlendColor, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BlendColor, red, green, blue, alpha) -DECLARE_GL_FUNCTION_STUB_HEAD(void, BlendEquation, GLenum mode) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BlendEquation, mode) +DECLARE_GL_FUNCTION_HEAD(void, BlendColor, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BlendColor, red, green, blue, alpha) +DECLARE_GL_FUNCTION_HEAD(void, BlendEquation, GLenum mode) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BlendEquation, mode) DECLARE_GL_FUNCTION_STUB_HEAD(void, BlendEquationSeparate, GLenum modeRGB, GLenum modeAlpha) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BlendEquationSeparate, modeRGB, modeAlpha) -DECLARE_GL_FUNCTION_STUB_HEAD(void, BlendFunc, GLenum sfactor, GLenum dfactor) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BlendFunc, sfactor, dfactor) -DECLARE_GL_FUNCTION_STUB_HEAD(void, BlendFuncSeparate, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BlendFuncSeparate, sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha) +DECLARE_GL_FUNCTION_HEAD(void, BlendFunc, GLenum sfactor, GLenum dfactor) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BlendFunc, sfactor, dfactor) +DECLARE_GL_FUNCTION_HEAD(void, BlendFuncSeparate, GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BlendFuncSeparate, sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha) DECLARE_GL_FUNCTION_HEAD(void, BufferData, GLenum target, GLsizeiptr size, const void* data, GLenum usage) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BufferData, target, size, data, usage) DECLARE_GL_FUNCTION_HEAD(void, BufferSubData, GLenum target, GLintptr offset, GLsizeiptr size, const void* data) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BufferSubData, target, offset, size, data) DECLARE_GL_FUNCTION_HEAD(GLenum, CheckFramebufferStatus, GLenum target) DECLARE_GL_FUNCTION_END(GLenum, CheckFramebufferStatus, target) DECLARE_GL_FUNCTION_STUB_HEAD(void, Clear, GLbitfield mask) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Clear, mask) -DECLARE_GL_FUNCTION_STUB_HEAD(void, ClearColor, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ClearColor, red, green, blue, alpha) +DECLARE_GL_FUNCTION_HEAD(void, ClearColor, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ClearColor, red, green, blue, alpha) DECLARE_GL_FUNCTION_STUB_HEAD(void, ClearDepthf, GLfloat d) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ClearDepthf, d) -DECLARE_GL_FUNCTION_STUB_HEAD(void, ClearStencil, GLint s) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ClearStencil, s) -DECLARE_GL_FUNCTION_STUB_HEAD(void, ColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ColorMask, red, green, blue, alpha) +DECLARE_GL_FUNCTION_HEAD(void, ClearStencil, GLint s) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ClearStencil, s) +DECLARE_GL_FUNCTION_HEAD(void, ColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ColorMask, red, green, blue, alpha) DECLARE_GL_FUNCTION_STUB_HEAD(void, CompileShader, GLuint shader) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, CompileShader, shader) DECLARE_GL_FUNCTION_HEAD(void, CompressedTexImage2D, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CompressedTexImage2D, target, level, internalformat, width, height, border, imageSize, data) DECLARE_GL_FUNCTION_HEAD(void, CompressedTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CompressedTexSubImage2D, target, level, xoffset, yoffset, width, height, format, imageSize, data) @@ -62,28 +63,28 @@ DECLARE_GL_FUNCTION_HEAD(void, CopyTexImage2D, GLenum target, GLint level, GLenu DECLARE_GL_FUNCTION_HEAD(void, CopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CopyTexSubImage2D, target, level, xoffset, yoffset, x, y, width, height) DECLARE_GL_FUNCTION_STUB_HEAD(GLuint, CreateProgram) DECLARE_GL_FUNCTION_STUB_END(GLuint, CreateProgram) DECLARE_GL_FUNCTION_STUB_HEAD(GLuint, CreateShader, GLenum type) DECLARE_GL_FUNCTION_STUB_END(GLuint, CreateShader, type) -DECLARE_GL_FUNCTION_STUB_HEAD(void, CullFace, GLenum mode) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, CullFace, mode) +DECLARE_GL_FUNCTION_HEAD(void, CullFace, GLenum mode) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CullFace, mode) DECLARE_GL_FUNCTION_HEAD(void, DeleteBuffers, GLsizei n, const GLuint* buffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DeleteBuffers, n, buffers) DECLARE_GL_FUNCTION_HEAD(void, DeleteFramebuffers, GLsizei n, const GLuint* framebuffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DeleteFramebuffers, n, framebuffers) DECLARE_GL_FUNCTION_STUB_HEAD(void, DeleteProgram, GLuint program) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DeleteProgram, program) DECLARE_GL_FUNCTION_HEAD(void, DeleteRenderbuffers, GLsizei n, const GLuint* renderbuffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DeleteRenderbuffers, n, renderbuffers) DECLARE_GL_FUNCTION_STUB_HEAD(void, DeleteShader, GLuint shader) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DeleteShader, shader) DECLARE_GL_FUNCTION_HEAD(void, DeleteTextures, GLsizei n, const GLuint* textures) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DeleteTextures, n, textures) -DECLARE_GL_FUNCTION_STUB_HEAD(void, DepthFunc, GLenum func) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DepthFunc, func) -DECLARE_GL_FUNCTION_STUB_HEAD(void, DepthMask, GLboolean flag) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DepthMask, flag) +DECLARE_GL_FUNCTION_HEAD(void, DepthFunc, GLenum func) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DepthFunc, func) +DECLARE_GL_FUNCTION_HEAD(void, DepthMask, GLboolean flag) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DepthMask, flag) DECLARE_GL_FUNCTION_STUB_HEAD(void, DepthRangef, GLfloat n, GLfloat f) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DepthRangef, n, f) DECLARE_GL_FUNCTION_STUB_HEAD(void, DetachShader, GLuint program, GLuint shader) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DetachShader, program, shader) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Disable, GLenum cap) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Disable, cap) +DECLARE_GL_FUNCTION_HEAD(void, Disable, GLenum cap) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Disable, cap) DECLARE_GL_FUNCTION_HEAD(void, DisableVertexAttribArray, GLuint index) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DisableVertexAttribArray, index) DECLARE_GL_FUNCTION_STUB_HEAD(void, DrawArrays, GLenum mode, GLint first, GLsizei count) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DrawArrays, mode, first, count) DECLARE_GL_FUNCTION_STUB_HEAD(void, DrawElements, GLenum mode, GLsizei count, GLenum type, const void* indices) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DrawElements, mode, count, type, indices) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Enable, GLenum cap) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Enable, cap) +DECLARE_GL_FUNCTION_HEAD(void, Enable, GLenum cap) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Enable, cap) DECLARE_GL_FUNCTION_HEAD(void, EnableVertexAttribArray, GLuint index) DECLARE_GL_FUNCTION_END_NO_RETURN(void, EnableVertexAttribArray, index) DECLARE_GL_FUNCTION_STUB_HEAD(void, Finish) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Finish) DECLARE_GL_FUNCTION_STUB_HEAD(void, Flush) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Flush) DECLARE_GL_FUNCTION_HEAD(void, FramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FramebufferRenderbuffer, target, attachment, renderbuffertarget, renderbuffer) DECLARE_GL_FUNCTION_HEAD(void, FramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FramebufferTexture2D, target, attachment, textarget, texture, level) -DECLARE_GL_FUNCTION_STUB_HEAD(void, FrontFace, GLenum mode) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, FrontFace, mode) +DECLARE_GL_FUNCTION_HEAD(void, FrontFace, GLenum mode) DECLARE_GL_FUNCTION_END_NO_RETURN(void, FrontFace, mode) DECLARE_GL_FUNCTION_STUB_HEAD(void, GenBuffers, GLsizei n, GLuint* buffers) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GenBuffers, n, buffers) DECLARE_GL_FUNCTION_HEAD(void, GenerateMipmap, GLenum target) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenerateMipmap, target) DECLARE_GL_FUNCTION_HEAD(void, GenFramebuffers, GLsizei n, GLuint* framebuffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenFramebuffers, n, framebuffers) @@ -114,31 +115,31 @@ DECLARE_GL_FUNCTION_STUB_HEAD(GLint, GetUniformLocation, GLuint program, const G DECLARE_GL_FUNCTION_STUB_HEAD(void, GetVertexAttribfv, GLuint index, GLenum pname, GLfloat* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetVertexAttribfv, index, pname, params) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetVertexAttribiv, GLuint index, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetVertexAttribiv, index, pname, params) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetVertexAttribPointerv, GLuint index, GLenum pname, void** pointer) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetVertexAttribPointerv, index, pname, pointer) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Hint, GLenum target, GLenum mode) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Hint, target, mode) +DECLARE_GL_FUNCTION_HEAD(void, Hint, GLenum target, GLenum mode) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Hint, target, mode) DECLARE_GL_FUNCTION_HEAD(GLboolean, IsBuffer, GLuint buffer) DECLARE_GL_FUNCTION_END(GLboolean, IsBuffer, buffer) -DECLARE_GL_FUNCTION_STUB_HEAD(GLboolean, IsEnabled, GLenum cap) DECLARE_GL_FUNCTION_STUB_END(GLboolean, IsEnabled, cap) +DECLARE_GL_FUNCTION_HEAD(GLboolean, IsEnabled, GLenum cap) DECLARE_GL_FUNCTION_END(GLboolean, IsEnabled, cap) DECLARE_GL_FUNCTION_HEAD(GLboolean, IsFramebuffer, GLuint framebuffer) DECLARE_GL_FUNCTION_END(GLboolean, IsFramebuffer, framebuffer) DECLARE_GL_FUNCTION_STUB_HEAD(GLboolean, IsProgram, GLuint program) DECLARE_GL_FUNCTION_STUB_END(GLboolean, IsProgram, program) DECLARE_GL_FUNCTION_HEAD(GLboolean, IsRenderbuffer, GLuint renderbuffer) DECLARE_GL_FUNCTION_END(GLboolean, IsRenderbuffer, renderbuffer) DECLARE_GL_FUNCTION_STUB_HEAD(GLboolean, IsShader, GLuint shader) DECLARE_GL_FUNCTION_STUB_END(GLboolean, IsShader, shader) DECLARE_GL_FUNCTION_HEAD(GLboolean, IsTexture, GLuint texture) DECLARE_GL_FUNCTION_END(GLboolean, IsTexture, texture) -DECLARE_GL_FUNCTION_STUB_HEAD(void, LineWidth, GLfloat width) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, LineWidth, width) +DECLARE_GL_FUNCTION_HEAD(void, LineWidth, GLfloat width) DECLARE_GL_FUNCTION_END_NO_RETURN(void, LineWidth, width) DECLARE_GL_FUNCTION_STUB_HEAD(void, LinkProgram, GLuint program) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, LinkProgram, program) -DECLARE_GL_FUNCTION_STUB_HEAD(void, PixelStorei, GLenum pname, GLint param) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PixelStorei, pname, param) -DECLARE_GL_FUNCTION_STUB_HEAD(void, PolygonOffset, GLfloat factor, GLfloat units) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PolygonOffset, factor, units) +DECLARE_GL_FUNCTION_HEAD(void, PixelStorei, GLenum pname, GLint param) DECLARE_GL_FUNCTION_END_NO_RETURN(void, PixelStorei, pname, param) +DECLARE_GL_FUNCTION_HEAD(void, PolygonOffset, GLfloat factor, GLfloat units) DECLARE_GL_FUNCTION_END_NO_RETURN(void, PolygonOffset, factor, units) DECLARE_GL_FUNCTION_STUB_HEAD(void, ReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ReadPixels, x, y, width, height, format, type, pixels) DECLARE_GL_FUNCTION_STUB_HEAD(void, ReleaseShaderCompiler) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ReleaseShaderCompiler) DECLARE_GL_FUNCTION_HEAD(void, RenderbufferStorage, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) DECLARE_GL_FUNCTION_END_NO_RETURN(void, RenderbufferStorage, target, internalformat, width, height) -DECLARE_GL_FUNCTION_STUB_HEAD(void, SampleCoverage, GLfloat value, GLboolean invert) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, SampleCoverage, value, invert) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Scissor, GLint x, GLint y, GLsizei width, GLsizei height) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Scissor, x, y, width, height) +DECLARE_GL_FUNCTION_HEAD(void, SampleCoverage, GLfloat value, GLboolean invert) DECLARE_GL_FUNCTION_END_NO_RETURN(void, SampleCoverage, value, invert) +DECLARE_GL_FUNCTION_HEAD(void, Scissor, GLint x, GLint y, GLsizei width, GLsizei height) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Scissor, x, y, width, height) DECLARE_GL_FUNCTION_STUB_HEAD(void, ShaderBinary, GLsizei count, const GLuint* shaders, GLenum binaryformat, const void* binary, GLsizei length) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ShaderBinary, count, shaders, binaryformat, binary, length) DECLARE_GL_FUNCTION_STUB_HEAD(void, ShaderSource, GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ShaderSource, shader, count, string, length) -DECLARE_GL_FUNCTION_STUB_HEAD(void, StencilFunc, GLenum func, GLint ref, GLuint mask) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, StencilFunc, func, ref, mask) -DECLARE_GL_FUNCTION_STUB_HEAD(void, StencilFuncSeparate, GLenum face, GLenum func, GLint ref, GLuint mask) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, StencilFuncSeparate, face, func, ref, mask) -DECLARE_GL_FUNCTION_STUB_HEAD(void, StencilMask, GLuint mask) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, StencilMask, mask) -DECLARE_GL_FUNCTION_STUB_HEAD(void, StencilMaskSeparate, GLenum face, GLuint mask) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, StencilMaskSeparate, face, mask) -DECLARE_GL_FUNCTION_STUB_HEAD(void, StencilOp, GLenum fail, GLenum zfail, GLenum zpass) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, StencilOp, fail, zfail, zpass) -DECLARE_GL_FUNCTION_STUB_HEAD(void, StencilOpSeparate, GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, StencilOpSeparate, face, sfail, dpfail, dppass) +DECLARE_GL_FUNCTION_HEAD(void, StencilFunc, GLenum func, GLint ref, GLuint mask) DECLARE_GL_FUNCTION_END_NO_RETURN(void, StencilFunc, func, ref, mask) +DECLARE_GL_FUNCTION_HEAD(void, StencilFuncSeparate, GLenum face, GLenum func, GLint ref, GLuint mask) DECLARE_GL_FUNCTION_END_NO_RETURN(void, StencilFuncSeparate, face, func, ref, mask) +DECLARE_GL_FUNCTION_HEAD(void, StencilMask, GLuint mask) DECLARE_GL_FUNCTION_END_NO_RETURN(void, StencilMask, mask) +DECLARE_GL_FUNCTION_HEAD(void, StencilMaskSeparate, GLenum face, GLuint mask) DECLARE_GL_FUNCTION_END_NO_RETURN(void, StencilMaskSeparate, face, mask) +DECLARE_GL_FUNCTION_HEAD(void, StencilOp, GLenum fail, GLenum zfail, GLenum zpass) DECLARE_GL_FUNCTION_END_NO_RETURN(void, StencilOp, fail, zfail, zpass) +DECLARE_GL_FUNCTION_HEAD(void, StencilOpSeparate, GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) DECLARE_GL_FUNCTION_END_NO_RETURN(void, StencilOpSeparate, face, sfail, dpfail, dppass) DECLARE_GL_FUNCTION_HEAD(void, TexImage2D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels) DECLARE_GL_FUNCTION_END_NO_RETURN(void, TexImage2D, target, level, internalformat, width, height, border, format, type, pixels) DECLARE_GL_FUNCTION_HEAD(void, TexParameterf, GLenum target, GLenum pname, GLfloat param) DECLARE_GL_FUNCTION_END_NO_RETURN(void, TexParameterf, target, pname, param) DECLARE_GL_FUNCTION_STUB_HEAD(void, TexParameterfv, GLenum target, GLenum pname, const GLfloat* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, TexParameterfv, target, pname, params) @@ -175,8 +176,8 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib3fv, GLuint index, const GLfloat DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib4f, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttrib4f, index, x, y, z, w) DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib4fv, GLuint index, const GLfloat* v) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttrib4fv, index, v) DECLARE_GL_FUNCTION_HEAD(void, VertexAttribPointer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, VertexAttribPointer, index, size, type, normalized, stride, pointer) -DECLARE_GL_FUNCTION_STUB_HEAD(void, Viewport, GLint x, GLint y, GLsizei width, GLsizei height) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Viewport, x, y, width, height) -DECLARE_GL_FUNCTION_STUB_HEAD(void, ReadBuffer, GLenum src) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ReadBuffer, src) +DECLARE_GL_FUNCTION_HEAD(void, Viewport, GLint x, GLint y, GLsizei width, GLsizei height) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Viewport, x, y, width, height) +DECLARE_GL_FUNCTION_HEAD(void, ReadBuffer, GLenum src) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ReadBuffer, src) DECLARE_GL_FUNCTION_STUB_HEAD(void, DrawRangeElements, GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DrawRangeElements, mode, start, end, count, type, indices) DECLARE_GL_FUNCTION_HEAD(void, TexImage3D, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels) DECLARE_GL_FUNCTION_END_NO_RETURN(void, TexImage3D, target, level, internalformat, width, height, depth, border, format, type, pixels) DECLARE_GL_FUNCTION_HEAD(void, TexSubImage3D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels) DECLARE_GL_FUNCTION_END_NO_RETURN(void, TexSubImage3D, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels) @@ -367,7 +368,7 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, BlendEquationSeparatei, GLuint buf, GLenum m DECLARE_GL_FUNCTION_STUB_HEAD(void, BlendFunci, GLuint buf, GLenum src, GLenum dst) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BlendFunci, buf, src, dst) DECLARE_GL_FUNCTION_STUB_HEAD(void, BlendFuncSeparatei, GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BlendFuncSeparatei, buf, srcRGB, dstRGB, srcAlpha, dstAlpha) DECLARE_GL_FUNCTION_STUB_HEAD(void, ColorMaski, GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ColorMaski, index, r, g, b, a) -DECLARE_GL_FUNCTION_STUB_HEAD(GLboolean, IsEnabledi, GLenum target, GLuint index) DECLARE_GL_FUNCTION_STUB_END(GLboolean, IsEnabledi, target, index) +DECLARE_GL_FUNCTION_HEAD(GLboolean, IsEnabledi, GLenum target, GLuint index) DECLARE_GL_FUNCTION_END(GLboolean, IsEnabledi, target, index) DECLARE_GL_FUNCTION_STUB_HEAD(void, DrawElementsBaseVertex, GLenum mode, GLsizei count, GLenum type, const void* indices, GLint basevertex) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DrawElementsBaseVertex, mode, count, type, indices, basevertex) DECLARE_GL_FUNCTION_STUB_HEAD(void, DrawRangeElementsBaseVertex, GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices, GLint basevertex) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DrawRangeElementsBaseVertex, mode, start, end, count, type, indices, basevertex) DECLARE_GL_FUNCTION_STUB_HEAD(void, DrawElementsInstancedBaseVertex, GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei instancecount, GLint basevertex) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DrawElementsInstancedBaseVertex, mode, count, type, indices, instancecount, basevertex) @@ -395,10 +396,10 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void*, MapBufferRange, GLenum target, GLintptr off DECLARE_GL_FUNCTION_STUB_HEAD(void, ClearIndex, GLfloat c) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ClearIndex, c) DECLARE_GL_FUNCTION_STUB_HEAD(void, IndexMask, GLuint mask) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, IndexMask, mask) DECLARE_GL_FUNCTION_STUB_HEAD(void, AlphaFunc, GLenum func, GLclampf ref) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, AlphaFunc, func, ref) -DECLARE_GL_FUNCTION_STUB_HEAD(void, LogicOp, GLenum opcode) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, LogicOp, opcode) -DECLARE_GL_FUNCTION_STUB_HEAD(void, PointSize, GLfloat size) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PointSize, size) +DECLARE_GL_FUNCTION_HEAD(void, LogicOp, GLenum opcode) DECLARE_GL_FUNCTION_END_NO_RETURN(void, LogicOp, opcode) +DECLARE_GL_FUNCTION_HEAD(void, PointSize, GLfloat size) DECLARE_GL_FUNCTION_END_NO_RETURN(void, PointSize, size) DECLARE_GL_FUNCTION_STUB_HEAD(void, LineStipple, GLint factor, GLushort pattern) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, LineStipple, factor, pattern) -DECLARE_GL_FUNCTION_STUB_HEAD(void, PolygonMode, GLenum face, GLenum mode) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PolygonMode, face, mode) +DECLARE_GL_FUNCTION_HEAD(void, PolygonMode, GLenum face, GLenum mode) DECLARE_GL_FUNCTION_END_NO_RETURN(void, PolygonMode, face, mode) DECLARE_GL_FUNCTION_STUB_HEAD(void, PolygonStipple, const GLubyte* mask) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PolygonStipple, mask) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetPolygonStipple, GLubyte* mask) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetPolygonStipple, mask) DECLARE_GL_FUNCTION_STUB_HEAD(void, EdgeFlag, GLboolean flag) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, EdgeFlag, flag) @@ -414,7 +415,7 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, PopAttrib) DECLARE_GL_FUNCTION_STUB_END_NO_R DECLARE_GL_FUNCTION_STUB_HEAD(void, PushClientAttrib, GLbitfield mask) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PushClientAttrib, mask) DECLARE_GL_FUNCTION_STUB_HEAD(void, PopClientAttrib) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PopClientAttrib) DECLARE_GL_FUNCTION_STUB_HEAD(GLint, RenderMode, GLenum mode) DECLARE_GL_FUNCTION_STUB_END(GLint, RenderMode, mode) -DECLARE_GL_FUNCTION_STUB_HEAD(void, DepthRange, GLclampd near_val, GLclampd far_val) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DepthRange, near_val, far_val) +DECLARE_GL_FUNCTION_HEAD(void, DepthRange, GLclampd near_val, GLclampd far_val) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DepthRange, near_val, far_val) DECLARE_GL_FUNCTION_STUB_HEAD(void, ClearAccum, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ClearAccum, red, green, blue, alpha) DECLARE_GL_FUNCTION_STUB_HEAD(void, Accum, GLenum op, GLfloat value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Accum, op, value) DECLARE_GL_FUNCTION_STUB_HEAD(void, MatrixMode, GLenum mode) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, MatrixMode, mode) @@ -678,7 +679,7 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, InitNames) DECLARE_GL_FUNCTION_STUB_END_NO_R DECLARE_GL_FUNCTION_STUB_HEAD(void, LoadName, GLuint name) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, LoadName, name) DECLARE_GL_FUNCTION_STUB_HEAD(void, PushName, GLuint name) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PushName, name) DECLARE_GL_FUNCTION_STUB_HEAD(void, PopName) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PopName) -DECLARE_GL_FUNCTION_STUB_HEAD(void, ClampColor, GLenum target, GLenum clamp) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ClampColor, target, clamp) +DECLARE_GL_FUNCTION_HEAD(void, ClampColor, GLenum target, GLenum clamp) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ClampColor, target, clamp) DECLARE_GL_FUNCTION_STUB_HEAD(void, BeginConditionalRender, GLuint id, GLenum mode) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, BeginConditionalRender, id, mode) DECLARE_GL_FUNCTION_STUB_HEAD(void, EndConditionalRender, void) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, EndConditionalRender) DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttribI1i, GLuint index, GLint x) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttribI1i, index, x) @@ -742,9 +743,9 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, MultTransposeMatrixf, const GLfloat* m) DECL DECLARE_GL_FUNCTION_STUB_HEAD(void, MultTransposeMatrixd, const GLdouble* m) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, MultTransposeMatrixd, m) DECLARE_GL_FUNCTION_STUB_HEAD(void, MultiDrawArrays, GLenum mode, const GLint* first, const GLsizei* count, GLsizei drawcount) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, MultiDrawArrays, mode, first, count, drawcount) DECLARE_GL_FUNCTION_STUB_HEAD(void, MultiDrawElements, GLenum mode, const GLsizei* count, GLenum type, const void* const* indices, GLsizei drawcount) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, MultiDrawElements, mode, count, type, indices, drawcount) -DECLARE_GL_FUNCTION_STUB_HEAD(void, PointParameterf, GLenum pname, GLfloat param) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PointParameterf, pname, param) +DECLARE_GL_FUNCTION_HEAD(void, PointParameterf, GLenum pname, GLfloat param) DECLARE_GL_FUNCTION_END_NO_RETURN(void, PointParameterf, pname, param) DECLARE_GL_FUNCTION_STUB_HEAD(void, PointParameterfv, GLenum pname, const GLfloat* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PointParameterfv, pname, params) -DECLARE_GL_FUNCTION_STUB_HEAD(void, PointParameteri, GLenum pname, GLint param) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PointParameteri, pname, param) +DECLARE_GL_FUNCTION_HEAD(void, PointParameteri, GLenum pname, GLint param) DECLARE_GL_FUNCTION_END_NO_RETURN(void, PointParameteri, pname, param) DECLARE_GL_FUNCTION_STUB_HEAD(void, PointParameteriv, GLenum pname, const GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, PointParameteriv, pname, params) DECLARE_GL_FUNCTION_STUB_HEAD(void, FogCoordf, GLfloat coord) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, FogCoordf, coord) DECLARE_GL_FUNCTION_STUB_HEAD(void, FogCoordfv, const GLfloat* coord) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, FogCoordfv, coord) diff --git a/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp b/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp new file mode 100644 index 00000000..2bdca0ec --- /dev/null +++ b/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp @@ -0,0 +1,393 @@ +#include "GL_RenderState.h" +#include "MG_State/GLState/RenderState/RenderState.h" +#include "MG_Util/Converters/GLToStr/GLEnumConverter.h" +#include +#include +#include +#include + +namespace MobileGL { + namespace MG_Impl::GLImpl { + void Viewport_State(GLint x, GLint y, GLsizei width, GLsizei height) { + if (width < 0 || height < 0) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidValue, MakeShared("MG_Impl/GLImpl", "Viewport_State", + "Width abd height must be non-negative.")); + return; + } + + MG_State::pGLContext->SetViewport(IntVec4(x, y, width, height)); + } + + void StencilOpSeparate_State(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) { + // TODO: implement + } + + void StencilOp_State(GLenum fail, GLenum zfail, GLenum zpass) { + // TODO: implement + } + + void StencilMaskSeparate_State(GLenum face, GLuint mask) { + // TODO: implement + } + + void StencilMask_State(GLuint mask) { + // TODO: implement + } + + void StencilFuncSeparate_State(GLenum face, GLenum func, GLint ref, GLuint mask) { + // TODO: implement + } + + void StencilFunc_State(GLenum func, GLint ref, GLuint mask) { + // TODO: implement + } + + void Scissor_State(GLint x, GLint y, GLsizei width, GLsizei height) { + // TODO: implement + } + + void SampleCoverage_State(GLfloat value, GLboolean invert) { + // TODO: implement + } + + void PolygonOffset_State(GLfloat factor, GLfloat units) { + // TODO: implement + } + + void PolygonMode_State(GLenum face, GLenum mode) { + // TODO: implement + } + + void PointSize_State(GLfloat size) { + // TODO: implement + } + + void PointParameterf_State(GLenum pname, GLfloat param) { + // TODO: implement + } + + void PointParameteri_State(GLenum pname, GLint param) { + // TODO: implement + } + + void PixelStorei_State(GLenum pname, GLint param) { + PixelStoreParam pixelStoreParam = MG_Util::ConvertGLEnumToPixelStoreParam(pname); + if (pixelStoreParam == PixelStoreParam::Unknown) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, + MakeShared("MG_Impl/GLImpl", "PixelStorei_State", + "Pixel store param enum " + + MG_Util::ConvertPixelStoreParamToString(pixelStoreParam) + "(" + + MG_Util::ConvertGLEnumToString(pname) + ") is not supported.")); + return; + } + + MG_State::pGLContext->SetPixelStoreParam(pixelStoreParam, param); + } + + void LogicOp_State(GLenum opcode) { + // TODO: implement + } + + void LineWidth_State(GLfloat width) { + // TODO: implement + } + + GLboolean IsEnabledi_State(GLenum target, GLuint index) { + // TODO: implement + return GL_FALSE; + } + + GLboolean IsEnabled_State(GLenum cap) { + // TODO: implement + return GL_FALSE; + } + + void Hint_State(GLenum target, GLenum mode) { + // TODO: implement + } + + void FrontFace_State(GLenum mode) { + // TODO: implement + } + + void Enable_State(GLenum cap) { + CapabilityInput capInput = MG_Util::ConvertGLEnumToCapabilityInput(cap); + if (capInput == CapabilityInput::Unknown) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, MakeShared( + "MG_Impl/GLImpl", "Enable_State", + "Capability enum " + MG_Util::ConvertCapabilityInputToString(capInput) + + "(" + MG_Util::ConvertGLEnumToString(cap) + ") is not supported.")); + return; + } + + MG_State::pGLContext->SetCapability(capInput, true); + } + + void Disable_State(GLenum cap) { + CapabilityInput capInput = MG_Util::ConvertGLEnumToCapabilityInput(cap); + if (capInput == CapabilityInput::Unknown) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, MakeShared( + "MG_Impl/GLImpl", "Disable_State", + "Capability enum " + MG_Util::ConvertCapabilityInputToString(capInput) + + "(" + MG_Util::ConvertGLEnumToString(cap) + ") is not supported.")); + return; + } + + MG_State::pGLContext->SetCapability(capInput, false); + } + + void DepthRange_State(GLclampd near_val, GLclampd far_val) { + // TODO: implement + } + + void DepthMask_State(GLboolean flag) { + MG_State::pGLContext->SetDepthMask(flag == GL_TRUE); + } + + void DepthFunc_State(GLenum func) { + DepthTestFunc depthFunc = MG_Util::ConvertGLEnumToDepthTestFunc(func); + if (depthFunc == DepthTestFunc::Unknown) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, + MakeShared("MG_Impl/GLImpl", "DepthFunc_State", + "Depth function enum " + + MG_Util::ConvertDepthTestFuncToString(depthFunc) + "(" + + MG_Util::ConvertGLEnumToString(func) + ") is not supported.")); + return; + } + + MG_State::pGLContext->SetDepthFunc(depthFunc); + } + + void CullFace_State(GLenum mode) { + CullFaceMode cullFaceMode = MG_Util::ConvertGLEnumToCullFaceMode(mode); + if (cullFaceMode == CullFaceMode::Unknown) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, + MakeShared("MG_Impl/GLImpl", "CullFace_State", + "Cull face mode enum " + + MG_Util::ConvertCullFaceModeToString(cullFaceMode) + "(" + + MG_Util::ConvertGLEnumToString(mode) + ") is not supported.")); + return; + } + + MG_State::pGLContext->SetCullFaceMode(cullFaceMode); + } + + void ColorMask_State(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { + MG_State::pGLContext->SetColorMask( + BoolVec4(red == GL_TRUE, green == GL_TRUE, blue == GL_TRUE, alpha == GL_TRUE)); + } + + void ClampColor_State(GLenum target, GLenum clamp) { + // TODO: implement + } + + void BlendFuncSeparate_State(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) { + BlendFactor srcRGB = MG_Util::ConvertGLEnumToBlendFactor(sfactorRGB); + BlendFactor dstRGB = MG_Util::ConvertGLEnumToBlendFactor(dfactorRGB); + BlendFactor srcAlpha = MG_Util::ConvertGLEnumToBlendFactor(sfactorAlpha); + BlendFactor dstAlpha = MG_Util::ConvertGLEnumToBlendFactor(dfactorAlpha); + + if (srcRGB == BlendFactor::Unknown || dstRGB == BlendFactor::Unknown || srcAlpha == BlendFactor::Unknown || + dstAlpha == BlendFactor::Unknown) { + MG_State::pGLContext->RecordError( + ErrorCode::InvalidEnum, + MakeShared("MG_Impl/GLImpl", "BlendFuncSeparate_State", + "One of the blend factor enums is not supported: srcRGB " + + MG_Util::ConvertBlendFactorToString(srcRGB) + "(" + + MG_Util::ConvertGLEnumToString(sfactorRGB) + "), dstRGB " + + MG_Util::ConvertBlendFactorToString(dstRGB) + "(" + + MG_Util::ConvertGLEnumToString(dfactorRGB) + "), srcAlpha " + + MG_Util::ConvertBlendFactorToString(srcAlpha) + "(" + + MG_Util::ConvertGLEnumToString(sfactorAlpha) + "), dstAlpha " + + MG_Util::ConvertBlendFactorToString(dstAlpha) + "(" + + MG_Util::ConvertGLEnumToString(dfactorAlpha) + ").")); + return; + } + + MG_State::pGLContext->SetBlendFunc(srcRGB, dstRGB, srcAlpha, dstAlpha); + } + + void BlendFunc_State(GLenum sfactor, GLenum dfactor) { + BlendFuncSeparate_State(sfactor, dfactor, sfactor, dfactor); + } + + void BlendEquation_State(GLenum mode) { + // TODO: implement + } + + void BlendColor_State(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { + // TODO: implement + } + + void ReadBuffer_State(GLenum src) { + // TODO: implement + } + + void ClearStencil_State(GLint s) { + // TODO: implement + } + + void ClearDepth_State(GLclampd depth) { + MG_State::pGLContext->SetClearDepth(static_cast(depth)); + } + + void ClearColor_State(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { + MG_State::pGLContext->SetClearColor(FloatVec4(red, green, blue, alpha)); + } + + /* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */ + void BlendFunc(GLenum sfactor, GLenum dfactor) { + BlendFunc_State(sfactor, dfactor); + } + + void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) { + Viewport_State(x, y, width, height); + } + + void StencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) { + StencilOpSeparate_State(face, sfail, dpfail, dppass); + } + + void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) { + StencilOp_State(fail, zfail, zpass); + } + + void StencilMaskSeparate(GLenum face, GLuint mask) { + StencilMaskSeparate_State(face, mask); + } + + void StencilMask(GLuint mask) { + StencilMask_State(mask); + } + + void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) { + StencilFuncSeparate_State(face, func, ref, mask); + } + + void StencilFunc(GLenum func, GLint ref, GLuint mask) { + StencilFunc_State(func, ref, mask); + } + + void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) { + Scissor_State(x, y, width, height); + } + + void SampleCoverage(GLfloat value, GLboolean invert) { + SampleCoverage_State(value, invert); + } + + void PolygonOffset(GLfloat factor, GLfloat units) { + PolygonOffset_State(factor, units); + } + + void PolygonMode(GLenum face, GLenum mode) { + PolygonMode_State(face, mode); + } + + void PointSize(GLfloat size) { + PointSize_State(size); + } + + void PointParameterf(GLenum pname, GLfloat param) { + PointParameterf_State(pname, param); + } + + void PointParameteri(GLenum pname, GLint param) { + PointParameteri_State(pname, param); + } + + void PixelStorei(GLenum pname, GLint param) { + PixelStorei_State(pname, param); + } + + void LogicOp(GLenum opcode) { + LogicOp_State(opcode); + } + + void LineWidth(GLfloat width) { + LineWidth_State(width); + } + + GLboolean IsEnabledi(GLenum target, GLuint index) { + return IsEnabledi_State(target, index); + } + + GLboolean IsEnabled(GLenum cap) { + return IsEnabled_State(cap); + } + + void Hint(GLenum target, GLenum mode) { + Hint_State(target, mode); + } + + void FrontFace(GLenum mode) { + FrontFace_State(mode); + } + + void Enable(GLenum cap) { + Enable_State(cap); + } + + void Disable(GLenum cap) { + Disable_State(cap); + } + + void DepthRange(GLclampd near_val, GLclampd far_val) { + DepthRange_State(near_val, far_val); + } + + void DepthMask(GLboolean flag) { + DepthMask_State(flag); + } + + void DepthFunc(GLenum func) { + DepthFunc_State(func); + } + + void CullFace(GLenum mode) { + CullFace_State(mode); + } + + void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { + ColorMask_State(red, green, blue, alpha); + } + + void ClampColor(GLenum target, GLenum clamp) { + ClampColor_State(target, clamp); + } + + void BlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) { + BlendFuncSeparate_State(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); + } + + void BlendEquation(GLenum mode) { + BlendEquation_State(mode); + } + + void BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { + BlendColor_State(red, green, blue, alpha); + } + + void ReadBuffer(GLenum src) { + ReadBuffer_State(src); + } + + void ClearStencil(GLint s) { + ClearStencil_State(s); + } + + void ClearDepth(GLclampd depth) { + ClearDepth_State(depth); + } + + void ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { + ClearColor_State(red, green, blue, alpha); + } + } // namespace MG_Impl::GLImpl +} // namespace MobileGL diff --git a/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.h b/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.h new file mode 100644 index 00000000..c6b597d5 --- /dev/null +++ b/MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.h @@ -0,0 +1,45 @@ +#pragma once +#include + +namespace MobileGL { + namespace MG_Impl::GLImpl { + /* @INSERTION_POINT:FUNCTION_DECLARATION@ */ + void BlendFunc(GLenum sfactor, GLenum dfactor); + void Viewport(GLint x, GLint y, GLsizei width, GLsizei height); + void StencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); + void StencilOp(GLenum fail, GLenum zfail, GLenum zpass); + void StencilMaskSeparate(GLenum face, GLuint mask); + void StencilMask(GLuint mask); + void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); + void StencilFunc(GLenum func, GLint ref, GLuint mask); + void Scissor(GLint x, GLint y, GLsizei width, GLsizei height); + void SampleCoverage(GLfloat value, GLboolean invert); + void PolygonOffset(GLfloat factor, GLfloat units); + void PolygonMode(GLenum face, GLenum mode); + void PointSize(GLfloat size); + void PointParameterf(GLenum pname, GLfloat param); + void PointParameteri(GLenum pname, GLint param); + void PixelStorei(GLenum pname, GLint param); + void LogicOp(GLenum opcode); + void LineWidth(GLfloat width); + GLboolean IsEnabledi(GLenum target, GLuint index); + GLboolean IsEnabled(GLenum cap); + void Hint(GLenum target, GLenum mode); + void FrontFace(GLenum mode); + void Enable(GLenum cap); + void Disable(GLenum cap); + void DepthRange(GLclampd near_val, GLclampd far_val); + void DepthMask(GLboolean flag); + void DepthFunc(GLenum func); + void CullFace(GLenum mode); + void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); + void ClampColor(GLenum target, GLenum clamp); + void BlendFuncSeparate(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); + void BlendEquation(GLenum mode); + void BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + void ReadBuffer(GLenum src); + void ClearStencil(GLint s); + void ClearDepth(GLclampd depth); + void ClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); + } // namespace MG_Impl::GLImpl +} // namespace MobileGL diff --git a/MobileGL/MG_State/GLState/Core.cpp b/MobileGL/MG_State/GLState/Core.cpp index 460ae78f..8480cc12 100644 --- a/MobileGL/MG_State/GLState/Core.cpp +++ b/MobileGL/MG_State/GLState/Core.cpp @@ -225,11 +225,11 @@ namespace MobileGL { m_renderState.GetBlendFunc(srcRGB, dstRGB, srcAlpha, dstAlpha); } - void GLContext::SetDepthFunc(DepthFunc func) { + void GLContext::SetDepthFunc(DepthTestFunc func) { m_renderState.SetDepthFunc(func); } - DepthFunc GLContext::GetDepthFunc() const { + DepthTestFunc GLContext::GetDepthFunc() const { return m_renderState.GetDepthFunc(); } diff --git a/MobileGL/MG_State/GLState/Core.h b/MobileGL/MG_State/GLState/Core.h index 9405dbcf..efc0fb49 100644 --- a/MobileGL/MG_State/GLState/Core.h +++ b/MobileGL/MG_State/GLState/Core.h @@ -76,8 +76,8 @@ namespace MobileGL { void SetBlendFunc(BlendFactor srcRGB, BlendFactor dstRGB, BlendFactor srcAlpha, BlendFactor dstAlpha); void GetBlendFunc(BlendFactor& srcRGB, BlendFactor& dstRGB, BlendFactor& srcAlpha, BlendFactor& dstAlpha) const; - void SetDepthFunc(DepthFunc func); - DepthFunc GetDepthFunc() const; + void SetDepthFunc(DepthTestFunc func); + DepthTestFunc GetDepthFunc() const; void SetDepthMask(Bool flag); Bool GetDepthMask() const; void SetColorMask(BoolVec4 mask); diff --git a/MobileGL/MG_State/GLState/RenderState/RenderState.cpp b/MobileGL/MG_State/GLState/RenderState/RenderState.cpp index 7c51da2d..03e4acf4 100644 --- a/MobileGL/MG_State/GLState/RenderState/RenderState.cpp +++ b/MobileGL/MG_State/GLState/RenderState/RenderState.cpp @@ -75,11 +75,11 @@ namespace MobileGL { } // -------------------- Depth -------------------- - void RenderState::SetDepthFunc(DepthFunc func) { + void RenderState::SetDepthFunc(DepthTestFunc func) { m_depthFunc = func; } - DepthFunc RenderState::GetDepthFunc() const { + DepthTestFunc RenderState::GetDepthFunc() const { return m_depthFunc; } diff --git a/MobileGL/MG_State/GLState/RenderState/RenderState.h b/MobileGL/MG_State/GLState/RenderState/RenderState.h index 08416e05..dd62c60a 100644 --- a/MobileGL/MG_State/GLState/RenderState/RenderState.h +++ b/MobileGL/MG_State/GLState/RenderState/RenderState.h @@ -22,7 +22,7 @@ namespace MobileGL { Unknown = -1 }; - enum class DepthFunc { + enum class DepthTestFunc { Never, Less, Equal, @@ -31,7 +31,7 @@ namespace MobileGL { NotEqual, GreaterEqual, Always, - DepthFuncCount, + DepthTestFuncCount, Unknown = -1 }; @@ -128,8 +128,8 @@ namespace MobileGL { BlendFactor& dstAlpha) const; // Depth - void SetDepthFunc(DepthFunc func); - DepthFunc GetDepthFunc() const; + void SetDepthFunc(DepthTestFunc func); + DepthTestFunc GetDepthFunc() const; void SetDepthMask(Bool flag); Bool GetDepthMask() const; @@ -164,7 +164,7 @@ namespace MobileGL { // Depth Bool m_depthTestEnabled = false; - DepthFunc m_depthFunc = DepthFunc::Less; + DepthTestFunc m_depthFunc = DepthTestFunc::Less; Bool m_depthMask = true; // Color Mask diff --git a/MobileGL/MG_Util/Converters/GLToMG/RenderStateEnumConverter.cpp b/MobileGL/MG_Util/Converters/GLToMG/RenderStateEnumConverter.cpp index aaf1525a..fe6a5481 100644 --- a/MobileGL/MG_Util/Converters/GLToMG/RenderStateEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/GLToMG/RenderStateEnumConverter.cpp @@ -37,26 +37,26 @@ namespace MobileGL { } } - DepthFunc ConvertGLEnumToDepthFunc(GLenum v) { + DepthTestFunc ConvertGLEnumToDepthTestFunc(GLenum v) { switch (v) { case GL_NEVER: - return DepthFunc::Never; + return DepthTestFunc::Never; case GL_LESS: - return DepthFunc::Less; + return DepthTestFunc::Less; case GL_EQUAL: - return DepthFunc::Equal; + return DepthTestFunc::Equal; case GL_LEQUAL: - return DepthFunc::LessEqual; + return DepthTestFunc::LessEqual; case GL_GREATER: - return DepthFunc::Greater; + return DepthTestFunc::Greater; case GL_NOTEQUAL: - return DepthFunc::NotEqual; + return DepthTestFunc::NotEqual; case GL_GEQUAL: - return DepthFunc::GreaterEqual; + return DepthTestFunc::GreaterEqual; case GL_ALWAYS: - return DepthFunc::Always; + return DepthTestFunc::Always; default: - return DepthFunc::Unknown; + return DepthTestFunc::Unknown; } } diff --git a/MobileGL/MG_Util/Converters/GLToMG/RenderStateEnumConverter.h b/MobileGL/MG_Util/Converters/GLToMG/RenderStateEnumConverter.h index 3b17d128..c4332671 100644 --- a/MobileGL/MG_Util/Converters/GLToMG/RenderStateEnumConverter.h +++ b/MobileGL/MG_Util/Converters/GLToMG/RenderStateEnumConverter.h @@ -5,7 +5,7 @@ namespace MobileGL { namespace MG_Util { BlendFactor ConvertGLEnumToBlendFactor(GLenum value); - DepthFunc ConvertGLEnumToDepthFunc(GLenum value); + DepthTestFunc ConvertGLEnumToDepthTestFunc(GLenum value); PixelStoreParam ConvertGLEnumToPixelStoreParam(GLenum value); CullFaceMode ConvertGLEnumToCullFaceMode(GLenum value); CapabilityInput ConvertGLEnumToCapabilityInput(GLenum value); diff --git a/MobileGL/MG_Util/Converters/MGToGL/RenderStateEnumConverter.cpp b/MobileGL/MG_Util/Converters/MGToGL/RenderStateEnumConverter.cpp index 9674c326..8ef47450 100644 --- a/MobileGL/MG_Util/Converters/MGToGL/RenderStateEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToGL/RenderStateEnumConverter.cpp @@ -38,23 +38,23 @@ namespace MobileGL { } } - GLenum ConvertDepthFuncToGLEnum(DepthFunc v) { + GLenum ConvertDepthTestFuncToGLEnum(DepthTestFunc v) { switch (v) { - case DepthFunc::Never: + case DepthTestFunc::Never: return GL_NEVER; - case DepthFunc::Less: + case DepthTestFunc::Less: return GL_LESS; - case DepthFunc::Equal: + case DepthTestFunc::Equal: return GL_EQUAL; - case DepthFunc::LessEqual: + case DepthTestFunc::LessEqual: return GL_LEQUAL; - case DepthFunc::Greater: + case DepthTestFunc::Greater: return GL_GREATER; - case DepthFunc::NotEqual: + case DepthTestFunc::NotEqual: return GL_NOTEQUAL; - case DepthFunc::GreaterEqual: + case DepthTestFunc::GreaterEqual: return GL_GEQUAL; - case DepthFunc::Always: + case DepthTestFunc::Always: return GL_ALWAYS; default: return GL_UNKNOWN_MGL; diff --git a/MobileGL/MG_Util/Converters/MGToGL/RenderStateEnumConverter.h b/MobileGL/MG_Util/Converters/MGToGL/RenderStateEnumConverter.h index 10a3d788..1f4769d7 100644 --- a/MobileGL/MG_Util/Converters/MGToGL/RenderStateEnumConverter.h +++ b/MobileGL/MG_Util/Converters/MGToGL/RenderStateEnumConverter.h @@ -5,7 +5,7 @@ namespace MobileGL { namespace MG_Util { GLenum ConvertBlendFactorToGLEnum(BlendFactor value); - GLenum ConvertDepthFuncToGLEnum(DepthFunc value); + GLenum ConvertDepthTestFuncToGLEnum(DepthTestFunc value); GLenum ConvertPixelStoreParamToGLEnum(PixelStoreParam value); GLenum ConvertCullFaceModeToGLEnum(CullFaceMode value); GLenum ConvertCapabilityInputToGLEnum(CapabilityInput value); diff --git a/MobileGL/MG_Util/Converters/MGToStr/RenderStateEnumConverter.cpp b/MobileGL/MG_Util/Converters/MGToStr/RenderStateEnumConverter.cpp index 7f6e6266..066cab1d 100644 --- a/MobileGL/MG_Util/Converters/MGToStr/RenderStateEnumConverter.cpp +++ b/MobileGL/MG_Util/Converters/MGToStr/RenderStateEnumConverter.cpp @@ -37,23 +37,23 @@ namespace MobileGL { } } - String ConvertDepthFuncToString(DepthFunc v) { + String ConvertDepthTestFuncToString(DepthTestFunc v) { switch (v) { - case DepthFunc::Never: + case DepthTestFunc::Never: return "Never"; - case DepthFunc::Less: + case DepthTestFunc::Less: return "Less"; - case DepthFunc::Equal: + case DepthTestFunc::Equal: return "Equal"; - case DepthFunc::LessEqual: + case DepthTestFunc::LessEqual: return "LessEqual"; - case DepthFunc::Greater: + case DepthTestFunc::Greater: return "Greater"; - case DepthFunc::NotEqual: + case DepthTestFunc::NotEqual: return "NotEqual"; - case DepthFunc::GreaterEqual: + case DepthTestFunc::GreaterEqual: return "GreaterEqual"; - case DepthFunc::Always: + case DepthTestFunc::Always: return "Always"; default: return "Unknown"; diff --git a/MobileGL/MG_Util/Converters/MGToStr/RenderStateEnumConverter.h b/MobileGL/MG_Util/Converters/MGToStr/RenderStateEnumConverter.h index 1b110a6c..c1ba8730 100644 --- a/MobileGL/MG_Util/Converters/MGToStr/RenderStateEnumConverter.h +++ b/MobileGL/MG_Util/Converters/MGToStr/RenderStateEnumConverter.h @@ -5,7 +5,7 @@ namespace MobileGL { namespace MG_Util { String ConvertBlendFactorToString(BlendFactor value); - String ConvertDepthFuncToString(DepthFunc value); + String ConvertDepthTestFuncToString(DepthTestFunc value); String ConvertPixelStoreParamToString(PixelStoreParam value); String ConvertCullFaceModeToString(CullFaceMode value); String ConvertCapabilityInputToString(CapabilityInput value);