-
-
Notifications
You must be signed in to change notification settings - Fork 557
Expand file tree
/
Copy pathCGraphicsInterface.h
More file actions
206 lines (168 loc) · 9.31 KB
/
Copy pathCGraphicsInterface.h
File metadata and controls
206 lines (168 loc) · 9.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*****************************************************************************
*
* PROJECT: Multi Theft Auto v1.0
* LICENSE: See LICENSE in the top level directory
* FILE: sdk/core/CGraphicsInterface.h
* PURPOSE: Graphics subsystem interface
*
* Multi Theft Auto is available from https://www.multitheftauto.com/
*
*****************************************************************************/
#pragma once
#include "CVector.h"
#include <d3d9.h>
// Vertex type used by the primitives batchers
struct PrimitiveVertice
{
static const uint FNV = D3DFVF_XYZ | D3DFVF_DIFFUSE;
float fX, fY, fZ;
D3DCOLOR Color;
};
struct PrimitiveMaterialVertice
{
static const uint FNV = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1;
float fX, fY, fZ;
D3DCOLOR Color;
float u, v;
};
enum PrimitiveVerticeSizes
{
VERT_XY = 2,
VERT_XY_COLOR = 3,
VERT_XY_UV = 4,
VERT_XY_COLOR_UV = 5
};
enum Primitive3DVerticeSizes
{
VERT_XYZ = 3,
VERT_XYZ_COLOR,
VERT_XYZ_UV,
VERT_XYZ_COLOR_UV,
};
struct ID3DXFont;
struct IDirect3DDevice9;
struct IDirect3DTexture9;
enum eFontType
{
FONT_DEFAULT = 0,
FONT_DEFAULT_BOLD,
FONT_CLEAR,
FONT_ARIAL,
FONT_SANS,
FONT_PRICEDOWN,
FONT_BANKGOTHIC,
FONT_DIPLOMA,
FONT_BECKETT,
FONT_UNIFONT,
NUM_FONTS
};
enum eFontQuality
{
FONT_QUALITY_DEFAULT = DEFAULT_QUALITY,
FONT_QUALITY_DRAFT = DRAFT_QUALITY,
FONT_QUALITY_PROOF = PROOF_QUALITY,
#if (WINVER >= 0x0400)
FONT_QUALITY_NONANTIALIASED = NONANTIALIASED_QUALITY,
FONT_QUALITY_ANTIALIASED = ANTIALIASED_QUALITY,
#endif
#if (_WIN32_WINNT >= _WIN32_WINNT_WINXP)
FONT_QUALITY_CLEARTYPE = CLEARTYPE_QUALITY,
FONT_QUALITY_CLEARTYPE_NATURAL = CLEARTYPE_NATURAL_QUALITY,
#endif
NUM_QUALITIES
};
namespace EBlendMode
{
enum EBlendModeType
{
NONE,
BLEND, // Alpha blend
ADD, // Color add (used for making composite textures with a premultiplied source)
MODULATE_ADD, // Modulate color with alpha then add (used for making composite textures with a non-premultiplied source)
OVERWRITE, // Blat everything
RT_TEXTURE, // Draw render target texture to screen (premultiplied-alpha source, avoids double-alpha compositing)
};
}
using EBlendMode::EBlendModeType;
enum class eRenderStage
{
PRE_FX,
POST_FX,
POST_GUI
};
class CGraphicsInterface
{
public:
virtual IDirect3DDevice9* GetDevice() = 0;
virtual void CalcWorldCoors(CVector* vecScreen, CVector* vecWorld) = 0;
virtual void CalcScreenCoors(CVector* vecWorld, CVector* vecScreen) = 0;
virtual void DrawString(int iLeft, int iTop, int iRight, int iBottom, unsigned long dwColor, const char* wszText, float fScaleX, float fScaleY,
unsigned long ulFormat, ID3DXFont* pDXFont = NULL, bool bOutline = false) = 0;
virtual void DrawString(int iX, int iY, unsigned long dwColor, float fScale, const char* szText, ...) = 0;
virtual void DrawLine3D(const CVector& vecBegin, const CVector& vecEnd, unsigned long ulColor, float fWidth = 1.0f) = 0;
virtual void DrawRectangle(float fX, float fY, float fWidth, float fHeight, unsigned long ulColor, bool bSubPixelPositioning = false) = 0;
virtual void SetBlendMode(EBlendModeType blendMode) = 0;
virtual EBlendModeType GetBlendMode() = 0;
virtual unsigned int GetViewportWidth() = 0;
virtual unsigned int GetViewportHeight() = 0;
virtual void SetAspectRatioAdjustmentEnabled(bool bEnabled, float fSourceRatio = 4 / 3.f) = 0;
virtual bool IsAspectRatioAdjustmentEnabled() = 0;
virtual float GetAspectRatioAdjustmentSourceRatio() = 0;
virtual void SetAspectRatioAdjustmentSuspended(bool bSuspended) = 0;
virtual float ConvertPositionForAspectRatio(float fY) = 0;
virtual void ConvertSideForAspectRatio(float* pfY, float* pfHeight) = 0;
virtual float GetDXFontHeight(float fScale = 1.0f, ID3DXFont* pDXFont = NULL) = 0;
virtual float GetDXCharacterWidth(char c, float fScale = 1.0f, ID3DXFont* pDXFont = NULL) = 0;
virtual float GetDXTextExtent(const char* szText, float fScale = 1.0f, ID3DXFont* pDXFont = NULL, bool bColorCoded = false) = 0;
virtual void GetDXTextSize(CVector2D& vecSize, const char* szText, float fWidth = 0, float fScaleX = 1.0f, float fScaleY = 1.0f,
ID3DXFont* pDXFont = nullptr, bool bWordBreak = false, bool bColorCoded = false) = 0;
virtual bool LoadAdditionalDXFont(std::string strFontPath, std::string strFontName, unsigned int uiHeight, bool bBold, ID3DXFont** ppD3DXFont) = 0;
virtual bool LoadAdditionalDXFont(std::string strFontPath, std::string strFontName, unsigned int uiHeight, bool bBold, DWORD ulQuality,
ID3DXFont** ppD3DXFont) = 0;
virtual bool DestroyAdditionalDXFont(std::string strFontPath, ID3DXFont* pD3DXFont) = 0;
virtual ID3DXFont* GetFont(eFontType fontType = FONT_DEFAULT, float* pfOutScaleUsed = NULL, float fRequestedScale = 1,
const char* szCustomScaleUser = NULL) = 0;
virtual void DrawTexture(CTextureItem* texture, float fX, float fY, float fScaleX = 1.0f, float fScaleY = 1.0f, float fRotation = 0.0f,
float fCenterX = 0.0f, float fCenterY = 0.0f, DWORD dwColor = 0xFFFFFFFF, float fU = 0, float fV = 0, float fSizeU = 1,
float fSizeV = 1, bool bRelativeUV = true) = 0;
// Queued up drawing
virtual void DrawLineQueued(float fX1, float fY1, float fX2, float fY2, float fWidth, unsigned long ulColor, bool bPostGUI) = 0;
virtual void DrawLine3DQueued(const CVector& vecBegin, const CVector& vecEnd, float fWidth, unsigned long ulColor,
eRenderStage stage = eRenderStage::PRE_FX) = 0;
virtual void DrawMaterialLine3DQueued(const CVector& vecBegin, const CVector& vecEnd, float fWidth, unsigned long ulColor, CMaterialItem* pMaterial,
float fU = 0, float fV = 0, float fSizeU = 1, float fSizeV = 1, bool bRelativeUV = true, bool bFlipUV = false,
bool bUseFaceToward = false, const CVector& vecFaceToward = CVector(),
eRenderStage renderStage = eRenderStage::POST_FX) = 0;
virtual void DrawRectQueued(float fX, float fY, float fWidth, float fHeight, unsigned long ulColor, bool bPostGUI, bool bSubPixelPositioning = false) = 0;
virtual void DrawTextureQueued(float fX, float fY, float fWidth, float fHeight, float fU, float fV, float fSizeU, float fSizeV, bool bRelativeUV,
CMaterialItem* pMaterial, float fRotation, float fRotCenOffX, float fRotCenOffY, unsigned long ulColor, bool bPostGUI) = 0;
virtual void DrawStringQueued(float fLeft, float fTop, float fRight, float fBottom, unsigned long dwColor, const char* wszText, float fScaleX,
float fScaleY, unsigned long ulFormat, ID3DXFont* pDXFont, bool bPostGUI, bool bColorCoded = false,
bool bSubPixelPositioning = false, float fRotation = 0, float fRotationCenterX = 0, float fRotationCenterY = 0,
float fLineHeight = 0) = 0;
virtual void DrawPrimitiveQueued(std::vector<PrimitiveVertice>* pVecVertices, D3DPRIMITIVETYPE eType, bool bPostGUI) = 0;
virtual void DrawMaterialPrimitiveQueued(std::vector<PrimitiveMaterialVertice>* pVecVertices, D3DPRIMITIVETYPE eType, CMaterialItem* pMaterial,
bool bPostGUI) = 0;
virtual void DrawPrimitive3DQueued(std::vector<PrimitiveVertice>* pVecVertices, D3DPRIMITIVETYPE eType, eRenderStage stage = eRenderStage::PRE_FX) = 0;
virtual void DrawMaterialPrimitive3DQueued(std::vector<PrimitiveMaterialVertice>* pVecVertices, D3DPRIMITIVETYPE eType, CMaterialItem* pMaterial,
eRenderStage stage = eRenderStage::PRE_FX) = 0;
virtual void DrawCircleQueued(float fX, float fY, float fRadius, float fStartAngle, float fStopAngle, unsigned long ulColor, unsigned long ulColorCenter,
short siSegments, float fRatio, bool bPostGUI) = 0;
virtual void DrawWiredSphere(CVector vecPosition, float fRadius, SColor color, float fLineWidth, int iterations) = 0;
virtual bool IsValidPrimitiveSize(int iNumVertives, D3DPRIMITIVETYPE eType) = 0;
// Subsystems
virtual CRenderItemManagerInterface* GetRenderItemManager() = 0;
virtual CScreenGrabberInterface* GetScreenGrabber() = 0;
virtual CPixelsManagerInterface* GetPixelsManager() = 0;
// Transition between GTA and MTA controlled rendering
virtual void EnteringMTARenderZone() = 0;
virtual void LeavingMTARenderZone() = 0;
virtual void MaybeEnteringMTARenderZone() = 0;
virtual void MaybeLeavingMTARenderZone() = 0;
virtual void MarkViewportRefreshPending() = 0;
virtual void RefreshViewportIfNeeded() = 0;
virtual void ApplyMTARenderViewportIfNeeded() = 0;
// Texture data manipulation
virtual bool ResizeTextureData(const void* pData, uint uiDataPitch, uint uiWidth, uint uiHeight, uint d3dFormat, uint uiNewWidth, uint uiNewHeight,
CBuffer& outBuffer) = 0;
};