]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_shared.c
fix a sound conversion bug in mono output
[xonotic/darkplaces.git] / vid_shared.c
index 6488195178c413a1bad4603eaab6dca52ffcff62..75c7c2cc8e381c6d7c8576516e997ac5a0a78fe3 100644 (file)
@@ -15,6 +15,10 @@ qboolean in_client_mouse = true;
 // AK where should it be placed ?
 float in_mouse_x, in_mouse_y;
 
+// value of GL_MAX_TEXTURE_<various>_SIZE
+int gl_max_texture_size = 0;
+int gl_max_3d_texture_size = 0;
+int gl_max_cube_map_texture_size = 0;
 // GL_ARB_multitexture
 int gl_textureunits = 1;
 // GL_ARB_texture_env_combine or GL_EXT_texture_env_combine
@@ -48,6 +52,8 @@ int gl_support_shading_language_100 = false;
 int gl_support_vertex_shader = false;
 // GL_ARB_fragment_shader
 int gl_support_fragment_shader = false;
+// GL_NV_half_float
+int gl_support_half_float = false;
 
 // LordHavoc: if window is hidden, don't update screen
 qboolean vid_hidden = true;
@@ -70,7 +76,7 @@ cvar_t vid_bitsperpixel = {CVAR_SAVE, "vid_bitsperpixel", "32"};
 
 cvar_t vid_vsync = {CVAR_SAVE, "vid_vsync", "0"};
 cvar_t vid_mouse = {CVAR_SAVE, "vid_mouse", "1"};
-cvar_t gl_combine = {CVAR_SAVE, "gl_combine", "1"};
+cvar_t gl_combine = {0, "gl_combine", "1"};
 cvar_t gl_finish = {0, "gl_finish", "0"};
 
 cvar_t v_gamma = {CVAR_SAVE, "v_gamma", "1"};
@@ -606,6 +612,9 @@ void VID_CheckExtensions(void)
 
        // reset all the gl extension variables here
        // this should match the declarations
+       gl_max_texture_size = 0;
+       gl_max_3d_texture_size = 0;
+       gl_max_cube_map_texture_size = 0;
        gl_textureunits = 1;
        gl_combine_extension = false;
        gl_supportslockarrays = false;
@@ -623,7 +632,7 @@ void VID_CheckExtensions(void)
        gl_support_fragment_shader = false;
 
        if (!GL_CheckExtension("OpenGL 1.1.0", opengl110funcs, NULL, false))
-               Sys_Error("OpenGL 1.1.0 functions not found\n");
+               Sys_Error("OpenGL 1.1.0 functions not found");
 
        Con_Printf("GL_VENDOR: %s\n", gl_vendor);
        Con_Printf("GL_RENDERER: %s\n", gl_renderer);
@@ -631,6 +640,8 @@ void VID_CheckExtensions(void)
        Con_Printf("GL_EXTENSIONS: %s\n", gl_extensions);
        Con_Printf("%s_EXTENSIONS: %s\n", gl_platform, gl_platformextensions);
 
+       qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_max_texture_size);
+
        Con_Print("Checking OpenGL extensions...\n");
 
 // COMMANDLINEOPTION: GL: -nodrawrangeelements disables GL_EXT_draw_range_elements (renders faster)
@@ -649,9 +660,11 @@ void VID_CheckExtensions(void)
        }
 
 // COMMANDLINEOPTION: GL: -notexture3d disables GL_EXT_texture3D (required for spherical lights, otherwise they render as a column)
-       gl_texture3d = GL_CheckExtension("GL_EXT_texture3D", texture3dextfuncs, "-notexture3d", false);
+       if ((gl_texture3d = GL_CheckExtension("GL_EXT_texture3D", texture3dextfuncs, "-notexture3d", false)))
+               qglGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &gl_max_3d_texture_size);
 // COMMANDLINEOPTION: GL: -nocubemap disables GL_ARB_texture_cube_map (required for bumpmapping)
-       gl_texturecubemap = GL_CheckExtension("GL_ARB_texture_cube_map", NULL, "-nocubemap", false);
+       if ((gl_texturecubemap = GL_CheckExtension("GL_ARB_texture_cube_map", NULL, "-nocubemap", false)))
+               qglGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &gl_max_cube_map_texture_size);
 // COMMANDLINEOPTION: GL: -nocva disables GL_EXT_compiled_vertex_array (renders faster)
        gl_supportslockarrays = GL_CheckExtension("GL_EXT_compiled_vertex_array", compiledvertexarrayfuncs, "-nocva", false);
 // COMMANDLINEOPTION: GL: -noedgeclamp disables GL_EXT_texture_edge_clamp or GL_SGIS_texture_edge_clamp (recommended, some cards do not support the other texture clamp method)
@@ -673,12 +686,15 @@ void VID_CheckExtensions(void)
 
 // COMMANDLINEOPTION: GL: -noshaderobjects disables GL_ARB_shader_objects (required for vertex shader and fragment shader)
 // COMMANDLINEOPTION: GL: -noshadinglanguage100 disables GL_ARB_shading_language_100 (required for vertex shader and fragment shader)
-// COMMANDLINEOPTION: GL: -novertexshader disables GL_ARB_vertex_shader (currently unused, allows vertex shader effects)
-// COMMANDLINEOPTION: GL: -nofragmentshader disables GL_ARB_fragment_shader (currently unused, allows pixel shader effects)
+// COMMANDLINEOPTION: GL: -novertexshader disables GL_ARB_vertex_shader (allows vertex shader effects)
+// COMMANDLINEOPTION: GL: -nofragmentshader disables GL_ARB_fragment_shader (allows pixel shader effects, can improve per pixel lighting performance and capabilities)
        if ((gl_support_shader_objects = GL_CheckExtension("GL_ARB_shader_objects", shaderobjectsfuncs, "-noshaderobjects", false)))
                if ((gl_support_shading_language_100 = GL_CheckExtension("GL_ARB_shading_language_100", NULL, "-noshadinglanguage100", false)))
                        if ((gl_support_vertex_shader = GL_CheckExtension("GL_ARB_vertex_shader", vertexshaderfuncs, "-novertexshader", false)))
                                gl_support_fragment_shader = GL_CheckExtension("GL_ARB_fragment_shader", NULL, "-nofragmentshader", false);
+
+// COMMANDLINEOPTION: GL: -nohalffloat disables GL_NV_half_float extension
+       gl_support_half_float = GL_CheckExtension("GL_NV_half_float", NULL, "-nohalffloat", false);
 }
 
 qboolean vid_vertexarrays_are_var = false;
@@ -887,19 +903,15 @@ void VID_Shared_Init(void)
                Cvar_Set("gl_combine", "0");
 }
 
-int current_vid_fullscreen;
-int current_vid_width;
-int current_vid_height;
-int current_vid_bitsperpixel;
 int VID_Mode(int fullscreen, int width, int height, int bpp)
 {
        Con_Printf("Video: %s %dx%dx%d\n", fullscreen ? "fullscreen" : "window", width, height, bpp);
        if (VID_InitMode(fullscreen, width, height, bpp))
        {
-               current_vid_fullscreen = fullscreen;
-               current_vid_width = width;
-               current_vid_height = height;
-               current_vid_bitsperpixel = bpp;
+               vid.fullscreen = fullscreen;
+               vid.width = width;
+               vid.height = height;
+               vid.bitsperpixel = bpp;
                Cvar_SetValueQuick(&vid_fullscreen, fullscreen);
                Cvar_SetValueQuick(&vid_width, width);
                Cvar_SetValueQuick(&vid_height, height);
@@ -931,15 +943,15 @@ void VID_Restart_f(void)
                return;
 
        Con_Printf("VID_Restart: changing from %s %dx%dx%dbpp, to %s %dx%dx%dbpp.\n",
-               current_vid_fullscreen ? "fullscreen" : "window", current_vid_width, current_vid_height, current_vid_bitsperpixel,
+               vid.fullscreen ? "fullscreen" : "window", vid.width, vid.height, vid.bitsperpixel,
                vid_fullscreen.integer ? "fullscreen" : "window", vid_width.integer, vid_height.integer, vid_bitsperpixel.integer);
        VID_CloseSystems();
        VID_Shutdown();
        if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer))
        {
                Con_Print("Video mode change failed\n");
-               if (!VID_Mode(current_vid_fullscreen, current_vid_width, current_vid_height, current_vid_bitsperpixel))
-                       Sys_Error("Unable to restore to last working video mode\n");
+               if (!VID_Mode(vid.fullscreen, vid.width, vid.height, vid.bitsperpixel))
+                       Sys_Error("Unable to restore to last working video mode");
        }
        VID_OpenSystems();
 }
@@ -991,7 +1003,7 @@ void VID_Start(void)
                if (!success && vid_fullscreen.integer)
                        success = VID_Mode(false, 640, 480, 16);
                if (!success)
-                       Sys_Error("Video modes failed\n");
+                       Sys_Error("Video modes failed");
        }
        VID_OpenSystems();
 }