]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - vid_shared.c
-width and -height can now be used alone (instead of having to use both) for better...
[xonotic/darkplaces.git] / vid_shared.c
index a65d5a72f3ea3890e5c92479dc4cf7abbd511221..89bfdfac6f9d36b4db366b0c21c32202c3733f10 100644 (file)
@@ -179,11 +179,14 @@ void (GLAPIENTRY *qglTexImage3D)(GLenum target, GLint level, GLenum internalForm
 void (GLAPIENTRY *qglTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
 void (GLAPIENTRY *qglCopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
 
+void (GLAPIENTRY *qglScissor)(GLint x, GLint y, GLsizei width, GLsizei height);
 
-int GL_CheckExtension(const char *name, const gl_extensionfunctionlist_t *funcs, const char *disableparm, int silent)
+void (GLAPIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units);
+
+int GL_CheckExtension(const char *name, const dllfunction_t *funcs, const char *disableparm, int silent)
 {
        int failed = false;
-       const gl_extensionfunctionlist_t *func;
+       const dllfunction_t *func;
 
        Con_Printf("checking for %s...  ", name);
 
@@ -221,7 +224,7 @@ int GL_CheckExtension(const char *name, const gl_extensionfunctionlist_t *funcs,
        }
 }
 
-static gl_extensionfunctionlist_t opengl110funcs[] =
+static dllfunction_t opengl110funcs[] =
 {
        {"glClearColor", (void **) &qglClearColor},
        {"glClear", (void **) &qglClear},
@@ -303,22 +306,24 @@ static gl_extensionfunctionlist_t opengl110funcs[] =
        {"glCopyTexImage2D", (void **) &qglCopyTexImage2D},
        {"glCopyTexSubImage1D", (void **) &qglCopyTexSubImage1D},
        {"glCopyTexSubImage2D", (void **) &qglCopyTexSubImage2D},
+       {"glScissor", (void **) &qglScissor},
+       {"glPolygonOffset", (void **) &qglPolygonOffset},
        {NULL, NULL}
 };
 
-static gl_extensionfunctionlist_t drawrangeelementsfuncs[] =
+static dllfunction_t drawrangeelementsfuncs[] =
 {
        {"glDrawRangeElements", (void **) &qglDrawRangeElements},
        {NULL, NULL}
 };
 
-static gl_extensionfunctionlist_t drawrangeelementsextfuncs[] =
+static dllfunction_t drawrangeelementsextfuncs[] =
 {
        {"glDrawRangeElementsEXT", (void **) &qglDrawRangeElementsEXT},
        {NULL, NULL}
 };
 
-static gl_extensionfunctionlist_t multitexturefuncs[] =
+static dllfunction_t multitexturefuncs[] =
 {
        {"glMultiTexCoord2fARB", (void **) &qglMultiTexCoord2f},
        {"glActiveTextureARB", (void **) &qglActiveTexture},
@@ -326,14 +331,14 @@ static gl_extensionfunctionlist_t multitexturefuncs[] =
        {NULL, NULL}
 };
 
-static gl_extensionfunctionlist_t compiledvertexarrayfuncs[] =
+static dllfunction_t compiledvertexarrayfuncs[] =
 {
        {"glLockArraysEXT", (void **) &qglLockArraysEXT},
        {"glUnlockArraysEXT", (void **) &qglUnlockArraysEXT},
        {NULL, NULL}
 };
 
-static gl_extensionfunctionlist_t texture3dextfuncs[] =
+static dllfunction_t texture3dextfuncs[] =
 {
        {"glTexImage3DEXT", (void **) &qglTexImage3D},
        {"glTexSubImage3DEXT", (void **) &qglTexSubImage3D},
@@ -515,7 +520,7 @@ void VID_Restart_f(void)
 int vid_commandlinecheck = true;
 void VID_Open(void)
 {
-       int i;
+       int i, width, height;
        if (vid_commandlinecheck)
        {
                // interpret command-line parameters
@@ -524,10 +529,20 @@ void VID_Open(void)
                        Cvar_SetValueQuick(&vid_fullscreen, false);
                if ((i = COM_CheckParm("-fullscreen")) != 0)
                        Cvar_SetValueQuick(&vid_fullscreen, true);
+               width = 0;
+               height = 0;
                if ((i = COM_CheckParm("-width")) != 0)
-                       Cvar_SetQuick(&vid_width, com_argv[i+1]);
+                       width = atoi(com_argv[i+1]);
                if ((i = COM_CheckParm("-height")) != 0)
-                       Cvar_SetQuick(&vid_height, com_argv[i+1]);
+                       height = atoi(com_argv[i+1]);
+               if (width == 0)
+                       width = height * 4 / 3;
+               if (height == 0)
+                       height = width * 3 / 4;
+               if (width)
+                       Cvar_SetValueQuick(&vid_width, width);
+               if (height)
+                       Cvar_SetValueQuick(&vid_height, height);
                if ((i = COM_CheckParm("-bpp")) != 0)
                        Cvar_SetQuick(&vid_bitsperpixel, com_argv[i+1]);
                if ((i = COM_CheckParm("-nostencil")) != 0)
@@ -536,6 +551,12 @@ void VID_Open(void)
                        Cvar_SetValueQuick(&vid_stencil, 1);
        }
 
+       if (vid_stencil.integer && vid_bitsperpixel.integer != 32)
+       {
+               Con_Printf("vid_stencil not allowed without vid_bitsperpixel 32, turning off vid_stencil\n");
+               Cvar_SetValueQuick(&vid_stencil, 0);
+       }
+
        Con_Printf("Starting video system\n");
        if (!VID_Mode(vid_fullscreen.integer, vid_width.integer, vid_height.integer, vid_bitsperpixel.integer, vid_stencil.integer))
        {