]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_shared.c
Use GL3.2 Core Profile context.
[xonotic/darkplaces.git] / vid_shared.c
index 92d6eba24d339f474ae3b62c0113ca2830ac5a88..461b0ad40b6e124dce5dec41cfbb9dd45bbd6d32 100644 (file)
@@ -744,28 +744,22 @@ void GL_Setup(void)
        if (vid.support.glshaderversion < 100)
                vid.support.glshaderversion = 100;
        Con_DPrintf("Detected GLSL #version %i\n", vid.support.glshaderversion);
-       vid.support.gl20shaders130 = true;
 
+#ifdef USE_GLES2
+       // GLES devices in general do not like GL_BGRA, so use GL_RGBA
+       vid.forcetextype = TEXTYPE_RGBA;
+#else
        // GL drivers generally prefer GL_BGRA
        vid.forcetextype = GL_BGRA;
+#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);
-       vid.support.ext_texture_srgb = true;
-       vid.support.arb_texture_float = true;
-       vid.support.arb_half_float_pixel = true;
-       vid.support.arb_half_float_vertex = true;
-       vid.support.arb_multisample = true;
+#ifndef USE_GLES2
+       vid.support.ext_texture_srgb = true; // GL3 core, but not GLES2
+#endif
        vid.support.arb_debug_output = GL_CheckExtension("GL_ARB_debug_output", "-nogldebugoutput", false);
        vid.allowalphatocoverage = false;
 
@@ -775,14 +769,41 @@ 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");
+       vid.renderpath = RENDERPATH_GLES2;
+       vid.sRGBcapable2D = false;
+       vid.sRGBcapable3D = false;
+#else
+       Con_DPrint("Using GL32 rendering path\n");
        vid.renderpath = RENDERPATH_GL32;
        vid.sRGBcapable2D = false;
        vid.sRGBcapable3D = true;
@@ -797,6 +818,14 @@ void GL_Setup(void)
                else
                        vid.allowalphatocoverage = false;
        }
+#endif
+       CHECKGLERROR
+
+#ifdef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
+       if (vid.support.ext_texture_filter_anisotropic)
+               qglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, (GLint*)&vid.max_anisotropy);
+#endif
+       CHECKGLERROR
 }
 
 float VID_JoyState_GetAxis(const vid_joystate_t *joystate, int axis, float fsensitivity, float deadzone)