]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Use GL3.2 Core Profile context.
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 12 Aug 2018 22:11:32 +0000 (22:11 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 12 Aug 2018 22:11:32 +0000 (22:11 +0000)
Create and bind a vertex array object at start, since Core Profile requires it, but gains no benefit in performance from using multiple.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12457 d7cf8633-e32d-0410-b094-e92efae38249

gl_backend.c
vid.h
vid_sdl.c
vid_shared.c

index b99d654aad7a4e9a695993a646bf4c58f16108b6..34895d13730c9d396ec40fbc3a2ddc4981030239 100644 (file)
@@ -156,6 +156,9 @@ typedef struct gl_state_s
        int defaultframebufferobject; // deal with platforms that use a non-zero default fbo
        qboolean pointer_color_enabled;
 
+       // GL3.2 Core requires that we have a GL_VERTEX_ARRAY_OBJECT, but... just one.
+       unsigned int defaultvao;
+
        int pointer_vertex_components;
        int pointer_vertex_gltype;
        size_t pointer_vertex_stride;
@@ -259,17 +262,21 @@ static void gl_backend_start(void)
 
        CHECKGLERROR
 
-       GL_Backend_ResetState();
-
        switch(vid.renderpath)
        {
        case RENDERPATH_GL32:
+               // GL3.2 Core requires that we have a VAO bound - but using more than one has no performance benefit so this is just placeholder
+               qglGenVertexArrays(1, &gl_state.defaultvao);
+               qglBindVertexArray(gl_state.defaultvao);
+               // fall through
        case RENDERPATH_GLES2:
                // fetch current fbo here (default fbo is not 0 on some GLES devices)
                CHECKGLERROR
                qglGetIntegerv(GL_FRAMEBUFFER_BINDING, &gl_state.defaultframebufferobject);CHECKGLERROR
                break;
        }
+
+       GL_Backend_ResetState();
 }
 
 static void gl_backend_shutdown(void)
diff --git a/vid.h b/vid.h
index ddd7a21e04d3a069f8f5cff40f6753d768729c51..df62a5a476d86d02605f32be8a2742c1779f932f 100644 (file)
--- a/vid.h
+++ b/vid.h
@@ -39,22 +39,10 @@ typedef struct viddef_support_s
 {
        int glshaderversion; // this is at least 150 (GL 3.2)
        qboolean amd_texture_texture4;
-       qboolean arb_draw_buffers;
-       qboolean arb_occlusion_query;
-       qboolean arb_query_buffer_object;
-       qboolean arb_texture_compression;
        qboolean arb_texture_gather;
-       qboolean ext_blend_minmax;
-       qboolean ext_blend_subtract;
-       qboolean ext_blend_func_separate;
-       qboolean ext_packed_depth_stencil;
        qboolean ext_texture_compression_s3tc;
        qboolean ext_texture_filter_anisotropic;
        qboolean ext_texture_srgb;
-       qboolean arb_texture_float;
-       qboolean arb_half_float_pixel;
-       qboolean arb_half_float_vertex;
-       qboolean arb_multisample;
        qboolean arb_debug_output;
 }
 viddef_support_t;
index 2c1b204487c8bd55aea00151ac8f3391f73a1cce..248baac760cecccfade6af4180ae8ff37fb0de3a 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -1512,6 +1512,8 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode)
        SDL_GL_SetAttribute (SDL_GL_CONTEXT_MINOR_VERSION, 0);
        SDL_GL_SetAttribute (SDL_GL_RETAINED_BACKING, 1);
 #else
+       SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
+       SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, (gl_debug.integer > 0 ? SDL_GL_CONTEXT_DEBUG_FLAG : 0));
 #endif
 
index 9f4df42ecbde5b9fb922ce8d82a90a0e86f5a50e..461b0ad40b6e124dce5dec41cfbb9dd45bbd6d32 100644 (file)
@@ -754,15 +754,7 @@ void GL_Setup(void)
 #endif
 
        vid.support.amd_texture_texture4 = GL_CheckExtension("GL_AMD_texture_texture4", "-notexture4", false);
-       vid.support.arb_draw_buffers = true;
-       vid.support.arb_occlusion_query = true;
-       vid.support.arb_query_buffer_object = true;
-       vid.support.arb_texture_compression = true;
        vid.support.arb_texture_gather = GL_CheckExtension("GL_ARB_texture_gather", "-notexturegather", false);
-       vid.support.ext_blend_minmax = true;
-       vid.support.ext_blend_subtract = true;
-       vid.support.ext_blend_func_separate = true;
-       vid.support.ext_packed_depth_stencil = true;
        vid.support.ext_texture_compression_s3tc = GL_CheckExtension("GL_EXT_texture_compression_s3tc", "-nos3tc", false);
        vid.support.ext_texture_filter_anisotropic = GL_CheckExtension("GL_EXT_texture_filter_anisotropic", "-noanisotropy", false);
 #ifndef USE_GLES2
@@ -777,13 +769,33 @@ void GL_Setup(void)
 // COMMANDLINEOPTION: GL: -notexturegather disables GL_ARB_texture_gather (which provides fetch4 sampling)
 // COMMANDLINEOPTION: GL: -nogldebugoutput disables GL_ARB_debug_output (which provides the gl_debug feature, if enabled)
 
-       if (vid.support.arb_draw_buffers)
-               qglGetIntegerv(GL_MAX_DRAW_BUFFERS, (GLint*)&vid.maxdrawbuffers);
-
+#ifdef GL_MAX_DRAW_BUFFERS
+       qglGetIntegerv(GL_MAX_DRAW_BUFFERS, (GLint*)&vid.maxdrawbuffers);
+       CHECKGLERROR
+#endif
        qglGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint*)&vid.maxtexturesize_2d);
-       qglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, (GLint*)&vid.max_anisotropy);
-       qglGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, (GLint*)&vid.maxtexturesize_cubemap);
-       qglGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, (GLint*)&vid.maxtexturesize_3d);
+       CHECKGLERROR
+#ifdef GL_MAX_CUBE_MAP_TEXTURE_SIZE
+#ifdef USE_GLES2
+       if (GL_CheckExtension("GL_ARB_texture_cube_map", "-nocubemap", false))
+#endif
+       {
+               qglGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, (GLint*)&vid.maxtexturesize_cubemap);
+               Con_DPrintf("GL_MAX_CUBE_MAP_TEXTURE_SIZE = %i\n", vid.maxtexturesize_cubemap);
+       }
+       CHECKGLERROR
+#endif
+#ifdef GL_MAX_3D_TEXTURE_SIZE
+#ifdef USE_GLES2
+       if (GL_CheckExtension("GL_EXT_texture3D", "-notexture3d", false)
+        || GL_CheckExtension("GL_OES_texture3D", "-notexture3d", false))
+#endif
+       {
+               qglGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, (GLint*)&vid.maxtexturesize_3d);
+               Con_DPrintf("GL_MAX_3D_TEXTURE_SIZE = %i\n", vid.maxtexturesize_3d);
+       }
+#endif
+       CHECKGLERROR
 
 #ifdef USE_GLES2
        Con_DPrint("Using GLES2 rendering path\n");