]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_backend.c
reworked cl.viewangles bounding of roll angle, and simplified pitch
[xonotic/darkplaces.git] / gl_backend.c
index 7daeff35e9586ac7b3a78735ed514eac55bb8b8a..fefdf7f3db32fa883290f9ca0508a9d607e187ac 100644 (file)
@@ -165,7 +165,6 @@ memexpandablearray_t gl_bufferobjectinfoarray;
 
 static void gl_backend_start(void)
 {
-       Con_Print("OpenGL Backend starting...\n");
        CHECKGLERROR
 
        if (qglDrawRangeElements != NULL)
@@ -175,7 +174,7 @@ static void gl_backend_start(void)
                CHECKGLERROR
                qglGetIntegerv(GL_MAX_ELEMENTS_INDICES, &gl_maxdrawrangeelementsindices);
                CHECKGLERROR
-               Con_Printf("glDrawRangeElements detected (max vertices %i, max indices %i)\n", gl_maxdrawrangeelementsvertices, gl_maxdrawrangeelementsindices);
+               Con_DPrintf("GL_MAX_ELEMENTS_VERTICES = %i\nGL_MAX_ELEMENTS_INDICES = %i\n", gl_maxdrawrangeelementsvertices, gl_maxdrawrangeelementsindices);
        }
 
        backendunits = bound(1, gl_textureunits, MAX_TEXTUREUNITS);
@@ -188,20 +187,18 @@ static void gl_backend_start(void)
                CHECKGLERROR
                qglGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, (int *)&backendarrayunits);
                CHECKGLERROR
-               Con_Printf("GLSL shader support detected: texture units = %i texenv, %i image, %i array\n", backendunits, backendimageunits, backendarrayunits);
+               Con_DPrintf("GLSL shader support detected: texture units = %i texenv, %i image, %i array\n", backendunits, backendimageunits, backendarrayunits);
                backendimageunits = bound(1, backendimageunits, MAX_TEXTUREUNITS);
                backendarrayunits = bound(1, backendarrayunits, MAX_TEXTUREUNITS);
        }
-       else if (backendunits > 1)
-               Con_Printf("multitexture detected: texture units = %i\n", backendunits);
        else
-               Con_Printf("singletexture\n");
+               Con_DPrintf("GL_MAX_TEXTUREUNITS = %i\n", backendunits);
 
        GL_Backend_AllocArrays();
 
        Mem_ExpandableArray_NewArray(&gl_bufferobjectinfoarray, r_main_mempool, sizeof(gl_bufferobjectinfo_t), 128);
 
-       Con_Printf("OpenGL backend started.\n");
+       Con_DPrintf("OpenGL backend started.\n");
 
        CHECKGLERROR
 
@@ -215,7 +212,7 @@ static void gl_backend_shutdown(void)
        backendarrayunits = 0;
        backendactive = false;
 
-       Con_Print("OpenGL Backend shutting down\n");
+       Con_DPrint("OpenGL Backend shutting down\n");
 
        Mem_ExpandableArray_FreeArray(&gl_bufferobjectinfoarray);
 
@@ -265,7 +262,7 @@ void gl_backend_init(void)
        Cvar_RegisterVariable(&gl_mesh_testarrayelement);
        Cvar_RegisterVariable(&gl_mesh_testmanualfeeding);
 
-       Cmd_AddCommand("gl_vbostats", GL_VBOStats_f, "prints a list of all buffer objects (vertex data and triangle elements) and total video memory used by them\n");
+       Cmd_AddCommand("gl_vbostats", GL_VBOStats_f, "prints a list of all buffer objects (vertex data and triangle elements) and total video memory used by them");
 
        R_RegisterModule("GL_Backend", gl_backend_start, gl_backend_shutdown, gl_backend_newmap);
 }
@@ -299,7 +296,11 @@ void GL_SetupView_Orientation_FromEntity(const matrix4x4_t *matrix)
        //Matrix4x4_ConcatRotate(&backend_viewmatrix, -angles[0], 0, 1, 0);
        //Matrix4x4_ConcatRotate(&backend_viewmatrix, -angles[1], 0, 0, 1);
        //Matrix4x4_ConcatTranslate(&backend_viewmatrix, -origin[0], -origin[1], -origin[2]);
+
+       // force an update of the model matrix by copying it off, resetting it, and then calling the R_Mesh_Matrix function with it
+       tempmatrix = backend_modelmatrix;
        memset(&backend_modelmatrix, 0, sizeof(backend_modelmatrix));
+       R_Mesh_Matrix(&tempmatrix);
 }
 
 void GL_SetupView_Mode_Perspective (double frustumx, double frustumy, double zNear, double zFar)
@@ -903,9 +904,9 @@ void GL_TransformToScreen(const vec4_t in, vec4_t out)
        Matrix4x4_Transform4 (&backend_viewmatrix, in, temp);
        Matrix4x4_Transform4 (&backend_projectmatrix, temp, out);
        iw = 1.0f / out[3];
-       out[0] = r_view.x + (out[0] * iw + 1.0f) * r_view.width * 0.5f;
-       out[1] = r_view.y + r_view.height - (out[1] * iw + 1.0f) * r_view.height * 0.5f;
-       out[2] = r_view.z + (out[2] * iw + 1.0f) * r_view.depth * 0.5f;
+       out[0] = r_refdef.view.x + (out[0] * iw + 1.0f) * r_refdef.view.width * 0.5f;
+       out[1] = r_refdef.view.y + r_refdef.view.height - (out[1] * iw + 1.0f) * r_refdef.view.height * 0.5f;
+       out[2] = r_refdef.view.z + (out[2] * iw + 1.0f) * r_refdef.view.depth * 0.5f;
 }
 
 // called at beginning of frame
@@ -933,8 +934,15 @@ qboolean GL_Backend_CompileShader(int programobject, GLenum shadertypeenum, cons
        qglCompileShaderARB(shaderobject);CHECKGLERROR
        qglGetObjectParameterivARB(shaderobject, GL_OBJECT_COMPILE_STATUS_ARB, &shadercompiled);CHECKGLERROR
        qglGetInfoLogARB(shaderobject, sizeof(compilelog), NULL, compilelog);CHECKGLERROR
-       if (compilelog[0])
-               Con_DPrintf("%s shader compile log:\n%s\n", shadertype, compilelog);
+       if (compilelog[0] && developer.integer > 0)
+       {
+               int i, j, pretextlines = 0;
+               for (i = 0;i < numstrings - 1;i++)
+                       for (j = 0;strings[i][j];j++)
+                               if (strings[i][j] == '\n')
+                                       pretextlines++;
+               Con_DPrintf("%s shader compile log:\n%s\n(line offset for any above warnings/errors: %i)\n", shadertype, compilelog, pretextlines);
+       }
        if (!shadercompiled)
        {
                qglDeleteObjectARB(shaderobject);CHECKGLERROR
@@ -1021,7 +1029,7 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int numtriangles, const int *
                Con_Printf("R_Mesh_Draw(%d, %d, %d, %8p, %i, %p);\n", firstvertex, numvertices, numtriangles, elements, bufferobject, (void *)bufferoffset);
                return;
        }
-       if (!gl_vbo.integer)
+       if (gl_vbo.integer != 1)
                bufferobject = 0;
        CHECKGLERROR
        r_refdef.stats.meshes++;