mirror of
https://github.com/shawns-valve/halflife.git
synced 2024-11-22 04:21:30 +00:00
127 lines
No EOL
2.9 KiB
C++
127 lines
No EOL
2.9 KiB
C++
/***
|
|
*
|
|
* Copyright (c) 1999, 2000 Valve LLC. All rights reserved.
|
|
*
|
|
* This product contains software technology licensed from Id
|
|
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
* All Rights Reserved.
|
|
*
|
|
* Use, distribution, and modification of this source code and/or resulting
|
|
* object code is restricted to non-commercial enhancements to products from
|
|
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
* without written permission from Valve LLC.
|
|
*
|
|
****/
|
|
// 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 EXPORT HUD_DrawNormalTriangles( void );
|
|
void EXPORT HUD_DrawTransparentTriangles( void );
|
|
};
|
|
|
|
//#define TEST_IT
|
|
#if defined( TEST_IT )
|
|
|
|
/*
|
|
=================
|
|
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();
|
|
if ( !player )
|
|
return;
|
|
|
|
org = player->origin;
|
|
|
|
org.x += 50;
|
|
org.y += 50;
|
|
|
|
if (gHUD.m_hsprCursor == 0)
|
|
{
|
|
char sz[256];
|
|
sprintf( sz, "sprites/cursor.spr" );
|
|
gHUD.m_hsprCursor = SPR_Load( sz );
|
|
}
|
|
|
|
if ( !gEngfuncs.pTriAPI->SpriteTexture( (struct model_s *)gEngfuncs.GetSpritePointer( gHUD.m_hsprCursor ), 0 ))
|
|
{
|
|
return;
|
|
}
|
|
|
|
// 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 EXPORT HUD_DrawNormalTriangles( void )
|
|
{
|
|
|
|
#if defined( TEST_IT )
|
|
// Draw_Triangles();
|
|
#endif
|
|
}
|
|
|
|
/*
|
|
=================
|
|
HUD_DrawTransparentTriangles
|
|
|
|
Render any triangles with transparent rendermode needs here
|
|
=================
|
|
*/
|
|
void EXPORT HUD_DrawTransparentTriangles( void )
|
|
{
|
|
|
|
#if defined( TEST_IT )
|
|
// Draw_Triangles();
|
|
#endif
|
|
} |