[Feat|Fix] (...): Add/Fix lots of stuff, being able not to crash in MC.

This commit is contained in:
BZLZHH
2025-10-06 16:08:35 +08:00
parent e37dedb72d
commit bd1056f9c9
36 changed files with 1164 additions and 201 deletions
+7 -3
View File
@@ -62,6 +62,7 @@ set(SOURCE_FILES
MobileGL/MG_Impl/EGLImpl/Exporting/Definitions.cpp MobileGL/MG_Impl/EGLImpl/Exporting/Definitions.cpp
MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp MobileGL/MG_Impl/EGLImpl/Temporary/TemporaryEGLImpl.cpp
MobileGL/MG_Impl/EGLImpl/EGLWrapper/EGLWrapper.cpp
# @INSERTION_POINT:SOURCE_FILE_GLIMPL@ # # @INSERTION_POINT:SOURCE_FILE_GLIMPL@ #
MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp MobileGL/MG_Impl/GLImpl/RenderState/GL_RenderState.cpp
@@ -70,6 +71,7 @@ set(SOURCE_FILES
MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp MobileGL/MG_Impl/GLImpl/Program/GL_Program.cpp
MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp MobileGL/MG_Impl/GLImpl/Texture/GL_Texture.cpp
MobileGL/MG_Impl/GLImpl/Texture/Validators.cpp MobileGL/MG_Impl/GLImpl/Texture/Validators.cpp
MobileGL/MG_Impl/GLImpl/Texture/ProxyTexture.cpp
MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp MobileGL/MG_Impl/GLImpl/VertexArray/GL_VertexArray.cpp
MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp MobileGL/MG_Impl/GLImpl/VertexArray/Validators.cpp
MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp MobileGL/MG_Impl/GLImpl/Buffer/GL_Buffer.cpp
@@ -77,6 +79,8 @@ set(SOURCE_FILES
MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp MobileGL/MG_Impl/GLImpl/Exporting/Definitions.cpp
MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp MobileGL/MG_Impl/GLImpl/Getter/GL_Getter.cpp
MobileGL/MG_Impl/Init.cpp
MobileGL/MG_Backend/Init.cpp MobileGL/MG_Backend/Init.cpp
MobileGL/MG_State/GLState/Core.cpp MobileGL/MG_State/GLState/Core.cpp
@@ -101,9 +105,9 @@ add_library(${CMAKE_PROJECT_NAME} SHARED
) )
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES
C_VISIBILITY_PRESET hidden C_VISIBILITY_PRESET default
CXX_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET default
VISIBILITY_INLINES_HIDDEN ON VISIBILITY_INLINES_HIDDEN OFF
) )
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
+5 -2
View File
@@ -1,4 +1,5 @@
#include "Includes.h" #include "Includes.h"
#include <MG_Impl/Init.h>
#include <MG_Backend/Backends.h> #include <MG_Backend/Backends.h>
#include <MG_State/GLState/Core.h> #include <MG_State/GLState/Core.h>
@@ -10,13 +11,15 @@ namespace MobileGL {
MGLOG_D("MobileGL State initialized"); MGLOG_D("MobileGL State initialized");
MG_Backend::Init(); MG_Backend::Init();
MGLOG_D("MobileGL Backend initialized"); MGLOG_D("MobileGL Backend initialized");
MG_Impl::Init();
MGLOG_D("MobileGL Implementation initialized");
glslang::InitializeProcess(); glslang::InitializeProcess();
MGLOG_D("glslang initialized"); MGLOG_D("glslang initialized");
MGLOG_I("MobileGL Initialized"); MGLOG_I("MobileGL initialized");
} }
void MG_Destroy() { void MG_Destroy() {
MGLOG_I("MobileGL Closing..."); MGLOG_I("MobileGL closing...");
glslang::FinalizeProcess(); glslang::FinalizeProcess();
MG_Util::Debug::Close(); MG_Util::Debug::Close();
} }
@@ -1,103 +1,88 @@
#include "EGLWrapper.h" #include "EGLWrapper.h"
#include <Config.h>
#include <MG_Util/BackendLoaders/OpenGL/Loader.h>
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
namespace MobileGL { namespace MobileGL {
namespace MG_Impl::EGLImpl { namespace MG_Impl::EGLImpl {
// TODO: implement complete EGL functionality // TODO: implement complete EGL functionality
EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window, EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, NativeWindowType window,
const EGLint* attrib_list) { const EGLint* attrib_list) {
return (EGLSurface)1; return MG_External::EGL::eglCreateWindowSurface(dpy, config, window, attrib_list);
} }
EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size, EGLBoolean ChooseConfig(EGLDisplay dpy, const EGLint* attrib_list, EGLConfig* configs, EGLint config_size,
EGLint* num_config) { EGLint* num_config) {
*num_config = 1; return MG_External::EGL::eglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
return EGL_TRUE;
} }
EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list) { EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext shareCtx, const EGLint* attrib_list) {
return (EGLContext)1; return MG_External::EGL::eglCreateContext(dpy, config, shareCtx, attrib_list);
} }
EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor) { EGLBoolean Initialize(EGLDisplay dpy, EGLint* major, EGLint* minor) {
if (major) *major = 1; return MG_External::EGL::eglInitialize(dpy, major, minor);
if (minor) *minor = 5;
return EGL_TRUE;
} }
EGLDisplay GetDisplay(NativeDisplayType display) { EGLDisplay GetDisplay(NativeDisplayType display) {
return (EGLDisplay)1; return MG_External::EGL::eglGetDisplay(display);
} }
EGLint GetError() { EGLint GetError() {
return EGL_SUCCESS; return MG_External::EGL::eglGetError();
} }
EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { EGLBoolean MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) {
return EGL_TRUE; return MG_External::EGL::eglMakeCurrent(dpy, draw, read, ctx);
} }
EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx) { EGLBoolean DestroyContext(EGLDisplay dpy, EGLContext ctx) {
return EGL_TRUE; return MG_External::EGL::eglDestroyContext(dpy, ctx);
} }
EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface) { EGLBoolean DestroySurface(EGLDisplay dpy, EGLSurface surface) {
return EGL_TRUE; return MG_External::EGL::eglDestroySurface(dpy, surface);
} }
EGLBoolean Terminate(EGLDisplay dpy) { EGLBoolean Terminate(EGLDisplay dpy) {
return EGL_TRUE; return MG_External::EGL::eglTerminate(dpy);
} }
EGLBoolean ReleaseThread(void) { EGLBoolean ReleaseThread(void) {
return EGL_TRUE; return MG_External::EGL::eglReleaseThread();
} }
EGLContext GetCurrentContext(void) { EGLContext GetCurrentContext(void) {
return (EGLContext)1; return MG_External::EGL::eglGetCurrentContext();
} }
EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) { EGLBoolean GetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint* value) {
if (attribute == EGL_NATIVE_VISUAL_ID) { return MG_External::EGL::eglGetConfigAttrib(dpy, config, attribute, value);
#if defined(ANDROID)
*value = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
return EGL_TRUE;
#elif defined(__linux__)
*value = 0;
return EGL_TRUE;
#elif defined(_WIN32)
*value = 0;
return EGL_TRUE;
#else
*value = 0;
return EGL_FALSE;
#endif
}
return EGL_TRUE;
} }
EGLBoolean BindAPI(EGLenum api) { EGLBoolean BindAPI(EGLenum api) {
return EGL_TRUE; return MG_External::EGL::eglBindAPI(api);
} }
EGLSurface GetCurrentSurface(EGLint readdraw) { EGLSurface GetCurrentSurface(EGLint readdraw) {
return (EGLSurface)1; return MG_External::EGL::eglGetCurrentSurface(readdraw);
} }
EGLBoolean QuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value) { EGLBoolean QuerySurface(EGLDisplay display, EGLSurface surface, EGLint attribute, EGLint* value) {
return EGL_TRUE; return MG_External::EGL::eglQuerySurface(display, surface, attribute, value);
} }
EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval) { EGLBoolean SwapInterval(EGLDisplay dpy, EGLint interval) {
return EGL_TRUE; return MG_External::EGL::eglSwapInterval(dpy, interval);
} }
EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw) { EGLBoolean SwapBuffers(EGLDisplay dpy, EGLSurface draw) {
return EGL_TRUE; return MG_External::EGL::eglSwapBuffers(dpy, draw);
} }
EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) { EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, const EGLint* attrib_list) {
return (EGLSurface)1; return MG_External::EGL::eglCreatePbufferSurface(dpy, config, attrib_list);
} }
__eglMustCastToProperFunctionPointerType GetProcAddress(const char* name) { __eglMustCastToProperFunctionPointerType GetProcAddress(const char* name) {
@@ -115,3 +100,5 @@ namespace MobileGL {
} }
} // namespace MG_Impl::EGLImpl } // namespace MG_Impl::EGLImpl
} // namespace MobileGL } // namespace MobileGL
#endif
@@ -1,5 +1,7 @@
#include "TemporaryEGLImpl.h" #include "TemporaryEGLImpl.h"
#include <Config.h>
#if !(MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES)
namespace MobileGL { namespace MobileGL {
namespace MG_Impl::EGLImpl { namespace MG_Impl::EGLImpl {
// TODO: implement complete EGL functionality // TODO: implement complete EGL functionality
@@ -115,3 +117,4 @@ namespace MobileGL {
} }
} // namespace MG_Impl::EGLImpl } // namespace MG_Impl::EGLImpl
} // namespace MobileGL } // namespace MobileGL
#endif
+62 -4
View File
@@ -3,9 +3,62 @@
#include <MG_State/GLState/Core.h> #include <MG_State/GLState/Core.h>
#include <MG_State/GLState/ErrorState/Error.h> #include <MG_State/GLState/ErrorState/Error.h>
#include <MG_Util/Converters/GLToMG/BufferEnumConverter.h> #include <MG_Util/Converters/GLToMG/BufferEnumConverter.h>
#include <MG_Util/Converters/MGToGL/BufferEnumConverter.h>
namespace MobileGL { namespace MobileGL {
namespace MG_Impl::GLImpl { namespace MG_Impl::GLImpl {
void GetBufferParameteriv_State(GLenum target, GLenum pname, GLint* params) {
if (!params) {
MG_State::pGLContext->RecordError(ErrorCode::InvalidValue,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl",
"GetBufferParameteriv_State",
"Params pointer cannot be null."));
return;
}
BufferTarget bufferTarget = MG_Util::ConvertGLEnumToBufferTarget(target);
if (!BufferImpl::ValidateBufferTarget(bufferTarget)) return;
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
auto bufferObject = bindingSlot.GetBoundObject();
if (!bufferObject) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidOperation,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetBufferParameteriv_State",
"Buffer target is bound to no buffer object."));
return;
}
switch (pname) {
case GL_BUFFER_SIZE:
*params = static_cast<GLint>(bufferObject->GetSize());
break;
case GL_BUFFER_USAGE:
*params = MG_Util::ConvertBufferUsageToGLEnum(bufferObject->GetUsage());
break;
case GL_BUFFER_ACCESS:
if (bufferObject->IsMapped()) {
auto access = bufferObject->GetMappingAccess();
if (access & BufferMappingAccessBit::Read && access & BufferMappingAccessBit::Write) {
*params = GL_READ_WRITE;
} else if (access & BufferMappingAccessBit::Read) {
*params = GL_READ_ONLY;
} else if (access & BufferMappingAccessBit::Write) {
*params = GL_WRITE_ONLY;
} else {
*params = 0;
}
} else {
*params = 0;
}
break;
case GL_BUFFER_MAPPED:
*params = bufferObject->IsMapped() ? GL_TRUE : GL_FALSE;
break;
}
}
void DeleteBuffers_State(GLsizei n, const GLuint* buffers) { void DeleteBuffers_State(GLsizei n, const GLuint* buffers) {
if (n < 0) { if (n < 0) {
MG_State::pGLContext->RecordError( MG_State::pGLContext->RecordError(
@@ -182,7 +235,8 @@ namespace MobileGL {
const auto storageFlags = BufferMappingAccessBit::Persistent | BufferMappingAccessBit::Coherent; const auto storageFlags = BufferMappingAccessBit::Persistent | BufferMappingAccessBit::Coherent;
auto requiredFlags = accessBits & storageFlags; auto requiredFlags = accessBits & storageFlags;
if (requiredFlags) { if (requiredFlags) {
// TODO: check if the buffer data is created by BufferStorage and its flags after its implementation // TODO: check if the buffer data is created by BufferStorage and its flags after its
// implementation
MG_State::pGLContext->RecordError( MG_State::pGLContext->RecordError(
ErrorCode::InvalidOperation, ErrorCode::InvalidOperation,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State", MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "MapBufferRange_State",
@@ -368,9 +422,9 @@ namespace MobileGL {
if (offset + size >= mappedRange.start) { if (offset + size >= mappedRange.start) {
MG_State::pGLContext->RecordError( MG_State::pGLContext->RecordError(
ErrorCode::InvalidOperation, ErrorCode::InvalidOperation,
MakeShared<GenericErrorInfo>( MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "BufferSubData_State",
"MG_Impl/GLImpl", "BufferSubData_State", "Cannot modify a mapped buffer object unless it was "
"Cannot modify a mapped buffer object unless it was mapped with GL_MAP_PERSISTENT_BIT.")); "mapped with GL_MAP_PERSISTENT_BIT."));
return; return;
} }
} }
@@ -441,6 +495,10 @@ namespace MobileGL {
} }
/* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */ /* @INSERTION_POINT:FUNCTION_IMPLEMENTATION@ */
void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) {
GetBufferParameteriv_State(target, pname, params);
}
GLboolean IsBuffer(GLuint buffer) { GLboolean IsBuffer(GLuint buffer) {
return IsBuffer_State(buffer); return IsBuffer_State(buffer);
} }
@@ -4,6 +4,7 @@
namespace MobileGL { namespace MobileGL {
namespace MG_Impl::GLImpl { namespace MG_Impl::GLImpl {
/* @INSERTION_POINT:FUNCTION_DECLARATION@ */ /* @INSERTION_POINT:FUNCTION_DECLARATION@ */
void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params);
GLboolean IsBuffer(GLuint buffer); GLboolean IsBuffer(GLuint buffer);
void DeleteBuffers(GLsizei n, const GLuint* buffers); void DeleteBuffers(GLsizei n, const GLuint* buffers);
void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length); void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length);
@@ -37,8 +37,8 @@ DECLARE_GL_FUNCTION_HEAD(const GLubyte*, GetString, GLenum name) DECLARE_GL_FUNC
DECLARE_GL_FUNCTION_HEAD(void*, MapBuffer, GLenum target, GLenum access) DECLARE_GL_FUNCTION_END(void*, MapBuffer, target, access) DECLARE_GL_FUNCTION_HEAD(void*, MapBuffer, GLenum target, GLenum access) DECLARE_GL_FUNCTION_END(void*, MapBuffer, target, access)
DECLARE_GL_FUNCTION_HEAD(void, ClearDepth, GLclampd depth) DECLARE_GL_FUNCTION_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_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_HEAD(void, AttachShader, GLuint program, GLuint shader) DECLARE_GL_FUNCTION_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) DECLARE_GL_FUNCTION_HEAD(void, BindAttribLocation, GLuint program, GLuint index, const GLchar* name) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindAttribLocation, program, index, name)
DECLARE_GL_FUNCTION_HEAD(void, BindBuffer, GLenum target, GLuint buffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindBuffer, target, buffer) DECLARE_GL_FUNCTION_HEAD(void, BindBuffer, GLenum target, GLuint buffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindBuffer, target, buffer)
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, 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, BindRenderbuffer, GLenum target, GLuint renderbuffer) DECLARE_GL_FUNCTION_END_NO_RETURN(void, BindRenderbuffer, target, renderbuffer)
@@ -56,24 +56,24 @@ DECLARE_GL_FUNCTION_HEAD(void, ClearColor, GLfloat red, GLfloat green, GLfloat b
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, ClearDepthf, GLfloat d) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ClearDepthf, d)
DECLARE_GL_FUNCTION_HEAD(void, ClearStencil, GLint s) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ClearStencil, s) 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_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, CompileShader, GLuint shader) DECLARE_GL_FUNCTION_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, 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) 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)
DECLARE_GL_FUNCTION_HEAD(void, CopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CopyTexImage2D, target, level, internalformat, x, y, width, height, border) DECLARE_GL_FUNCTION_HEAD(void, CopyTexImage2D, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) DECLARE_GL_FUNCTION_END_NO_RETURN(void, CopyTexImage2D, target, level, internalformat, x, y, width, height, border)
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_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_HEAD(GLuint, CreateProgram) DECLARE_GL_FUNCTION_END(GLuint, CreateProgram)
DECLARE_GL_FUNCTION_STUB_HEAD(GLuint, CreateShader, GLenum type) DECLARE_GL_FUNCTION_STUB_END(GLuint, CreateShader, type) DECLARE_GL_FUNCTION_HEAD(GLuint, CreateShader, GLenum type) DECLARE_GL_FUNCTION_END(GLuint, CreateShader, type)
DECLARE_GL_FUNCTION_HEAD(void, CullFace, GLenum mode) DECLARE_GL_FUNCTION_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, 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_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, DeleteProgram, GLuint program) DECLARE_GL_FUNCTION_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_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, DeleteShader, GLuint shader) DECLARE_GL_FUNCTION_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_HEAD(void, DeleteTextures, GLsizei n, const GLuint* textures) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DeleteTextures, n, textures)
DECLARE_GL_FUNCTION_HEAD(void, DepthFunc, GLenum func) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DepthFunc, func) 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_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, 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_HEAD(void, DetachShader, GLuint program, GLuint shader) DECLARE_GL_FUNCTION_END_NO_RETURN(void, DetachShader, program, shader)
DECLARE_GL_FUNCTION_HEAD(void, Disable, GLenum cap) DECLARE_GL_FUNCTION_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_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, DrawArrays, GLenum mode, GLint first, GLsizei count) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, DrawArrays, mode, first, count)
@@ -85,33 +85,33 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, Flush) DECLARE_GL_FUNCTION_STUB_END_NO_RETUR
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, 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_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_HEAD(void, FrontFace, GLenum mode) DECLARE_GL_FUNCTION_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, GenBuffers, GLsizei n, GLuint* buffers) DECLARE_GL_FUNCTION_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, 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) DECLARE_GL_FUNCTION_HEAD(void, GenFramebuffers, GLsizei n, GLuint* framebuffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenFramebuffers, n, framebuffers)
DECLARE_GL_FUNCTION_HEAD(void, GenRenderbuffers, GLsizei n, GLuint* renderbuffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenRenderbuffers, n, renderbuffers) DECLARE_GL_FUNCTION_HEAD(void, GenRenderbuffers, GLsizei n, GLuint* renderbuffers) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenRenderbuffers, n, renderbuffers)
DECLARE_GL_FUNCTION_HEAD(void, GenTextures, GLsizei n, GLuint* textures) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenTextures, n, textures) DECLARE_GL_FUNCTION_HEAD(void, GenTextures, GLsizei n, GLuint* textures) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GenTextures, n, textures)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetActiveAttrib, GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetActiveAttrib, program, index, bufSize, length, size, type, name) DECLARE_GL_FUNCTION_HEAD(void, GetActiveAttrib, GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetActiveAttrib, program, index, bufSize, length, size, type, name)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetActiveUniform, GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetActiveUniform, program, index, bufSize, length, size, type, name) DECLARE_GL_FUNCTION_HEAD(void, GetActiveUniform, GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLint* size, GLenum* type, GLchar* name) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetActiveUniform, program, index, bufSize, length, size, type, name)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetAttachedShaders, GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetAttachedShaders, program, maxCount, count, shaders) DECLARE_GL_FUNCTION_HEAD(void, GetAttachedShaders, GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetAttachedShaders, program, maxCount, count, shaders)
DECLARE_GL_FUNCTION_STUB_HEAD(GLint, GetAttribLocation, GLuint program, const GLchar* name) DECLARE_GL_FUNCTION_STUB_END(GLint, GetAttribLocation, program, name) DECLARE_GL_FUNCTION_HEAD(GLint, GetAttribLocation, GLuint program, const GLchar* name) DECLARE_GL_FUNCTION_END(GLint, GetAttribLocation, program, name)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetBooleanv, GLenum pname, GLboolean* data) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetBooleanv, pname, data) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetBooleanv, GLenum pname, GLboolean* data) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetBooleanv, pname, data)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetBufferParameteriv, GLenum target, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetBufferParameteriv, target, pname, params) DECLARE_GL_FUNCTION_HEAD(void, GetBufferParameteriv, GLenum target, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetBufferParameteriv, target, pname, params)
DECLARE_GL_FUNCTION_HEAD(GLenum, GetError) DECLARE_GL_FUNCTION_END(GLenum, GetError) DECLARE_GL_FUNCTION_HEAD(GLenum, GetError) DECLARE_GL_FUNCTION_END(GLenum, GetError)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetFloatv, GLenum pname, GLfloat* data) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetFloatv, pname, data) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetFloatv, GLenum pname, GLfloat* data) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetFloatv, pname, data)
DECLARE_GL_FUNCTION_HEAD(void, GetFramebufferAttachmentParameteriv, GLenum target, GLenum attachment, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetFramebufferAttachmentParameteriv, target, attachment, pname, params) DECLARE_GL_FUNCTION_HEAD(void, GetFramebufferAttachmentParameteriv, GLenum target, GLenum attachment, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetFramebufferAttachmentParameteriv, target, attachment, pname, params)
DECLARE_GL_FUNCTION_HEAD(void, GetIntegerv, GLenum pname, GLint* data) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetIntegerv, pname, data) DECLARE_GL_FUNCTION_HEAD(void, GetIntegerv, GLenum pname, GLint* data) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetIntegerv, pname, data)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetProgramiv, GLuint program, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetProgramiv, program, pname, params) DECLARE_GL_FUNCTION_HEAD(void, GetProgramiv, GLuint program, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetProgramiv, program, pname, params)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetProgramInfoLog, GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetProgramInfoLog, program, bufSize, length, infoLog) DECLARE_GL_FUNCTION_HEAD(void, GetProgramInfoLog, GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetProgramInfoLog, program, bufSize, length, infoLog)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetRenderbufferParameteriv, GLenum target, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetRenderbufferParameteriv, target, pname, params) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetRenderbufferParameteriv, GLenum target, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetRenderbufferParameteriv, target, pname, params)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetShaderiv, GLuint shader, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetShaderiv, shader, pname, params) DECLARE_GL_FUNCTION_HEAD(void, GetShaderiv, GLuint shader, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetShaderiv, shader, pname, params)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetShaderInfoLog, GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetShaderInfoLog, shader, bufSize, length, infoLog) DECLARE_GL_FUNCTION_HEAD(void, GetShaderInfoLog, GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetShaderInfoLog, shader, bufSize, length, infoLog)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetShaderPrecisionFormat, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetShaderPrecisionFormat, shadertype, precisiontype, range, precision) DECLARE_GL_FUNCTION_STUB_HEAD(void, GetShaderPrecisionFormat, GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetShaderPrecisionFormat, shadertype, precisiontype, range, precision)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetShaderSource, GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetShaderSource, shader, bufSize, length, source) DECLARE_GL_FUNCTION_HEAD(void, GetShaderSource, GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* source) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetShaderSource, shader, bufSize, length, source)
DECLARE_GL_FUNCTION_HEAD(void, GetTexParameterfv, GLenum target, GLenum pname, GLfloat* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetTexParameterfv, target, pname, params) DECLARE_GL_FUNCTION_HEAD(void, GetTexParameterfv, GLenum target, GLenum pname, GLfloat* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetTexParameterfv, target, pname, params)
DECLARE_GL_FUNCTION_HEAD(void, GetTexParameteriv, GLenum target, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetTexParameteriv, target, pname, params) DECLARE_GL_FUNCTION_HEAD(void, GetTexParameteriv, GLenum target, GLenum pname, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetTexParameteriv, target, pname, params)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetUniformfv, GLuint program, GLint location, GLfloat* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetUniformfv, program, location, params) DECLARE_GL_FUNCTION_HEAD(void, GetUniformfv, GLuint program, GLint location, GLfloat* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetUniformfv, program, location, params)
DECLARE_GL_FUNCTION_STUB_HEAD(void, GetUniformiv, GLuint program, GLint location, GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetUniformiv, program, location, params) DECLARE_GL_FUNCTION_HEAD(void, GetUniformiv, GLuint program, GLint location, GLint* params) DECLARE_GL_FUNCTION_END_NO_RETURN(void, GetUniformiv, program, location, params)
DECLARE_GL_FUNCTION_STUB_HEAD(GLint, GetUniformLocation, GLuint program, const GLchar* name) DECLARE_GL_FUNCTION_STUB_END(GLint, GetUniformLocation, program, name) DECLARE_GL_FUNCTION_HEAD(GLint, GetUniformLocation, GLuint program, const GLchar* name) DECLARE_GL_FUNCTION_END(GLint, GetUniformLocation, program, name)
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, 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, 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, GetVertexAttribPointerv, GLuint index, GLenum pname, void** pointer) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, GetVertexAttribPointerv, index, pname, pointer)
@@ -119,12 +119,12 @@ DECLARE_GL_FUNCTION_HEAD(void, Hint, GLenum target, GLenum mode) DECLARE_GL_FUNC
DECLARE_GL_FUNCTION_HEAD(GLboolean, IsBuffer, GLuint buffer) DECLARE_GL_FUNCTION_END(GLboolean, IsBuffer, buffer) DECLARE_GL_FUNCTION_HEAD(GLboolean, IsBuffer, GLuint buffer) DECLARE_GL_FUNCTION_END(GLboolean, IsBuffer, buffer)
DECLARE_GL_FUNCTION_HEAD(GLboolean, IsEnabled, GLenum cap) DECLARE_GL_FUNCTION_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_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, IsProgram, GLuint program) DECLARE_GL_FUNCTION_END(GLboolean, IsProgram, program)
DECLARE_GL_FUNCTION_HEAD(GLboolean, IsRenderbuffer, GLuint renderbuffer) DECLARE_GL_FUNCTION_END(GLboolean, IsRenderbuffer, renderbuffer) 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, IsShader, GLuint shader) DECLARE_GL_FUNCTION_END(GLboolean, IsShader, shader)
DECLARE_GL_FUNCTION_HEAD(GLboolean, IsTexture, GLuint texture) DECLARE_GL_FUNCTION_END(GLboolean, IsTexture, texture) DECLARE_GL_FUNCTION_HEAD(GLboolean, IsTexture, GLuint texture) DECLARE_GL_FUNCTION_END(GLboolean, IsTexture, texture)
DECLARE_GL_FUNCTION_HEAD(void, LineWidth, GLfloat width) DECLARE_GL_FUNCTION_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_HEAD(void, LinkProgram, GLuint program) DECLARE_GL_FUNCTION_END_NO_RETURN(void, LinkProgram, program)
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, 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_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, 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)
@@ -133,7 +133,7 @@ DECLARE_GL_FUNCTION_HEAD(void, RenderbufferStorage, GLenum target, GLenum intern
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, 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_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, 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_HEAD(void, ShaderSource, GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ShaderSource, shader, count, string, length)
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, 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, 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, StencilMask, GLuint mask) DECLARE_GL_FUNCTION_END_NO_RETURN(void, StencilMask, mask)
@@ -146,27 +146,27 @@ DECLARE_GL_FUNCTION_STUB_HEAD(void, TexParameterfv, GLenum target, GLenum pname,
DECLARE_GL_FUNCTION_HEAD(void, TexParameteri, GLenum target, GLenum pname, GLint param) DECLARE_GL_FUNCTION_END_NO_RETURN(void, TexParameteri, target, pname, param) DECLARE_GL_FUNCTION_HEAD(void, TexParameteri, GLenum target, GLenum pname, GLint param) DECLARE_GL_FUNCTION_END_NO_RETURN(void, TexParameteri, target, pname, param)
DECLARE_GL_FUNCTION_STUB_HEAD(void, TexParameteriv, GLenum target, GLenum pname, const GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, TexParameteriv, target, pname, params) DECLARE_GL_FUNCTION_STUB_HEAD(void, TexParameteriv, GLenum target, GLenum pname, const GLint* params) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, TexParameteriv, target, pname, params)
DECLARE_GL_FUNCTION_HEAD(void, TexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) DECLARE_GL_FUNCTION_END_NO_RETURN(void, TexSubImage2D, target, level, xoffset, yoffset, width, height, format, type, pixels) DECLARE_GL_FUNCTION_HEAD(void, TexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) DECLARE_GL_FUNCTION_END_NO_RETURN(void, TexSubImage2D, target, level, xoffset, yoffset, width, height, format, type, pixels)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform1f, GLint location, GLfloat v0) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform1f, location, v0) DECLARE_GL_FUNCTION_HEAD(void, Uniform1f, GLint location, GLfloat v0) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform1f, location, v0)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform1fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform1fv, location, count, value) DECLARE_GL_FUNCTION_HEAD(void, Uniform1fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform1fv, location, count, value)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform1i, GLint location, GLint v0) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform1i, location, v0) DECLARE_GL_FUNCTION_HEAD(void, Uniform1i, GLint location, GLint v0) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform1i, location, v0)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform1iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform1iv, location, count, value) DECLARE_GL_FUNCTION_HEAD(void, Uniform1iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform1iv, location, count, value)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform2f, GLint location, GLfloat v0, GLfloat v1) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform2f, location, v0, v1) DECLARE_GL_FUNCTION_HEAD(void, Uniform2f, GLint location, GLfloat v0, GLfloat v1) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform2f, location, v0, v1)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform2fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform2fv, location, count, value) DECLARE_GL_FUNCTION_HEAD(void, Uniform2fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform2fv, location, count, value)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform2i, GLint location, GLint v0, GLint v1) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform2i, location, v0, v1) DECLARE_GL_FUNCTION_HEAD(void, Uniform2i, GLint location, GLint v0, GLint v1) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform2i, location, v0, v1)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform2iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform2iv, location, count, value) DECLARE_GL_FUNCTION_HEAD(void, Uniform2iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform2iv, location, count, value)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform3f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform3f, location, v0, v1, v2) DECLARE_GL_FUNCTION_HEAD(void, Uniform3f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform3f, location, v0, v1, v2)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform3fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform3fv, location, count, value) DECLARE_GL_FUNCTION_HEAD(void, Uniform3fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform3fv, location, count, value)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform3i, GLint location, GLint v0, GLint v1, GLint v2) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform3i, location, v0, v1, v2) DECLARE_GL_FUNCTION_HEAD(void, Uniform3i, GLint location, GLint v0, GLint v1, GLint v2) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform3i, location, v0, v1, v2)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform3iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform3iv, location, count, value) DECLARE_GL_FUNCTION_HEAD(void, Uniform3iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform3iv, location, count, value)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform4f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform4f, location, v0, v1, v2, v3) DECLARE_GL_FUNCTION_HEAD(void, Uniform4f, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform4f, location, v0, v1, v2, v3)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform4fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform4fv, location, count, value) DECLARE_GL_FUNCTION_HEAD(void, Uniform4fv, GLint location, GLsizei count, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform4fv, location, count, value)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform4i, GLint location, GLint v0, GLint v1, GLint v2, GLint v3) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform4i, location, v0, v1, v2, v3) DECLARE_GL_FUNCTION_HEAD(void, Uniform4i, GLint location, GLint v0, GLint v1, GLint v2, GLint v3) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform4i, location, v0, v1, v2, v3)
DECLARE_GL_FUNCTION_STUB_HEAD(void, Uniform4iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, Uniform4iv, location, count, value) DECLARE_GL_FUNCTION_HEAD(void, Uniform4iv, GLint location, GLsizei count, const GLint* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, Uniform4iv, location, count, value)
DECLARE_GL_FUNCTION_STUB_HEAD(void, UniformMatrix2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, UniformMatrix2fv, location, count, transpose, value) DECLARE_GL_FUNCTION_HEAD(void, UniformMatrix2fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, UniformMatrix2fv, location, count, transpose, value)
DECLARE_GL_FUNCTION_STUB_HEAD(void, UniformMatrix3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, UniformMatrix3fv, location, count, transpose, value) DECLARE_GL_FUNCTION_HEAD(void, UniformMatrix3fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, UniformMatrix3fv, location, count, transpose, value)
DECLARE_GL_FUNCTION_STUB_HEAD(void, UniformMatrix4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, UniformMatrix4fv, location, count, transpose, value) DECLARE_GL_FUNCTION_HEAD(void, UniformMatrix4fv, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) DECLARE_GL_FUNCTION_END_NO_RETURN(void, UniformMatrix4fv, location, count, transpose, value)
DECLARE_GL_FUNCTION_STUB_HEAD(void, UseProgram, GLuint program) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, UseProgram, program) DECLARE_GL_FUNCTION_HEAD(void, UseProgram, GLuint program) DECLARE_GL_FUNCTION_END_NO_RETURN(void, UseProgram, program)
DECLARE_GL_FUNCTION_STUB_HEAD(void, ValidateProgram, GLuint program) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, ValidateProgram, program) DECLARE_GL_FUNCTION_HEAD(void, ValidateProgram, GLuint program) DECLARE_GL_FUNCTION_END_NO_RETURN(void, ValidateProgram, program)
DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib1f, GLuint index, GLfloat x) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttrib1f, index, x) DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib1f, GLuint index, GLfloat x) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttrib1f, index, x)
DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib1fv, GLuint index, const GLfloat* v) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttrib1fv, index, v) DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib1fv, GLuint index, const GLfloat* v) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttrib1fv, index, v)
DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib2f, GLuint index, GLfloat x, GLfloat y) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttrib2f, index, x, y) DECLARE_GL_FUNCTION_STUB_HEAD(void, VertexAttrib2f, GLuint index, GLfloat x, GLfloat y) DECLARE_GL_FUNCTION_STUB_END_NO_RETURN(void, VertexAttrib2f, index, x, y)
@@ -1,7 +1,6 @@
#include "GL_Framebuffer.h" #include "GL_Framebuffer.h"
#include "GL/glext.h"
#include "Validators.h" #include "Validators.h"
#include <MG_State/GLState/Core.h> #include <MG_Impl/GLImpl/Texture/Validators.h>
#include <MG_State/GLState/ErrorState/Error.h> #include <MG_State/GLState/ErrorState/Error.h>
#include <MG_Util/Converters/GLToMG/FramebufferEnumConverter.h> #include <MG_Util/Converters/GLToMG/FramebufferEnumConverter.h>
@@ -70,17 +69,20 @@ namespace MobileGL {
void FramebufferTexture2D_State(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, void FramebufferTexture2D_State(GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
GLint level) { GLint level) {
if (target == GL_FRAMEBUFFER) { if (target == GL_FRAMEBUFFER) {
FramebufferTexture2D_State(GL_DRAW_FRAMEBUFFER, attachment, textarget, texture, level); target = GL_DRAW_FRAMEBUFFER;
FramebufferTexture2D_State(GL_READ_FRAMEBUFFER, attachment, textarget, texture, level); }
return;
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
FramebufferTexture2D_State(target, GL_DEPTH_ATTACHMENT, textarget, texture, level);
FramebufferTexture2D_State(target, GL_STENCIL_ATTACHMENT, textarget, texture, level);
} }
FramebufferAttachmentType attachmentType = MG_Util::ConvertGLEnumToFramebufferAttachmentType(attachment); FramebufferAttachmentType attachmentType = MG_Util::ConvertGLEnumToFramebufferAttachmentType(attachment);
if (!FramebufferImpl::ValidateFramebufferAttachmentType(attachmentType)) return;
if (!FramebufferImpl::ValidateFramebufferName(texture, true)) return;
FramebufferTarget framebufferTarget = MG_Util::ConvertGLEnumToFramebufferTarget(target); FramebufferTarget framebufferTarget = MG_Util::ConvertGLEnumToFramebufferTarget(target);
if (!FramebufferImpl::ValidateFramebufferAttachmentType(attachmentType)) return;
if (!FramebufferImpl::ValidateFramebufferTarget(framebufferTarget)) return; if (!FramebufferImpl::ValidateFramebufferTarget(framebufferTarget)) return;
if (!TextureImpl::ValidateTextureName(texture)) return;
auto& bindingSlot = MG_State::pGLContext->GetFramebufferBindingSlot(framebufferTarget); auto& bindingSlot = MG_State::pGLContext->GetFramebufferBindingSlot(framebufferTarget);
auto framebufferObject = bindingSlot.GetBoundObject(); auto framebufferObject = bindingSlot.GetBoundObject();
@@ -287,5 +289,9 @@ namespace MobileGL {
void BindFramebuffer(GLenum target, GLuint framebuffer) { void BindFramebuffer(GLenum target, GLuint framebuffer) {
BindFramebuffer_State(target, framebuffer); BindFramebuffer_State(target, framebuffer);
} }
namespace FramebufferImpl {
DefaultFramebufferInfo* pDefaultFramebufferInfo;
}
} // namespace MG_Impl::GLImpl } // namespace MG_Impl::GLImpl
} // namespace MobileGL } // namespace MobileGL
@@ -1,5 +1,7 @@
#pragma once #pragma once
#include "MG_State/GLState/FramebufferState/FramebufferObject.h"
#include <Includes.h> #include <Includes.h>
#include <MG_State/GLState/Core.h>
namespace MobileGL { namespace MobileGL {
namespace MG_Impl::GLImpl { namespace MG_Impl::GLImpl {
@@ -29,5 +31,16 @@ namespace MobileGL {
GLint dstY1, GLbitfield mask, GLenum filter); GLint dstY1, GLbitfield mask, GLenum filter);
void BindRenderbuffer(GLenum target, GLuint renderbuffer); void BindRenderbuffer(GLenum target, GLuint renderbuffer);
void BindFramebuffer(GLenum target, GLuint framebuffer); void BindFramebuffer(GLenum target, GLuint framebuffer);
namespace FramebufferImpl {
struct DefaultFramebufferInfo {
SharedPtr<MG_State::GLState::FramebufferObject> defaultFBO;
SharedPtr<MG_State::GLState::ITextureObject> colorAttachment;
SharedPtr<MG_State::GLState::ITextureObject> depthAttachment;
SharedPtr<MG_State::GLState::ITextureObject> stencilAttachment;
};
extern DefaultFramebufferInfo* pDefaultFramebufferInfo;
} // namespace FramebufferImpl
} // namespace MG_Impl::GLImpl } // namespace MG_Impl::GLImpl
} // namespace MobileGL } // namespace MobileGL
+6 -3
View File
@@ -29,10 +29,10 @@ namespace MobileGL {
case GL_VERSION: { case GL_VERSION: {
if (versionStr.empty()) { if (versionStr.empty()) {
versionStr = versionStr =
std::format("{} {}, {} Backend, Version {}", std::format("{} {} {}, {} Backend",
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(), MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(),
MG_Config::ProjectName.c_str(), MG_Config::RendererInfoPtr->BackendName.c_str(), MG_Config::ProjectName.c_str(), MG_Config::CoreVersion.toString().c_str(),
MG_Config::CoreVersion.toString().c_str()); MG_Config::RendererInfoPtr->BackendName.c_str());
} }
return (const GLubyte*)versionStr.c_str(); return (const GLubyte*)versionStr.c_str();
} }
@@ -115,6 +115,9 @@ namespace MobileGL {
case GL_MINOR_VERSION: case GL_MINOR_VERSION:
params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.Minor; params[0] = MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.Minor;
break; break;
case GL_MAX_TEXTURE_SIZE:
params[0] = 1024 * 64; // TODO: get from backend
break;
// State // State
// TODO // TODO
+436 -10
View File
@@ -1,8 +1,8 @@
#include "GL_Texture.h" #include "GL_Texture.h"
#include "GL/glext.h" #include "GL/gl.h"
#include "MG_State/GLState/TextureState/TextureObject.h"
#include "MG_Util/Types.h" #include "MG_Util/Types.h"
#include "Validators.h" #include "Validators.h"
#include "ProxyTexture.h"
#include <MG_State/GLState/Core.h> #include <MG_State/GLState/Core.h>
#include <MG_Util/Metrics/TextureMetrics.h> #include <MG_Util/Metrics/TextureMetrics.h>
#include <MG_State/GLState/ErrorState/Error.h> #include <MG_State/GLState/ErrorState/Error.h>
@@ -93,11 +93,142 @@ namespace MobileGL {
} }
void TexParameterf_State(GLenum target, GLenum pname, GLfloat param) { void TexParameterf_State(GLenum target, GLenum pname, GLfloat param) {
// TODO: implement
// ======================= Converting ================================
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget);
// ======================= Processing ================================
SharedPtr<MG_State::GLState::ITextureObject> textureObject = nullptr;
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
textureObject =
TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget);
} else {
auto activeUnit =
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
textureObject = bindingSlot.GetBoundObject();
}
if (!TextureImpl::ValidateTextureObject(textureObject)) return;
switch (pname) {
case GL_TEXTURE_MAG_FILTER:
textureObject->GetSamplerObject()->SetMagFilter(MG_Util::ConvertGLEnumToSamplerFilterMode(param));
break;
case GL_TEXTURE_MIN_FILTER:
textureObject->GetSamplerObject()->SetMinFilter(MG_Util::ConvertGLEnumToSamplerFilterMode(param));
break;
case GL_TEXTURE_MIN_LOD: {
Float maxLod = textureObject->GetSamplerObject()->GetMaxLod();
textureObject->GetSamplerObject()->SetLodRange(param, maxLod);
break;
}
case GL_TEXTURE_MAX_LOD: {
Float minLod = textureObject->GetSamplerObject()->GetMinLod();
textureObject->GetSamplerObject()->SetLodRange(minLod, param);
break;
}
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_SWIZZLE_R:
case GL_TEXTURE_SWIZZLE_G:
case GL_TEXTURE_SWIZZLE_B:
case GL_TEXTURE_SWIZZLE_A:
case GL_TEXTURE_SWIZZLE_RGBA:
case GL_TEXTURE_BORDER_COLOR:
break; // TODO
case GL_TEXTURE_WRAP_S:
textureObject->GetSamplerObject()->SetWrapS(MG_Util::ConvertGLEnumToSamplerWrapMode(param));
break;
case GL_TEXTURE_WRAP_T:
textureObject->GetSamplerObject()->SetWrapT(MG_Util::ConvertGLEnumToSamplerWrapMode(param));
break;
case GL_TEXTURE_WRAP_R:
textureObject->GetSamplerObject()->SetWrapR(MG_Util::ConvertGLEnumToSamplerWrapMode(param));
break;
case GL_TEXTURE_COMPARE_MODE:
textureObject->GetSamplerObject()->SetCompareMode(MG_Util::ConvertGLEnumToSamplerCompareMode(param));
break;
case GL_TEXTURE_COMPARE_FUNC:
textureObject->GetSamplerObject()->SetSamplerCompareFunc(
MG_Util::ConvertGLEnumToSamplerCompareFunc(param));
break;
default:
MG_State::pGLContext->RecordError(
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "TexParameteri_State",
"pname is not a valid texture parameter."));
return;
}
} }
void TexParameteri_State(GLenum target, GLenum pname, GLint param) { void TexParameteri_State(GLenum target, GLenum pname, GLint param) {
// TODO: implement // ======================= Converting ================================
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget);
// ======================= Processing ================================
SharedPtr<MG_State::GLState::ITextureObject> textureObject = nullptr;
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
textureObject =
TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget);
} else {
auto activeUnit =
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
textureObject = bindingSlot.GetBoundObject();
}
if (!TextureImpl::ValidateTextureObject(textureObject)) return;
switch (pname) {
case GL_TEXTURE_MAG_FILTER:
textureObject->GetSamplerObject()->SetMagFilter(MG_Util::ConvertGLEnumToSamplerFilterMode(param));
break;
case GL_TEXTURE_MIN_FILTER:
textureObject->GetSamplerObject()->SetMinFilter(MG_Util::ConvertGLEnumToSamplerFilterMode(param));
break;
case GL_TEXTURE_MIN_LOD: {
Float maxLod = textureObject->GetSamplerObject()->GetMaxLod();
textureObject->GetSamplerObject()->SetLodRange(param, maxLod);
break;
}
case GL_TEXTURE_MAX_LOD: {
Float minLod = textureObject->GetSamplerObject()->GetMinLod();
textureObject->GetSamplerObject()->SetLodRange(minLod, param);
break;
}
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_SWIZZLE_R:
case GL_TEXTURE_SWIZZLE_G:
case GL_TEXTURE_SWIZZLE_B:
case GL_TEXTURE_SWIZZLE_A:
case GL_TEXTURE_SWIZZLE_RGBA:
case GL_TEXTURE_BORDER_COLOR:
break; // TODO
case GL_TEXTURE_WRAP_S:
textureObject->GetSamplerObject()->SetWrapS(MG_Util::ConvertGLEnumToSamplerWrapMode(param));
break;
case GL_TEXTURE_WRAP_T:
textureObject->GetSamplerObject()->SetWrapT(MG_Util::ConvertGLEnumToSamplerWrapMode(param));
break;
case GL_TEXTURE_WRAP_R:
textureObject->GetSamplerObject()->SetWrapR(MG_Util::ConvertGLEnumToSamplerWrapMode(param));
break;
case GL_TEXTURE_COMPARE_MODE:
textureObject->GetSamplerObject()->SetCompareMode(MG_Util::ConvertGLEnumToSamplerCompareMode(param));
break;
case GL_TEXTURE_COMPARE_FUNC:
textureObject->GetSamplerObject()->SetSamplerCompareFunc(
MG_Util::ConvertGLEnumToSamplerCompareFunc(param));
break;
default:
MG_State::pGLContext->RecordError(
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "TexParameteri_State",
"pname is not a valid texture parameter."));
return;
}
} }
void TexImage3DMultisample_State(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, void TexImage3DMultisample_State(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width,
@@ -148,9 +279,16 @@ namespace MobileGL {
// indicated by type. // indicated by type.
// ======================= Processing ================================ // ======================= Processing ================================
auto activeUnit = MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit()); SharedPtr<MG_State::GLState::ITextureObject> textureObject = nullptr;
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
textureObject =
TextureImpl::pProxyTextureManager->CreateOrReplaceProxyTextureObject(textureUploadingTarget);
} else {
auto activeUnit =
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget); auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
auto textureObject = bindingSlot.GetBoundObject(); textureObject = bindingSlot.GetBoundObject();
}
// ===================== Error Checking ============================== // ===================== Error Checking ==============================
if (!TextureImpl::ValidateTextureObject(textureObject)) return; if (!TextureImpl::ValidateTextureObject(textureObject)) return;
@@ -189,19 +327,307 @@ namespace MobileGL {
} }
void GetTexParameteriv_State(GLenum target, GLenum pname, GLint* params) { void GetTexParameteriv_State(GLenum target, GLenum pname, GLint* params) {
// TODO: implement // ======================= Converting ================================
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget);
// ======================= Processing ================================
SharedPtr<MG_State::GLState::ITextureObject> textureObject = nullptr;
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
} else {
auto activeUnit =
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
textureObject = bindingSlot.GetBoundObject();
}
if (!TextureImpl::ValidateTextureObject(textureObject)) return;
switch (pname) {
case GL_TEXTURE_MAG_FILTER:
if (params) {
*params =
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMagFilter());
}
break;
case GL_TEXTURE_MIN_FILTER:
if (params) {
*params =
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter());
}
break;
case GL_TEXTURE_MIN_LOD:
if (params) {
*params = static_cast<GLint>(textureObject->GetSamplerObject()->GetMinLod());
}
break;
case GL_TEXTURE_MAX_LOD:
if (params) {
*params = static_cast<GLint>(textureObject->GetSamplerObject()->GetMaxLod());
}
break;
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_SWIZZLE_R:
case GL_TEXTURE_SWIZZLE_G:
case GL_TEXTURE_SWIZZLE_B:
case GL_TEXTURE_SWIZZLE_A:
case GL_TEXTURE_SWIZZLE_RGBA:
case GL_TEXTURE_BORDER_COLOR:
break; // TODO
case GL_TEXTURE_WRAP_S:
if (params) {
*params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapS());
}
break;
case GL_TEXTURE_WRAP_T:
if (params) {
*params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapT());
}
break;
case GL_TEXTURE_WRAP_R:
if (params) {
*params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapR());
}
break;
case GL_TEXTURE_COMPARE_MODE:
if (params) {
*params =
MG_Util::ConvertSamplerCompareModeToGLEnum(textureObject->GetSamplerObject()->GetCompareMode());
}
break;
case GL_TEXTURE_COMPARE_FUNC:
if (params) {
*params = MG_Util::ConvertSamplerCompareFuncToGLEnum(
textureObject->GetSamplerObject()->GetSamplerCompareFunc());
}
break;
default:
MG_State::pGLContext->RecordError(
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexParameteriv_State",
"pname is not a valid texture parameter."));
return;
}
} }
void GetTexParameterfv_State(GLenum target, GLenum pname, GLfloat* params) { void GetTexParameterfv_State(GLenum target, GLenum pname, GLfloat* params) {
// TODO: implement // ======================= Converting ================================
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget);
// ======================= Processing ================================
SharedPtr<MG_State::GLState::ITextureObject> textureObject = nullptr;
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
} else {
auto activeUnit =
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
textureObject = bindingSlot.GetBoundObject();
}
if (!TextureImpl::ValidateTextureObject(textureObject)) return;
switch (pname) {
case GL_TEXTURE_MAG_FILTER:
if (params) {
*params =
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMagFilter());
}
break;
case GL_TEXTURE_MIN_FILTER:
if (params) {
*params =
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter());
}
break;
case GL_TEXTURE_MIN_LOD:
if (params) {
*params = static_cast<GLfloat>(textureObject->GetSamplerObject()->GetMinLod());
}
break;
case GL_TEXTURE_MAX_LOD:
if (params) {
*params = static_cast<GLfloat>(textureObject->GetSamplerObject()->GetMaxLod());
}
break;
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_SWIZZLE_R:
case GL_TEXTURE_SWIZZLE_G:
case GL_TEXTURE_SWIZZLE_B:
case GL_TEXTURE_SWIZZLE_A:
case GL_TEXTURE_SWIZZLE_RGBA:
case GL_TEXTURE_BORDER_COLOR:
break; // TODO
case GL_TEXTURE_WRAP_S:
if (params) {
*params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapS());
}
break;
case GL_TEXTURE_WRAP_T:
if (params) {
*params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapT());
}
break;
case GL_TEXTURE_WRAP_R:
if (params) {
*params = MG_Util::ConvertSamplerWrapModeToGLEnum(textureObject->GetSamplerObject()->GetWrapR());
}
break;
case GL_TEXTURE_COMPARE_MODE:
if (params) {
*params =
MG_Util::ConvertSamplerCompareModeToGLEnum(textureObject->GetSamplerObject()->GetCompareMode());
}
break;
case GL_TEXTURE_COMPARE_FUNC:
if (params) {
*params = MG_Util::ConvertSamplerCompareFuncToGLEnum(
textureObject->GetSamplerObject()->GetSamplerCompareFunc());
}
break;
default:
MG_State::pGLContext->RecordError(
ErrorCode::InvalidEnum, MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexParameterfv_State",
"pname is not a valid texture parameter."));
return;
}
} }
void GetTexLevelParameteriv_State(GLenum target, GLint level, GLenum pname, GLint* params) { void GetTexLevelParameteriv_State(GLenum target, GLint level, GLenum pname, GLint* params) {
// TODO: implement MGLOG_D("GetTexLevelParameteriv_State called");
// ======================= Converting ================================
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget);
// ===================== Error Checking ==============================
if (!TextureImpl::ValidateTextureUploadTarget(textureUploadingTarget)) return;
if (!TextureImpl::ValidateTextureLevelNumber(level)) return;
if (!TextureImpl::ValidateTextureLevelWithUploadTarget(textureUploadingTarget, level)) return;
// ======================= Processing ================================
SharedPtr<MG_State::GLState::ITextureObject> textureObject = nullptr;
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
} else {
auto activeUnit =
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
textureObject = bindingSlot.GetBoundObject();
}
if (!TextureImpl::ValidateTextureObject(textureObject)) return;
switch (pname) {
case GL_TEXTURE_WIDTH:
if (params) {
*params = textureObject->GetMipmap(level).size.x();
}
break;
case GL_TEXTURE_HEIGHT:
if (params) {
*params = textureObject->GetMipmap(level).size.y();
}
break;
case GL_TEXTURE_DEPTH:
if (params) {
*params = textureObject->GetMipmap(level).size.z();
}
break;
case GL_TEXTURE_INTERNAL_FORMAT:
if (params) {
*params = MG_Util::ConvertTextureInternalFormatToGLEnum(textureObject->GetFormat());
}
break;
case GL_TEXTURE_RED_TYPE:
case GL_TEXTURE_GREEN_TYPE:
case GL_TEXTURE_BLUE_TYPE:
case GL_TEXTURE_ALPHA_TYPE:
case GL_TEXTURE_DEPTH_TYPE:
case GL_TEXTURE_RED_SIZE:
case GL_TEXTURE_GREEN_SIZE:
case GL_TEXTURE_BLUE_SIZE:
case GL_TEXTURE_ALPHA_SIZE:
case GL_TEXTURE_DEPTH_SIZE:
case GL_TEXTURE_COMPRESSED:
case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
break; // TODO
default:
MG_State::pGLContext->RecordError(
ErrorCode::InvalidEnum,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexLevelParameteriv_State",
"pname is not a valid texture level parameter."));
return;
}
} }
void GetTexLevelParameterfv_State(GLenum target, GLint level, GLenum pname, GLfloat* params) { void GetTexLevelParameterfv_State(GLenum target, GLint level, GLenum pname, GLfloat* params) {
// TODO: implement // ======================= Converting ================================
TextureUploadTarget textureUploadingTarget = MG_Util::ConvertGLEnumToTextureUploadTarget(target);
TextureTarget textureTarget = MG_Util::ConvertTextureUploadTargetToTextureTarget(textureUploadingTarget);
// ===================== Error Checking ==============================
if (!TextureImpl::ValidateTextureUploadTarget(textureUploadingTarget)) return;
if (!TextureImpl::ValidateTextureLevelNumber(level)) return;
if (!TextureImpl::ValidateTextureLevelWithUploadTarget(textureUploadingTarget, level)) return;
// ======================= Processing ================================
SharedPtr<MG_State::GLState::ITextureObject> textureObject = nullptr;
if (TextureImpl::IsProxyTextureTarget(textureUploadingTarget)) {
textureObject = TextureImpl::pProxyTextureManager->GetProxyTextureObject(textureUploadingTarget);
} else {
auto activeUnit =
MG_State::pGLContext->GetTextureUnitObject(MG_State::pGLContext->GetActiveTextureUnit());
auto& bindingSlot = activeUnit.GetBindingSlot(textureTarget);
textureObject = bindingSlot.GetBoundObject();
}
if (!TextureImpl::ValidateTextureObject(textureObject)) return;
switch (pname) {
case GL_TEXTURE_WIDTH:
if (params) {
*params = textureObject->GetMipmap(level).size.x();
}
break;
case GL_TEXTURE_HEIGHT:
if (params) {
*params = textureObject->GetMipmap(level).size.y();
}
break;
case GL_TEXTURE_DEPTH:
if (params) {
*params = textureObject->GetMipmap(level).size.z();
}
break;
case GL_TEXTURE_INTERNAL_FORMAT:
if (params) {
*params = MG_Util::ConvertTextureInternalFormatToGLEnum(textureObject->GetFormat());
}
break;
case GL_TEXTURE_RED_TYPE:
case GL_TEXTURE_GREEN_TYPE:
case GL_TEXTURE_BLUE_TYPE:
case GL_TEXTURE_ALPHA_TYPE:
case GL_TEXTURE_DEPTH_TYPE:
case GL_TEXTURE_RED_SIZE:
case GL_TEXTURE_GREEN_SIZE:
case GL_TEXTURE_BLUE_SIZE:
case GL_TEXTURE_ALPHA_SIZE:
case GL_TEXTURE_DEPTH_SIZE:
case GL_TEXTURE_COMPRESSED:
case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
break; // TODO
default:
MG_State::pGLContext->RecordError(
ErrorCode::InvalidEnum,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "GetTexLevelParameterfv_State",
"pname is not a valid texture level parameter."));
return;
}
} }
void GetTexImage_State(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels) { void GetTexImage_State(GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels) {
@@ -0,0 +1,41 @@
#include "ProxyTexture.h"
#include "MG_State/GLState/TextureState/TextureObject.h"
#include "MG_Util/Types.h"
namespace MobileGL::MG_Impl::GLImpl {
namespace TextureImpl {
ProxyTextureManager* pProxyTextureManager;
Bool IsProxyTextureTarget(TextureUploadTarget target) {
switch (target) {
case TextureUploadTarget::ProxyCubeMap:
case TextureUploadTarget::ProxyTexture1DArray:
case TextureUploadTarget::ProxyTexture2D:
case TextureUploadTarget::ProxyTexture2DMultisample:
case TextureUploadTarget::ProxyTextureRectangle:
return true;
default:
return false;
}
}
SharedPtr<MG_State::GLState::ITextureObject> ProxyTextureManager::CreateOrReplaceProxyTextureObject(
TextureUploadTarget target) {
auto it = m_proxyTexturesMap.find(target);
if (it != m_proxyTexturesMap.end()) {
m_proxyTexturesMap.erase(it);
}
m_proxyTexturesMap[target] = MakeShared<MG_State::GLState::TextureObject2D>();
return m_proxyTexturesMap[target];
}
SharedPtr<MG_State::GLState::ITextureObject> ProxyTextureManager::GetProxyTextureObject(
TextureUploadTarget target) {
auto it = m_proxyTexturesMap.find(target);
if (it != m_proxyTexturesMap.end()) {
return it->second;
}
return nullptr;
}
} // namespace TextureImpl
} // namespace MobileGL::MG_Impl::GLImpl
@@ -0,0 +1,20 @@
#pragma once
#include <Includes.h>
#include <MG_State/GLState/Core.h>
namespace MobileGL::MG_Impl::GLImpl {
namespace TextureImpl {
Bool IsProxyTextureTarget(TextureUploadTarget target);
class ProxyTextureManager {
public:
SharedPtr<MG_State::GLState::ITextureObject> CreateOrReplaceProxyTextureObject(TextureUploadTarget target);
SharedPtr<MG_State::GLState::ITextureObject> GetProxyTextureObject(TextureUploadTarget target);
private:
UnorderedMap<TextureUploadTarget, SharedPtr<MG_State::GLState::ITextureObject>> m_proxyTexturesMap;
};
extern ProxyTextureManager* pProxyTextureManager;
} // namespace TextureImpl
} // namespace MobileGL::MG_Impl::GLImpl
+30
View File
@@ -0,0 +1,30 @@
#include "Init.h"
#include "GLImpl/Texture/ProxyTexture.h"
#include "GLImpl/Framebuffer/GL_Framebuffer.h"
namespace MobileGL {
namespace MG_Impl {
void Init() {
MGLOG_D("Initializing MobileGL Implementation...");
GLImpl::TextureImpl::pProxyTextureManager = new GLImpl::TextureImpl::ProxyTextureManager();
// TODO: get real info in EGL
auto fbo0 = MG_State::pGLContext->CreateFramebufferObject(0);
auto colorTex = MakeShared<MG_State::GLState::TextureObject2D>();
colorTex->SetInternalFormat(TextureInternalFormat::RGBA8);
colorTex->SetMipmapLevel({{512, 512, 1}, 0, false, 0, {nullptr, 0}});
auto depthTex = MakeShared<MG_State::GLState::TextureObject2D>();
depthTex->SetInternalFormat(TextureInternalFormat::Depth32FStencil8);
depthTex->SetMipmapLevel({{512, 512, 1}, 0, false, 0, {nullptr, 0}});
auto stencilTex = MakeShared<MG_State::GLState::TextureObject2D>();
stencilTex->SetInternalFormat(TextureInternalFormat::Depth32FStencil8);
stencilTex->SetMipmapLevel({{512, 512, 1}, 0, false, 0, {nullptr, 0}});
fbo0->AttachTexture(FramebufferAttachmentType::Color0, colorTex);
fbo0->AttachTexture(FramebufferAttachmentType::Depth, depthTex);
fbo0->AttachTexture(FramebufferAttachmentType::Depth, depthTex);
fbo0->AttachTexture(FramebufferAttachmentType::Stencil, stencilTex);
GLImpl::FramebufferImpl::pDefaultFramebufferInfo =
new GLImpl::FramebufferImpl::DefaultFramebufferInfo(fbo0, colorTex, depthTex, stencilTex);
}
} // namespace MG_Impl
} // namespace MobileGL
+7
View File
@@ -0,0 +1,7 @@
#include <Includes.h>
namespace MobileGL {
namespace MG_Impl {
void Init();
} // namespace MG_Impl
} // namespace MobileGL
@@ -9,9 +9,9 @@ namespace MobileGL {
: m_texture(texture), m_textureLevel(level) {} : m_texture(texture), m_textureLevel(level) {}
FramebufferAttachment::FramebufferAttachment(SharedPtr<RenderbufferObjectStub> renderbuffer) FramebufferAttachment::FramebufferAttachment(SharedPtr<RenderbufferObjectStub> renderbuffer)
: m_renderbuffer(renderbuffer) {} : m_renderbuffer(renderbuffer) {}
FramebufferAttachment::FramebufferAttachment(std::nullptr_t) FramebufferAttachment::FramebufferAttachment(Bool IsValid) : m_texture(nullptr), m_renderbuffer(nullptr) {
: m_texture(nullptr), m_renderbuffer(nullptr) {} m_isValid = IsValid;
FramebufferAttachment::FramebufferAttachment() : m_texture(nullptr), m_renderbuffer(nullptr) {} }
Bool FramebufferAttachment::IsTexture() const { Bool FramebufferAttachment::IsTexture() const {
return m_texture != nullptr; return m_texture != nullptr;
@@ -39,10 +39,13 @@ namespace MobileGL {
Bool FramebufferAttachment::IsComplete() const { Bool FramebufferAttachment::IsComplete() const {
if (IsTexture()) { if (IsTexture()) {
return m_texture->IsComplete(); Bool complete = m_texture->IsComplete();
return complete;
} else if (IsRenderbuffer()) { } else if (IsRenderbuffer()) {
// TODO // TODO
return false;
} }
return false; return false;
} }
@@ -55,9 +58,13 @@ namespace MobileGL {
return {0, 0}; return {0, 0};
} }
Bool FramebufferAttachment::IsValid() const {
return m_isValid;
}
// FramebufferObject // FramebufferObject
FramebufferObject::FramebufferObject() { FramebufferObject::FramebufferObject() {
m_attachments.fill(FramebufferAttachment(nullptr)); m_attachments.fill(FramebufferAttachment(false));
} }
void FramebufferObject::AttachTexture(FramebufferAttachmentType type, SharedPtr<ITextureObject> texture, void FramebufferObject::AttachTexture(FramebufferAttachmentType type, SharedPtr<ITextureObject> texture,
@@ -73,7 +80,7 @@ namespace MobileGL {
} }
void FramebufferObject::Detach(FramebufferAttachmentType type) { void FramebufferObject::Detach(FramebufferAttachmentType type) {
m_attachments[static_cast<SizeT>(type)] = FramebufferAttachment(nullptr); m_attachments[static_cast<SizeT>(type)] = FramebufferAttachment(false);
m_drawBuffersDirty = true; m_drawBuffersDirty = true;
} }
@@ -86,21 +93,30 @@ namespace MobileGL {
return false; return false;
} }
int width = -1, height = -1; Int width = -1, height = -1;
for (const auto& attachment : m_attachments) { Int validAttachmentCount = 0;
for (SizeT i = 0; i < m_attachments.size(); ++i) {
if (!m_attachments[i].IsValid()) continue;
++validAttachmentCount;
const auto& attachment = m_attachments[i];
auto attachmentSize = attachment.GetSize(); auto attachmentSize = attachment.GetSize();
int w = attachmentSize.x(); Int w = attachmentSize.x();
int h = attachmentSize.y(); Int h = attachmentSize.y();
if (width == -1) { if (width == -1) {
width = w; width = w;
height = h; height = h;
} else if (width != w || height != h) { } else if (width != w || height != h) {
return false; return false;
} }
if (!attachment.IsComplete()) { if (!attachment.IsComplete()) {
return false; return false;
} }
} }
if (validAttachmentCount == 0) return false;
return true; return true;
} }
@@ -46,7 +46,6 @@ namespace MobileGL {
Color31, Color31,
Depth, Depth,
Stencil, Stencil,
DepthStencil,
FramebufferAttachmentTypeCount, FramebufferAttachmentTypeCount,
Unknown = -1 Unknown = -1
}; };
@@ -60,8 +59,7 @@ namespace MobileGL {
// TODO: add Renderbuffer when it is implemented // TODO: add Renderbuffer when it is implemented
explicit FramebufferAttachment(SharedPtr<MG_State::GLState::ITextureObject> texture, Int level = 0); explicit FramebufferAttachment(SharedPtr<MG_State::GLState::ITextureObject> texture, Int level = 0);
explicit FramebufferAttachment(SharedPtr<RenderbufferObjectStub> renderbuffer); explicit FramebufferAttachment(SharedPtr<RenderbufferObjectStub> renderbuffer);
explicit FramebufferAttachment(std::nullptr_t); explicit FramebufferAttachment(Bool IsValid = true);
explicit FramebufferAttachment();
Bool IsTexture() const; Bool IsTexture() const;
Bool IsRenderbuffer() const; Bool IsRenderbuffer() const;
@@ -71,11 +69,13 @@ namespace MobileGL {
Int GetTextureLevel() const; Int GetTextureLevel() const;
Bool IsComplete() const; Bool IsComplete() const;
IntVec3 GetSize() const; IntVec3 GetSize() const;
Bool IsValid() const;
private: private:
SharedPtr<MG_State::GLState::ITextureObject> m_texture = nullptr; SharedPtr<MG_State::GLState::ITextureObject> m_texture = nullptr;
SharedPtr<RenderbufferObjectStub> m_renderbuffer = nullptr; SharedPtr<RenderbufferObjectStub> m_renderbuffer = nullptr;
Int m_textureLevel = 0; Int m_textureLevel = 0;
Bool m_isValid = true;
}; };
class FramebufferObject { class FramebufferObject {
@@ -1,13 +1,18 @@
#include "FramebufferState.h" #include "FramebufferState.h"
#include "MG_State/GLState/FramebufferState/FramebufferObject.h"
namespace MobileGL { namespace MobileGL {
namespace MG_State { namespace MG_State {
namespace GLState { namespace GLState {
FramebufferState::FramebufferState() {} FramebufferState::FramebufferState() {
for (SizeT i = 0; i < m_bindingSlots.size(); ++i) {
m_bindingSlots[i] = BindingSlot<FramebufferObject>(static_cast<FramebufferTarget>(i));
}
}
SharedPtr<FramebufferObject> FramebufferState::GetFramebufferObject(Uint index) { SharedPtr<FramebufferObject> FramebufferState::GetFramebufferObject(Uint index) {
auto it = m_bufferObjects.find(index); auto it = m_framebufferObjects.find(index);
if (it != m_bufferObjects.end()) { if (it != m_framebufferObjects.end()) {
return it->second; return it->second;
} }
return nullptr; return nullptr;
@@ -20,8 +25,15 @@ namespace MobileGL {
} }
SharedPtr<FramebufferObject> FramebufferState::CreateFramebufferObject(Uint index) { SharedPtr<FramebufferObject> FramebufferState::CreateFramebufferObject(Uint index) {
if (index == 0) {
if (!m_indexGenerator.IsValid(0)) {
m_indexGenerator.Insert(0);
} else {
return nullptr;
}
}
auto bufferObject = MakeShared<FramebufferObject>(); auto bufferObject = MakeShared<FramebufferObject>();
m_bufferObjects[index] = bufferObject; m_framebufferObjects[index] = bufferObject;
return bufferObject; return bufferObject;
} }
@@ -37,14 +49,14 @@ namespace MobileGL {
void FramebufferState::MarkFramebufferObjectForDeletion(Uint index) { void FramebufferState::MarkFramebufferObjectForDeletion(Uint index) {
if (m_indexGenerator.IsValid(index)) { if (m_indexGenerator.IsValid(index)) {
auto it = m_bufferObjects.find(index); auto it = m_framebufferObjects.find(index);
if (it != m_bufferObjects.end()) { if (it != m_framebufferObjects.end()) {
for (SizeT i = 0; i < m_bindingSlots.size(); ++i) { for (SizeT i = 0; i < m_bindingSlots.size(); ++i) {
if (m_bindingSlots[i].GetBoundObject() == it->second) { if (m_bindingSlots[i].GetBoundObject() == it->second) {
m_bindingSlots[i].Bind(nullptr); m_bindingSlots[i].Bind(nullptr);
} }
} }
m_bufferObjects.erase(it); m_framebufferObjects.erase(it);
} }
m_indexGenerator.Delete(index); m_indexGenerator.Delete(index);
} }
@@ -55,7 +67,7 @@ namespace MobileGL {
} }
Bool FramebufferState::ValidateFramebufferObject(Uint index) const { Bool FramebufferState::ValidateFramebufferObject(Uint index) const {
return m_bufferObjects.find(index) != m_bufferObjects.end(); return m_framebufferObjects.find(index) != m_framebufferObjects.end();
} }
} // namespace GLState } // namespace GLState
} // namespace MG_State } // namespace MG_State
@@ -20,7 +20,7 @@ namespace MobileGL {
Bool ValidateFramebufferObject(Uint index) const; Bool ValidateFramebufferObject(Uint index) const;
private: private:
UnorderedMap<Uint, SharedPtr<FramebufferObject>> m_bufferObjects; UnorderedMap<Uint, SharedPtr<FramebufferObject>> m_framebufferObjects;
IndexGenerator<Uint> m_indexGenerator; IndexGenerator<Uint> m_indexGenerator;
Array<BindingSlot<FramebufferObject>, static_cast<SizeT>(FramebufferTarget::FramebufferTargetCount)> Array<BindingSlot<FramebufferObject>, static_cast<SizeT>(FramebufferTarget::FramebufferTargetCount)>
m_bindingSlots; m_bindingSlots;
@@ -1,7 +1,6 @@
#include "ProgramObject.h" #include "ProgramObject.h"
#include <MG_Util/ShaderTranspiler/ShaderCompiler.h> #include <MG_Util/ShaderTranspiler/ShaderCompiler.h>
#include <MG_Util/Converters/SPIRVCrossToGL/SpvcTypeConverter.h>
#include "MG_Util/Converters/SPIRVCrossToGL/SpvcTypeConverter.h"
namespace MobileGL { namespace MobileGL {
namespace MG_State { namespace MG_State {
@@ -74,7 +73,9 @@ namespace MobileGL {
for (int i = 0; i < m_activeUniformCount; i++) { for (int i = 0; i < m_activeUniformCount; i++) {
auto& uniform = m_program->getUniform(i); auto& uniform = m_program->getUniform(i);
auto location = uniform.layoutLocation(); auto location = uniform.layoutLocation();
if (location >= 0) {
m_maxUniformLocation = std::max(m_maxUniformLocation, location); m_maxUniformLocation = std::max(m_maxUniformLocation, location);
}
m_uniformNameMaxLength = std::max(m_uniformNameMaxLength, (Int)uniform.name.length()); m_uniformNameMaxLength = std::max(m_uniformNameMaxLength, (Int)uniform.name.length());
m_uniformLocations[uniform.name] = location; m_uniformLocations[uniform.name] = location;
} }
@@ -88,37 +89,97 @@ namespace MobileGL {
for (int i = 0; i < m_activeUniformCount; i++) { for (int i = 0; i < m_activeUniformCount; i++) {
auto& uniform = m_program->getUniform(i); auto& uniform = m_program->getUniform(i);
auto location = uniform.layoutLocation(); auto location = uniform.layoutLocation();
if (location >= 0 && location < (int)m_uniformNames.size()) {
m_uniformNames[location] = uniform.name; m_uniformNames[location] = uniform.name;
m_uniformTypes[location] = uniform.glDefineType; m_uniformTypes[location] = uniform.glDefineType;
m_uniformIsOpaqueType[location] = uniform.getType()->isOpaque(); m_uniformIsOpaqueType[location] = uniform.getType()->isOpaque();
m_uniformArraySizes[location] = uniform.size; m_uniformArraySizes[location] = uniform.size;
} }
}
// attributes (pipe in)
int inCount = m_program->getNumPipeInputs(); int inCount = m_program->getNumPipeInputs();
m_attribs.resize(inCount);
m_attribTypes.resize(inCount);
// Get locations parsed in program int maxLoc = -1;
for (int i = 0; i < inCount; i++) { for (int i = 0; i < inCount; ++i) {
int loc = m_program->getPipeInput(i).layoutLocation();
if (loc >= 0) maxLoc = std::max(maxLoc, loc);
}
if (maxLoc < 0) {
maxLoc = std::max(0, inCount - 1);
}
GLint maxAttribs = 16; // TODO: get from backend
if (maxLoc >= maxAttribs) {
MGLOG_W("ProgramObject::DoReflection - required attrib location %d >= GL_MAX_VERTEX_ATTRIBS (%d). "
"Clamping.",
maxLoc, maxAttribs);
maxLoc = maxAttribs - 1;
}
m_attribs.resize(maxLoc + 1);
m_attribTypes.resize(maxLoc + 1);
for (int i = 0; i < inCount; ++i) {
auto& inVar = m_program->getPipeInput(i); auto& inVar = m_program->getPipeInput(i);
auto location = inVar.layoutLocation(); int location = inVar.layoutLocation();
m_attribInNameMaxLength = std::max(m_attribInNameMaxLength, (Int)inVar.name.length()); m_attribInNameMaxLength = std::max(m_attribInNameMaxLength, (Int)inVar.name.length());
if (location >= 0 && location < (int)m_attribs.size()) {
m_attribs[location] = inVar.name; m_attribs[location] = inVar.name;
m_attribTypes[location] = inVar.glDefineType; m_attribTypes[location] = inVar.glDefineType;
} else if (location >= (int)m_attribs.size()) {
MGLOG_W("ProgramObject::DoReflection - attrib location %d >= attribs.size() (%zu). Ignoring.",
location, m_attribs.size());
continue;
} else {
bool placed = false;
for (size_t idx = 0; idx < m_attribs.size(); ++idx) {
if (m_attribs[idx].empty()) {
m_attribs[idx] = inVar.name;
m_attribTypes[idx] = inVar.glDefineType;
placed = true;
break;
} }
// Implement glBindAttribLocation semantics }
if (!placed && (int)m_attribs.size() < maxAttribs) {
m_attribs.push_back(inVar.name);
m_attribTypes.push_back(inVar.glDefineType);
placed = true;
}
if (!placed) {
MGLOG_W("ProgramObject::DoReflection - cannot place attrib '%s' (no free slot and at max "
"capacity). Ignoring.",
inVar.name.c_str());
}
}
}
// Implement glBindAttribLocation semantics (explicit locations set by user)
for (auto& [name, location] : m_explicitAttribLocations) { for (auto& [name, location] : m_explicitAttribLocations) {
assert(location < m_attribs.size()); if (location < 0) continue;
if (location >= (int)m_attribs.size()) {
if (location >= maxAttribs) {
MGLOG_W("SetExplicitAttribLocation: requested location %d >= GL_MAX_VERTEX_ATTRIBS (%d). "
"Ignored for attribute '%s'.",
location, maxAttribs, name.c_str());
continue;
}
m_attribs.resize(location + 1);
m_attribTypes.resize(location + 1);
}
if (m_attribs[location] != name) { if (m_attribs[location] != name) {
auto it = std::find(m_attribs.begin(), m_attribs.end(), name); auto it = std::find(m_attribs.begin(), m_attribs.end(), name);
if (it == m_attribs.end()) continue; if (it == m_attribs.end()) continue;
std::swap(m_attribs[location], m_attribs[std::distance(m_attribs.begin(), it)]); auto idx = std::distance(m_attribs.begin(), it);
std::swap(m_attribTypes[location], m_attribTypes[std::distance(m_attribs.begin(), it)]); std::swap(m_attribs[location], m_attribs[idx]);
std::swap(m_attribTypes[location], m_attribTypes[idx]);
} }
} }
// UBO // ---------- UBO ----------
int uboCount = m_program->getNumUniformBlocks(); int uboCount = m_program->getNumUniformBlocks();
for (int i = 0; i < uboCount; i++) { for (int i = 0; i < uboCount; i++) {
auto& ubo = m_program->getUniformBlock(i); auto& ubo = m_program->getUniformBlock(i);
@@ -1,7 +1,6 @@
#include "ShaderObject.h" #include "ShaderObject.h"
#include <MG_Util/ShaderTranspiler/ShaderCompiler.h> #include <MG_Util/ShaderTranspiler/ShaderCompiler.h>
#include <MG_Util/ShaderTranspiler/glslang/UniformTraverser.h>
#include "MG_Util/ShaderTranspiler/glslang/UniformTraverser.h"
namespace MobileGL { namespace MobileGL {
namespace MG_State { namespace MG_State {
@@ -33,7 +33,7 @@ namespace MobileGL {
Unknown = -1 Unknown = -1
}; };
enum class CompareFunc { enum class SamplerCompareFunc {
Never, Never,
Less, Less,
Equal, Equal,
@@ -42,7 +42,7 @@ namespace MobileGL {
NotEqual, NotEqual,
GreaterEqual, GreaterEqual,
Always, Always,
CompareFuncCount, SamplerCompareFuncCount,
Unknown = -1 Unknown = -1
}; };
@@ -55,7 +55,7 @@ namespace MobileGL {
m_wrapR(SamplerWrapMode::Repeat), m_minFilter(SamplerFilterMode::Linear), m_wrapR(SamplerWrapMode::Repeat), m_minFilter(SamplerFilterMode::Linear),
m_magFilter(SamplerFilterMode::Linear), m_mipmapMode(SamplerMipmapMode::None), m_minLod(0.0f), m_magFilter(SamplerFilterMode::Linear), m_mipmapMode(SamplerMipmapMode::None), m_minLod(0.0f),
m_maxLod(1000.0f), m_lodBias(0.0f), m_compareMode(SamplerCompareMode::None), m_maxLod(1000.0f), m_lodBias(0.0f), m_compareMode(SamplerCompareMode::None),
m_compareFunc(CompareFunc::Less) {} m_compareFunc(SamplerCompareFunc::Less) {}
void SetWrapS(SamplerWrapMode mode) { m_wrapS = mode; } void SetWrapS(SamplerWrapMode mode) { m_wrapS = mode; }
void SetWrapT(SamplerWrapMode mode) { m_wrapT = mode; } void SetWrapT(SamplerWrapMode mode) { m_wrapT = mode; }
@@ -71,7 +71,7 @@ namespace MobileGL {
m_maxLod = maxLod; m_maxLod = maxLod;
} }
void SetLodBias(Float bias) { m_lodBias = bias; } void SetLodBias(Float bias) { m_lodBias = bias; }
void SetCompareFunc(CompareFunc func) { m_compareFunc = func; } void SetSamplerCompareFunc(SamplerCompareFunc func) { m_compareFunc = func; }
void SetCompareMode(SamplerCompareMode mode) { m_compareMode = mode; } void SetCompareMode(SamplerCompareMode mode) { m_compareMode = mode; }
SamplerWrapMode GetWrapS() const { return m_wrapS; } SamplerWrapMode GetWrapS() const { return m_wrapS; }
@@ -84,7 +84,7 @@ namespace MobileGL {
Float GetMaxLod() const { return m_maxLod; } Float GetMaxLod() const { return m_maxLod; }
Float GetLodBias() const { return m_lodBias; } Float GetLodBias() const { return m_lodBias; }
SamplerCompareMode GetCompareMode() const { return m_compareMode; } SamplerCompareMode GetCompareMode() const { return m_compareMode; }
CompareFunc GetCompareFunc() const { return m_compareFunc; } SamplerCompareFunc GetSamplerCompareFunc() const { return m_compareFunc; }
private: private:
SamplerWrapMode m_wrapS, m_wrapT, m_wrapR; SamplerWrapMode m_wrapS, m_wrapT, m_wrapR;
@@ -93,7 +93,7 @@ namespace MobileGL {
Float m_minLod, m_maxLod; Float m_minLod, m_maxLod;
Float m_lodBias; Float m_lodBias;
SamplerCompareMode m_compareMode; SamplerCompareMode m_compareMode;
CompareFunc m_compareFunc; SamplerCompareFunc m_compareFunc;
}; };
} // namespace GLState } // namespace GLState
} // namespace MG_State } // namespace MG_State
@@ -5,7 +5,9 @@ namespace MobileGL {
namespace MG_State { namespace MG_State {
namespace GLState { namespace GLState {
// TextureObjectBase implementations // TextureObjectBase implementations
TextureObjectBase::TextureObjectBase(TextureTarget target) : m_target(target), m_sampler(nullptr) {} TextureObjectBase::TextureObjectBase(TextureTarget target) : m_target(target) {
m_sampler = MakeShared<SamplerObject>();
}
void TextureObjectBase::SetMipmapLevel(const MipmapLevelInput& level) { void TextureObjectBase::SetMipmapLevel(const MipmapLevelInput& level) {
SetMipmapImpl(level); SetMipmapImpl(level);
@@ -38,14 +40,18 @@ namespace MobileGL {
if (m_internalFormat == TextureInternalFormat::Unknown) { if (m_internalFormat == TextureInternalFormat::Unknown) {
return false; return false;
} }
if (m_mipmaps.empty()) { if (m_mipmaps.empty()) {
return false; return false;
} }
for (const auto& level : m_mipmaps) {
for (size_t i = 0; i < m_mipmaps.size(); ++i) {
const auto& level = m_mipmaps[i];
if (level.size.x() <= 0 || level.size.y() <= 0 || level.size.z() <= 0) { if (level.size.x() <= 0 || level.size.y() <= 0 || level.size.z() <= 0) {
return false; return false;
} }
} }
// TODO: add more completeness checks based on texture type and mipmap levels // TODO: add more completeness checks based on texture type and mipmap levels
return true; return true;
} }
@@ -1,8 +1,7 @@
#pragma once #pragma once
#include "SamplerObject.h"
#include <Includes.h> #include <Includes.h>
#include <MG_Util/Math/VectorTypes.h> #include <MG_Util/Math/VectorTypes.h>
#include "MG_Util/Types.h"
#include "SamplerObject.h"
namespace MobileGL { namespace MobileGL {
enum class TextureTarget { enum class TextureTarget {
@@ -197,6 +196,7 @@ namespace MobileGL {
} }
}; };
// TODO: BaseLevel, MaxLevel, Swizzle
class ITextureObject { class ITextureObject {
public: public:
using TargetEnum = TextureTarget; using TargetEnum = TextureTarget;
@@ -863,21 +863,45 @@ namespace MobileGL {
if (libEGL != NULL) { \ if (libEGL != NULL) { \
MG_External::EGL::name = (MG_External::EGL::name##_PTR)ProcAddress(libEGL, #name); \ MG_External::EGL::name = (MG_External::EGL::name##_PTR)ProcAddress(libEGL, #name); \
} }
void InitEGL() { void InitEGL() {
INIT_EGL_FUNC(eglGetProcAddress)
INIT_EGL_FUNC(eglBindAPI) INIT_EGL_FUNC(eglBindAPI)
INIT_EGL_FUNC(eglInitialize) INIT_EGL_FUNC(eglBindTexImage)
INIT_EGL_FUNC(eglGetDisplay)
INIT_EGL_FUNC(eglCreatePbufferSurface)
INIT_EGL_FUNC(eglDestroySurface)
INIT_EGL_FUNC(eglDestroyContext)
INIT_EGL_FUNC(eglMakeCurrent)
INIT_EGL_FUNC(eglChooseConfig) INIT_EGL_FUNC(eglChooseConfig)
INIT_EGL_FUNC(eglCopyBuffers)
INIT_EGL_FUNC(eglCreateContext) INIT_EGL_FUNC(eglCreateContext)
INIT_EGL_FUNC(eglQueryString) INIT_EGL_FUNC(eglCreatePbufferFromClientBuffer)
INIT_EGL_FUNC(eglTerminate) INIT_EGL_FUNC(eglCreatePbufferSurface)
INIT_EGL_FUNC(eglCreatePixmapSurface)
INIT_EGL_FUNC(eglCreatePlatformWindowSurface)
INIT_EGL_FUNC(eglCreateWindowSurface)
INIT_EGL_FUNC(eglDestroyContext)
INIT_EGL_FUNC(eglDestroySurface)
INIT_EGL_FUNC(eglGetConfigAttrib)
INIT_EGL_FUNC(eglGetConfigs)
INIT_EGL_FUNC(eglGetCurrentContext)
INIT_EGL_FUNC(eglGetCurrentDisplay)
INIT_EGL_FUNC(eglGetCurrentSurface)
INIT_EGL_FUNC(eglGetDisplay)
INIT_EGL_FUNC(eglGetPlatformDisplay)
INIT_EGL_FUNC(eglGetError) INIT_EGL_FUNC(eglGetError)
INIT_EGL_FUNC(eglGetProcAddress)
INIT_EGL_FUNC(eglInitialize)
INIT_EGL_FUNC(eglMakeCurrent)
INIT_EGL_FUNC(eglQueryAPI)
INIT_EGL_FUNC(eglQueryContext)
INIT_EGL_FUNC(eglQueryString)
INIT_EGL_FUNC(eglQuerySurface)
INIT_EGL_FUNC(eglReleaseTexImage)
INIT_EGL_FUNC(eglReleaseThread)
INIT_EGL_FUNC(eglSurfaceAttrib)
INIT_EGL_FUNC(eglSwapBuffers)
INIT_EGL_FUNC(eglSwapBuffersWithDamageEXT)
INIT_EGL_FUNC(eglSwapInterval)
INIT_EGL_FUNC(eglTerminate)
INIT_EGL_FUNC(eglUnlockSurfaceKHR)
INIT_EGL_FUNC(eglWaitClient)
INIT_EGL_FUNC(eglWaitGL)
INIT_EGL_FUNC(eglWaitNative)
EGLint configAttribs[] = {EGL_RED_SIZE, EGLint configAttribs[] = {EGL_RED_SIZE,
8, 8,
@@ -26,8 +26,6 @@ namespace MobileGL {
return FramebufferAttachmentType::Depth; return FramebufferAttachmentType::Depth;
case GL_STENCIL_ATTACHMENT: case GL_STENCIL_ATTACHMENT:
return FramebufferAttachmentType::Stencil; return FramebufferAttachmentType::Stencil;
case GL_DEPTH_STENCIL_ATTACHMENT:
return FramebufferAttachmentType::DepthStencil;
case GL_UNKNOWN_MGL: case GL_UNKNOWN_MGL:
default: default:
return FramebufferAttachmentType::Unknown; return FramebufferAttachmentType::Unknown;
@@ -305,5 +305,76 @@ namespace MobileGL {
} }
} }
SamplerFilterMode ConvertGLEnumToSamplerFilterMode(GLenum v) {
switch (v) {
case GL_NEAREST:
return SamplerFilterMode::Nearest;
case GL_LINEAR:
return SamplerFilterMode::Linear;
default:
return SamplerFilterMode::Unknown;
}
}
SamplerMipmapMode ConvertGLEnumToSamplerMipmapMode(GLenum v) {
switch (v) {
case 0:
return SamplerMipmapMode::None; // 无 mipmap 时
case GL_NEAREST_MIPMAP_NEAREST:
return SamplerMipmapMode::Nearest;
default:
return SamplerMipmapMode::Unknown;
}
}
SamplerWrapMode ConvertGLEnumToSamplerWrapMode(GLenum v) {
switch (v) {
case GL_CLAMP_TO_EDGE:
return SamplerWrapMode::ClampToEdge;
case GL_MIRRORED_REPEAT:
return SamplerWrapMode::MirroredRepeat;
case GL_REPEAT:
return SamplerWrapMode::Repeat;
case GL_CLAMP_TO_BORDER:
return SamplerWrapMode::ClampToBorder;
default:
return SamplerWrapMode::Unknown;
}
}
SamplerCompareMode ConvertGLEnumToSamplerCompareMode(GLenum v) {
switch (v) {
case 0:
return SamplerCompareMode::None; // 无 compare
case GL_COMPARE_REF_TO_TEXTURE:
return SamplerCompareMode::CompareToTexture;
default:
return SamplerCompareMode::Unknown;
}
}
SamplerCompareFunc ConvertGLEnumToSamplerCompareFunc(GLenum v) {
switch (v) {
case GL_NEVER:
return SamplerCompareFunc::Never;
case GL_LESS:
return SamplerCompareFunc::Less;
case GL_EQUAL:
return SamplerCompareFunc::Equal;
case GL_LEQUAL:
return SamplerCompareFunc::LessEqual;
case GL_GREATER:
return SamplerCompareFunc::Greater;
case GL_NOTEQUAL:
return SamplerCompareFunc::NotEqual;
case GL_GEQUAL:
return SamplerCompareFunc::GreaterEqual;
case GL_ALWAYS:
return SamplerCompareFunc::Always;
default:
return SamplerCompareFunc::Unknown;
}
}
} // namespace MG_Util } // namespace MG_Util
} // namespace MobileGL } // namespace MobileGL
@@ -9,5 +9,10 @@ namespace MobileGL {
TextureInternalFormat ConvertGLEnumToTextureInternalFormat(GLenum internalformat); TextureInternalFormat ConvertGLEnumToTextureInternalFormat(GLenum internalformat);
TexturePixelDataType ConvertGLEnumToTexturePixelDataType(GLenum type); TexturePixelDataType ConvertGLEnumToTexturePixelDataType(GLenum type);
TextureUploadTarget ConvertGLEnumToTextureUploadTarget(GLenum target); TextureUploadTarget ConvertGLEnumToTextureUploadTarget(GLenum target);
SamplerFilterMode ConvertGLEnumToSamplerFilterMode(GLenum value);
SamplerMipmapMode ConvertGLEnumToSamplerMipmapMode(GLenum value);
SamplerWrapMode ConvertGLEnumToSamplerWrapMode(GLenum value);
SamplerCompareMode ConvertGLEnumToSamplerCompareMode(GLenum value);
SamplerCompareFunc ConvertGLEnumToSamplerCompareFunc(GLenum value);
} // namespace MG_Util } // namespace MG_Util
} // namespace MobileGL } // namespace MobileGL
@@ -25,8 +25,6 @@ namespace MobileGL {
return GL_DEPTH_ATTACHMENT; return GL_DEPTH_ATTACHMENT;
case FramebufferAttachmentType::Stencil: case FramebufferAttachmentType::Stencil:
return GL_STENCIL_ATTACHMENT; return GL_STENCIL_ATTACHMENT;
case FramebufferAttachmentType::DepthStencil:
return GL_DEPTH_STENCIL_ATTACHMENT;
default: default:
return GL_COLOR_ATTACHMENT0; return GL_COLOR_ATTACHMENT0;
} }
@@ -305,5 +305,76 @@ namespace MobileGL {
} }
} }
GLenum ConvertSamplerFilterModeToGLEnum(SamplerFilterMode v) {
switch (v) {
case SamplerFilterMode::Nearest:
return GL_NEAREST;
case SamplerFilterMode::Linear:
return GL_LINEAR;
default:
return 0;
}
}
GLenum ConvertSamplerMipmapModeToGLEnum(SamplerMipmapMode v) {
switch (v) {
case SamplerMipmapMode::None:
return 0;
case SamplerMipmapMode::Nearest:
return GL_NEAREST_MIPMAP_NEAREST;
default:
return 0;
}
}
GLenum ConvertSamplerWrapModeToGLEnum(SamplerWrapMode v) {
switch (v) {
case SamplerWrapMode::ClampToEdge:
return GL_CLAMP_TO_EDGE;
case SamplerWrapMode::MirroredRepeat:
return GL_MIRRORED_REPEAT;
case SamplerWrapMode::Repeat:
return GL_REPEAT;
case SamplerWrapMode::ClampToBorder:
return GL_CLAMP_TO_BORDER;
default:
return 0;
}
}
GLenum ConvertSamplerCompareModeToGLEnum(SamplerCompareMode v) {
switch (v) {
case SamplerCompareMode::None:
return 0;
case SamplerCompareMode::CompareToTexture:
return GL_COMPARE_REF_TO_TEXTURE;
default:
return 0;
}
}
GLenum ConvertSamplerCompareFuncToGLEnum(SamplerCompareFunc v) {
switch (v) {
case SamplerCompareFunc::Never:
return GL_NEVER;
case SamplerCompareFunc::Less:
return GL_LESS;
case SamplerCompareFunc::Equal:
return GL_EQUAL;
case SamplerCompareFunc::LessEqual:
return GL_LEQUAL;
case SamplerCompareFunc::Greater:
return GL_GREATER;
case SamplerCompareFunc::NotEqual:
return GL_NOTEQUAL;
case SamplerCompareFunc::GreaterEqual:
return GL_GEQUAL;
case SamplerCompareFunc::Always:
return GL_ALWAYS;
default:
return 0;
}
}
} // namespace MG_Util } // namespace MG_Util
} // namespace MobileGL } // namespace MobileGL
@@ -9,5 +9,10 @@ namespace MobileGL {
GLenum ConvertTextureInternalFormatToGLEnum(TextureInternalFormat internalformat); GLenum ConvertTextureInternalFormatToGLEnum(TextureInternalFormat internalformat);
GLenum ConvertTexturePixelDataTypeToGLEnum(TexturePixelDataType type); GLenum ConvertTexturePixelDataTypeToGLEnum(TexturePixelDataType type);
GLenum ConvertTextureUploadTargetToGLEnum(TextureUploadTarget target); GLenum ConvertTextureUploadTargetToGLEnum(TextureUploadTarget target);
GLenum ConvertSamplerFilterModeToGLEnum(SamplerFilterMode value);
GLenum ConvertSamplerMipmapModeToGLEnum(SamplerMipmapMode value);
GLenum ConvertSamplerWrapModeToGLEnum(SamplerWrapMode value);
GLenum ConvertSamplerCompareModeToGLEnum(SamplerCompareMode value);
GLenum ConvertSamplerCompareFuncToGLEnum(SamplerCompareFunc value);
} // namespace MG_Util } // namespace MG_Util
} // namespace MobileGL } // namespace MobileGL
@@ -25,8 +25,6 @@ namespace MobileGL {
return "Depth"; return "Depth";
case FramebufferAttachmentType::Stencil: case FramebufferAttachmentType::Stencil:
return "Stencil"; return "Stencil";
case FramebufferAttachmentType::DepthStencil:
return "DepthStencil";
case FramebufferAttachmentType::Unknown: case FramebufferAttachmentType::Unknown:
default: default:
return "Unknown"; return "Unknown";
@@ -300,5 +300,76 @@ namespace MobileGL {
return "Unknown"; return "Unknown";
} }
} }
String ConvertSamplerFilterModeToString(SamplerFilterMode v) {
switch (v) {
case SamplerFilterMode::Nearest:
return "Nearest";
case SamplerFilterMode::Linear:
return "Linear";
default:
return "Unknown";
}
}
String ConvertSamplerMipmapModeToString(SamplerMipmapMode v) {
switch (v) {
case SamplerMipmapMode::None:
return "None";
case SamplerMipmapMode::Nearest:
return "Nearest";
default:
return "Unknown";
}
}
String ConvertSamplerWrapModeToString(SamplerWrapMode v) {
switch (v) {
case SamplerWrapMode::ClampToEdge:
return "ClampToEdge";
case SamplerWrapMode::MirroredRepeat:
return "MirroredRepeat";
case SamplerWrapMode::Repeat:
return "Repeat";
case SamplerWrapMode::ClampToBorder:
return "ClampToBorder";
default:
return "Unknown";
}
}
String ConvertSamplerCompareModeToString(SamplerCompareMode v) {
switch (v) {
case SamplerCompareMode::None:
return "None";
case SamplerCompareMode::CompareToTexture:
return "CompareToTexture";
default:
return "Unknown";
}
}
String ConvertSamplerCompareFuncToString(SamplerCompareFunc v) {
switch (v) {
case SamplerCompareFunc::Never:
return "Never";
case SamplerCompareFunc::Less:
return "Less";
case SamplerCompareFunc::Equal:
return "Equal";
case SamplerCompareFunc::LessEqual:
return "LessEqual";
case SamplerCompareFunc::Greater:
return "Greater";
case SamplerCompareFunc::NotEqual:
return "NotEqual";
case SamplerCompareFunc::GreaterEqual:
return "GreaterEqual";
case SamplerCompareFunc::Always:
return "Always";
default:
return "Unknown";
}
}
} // namespace MG_Util } // namespace MG_Util
} // namespace MobileGL } // namespace MobileGL
@@ -9,5 +9,10 @@ namespace MobileGL {
String ConvertTextureInternalFormatToString(TextureInternalFormat internalformat); String ConvertTextureInternalFormatToString(TextureInternalFormat internalformat);
String ConvertTexturePixelDataTypeToString(TexturePixelDataType type); String ConvertTexturePixelDataTypeToString(TexturePixelDataType type);
String ConvertTextureUploadTargetToString(TextureUploadTarget target); String ConvertTextureUploadTargetToString(TextureUploadTarget target);
String ConvertSamplerFilterModeToString(SamplerFilterMode value);
String ConvertSamplerMipmapModeToString(SamplerMipmapMode value);
String ConvertSamplerWrapModeToString(SamplerWrapMode value);
String ConvertSamplerCompareModeToString(SamplerCompareMode value);
String ConvertSamplerCompareFuncToString(SamplerCompareFunc value);
} // namespace MG_Util } // namespace MG_Util
} // namespace MobileGL } // namespace MobileGL
+22 -1
View File
@@ -61,6 +61,28 @@ namespace MobileGL {
m_active_count--; m_active_count--;
} }
bool Insert(IndexType index) noexcept {
if (IsValid(index)) return false;
if (index >= m_valid_bits.size()) {
m_valid_bits.resize(index + 1, false);
}
auto it = std::find(m_free_list.begin(), m_free_list.end(), index);
if (it != m_free_list.end()) {
m_free_list.erase(it);
}
m_valid_bits[index] = true;
m_active_count++;
if (index >= m_next_index) {
m_next_index = index + 1;
}
return true;
}
bool IsValid(IndexType index) const noexcept { return index < m_valid_bits.size() && m_valid_bits[index]; } bool IsValid(IndexType index) const noexcept { return index < m_valid_bits.size() && m_valid_bits[index]; }
SizeT FreeListSize() const noexcept { return m_free_list.size(); } SizeT FreeListSize() const noexcept { return m_free_list.size(); }
@@ -74,5 +96,4 @@ namespace MobileGL {
std::vector<IndexType> m_free_list; std::vector<IndexType> m_free_list;
std::vector<bool> m_valid_bits; std::vector<bool> m_valid_bits;
}; };
} // namespace MobileGL } // namespace MobileGL
@@ -132,7 +132,7 @@ namespace MobileGL {
tshader->setStrings(src, 1); tshader->setStrings(src, 1);
tshader->setInvertY(true); tshader->setInvertY(true);
if (attrib.flags & ShaderCompileBits::CompileForOpenGL) { if (attrib.flags & ShaderCompileBits::CompileForOpenGL) {
tshader->setEnvInput(glslang::EShSourceGlsl, lang, glslang::EShClientOpenGL, 450); tshader->setEnvInput(glslang::EShSourceGlsl, lang, glslang::EShClientVulkan, 450);
tshader->setEnvClient(glslang::EShClientOpenGL, glslang::EShTargetOpenGL_450); tshader->setEnvClient(glslang::EShClientOpenGL, glslang::EShTargetOpenGL_450);
tshader->setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_5); tshader->setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_5);
} else { } else {