/* ============== Z_Draw ============== */ void Z_Draw( void ){ #ifdef DBG_WINDOWPOS CheckWatchit( "Z_Draw" ); #endif brush_t *brush; float w, h; double start, end; qtexture_t *q; float top, bottom; vec3_t org_top, org_bottom, dir_up, dir_down; int xCam = z.width / 3; if ( !active_brushes.next ) { return; // not valid yet } if ( z.timing ) { start = Sys_DoubleTime(); } // // clear // glViewport( 0, 0, z.width, z.height ); glClearColor( g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][0], g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][1], g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][2], 0 ); /* GL Bug */ /* When not using hw acceleration, gl will fault if we clear the depth buffer bit on the first pass. The hack fix is to set the GL_DEPTH_BUFFER_BIT only after Z_Draw() has been called once. Yeah, right. */ glClear( glbitClear ); glbitClear |= GL_DEPTH_BUFFER_BIT; glMatrixMode( GL_PROJECTION ); glLoadIdentity(); w = z.width / 2 / z.scale; h = z.height / 2 / z.scale; glOrtho( -w, w, z.origin[2] - h, z.origin[2] + h, -8, 8 ); glDisable( GL_TEXTURE_2D ); glDisable( GL_TEXTURE_1D ); glDisable( GL_DEPTH_TEST ); glDisable( GL_BLEND ); // // now draw the grid // Z_DrawGrid(); // // draw stuff // glDisable( GL_CULL_FACE ); glShadeModel( GL_FLAT ); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); glDisable( GL_TEXTURE_2D ); glDisable( GL_BLEND ); glDisable( GL_DEPTH_TEST ); // draw filled interiors and edges dir_up[0] = 0 ; dir_up[1] = 0; dir_up[2] = 1; dir_down[0] = 0 ; dir_down[1] = 0; dir_down[2] = -1; VectorCopy( z.origin, org_top ); org_top[2] = g_MaxWorldCoord; VectorCopy( z.origin, org_bottom ); org_bottom[2] = g_MinWorldCoord; for ( brush = active_brushes.next ; brush != &active_brushes ; brush = brush->next ) { if ( brush->bFiltered ) { continue; } if ( brush->mins[0] >= z.origin[0] || brush->maxs[0] <= z.origin[0] || brush->mins[1] >= z.origin[1] || brush->maxs[1] <= z.origin[1] ) { continue; } if ( !Brush_Ray( org_top, dir_down, brush, &top ) ) { continue; } top = org_top[2] - top; if ( !Brush_Ray( org_bottom, dir_up, brush, &bottom ) ) { continue; } bottom = org_bottom[2] + bottom; q = brush->brush_faces->pShader->getTexture(); glColor3f( q->color[0], q->color[1], q->color[2] ); glBegin( GL_QUADS ); glVertex2f( -xCam, bottom ); glVertex2f( xCam, bottom ); glVertex2f( xCam, top ); glVertex2f( -xCam, top ); glEnd(); glColor3f( 1,1,1 ); glBegin( GL_LINE_LOOP ); glVertex2f( -xCam, bottom ); glVertex2f( xCam, bottom ); glVertex2f( xCam, top ); glVertex2f( -xCam, top ); glEnd(); } // // now draw selected brushes // for ( brush = selected_brushes.next ; brush != &selected_brushes ; brush = brush->next ) { if ( !( brush->mins[0] >= z.origin[0] || brush->maxs[0] <= z.origin[0] || brush->mins[1] >= z.origin[1] || brush->maxs[1] <= z.origin[1] ) ) { if ( Brush_Ray( org_top, dir_down, brush, &top ) ) { top = org_top[2] - top; if ( Brush_Ray( org_bottom, dir_up, brush, &bottom ) ) { bottom = org_bottom[2] + bottom; q = brush->brush_faces->pShader->getTexture(); glColor3f( q->color[0], q->color[1], q->color[2] ); glBegin( GL_QUADS ); glVertex2f( -xCam, bottom ); glVertex2f( xCam, bottom ); glVertex2f( xCam, top ); glVertex2f( -xCam, top ); glEnd(); } } } glColor3fv( g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES] ); glBegin( GL_LINE_LOOP ); glVertex2f( -xCam, brush->mins[2] ); glVertex2f( xCam, brush->mins[2] ); glVertex2f( xCam, brush->maxs[2] ); glVertex2f( -xCam, brush->maxs[2] ); glEnd(); } ZDrawCameraIcon(); glFinish(); QE_CheckOpenGLForErrors(); if ( z.timing ) { end = Sys_DoubleTime(); Sys_Printf( "z: %i ms\n", (int)( 1000 * ( end - start ) ) ); } }
/* ======================================================================================================================= Z_Draw ======================================================================================================================= */ void Z_Draw(void) { brush_t *brush; float top, bottom; idVec3 org_top, org_bottom, dir_up, dir_down; int xCam = z.width / 3; if (!active_brushes.next) { return; // not valid yet } // clear glViewport(0, 0, z.width, z.height); glScissor(0, 0, z.width, z.height); glClearColor ( g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][0], g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][1], g_qeglobals.d_savedinfo.colors[COLOR_GRIDBACK][2], 0 ); /* * GL Bug £ * When not using hw acceleration, gl will fault if we clear the depth buffer bit * on the first pass. The hack fix is to set the GL_DEPTH_BUFFER_BIT only after * Z_Draw() has been called once. Yeah, right. £ * glClear(glbitClear); */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // // glbitClear |= GL_DEPTH_BUFFER_BIT; // glClear(GL_DEPTH_BUFFER_BIT); // const float w = z.width / 2 / z.scale; const float h = z.height / 2 / z.scale; GL_ProjectionMatrix.LoadIdentity(); GL_ProjectionMatrix.Ortho(-w, w, z.origin[2] - h, z.origin[2] + h, -8, 8); globalImages->BindNull(); glDisable(GL_DEPTH_TEST); glDisable(GL_BLEND); // now draw the grid Z_DrawGrid(); // draw stuff glDisable(GL_CULL_FACE); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLineWidth(1.0f); globalImages->BindNull(); // draw filled interiors and edges dir_up[0] = 0; dir_up[1] = 0; dir_up[2] = 1; dir_down[0] = 0; dir_down[1] = 0; dir_down[2] = -1; VectorCopy(z.origin, org_top); org_top[2] = 4096; VectorCopy(z.origin, org_bottom); org_bottom[2] = -4096; for (brush = active_brushes.next; brush != &active_brushes; brush = brush->next) { if ( brush->mins[0] >= z.origin[0] || brush->maxs[0] <= z.origin[0] || brush->mins[1] >= z.origin[1] || brush->maxs[1] <= z.origin[1] ) { continue; } if (!Brush_Ray(org_top, dir_down, brush, &top)) { continue; } top = org_top[2] - top; if (!Brush_Ray(org_bottom, dir_up, brush, &bottom)) { continue; } bottom = org_bottom[2] + bottom; //q = declManager->FindMaterial(brush->brush_faces->texdef.name); fhImmediateMode im; im.Color3f(brush->owner->eclass->color.x, brush->owner->eclass->color.y, brush->owner->eclass->color.z); im.Begin(GL_QUADS); im.Vertex2f(-xCam, bottom); im.Vertex2f(xCam, bottom); im.Vertex2f(xCam, top); im.Vertex2f(-xCam, top); im.End(); im.Color3f(1, 1, 1); im.Begin(GL_LINE_LOOP); im.Vertex2f(-xCam, bottom); im.Vertex2f(xCam, bottom); im.Vertex2f(xCam, top); im.Vertex2f(-xCam, top); im.End(); } // now draw selected brushes fhImmediateMode im; for (brush = selected_brushes.next; brush != &selected_brushes; brush = brush->next) { if ( !( brush->mins[0] >= z.origin[0] || brush->maxs[0] <= z.origin[0] || brush->mins[1] >= z.origin[1] || brush->maxs[1] <= z.origin[1] ) ) { if (Brush_Ray(org_top, dir_down, brush, &top)) { top = org_top[2] - top; if (Brush_Ray(org_bottom, dir_up, brush, &bottom)) { bottom = org_bottom[2] + bottom; //q = declManager->FindMaterial(brush->brush_faces->texdef.name); im.Color3f(brush->owner->eclass->color.x, brush->owner->eclass->color.y, brush->owner->eclass->color.z); im.Begin(GL_QUADS); im.Vertex2f(-xCam, bottom); im.Vertex2f(xCam, bottom); im.Vertex2f(xCam, top); im.Vertex2f(-xCam, top); im.End(); } } } im.Color3fv(g_qeglobals.d_savedinfo.colors[COLOR_SELBRUSHES].ToFloatPtr()); im.Begin(GL_LINE_LOOP); im.Vertex2f(-xCam, brush->mins[2]); im.Vertex2f(xCam, brush->mins[2]); im.Vertex2f(xCam, brush->maxs[2]); im.Vertex2f(-xCam, brush->maxs[2]); im.End(); } ZDrawCameraIcon(); ZDrawZClip(); glFinish(); QE_CheckOpenGLForErrors(); }