100 lines
2.9 KiB
C++
100 lines
2.9 KiB
C++
/*
|
|
hud_overlays.cpp - HUD Overlays
|
|
Copyright (C) 2015 a1batross
|
|
*/
|
|
|
|
#include "hud.h"
|
|
#include "triangleapi.h"
|
|
#include "r_efx.h"
|
|
#include "cl_util.h"
|
|
|
|
void Quad(float x1, float y1, float x2, float y2)
|
|
{
|
|
gEngfuncs.pTriAPI->TexCoord2f(0,0);
|
|
gEngfuncs.pTriAPI->Vertex3f(x1, y1, 0);
|
|
|
|
gEngfuncs.pTriAPI->TexCoord2f(0,1);
|
|
gEngfuncs.pTriAPI->Vertex3f(x1, y2, 0);
|
|
|
|
gEngfuncs.pTriAPI->TexCoord2f(1,1);
|
|
gEngfuncs.pTriAPI->Vertex3f(x2, y2, 0);
|
|
|
|
gEngfuncs.pTriAPI->TexCoord2f(1,0);
|
|
gEngfuncs.pTriAPI->Vertex3f(x2, y1, 0);
|
|
}
|
|
|
|
|
|
int CHudSniperScope::Init()
|
|
{
|
|
gHUD.AddHudElem(this);
|
|
m_iFlags = HUD_ACTIVE;
|
|
return 1;
|
|
}
|
|
|
|
int CHudSniperScope::VidInit()
|
|
{
|
|
if( g_iXash == 0 )
|
|
{
|
|
ConsolePrint("^3No Xash Found Warning^7: CHudSniperScope is disabled! ");
|
|
m_iFlags = 0;
|
|
return 0;
|
|
}
|
|
m_iScopeArc[0] = gRenderAPI.GL_LoadTexture("sprites/scope_arc_nw.tga", NULL, 0, TF_NEAREST |TF_NOPICMIP|TF_NOMIPMAP|TF_CLAMP);
|
|
m_iScopeArc[1] = gRenderAPI.GL_LoadTexture("sprites/scope_arc_ne.tga", NULL, 0, TF_NEAREST |TF_NOPICMIP|TF_NOMIPMAP|TF_CLAMP);
|
|
m_iScopeArc[2] = gRenderAPI.GL_LoadTexture("sprites/scope_arc.tga", NULL, 0, TF_NEAREST |TF_NOPICMIP|TF_NOMIPMAP|TF_CLAMP);
|
|
m_iScopeArc[3] = gRenderAPI.GL_LoadTexture("sprites/scope_arc_sw.tga", NULL, 0, TF_NEAREST |TF_NOPICMIP|TF_NOMIPMAP|TF_CLAMP);
|
|
blackTex = gRenderAPI.GL_FindTexture("*black");
|
|
left = (TrueWidth - TrueHeight)/2;
|
|
right = left + TrueHeight;
|
|
centerx = TrueWidth/2;
|
|
centery = TrueHeight/2;
|
|
return 1;
|
|
}
|
|
|
|
int CHudSniperScope::Draw(float flTime)
|
|
{
|
|
if(gHUD.m_iFOV > 40)
|
|
return 1;
|
|
gEngfuncs.pTriAPI->RenderMode(kRenderTransColor);
|
|
gEngfuncs.pTriAPI->Brightness(1.0);
|
|
gEngfuncs.pTriAPI->Color4ub(0, 0, 0, 255);
|
|
gEngfuncs.pTriAPI->CullFace(TRI_NONE);
|
|
|
|
gRenderAPI.GL_Bind(0, m_iScopeArc[0]);
|
|
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
|
|
Quad(left, 0, centerx, centery);
|
|
gEngfuncs.pTriAPI->End();
|
|
|
|
gRenderAPI.GL_Bind(0, m_iScopeArc[1]);
|
|
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
|
|
Quad(centerx, 0, right, centery);
|
|
gEngfuncs.pTriAPI->End();
|
|
|
|
gRenderAPI.GL_Bind(0, m_iScopeArc[2]);
|
|
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
|
|
Quad(centerx, centery, right, TrueHeight);
|
|
gEngfuncs.pTriAPI->End();
|
|
|
|
gRenderAPI.GL_Bind(0, m_iScopeArc[3]);
|
|
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
|
|
Quad(left, centery, centerx, TrueHeight);
|
|
gEngfuncs.pTriAPI->End();
|
|
|
|
gRenderAPI.GL_Bind(0, blackTex);
|
|
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
|
|
Quad(0, 0, left + 1.0f / TrueWidth, TrueHeight);
|
|
gEngfuncs.pTriAPI->End();
|
|
|
|
gEngfuncs.pTriAPI->Begin(TRI_QUADS);
|
|
Quad(right - 1.0f / TrueWidth, 0, TrueWidth, TrueHeight);
|
|
gEngfuncs.pTriAPI->End();
|
|
|
|
FillRGBABlend(0, ScreenHeight/2, ScreenWidth/2 - 20, 1, 0, 0, 0, 255);
|
|
FillRGBABlend(ScreenWidth/2 + 20, ScreenHeight/2, ScreenWidth , 1, 0, 0, 0, 255);
|
|
|
|
FillRGBABlend(ScreenWidth/2, 0 , 1, ScreenHeight/2 - 20, 0, 0, 0, 255);
|
|
FillRGBABlend(ScreenWidth/2, ScreenHeight/2 + 20, 1, ScreenHeight , 0, 0, 0, 255);
|
|
|
|
return 0;
|
|
}
|