2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-25 19:29:13 +01:00
hlsdk-xash3d/cl_dll/tri.cpp

119 lines
2.6 KiB
C++
Raw Normal View History

2018-01-19 18:00:32 +01:00
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
2016-06-04 15:24:23 +02:00
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
// Triangle rendering, if any
#include "hud.h"
#include "cl_util.h"
// Triangle rendering apis are in gEngfuncs.pTriAPI
#include "const.h"
#include "entity_state.h"
#include "cl_entity.h"
#include "triangleapi.h"
extern "C"
{
void DLLEXPORT HUD_DrawNormalTriangles( void );
void DLLEXPORT HUD_DrawTransparentTriangles( void );
2016-06-25 20:21:01 +02:00
}
2016-06-04 15:24:23 +02:00
2021-06-20 00:53:07 +02:00
//#define TEST_IT 1
#if TEST_IT
2016-06-04 15:24:23 +02:00
/*
=================
Draw_Triangles
Example routine. Draws a sprite offset from the player origin.
=================
*/
void Draw_Triangles( void )
{
cl_entity_t *player;
vec3_t org;
// Load it up with some bogus data
player = gEngfuncs.GetLocalPlayer();
2016-07-03 15:39:55 +02:00
if( !player )
2016-06-04 15:24:23 +02:00
return;
org = player->origin;
org.x += 50;
org.y += 50;
2016-07-03 15:39:55 +02:00
if( gHUD.m_hsprCursor == 0 )
2016-06-04 15:24:23 +02:00
{
char sz[256];
sprintf( sz, "sprites/cursor.spr" );
gHUD.m_hsprCursor = SPR_Load( sz );
}
2016-07-03 15:39:55 +02:00
if( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ) )
2016-06-04 15:24:23 +02:00
{
return;
}
2016-07-03 15:39:55 +02:00
2016-06-04 15:24:23 +02:00
// Create a triangle, sigh
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
gEngfuncs.pTriAPI->CullFace( TRI_NONE );
gEngfuncs.pTriAPI->Begin( TRI_QUADS );
// Overload p->color with index into tracer palette, p->packedColor with brightness
gEngfuncs.pTriAPI->Color4f( 1.0, 1.0, 1.0, 1.0 );
// UNDONE: This gouraud shading causes tracers to disappear on some cards (permedia2)
gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 0, 0 );
gEngfuncs.pTriAPI->Vertex3f( org.x, org.y, org.z );
gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 0, 1 );
gEngfuncs.pTriAPI->Vertex3f( org.x, org.y + 50, org.z );
gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 1, 1 );
gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y + 50, org.z );
gEngfuncs.pTriAPI->Brightness( 1 );
gEngfuncs.pTriAPI->TexCoord2f( 1, 0 );
gEngfuncs.pTriAPI->Vertex3f( org.x + 50, org.y, org.z );
gEngfuncs.pTriAPI->End();
gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
}
#endif
/*
=================
HUD_DrawNormalTriangles
Non-transparent triangles-- add them here
=================
*/
void DLLEXPORT HUD_DrawNormalTriangles( void )
{
gHUD.m_Spectator.DrawOverview();
2021-06-20 00:53:07 +02:00
#if TEST_IT
2016-06-04 15:24:23 +02:00
// Draw_Triangles();
#endif
}
/*
=================
HUD_DrawTransparentTriangles
Render any triangles with transparent rendermode needs here
=================
*/
void DLLEXPORT HUD_DrawTransparentTriangles( void )
{
2021-06-20 00:53:07 +02:00
#if TEST_IT
2016-06-04 15:24:23 +02:00
// Draw_Triangles();
#endif
}