/*
=====================
idRenderWorldLocal::ShowPortals

Debugging tool, won't work correctly with SMP or when mirrors are present
=====================
*/
void idRenderWorldLocal::ShowPortals() {
	int			i, j;
	portalArea_t	*area;
	portal_t	*p;
	idWinding	*w;

	// flood out through portals, setting area viewCount
	for ( i = 0; i < numPortalAreas; i++ ) {
		area = &portalAreas[i];
		if ( area->viewCount != tr.viewCount ) {
			continue;
		}
		for ( p = area->portals; p; p = p->next ) {
			w = p->w;
			if ( !w ) {
				continue;
			}

			if ( portalAreas[ p->intoArea ].viewCount != tr.viewCount ) {
				// red = can't see
				GL_Color( 1, 0, 0 );
			} else {
				// green = see through
				GL_Color( 0, 1, 0 );
			}

			qglBegin( GL_LINE_LOOP );
			for ( j = 0; j < w->GetNumPoints(); j++ ) {
				qglVertex3fv( (*w)[j].ToFloatPtr() );
			}
			qglEnd();
		}
	}
}
void CZClip::Paint( void ) {
	float	x, y;
	int	xCam = z.width / 4;	// hmmm, a rather unpleasant and obscure global name, but it was already called that so...
	GL_Color( ZCLIP_COLOUR ); //1.0, 0.0, 1.0);
	// draw TOP marker...
	//
	x = 0;
	y = m_iZClipTop;
	if( m_bEnabled ) {
		glBegin( GL_QUADS );
	} else {
		glBegin( GL_LINE_LOOP );
	}
	glVertex3f( x - xCam, y, 0 );
	glVertex3f( x - xCam, y + ZCLIP_BAR_THICKNESS, 0 );
	glVertex3f( x + xCam, y + ZCLIP_BAR_THICKNESS, 0 );
	glVertex3f( x + xCam, y, 0 );
	glEnd();
	GL_Color( ZCLIP_COLOUR_DIM ); //0.8, 0.0, 0.8);
	if( m_bEnabled ) {
		glBegin( GL_TRIANGLES );
	} else {
		glBegin( GL_LINE_LOOP );
	}
	glVertex3f( x, ( y + ZCLIP_BAR_THICKNESS ), 0 );
	glVertex3f( x - xCam, ( y + ZCLIP_BAR_THICKNESS ) + ( ZCLIP_ARROWHEIGHT / 2 ), 0 );
	glVertex3f( x + xCam, ( y + ZCLIP_BAR_THICKNESS ) + ( ZCLIP_ARROWHEIGHT / 2 ), 0 );
	glEnd();
	// draw bottom marker...
	//
	GL_Color( ZCLIP_COLOUR ); //1.0, 0.0, 1.0);
	x = 0;
	y = m_iZClipBottom;
	if( m_bEnabled ) {
		glBegin( GL_QUADS );
	} else {
		glBegin( GL_LINE_LOOP );
	}
	glVertex3f( x - xCam, y, 0 );
	glVertex3f( x - xCam, y - ZCLIP_BAR_THICKNESS, 0 );
	glVertex3f( x + xCam, y - ZCLIP_BAR_THICKNESS, 0 );
	glVertex3f( x + xCam, y, 0 );
	glEnd();
	GL_Color( ZCLIP_COLOUR_DIM ); //0.8, 0.0, 0.8);
	if( m_bEnabled ) {
		glBegin( GL_TRIANGLES );
	} else {
		glBegin( GL_LINE_LOOP );
	}
	glVertex3f( x, ( y - ZCLIP_BAR_THICKNESS ), 0 );
	glVertex3f( x - xCam, ( y - ZCLIP_BAR_THICKNESS ) - ( ZCLIP_ARROWHEIGHT / 2 ), 0 );
	glVertex3f( x + xCam, ( y - ZCLIP_BAR_THICKNESS ) - ( ZCLIP_ARROWHEIGHT / 2 ), 0 );
	glEnd();
}
/*
=====================
idRenderWorldLocal::ShowPortals

Debugging tool, won't work correctly with SMP or when mirrors are present
=====================
*/
void idRenderWorldLocal::ShowPortals()
{
#if !defined(USE_GLES3) && !defined(USE_GLES2)
	int			i, j;
	portalArea_t*	area;
	portal_t*	p;
	idWinding*	w;
	
	// flood out through portals, setting area viewCount
	for( i = 0; i < numPortalAreas; i++ )
	{
		area = &portalAreas[i];
		if( area->viewCount != tr.viewCount )
		{
			continue;
		}
		for( p = area->portals; p; p = p->next )
		{
			w = p->w;
			if( !w )
			{
				continue;
			}
			
			if( portalAreas[ p->intoArea ].viewCount != tr.viewCount )
			{
				// red = can't see
				GL_Color( 1, 0, 0 );
			}
			else
			{
				// green = see through
				GL_Color( 0, 1, 0 );
			}
			
			// RB begin
			renderProgManager.CommitUniforms();
			// RB end
			
			glBegin( GL_LINE_LOOP );
			for( j = 0; j < w->GetNumPoints(); j++ )
			{
				glVertex3fv( ( *w )[j].ToFloatPtr() );
			}
			glEnd();
		}
	}
#endif
}
Example #4
0
/*
===================
R_ColorByStencilBuffer

Sets the screen colors based on the contents of the
stencil buffer.  Stencil of 0 = black, 1 = red, 2 = green,
3 = blue, ..., 7+ = white
===================
*/
static void R_ColorByStencilBuffer() {
	int		i;
	static float	colors[8][3] = {
		{0,0,0},
		{1,0,0},
		{0,1,0},
		{0,0,1},
		{0,1,1},
		{1,0,1},
		{1,1,0},
		{1,1,1},
	};

	// clear color buffer to white (>6 passes)
	GL_Clear( true, false, false, 0, 1.0f, 1.0f, 1.0f, 1.0f );

	// now draw color for each stencil value
	qglStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
	for ( i = 0; i < 6; i++ ) {
		GL_Color( colors[i] );
		renderProgManager.BindShader_Color();
		qglStencilFunc( GL_EQUAL, i, 255 );
		RB_PolygonClear();
	}

	qglStencilFunc( GL_ALWAYS, 0, 255 );
}
void DrawAuxWinding( const idWinding *w ) {
	int		i;
	if( !dmapGlobals.drawflag ) {
		return;
	}
	GL_Color( 0.0f, 0.3f, 0.0f );
	glBegin( GL_POLYGON );
	for( i = 0; i < w->GetNumPoints(); i++ ) {
		glVertex3f( ( *w )[i][0], ( *w )[i][1], ( *w )[i][2] );
	}
	glEnd();
	GL_Color( 0.0f, 1.0f, 0.0f );
	glBegin( GL_LINE_LOOP );
	for( i = 0; i < w->GetNumPoints(); i++ ) {
		glVertex3f( ( *w )[i][0], ( *w )[i][1], ( *w )[i][2] );
	}
	glEnd();
	glFlush();
}
void idGLDrawable::draw( int x, int y, int w, int h ) {
	GL_State( GLS_DEFAULT );
	GL_Viewport( x, y, w, h );
	GL_Scissor( x, y, w, h );
	glMatrixMode( GL_PROJECTION );
	glClearColor( 0.1f, 0.1f, 0.1f, 0.0f );
	glClear( GL_COLOR_BUFFER_BIT );
	glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
	glLineWidth( 0.5 );
	GL_Color( 1.0f, 1.0f, 1.0f );
	globalImages->BindNull();
	glBegin( GL_LINE_LOOP );
	GL_Color( 1.0f, 0.0f, 0.0f );
	glVertex2f( x + 3, y + 3 );
	GL_Color( 0.0f, 1.0f, 0.0f );
	glVertex2f( x + 3, h - 3 );
	GL_Color( 0.0f, 0.0f, 1.0f );
	glVertex2f( w - 3, h - 3 );
	GL_Color( 1.0f, 1.0f, 1.0f );
	glVertex2f( w - 3, y + 3 );
	glEnd();
}
Example #7
0
/*
===================
RB_ShowIntensity

Debugging tool to see how much dynamic range a scene is using.
The greatest of the rgb values at each pixel will be used, with
the resulting color shading from red at 0 to green at 128 to blue at 255
===================
*/
static void RB_ShowIntensity() {
	byte	*colorReadback;
	int		i, j, c;

	if ( !r_showIntensity.GetBool() ) {
		return;
	}

	colorReadback = (byte *)R_StaticAlloc( renderSystem->GetWidth() * renderSystem->GetHeight() * 4, TAG_RENDER_TOOLS );
	qglReadPixels( 0, 0, renderSystem->GetWidth(), renderSystem->GetHeight(), GL_RGBA, GL_UNSIGNED_BYTE, colorReadback );

	c = renderSystem->GetWidth() * renderSystem->GetHeight() * 4;
	for ( i = 0; i < c; i+=4 ) {
		j = colorReadback[i];
		if ( colorReadback[i+1] > j ) {
			j = colorReadback[i+1];
		}
		if ( colorReadback[i+2] > j ) {
			j = colorReadback[i+2];
		}
		if ( j < 128 ) {
			colorReadback[i+0] = 2*(128-j);
			colorReadback[i+1] = 2*j;
			colorReadback[i+2] = 0;
		} else {
			colorReadback[i+0] = 0;
			colorReadback[i+1] = 2*(255-j);
			colorReadback[i+2] = 2*(j-128);
		}
	}

	// draw it back to the screen
	qglLoadIdentity();
	qglMatrixMode( GL_PROJECTION );
	GL_State( GLS_DEPTHFUNC_ALWAYS );
	qglPushMatrix();
	qglLoadIdentity(); 
    qglOrtho( 0, 1, 0, 1, -1, 1 );
	qglRasterPos2f( 0, 0 );
	qglPopMatrix();
	GL_Color( 1, 1, 1 );
	globalImages->BindNull();
	qglMatrixMode( GL_MODELVIEW );

	qglDrawPixels( renderSystem->GetWidth(), renderSystem->GetHeight(), GL_RGBA , GL_UNSIGNED_BYTE, colorReadback );

	R_StaticFree( colorReadback );
}
void Draw_ClearWindow( void ) {
	if( !dmapGlobals.drawflag ) {
		return;
	}
	glDrawBuffer( GL_FRONT );
	RB_SetGL2D();
	glClearColor( 0.5, 0.5, 0.5, 0 );
	glClear( GL_COLOR_BUFFER_BIT );
#if 0
	int		w, h, g;
	float	mx, my;
	w = ( dmapGlobals.drawBounds.b[1][0] - dmapGlobals.drawBounds.b[0][0] );
	h = ( dmapGlobals.drawBounds.b[1][1] - dmapGlobals.drawBounds.b[0][1] );
	mx = dmapGlobals.drawBounds.b[0][0] + w / 2;
	my = dmapGlobals.drawBounds.b[1][1] + h / 2;
	g = w > h ? w : h;
	glLoadIdentity();
	gluPerspective( 90,  1,  2,  16384 );
	gluLookAt( mx, my, draw_maxs[2] + g / 2, mx , my, draw_maxs[2], 0, 1, 0 );
#else
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	glOrtho( dmapGlobals.drawBounds[0][0], dmapGlobals.drawBounds[1][0],
			 dmapGlobals.drawBounds[0][1], dmapGlobals.drawBounds[1][1],
			 -1, 1 );
	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();
#endif
	GL_Color( 0.0f, 0.0f, 0.0f );
	//	glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
	glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
	glDisable( GL_DEPTH_TEST );
	//	glEnable (GL_BLEND);
	glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
#if 0
	//glColor4f (1,0,0,0.5);
	//	glBegin( GL_LINE_LOOP );
	glBegin( GL_QUADS );
	glVertex2f( dmapGlobals.drawBounds.b[0][0] + 20, dmapGlobals.drawBounds.b[0][1] + 20 );
	glVertex2f( dmapGlobals.drawBounds.b[1][0] - 20, dmapGlobals.drawBounds.b[0][1] + 20 );
	glVertex2f( dmapGlobals.drawBounds.b[1][0] - 20, dmapGlobals.drawBounds.b[1][1] - 20 );
	glVertex2f( dmapGlobals.drawBounds.b[0][0] + 20, dmapGlobals.drawBounds.b[1][1] - 20 );
	glEnd();
#endif
	glFlush();
}
Example #9
0
/*
===================
RB_ShowDepthBuffer

Draw the depth buffer as colors
===================
*/
static void RB_ShowDepthBuffer() {
	void	*depthReadback;

	if ( !r_showDepth.GetBool() ) {
		return;
	}

	qglPushMatrix();
	qglLoadIdentity();
	qglMatrixMode( GL_PROJECTION );
	qglPushMatrix();
	qglLoadIdentity(); 
    qglOrtho( 0, 1, 0, 1, -1, 1 );
	qglRasterPos2f( 0, 0 );
	qglPopMatrix();
	qglMatrixMode( GL_MODELVIEW );
	qglPopMatrix();

	GL_State( GLS_DEPTHFUNC_ALWAYS );
	GL_Color( 1, 1, 1 );
	globalImages->BindNull();

	depthReadback = R_StaticAlloc( renderSystem->GetWidth() * renderSystem->GetHeight()*4, TAG_RENDER_TOOLS );
	memset( depthReadback, 0, renderSystem->GetWidth() * renderSystem->GetHeight()*4 );

	qglReadPixels( 0, 0, renderSystem->GetWidth(), renderSystem->GetHeight(), GL_DEPTH_COMPONENT , GL_FLOAT, depthReadback );

#if 0
	for ( i = 0; i < renderSystem->GetWidth() * renderSystem->GetHeight(); i++ ) {
		((byte *)depthReadback)[i*4] = 
		((byte *)depthReadback)[i*4+1] = 
		((byte *)depthReadback)[i*4+2] = 255 * ((float *)depthReadback)[i];
		((byte *)depthReadback)[i*4+3] = 1;
	}
#endif

	qglDrawPixels( renderSystem->GetWidth(), renderSystem->GetHeight(), GL_RGBA , GL_UNSIGNED_BYTE, depthReadback );
	R_StaticFree( depthReadback );
}
void DrawLine( idVec3 v1, idVec3 v2, int color ) {
	if( !dmapGlobals.drawflag ) {
		return;
	}
	switch( color ) {
	case 0:
		GL_Color( 0.0f, 0.0f, 0.0f );
		break;
	case 1:
		GL_Color( 0.0f, 0.0f, 1.0f );
		break;
	case 2:
		GL_Color( 0.0f, 1.0f, 0.0f );
		break;
	case 3:
		GL_Color( 0.0f, 1.0f, 1.0f );
		break;
	case 4:
		GL_Color( 1.0f, 0.0f, 0.0f );
		break;
	case 5:
		GL_Color( 1.0f, 0.0f, 1.0f );
		break;
	case 6:
		GL_Color( 1.0f, 1.0f, 0.0f );
		break;
	case 7:
		GL_Color( 1.0f, 1.0f, 1.0f );
		break;
	}
	glBegin( GL_LINES );
	glVertex3fv( v1.ToFloatPtr() );
	glVertex3fv( v2.ToFloatPtr() );
	glEnd();
	glFlush();
}
Example #11
0
static void R_DrawExplosion_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
{
	int surfacelistindex = 0;
	const int numtriangles = EXPLOSIONTRIS, numverts = EXPLOSIONVERTS;
	GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
	GL_DepthMask(false);
	GL_DepthRange(0, 1);
	GL_PolygonOffset(r_refdef.polygonfactor, r_refdef.polygonoffset);
	GL_DepthTest(true);
	GL_CullFace(r_refdef.view.cullface_back);
	R_EntityMatrix(&identitymatrix);

//	R_Mesh_ResetTextureState();
	R_SetupShader_Generic(explosiontexture, NULL, GL_MODULATE, 1, false, false, false);
	for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
	{
		const explosion_t *e = explosion + surfacelist[surfacelistindex];
		// FIXME: this can't properly handle r_refdef.view.colorscale > 1
		GL_Color(e->alpha * r_refdef.view.colorscale, e->alpha * r_refdef.view.colorscale, e->alpha * r_refdef.view.colorscale, 1);
		R_Mesh_PrepareVertices_Generic_Arrays(numverts, e->vert[0], NULL, explosiontexcoord2f[0]);
		R_Mesh_Draw(0, numverts, 0, numtriangles, NULL, NULL, 0, explosiontris[0], NULL, 0);
	}
}
Example #12
0
/*
============================
idAutoRender::RenderLoadingIcon
============================
*/
void idAutoRender::RenderLoadingIcon( float fracX, float fracY, float size, float speed )
{

	float s = 0.0f;
	float c = 1.0f;
	
	if( autoRenderIcon != AUTORENDER_HELLICON )
	{
		if( Sys_Milliseconds() >= nextRotateTime )
		{
			nextRotateTime = Sys_Milliseconds() + 100;
			currentRotation -= 90.0f;
		}
		float angle = DEG2RAD( currentRotation );
		idMath::SinCos( angle, s, c );
	}
	
	const float pixelAspect = renderSystem->GetPixelAspect();
	const float screenWidth = renderSystem->GetWidth();
	const float screenHeight = renderSystem->GetHeight();
	
	const float minSize = Min( screenWidth, screenHeight );
	if( minSize <= 0.0f )
	{
		return;
	}
	
	float scaleX = size * minSize / screenWidth;
	float scaleY = size * minSize / screenHeight;
	
	float scale[16] = { 0 };
	scale[0] = c * scaleX / pixelAspect;
	scale[1] = -s * scaleY;
	scale[4] = s * scaleX / pixelAspect;
	scale[5] = c * scaleY;
	scale[10] = 1.0f;
	scale[15] = 1.0f;
	
	scale[12] = fracX;
	scale[13] = fracY;
	
	float ortho[16] = { 0 };
	ortho[0] = 2.0f;
	ortho[5] = -2.0f;
	ortho[10] = -2.0f;
	ortho[12] = -1.0f;
	ortho[13] = 1.0f;
	ortho[14] = -1.0f;
	ortho[15] = 1.0f;
	
	float finalOrtho[16];
	R_MatrixMultiply( scale, ortho, finalOrtho );
	
	float projMatrixTranspose[16];
	R_MatrixTranspose( finalOrtho, projMatrixTranspose );
	renderProgManager.SetRenderParms( RENDERPARM_MVPMATRIX_X, projMatrixTranspose, 4 );
	
	float a = 1.0f;
	if( autoRenderIcon == AUTORENDER_HELLICON )
	{
		float alpha = DEG2RAD( Sys_Milliseconds() * speed );
		a = idMath::Sin( alpha );
		a = 0.35f + ( 0.65f * idMath::Fabs( a ) );
	}
	
	GL_SelectTexture( 0 );
	
	if( autoRenderIcon == AUTORENDER_HELLICON )
	{
		globalImages->hellLoadingIconImage->Bind();
	}
	else
	{
		globalImages->loadingIconImage->Bind();
	}
	
	GL_State( GLS_DEPTHFUNC_ALWAYS | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA );
	
	// Set Parms
	float texS[4] = { 1.0f, 0.0f, 0.0f, 0.0f };
	float texT[4] = { 0.0f, 1.0f, 0.0f, 0.0f };
	renderProgManager.SetRenderParm( RENDERPARM_TEXTUREMATRIX_S, texS );
	renderProgManager.SetRenderParm( RENDERPARM_TEXTUREMATRIX_T, texT );
	
	if( autoRenderIcon == AUTORENDER_HELLICON )
	{
		GL_Color( 1.0f, 1.0f, 1.0f, a );
	}
	
	// disable texgen
	float texGenEnabled[4] = { 0, 0, 0, 0 };
	renderProgManager.SetRenderParm( RENDERPARM_TEXGEN_0_ENABLED, texGenEnabled );
	
	renderProgManager.BindShader_TextureVertexColor();
	
	RB_DrawElementsWithCounters( &backEnd.unitSquareSurface );
}
void Draw_SetBlack( void ) {
	if( !dmapGlobals.drawflag ) {
		return;
	}
	GL_Color( 0.0f, 0.0f, 0.0f );
}
void Draw_SetGrey( void ) {
	if( !dmapGlobals.drawflag ) {
		return;
	}
	GL_Color( 0.5f, 0.5f, 0.5f );
}
void Draw_SetRed( void ) {
	if( !dmapGlobals.drawflag ) {
		return;
	}
	GL_Color( 1.0f, 0.0f, 0.0f );
}
Example #16
0
/*
====================
RB_ShowDestinationAlpha
====================
*/
void RB_ShowDestinationAlpha() {
	GL_State( GLS_SRCBLEND_DST_ALPHA | GLS_DSTBLEND_ZERO | GLS_DEPTHMASK | GLS_DEPTHFUNC_ALWAYS );
	GL_Color( 1, 1, 1 );
	RB_PolygonClear();
}