Skip to content

Commit

Permalink
Update vgui::VGuiVertex and DrawTexturedPolygon.
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Jan 18, 2024
1 parent 2d74032 commit 9ba29c6
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Plugins/CaptionMod/EngineSurfaceHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void CEngineSurfaceProxy::drawPolyLine(int* px, int* py, int numPoints)

}

void CEngineSurfaceProxy::drawTexturedPolygon(int* p, int n)
void CEngineSurfaceProxy::drawTexturedPolygon(vgui::VGuiVertex* p, int n)
{

}
Expand Down
2 changes: 1 addition & 1 deletion Plugins/CaptionMod/EngineSurfaceHook.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CEngineSurfaceProxy : public IEngineSurface
void drawOutlinedRect(int x0, int y0, int x1, int y1) override;
void drawLine(int x0, int y0, int x1, int y1) override;
void drawPolyLine(int* px, int* py, int numPoints) override;
void drawTexturedPolygon(int* p, int n) override;
void drawTexturedPolygon(vgui::VGuiVertex* p, int n) override;
void drawSetTextureRGBA(int id, const unsigned char* rgba, int wide, int tall, int hardwareFilter, bool forceReload) override;
void drawSetTexture(int id) override;
void drawTexturedRect(int x0, int y0, int x1, int y1) override;
Expand Down
19 changes: 19 additions & 0 deletions Plugins/CaptionMod/Surface2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,22 +1138,39 @@ void CSurface2::SurfaceSetCursorPos(int x, int y)
// Source specific interfaces
void CSurface2::DrawTexturedLine(const Vertex_t &a, const Vertex_t &b)
{

}

void CSurface2::DrawOutlinedCircle(int x, int y, int radius, int segments)
{

}

void CSurface2::DrawTexturedPolyLine(const Vertex_t *p, int n)
{

}

void CSurface2::DrawTexturedSubRect(int x0, int y0, int x1, int y1, float texs0, float text0, float texs1, float text1)
{

}

void CSurface2::DrawTexturedPolygon(int n, Vertex_t *pVertices)
{
vgui::VGuiVertex GoldSrcVertices[32];

int maxVerts = min(n, 32);

for (int i = 0; i < n; ++i)
{
GoldSrcVertices[i].SetVertex(pVertices[i].m_Position.x, pVertices[i].m_Position.y, pVertices[i].m_TexCoord.x, pVertices[i].m_TexCoord.y);
}

if(g_pSurface_HL25)
g_pSurface_HL25->DrawTexturedPolygon(GoldSrcVertices, n);
else
g_pSurface->DrawTexturedPolygon(GoldSrcVertices, n);
}

const wchar_t *CSurface2::GetTitle(VPANEL panel)
Expand Down Expand Up @@ -1256,6 +1273,7 @@ bool CSurface2::SetBitmapFontGlyphSet(HFont font, const char *windowsFontName, f
//-----------------------------------------------------------------------------
bool CSurface2::AddBitmapFontFile(const char *fontFileName)
{

return false;
}

Expand Down Expand Up @@ -1287,6 +1305,7 @@ void CSurface2::DrawUnicodeString(const wchar_t *pwString, FontDrawType_t drawTy
auto ch = (*pwString);
if (!ch)
break;

DrawUnicodeChar(ch);

pwString++;
Expand Down
8 changes: 4 additions & 4 deletions Plugins/CaptionMod/SurfaceHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class CSurfaceProxy : public ISurface
bool HasCursorPosFunctions(void) override;
void SurfaceGetCursorPos(int &x, int &y) override;
void SurfaceSetCursorPos(int x, int y) override;
void DrawTexturedPolygon(int *p, int n) override;
void DrawTexturedPolygon(vgui::VGuiVertex*p, int n) override;
int GetFontAscent(HFont font, wchar_t wch) override;
void SetAllowHTMLJavaScript(bool state) override;
void SetLanguage(const char *pchLang) override;
Expand Down Expand Up @@ -831,7 +831,7 @@ void CSurfaceProxy::SurfaceSetCursorPos(int x, int y)
return m_pfnSurfaceSetCursorPos(this, 0, x, y);
}

void CSurfaceProxy::DrawTexturedPolygon(int *p, int n)
void CSurfaceProxy::DrawTexturedPolygon(vgui::VGuiVertex*p, int n)
{
g_pSurface->DrawTexturedPolygon(p, n);
}
Expand Down Expand Up @@ -979,7 +979,7 @@ class CSurfaceProxy_HL25 : public ISurface_HL25
bool HasCursorPosFunctions(void) override;
void SurfaceGetCursorPos(int& x, int& y) override;
void SurfaceSetCursorPos(int x, int y) override;
void DrawTexturedPolygon(int* p, int n) override;
void DrawTexturedPolygon(vgui::VGuiVertex* p, int n) override;
int GetFontAscent(HFont font, wchar_t wch) override;
void SetAllowHTMLJavaScript(bool state) override;
void SetLanguage(const char* szLanguage) override;
Expand Down Expand Up @@ -1668,7 +1668,7 @@ void CSurfaceProxy_HL25::SurfaceSetCursorPos(int x, int y)
return m_pfnSurfaceSetCursorPos(this, 0, x, y);
}

void CSurfaceProxy_HL25::DrawTexturedPolygon(int *p, int n)
void CSurfaceProxy_HL25::DrawTexturedPolygon(vgui::VGuiVertex*p, int n)
{
g_pSurface_HL25->DrawTexturedPolygon(p, n);
}
Expand Down
3 changes: 2 additions & 1 deletion include/VGUI/IEngineSurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#endif

#include "tier1/interface.h"
#include <VGuiVertex.h>

class IEngineSurface : public IBaseInterface
{
Expand All @@ -16,7 +17,7 @@ class IEngineSurface : public IBaseInterface
virtual void drawOutlinedRect(int x0, int y0, int x1, int y1) = 0;
virtual void drawLine(int x0, int y0, int x1, int y1) = 0;
virtual void drawPolyLine(int *px, int *py, int numPoints) = 0;
virtual void drawTexturedPolygon(int *p, int n) = 0;
virtual void drawTexturedPolygon(vgui::VGuiVertex*p, int n) = 0;
virtual void drawSetTextureRGBA(int id, const unsigned char *rgba, int wide, int tall, int hardwareFilter, bool forceReload) = 0;
virtual void drawSetTexture(int id) = 0;
virtual void drawTexturedRect(int x0, int y0, int x1, int y1) = 0;
Expand Down
3 changes: 2 additions & 1 deletion include/VGUI/ISurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#endif

#include "VGUI.h"
#include "VGuiVertex.h"
#include "IHTML.h"
#include <interface.h>

Expand Down Expand Up @@ -153,7 +154,7 @@ namespace vgui
virtual bool HasCursorPosFunctions(void) = 0;
virtual void SurfaceGetCursorPos(int &x, int &y) = 0;
virtual void SurfaceSetCursorPos(int x, int y) = 0;
virtual void DrawTexturedPolygon(int *p, int n) = 0;
virtual void DrawTexturedPolygon(vgui::VGuiVertex*p, int n) = 0;
virtual int GetFontAscent(HFont font, wchar_t wch) = 0;
virtual void SetAllowHTMLJavaScript(bool state) = 0;
virtual void SetLanguage(const char * szLanguage) = 0;
Expand Down
75 changes: 75 additions & 0 deletions include/VGUI/VGuiVertex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//========= Copyright ?1996-2003, Valve LLC, All rights reserved. ============
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================

#ifndef VGUIVERTEX_H
#define VGUIVERTEX_H

#ifdef _WIN32
#pragma once
#endif

namespace vgui
{
class VGuiVertex
{
public:
VGuiVertex()
{
SetVertex(0,0,0,0);
}

VGuiVertex( int x, int y, float u, float v )
{
SetVertex( x, y, u, v );
}

void SetX( int i ) { x = i; }
void SetY( int i ) { y = i; }
void SetU( float f ) { u = f; }
void SetV( float f ) { v = f; }
void SetVertex( int x, int y )
{
SetX( x );
SetY( y );
}
void SetVertex( int x, int y, float u, float v )
{
SetX( x );
SetY( y );
SetU( u );
SetV( v );
}

int GetX() { return x; }
int GetY() { return y; }
float GetU() { return u; }
float GetV() { return v; }
void GetVertex( int &x, int &y, float &u, float &v )
{
x = GetX();
y = GetY();
u = GetU();
v = GetV();
}

bool operator==( VGuiVertex &from )
{
return (from.x == x && from.y == y && from.u == u && from.v == v);
}

private:
int x, y;
float u, v;
};
}

#endif // VGUIVERTEX_H
2 changes: 1 addition & 1 deletion thirdparty/FreeImage_clone

0 comments on commit 9ba29c6

Please sign in to comment.