2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#ifndef ENGINE_GRAPHICS_H
|
|
|
|
#define ENGINE_GRAPHICS_H
|
|
|
|
|
|
|
|
#include "kernel.h"
|
2020-10-02 13:43:52 +00:00
|
|
|
#include "warning.h"
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2019-04-26 22:11:15 +00:00
|
|
|
#include <base/color.h>
|
2020-08-29 10:49:45 +00:00
|
|
|
#include <stddef.h>
|
2020-09-13 21:05:43 +00:00
|
|
|
#include <stdint.h>
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2021-08-21 19:41:51 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2018-03-13 20:47:07 +00:00
|
|
|
#include <vector>
|
|
|
|
#define GRAPHICS_TYPE_UNSIGNED_BYTE 0x1401
|
|
|
|
#define GRAPHICS_TYPE_UNSIGNED_SHORT 0x1403
|
|
|
|
#define GRAPHICS_TYPE_INT 0x1404
|
|
|
|
#define GRAPHICS_TYPE_UNSIGNED_INT 0x1405
|
|
|
|
#define GRAPHICS_TYPE_FLOAT 0x1406
|
|
|
|
struct SBufferContainerInfo
|
|
|
|
{
|
|
|
|
int m_Stride;
|
|
|
|
|
|
|
|
// the attributes of the container
|
|
|
|
struct SAttribute
|
|
|
|
{
|
|
|
|
int m_DataTypeCount;
|
|
|
|
unsigned int m_Type;
|
|
|
|
bool m_Normalized;
|
2018-08-02 16:26:12 +00:00
|
|
|
void *m_pOffset;
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
//0: float, 1:integer
|
|
|
|
unsigned int m_FuncType;
|
|
|
|
|
|
|
|
int m_VertBufferBindingIndex;
|
|
|
|
};
|
|
|
|
std::vector<SAttribute> m_Attributes;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SQuadRenderInfo
|
|
|
|
{
|
|
|
|
float m_aColor[4];
|
|
|
|
float m_aOffsets[2];
|
|
|
|
float m_Rotation;
|
|
|
|
};
|
2011-12-31 09:04:46 +00:00
|
|
|
|
2020-08-22 06:09:10 +00:00
|
|
|
struct SGraphicTile
|
|
|
|
{
|
|
|
|
vec2 m_TopLeft;
|
|
|
|
vec2 m_TopRight;
|
|
|
|
vec2 m_BottomRight;
|
|
|
|
vec2 m_BottomLeft;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SGraphicTileTexureCoords
|
|
|
|
{
|
|
|
|
vec3 m_TexCoordTopLeft;
|
|
|
|
vec3 m_TexCoordTopRight;
|
|
|
|
vec3 m_TexCoordBottomRight;
|
|
|
|
vec3 m_TexCoordBottomLeft;
|
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class CImageInfo
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
FORMAT_AUTO = -1,
|
|
|
|
FORMAT_RGB = 0,
|
|
|
|
FORMAT_RGBA = 1,
|
|
|
|
FORMAT_ALPHA = 2,
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Variable: width
|
|
|
|
Contains the width of the image */
|
|
|
|
int m_Width;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
/* Variable: height
|
|
|
|
Contains the height of the image */
|
|
|
|
int m_Height;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
/* Variable: format
|
|
|
|
Contains the format of the image. See <Image Formats> for more information. */
|
|
|
|
int m_Format;
|
|
|
|
|
|
|
|
/* Variable: data
|
|
|
|
Pointer to the image data. */
|
|
|
|
void *m_pData;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Structure: CVideoMode
|
|
|
|
*/
|
|
|
|
class CVideoMode
|
|
|
|
{
|
|
|
|
public:
|
2021-05-06 10:59:30 +00:00
|
|
|
int m_CanvasWidth, m_CanvasHeight;
|
|
|
|
int m_WindowWidth, m_WindowHeight;
|
2021-08-21 19:41:51 +00:00
|
|
|
int m_RefreshRate;
|
2010-05-29 07:25:38 +00:00
|
|
|
int m_Red, m_Green, m_Blue;
|
2021-08-21 19:41:51 +00:00
|
|
|
uint32_t m_Format;
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
2020-09-21 03:57:54 +00:00
|
|
|
struct GL_SPoint
|
|
|
|
{
|
|
|
|
float x, y;
|
|
|
|
};
|
|
|
|
struct GL_STexCoord
|
|
|
|
{
|
|
|
|
float u, v;
|
|
|
|
};
|
|
|
|
struct GL_STexCoord3D
|
|
|
|
{
|
|
|
|
GL_STexCoord3D &operator=(const GL_STexCoord &TexCoord)
|
|
|
|
{
|
|
|
|
u = TexCoord.u;
|
|
|
|
v = TexCoord.v;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
float u, v, w;
|
|
|
|
};
|
|
|
|
struct GL_SColorf
|
|
|
|
{
|
|
|
|
float r, g, b, a;
|
|
|
|
};
|
2018-04-03 15:40:21 +00:00
|
|
|
|
|
|
|
//use normalized color values
|
2020-09-26 19:41:58 +00:00
|
|
|
struct GL_SColor
|
|
|
|
{
|
|
|
|
unsigned char r, g, b, a;
|
|
|
|
};
|
2018-04-03 15:40:21 +00:00
|
|
|
|
|
|
|
struct GL_SVertex
|
|
|
|
{
|
|
|
|
GL_SPoint m_Pos;
|
|
|
|
GL_STexCoord m_Tex;
|
|
|
|
GL_SColor m_Color;
|
|
|
|
};
|
2018-03-21 14:48:48 +00:00
|
|
|
|
2020-08-22 06:09:10 +00:00
|
|
|
struct GL_SVertexTex3D
|
|
|
|
{
|
|
|
|
GL_SPoint m_Pos;
|
|
|
|
GL_SColorf m_Color;
|
|
|
|
GL_STexCoord3D m_Tex;
|
|
|
|
};
|
|
|
|
|
2020-09-21 03:57:54 +00:00
|
|
|
struct GL_SVertexTex3DStream
|
|
|
|
{
|
|
|
|
GL_SPoint m_Pos;
|
|
|
|
GL_SColor m_Color;
|
|
|
|
GL_STexCoord3D m_Tex;
|
|
|
|
};
|
|
|
|
|
2021-05-02 21:20:21 +00:00
|
|
|
enum EGraphicsDriverAgeType
|
|
|
|
{
|
|
|
|
GRAPHICS_DRIVER_AGE_TYPE_LEGACY = 0,
|
|
|
|
GRAPHICS_DRIVER_AGE_TYPE_DEFAULT,
|
|
|
|
GRAPHICS_DRIVER_AGE_TYPE_MODERN,
|
|
|
|
};
|
|
|
|
|
2021-08-21 19:41:51 +00:00
|
|
|
typedef std::function<void(void *)> WINDOW_RESIZE_FUNC;
|
2018-03-21 14:48:48 +00:00
|
|
|
|
2020-10-09 07:07:05 +00:00
|
|
|
namespace client_data7 {
|
2020-11-04 18:20:21 +00:00
|
|
|
struct CDataSprite; // NOLINT(bugprone-forward-declaration-namespace)
|
2020-10-09 07:07:05 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
class IGraphics : public IInterface
|
|
|
|
{
|
|
|
|
MACRO_INTERFACE("graphics", 0)
|
|
|
|
protected:
|
|
|
|
int m_ScreenWidth;
|
|
|
|
int m_ScreenHeight;
|
2021-08-21 19:41:51 +00:00
|
|
|
int m_ScreenRefreshRate;
|
2021-05-06 10:59:30 +00:00
|
|
|
float m_ScreenHiDPIScale;
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
public:
|
|
|
|
enum
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
TEXLOAD_NOMIPMAPS = 1 << 1,
|
|
|
|
TEXLOAD_NO_COMPRESSION = 1 << 2,
|
2020-08-19 05:05:51 +00:00
|
|
|
TEXLOAD_TO_3D_TEXTURE = (1 << 3),
|
|
|
|
TEXLOAD_TO_2D_ARRAY_TEXTURE = (1 << 4),
|
|
|
|
TEXLOAD_TO_3D_TEXTURE_SINGLE_LAYER = (1 << 5),
|
|
|
|
TEXLOAD_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER = (1 << 6),
|
2020-08-23 06:25:21 +00:00
|
|
|
TEXLOAD_NO_2D_TEXTURE = (1 << 7),
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
2012-08-12 10:41:50 +00:00
|
|
|
class CTextureHandle
|
|
|
|
{
|
|
|
|
friend class IGraphics;
|
|
|
|
int m_Id;
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2012-08-12 10:41:50 +00:00
|
|
|
public:
|
2020-09-26 19:41:58 +00:00
|
|
|
CTextureHandle() :
|
|
|
|
m_Id(-1)
|
|
|
|
{
|
|
|
|
}
|
2012-08-12 10:41:50 +00:00
|
|
|
|
2012-08-12 12:02:50 +00:00
|
|
|
bool IsValid() const { return Id() >= 0; }
|
|
|
|
int Id() const { return m_Id; }
|
2016-07-02 08:33:37 +00:00
|
|
|
void Invalidate() { m_Id = -1; }
|
2012-08-12 10:41:50 +00:00
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int ScreenWidth() const { return m_ScreenWidth; }
|
|
|
|
int ScreenHeight() const { return m_ScreenHeight; }
|
2020-09-26 19:41:58 +00:00
|
|
|
float ScreenAspect() const { return (float)ScreenWidth() / (float)ScreenHeight(); }
|
2021-05-06 10:59:30 +00:00
|
|
|
float ScreenHiDPIScale() const { return m_ScreenHiDPIScale; }
|
|
|
|
int WindowWidth() const { return m_ScreenWidth / m_ScreenHiDPIScale; }
|
|
|
|
int WindowHeight() const { return m_ScreenHeight / m_ScreenHiDPIScale; }
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2021-01-31 20:54:04 +00:00
|
|
|
virtual void SetWindowParams(int FullscreenMode, bool IsBorderless) = 0;
|
2016-04-29 22:34:12 +00:00
|
|
|
virtual bool SetWindowScreen(int Index) = 0;
|
|
|
|
virtual bool SetVSync(bool State) = 0;
|
|
|
|
virtual int GetWindowScreen() = 0;
|
2021-12-13 17:42:21 +00:00
|
|
|
virtual void Move(int x, int y) = 0;
|
2021-08-21 19:41:51 +00:00
|
|
|
virtual void Resize(int w, int h, int RefreshRate, bool SetWindowSize = false, bool ForceResizeEvent = false) = 0;
|
2018-03-21 14:48:48 +00:00
|
|
|
virtual void AddWindowResizeListener(WINDOW_RESIZE_FUNC pFunc, void *pUser) = 0;
|
2016-04-29 19:07:10 +00:00
|
|
|
|
2021-08-24 10:18:20 +00:00
|
|
|
virtual void WindowDestroyNtf(uint32_t WindowID) = 0;
|
|
|
|
virtual void WindowCreateNtf(uint32_t WindowID) = 0;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void Clear(float r, float g, float b) = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void ClipEnable(int x, int y, int w, int h) = 0;
|
|
|
|
virtual void ClipDisable() = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY) = 0;
|
|
|
|
virtual void GetScreen(float *pTopLeftX, float *pTopLeftY, float *pBottomRightX, float *pBottomRightY) = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
// TODO: These should perhaps not be virtuals
|
|
|
|
virtual void BlendNone() = 0;
|
|
|
|
virtual void BlendNormal() = 0;
|
|
|
|
virtual void BlendAdditive() = 0;
|
2012-01-08 00:47:53 +00:00
|
|
|
virtual void WrapNormal() = 0;
|
|
|
|
virtual void WrapClamp() = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual int MemoryUsage() const = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-07-25 16:28:02 +00:00
|
|
|
virtual int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) = 0;
|
2020-11-25 12:05:53 +00:00
|
|
|
virtual void FreePNG(CImageInfo *pImg) = 0;
|
2012-08-12 10:41:50 +00:00
|
|
|
|
2020-11-18 06:36:19 +00:00
|
|
|
virtual bool CheckImageDivisibility(const char *pFileName, CImageInfo &Img, int DivX, int DivY, bool AllowResize) = 0;
|
|
|
|
|
2020-09-08 13:11:32 +00:00
|
|
|
// destination and source buffer require to have the same width and height
|
2020-09-10 22:42:42 +00:00
|
|
|
virtual void CopyTextureBufferSub(uint8_t *pDestBuffer, uint8_t *pSourceBuffer, int FullWidth, int FullHeight, int ColorChannelCount, int SubOffsetX, int SubOffsetY, int SubCopyWidth, int SubCopyHeight) = 0;
|
2020-09-08 13:11:32 +00:00
|
|
|
|
2020-10-09 07:07:05 +00:00
|
|
|
// destination width must be equal to the subwidth of the source
|
|
|
|
virtual void CopyTextureFromTextureBufferSub(uint8_t *pDestBuffer, int DestWidth, int DestHeight, uint8_t *pSourceBuffer, int SrcWidth, int SrcHeight, int ColorChannelCount, int SrcSubOffsetX, int SrcSubOffsetY, int SrcSubCopyWidth, int SrcSubCopyHeight) = 0;
|
|
|
|
|
2021-09-15 11:19:54 +00:00
|
|
|
virtual int UnloadTexture(CTextureHandle *pIndex) = 0;
|
2020-08-29 10:49:45 +00:00
|
|
|
virtual CTextureHandle LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags, const char *pTexName = NULL) = 0;
|
2012-08-12 10:41:50 +00:00
|
|
|
virtual int LoadTextureRawSub(CTextureHandle TextureID, int x, int y, int Width, int Height, int Format, const void *pData) = 0;
|
|
|
|
virtual CTextureHandle LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags) = 0;
|
|
|
|
virtual void TextureSet(CTextureHandle Texture) = 0;
|
|
|
|
void TextureClear() { TextureSet(CTextureHandle()); }
|
2018-03-13 20:47:07 +00:00
|
|
|
|
2020-10-09 07:07:05 +00:00
|
|
|
virtual CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct CDataSprite *pSprite) = 0;
|
|
|
|
virtual CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct client_data7::CDataSprite *pSprite) = 0;
|
|
|
|
|
|
|
|
virtual bool IsImageSubFullyTransparent(CImageInfo &FromImageInfo, int x, int y, int w, int h) = 0;
|
|
|
|
virtual bool IsSpriteTextureFullyTransparent(CImageInfo &FromImageInfo, struct client_data7::CDataSprite *pSprite) = 0;
|
|
|
|
|
2018-03-13 20:47:07 +00:00
|
|
|
virtual void FlushVertices(bool KeepVertices = false) = 0;
|
2018-08-02 16:26:12 +00:00
|
|
|
virtual void FlushTextVertices(int TextureSize, int TextTextureIndex, int TextOutlineTextureIndex, float *pOutlineTextColor) = 0;
|
2020-09-21 03:57:54 +00:00
|
|
|
virtual void FlushVerticesTex3D() = 0;
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
// specific render functions
|
2018-08-02 16:26:12 +00:00
|
|
|
virtual void RenderTileLayer(int BufferContainerIndex, float *pColor, char **pOffsets, unsigned int *IndicedVertexDrawNum, size_t NumIndicesOffet) = 0;
|
|
|
|
virtual void RenderBorderTiles(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, int JumpIndex, unsigned int DrawNum) = 0;
|
|
|
|
virtual void RenderBorderTileLines(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, unsigned int IndexDrawNum, unsigned int RedrawNum) = 0;
|
2020-12-29 13:31:42 +00:00
|
|
|
virtual void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, int QuadNum, int QuadOffset) = 0;
|
2018-08-02 16:26:12 +00:00
|
|
|
virtual void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, float *pTextColor, float *pTextoutlineColor) = 0;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2018-03-13 20:47:07 +00:00
|
|
|
// opengl 3.3 functions
|
2020-10-13 17:33:02 +00:00
|
|
|
// if a pointer is passed as moved pointer, it requires to be allocated with malloc()
|
|
|
|
virtual int CreateBufferObject(size_t UploadDataSize, void *pUploadData, bool IsMovedPointer = false) = 0;
|
|
|
|
virtual void RecreateBufferObject(int BufferIndex, size_t UploadDataSize, void *pUploadData, bool IsMovedPointer = false) = 0;
|
|
|
|
virtual void UpdateBufferObject(int BufferIndex, size_t UploadDataSize, void *pUploadData, void *pOffset, bool IsMovedPointer = false) = 0;
|
2018-03-13 20:47:07 +00:00
|
|
|
virtual void CopyBufferObject(int WriteBufferIndex, int ReadBufferIndex, size_t WriteOffset, size_t ReadOffset, size_t CopyDataSize) = 0;
|
|
|
|
virtual void DeleteBufferObject(int BufferIndex) = 0;
|
|
|
|
|
|
|
|
virtual int CreateBufferContainer(struct SBufferContainerInfo *pContainerInfo) = 0;
|
|
|
|
// destroying all buffer objects means, that all referenced VBOs are destroyed automatically, so the user does not need to save references to them
|
|
|
|
virtual void DeleteBufferContainer(int ContainerIndex, bool DestroyAllBO = true) = 0;
|
|
|
|
virtual void UpdateBufferContainer(int ContainerIndex, struct SBufferContainerInfo *pContainerInfo) = 0;
|
|
|
|
virtual void IndicesNumRequiredNotify(unsigned int RequiredIndicesCount) = 0;
|
|
|
|
|
2021-05-02 21:20:21 +00:00
|
|
|
virtual void GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch) = 0;
|
|
|
|
virtual bool IsConfigModernAPI() = 0;
|
2020-08-22 06:09:10 +00:00
|
|
|
virtual bool IsTileBufferingEnabled() = 0;
|
|
|
|
virtual bool IsQuadBufferingEnabled() = 0;
|
|
|
|
virtual bool IsTextBufferingEnabled() = 0;
|
|
|
|
virtual bool IsQuadContainerBufferingEnabled() = 0;
|
2020-08-19 05:05:51 +00:00
|
|
|
virtual bool HasTextureArrays() = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2021-03-26 10:30:24 +00:00
|
|
|
virtual const char *GetVendorString() = 0;
|
|
|
|
virtual const char *GetVersionString() = 0;
|
|
|
|
virtual const char *GetRendererString() = 0;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
struct CLineItem
|
|
|
|
{
|
|
|
|
float m_X0, m_Y0, m_X1, m_Y1;
|
|
|
|
CLineItem() {}
|
2020-09-26 19:41:58 +00:00
|
|
|
CLineItem(float x0, float y0, float x1, float y1) :
|
|
|
|
m_X0(x0), m_Y0(y0), m_X1(x1), m_Y1(y1) {}
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
virtual void LinesBegin() = 0;
|
|
|
|
virtual void LinesEnd() = 0;
|
|
|
|
virtual void LinesDraw(const CLineItem *pArray, int Num) = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void QuadsBegin() = 0;
|
|
|
|
virtual void QuadsEnd() = 0;
|
2018-03-13 20:47:07 +00:00
|
|
|
virtual void TextQuadsBegin() = 0;
|
2018-08-02 16:26:12 +00:00
|
|
|
virtual void TextQuadsEnd(int TextureSize, int TextTextureIndex, int TextOutlineTextureIndex, float *pOutlineTextColor) = 0;
|
2020-09-21 03:57:54 +00:00
|
|
|
virtual void QuadsTex3DBegin() = 0;
|
|
|
|
virtual void QuadsTex3DEnd() = 0;
|
2020-10-20 17:11:19 +00:00
|
|
|
virtual void TrianglesBegin() = 0;
|
|
|
|
virtual void TrianglesEnd() = 0;
|
2018-03-13 20:47:07 +00:00
|
|
|
virtual void QuadsEndKeepVertices() = 0;
|
|
|
|
virtual void QuadsDrawCurrentVertices(bool KeepVertices = true) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void QuadsSetRotation(float Angle) = 0;
|
2014-08-16 14:50:01 +00:00
|
|
|
virtual void QuadsSetSubset(float TopLeftU, float TopLeftV, float BottomRightU, float BottomRightV) = 0;
|
2020-09-21 03:57:54 +00:00
|
|
|
virtual void QuadsSetSubsetFree(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3, int Index = -1) = 0;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2021-09-13 21:14:04 +00:00
|
|
|
struct CFreeformItem
|
|
|
|
{
|
|
|
|
float m_X0, m_Y0, m_X1, m_Y1, m_X2, m_Y2, m_X3, m_Y3;
|
|
|
|
CFreeformItem() {}
|
|
|
|
CFreeformItem(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) :
|
|
|
|
m_X0(x0), m_Y0(y0), m_X1(x1), m_Y1(y1), m_X2(x2), m_Y2(y2), m_X3(x3), m_Y3(y3) {}
|
|
|
|
};
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
struct CQuadItem
|
|
|
|
{
|
|
|
|
float m_X, m_Y, m_Width, m_Height;
|
|
|
|
CQuadItem() {}
|
2020-09-26 19:41:58 +00:00
|
|
|
CQuadItem(float x, float y, float w, float h) :
|
|
|
|
m_X(x), m_Y(y), m_Width(w), m_Height(h) {}
|
|
|
|
void Set(float x, float y, float w, float h)
|
|
|
|
{
|
|
|
|
m_X = x;
|
|
|
|
m_Y = y;
|
|
|
|
m_Width = w;
|
|
|
|
m_Height = h;
|
|
|
|
}
|
2021-09-13 21:14:04 +00:00
|
|
|
|
|
|
|
CFreeformItem ToFreeForm() const
|
|
|
|
{
|
|
|
|
return CFreeformItem(m_X, m_Y, m_X + m_Width, m_Y, m_X, m_Y + m_Height, m_X + m_Width, m_Y + m_Height);
|
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
virtual void QuadsDraw(CQuadItem *pArray, int Num) = 0;
|
|
|
|
virtual void QuadsDrawTL(const CQuadItem *pArray, int Num) = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-09-21 03:57:54 +00:00
|
|
|
virtual void QuadsTex3DDrawTL(const CQuadItem *pArray, int Num) = 0;
|
|
|
|
|
2021-09-13 21:14:04 +00:00
|
|
|
virtual const GL_STexCoord *GetCurTextureCoordinates() = 0;
|
|
|
|
virtual const GL_SColor *GetCurColor() = 0;
|
2018-03-13 20:47:07 +00:00
|
|
|
|
2021-09-13 21:14:04 +00:00
|
|
|
virtual int CreateQuadContainer(bool AutomaticUpload = true) = 0;
|
|
|
|
virtual void QuadContainerChangeAutomaticUpload(int ContainerIndex, bool AutomaticUpload) = 0;
|
2018-04-15 17:34:56 +00:00
|
|
|
virtual void QuadContainerUpload(int ContainerIndex) = 0;
|
2018-03-13 20:47:07 +00:00
|
|
|
virtual void QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) = 0;
|
|
|
|
virtual void QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) = 0;
|
|
|
|
virtual void QuadContainerReset(int ContainerIndex) = 0;
|
|
|
|
virtual void DeleteQuadContainer(int ContainerIndex) = 0;
|
|
|
|
virtual void RenderQuadContainer(int ContainerIndex, int QuadDrawNum) = 0;
|
2021-09-13 21:14:04 +00:00
|
|
|
virtual void RenderQuadContainer(int ContainerIndex, int QuadOffset, int QuadDrawNum, bool ChangeWrapMode = true) = 0;
|
2020-10-13 20:08:52 +00:00
|
|
|
virtual void RenderQuadContainerEx(int ContainerIndex, int QuadOffset, int QuadDrawNum, float X, float Y, float ScaleX = 1.f, float ScaleY = 1.f) = 0;
|
2018-03-13 20:47:07 +00:00
|
|
|
virtual void RenderQuadContainerAsSprite(int ContainerIndex, int QuadOffset, float X, float Y, float ScaleX = 1.f, float ScaleY = 1.f) = 0;
|
|
|
|
|
|
|
|
struct SRenderSpriteInfo
|
|
|
|
{
|
|
|
|
float m_Pos[2];
|
|
|
|
float m_Scale;
|
|
|
|
float m_Rotation;
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual void RenderQuadContainerAsSpriteMultiple(int ContainerIndex, int QuadOffset, int DrawCount, SRenderSpriteInfo *pRenderInfo) = 0;
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num) = 0;
|
2012-10-14 12:04:48 +00:00
|
|
|
virtual void QuadsText(float x, float y, float Size, const char *pText) = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
struct CColorVertex
|
|
|
|
{
|
|
|
|
int m_Index;
|
|
|
|
float m_R, m_G, m_B, m_A;
|
|
|
|
CColorVertex() {}
|
2020-09-26 19:41:58 +00:00
|
|
|
CColorVertex(int i, float r, float g, float b, float a) :
|
|
|
|
m_Index(i), m_R(r), m_G(g), m_B(b), m_A(a) {}
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
virtual void SetColorVertex(const CColorVertex *pArray, int Num) = 0;
|
|
|
|
virtual void SetColor(float r, float g, float b, float a) = 0;
|
2019-04-26 22:11:15 +00:00
|
|
|
virtual void SetColor(ColorRGBA rgb) = 0;
|
2020-09-03 12:08:26 +00:00
|
|
|
virtual void SetColor4(vec4 TopLeft, vec4 TopRight, vec4 BottomLeft, vec4 BottomRight) = 0;
|
2018-03-13 20:47:07 +00:00
|
|
|
virtual void ChangeColorOfCurrentQuadVertices(float r, float g, float b, float a) = 0;
|
2018-04-03 15:40:21 +00:00
|
|
|
virtual void ChangeColorOfQuadVertices(int QuadOffset, unsigned char r, unsigned char g, unsigned char b, unsigned char a) = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-12-12 15:48:13 +00:00
|
|
|
virtual void TakeScreenshot(const char *pFilename) = 0;
|
2014-01-19 03:02:01 +00:00
|
|
|
virtual void TakeCustomScreenshot(const char *pFilename) = 0;
|
2015-08-24 20:46:28 +00:00
|
|
|
virtual int GetVideoModes(CVideoMode *pModes, int MaxModes, int Screen) = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
virtual void Swap() = 0;
|
2016-04-29 22:34:12 +00:00
|
|
|
virtual int GetNumScreens() const = 0;
|
2011-12-31 09:04:46 +00:00
|
|
|
|
2018-02-04 15:00:47 +00:00
|
|
|
// synchronization
|
2020-11-29 16:53:54 +00:00
|
|
|
virtual void InsertSignal(class CSemaphore *pSemaphore) = 0;
|
2021-02-08 21:26:26 +00:00
|
|
|
virtual bool IsIdle() const = 0;
|
2011-12-31 09:04:46 +00:00
|
|
|
virtual void WaitForIdle() = 0;
|
2014-10-18 14:17:36 +00:00
|
|
|
|
2015-08-24 23:01:38 +00:00
|
|
|
virtual void SetWindowGrab(bool Grab) = 0;
|
2014-10-18 14:17:36 +00:00
|
|
|
virtual void NotifyWindow() = 0;
|
2012-08-12 10:41:50 +00:00
|
|
|
|
2020-10-02 13:43:52 +00:00
|
|
|
virtual SWarning *GetCurWarning() = 0;
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2012-08-12 10:41:50 +00:00
|
|
|
protected:
|
|
|
|
inline CTextureHandle CreateTextureHandle(int Index)
|
|
|
|
{
|
|
|
|
CTextureHandle Tex;
|
|
|
|
Tex.m_Id = Index;
|
|
|
|
return Tex;
|
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IEngineGraphics : public IGraphics
|
|
|
|
{
|
|
|
|
MACRO_INTERFACE("enginegraphics", 0)
|
|
|
|
public:
|
2012-01-03 20:39:10 +00:00
|
|
|
virtual int Init() = 0;
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void Shutdown() = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual void Minimize() = 0;
|
|
|
|
virtual void Maximize() = 0;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
virtual int WindowActive() = 0;
|
|
|
|
virtual int WindowOpen() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern IEngineGraphics *CreateEngineGraphics();
|
2011-12-31 09:29:25 +00:00
|
|
|
extern IEngineGraphics *CreateEngineGraphicsThreaded();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
#endif
|