]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
refactoring to avoid doing the same mistake again (see HEAD^)
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 5 Nov 2011 16:29:37 +0000 (16:29 +0000)
committerRudolf Polzer <divverent@xonotic.org>
Sat, 5 Nov 2011 16:35:49 +0000 (17:35 +0100)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11528 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=25f6db62e5912b5f6f377209fa9ff10a03e64a63

gl_draw.c
gl_rmain.c
render.h

index a42950748260dbf2605e88eddad76373033743e6..dc523db2590d07cc8c2ffeee330bf33155b1efd3 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -1068,37 +1068,17 @@ void GL_Draw_Init (void)
 
 static void _DrawQ_Setup(void) // see R_ResetViewRendering2D
 {
-       r_viewport_t viewport;
        if (r_refdef.draw2dstage == 1)
                return;
        r_refdef.draw2dstage = 1;
-       CHECKGLERROR
-
-       R_Viewport_InitOrtho(&viewport, &identitymatrix, r_refdef.view.x, vid.height - r_refdef.view.y - r_refdef.view.height, r_refdef.view.width, r_refdef.view.height, 0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100, NULL);
-       R_Mesh_SetRenderTargets(0, NULL, NULL, NULL, NULL, NULL);
-       R_SetViewport(&viewport);
-       //GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height); // DrawQ_SetClipArea would do this
-       GL_Color(1, 1, 1, 1);
-       GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
-       //GL_BlendFunc(GL_ONE, GL_ZERO); // DrawQ_ProcessDrawFlag does this
-       GL_ScissorTest(false);
-       GL_DepthMask(false);
-       GL_DepthRange(0, 1);
-       GL_DepthTest(false);
-       GL_DepthFunc(GL_LEQUAL);
-       R_EntityMatrix(&identitymatrix);
-       R_Mesh_ResetTextureState();
-       GL_PolygonOffset(0, 0);
-       //R_SetStencil(false, 255, GL_KEEP, GL_KEEP, GL_KEEP, GL_ALWAYS, 128, 255); // not needed
-       //qglEnable(GL_POLYGON_OFFSET_FILL); // we never use polygon offset here
-       GL_CullFace(GL_NONE);
+
+       R_ResetViewRendering2D_Common(0, NULL, NULL, vid_conwidth.integer, vid_conheight.integer);
 }
 
 qboolean r_draw2d_force = false;
 void _DrawQ_SetupAndProcessDrawFlag(int flags, cachepic_t *pic, float alpha)
 {
        _DrawQ_Setup();
-       CHECKGLERROR
        if(!r_draw2d.integer && !r_draw2d_force)
                return;
        DrawQ_ProcessDrawFlag(flags, (alpha < 1) || (pic && pic->hasalpha));
@@ -1956,7 +1936,6 @@ void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height
 void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags, qboolean hasalpha)
 {
        _DrawQ_Setup();
-       CHECKGLERROR
        if(!r_draw2d.integer && !r_draw2d_force)
                return;
        DrawQ_ProcessDrawFlag(flags, hasalpha);
index 01ecc1fc25191b569edd96bb1b3fa00f8a9e130b..e1bc4d28cf9cf6392b475e2578b19ce92df955d7 100644 (file)
@@ -5430,13 +5430,14 @@ void R_EntityMatrix(const matrix4x4_t *matrix)
        }
 }
 
-void R_ResetViewRendering2D(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture)
+void R_ResetViewRendering2D_Common(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, float x2, float y2)
 {
        r_viewport_t viewport;
-       DrawQ_Finish();
+
+       CHECKGLERROR
 
        // GL is weird because it's bottom to top, r_refdef.view.y is top to bottom
-       R_Viewport_InitOrtho(&viewport, &identitymatrix, r_refdef.view.x, vid.height - r_refdef.view.height - r_refdef.view.y, r_refdef.view.width, r_refdef.view.height, 0, 0, 1, 1, -10, 100, NULL);
+       R_Viewport_InitOrtho(&viewport, &identitymatrix, r_refdef.view.x, vid.height - r_refdef.view.height - r_refdef.view.y, r_refdef.view.width, r_refdef.view.height, 0, 0, x2, y2, -10, 100, NULL);
        R_Mesh_SetRenderTargets(fbo, depthtexture, colortexture, NULL, NULL, NULL);
        R_SetViewport(&viewport);
        GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
@@ -5468,6 +5469,15 @@ void R_ResetViewRendering2D(int fbo, rtexture_t *depthtexture, rtexture_t *color
                break;
        }
        GL_CullFace(GL_NONE);
+
+       CHECKGLERROR
+}
+
+void R_ResetViewRendering2D(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture)
+{
+       DrawQ_Finish();
+
+       R_ResetViewRendering2D_Common(fbo, depthtexture, colortexture, 1, 1);
 }
 
 void R_ResetViewRendering3D(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture)
index 46c0c658ee502e556aa92453e858dbc0c2d4cfc4..0ddb2f5755d12f1732cc121124fe004ff517f61d 100644 (file)
--- a/render.h
+++ b/render.h
@@ -516,6 +516,7 @@ r_framebufferstate_t;
 
 extern r_framebufferstate_t r_fb;
 
+void R_ResetViewRendering2D_Common(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, float x2, float y2); // this is called by R_ResetViewRendering2D and _DrawQ_Setup and internal
 void R_ResetViewRendering2D(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture);
 void R_ResetViewRendering3D(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture);
 void R_SetupView(qboolean allowwaterclippingplane, int fbo, rtexture_t *depthtexture, rtexture_t *colortexture);