]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_backend.c
Hopefully finished the core of the new ui.
[xonotic/darkplaces.git] / gl_backend.c
index c3eef34081e835296f1a08800b37a1663fa55521..730ce44b3afc676af660e1ee58767442b3fcfd21 100644 (file)
@@ -72,9 +72,6 @@ int c_meshs, c_meshelements;
 
 void SCR_ScreenShot_f (void);
 
-// these are externally accessible
-int r_lightmapscalebit;
-
 static matrix4x4_t backend_viewmatrix;
 static matrix4x4_t backend_modelmatrix;
 static matrix4x4_t backend_modelviewmatrix;
@@ -232,14 +229,17 @@ void GL_SetupView_Orientation_Identity (void)
        memset(&backend_modelmatrix, 0, sizeof(backend_modelmatrix));
 }
 
-void GL_SetupView_Orientation_FromEntity (vec3_t origin, vec3_t angles)
+void GL_SetupView_Orientation_FromEntity(matrix4x4_t *matrix)
 {
-       Matrix4x4_CreateRotate(&backend_viewmatrix, -90, 1, 0, 0);
-       Matrix4x4_ConcatRotate(&backend_viewmatrix, 90, 0, 0, 1);
-       Matrix4x4_ConcatRotate(&backend_viewmatrix, -angles[2], 1, 0, 0);
-       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]);
+       matrix4x4_t tempmatrix, basematrix;
+       Matrix4x4_Invert_Simple(&tempmatrix, matrix);
+       Matrix4x4_CreateRotate(&basematrix, -90, 1, 0, 0);
+       Matrix4x4_ConcatRotate(&basematrix, 90, 0, 0, 1);
+       Matrix4x4_Concat(&backend_viewmatrix, &basematrix, &tempmatrix);
+       //Matrix4x4_ConcatRotate(&backend_viewmatrix, -angles[2], 1, 0, 0);
+       //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]);
        memset(&backend_modelmatrix, 0, sizeof(backend_modelmatrix));
 }
 
@@ -344,6 +344,7 @@ static struct
        int blend;
        GLboolean depthmask;
        int depthtest;
+       int scissortest;
        int unit;
        int clientunit;
        gltextureunit_t units[MAX_TEXTUREUNITS];
@@ -605,6 +606,26 @@ void GL_LockArrays(int first, int count)
        }
 }
 
+void GL_Scissor (int x, int y, int width, int height)
+{
+       CHECKGLERROR
+       qglScissor(x, vid.realheight - (y + height),width,height);
+       CHECKGLERROR
+}
+
+void GL_ScissorTest(int state)
+{
+       if(gl_state.scissortest == state)
+               return;
+
+       CHECKGLERROR
+       if((gl_state.scissortest = state))
+               qglEnable(GL_SCISSOR_TEST);
+       else
+               qglDisable(GL_SCISSOR_TEST);
+       CHECKGLERROR
+}
+
 void GL_TransformToScreen(const vec4_t in, vec4_t out)
 {
        vec4_t temp;
@@ -918,7 +939,7 @@ void R_Mesh_State_Texture(const rmeshstate_t *m)
                {
                        GL_ActiveTexture(i);
                        unit->combinergb = combinergb;
-                       if (gl_combine.integer)
+                       if (gl_combine.integer) 
                        {
                                qglTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, unit->combinergb);CHECKGLERROR
                        }
@@ -982,6 +1003,19 @@ void R_Mesh_State_Texture(const rmeshstate_t *m)
        }
 }
 
+void R_Mesh_Draw_ShowTris(int numverts, int numtriangles, int *elements)
+{
+       qglBegin(GL_LINES);
+       for (;numtriangles;numtriangles--, elements += 3)
+       {
+               qglArrayElement(elements[0]);qglArrayElement(elements[1]);
+               qglArrayElement(elements[1]);qglArrayElement(elements[2]);
+               qglArrayElement(elements[2]);qglArrayElement(elements[0]);
+       }
+       qglEnd();
+       CHECKGLERROR
+}
+
 /*
 ==============================================================================
 
@@ -1066,11 +1100,6 @@ void SCR_UpdateScreen (void)
        if (gl_combine.integer && (!gl_combine_extension || r_textureunits.integer < 2))
                Cvar_SetValueQuick(&gl_combine, 0);
 
-       // lightmaps only
-       r_lightmapscalebit = 0;
-       if (gl_combine.integer && r_textureunits.integer > 1)
-               r_lightmapscalebit += 2;
-
        R_TimeReport("setup");
 
        R_ClearScreen();