DDNet documentation
Loading...
Searching...
No Matches
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/vmath.h>
12
13#include <cstddef>
14#include <cstdint>
15#include <functional>
16#include <optional>
17#include <vector>
18
19#define GRAPHICS_TYPE_UNSIGNED_BYTE 0x1401
20#define GRAPHICS_TYPE_UNSIGNED_SHORT 0x1403
21#define GRAPHICS_TYPE_INT 0x1404
22#define GRAPHICS_TYPE_UNSIGNED_INT 0x1405
23#define GRAPHICS_TYPE_FLOAT 0x1406
24
26{
29
30 // the attributes of the container
32 {
34 unsigned int m_Type;
36 void *m_pOffset;
37
38 //0: float, 1:integer
39 unsigned int m_FuncType;
40 };
41 std::vector<SAttribute> m_vAttributes;
42};
43
45{
49 // allows easier upload for uniform buffers because of the alignment requirements
50 float m_Padding;
51};
52
61
70
71/*
72 Structure: CVideoMode
73*/
81
84
86{
88 {
89 u = TexCoord.u;
90 v = TexCoord.v;
91 return *this;
92 }
93
94 GL_STexCoord3D &operator=(const vec3 &TexCoord)
95 {
96 u = TexCoord.u;
97 v = TexCoord.v;
98 w = TexCoord.w;
99 return *this;
100 }
101
102 float u, v, w;
103};
104
106//use normalized color values
108
115
122
129
130static constexpr size_t GRAPHICS_MAX_QUADS_RENDER_COUNT = 256;
131static constexpr size_t GRAPHICS_MAX_PARTICLES_RENDER_COUNT = 512;
132
141
143{
147
148 // special value to tell the backend to identify the current backend
150
152};
153
175
177
178typedef std::function<void()> WINDOW_RESIZE_FUNC;
179typedef std::function<void()> WINDOW_PROPS_CHANGED_FUNC;
180
181typedef std::function<bool(uint32_t &Width, uint32_t &Height, CImageInfo::EImageFormat &Format, std::vector<uint8_t> &vDstData)> TGLBackendReadPresentedImageData;
182
183struct CDataSprite;
184
186{
187public:
188 CScreenRect(float Left, float Top, float Width, float Height) :
189 m_TopLeft(Left, Top), m_BottomRight(Left + Width, Top + Height) {}
190
191 CScreenRect(const vec2 &TopLeft, const vec2 &BottomRight) :
192 m_TopLeft(TopLeft), m_BottomRight(BottomRight) {}
193
194 CScreenRect Move(const vec2 &Position) const
195 {
196 CScreenRect Rect(*this);
197 Rect.m_TopLeft += Position;
198 Rect.m_BottomRight += Position;
199 return Rect;
200 }
201
202 constexpr vec2 Size() const
203 {
204 return m_BottomRight - m_TopLeft;
205 }
206
207 constexpr float Width() const
208 {
209 return m_BottomRight.x - m_TopLeft.x;
210 }
211
212 constexpr float Height() const
213 {
214 return m_BottomRight.y - m_TopLeft.y;
215 }
216
217 constexpr bool Inside(const vec2 &Position) const
218 {
219 return !(!in_range(Position.x, m_TopLeft.x, m_BottomRight.x) || !in_range(Position.y, m_TopLeft.y, m_BottomRight.y));
220 }
221
222 void Expand(float Width, float Height)
223 {
224 m_TopLeft.x -= Width;
225 m_BottomRight.x += Width;
226 m_TopLeft.y -= Height;
228 }
229
230 void Expand(float Size)
231 {
232 Expand(Size, Size);
233 }
234
237};
238
239class IGraphics : public IInterface
240{
241 MACRO_INTERFACE("graphics")
242protected:
245 int m_ViewportX = 0;
251
252public:
253 enum
254 {
258 };
259
261 {
262 friend class IGraphics;
263 int m_Id;
264
265 public:
267 m_Id(-1)
268 {
269 }
270
271 bool IsValid() const { return Id() >= 0; }
272 bool IsNullTexture() const { return Id() == 0; }
273 int Id() const { return m_Id; }
274 void Invalidate() { m_Id = -1; }
275 };
276
277 int ScreenWidth() const { return m_ScreenWidth; }
278 int ScreenHeight() const { return m_ScreenHeight; }
280 float ScreenAspect() const { return (float)ScreenWidth() / (float)ScreenHeight(); }
281 float ScreenHiDPIScale() const { return m_ScreenHiDPIScale; }
284
285 // Size of the whole drawable area, in the same units as ScreenWidth()/ScreenHeight().
286 // The rendered image is clamped to an aspect ratio of at most 5:4 and excludes the
287 // area covered by the cutout of the display, so it can be smaller than that area.
288 // The rest of the drawable area is not rendered to.
290
291 // Distance of the rendered image from the left edge of the drawable area, in the
292 // same units as ScreenWidth(). The image is always aligned to the top edge.
293 int ViewportX() const { return m_ViewportX; }
294
295 virtual void WarnPngliteIncompatibleImages(bool Warn) = 0;
296 virtual void SetWindowParams(int FullscreenMode, bool IsBorderless) = 0;
297 virtual bool SetWindowScreen(int Index, bool MoveToCenter) = 0;
298 virtual bool SwitchWindowScreen(int Index, bool MoveToCenter) = 0;
299 virtual bool SetVSync(bool State) = 0;
300 virtual bool SetMultiSampling(uint32_t ReqMultiSamplingCount, uint32_t &MultiSamplingCountBackend) = 0;
301 virtual int GetWindowScreen() = 0;
302 virtual void Move(int x, int y) = 0;
303 virtual bool Resize(int w, int h, int RefreshRate) = 0;
304 virtual void ResizeToScreen() = 0;
305 virtual void GotResized(int w, int h, int RefreshRate) = 0;
306 virtual void UpdateViewport(int X, int Y, int W, int H, bool ByResize) = 0;
307 virtual bool IsScreenKeyboardShown() = 0;
308
318
319 virtual void WindowDestroyNtf(uint32_t WindowId) = 0;
320 virtual void WindowCreateNtf(uint32_t WindowId) = 0;
321
322 // ForceClearNow forces the backend to trigger a clear, even at performance cost, else it might be delayed by one frame
323 virtual void Clear(float r, float g, float b, bool ForceClearNow = false) = 0;
324
325 virtual void ClipEnable(int x, int y, int w, int h) = 0;
326 virtual void ClipDisable() = 0;
327
328 virtual void MapScreen(const CScreenRect &ScreenRect) = 0;
329
330 // helper functions
331 void CalcScreenParams(float Aspect, float Zoom, float *pWidth, float *pHeight) const;
332 CScreenRect MapScreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY,
333 float ParallaxZoom, float OffsetX, float OffsetY, float Aspect, float Zoom) const;
334 void MapScreenToInterface(float CenterX, float CenterY, float Zoom = 1.0f);
335 void MapScreenToSize(float Width, float Height);
336
337 virtual CScreenRect GetScreen() const = 0;
338
339 // TODO: These should perhaps not be virtuals
340 virtual void BlendNone() = 0;
341 virtual void BlendNormal() = 0;
342 virtual void BlendAdditive() = 0;
343 virtual void WrapNormal() = 0;
344 virtual void WrapClamp() = 0;
345
346 virtual uint64_t TextureMemoryUsage() const = 0;
347 virtual uint64_t BufferMemoryUsage() const = 0;
348 virtual uint64_t StreamedMemoryUsage() const = 0;
349 virtual uint64_t StagingMemoryUsage() const = 0;
350
351 virtual const TTwGraphicsGpuList &GetGpus() const = 0;
352
353 virtual bool LoadPng(CImageInfo &Image, const char *pFilename, int StorageType) = 0;
354 virtual bool LoadPng(CImageInfo &Image, const uint8_t *pData, size_t DataSize, const char *pContextName) = 0;
355
356 virtual bool CheckImageDivisibility(const char *pContextName, CImageInfo &Image, int DivX, int DivY, bool AllowResize) = 0;
357 virtual bool IsImageFormatRgba(const char *pContextName, const CImageInfo &Image) = 0;
358
359 virtual void UnloadTexture(CTextureHandle *pIndex) = 0;
360 virtual CTextureHandle LoadTextureRaw(const CImageInfo &Image, int Flags, const char *pTexName = nullptr) = 0;
361 virtual CTextureHandle LoadTextureRawMove(CImageInfo &Image, int Flags, const char *pTexName = nullptr) = 0;
362 virtual CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) = 0;
363 virtual void TextureSet(CTextureHandle Texture) = 0;
365
366 // pTextData & pTextOutlineData are automatically free'd
367 virtual bool LoadTextTextures(size_t Width, size_t Height, CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture, uint8_t *pTextData, uint8_t *pTextOutlineData) = 0;
368 virtual bool UnloadTextTextures(CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture) = 0;
369 virtual bool UpdateTextTexture(CTextureHandle TextureId, int x, int y, size_t Width, size_t Height, uint8_t *pData, bool IsMovedPointer) = 0;
370
371 virtual CTextureHandle LoadSpriteTexture(const CImageInfo &FromImageInfo, const std::optional<CImageInfo> &FallbackImageInfo, const struct CDataSprite *pSprite) = 0;
372
373 virtual bool IsImageSubFullyTransparent(const CImageInfo &FromImageInfo, int x, int y, int w, int h) = 0;
374 virtual bool IsSpriteTextureFullyTransparent(const CImageInfo &FromImageInfo, const struct CDataSprite *pSprite) = 0;
375
376 virtual void FlushVertices(bool KeepVertices = false) = 0;
377 virtual void FlushVerticesTex3D() = 0;
378
379 // specific render functions
380 virtual void RenderTileLayer(int BufferContainerIndex, const ColorRGBA &Color, char **pOffsets, unsigned int *pIndicedVertexDrawNum, size_t NumIndicesOffset) = 0;
381 virtual void RenderBorderTiles(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Scale, uint32_t DrawNum) = 0;
382 virtual void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, size_t QuadNum, int QuadOffset, bool Grouped = false) = 0;
383 virtual void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor) = 0;
384
385 // opengl 3.3 functions
386
388 {
389 // 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
391 };
392
393 // if a pointer is passed as moved pointer, it requires to be allocated with malloc()
394 virtual int CreateBufferObject(size_t UploadDataSize, void *pUploadData, int CreateFlags, bool IsMovedPointer = false) = 0;
395 virtual void RecreateBufferObject(int BufferIndex, size_t UploadDataSize, void *pUploadData, int CreateFlags, bool IsMovedPointer = false) = 0;
396 virtual void DeleteBufferObject(int BufferIndex) = 0;
397
398 virtual int CreateBufferContainer(struct SBufferContainerInfo *pContainerInfo) = 0;
399 // destroying all buffer objects means, that all referenced VBOs are destroyed automatically, so the user does not need to save references to them
400 virtual void DeleteBufferContainer(int &ContainerIndex, bool DestroyAllBO = true) = 0;
401 virtual void IndicesNumRequiredNotify(unsigned int RequiredIndicesCount) = 0;
402
403 // returns true if the driver age type is supported, passing BACKEND_TYPE_AUTO for BackendType will query the values for the currently used backend
404 virtual bool GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch, const char *&pName, EBackendType BackendType) = 0;
405 virtual bool IsConfigModernAPI() = 0;
406 virtual bool IsTileBufferingEnabled() = 0;
407 virtual bool IsQuadBufferingEnabled() = 0;
408 virtual bool IsTextBufferingEnabled() = 0;
410 virtual bool Uses2DTextureArrays() = 0;
411 virtual int TextureLoadFlags() = 0;
412 virtual bool HasTextureArraysSupport() = 0;
413
414 virtual const char *GetVendorString() = 0;
415 virtual const char *GetVersionString() = 0;
416 virtual const char *GetRendererString() = 0;
417 virtual const char *GetFatalError() const = 0;
418
420 {
421 public:
422 float m_X0, m_Y0, m_X1, m_Y1;
423 CLineItem() = default;
424 CLineItem(float x0, float y0, float x1, float y1) :
425 m_X0(x0), m_Y0(y0), m_X1(x1), m_Y1(y1) {}
427 {
428 m_X0 = From.x;
429 m_Y0 = From.y;
430 m_X1 = To.x;
431 m_Y1 = To.y;
432 }
433 };
434 virtual void LinesBegin() = 0;
435 virtual void LinesEnd() = 0;
436 virtual void LinesDraw(const CLineItem *pArray, size_t Num) = 0;
437
439 {
440 public:
442 size_t m_NumItems = 0;
443 };
444 virtual void LinesBatchBegin(CLineItemBatch *pBatch) = 0;
445 virtual void LinesBatchEnd(CLineItemBatch *pBatch) = 0;
446 virtual void LinesBatchDraw(CLineItemBatch *pBatch, const CLineItem *pArray, size_t Num) = 0;
447
448 virtual void QuadsBegin() = 0;
449 virtual void QuadsEnd() = 0;
450 virtual void QuadsTex3DBegin() = 0;
451 virtual void QuadsTex3DEnd() = 0;
452 virtual void TrianglesBegin() = 0;
453 virtual void TrianglesEnd() = 0;
454 virtual void QuadsEndKeepVertices() = 0;
455 virtual void QuadsDrawCurrentVertices(bool KeepVertices = true) = 0;
456 virtual void QuadsSetRotation(float Angle) = 0;
457 virtual void QuadsSetSubset(float TopLeftU, float TopLeftV, float BottomRightU, float BottomRightV) = 0;
458 virtual void QuadsSetSubsetFree(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, int Index = -1) = 0;
459
461 {
463 CFreeformItem() = default;
464 CFreeformItem(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) :
465 m_X0(x0), m_Y0(y0), m_X1(x1), m_Y1(y1), m_X2(x2), m_Y2(y2), m_X3(x3), m_Y3(y3) {}
466 CFreeformItem(vec2 Point1, vec2 Point2, vec2 Point3, vec2 Point4) :
467 m_X0(Point1.x), m_Y0(Point1.y), m_X1(Point2.x), m_Y1(Point2.y), m_X2(Point3.x), m_Y2(Point3.y), m_X3(Point4.x), m_Y3(Point4.y) {}
468 };
469
471 {
473 CQuadItem() = default;
474 CQuadItem(float x, float y, float w, float h) :
475 m_X(x), m_Y(y), m_Width(w), m_Height(h) {}
476 CQuadItem(vec2 Position, vec2 Size) :
477 m_X(Position.x), m_Y(Position.y), m_Width(Size.x), m_Height(Size.y) {}
478 };
479 virtual void QuadsDraw(CQuadItem *pArray, int Num) = 0;
480 virtual void QuadsDrawTL(const CQuadItem *pArray, int Num) = 0;
481
482 virtual void QuadsTex3DDrawTL(const CQuadItem *pArray, int Num) = 0;
483
484 virtual int CreateQuadContainer(bool AutomaticUpload = true) = 0;
485 virtual void QuadContainerChangeAutomaticUpload(int ContainerIndex, bool AutomaticUpload) = 0;
486 virtual void QuadContainerUpload(int ContainerIndex) = 0;
487 virtual int QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) = 0;
488 virtual int QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) = 0;
489 virtual void QuadContainerReset(int ContainerIndex) = 0;
490 virtual void DeleteQuadContainer(int &ContainerIndex) = 0;
491 virtual void RenderQuadContainer(int ContainerIndex, int QuadDrawNum) = 0;
492 virtual void RenderQuadContainer(int ContainerIndex, int QuadOffset, int QuadDrawNum, bool ChangeWrapMode = true) = 0;
493 virtual void RenderQuadContainerEx(int ContainerIndex, int QuadOffset, int QuadDrawNum, float X, float Y, float ScaleX = 1.f, float ScaleY = 1.f) = 0;
494 virtual void RenderQuadContainerAsSprite(int ContainerIndex, int QuadOffset, float X, float Y, float ScaleX = 1.f, float ScaleY = 1.f) = 0;
495
497 {
499 float m_Scale;
501 };
502
503 virtual void RenderQuadContainerAsSpriteMultiple(int ContainerIndex, int QuadOffset, int DrawCount, SRenderSpriteInfo *pRenderInfo) = 0;
504
505 virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num) = 0;
506 virtual void QuadsText(float x, float y, float Size, const char *pText) = 0;
507
508 // sprites
509 enum
510 {
513 };
514 virtual void SelectSprite(int Id, int Flags = 0) = 0;
515 virtual void SelectSprite7(int Id, int Flags = 0) = 0;
516
517 virtual void GetSpriteScale(const CDataSprite *pSprite, float &ScaleX, float &ScaleY) const = 0;
518 virtual void GetSpriteScale(int Id, float &ScaleX, float &ScaleY) const = 0;
519 virtual void GetSpriteScaleImpl(int Width, int Height, float &ScaleX, float &ScaleY) const = 0;
520
521 virtual void DrawSprite(float x, float y, float Size) = 0;
522 virtual void DrawSprite(float x, float y, float ScaledWidth, float ScaledHeight) = 0;
523
524 virtual int QuadContainerAddSprite(int QuadContainerIndex, float x, float y, float Size) = 0;
525 virtual int QuadContainerAddSprite(int QuadContainerIndex, float Size) = 0;
526 virtual int QuadContainerAddSprite(int QuadContainerIndex, float Width, float Height) = 0;
527 virtual int QuadContainerAddSprite(int QuadContainerIndex, float X, float Y, float Width, float Height) = 0;
528
529 enum
530 {
536
541
543 };
544 virtual void DrawRectExt(float x, float y, float w, float h, float r, int Corners) = 0;
545 virtual void DrawRectExt4(float x, float y, float w, float h, ColorRGBA ColorTopLeft, ColorRGBA ColorTopRight, ColorRGBA ColorBottomLeft, ColorRGBA ColorBottomRight, float r, int Corners) = 0;
546 virtual int CreateRectQuadContainer(float x, float y, float w, float h, float r, int Corners) = 0;
547 virtual void DrawRect(float x, float y, float w, float h, ColorRGBA Color, int Corners, float Rounding) = 0;
548 virtual void DrawRect4(float x, float y, float w, float h, ColorRGBA ColorTopLeft, ColorRGBA ColorTopRight, ColorRGBA ColorBottomLeft, ColorRGBA ColorBottomRight, int Corners, float Rounding) = 0;
549 virtual void DrawCircle(float CenterX, float CenterY, float Radius, int Segments) = 0;
550
554 virtual void SetColor(float r, float g, float b, float a) = 0;
555 virtual void SetColor(ColorRGBA Color) = 0;
556 virtual void SetColor2(ColorRGBA First, ColorRGBA Second) = 0;
557 virtual void SetColor4(ColorRGBA TopLeft, ColorRGBA TopRight, ColorRGBA BottomLeft, ColorRGBA BottomRight) = 0;
558 virtual void ChangeColorOfQuadVertices(size_t QuadOffset, unsigned char r, unsigned char g, unsigned char b, unsigned char a) = 0;
559
568 virtual void ReadPixel(ivec2 Position, ColorRGBA *pColor) = 0;
569 virtual void TakeScreenshot(const char *pFilename) = 0;
570 virtual void TakeCustomScreenshot(const char *pFilename) = 0;
571 virtual int GetVideoModes(CVideoMode *pModes, int MaxModes, int Screen) = 0;
572 virtual void GetCurrentVideoMode(CVideoMode &CurMode, int Screen) = 0;
573 virtual void Swap() = 0;
574 virtual int GetNumScreens() const = 0;
575 virtual const char *GetScreenName(int Screen) const = 0;
576
577 // synchronization
578 virtual void InsertSignal(class CSemaphore *pSemaphore) = 0;
579 virtual bool IsIdle() const = 0;
580 virtual void WaitForIdle() = 0;
581
582 virtual void SetWindowGrab(bool Grab) = 0;
583 virtual void NotifyWindow() = 0;
584
585 // be aware that this function should only be called from the graphics thread, and even then you should really know what you are doing
586 // this function always returns the pixels in RGB
588
589 virtual std::optional<SWarning> CurrentWarning() = 0;
590
597 {
599 WARNING,
600 INFO,
601 };
602
608 {
609 public:
615 const char *m_pLabel = nullptr;
619 bool m_Confirm = false;
625 bool m_Cancel = false;
626 };
627
633 {
634 public:
638 const char *m_pTitle = nullptr;
642 const char *m_pMessage = nullptr;
651 std::vector<CMessageBoxButton> m_vButtons = {{.m_pLabel = "OK", .m_Confirm = true, .m_Cancel = true}};
652 };
653
664 virtual std::optional<int> ShowMessageBox(const CMessageBox &MessageBox) = 0;
665
666 virtual bool IsBackendInitialized() = 0;
667
668protected:
670 {
671 CTextureHandle Tex;
672 Tex.m_Id = Index;
673 return Tex;
674 }
675};
676
678{
679 MACRO_INTERFACE("enginegraphics")
680public:
681 virtual int Init() = 0;
682 void Shutdown() override = 0;
683
684 virtual void Minimize() = 0;
685
686 virtual int WindowActive() = 0;
687 virtual int WindowOpen() = 0;
688};
689
691
697extern std::optional<int> ShowMessageBoxWithoutGraphics(const IGraphics::CMessageBox &MessageBox);
698
699#endif
Definition graphics.h:63
ubvec4 m_TexCoordBottomRight
Definition graphics.h:67
ubvec4 m_TexCoordTopLeft
Definition graphics.h:65
ubvec4 m_TexCoordTopRight
Definition graphics.h:66
ubvec4 m_TexCoordBottomLeft
Definition graphics.h:68
Definition graphics.h:54
vec2 m_TopRight
Definition graphics.h:57
vec2 m_BottomLeft
Definition graphics.h:59
vec2 m_TopLeft
Definition graphics.h:56
vec2 m_BottomRight
Definition graphics.h:58
Definition image.h:12
EImageFormat
Definition image.h:21
Definition graphics.h:186
vec2 m_BottomRight
Definition graphics.h:236
CScreenRect(float Left, float Top, float Width, float Height)
Definition graphics.h:188
vec2 m_TopLeft
Definition graphics.h:235
constexpr vec2 Size() const
Definition graphics.h:202
constexpr float Width() const
Definition graphics.h:207
constexpr bool Inside(const vec2 &Position) const
Definition graphics.h:217
constexpr float Height() const
Definition graphics.h:212
CScreenRect Move(const vec2 &Position) const
Definition graphics.h:194
void Expand(float Size)
Definition graphics.h:230
CScreenRect(const vec2 &TopLeft, const vec2 &BottomRight)
Definition graphics.h:191
void Expand(float Width, float Height)
Definition graphics.h:222
Definition sphore.h:62
Definition graphics.h:75
int m_RefreshRate
Definition graphics.h:79
int m_CanvasHeight
Definition graphics.h:77
int m_CanvasWidth
Definition graphics.h:77
int m_WindowHeight
Definition graphics.h:78
int m_WindowWidth
Definition graphics.h:78
Definition color.h:183
Definition graphics.h:678
virtual int Init()=0
virtual int WindowOpen()=0
void Shutdown() override=0
virtual void Minimize()=0
virtual int WindowActive()=0
Definition graphics.h:439
size_t m_NumItems
Definition graphics.h:442
IGraphics::CLineItem m_aItems[256]
Definition graphics.h:441
Definition graphics.h:420
CLineItem(vec2 From, vec2 To)
Definition graphics.h:426
float m_X0
Definition graphics.h:422
float m_X1
Definition graphics.h:422
float m_Y1
Definition graphics.h:422
CLineItem(float x0, float y0, float x1, float y1)
Definition graphics.h:424
float m_Y0
Definition graphics.h:422
Definition graphics.h:608
bool m_Confirm
Definition graphics.h:619
const char * m_pLabel
Definition graphics.h:615
bool m_Cancel
Definition graphics.h:625
Definition graphics.h:633
std::vector< CMessageBoxButton > m_vButtons
Definition graphics.h:651
const char * m_pMessage
Definition graphics.h:642
EMessageBoxType m_Type
Definition graphics.h:646
const char * m_pTitle
Definition graphics.h:638
Definition graphics.h:261
friend class IGraphics
Definition graphics.h:262
void Invalidate()
Definition graphics.h:274
CTextureHandle()
Definition graphics.h:266
bool IsNullTexture() const
Definition graphics.h:272
bool IsValid() const
Definition graphics.h:271
int m_Id
Definition graphics.h:263
int Id() const
Definition graphics.h:273
Definition graphics.h:240
virtual void SetColor2(ColorRGBA First, ColorRGBA Second)=0
virtual int GetWindowScreen()=0
virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num)=0
virtual void QuadsEnd()=0
int m_ScreenWidth
Definition graphics.h:243
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
@ CORNER_NONE
Definition graphics.h:531
@ CORNER_ALL
Definition graphics.h:542
@ CORNER_B
Definition graphics.h:538
@ CORNER_BR
Definition graphics.h:535
@ CORNER_T
Definition graphics.h:537
@ CORNER_TR
Definition graphics.h:533
@ CORNER_R
Definition graphics.h:539
@ CORNER_L
Definition graphics.h:540
@ CORNER_BL
Definition graphics.h:534
@ CORNER_TL
Definition graphics.h:532
virtual int QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num)=0
virtual void WrapClamp()=0
virtual int QuadContainerAddSprite(int QuadContainerIndex, float x, float y, float Size)=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:278
virtual void BlendNormal()=0
virtual const char * GetVersionString()=0
virtual void RenderQuadContainer(int ContainerIndex, int QuadDrawNum)=0
virtual void LinesBatchDraw(CLineItemBatch *pBatch, const CLineItem *pArray, size_t Num)=0
virtual void UpdateViewport(int X, int Y, int W, int H, bool ByResize)=0
virtual bool IsIdle() const =0
int m_ViewportX
Definition graphics.h:245
virtual void LinesBatchEnd(CLineItemBatch *pBatch)=0
EMessageBoxType
Definition graphics.h:597
@ ERROR
Definition graphics.h:598
virtual void QuadsSetRotation(float Angle)=0
virtual TGLBackendReadPresentedImageData & GetReadPresentedImageDataFuncUnsafe()=0
virtual void TextureSet(CTextureHandle Texture)=0
virtual int TextureLoadFlags()=0
CTextureHandle CreateTextureHandle(int Index)
Definition graphics.h:669
virtual uint64_t TextureMemoryUsage() const =0
virtual void TrianglesBegin()=0
virtual void TakeCustomScreenshot(const char *pFilename)=0
virtual void SelectSprite(int Id, int Flags=0)=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:388
@ BUFFER_OBJECT_CREATE_FLAGS_ONE_TIME_USE_BIT
Definition graphics.h:390
float ScreenHiDPIScale() const
Definition graphics.h:281
virtual void SetColor4(ColorRGBA TopLeft, ColorRGBA TopRight, ColorRGBA BottomLeft, ColorRGBA BottomRight)=0
virtual void LinesBatchBegin(CLineItemBatch *pBatch)=0
virtual CTextureHandle LoadTextureRawMove(CImageInfo &Image, int Flags, const char *pTexName=nullptr)=0
int m_DrawableWidth
Definition graphics.h:246
virtual bool IsScreenKeyboardShown()=0
virtual bool IsQuadContainerBufferingEnabled()=0
virtual void ReadPixel(ivec2 Position, ColorRGBA *pColor)=0
virtual void BlendNone()=0
virtual bool Uses2DTextureArrays()=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:364
virtual void TakeScreenshot(const char *pFilename)=0
virtual uint64_t BufferMemoryUsage() const =0
virtual void GetSpriteScale(const CDataSprite *pSprite, float &ScaleX, float &ScaleY) const =0
virtual void RenderBorderTiles(int BufferContainerIndex, const ColorRGBA &Color, char *pIndexBufferOffset, const vec2 &Offset, const vec2 &Scale, uint32_t DrawNum)=0
virtual void LinesDraw(const CLineItem *pArray, size_t Num)=0
float m_ScreenHiDPIScale
Definition graphics.h:249
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 void SelectSprite7(int Id, int Flags=0)=0
virtual int CreateBufferObject(size_t UploadDataSize, void *pUploadData, int CreateFlags, bool IsMovedPointer=false)=0
vec2 ScreenSize() const
Definition graphics.h:279
virtual CScreenRect GetScreen() const =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:282
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
int ViewportX() const
Definition graphics.h:293
@ TEXLOAD_NO_2D_TEXTURE
Definition graphics.h:257
@ TEXLOAD_TO_3D_TEXTURE
Definition graphics.h:255
@ TEXLOAD_TO_2D_ARRAY_TEXTURE
Definition graphics.h:256
virtual void LinesEnd()=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
virtual bool IsBackendInitialized()=0
virtual int CreateQuadContainer(bool AutomaticUpload=true)=0
virtual void DrawRectExt(float x, float y, float w, float h, float r, int Corners)=0
int m_ScreenHeight
Definition graphics.h:244
virtual int QuadContainerAddSprite(int QuadContainerIndex, float Size)=0
void MapScreenToSize(float Width, float Height)
Definition graphics.cpp:58
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 void GetSpriteScaleImpl(int Width, int Height, float &ScaleX, float &ScaleY) const =0
virtual std::optional< int > ShowMessageBox(const CMessageBox &MessageBox)=0
virtual uint64_t StagingMemoryUsage() const =0
virtual bool IsTileBufferingEnabled()=0
virtual bool IsTextBufferingEnabled()=0
virtual bool SwitchWindowScreen(int Index, bool MoveToCenter)=0
virtual void WaitForIdle()=0
virtual void MapScreen(const CScreenRect &ScreenRect)=0
virtual bool LoadPng(CImageInfo &Image, const char *pFilename, int StorageType)=0
virtual void NotifyWindow()=0
virtual void BlendAdditive()=0
void MapScreenToInterface(float CenterX, float CenterY, float Zoom=1.0f)
Definition graphics.cpp:51
virtual void DrawSprite(float x, float y, float Size)=0
virtual void QuadsBegin()=0
virtual void DeleteQuadContainer(int &ContainerIndex)=0
virtual void DeleteBufferObject(int BufferIndex)=0
int m_DrawableHeight
Definition graphics.h:247
void CalcScreenParams(float Aspect, float Zoom, float *pWidth, float *pHeight) const
Definition graphics.cpp:4
virtual void DeleteBufferContainer(int &ContainerIndex, bool DestroyAllBO=true)=0
virtual void IndicesNumRequiredNotify(unsigned int RequiredIndicesCount)=0
virtual void WindowCreateNtf(uint32_t WindowId)=0
virtual const char * GetFatalError() const =0
virtual void GotResized(int w, int h, int RefreshRate)=0
virtual CTextureHandle LoadSpriteTexture(const CImageInfo &FromImageInfo, const std::optional< CImageInfo > &FallbackImageInfo, const struct CDataSprite *pSprite)=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 GetSpriteScale(int Id, float &ScaleX, float &ScaleY) const =0
virtual std::optional< SWarning > CurrentWarning()=0
virtual void FlushVerticesTex3D()=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
@ SPRITE_FLAG_FLIP_X
Definition graphics.h:512
@ SPRITE_FLAG_FLIP_Y
Definition graphics.h:511
virtual CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags=0)=0
virtual int QuadContainerAddSprite(int QuadContainerIndex, float Width, float Height)=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 bool SetWindowScreen(int Index, bool MoveToCenter)=0
virtual const char * GetRendererString()=0
vec2 DrawableSize() const
Definition graphics.h:289
virtual void FlushVertices(bool KeepVertices=false)=0
virtual void DrawSprite(float x, float y, float ScaledWidth, float ScaledHeight)=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
ivec2 m_DesktopSize
Definition graphics.h:250
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
virtual void Clear(float r, float g, float b, bool ForceClearNow=false)=0
virtual void LinesBegin()=0
CScreenRect MapScreenToWorld(float CenterX, float CenterY, float ParallaxX, float ParallaxY, float ParallaxZoom, float OffsetX, float OffsetY, float Aspect, float Zoom) const
Definition graphics.cpp:31
virtual void SetWindowGrab(bool Grab)=0
int m_ScreenRefreshRate
Definition graphics.h:248
virtual bool IsImageSubFullyTransparent(const CImageInfo &FromImageInfo, int x, int y, int w, int h)=0
int ScreenWidth() const
Definition graphics.h:277
virtual bool IsImageFormatRgba(const char *pContextName, const CImageInfo &Image)=0
virtual int QuadContainerAddSprite(int QuadContainerIndex, float X, float Y, float Width, float Height)=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:283
float ScreenAspect() const
Definition graphics.h:280
virtual void ChangeColorOfQuadVertices(size_t QuadOffset, unsigned char r, unsigned char g, unsigned char b, unsigned char a)=0
virtual void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, size_t QuadNum, int QuadOffset, bool Grouped=false)=0
virtual void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor)=0
IInterface()
Definition kernel.h:19
Definition vmath.h:350
IEngineGraphics * CreateEngineGraphicsThreaded()
Definition graphics_threaded.cpp:2958
vector4_base< unsigned char > GL_SColor
Definition graphics.h:107
static constexpr size_t GRAPHICS_MAX_QUADS_RENDER_COUNT
Definition graphics.h:130
ColorRGBA GL_SColorf
Definition graphics.h:105
EBackendType
Definition graphics.h:143
@ BACKEND_TYPE_OPENGL_ES
Definition graphics.h:145
@ BACKEND_TYPE_OPENGL
Definition graphics.h:144
@ BACKEND_TYPE_VULKAN
Definition graphics.h:146
@ BACKEND_TYPE_AUTO
Definition graphics.h:149
@ BACKEND_TYPE_COUNT
Definition graphics.h:151
EGraphicsDriverAgeType
Definition graphics.h:134
@ GRAPHICS_DRIVER_AGE_TYPE_DEFAULT
Definition graphics.h:136
@ GRAPHICS_DRIVER_AGE_TYPE_COUNT
Definition graphics.h:139
@ GRAPHICS_DRIVER_AGE_TYPE_MODERN
Definition graphics.h:137
@ GRAPHICS_DRIVER_AGE_TYPE_LEGACY
Definition graphics.h:135
std::function< bool(uint32_t &Width, uint32_t &Height, CImageInfo::EImageFormat &Format, std::vector< uint8_t > &vDstData)> TGLBackendReadPresentedImageData
Definition graphics.h:181
std::optional< int > ShowMessageBoxWithoutGraphics(const IGraphics::CMessageBox &MessageBox)
Definition backend_sdl.cpp:917
std::function< void()> WINDOW_RESIZE_FUNC
Definition graphics.h:178
STWGraphicGpu TTwGraphicsGpuList
Definition graphics.h:176
vec2 GL_SPoint
Definition graphics.h:82
static constexpr size_t GRAPHICS_MAX_PARTICLES_RENDER_COUNT
Definition graphics.h:131
vec2 GL_STexCoord
Definition graphics.h:83
std::function< void()> WINDOW_PROPS_CHANGED_FUNC
Definition graphics.h:179
@ ERROR
Definition http.h:22
#define MACRO_INTERFACE(Name)
Definition kernel.h:25
constexpr bool in_range(T a, T lower, T upper)
Definition math.h:144
Definition graphics.h:86
float v
Definition graphics.h:102
GL_STexCoord3D & operator=(const GL_STexCoord &TexCoord)
Definition graphics.h:87
float u
Definition graphics.h:102
GL_STexCoord3D & operator=(const vec3 &TexCoord)
Definition graphics.h:94
float w
Definition graphics.h:102
Definition graphics.h:124
GL_SColor m_Color
Definition graphics.h:126
GL_STexCoord3D m_Tex
Definition graphics.h:127
GL_SPoint m_Pos
Definition graphics.h:125
Definition graphics.h:117
GL_STexCoord3D m_Tex
Definition graphics.h:120
GL_SPoint m_Pos
Definition graphics.h:118
GL_SColorf m_Color
Definition graphics.h:119
Definition graphics.h:110
GL_SColor m_Color
Definition graphics.h:113
GL_SPoint m_Pos
Definition graphics.h:111
GL_STexCoord m_Tex
Definition graphics.h:112
Definition graphics.h:461
float m_X2
Definition graphics.h:462
float m_X0
Definition graphics.h:462
float m_Y1
Definition graphics.h:462
float m_Y0
Definition graphics.h:462
float m_Y3
Definition graphics.h:462
CFreeformItem(vec2 Point1, vec2 Point2, vec2 Point3, vec2 Point4)
Definition graphics.h:466
float m_X3
Definition graphics.h:462
CFreeformItem(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)
Definition graphics.h:464
float m_X1
Definition graphics.h:462
float m_Y2
Definition graphics.h:462
Definition graphics.h:471
CQuadItem(float x, float y, float w, float h)
Definition graphics.h:474
float m_Y
Definition graphics.h:472
CQuadItem(vec2 Position, vec2 Size)
Definition graphics.h:476
float m_Height
Definition graphics.h:472
float m_X
Definition graphics.h:472
float m_Width
Definition graphics.h:472
Definition graphics.h:497
vec2 m_Pos
Definition graphics.h:498
float m_Rotation
Definition graphics.h:500
float m_Scale
Definition graphics.h:499
Definition graphics.h:32
unsigned int m_FuncType
Definition graphics.h:39
unsigned int m_Type
Definition graphics.h:34
bool m_Normalized
Definition graphics.h:35
void * m_pOffset
Definition graphics.h:36
int m_DataTypeCount
Definition graphics.h:33
Definition graphics.h:26
int m_VertBufferBindingIndex
Definition graphics.h:28
int m_Stride
Definition graphics.h:27
std::vector< SAttribute > m_vAttributes
Definition graphics.h:41
Definition graphics.h:45
vec2 m_Offsets
Definition graphics.h:47
float m_Padding
Definition graphics.h:50
float m_Rotation
Definition graphics.h:48
ColorRGBA m_Color
Definition graphics.h:46
Definition graphics.h:168
ETWGraphicsGpuType m_GpuType
Definition graphics.h:170
char m_aName[256]
Definition graphics.h:169
Definition graphics.h:155
ETWGraphicsGpuType
Definition graphics.h:157
@ GRAPHICS_GPU_TYPE_INTEGRATED
Definition graphics.h:159
@ GRAPHICS_GPU_TYPE_INVALID
Definition graphics.h:164
@ GRAPHICS_GPU_TYPE_DISCRETE
Definition graphics.h:158
@ GRAPHICS_GPU_TYPE_VIRTUAL
Definition graphics.h:160
@ GRAPHICS_GPU_TYPE_CPU
Definition graphics.h:161
std::vector< STWGraphicGpuItem > m_vGpus
Definition graphics.h:172
STWGraphicGpuItem m_AutoGpu
Definition graphics.h:173
vector4_base< uint8_t > ubvec4
Definition vmath.h:439
vector3_base< float > vec3
Definition vmath.h:342
vector2_base< int > ivec2
Definition vmath.h:170
vector2_base< float > vec2
Definition vmath.h:168