]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_shared.c
::stable-branch::reset=c0b5a9d4a829afdee87b9ef5fc508dfff77eee4e
[xonotic/darkplaces.git] / vid_shared.c
index 0db91b50339527f38cdc54a76d3bbbcd65d9856c..8eda95e58fcf1822f99edbd788668770de54c1c2 100644 (file)
@@ -2,10 +2,6 @@
 #include "quakedef.h"
 #include "cdaudio.h"
 
-#ifdef SUPPORTCG
-#include <Cg/cgGL.h>
-#endif
-
 #ifdef SUPPORTD3D
 #include <d3d9.h>
 #ifdef _MSC_VER
@@ -69,11 +65,9 @@ cvar_t vid_minwidth = {0, "vid_minwidth", "0", "minimum vid_width that is accept
 cvar_t vid_minheight = {0, "vid_minheight", "0", "minimum vid_height that is acceptable (to be set in default.cfg in mods)"};
 cvar_t vid_gl13 = {0, "vid_gl13", "1", "enables faster rendering using OpenGL 1.3 features (such as GL_ARB_texture_env_combine extension)"};
 cvar_t vid_gl20 = {0, "vid_gl20", "1", "enables faster rendering using OpenGL 2.0 features (such as GL_ARB_fragment_shader extension)"};
-#ifdef SUPPORTCG
-cvar_t vid_cggl = {0, "vid_glcg", "1", "enables faster rendering using the Cg shader library"};
-#endif
 cvar_t gl_finish = {0, "gl_finish", "0", "make the cpu wait for the graphics processor at the end of each rendered frame (can help with strange input or video lag problems on some machines)"};
 
+cvar_t vid_touchscreen = {0, "vid_touchscreen", "0", "Use touchscreen-style input (no mouse grab, track mouse motion only while button is down, screen areas for mimicing joystick axes and buttons"};
 cvar_t vid_stick_mouse = {CVAR_SAVE, "vid_stick_mouse", "0", "have the mouse stuck in the center of the screen" };
 cvar_t vid_resizable = {CVAR_SAVE, "vid_resizable", "0", "0: window not resizable, 1: resizable, 2: window can be resized but the framebuffer isn't adjusted" };
 
@@ -931,17 +925,6 @@ void VID_CheckExtensions(void)
                vid.renderpath = RENDERPATH_GL20;
                vid.useinterleavedarrays = false;
        }
-#ifdef SUPPORTCG
-       else if (vid_cggl.integer && (vid.cgcontext = cgCreateContext()))
-       {
-               vid.texunits = 4;
-               vid.teximageunits = 16;
-               vid.texarrayunits = 8;
-               Con_DPrintf("Using NVIDIA Cg rendering path - %i texture matrix, %i texture images, %i texcoords%s\n", vid.texunits, vid.teximageunits, vid.texarrayunits, vid.support.ext_framebuffer_object ? ", shadowmapping supported" : "");
-               vid.renderpath = RENDERPATH_CGGL;
-               vid.useinterleavedarrays = false;
-       }
-#endif
        else if (vid.support.arb_texture_env_combine && vid.texunits >= 2 && vid_gl13.integer)
        {
                qglGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&vid.texunits);
@@ -1051,7 +1034,6 @@ void VID_UpdateGamma(qboolean force, int rampsize)
        switch(vid.renderpath)
        {
        case RENDERPATH_GL20:
-       case RENDERPATH_CGGL:
        case RENDERPATH_D3D9:
        case RENDERPATH_D3D10:
        case RENDERPATH_D3D11:
@@ -1230,15 +1212,13 @@ void VID_Shared_Init(void)
        Cvar_RegisterVariable(&vid_vsync);
        Cvar_RegisterVariable(&vid_mouse);
        Cvar_RegisterVariable(&vid_grabkeyboard);
+       Cvar_RegisterVariable(&vid_touchscreen);
        Cvar_RegisterVariable(&vid_stick_mouse);
        Cvar_RegisterVariable(&vid_resizable);
        Cvar_RegisterVariable(&vid_minwidth);
        Cvar_RegisterVariable(&vid_minheight);
        Cvar_RegisterVariable(&vid_gl13);
        Cvar_RegisterVariable(&vid_gl20);
-#ifdef SUPPORTCG
-       Cvar_RegisterVariable(&vid_cggl);
-#endif
        Cvar_RegisterVariable(&gl_finish);
        Cmd_AddCommand("force_centerview", Force_CenterView_f, "recenters view (stops looking up/down)");
        Cmd_AddCommand("vid_restart", VID_Restart_f, "restarts video system (closes and reopens the window, restarts renderer)");
@@ -1301,6 +1281,7 @@ static void VID_CloseSystems(void)
 }
 
 qboolean vid_commandlinecheck = true;
+extern qboolean vid_opened;
 
 void VID_Restart_f(void)
 {
@@ -1308,6 +1289,12 @@ void VID_Restart_f(void)
        if (vid_commandlinecheck)
                return;
 
+       if (!vid_opened)
+       {
+               SCR_BeginLoadingPlaque();
+               return;
+       }
+
        Con_Printf("VID_Restart: changing from %s %dx%dx%dbpp%s%s, to %s %dx%dx%dbpp%s%s.\n",
                vid.mode.fullscreen ? "fullscreen" : "window", vid.mode.width, vid.mode.height, vid.mode.bitsperpixel, vid.mode.fullscreen && vid.mode.userefreshrate ? va("x%.2fhz", vid.mode.refreshrate) : "", vid.mode.samples > 1 ? va(" (%ix AA)", vid.mode.samples) : "",
                vid_fullscreen.integer ? "fullscreen" : "window", vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_fullscreen.integer && vid_userefreshrate.integer ? va("x%.2fhz", vid_refreshrate.value) : "", vid_samples.integer > 1 ? va(" (%ix AA)", vid_samples.integer) : "");
@@ -1333,7 +1320,7 @@ const char *vidfallbacks[][2] =
        {NULL, NULL}
 };
 
-// this is only called once by Host_StartVideo
+// this is only called once by Host_StartVideo and again on each FS_GameDir_f
 void VID_Start(void)
 {
        int i, width, height, success;
@@ -1383,6 +1370,12 @@ void VID_Start(void)
        VID_OpenSystems();
 }
 
+void VID_Stop(void)
+{
+       VID_CloseSystems();
+       VID_Shutdown();
+}
+
 int VID_SortModes_Compare(const void *a_, const void *b_)
 {
        vid_mode_t *a = (vid_mode_t *) a_;