diff --git a/src/gl/gl3device.cpp b/src/gl/gl3device.cpp index e94f6da..521ba40 100644 --- a/src/gl/gl3device.cpp +++ b/src/gl/gl3device.cpp @@ -1571,7 +1571,7 @@ startSDL2(void) } ctx = SDL_GL_CreateContext(win); - if (!gladLoadGLLoader((GLADloadproc) SDL_GL_GetProcAddress)){ + if (!((gl3Caps.gles ? gladLoadGLES2Loader : gladLoadGLLoader) ((GLADloadproc) SDL_GL_GetProcAddress, gl3Caps.glversion)) ) { RWERROR((ERR_GENERAL, "gladLoadGLLoader failed")); SDL_GL_DeleteContext(ctx); SDL_DestroyWindow(win); @@ -1734,7 +1734,7 @@ startGLFW(void) glfwMakeContextCurrent(win); /* Init GLAD */ - if(!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)) { + if (!((gl3Caps.gles ? gladLoadGLES2Loader : gladLoadGLLoader) ((GLADloadproc) glfwGetProcAddress, gl3Caps.glversion)) ) { RWERROR((ERR_GENERAL, "gladLoadGLLoader failed")); glfwDestroyWindow(win); return 0; diff --git a/src/gl/glad/glad.c b/src/gl/glad/glad.c index 5a3ccfa..8c45495 100644 --- a/src/gl/glad/glad.c +++ b/src/gl/glad/glad.c @@ -1,12 +1,13 @@ /* - OpenGL, OpenGL ES loader generated by glad 0.1.34 on Sun Jan 31 12:38:28 2021. + OpenGL, OpenGL ES loader generated by glad 0.1.34 on Wed Feb 17 01:38:43 2021. Language/Generator: C/C++ Specification: gl APIs: gl=3.3, gles2=3.1 Profile: core Extensions: + GL_EXT_framebuffer_object, GL_EXT_texture_compression_s3tc, GL_EXT_texture_filter_anisotropic, GL_KHR_texture_compression_astc_ldr @@ -16,9 +17,9 @@ Reproducible: False Commandline: - --profile="core" --api="gl=3.3,gles2=3.1" --generator="c" --spec="gl" --no-loader --extensions="GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_KHR_texture_compression_astc_ldr" + --profile="core" --api="gl=3.3,gles2=3.1" --generator="c" --spec="gl" --no-loader --extensions="GL_EXT_framebuffer_object,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_KHR_texture_compression_astc_ldr" Online: - https://glad.dav1d.de/#profile=core&language=c&specification=gl&api=gl%3D3.3&api=gles2%3D3.1&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_KHR_texture_compression_astc_ldr + https://glad.dav1d.de/#profile=core&language=c&specification=gl&api=gl%3D3.3&api=gles2%3D3.1&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_KHR_texture_compression_astc_ldr */ #include @@ -28,6 +29,9 @@ struct gladGLversionStruct GLVersion = { 0, 0 }; +static int requested_major_version; +static int requested_minor_version; + #if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0) #define _GLAD_IS_SOME_NEW_VERSION 1 #endif @@ -596,6 +600,7 @@ PFNGLVERTEXP4UIPROC glad_glVertexP4ui = NULL; PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv = NULL; PFNGLVIEWPORTPROC glad_glViewport = NULL; PFNGLWAITSYNCPROC glad_glWaitSync = NULL; +int GLAD_GL_EXT_framebuffer_object = 0; int GLAD_GL_EXT_texture_compression_s3tc = 0; int GLAD_GL_EXT_texture_filter_anisotropic = 0; int GLAD_GL_KHR_texture_compression_astc_ldr = 0; @@ -1012,8 +1017,29 @@ static void load_GL_VERSION_3_3(GLADloadproc load) { glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)load("glSecondaryColorP3ui"); glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)load("glSecondaryColorP3uiv"); } +static void load_GL_EXT_framebuffer_object(GLADloadproc load) { + if(!GLAD_GL_EXT_framebuffer_object || GLAD_GL_VERSION_3_0) return; + glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbufferEXT"); + glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbufferEXT"); + glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffersEXT"); + glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffersEXT"); + glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorageEXT"); + glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameterivEXT"); + glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebufferEXT"); + glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebufferEXT"); + glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffersEXT"); + glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffersEXT"); + glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatusEXT"); + glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1DEXT"); + glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2DEXT"); + glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3DEXT"); + glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbufferEXT"); + glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameterivEXT"); + glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmapEXT"); +} static int find_extensionsGL(void) { if (!get_exts()) return 0; + GLAD_GL_EXT_framebuffer_object = has_ext("GL_EXT_framebuffer_object"); GLAD_GL_EXT_texture_compression_s3tc = has_ext("GL_EXT_texture_compression_s3tc"); GLAD_GL_EXT_texture_filter_anisotropic = has_ext("GL_EXT_texture_filter_anisotropic"); GLAD_GL_KHR_texture_compression_astc_ldr = has_ext("GL_KHR_texture_compression_astc_ldr"); @@ -1055,6 +1081,14 @@ static void find_coreGL(void) { sscanf(version, "%d.%d", &major, &minor); #endif + if(major > requested_major_version) { + major = requested_major_version; + } + + if(major == requested_major_version && minor > requested_minor_version) { + minor = requested_minor_version; + } + GLVersion.major = major; GLVersion.minor = minor; max_loaded_major = major; max_loaded_minor = minor; GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1; @@ -1075,7 +1109,9 @@ static void find_coreGL(void) { } } -int gladLoadGLLoader(GLADloadproc load) { +int gladLoadGLLoader(GLADloadproc load, int requestedVersion) { + requested_major_version = requestedVersion / 10; + requested_minor_version = requestedVersion % 10; GLVersion.major = 0; GLVersion.minor = 0; glGetString = (PFNGLGETSTRINGPROC)load("glGetString"); if(glGetString == NULL) return 0; @@ -1095,6 +1131,7 @@ int gladLoadGLLoader(GLADloadproc load) { load_GL_VERSION_3_3(load); if (!find_extensionsGL()) return 0; + load_GL_EXT_framebuffer_object(load); return GLVersion.major != 0 || GLVersion.minor != 0; } @@ -1464,6 +1501,14 @@ static void find_coreGLES2(void) { sscanf(version, "%d.%d", &major, &minor); #endif + if(major > requested_major_version) { + major = requested_major_version; + } + + if(major == requested_major_version && minor > requested_minor_version) { + minor = requested_minor_version; + } + GLVersion.major = major; GLVersion.minor = minor; max_loaded_major = major; max_loaded_minor = minor; GLAD_GL_ES_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2; @@ -1475,7 +1520,9 @@ static void find_coreGLES2(void) { } } -int gladLoadGLES2Loader(GLADloadproc load) { +int gladLoadGLES2Loader(GLADloadproc load, int requestedVersion) { + requested_major_version = requestedVersion / 10; + requested_minor_version = requestedVersion % 10; GLVersion.major = 0; GLVersion.minor = 0; glGetString = (PFNGLGETSTRINGPROC)load("glGetString"); if(glGetString == NULL) return 0; diff --git a/src/gl/glad/glad.h b/src/gl/glad/glad.h index 9f2f228..e5cc1f1 100644 --- a/src/gl/glad/glad.h +++ b/src/gl/glad/glad.h @@ -1,12 +1,13 @@ /* - OpenGL, OpenGL ES loader generated by glad 0.1.34 on Sun Jan 31 12:38:28 2021. + OpenGL, OpenGL ES loader generated by glad 0.1.34 on Wed Feb 17 01:38:43 2021. Language/Generator: C/C++ Specification: gl APIs: gl=3.3, gles2=3.1 Profile: core Extensions: + GL_EXT_framebuffer_object, GL_EXT_texture_compression_s3tc, GL_EXT_texture_filter_anisotropic, GL_KHR_texture_compression_astc_ldr @@ -16,9 +17,9 @@ Reproducible: False Commandline: - --profile="core" --api="gl=3.3,gles2=3.1" --generator="c" --spec="gl" --no-loader --extensions="GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_KHR_texture_compression_astc_ldr" + --profile="core" --api="gl=3.3,gles2=3.1" --generator="c" --spec="gl" --no-loader --extensions="GL_EXT_framebuffer_object,GL_EXT_texture_compression_s3tc,GL_EXT_texture_filter_anisotropic,GL_KHR_texture_compression_astc_ldr" Online: - https://glad.dav1d.de/#profile=core&language=c&specification=gl&api=gl%3D3.3&api=gles2%3D3.1&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_KHR_texture_compression_astc_ldr + https://glad.dav1d.de/#profile=core&language=c&specification=gl&api=gl%3D3.3&api=gles2%3D3.1&extensions=GL_EXT_framebuffer_object&extensions=GL_EXT_texture_compression_s3tc&extensions=GL_EXT_texture_filter_anisotropic&extensions=GL_KHR_texture_compression_astc_ldr */ @@ -93,9 +94,9 @@ typedef void* (* GLADloadproc)(const char *name); #endif GLAPI struct gladGLversionStruct GLVersion; -GLAPI int gladLoadGLLoader(GLADloadproc); +GLAPI int gladLoadGLLoader(GLADloadproc, int requestedVersion); -GLAPI int gladLoadGLES2Loader(GLADloadproc); +GLAPI int gladLoadGLES2Loader(GLADloadproc, int requestedVersion); #include "khrplatform.h" typedef unsigned int GLenum; @@ -2615,6 +2616,10 @@ GLAPI PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor; #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC #define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +GLAPI int GLAD_GL_EXT_framebuffer_object; +#endif #ifndef GL_EXT_texture_compression_s3tc #define GL_EXT_texture_compression_s3tc 1 GLAPI int GLAD_GL_EXT_texture_compression_s3tc;