DDraceNetwork Docs
graphics.h
Go to the documentation of this file.
1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3#ifndef ENGINE_GRAPHICS_H
4#define ENGINE_GRAPHICS_H
5
6#include "image.h"
7#include "kernel.h"
8#include "warning.h"
9
10#include <base/color.h>
11#include <base/system.h>
12
13#include <cstddef>
14#include <cstdint>
15#include <functional>
16#include <vector>
17
18#define GRAPHICS_TYPE_UNSIGNED_BYTE 0x1401
19#define GRAPHICS_TYPE_UNSIGNED_SHORT 0x1403
20#define GRAPHICS_TYPE_INT 0x1404
21#define GRAPHICS_TYPE_UNSIGNED_INT 0x1405
22#define GRAPHICS_TYPE_FLOAT 0x1406
23
25{
28
29 // the attributes of the container
31 {
33 unsigned int m_Type;
35 void *m_pOffset;
36
37 //0: float, 1:integer
38 unsigned int m_FuncType;
39 };
40 std::vector<SAttribute> m_vAttributes;
41};
42
44{
48 // allows easier upload for uniform buffers because of the alignment requirements
49 float m_Padding;
50};
51
53{
58};
59
61{
66};
67
68/*
69 Structure: CVideoMode
70*/
72{
73public:
78 uint32_t m_Format;
79};
80
83
85{
87 {
88 u = TexCoord.u;
89 v = TexCoord.v;
90 return *this;
91 }
92
93 GL_STexCoord3D &operator=(const vec3 &TexCoord)
94 {
95 u = TexCoord.u;
96 v = TexCoord.v;
97 w = TexCoord.w;
98 return *this;
99 }
100
101 float u, v, w;
102};
103
105//use normalized color values
107
109{
113};
114
116{
120};
121
123{
127};
128
129static constexpr size_t gs_GraphicsMaxQuadsRenderCount = 256;
130static constexpr size_t gs_GraphicsMaxParticlesRenderCount = 512;
131
133{
137
139};
140
142{
146
147 // special value to tell the backend to identify the current backend
149
151};
152
154{
156 {
161
162 // should stay at last position in this enum
164 };
165
167 {
168 char m_aName[256];
170 };
171 std::vector<STWGraphicGpuItem> m_vGpus;
173};
174
176
177typedef std::function<void()> WINDOW_RESIZE_FUNC;
178typedef std::function<void()> WINDOW_PROPS_CHANGED_FUNC;
179
180typedef std::function<bool(uint32_t &Width, uint32_t &Height, CImageInfo::EImageFormat &Format, std::vector<uint8_t> &vDstData)> TGLBackendReadPresentedImageData;
181
182class IGraphics : public IInterface
183{
184 MACRO_INTERFACE("graphics")
185protected:
190
191public:
192 enum
193 {
197 };
198
200 {
201 friend class IGraphics;
202 int m_Id;
203
204 public:
206 m_Id(-1)
207 {
208 }
209
210 bool IsValid() const { return Id() >= 0; }
211 bool IsNullTexture() const { return Id() == 0; }
212 int Id() const { return m_Id; }
213 void Invalidate() { m_Id = -1; }
214 };
215
216 int ScreenWidth() const { return m_ScreenWidth; }
217 int ScreenHeight() const { return m_ScreenHeight; }
218 float ScreenAspect() const { return (float)ScreenWidth() / (float)ScreenHeight(); }
219 float ScreenHiDPIScale() const { return m_ScreenHiDPIScale; }
222
223 virtual void WarnPngliteIncompatibleImages(bool Warn) = 0;
224 virtual void SetWindowParams(int FullscreenMode, bool IsBorderless) = 0;
225 virtual bool SetWindowScreen(int Index) = 0;
226 virtual bool SetVSync(bool State) = 0;
227 virtual bool SetMultiSampling(uint32_t ReqMultiSamplingCount, uint32_t &MultiSamplingCountBackend) = 0;
228 virtual int GetWindowScreen() = 0;
229 virtual void Move(int x, int y) = 0;
230 virtual bool Resize(int w, int h, int RefreshRate) = 0;
231 virtual void ResizeToScreen() = 0;
232 virtual void GotResized(int w, int h, int RefreshRate) = 0;
233 virtual void UpdateViewport(int X, int Y, int W, int H, bool ByResize) = 0;
234
244
245 virtual void WindowDestroyNtf(uint32_t WindowId) = 0;
246 virtual void WindowCreateNtf(uint32_t WindowId) = 0;
247
248 // ForceClearNow forces the backend to trigger a clear, even at performance cost, else it might be delayed by one frame
249 virtual void Clear(float r, float g, float b, bool ForceClearNow = false) = 0;
250
251 virtual void ClipEnable(int x, int y, int w, int h) = 0;
252 virtual void ClipDisable() = 0;
253
254 virtual void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY) = 0;
255 virtual void GetScreen(float *pTopLeftX, float *pTopLeftY, float *pBottomRightX, float *pBottomRightY) = 0;
256
257 // TODO: These should perhaps not be virtuals
258 virtual void BlendNone() = 0;
259 virtual void BlendNormal() = 0;
260 virtual void BlendAdditive() = 0;
261 virtual void WrapNormal() = 0;
262 virtual void WrapClamp() = 0;
263
264 virtual uint64_t TextureMemoryUsage() const = 0;
265 virtual uint64_t BufferMemoryUsage() const = 0;
266 virtual uint64_t StreamedMemoryUsage() const = 0;
267 virtual uint64_t StagingMemoryUsage() const = 0;
268
269 virtual const TTwGraphicsGpuList &GetGpus() const = 0;
270
271 virtual bool LoadPng(CImageInfo &Image, const char *pFilename, int StorageType) = 0;
272 virtual bool LoadPng(CImageInfo &Image, const uint8_t *pData, size_t DataSize, const char *pContextName) = 0;
273
274 virtual bool CheckImageDivisibility(const char *pContextName, CImageInfo &Image, int DivX, int DivY, bool AllowResize) = 0;
275 virtual bool IsImageFormatRgba(const char *pContextName, const CImageInfo &Image) = 0;
276
277 virtual void UnloadTexture(CTextureHandle *pIndex) = 0;
278 virtual CTextureHandle LoadTextureRaw(const CImageInfo &Image, int Flags, const char *pTexName = nullptr) = 0;
279 virtual CTextureHandle LoadTextureRawMove(CImageInfo &Image, int Flags, const char *pTexName = nullptr) = 0;
280 virtual CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) = 0;
281 virtual void TextureSet(CTextureHandle Texture) = 0;
283
284 // pTextData & pTextOutlineData are automatically free'd
285 virtual bool LoadTextTextures(size_t Width, size_t Height, CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture, uint8_t *pTextData, uint8_t *pTextOutlineData) = 0;
286 virtual bool UnloadTextTextures(CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture) = 0;
287 virtual bool UpdateTextTexture(CTextureHandle TextureId, int x, int y, size_t Width, size_t Height, uint8_t *pData, bool IsMovedPointer) = 0;
288
289 virtual CTextureHandle LoadSpriteTexture(const CImageInfo &FromImageInfo, const struct CDataSprite *pSprite) = 0;
290
291 virtual bool IsImageSubFullyTransparent(const CImageInfo &FromImageInfo, int x, int y, int w, int h) = 0;
292 virtual bool IsSpriteTextureFullyTransparent(const CImageInfo &FromImageInfo, const struct CDataSprite *pSprite) = 0;
293
294 virtual void FlushVertices(bool KeepVertices = false) = 0;
295 virtual void FlushVerticesTex3D() = 0;
296
297 // specific render functions
298 virtual void RenderTileLayer(int BufferContainerIndex, const ColorRGBA &Color, char **pOffsets, unsigned int *pIndicedVertexDrawNum, size_t NumIndicesOffset) = 0;
299 virtual void RenderBorderTiles(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Scale, uint32_t DrawNum) = 0;
300 virtual void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, size_t QuadNum, int QuadOffset) = 0;
301 virtual void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor) = 0;
302
303 // opengl 3.3 functions
304
306 {
307 // tell the backend that the buffer only needs to be valid for the span of one frame. Buffer size is not allowed to be bigger than GL_SVertex * MAX_VERTICES
309 };
310
311 // if a pointer is passed as moved pointer, it requires to be allocated with malloc()
312 virtual int CreateBufferObject(size_t UploadDataSize, void *pUploadData, int CreateFlags, bool IsMovedPointer = false) = 0;
313 virtual void RecreateBufferObject(int BufferIndex, size_t UploadDataSize, void *pUploadData, int CreateFlags, bool IsMovedPointer = false) = 0;
314 virtual void DeleteBufferObject(int BufferIndex) = 0;
315
316 virtual int CreateBufferContainer(struct SBufferContainerInfo *pContainerInfo) = 0;
317 // destroying all buffer objects means, that all referenced VBOs are destroyed automatically, so the user does not need to save references to them
318 virtual void DeleteBufferContainer(int &ContainerIndex, bool DestroyAllBO = true) = 0;
319 virtual void IndicesNumRequiredNotify(unsigned int RequiredIndicesCount) = 0;
320
321 // returns true if the driver age type is supported, passing BACKEND_TYPE_AUTO for BackendType will query the values for the currently used backend
322 virtual bool GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch, const char *&pName, EBackendType BackendType) = 0;
323 virtual bool IsConfigModernAPI() = 0;
324 virtual bool IsTileBufferingEnabled() = 0;
325 virtual bool IsQuadBufferingEnabled() = 0;
326 virtual bool IsTextBufferingEnabled() = 0;
328 virtual bool Uses2DTextureArrays() = 0;
329 virtual bool HasTextureArraysSupport() = 0;
330
331 virtual const char *GetVendorString() = 0;
332 virtual const char *GetVersionString() = 0;
333 virtual const char *GetRendererString() = 0;
334
336 {
337 float m_X0, m_Y0, m_X1, m_Y1;
339 CLineItem(float x0, float y0, float x1, float y1) :
340 m_X0(x0), m_Y0(y0), m_X1(x1), m_Y1(y1) {}
341 };
342 virtual void LinesBegin() = 0;
343 virtual void LinesEnd() = 0;
344 virtual void LinesDraw(const CLineItem *pArray, int Num) = 0;
345
346 virtual void QuadsBegin() = 0;
347 virtual void QuadsEnd() = 0;
348 virtual void QuadsTex3DBegin() = 0;
349 virtual void QuadsTex3DEnd() = 0;
350 virtual void TrianglesBegin() = 0;
351 virtual void TrianglesEnd() = 0;
352 virtual void QuadsEndKeepVertices() = 0;
353 virtual void QuadsDrawCurrentVertices(bool KeepVertices = true) = 0;
354 virtual void QuadsSetRotation(float Angle) = 0;
355 virtual void QuadsSetSubset(float TopLeftU, float TopLeftV, float BottomRightU, float BottomRightV) = 0;
356 virtual void QuadsSetSubsetFree(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, int Index = -1) = 0;
357
359 {
362 CFreeformItem(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) :
363 m_X0(x0), m_Y0(y0), m_X1(x1), m_Y1(y1), m_X2(x2), m_Y2(y2), m_X3(x3), m_Y3(y3) {}
364 };
365
367 {
370 CQuadItem(float x, float y, float w, float h) :
371 m_X(x), m_Y(y), m_Width(w), m_Height(h) {}
372 void Set(float x, float y, float w, float h)
373 {
374 m_X = x;
375 m_Y = y;
376 m_Width = w;
377 m_Height = h;
378 }
379
381 {
383 }
384 };
385 virtual void QuadsDraw(CQuadItem *pArray, int Num) = 0;
386 virtual void QuadsDrawTL(const CQuadItem *pArray, int Num) = 0;
387
388 virtual void QuadsTex3DDrawTL(const CQuadItem *pArray, int Num) = 0;
389
391 virtual const GL_SColor *GetCurColor() = 0;
392
393 virtual int CreateQuadContainer(bool AutomaticUpload = true) = 0;
394 virtual void QuadContainerChangeAutomaticUpload(int ContainerIndex, bool AutomaticUpload) = 0;
395 virtual void QuadContainerUpload(int ContainerIndex) = 0;
396 virtual int QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) = 0;
397 virtual int QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) = 0;
398 virtual void QuadContainerReset(int ContainerIndex) = 0;
399 virtual void DeleteQuadContainer(int &ContainerIndex) = 0;
400 virtual void RenderQuadContainer(int ContainerIndex, int QuadDrawNum) = 0;
401 virtual void RenderQuadContainer(int ContainerIndex, int QuadOffset, int QuadDrawNum, bool ChangeWrapMode = true) = 0;
402 virtual void RenderQuadContainerEx(int ContainerIndex, int QuadOffset, int QuadDrawNum, float X, float Y, float ScaleX = 1.f, float ScaleY = 1.f) = 0;
403 virtual void RenderQuadContainerAsSprite(int ContainerIndex, int QuadOffset, float X, float Y, float ScaleX = 1.f, float ScaleY = 1.f) = 0;
404
406 {
408 float m_Scale;
410 };
411
412 virtual void RenderQuadContainerAsSpriteMultiple(int ContainerIndex, int QuadOffset, int DrawCount, SRenderSpriteInfo *pRenderInfo) = 0;
413
414 virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num) = 0;
415 virtual void QuadsText(float x, float y, float Size, const char *pText) = 0;
416
417 enum
418 {
424
429
431 };
432 virtual void DrawRectExt(float x, float y, float w, float h, float r, int Corners) = 0;
433 virtual void DrawRectExt4(float x, float y, float w, float h, ColorRGBA ColorTopLeft, ColorRGBA ColorTopRight, ColorRGBA ColorBottomLeft, ColorRGBA ColorBottomRight, float r, int Corners) = 0;
434 virtual int CreateRectQuadContainer(float x, float y, float w, float h, float r, int Corners) = 0;
435 virtual void DrawRect(float x, float y, float w, float h, ColorRGBA Color, int Corners, float Rounding) = 0;
436 virtual void DrawRect4(float x, float y, float w, float h, ColorRGBA ColorTopLeft, ColorRGBA ColorTopRight, ColorRGBA ColorBottomLeft, ColorRGBA ColorBottomRight, int Corners, float Rounding) = 0;
437 virtual void DrawCircle(float CenterX, float CenterY, float Radius, int Segments) = 0;
438
440 {
442 float m_R, m_G, m_B, m_A;
444 CColorVertex(int i, float r, float g, float b, float a) :
445 m_Index(i), m_R(r), m_G(g), m_B(b), m_A(a) {}
446 CColorVertex(int i, ColorRGBA Color) :
447 m_Index(i), m_R(Color.r), m_G(Color.g), m_B(Color.b), m_A(Color.a) {}
448 };
449 virtual void SetColorVertex(const CColorVertex *pArray, size_t Num) = 0;
450 virtual void SetColor(float r, float g, float b, float a) = 0;
451 virtual void SetColor(ColorRGBA Color) = 0;
452 virtual void SetColor4(ColorRGBA TopLeft, ColorRGBA TopRight, ColorRGBA BottomLeft, ColorRGBA BottomRight) = 0;
453 virtual void ChangeColorOfCurrentQuadVertices(float r, float g, float b, float a) = 0;
454 virtual void ChangeColorOfQuadVertices(size_t QuadOffset, unsigned char r, unsigned char g, unsigned char b, unsigned char a) = 0;
455
464 virtual void ReadPixel(ivec2 Position, ColorRGBA *pColor) = 0;
465 virtual void TakeScreenshot(const char *pFilename) = 0;
466 virtual void TakeCustomScreenshot(const char *pFilename) = 0;
467 virtual int GetVideoModes(CVideoMode *pModes, int MaxModes, int Screen) = 0;
468 virtual void GetCurrentVideoMode(CVideoMode &CurMode, int Screen) = 0;
469 virtual void Swap() = 0;
470 virtual int GetNumScreens() const = 0;
471 virtual const char *GetScreenName(int Screen) const = 0;
472
473 // synchronization
474 virtual void InsertSignal(class CSemaphore *pSemaphore) = 0;
475 virtual bool IsIdle() const = 0;
476 virtual void WaitForIdle() = 0;
477
478 virtual void SetWindowGrab(bool Grab) = 0;
479 virtual void NotifyWindow() = 0;
480
481 // be aware that this function should only be called from the graphics thread, and even then you should really know what you are doing
482 // this function always returns the pixels in RGB
484
485 virtual SWarning *GetCurWarning() = 0;
486
487 // returns true if the error msg was shown
488 virtual bool ShowMessageBox(unsigned Type, const char *pTitle, const char *pMsg) = 0;
489 virtual bool IsBackendInitialized() = 0;
490
491protected:
493 {
494 CTextureHandle Tex;
495 Tex.m_Id = Index;
496 return Tex;
497 }
498};
499
501{
502 MACRO_INTERFACE("enginegraphics")
503public:
504 virtual int Init() = 0;
505 virtual void Shutdown() override = 0;
506
507 virtual void Minimize() = 0;
508 virtual void Maximize() = 0;
509
510 virtual int WindowActive() = 0;
511 virtual int WindowOpen() = 0;
512};
513
515
516#endif
Definition: image.h:12
EImageFormat
Definition: image.h:18
Definition: threading.h:8
Definition: graphics.h:72
int m_RefreshRate
Definition: graphics.h:76
uint32_t m_Format
Definition: graphics.h:78
int m_CanvasHeight
Definition: graphics.h:74
int m_Red
Definition: graphics.h:77
int m_Blue
Definition: graphics.h:77
int m_CanvasWidth
Definition: graphics.h:74
int m_WindowHeight
Definition: graphics.h:75
int m_Green
Definition: graphics.h:77
int m_WindowWidth
Definition: graphics.h:75
Definition: color.h:210
Definition: graphics.h:501
virtual int Init()=0
virtual void Maximize()=0
virtual int WindowOpen()=0
virtual void Minimize()=0
virtual void Shutdown() override=0
virtual int WindowActive()=0
Definition: graphics.h:200
void Invalidate()
Definition: graphics.h:213
CTextureHandle()
Definition: graphics.h:205
bool IsNullTexture() const
Definition: graphics.h:211
bool IsValid() const
Definition: graphics.h:210
int m_Id
Definition: graphics.h:202
int Id() const
Definition: graphics.h:212
Definition: graphics.h:183
virtual int GetWindowScreen()=0
virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num)=0
virtual void QuadsEnd()=0
int m_ScreenWidth
Definition: graphics.h:186
virtual void AddWindowResizeListener(WINDOW_RESIZE_FUNC pFunc)=0
virtual bool GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch, const char *&pName, EBackendType BackendType)=0
virtual void QuadsSetSubsetFree(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, int Index=-1)=0
virtual bool UnloadTextTextures(CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture)=0
virtual bool IsQuadBufferingEnabled()=0
virtual void WrapNormal()=0
virtual bool IsSpriteTextureFullyTransparent(const CImageInfo &FromImageInfo, const struct CDataSprite *pSprite)=0
virtual void QuadsDrawTL(const CQuadItem *pArray, int Num)=0
virtual void QuadsDraw(CQuadItem *pArray, int Num)=0
virtual CTextureHandle LoadSpriteTexture(const CImageInfo &FromImageInfo, const struct CDataSprite *pSprite)=0
virtual int QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num)=0
virtual void WrapClamp()=0
virtual void DrawRect(float x, float y, float w, float h, ColorRGBA Color, int Corners, float Rounding)=0
virtual void TrianglesEnd()=0
virtual void GetCurrentVideoMode(CVideoMode &CurMode, int Screen)=0
virtual void WarnPngliteIncompatibleImages(bool Warn)=0
int ScreenHeight() const
Definition: graphics.h:217
virtual void BlendNormal()=0
virtual const char * GetVersionString()=0
virtual void RenderQuadContainer(int ContainerIndex, int QuadDrawNum)=0
virtual void UpdateViewport(int X, int Y, int W, int H, bool ByResize)=0
virtual bool IsIdle() const =0
virtual void QuadsSetRotation(float Angle)=0
virtual TGLBackendReadPresentedImageData & GetReadPresentedImageDataFuncUnsafe()=0
virtual void ChangeColorOfCurrentQuadVertices(float r, float g, float b, float a)=0
virtual void TextureSet(CTextureHandle Texture)=0
CTextureHandle CreateTextureHandle(int Index)
Definition: graphics.h:492
virtual uint64_t TextureMemoryUsage() const =0
virtual void TrianglesBegin()=0
virtual void TakeCustomScreenshot(const char *pFilename)=0
virtual void Move(int x, int y)=0
virtual void RenderQuadContainerAsSprite(int ContainerIndex, int QuadOffset, float X, float Y, float ScaleX=1.f, float ScaleY=1.f)=0
EBufferObjectCreateFlags
Definition: graphics.h:306
@ BUFFER_OBJECT_CREATE_FLAGS_ONE_TIME_USE_BIT
Definition: graphics.h:308
float ScreenHiDPIScale() const
Definition: graphics.h:219
virtual void SetColor4(ColorRGBA TopLeft, ColorRGBA TopRight, ColorRGBA BottomLeft, ColorRGBA BottomRight)=0
virtual CTextureHandle LoadTextureRawMove(CImageInfo &Image, int Flags, const char *pTexName=nullptr)=0
virtual bool IsQuadContainerBufferingEnabled()=0
virtual void ReadPixel(ivec2 Position, ColorRGBA *pColor)=0
virtual void BlendNone()=0
virtual bool Uses2DTextureArrays()=0
virtual SWarning * GetCurWarning()=0
virtual bool LoadTextTextures(size_t Width, size_t Height, CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture, uint8_t *pTextData, uint8_t *pTextOutlineData)=0
virtual int CreateRectQuadContainer(float x, float y, float w, float h, float r, int Corners)=0
void TextureClear()
Definition: graphics.h:282
virtual void TakeScreenshot(const char *pFilename)=0
virtual uint64_t BufferMemoryUsage() const =0
virtual void RenderBorderTiles(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Scale, uint32_t DrawNum)=0
float m_ScreenHiDPIScale
Definition: graphics.h:189
virtual uint64_t StreamedMemoryUsage() const =0
virtual void QuadsText(float x, float y, float Size, const char *pText)=0
virtual void QuadsSetSubset(float TopLeftU, float TopLeftV, float BottomRightU, float BottomRightV)=0
virtual void RecreateBufferObject(int BufferIndex, size_t UploadDataSize, void *pUploadData, int CreateFlags, bool IsMovedPointer=false)=0
virtual void QuadsTex3DEnd()=0
virtual int GetVideoModes(CVideoMode *pModes, int MaxModes, int Screen)=0
virtual const GL_STexCoord * GetCurTextureCoordinates()=0
virtual int CreateBufferObject(size_t UploadDataSize, void *pUploadData, int CreateFlags, bool IsMovedPointer=false)=0
virtual bool SetMultiSampling(uint32_t ReqMultiSamplingCount, uint32_t &MultiSamplingCountBackend)=0
virtual int GetNumScreens() const =0
virtual CTextureHandle LoadTextureRaw(const CImageInfo &Image, int Flags, const char *pTexName=nullptr)=0
int WindowWidth() const
Definition: graphics.h:220
virtual void ClipEnable(int x, int y, int w, int h)=0
virtual void RenderTileLayer(int BufferContainerIndex, const ColorRGBA &Color, char **pOffsets, unsigned int *pIndicedVertexDrawNum, size_t NumIndicesOffset)=0
virtual bool IsConfigModernAPI()=0
virtual void UnloadTexture(CTextureHandle *pIndex)=0
virtual bool SetWindowScreen(int Index)=0
virtual void LinesEnd()=0
virtual void LinesDraw(const CLineItem *pArray, int Num)=0
virtual void QuadsTex3DBegin()=0
virtual const char * GetScreenName(int Screen) const =0
virtual bool SetVSync(bool State)=0
virtual void ResizeToScreen()=0
virtual void Swap()=0
virtual const char * GetVendorString()=0
@ CORNER_NONE
Definition: graphics.h:419
@ CORNER_ALL
Definition: graphics.h:430
@ CORNER_B
Definition: graphics.h:426
@ CORNER_BR
Definition: graphics.h:423
@ CORNER_T
Definition: graphics.h:425
@ CORNER_TR
Definition: graphics.h:421
@ CORNER_R
Definition: graphics.h:427
@ CORNER_L
Definition: graphics.h:428
@ CORNER_BL
Definition: graphics.h:422
@ CORNER_TL
Definition: graphics.h:420
virtual bool IsBackendInitialized()=0
virtual int CreateQuadContainer(bool AutomaticUpload=true)=0
virtual void SetColorVertex(const CColorVertex *pArray, size_t Num)=0
virtual void DrawRectExt(float x, float y, float w, float h, float r, int Corners)=0
int m_ScreenHeight
Definition: graphics.h:187
virtual void AddWindowPropChangeListener(WINDOW_PROPS_CHANGED_FUNC pFunc)=0
virtual void QuadsTex3DDrawTL(const CQuadItem *pArray, int Num)=0
virtual void DrawRectExt4(float x, float y, float w, float h, ColorRGBA ColorTopLeft, ColorRGBA ColorTopRight, ColorRGBA ColorBottomLeft, ColorRGBA ColorBottomRight, float r, int Corners)=0
virtual void SetColor(ColorRGBA Color)=0
virtual void WindowDestroyNtf(uint32_t WindowId)=0
virtual uint64_t StagingMemoryUsage() const =0
virtual bool IsTileBufferingEnabled()=0
virtual bool IsTextBufferingEnabled()=0
virtual void GetScreen(float *pTopLeftX, float *pTopLeftY, float *pBottomRightX, float *pBottomRightY)=0
virtual void WaitForIdle()=0
virtual bool LoadPng(CImageInfo &Image, const char *pFilename, int StorageType)=0
virtual void NotifyWindow()=0
virtual void BlendAdditive()=0
virtual void QuadsBegin()=0
virtual void DeleteQuadContainer(int &ContainerIndex)=0
virtual void DeleteBufferObject(int BufferIndex)=0
virtual void DeleteBufferContainer(int &ContainerIndex, bool DestroyAllBO=true)=0
virtual void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, size_t QuadNum, int QuadOffset)=0
virtual void IndicesNumRequiredNotify(unsigned int RequiredIndicesCount)=0
virtual void WindowCreateNtf(uint32_t WindowId)=0
virtual void GotResized(int w, int h, int RefreshRate)=0
virtual bool CheckImageDivisibility(const char *pContextName, CImageInfo &Image, int DivX, int DivY, bool AllowResize)=0
virtual void RenderQuadContainer(int ContainerIndex, int QuadOffset, int QuadDrawNum, bool ChangeWrapMode=true)=0
virtual void QuadContainerChangeAutomaticUpload(int ContainerIndex, bool AutomaticUpload)=0
virtual void SetWindowParams(int FullscreenMode, bool IsBorderless)=0
virtual void FlushVerticesTex3D()=0
virtual const GL_SColor * GetCurColor()=0
virtual void DrawRect4(float x, float y, float w, float h, ColorRGBA ColorTopLeft, ColorRGBA ColorTopRight, ColorRGBA ColorBottomLeft, ColorRGBA ColorBottomRight, int Corners, float Rounding)=0
virtual void QuadsEndKeepVertices()=0
virtual void QuadsDrawCurrentVertices(bool KeepVertices=true)=0
virtual void RenderQuadContainerAsSpriteMultiple(int ContainerIndex, int QuadOffset, int DrawCount, SRenderSpriteInfo *pRenderInfo)=0
virtual CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags=0)=0
virtual int CreateBufferContainer(struct SBufferContainerInfo *pContainerInfo)=0
virtual bool HasTextureArraysSupport()=0
virtual void InsertSignal(class CSemaphore *pSemaphore)=0
virtual void RenderQuadContainerEx(int ContainerIndex, int QuadOffset, int QuadDrawNum, float X, float Y, float ScaleX=1.f, float ScaleY=1.f)=0
virtual bool Resize(int w, int h, int RefreshRate)=0
virtual void SetColor(float r, float g, float b, float a)=0
virtual int QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num)=0
virtual const char * GetRendererString()=0
virtual void FlushVertices(bool KeepVertices=false)=0
virtual void QuadContainerReset(int ContainerIndex)=0
virtual bool UpdateTextTexture(CTextureHandle TextureId, int x, int y, size_t Width, size_t Height, uint8_t *pData, bool IsMovedPointer)=0
virtual bool LoadPng(CImageInfo &Image, const uint8_t *pData, size_t DataSize, const char *pContextName)=0
virtual void ClipDisable()=0
virtual void QuadContainerUpload(int ContainerIndex)=0
@ TEXLOAD_NO_2D_TEXTURE
Definition: graphics.h:196
@ TEXLOAD_TO_3D_TEXTURE
Definition: graphics.h:194
@ TEXLOAD_TO_2D_ARRAY_TEXTURE
Definition: graphics.h:195
virtual void Clear(float r, float g, float b, bool ForceClearNow=false)=0
virtual bool ShowMessageBox(unsigned Type, const char *pTitle, const char *pMsg)=0
virtual void LinesBegin()=0
virtual void SetWindowGrab(bool Grab)=0
int m_ScreenRefreshRate
Definition: graphics.h:188
virtual bool IsImageSubFullyTransparent(const CImageInfo &FromImageInfo, int x, int y, int w, int h)=0
virtual void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY)=0
int ScreenWidth() const
Definition: graphics.h:216
virtual bool IsImageFormatRgba(const char *pContextName, const CImageInfo &Image)=0
virtual void DrawCircle(float CenterX, float CenterY, float Radius, int Segments)=0
virtual const TTwGraphicsGpuList & GetGpus() const =0
int WindowHeight() const
Definition: graphics.h:221
float ScreenAspect() const
Definition: graphics.h:218
virtual void ChangeColorOfQuadVertices(size_t QuadOffset, unsigned char r, unsigned char g, unsigned char b, unsigned char a)=0
virtual void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor)=0
Definition: kernel.h:10
T u
Definition: vmath.h:19
T v
Definition: vmath.h:23
Definition: vmath.h:182
T v
Definition: vmath.h:190
T u
Definition: vmath.h:186
T w
Definition: vmath.h:194
IEngineGraphics * CreateEngineGraphicsThreaded()
Definition: graphics_threaded.cpp:2856
vector4_base< unsigned char > GL_SColor
Definition: graphics.h:106
ColorRGBA GL_SColorf
Definition: graphics.h:104
EBackendType
Definition: graphics.h:142
@ BACKEND_TYPE_OPENGL_ES
Definition: graphics.h:144
@ BACKEND_TYPE_OPENGL
Definition: graphics.h:143
@ BACKEND_TYPE_VULKAN
Definition: graphics.h:145
@ BACKEND_TYPE_AUTO
Definition: graphics.h:148
@ BACKEND_TYPE_COUNT
Definition: graphics.h:150
EGraphicsDriverAgeType
Definition: graphics.h:133
@ GRAPHICS_DRIVER_AGE_TYPE_DEFAULT
Definition: graphics.h:135
@ GRAPHICS_DRIVER_AGE_TYPE_COUNT
Definition: graphics.h:138
@ GRAPHICS_DRIVER_AGE_TYPE_MODERN
Definition: graphics.h:136
@ GRAPHICS_DRIVER_AGE_TYPE_LEGACY
Definition: graphics.h:134
std::function< bool(uint32_t &Width, uint32_t &Height, CImageInfo::EImageFormat &Format, std::vector< uint8_t > &vDstData)> TGLBackendReadPresentedImageData
Definition: graphics.h:180
std::function< void()> WINDOW_RESIZE_FUNC
Definition: graphics.h:177
STWGraphicGpu TTwGraphicsGpuList
Definition: graphics.h:175
static constexpr size_t gs_GraphicsMaxParticlesRenderCount
Definition: graphics.h:130
vec2 GL_SPoint
Definition: graphics.h:81
static constexpr size_t gs_GraphicsMaxQuadsRenderCount
Definition: graphics.h:129
vec2 GL_STexCoord
Definition: graphics.h:82
std::function< void()> WINDOW_PROPS_CHANGED_FUNC
Definition: graphics.h:178
#define MACRO_INTERFACE(Name)
Definition: kernel.h:25
Definition: client_data.h:29
Definition: graphics.h:85
float v
Definition: graphics.h:101
GL_STexCoord3D & operator=(const GL_STexCoord &TexCoord)
Definition: graphics.h:86
float u
Definition: graphics.h:101
GL_STexCoord3D & operator=(const vec3 &TexCoord)
Definition: graphics.h:93
float w
Definition: graphics.h:101
Definition: graphics.h:123
GL_SColor m_Color
Definition: graphics.h:125
GL_STexCoord3D m_Tex
Definition: graphics.h:126
GL_SPoint m_Pos
Definition: graphics.h:124
Definition: graphics.h:116
GL_STexCoord3D m_Tex
Definition: graphics.h:119
GL_SPoint m_Pos
Definition: graphics.h:117
GL_SColorf m_Color
Definition: graphics.h:118
Definition: graphics.h:109
GL_SColor m_Color
Definition: graphics.h:112
GL_SPoint m_Pos
Definition: graphics.h:110
GL_STexCoord m_Tex
Definition: graphics.h:111
Definition: graphics.h:440
float m_B
Definition: graphics.h:442
float m_A
Definition: graphics.h:442
CColorVertex(int i, ColorRGBA Color)
Definition: graphics.h:446
CColorVertex()
Definition: graphics.h:443
float m_R
Definition: graphics.h:442
float m_G
Definition: graphics.h:442
CColorVertex(int i, float r, float g, float b, float a)
Definition: graphics.h:444
int m_Index
Definition: graphics.h:441
Definition: graphics.h:359
float m_X2
Definition: graphics.h:360
float m_X0
Definition: graphics.h:360
float m_Y1
Definition: graphics.h:360
float m_Y0
Definition: graphics.h:360
float m_Y3
Definition: graphics.h:360
float m_X3
Definition: graphics.h:360
CFreeformItem(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
Definition: graphics.h:362
float m_X1
Definition: graphics.h:360
CFreeformItem()
Definition: graphics.h:361
float m_Y2
Definition: graphics.h:360
Definition: graphics.h:336
float m_X0
Definition: graphics.h:337
float m_X1
Definition: graphics.h:337
float m_Y1
Definition: graphics.h:337
CLineItem(float x0, float y0, float x1, float y1)
Definition: graphics.h:339
float m_Y0
Definition: graphics.h:337
CLineItem()
Definition: graphics.h:338
Definition: graphics.h:367
CQuadItem(float x, float y, float w, float h)
Definition: graphics.h:370
float m_Y
Definition: graphics.h:368
CQuadItem()
Definition: graphics.h:369
float m_Height
Definition: graphics.h:368
float m_X
Definition: graphics.h:368
void Set(float x, float y, float w, float h)
Definition: graphics.h:372
float m_Width
Definition: graphics.h:368
CFreeformItem ToFreeForm() const
Definition: graphics.h:380
Definition: graphics.h:406
vec2 m_Pos
Definition: graphics.h:407
float m_Rotation
Definition: graphics.h:409
float m_Scale
Definition: graphics.h:408
Definition: graphics.h:31
unsigned int m_FuncType
Definition: graphics.h:38
unsigned int m_Type
Definition: graphics.h:33
bool m_Normalized
Definition: graphics.h:34
void * m_pOffset
Definition: graphics.h:35
int m_DataTypeCount
Definition: graphics.h:32
Definition: graphics.h:25
int m_VertBufferBindingIndex
Definition: graphics.h:27
int m_Stride
Definition: graphics.h:26
std::vector< SAttribute > m_vAttributes
Definition: graphics.h:40
Definition: graphics.h:61
ubvec4 m_TexCoordTopRight
Definition: graphics.h:63
ubvec4 m_TexCoordBottomRight
Definition: graphics.h:64
ubvec4 m_TexCoordTopLeft
Definition: graphics.h:62
ubvec4 m_TexCoordBottomLeft
Definition: graphics.h:65
Definition: graphics.h:53
vec2 m_TopLeft
Definition: graphics.h:54
vec2 m_BottomLeft
Definition: graphics.h:57
vec2 m_BottomRight
Definition: graphics.h:56
vec2 m_TopRight
Definition: graphics.h:55
Definition: graphics.h:44
vec2 m_Offsets
Definition: graphics.h:46
float m_Padding
Definition: graphics.h:49
float m_Rotation
Definition: graphics.h:47
ColorRGBA m_Color
Definition: graphics.h:45
Definition: graphics.h:167
ETWGraphicsGpuType m_GpuType
Definition: graphics.h:169
char m_aName[256]
Definition: graphics.h:168
Definition: graphics.h:154
ETWGraphicsGpuType
Definition: graphics.h:156
@ GRAPHICS_GPU_TYPE_INTEGRATED
Definition: graphics.h:158
@ GRAPHICS_GPU_TYPE_INVALID
Definition: graphics.h:163
@ GRAPHICS_GPU_TYPE_DISCRETE
Definition: graphics.h:157
@ GRAPHICS_GPU_TYPE_VIRTUAL
Definition: graphics.h:159
@ GRAPHICS_GPU_TYPE_CPU
Definition: graphics.h:160
std::vector< STWGraphicGpuItem > m_vGpus
Definition: graphics.h:171
STWGraphicGpuItem m_AutoGpu
Definition: graphics.h:172
Definition: warning.h:5