2018-07-06 14:11:38 +00:00
|
|
|
#ifndef ENGINE_CLIENT_GRAPHICS_THREADED_H
|
|
|
|
#define ENGINE_CLIENT_GRAPHICS_THREADED_H
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2012-01-03 20:39:10 +00:00
|
|
|
#include <engine/graphics.h>
|
Make sure headers compile standalone
Not planning to do this automatically, but at least cleaning it up once
provides some benefit. Every header should include what it uses.
$ for i in src/**/*.h; do j=${i#"src/"}; echo $j; echo "#include <$j>\nint main() { return 0; }" | /usr/bin/c++ -DCONF_OPENSSL -DCONF_SQL -DCONF_VIDEORECORDER -DCONF_WAVPACK_CLOSE_FILE -DCONF_WAVPACK_OPEN_FILE_INPUT_EX -DGAME_RELEASE_VERSION=\"15.0.5\" -DGLEW_STATIC -D_FORTIFY_SOURCE=2 -I/usr/include/freetype2 -I/usr/include/opus -I/usr/include/SDL2 -I/usr/include/wavpack -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -Isrc -I/usr/include/mysql -I/home/deen/sys/include/ -O2 -g -DNDEBUG -fdiagnostics-color=always -fstack-protector-all -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wformat=2 -Wno-nullability-completeness -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -std=gnu++11 -o /dev/null -x c++ -; done
Ignored: tuning.h, variables.h, config_common.h, mapitems_ex_types.h, mapbugs_list.h, protocol7.h, teehistorian_ex_chunks.h, protocol_ex_msgs.h, config.h, config_variables.h, external, keynames.h
2020-09-26 08:23:33 +00:00
|
|
|
#include <engine/shared/config.h>
|
2012-01-03 20:39:10 +00:00
|
|
|
|
2020-10-11 15:08:04 +00:00
|
|
|
#include <cstddef>
|
2017-09-12 18:08:45 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
#define CMD_BUFFER_DATA_BUFFER_SIZE 1024 * 1024 * 2
|
|
|
|
#define CMD_BUFFER_CMD_BUFFER_SIZE 1024 * 256
|
2018-03-13 20:47:07 +00:00
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
class CCommandBuffer
|
|
|
|
{
|
|
|
|
class CBuffer
|
|
|
|
{
|
|
|
|
unsigned char *m_pData;
|
|
|
|
unsigned m_Size;
|
|
|
|
unsigned m_Used;
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
public:
|
|
|
|
CBuffer(unsigned BufferSize)
|
|
|
|
{
|
|
|
|
m_Size = BufferSize;
|
|
|
|
m_pData = new unsigned char[m_Size];
|
|
|
|
m_Used = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
~CBuffer()
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
delete[] m_pData;
|
2011-12-31 00:11:24 +00:00
|
|
|
m_pData = 0x0;
|
|
|
|
m_Used = 0;
|
|
|
|
m_Size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Reset()
|
|
|
|
{
|
|
|
|
m_Used = 0;
|
|
|
|
}
|
|
|
|
|
2020-10-11 15:08:04 +00:00
|
|
|
void *Alloc(unsigned Requested, unsigned Alignment = alignof(std::max_align_t))
|
2011-12-31 00:11:24 +00:00
|
|
|
{
|
2020-10-13 15:30:30 +00:00
|
|
|
size_t Offset = reinterpret_cast<uintptr_t>(m_pData + m_Used) % Alignment;
|
|
|
|
if(Offset)
|
|
|
|
Offset = Alignment - Offset;
|
|
|
|
|
2020-10-11 15:08:04 +00:00
|
|
|
if(Requested + Offset + m_Used > m_Size)
|
2011-12-31 00:11:24 +00:00
|
|
|
return 0;
|
2020-10-11 15:08:04 +00:00
|
|
|
|
|
|
|
void *pPtr = &m_pData[m_Used + Offset];
|
|
|
|
m_Used += Requested + Offset;
|
2011-12-31 00:11:24 +00:00
|
|
|
return pPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char *DataPtr() { return m_pData; }
|
|
|
|
unsigned DataSize() { return m_Size; }
|
|
|
|
unsigned DataUsed() { return m_Used; }
|
|
|
|
};
|
|
|
|
|
2012-01-03 21:01:37 +00:00
|
|
|
public:
|
2011-12-31 00:11:24 +00:00
|
|
|
CBuffer m_CmdBuffer;
|
|
|
|
CBuffer m_DataBuffer;
|
2012-01-03 21:01:37 +00:00
|
|
|
|
2011-12-31 08:40:11 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-10-09 07:07:05 +00:00
|
|
|
MAX_TEXTURES = 1024 * 32,
|
2020-09-26 19:41:58 +00:00
|
|
|
MAX_VERTICES = 32 * 1024,
|
2011-12-31 08:40:11 +00:00
|
|
|
};
|
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
enum
|
|
|
|
{
|
2012-01-03 20:39:10 +00:00
|
|
|
// commadn groups
|
|
|
|
CMDGROUP_CORE = 0, // commands that everyone has to implement
|
2012-10-06 21:31:02 +00:00
|
|
|
CMDGROUP_PLATFORM_OPENGL = 10000, // commands specific to a platform
|
|
|
|
CMDGROUP_PLATFORM_SDL = 20000,
|
2011-12-31 00:11:24 +00:00
|
|
|
|
|
|
|
//
|
2012-01-03 20:39:10 +00:00
|
|
|
CMD_NOP = CMDGROUP_CORE,
|
2011-12-31 00:11:24 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
CMD_RUNBUFFER,
|
|
|
|
|
2018-02-04 15:00:47 +00:00
|
|
|
// synchronization
|
2011-12-31 00:11:24 +00:00
|
|
|
CMD_SIGNAL,
|
|
|
|
|
|
|
|
// texture commands
|
|
|
|
CMD_TEXTURE_CREATE,
|
|
|
|
CMD_TEXTURE_DESTROY,
|
2011-12-31 08:40:11 +00:00
|
|
|
CMD_TEXTURE_UPDATE,
|
2011-12-31 00:11:24 +00:00
|
|
|
|
|
|
|
// rendering
|
|
|
|
CMD_CLEAR,
|
|
|
|
CMD_RENDER,
|
2020-09-21 03:57:54 +00:00
|
|
|
CMD_RENDER_TEX3D,
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2020-08-22 06:09:10 +00:00
|
|
|
//opengl 2.0+ commands (some are just emulated and only exist in opengl 3.3+)
|
2018-03-13 20:47:07 +00:00
|
|
|
CMD_CREATE_BUFFER_OBJECT, // create vbo
|
|
|
|
CMD_RECREATE_BUFFER_OBJECT, // recreate vbo
|
|
|
|
CMD_UPDATE_BUFFER_OBJECT, // update vbo
|
|
|
|
CMD_COPY_BUFFER_OBJECT, // copy vbo to another
|
|
|
|
CMD_DELETE_BUFFER_OBJECT, // delete vbo
|
|
|
|
|
|
|
|
CMD_CREATE_BUFFER_CONTAINER, // create vao
|
|
|
|
CMD_DELETE_BUFFER_CONTAINER, // delete vao
|
|
|
|
CMD_UPDATE_BUFFER_CONTAINER, // update vao
|
|
|
|
|
|
|
|
CMD_INDICES_REQUIRED_NUM_NOTIFY, // create indices that are required
|
|
|
|
|
|
|
|
CMD_RENDER_TILE_LAYER, // render a tilelayer
|
|
|
|
CMD_RENDER_BORDER_TILE, // render one tile multiple times
|
|
|
|
CMD_RENDER_BORDER_TILE_LINE, // render an amount of tiles multiple times
|
|
|
|
CMD_RENDER_QUAD_LAYER, // render a quad layer
|
|
|
|
CMD_RENDER_TEXT, // render text
|
|
|
|
CMD_RENDER_TEXT_STREAM, // render text stream
|
|
|
|
CMD_RENDER_QUAD_CONTAINER, // render a quad buffer container
|
|
|
|
CMD_RENDER_QUAD_CONTAINER_SPRITE, // render a quad buffer container as sprite
|
|
|
|
CMD_RENDER_QUAD_CONTAINER_SPRITE_MULTIPLE, // render a quad buffer container as sprite multiple times
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
// swap
|
|
|
|
CMD_SWAP,
|
2012-01-01 12:38:46 +00:00
|
|
|
|
2012-01-01 13:30:45 +00:00
|
|
|
// misc
|
2016-04-29 22:34:12 +00:00
|
|
|
CMD_VSYNC,
|
2012-01-01 12:38:46 +00:00
|
|
|
CMD_SCREENSHOT,
|
2012-01-01 13:30:45 +00:00
|
|
|
CMD_VIDEOMODES,
|
2016-04-30 15:59:58 +00:00
|
|
|
CMD_RESIZE,
|
2012-01-03 20:39:10 +00:00
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
};
|
|
|
|
|
2011-12-31 08:40:11 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TEXFORMAT_INVALID = 0,
|
|
|
|
TEXFORMAT_RGB,
|
|
|
|
TEXFORMAT_RGBA,
|
|
|
|
TEXFORMAT_ALPHA,
|
2011-12-31 10:18:55 +00:00
|
|
|
|
|
|
|
TEXFLAG_NOMIPMAPS = 1,
|
2012-08-27 16:58:30 +00:00
|
|
|
TEXFLAG_COMPRESSED = 2,
|
2012-10-07 09:22:49 +00:00
|
|
|
TEXFLAG_QUALITY = 4,
|
2020-08-19 05:05:51 +00:00
|
|
|
TEXFLAG_TO_3D_TEXTURE = (1 << 3),
|
|
|
|
TEXFLAG_TO_2D_ARRAY_TEXTURE = (1 << 4),
|
|
|
|
TEXFLAG_TO_3D_TEXTURE_SINGLE_LAYER = (1 << 5),
|
|
|
|
TEXFLAG_TO_2D_ARRAY_TEXTURE_SINGLE_LAYER = (1 << 6),
|
2020-08-23 06:25:21 +00:00
|
|
|
TEXFLAG_NO_2D_TEXTURE = (1 << 7),
|
2011-12-31 08:40:11 +00:00
|
|
|
};
|
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
//
|
|
|
|
PRIMTYPE_INVALID = 0,
|
2015-07-09 00:08:14 +00:00
|
|
|
PRIMTYPE_LINES,
|
2011-12-31 00:11:24 +00:00
|
|
|
PRIMTYPE_QUADS,
|
2015-03-31 11:35:18 +00:00
|
|
|
PRIMTYPE_TRIANGLES,
|
2011-12-31 00:11:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
BLEND_NONE = 0,
|
|
|
|
BLEND_ALPHA,
|
|
|
|
BLEND_ADDITIVE,
|
|
|
|
};
|
|
|
|
|
2012-01-08 00:47:53 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
WRAP_REPEAT = 0,
|
|
|
|
WRAP_CLAMP,
|
|
|
|
};
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2018-04-03 15:40:21 +00:00
|
|
|
typedef GL_SPoint SPoint;
|
|
|
|
typedef GL_STexCoord STexCoord;
|
|
|
|
typedef GL_SColorf SColorf;
|
|
|
|
typedef GL_SColor SColor;
|
|
|
|
typedef GL_SVertex SVertex;
|
2020-09-21 03:57:54 +00:00
|
|
|
typedef GL_SVertexTex3D SVertexTex3D;
|
|
|
|
typedef GL_SVertexTex3DStream SVertexTex3DStream;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
|
|
|
struct SCommand
|
|
|
|
{
|
|
|
|
public:
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand(unsigned Cmd) :
|
2020-10-11 15:08:04 +00:00
|
|
|
m_Cmd(Cmd), m_pNext(nullptr) {}
|
2011-12-31 00:11:24 +00:00
|
|
|
unsigned m_Cmd;
|
2020-10-11 15:08:04 +00:00
|
|
|
SCommand *m_pNext;
|
2011-12-31 00:11:24 +00:00
|
|
|
};
|
2020-10-11 15:08:04 +00:00
|
|
|
SCommand *m_pCmdBufferHead;
|
|
|
|
SCommand *m_pCmdBufferTail;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
|
|
|
struct SState
|
|
|
|
{
|
|
|
|
int m_BlendMode;
|
2012-01-08 00:47:53 +00:00
|
|
|
int m_WrapMode;
|
2011-12-31 00:11:24 +00:00
|
|
|
int m_Texture;
|
|
|
|
SPoint m_ScreenTL;
|
|
|
|
SPoint m_ScreenBR;
|
|
|
|
|
|
|
|
// clip
|
|
|
|
bool m_ClipEnable;
|
|
|
|
int m_ClipX;
|
|
|
|
int m_ClipY;
|
|
|
|
int m_ClipW;
|
|
|
|
int m_ClipH;
|
|
|
|
};
|
2015-07-09 00:08:14 +00:00
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
struct SCommand_Clear : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_Clear() :
|
|
|
|
SCommand(CMD_CLEAR) {}
|
2017-09-27 10:16:34 +00:00
|
|
|
SColorf m_Color;
|
2011-12-31 00:11:24 +00:00
|
|
|
};
|
2015-07-09 00:08:14 +00:00
|
|
|
|
2011-12-31 09:04:46 +00:00
|
|
|
struct SCommand_Signal : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_Signal() :
|
|
|
|
SCommand(CMD_SIGNAL) {}
|
2011-12-31 09:04:46 +00:00
|
|
|
semaphore *m_pSemaphore;
|
|
|
|
};
|
2011-12-31 00:11:24 +00:00
|
|
|
|
|
|
|
struct SCommand_RunBuffer : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RunBuffer() :
|
|
|
|
SCommand(CMD_RUNBUFFER) {}
|
2011-12-31 00:11:24 +00:00
|
|
|
CCommandBuffer *m_pOtherBuffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_Render : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_Render() :
|
|
|
|
SCommand(CMD_RENDER) {}
|
2011-12-31 00:11:24 +00:00
|
|
|
SState m_State;
|
|
|
|
unsigned m_PrimType;
|
|
|
|
unsigned m_PrimCount;
|
2018-03-13 20:47:07 +00:00
|
|
|
SVertex *m_pVertices; // you should use the command buffer data to allocate vertices for this command
|
2011-12-31 00:11:24 +00:00
|
|
|
};
|
2018-03-13 20:47:07 +00:00
|
|
|
|
2020-09-21 03:57:54 +00:00
|
|
|
struct SCommand_RenderTex3D : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RenderTex3D() :
|
|
|
|
SCommand(CMD_RENDER_TEX3D) {}
|
2020-09-21 03:57:54 +00:00
|
|
|
SState m_State;
|
|
|
|
unsigned m_PrimType;
|
|
|
|
unsigned m_PrimCount;
|
|
|
|
SVertexTex3DStream *m_pVertices; // you should use the command buffer data to allocate vertices for this command
|
|
|
|
};
|
|
|
|
|
2018-03-13 20:47:07 +00:00
|
|
|
struct SCommand_CreateBufferObject : public SCommand
|
2017-09-12 18:08:45 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_CreateBufferObject() :
|
|
|
|
SCommand(CMD_CREATE_BUFFER_OBJECT) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
int m_BufferIndex;
|
|
|
|
|
2020-10-13 17:33:02 +00:00
|
|
|
bool m_DeletePointer;
|
2018-03-13 20:47:07 +00:00
|
|
|
void *m_pUploadData;
|
|
|
|
size_t m_DataSize;
|
2017-09-12 18:08:45 +00:00
|
|
|
};
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
struct SCommand_RecreateBufferObject : public SCommand
|
2017-09-12 18:08:45 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RecreateBufferObject() :
|
|
|
|
SCommand(CMD_RECREATE_BUFFER_OBJECT) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
int m_BufferIndex;
|
|
|
|
|
2020-10-13 17:33:02 +00:00
|
|
|
bool m_DeletePointer;
|
2018-03-13 20:47:07 +00:00
|
|
|
void *m_pUploadData;
|
|
|
|
size_t m_DataSize;
|
2017-09-12 18:08:45 +00:00
|
|
|
};
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
struct SCommand_UpdateBufferObject : public SCommand
|
2017-09-12 18:08:45 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_UpdateBufferObject() :
|
|
|
|
SCommand(CMD_UPDATE_BUFFER_OBJECT) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
int m_BufferIndex;
|
|
|
|
|
2020-10-13 17:33:02 +00:00
|
|
|
bool m_DeletePointer;
|
2018-03-13 20:47:07 +00:00
|
|
|
void *m_pOffset;
|
|
|
|
void *m_pUploadData;
|
|
|
|
size_t m_DataSize;
|
2017-09-12 18:08:45 +00:00
|
|
|
};
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
struct SCommand_CopyBufferObject : public SCommand
|
2017-09-12 18:08:45 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_CopyBufferObject() :
|
|
|
|
SCommand(CMD_COPY_BUFFER_OBJECT) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
int m_WriteBufferIndex;
|
|
|
|
int m_ReadBufferIndex;
|
|
|
|
|
|
|
|
size_t m_pReadOffset;
|
|
|
|
size_t m_pWriteOffset;
|
|
|
|
size_t m_CopySize;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_DeleteBufferObject : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_DeleteBufferObject() :
|
|
|
|
SCommand(CMD_DELETE_BUFFER_OBJECT) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
int m_BufferIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_CreateBufferContainer : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_CreateBufferContainer() :
|
|
|
|
SCommand(CMD_CREATE_BUFFER_CONTAINER) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
int m_BufferContainerIndex;
|
|
|
|
|
|
|
|
int m_Stride;
|
|
|
|
|
|
|
|
int m_AttrCount;
|
2020-09-26 19:41:58 +00:00
|
|
|
SBufferContainerInfo::SAttribute *m_Attributes;
|
2018-03-13 20:47:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_UpdateBufferContainer : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_UpdateBufferContainer() :
|
|
|
|
SCommand(CMD_UPDATE_BUFFER_CONTAINER) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
int m_BufferContainerIndex;
|
|
|
|
|
|
|
|
int m_Stride;
|
|
|
|
|
|
|
|
int m_AttrCount;
|
2020-09-26 19:41:58 +00:00
|
|
|
SBufferContainerInfo::SAttribute *m_Attributes;
|
2018-03-13 20:47:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_DeleteBufferContainer : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_DeleteBufferContainer() :
|
|
|
|
SCommand(CMD_DELETE_BUFFER_CONTAINER) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
int m_BufferContainerIndex;
|
|
|
|
bool m_DestroyAllBO;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_IndicesRequiredNumNotify : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_IndicesRequiredNumNotify() :
|
|
|
|
SCommand(CMD_INDICES_REQUIRED_NUM_NOTIFY) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
unsigned int m_RequiredIndicesNum;
|
|
|
|
};
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2018-03-13 20:47:07 +00:00
|
|
|
struct SCommand_RenderTileLayer : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RenderTileLayer() :
|
|
|
|
SCommand(CMD_RENDER_TILE_LAYER) {}
|
2017-09-12 18:08:45 +00:00
|
|
|
SState m_State;
|
2017-09-27 10:16:34 +00:00
|
|
|
SColorf m_Color; //the color of the whole tilelayer -- already envelopped
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2017-09-27 10:16:34 +00:00
|
|
|
//the char offset of all indices that should be rendered, and the amount of renders
|
2020-09-26 19:41:58 +00:00
|
|
|
char **m_pIndicesOffsets;
|
2017-12-02 21:19:57 +00:00
|
|
|
unsigned int *m_pDrawCount;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2017-09-12 18:08:45 +00:00
|
|
|
int m_IndicesDrawNum;
|
2018-03-13 20:47:07 +00:00
|
|
|
int m_BufferContainerIndex;
|
2017-09-12 18:08:45 +00:00
|
|
|
};
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2017-09-12 18:08:45 +00:00
|
|
|
struct SCommand_RenderBorderTile : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RenderBorderTile() :
|
|
|
|
SCommand(CMD_RENDER_BORDER_TILE) {}
|
2017-09-12 18:08:45 +00:00
|
|
|
SState m_State;
|
2017-09-27 10:16:34 +00:00
|
|
|
SColorf m_Color; //the color of the whole tilelayer -- already envelopped
|
2017-09-12 18:08:45 +00:00
|
|
|
char *m_pIndicesOffset; // you should use the command buffer data to allocate vertices for this command
|
|
|
|
unsigned int m_DrawNum;
|
2018-03-13 20:47:07 +00:00
|
|
|
int m_BufferContainerIndex;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2017-09-12 18:08:45 +00:00
|
|
|
float m_Offset[2];
|
|
|
|
float m_Dir[2];
|
|
|
|
int m_JumpIndex;
|
|
|
|
};
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2017-09-12 18:08:45 +00:00
|
|
|
struct SCommand_RenderBorderTileLine : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RenderBorderTileLine() :
|
|
|
|
SCommand(CMD_RENDER_BORDER_TILE_LINE) {}
|
2017-09-12 18:08:45 +00:00
|
|
|
SState m_State;
|
2017-09-27 10:16:34 +00:00
|
|
|
SColorf m_Color; //the color of the whole tilelayer -- already envelopped
|
2017-09-12 18:08:45 +00:00
|
|
|
char *m_pIndicesOffset; // you should use the command buffer data to allocate vertices for this command
|
|
|
|
unsigned int m_IndexDrawNum;
|
|
|
|
unsigned int m_DrawNum;
|
2018-03-13 20:47:07 +00:00
|
|
|
int m_BufferContainerIndex;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2018-08-02 16:26:12 +00:00
|
|
|
float m_Offset[2];
|
2017-09-12 18:08:45 +00:00
|
|
|
float m_Dir[2];
|
|
|
|
};
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
struct SCommand_RenderQuadLayer : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RenderQuadLayer() :
|
|
|
|
SCommand(CMD_RENDER_QUAD_LAYER) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
SState m_State;
|
|
|
|
|
|
|
|
int m_BufferContainerIndex;
|
2020-09-26 19:41:58 +00:00
|
|
|
SQuadRenderInfo *m_pQuadInfo;
|
2018-03-13 20:47:07 +00:00
|
|
|
int m_QuadNum;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_RenderText : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RenderText() :
|
|
|
|
SCommand(CMD_RENDER_TEXT) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
SState m_State;
|
|
|
|
|
|
|
|
int m_BufferContainerIndex;
|
|
|
|
int m_TextureSize;
|
|
|
|
|
|
|
|
int m_TextTextureIndex;
|
|
|
|
int m_TextOutlineTextureIndex;
|
|
|
|
|
|
|
|
int m_DrawNum;
|
|
|
|
float m_aTextColor[4];
|
|
|
|
float m_aTextOutlineColor[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_RenderTextStream : public SCommand
|
2017-09-12 18:08:45 +00:00
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RenderTextStream() :
|
|
|
|
SCommand(CMD_RENDER_TEXT_STREAM) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
SState m_State;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2018-03-13 20:47:07 +00:00
|
|
|
SVertex *m_pVertices;
|
2020-09-21 03:57:54 +00:00
|
|
|
unsigned m_PrimType;
|
|
|
|
unsigned m_PrimCount;
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
int m_TextureSize;
|
|
|
|
|
|
|
|
int m_TextTextureIndex;
|
|
|
|
int m_TextOutlineTextureIndex;
|
|
|
|
|
|
|
|
float m_aTextOutlineColor[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_RenderQuadContainer : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RenderQuadContainer() :
|
|
|
|
SCommand(CMD_RENDER_QUAD_CONTAINER) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
SState m_State;
|
|
|
|
|
|
|
|
int m_BufferContainerIndex;
|
|
|
|
|
|
|
|
unsigned int m_DrawNum;
|
|
|
|
void *m_pOffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_RenderQuadContainerAsSprite : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RenderQuadContainerAsSprite() :
|
|
|
|
SCommand(CMD_RENDER_QUAD_CONTAINER_SPRITE) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
SState m_State;
|
|
|
|
|
|
|
|
int m_BufferContainerIndex;
|
|
|
|
|
|
|
|
float m_Rotation;
|
|
|
|
SPoint m_Center;
|
|
|
|
|
|
|
|
SColorf m_VertexColor;
|
|
|
|
|
|
|
|
unsigned int m_DrawNum;
|
|
|
|
void *m_pOffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_RenderQuadContainerAsSpriteMultiple : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_RenderQuadContainerAsSpriteMultiple() :
|
|
|
|
SCommand(CMD_RENDER_QUAD_CONTAINER_SPRITE_MULTIPLE) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
SState m_State;
|
|
|
|
|
|
|
|
int m_BufferContainerIndex;
|
|
|
|
|
|
|
|
IGraphics::SRenderSpriteInfo *m_pRenderInfo;
|
|
|
|
|
|
|
|
SPoint m_Center;
|
|
|
|
SColorf m_VertexColor;
|
|
|
|
|
|
|
|
unsigned int m_DrawNum;
|
|
|
|
unsigned int m_DrawCount;
|
|
|
|
void *m_pOffset;
|
2017-09-12 18:08:45 +00:00
|
|
|
};
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2012-01-01 12:38:46 +00:00
|
|
|
struct SCommand_Screenshot : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_Screenshot() :
|
|
|
|
SCommand(CMD_SCREENSHOT) {}
|
2012-01-01 13:15:35 +00:00
|
|
|
CImageInfo *m_pImage; // processor will fill this out, the one who adds this command must free the data as well
|
2012-01-01 12:38:46 +00:00
|
|
|
};
|
|
|
|
|
2012-01-01 13:30:45 +00:00
|
|
|
struct SCommand_VideoModes : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_VideoModes() :
|
|
|
|
SCommand(CMD_VIDEOMODES) {}
|
2012-01-01 13:30:45 +00:00
|
|
|
|
|
|
|
CVideoMode *m_pModes; // processor will fill this in
|
|
|
|
int m_MaxModes; // maximum of modes the processor can write to the m_pModes
|
|
|
|
int *m_pNumModes; // processor will write to this pointer
|
2015-08-24 20:46:28 +00:00
|
|
|
int m_Screen;
|
2012-01-01 13:30:45 +00:00
|
|
|
};
|
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
struct SCommand_Swap : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_Swap() :
|
|
|
|
SCommand(CMD_SWAP) {}
|
2012-01-06 13:12:49 +00:00
|
|
|
|
|
|
|
int m_Finish;
|
2011-12-31 00:11:24 +00:00
|
|
|
};
|
2011-12-31 08:40:11 +00:00
|
|
|
|
2016-04-29 22:34:12 +00:00
|
|
|
struct SCommand_VSync : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_VSync() :
|
|
|
|
SCommand(CMD_VSYNC) {}
|
2016-04-29 22:34:12 +00:00
|
|
|
|
|
|
|
int m_VSync;
|
|
|
|
bool *m_pRetOk;
|
|
|
|
};
|
|
|
|
|
2016-04-30 15:59:58 +00:00
|
|
|
struct SCommand_Resize : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_Resize() :
|
|
|
|
SCommand(CMD_RESIZE) {}
|
2016-04-30 15:59:58 +00:00
|
|
|
|
|
|
|
int m_Width;
|
|
|
|
int m_Height;
|
|
|
|
};
|
|
|
|
|
2011-12-31 08:40:11 +00:00
|
|
|
struct SCommand_Texture_Create : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_Texture_Create() :
|
|
|
|
SCommand(CMD_TEXTURE_CREATE) {}
|
2011-12-31 08:40:11 +00:00
|
|
|
|
|
|
|
// texture information
|
|
|
|
int m_Slot;
|
|
|
|
|
|
|
|
int m_Width;
|
|
|
|
int m_Height;
|
2012-10-06 21:31:02 +00:00
|
|
|
int m_PixelSize;
|
2011-12-31 08:40:11 +00:00
|
|
|
int m_Format;
|
|
|
|
int m_StoreFormat;
|
2011-12-31 10:18:55 +00:00
|
|
|
int m_Flags;
|
2011-12-31 08:40:11 +00:00
|
|
|
void *m_pData; // will be freed by the command processor
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_Texture_Update : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_Texture_Update() :
|
|
|
|
SCommand(CMD_TEXTURE_UPDATE) {}
|
2011-12-31 08:40:11 +00:00
|
|
|
|
|
|
|
// texture information
|
|
|
|
int m_Slot;
|
|
|
|
|
|
|
|
int m_X;
|
|
|
|
int m_Y;
|
|
|
|
int m_Width;
|
|
|
|
int m_Height;
|
|
|
|
int m_Format;
|
|
|
|
void *m_pData; // will be freed by the command processor
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SCommand_Texture_Destroy : public SCommand
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SCommand_Texture_Destroy() :
|
|
|
|
SCommand(CMD_TEXTURE_DESTROY) {}
|
2011-12-31 08:40:11 +00:00
|
|
|
|
|
|
|
// texture information
|
|
|
|
int m_Slot;
|
|
|
|
};
|
2015-07-09 00:08:14 +00:00
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
//
|
2020-09-26 19:41:58 +00:00
|
|
|
CCommandBuffer(unsigned CmdBufferSize, unsigned DataBufferSize) :
|
2020-10-11 15:08:04 +00:00
|
|
|
m_CmdBuffer(CmdBufferSize), m_DataBuffer(DataBufferSize), m_pCmdBufferHead(nullptr), m_pCmdBufferTail(nullptr)
|
2011-12-31 00:11:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void *AllocData(unsigned WantedSize)
|
|
|
|
{
|
|
|
|
return m_DataBuffer.Alloc(WantedSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
2012-01-03 21:01:37 +00:00
|
|
|
bool AddCommand(const T &Command)
|
2011-12-31 00:11:24 +00:00
|
|
|
{
|
2012-01-03 20:39:10 +00:00
|
|
|
// make sure that we don't do something stupid like ->AddCommand(&Cmd);
|
|
|
|
(void)static_cast<const SCommand *>(&Command);
|
|
|
|
|
|
|
|
// allocate and copy the command into the buffer
|
2020-10-11 15:08:04 +00:00
|
|
|
T *pCmd = (T *)m_CmdBuffer.Alloc(sizeof(*pCmd), alignof(T));
|
2011-12-31 00:11:24 +00:00
|
|
|
if(!pCmd)
|
2012-01-03 21:01:37 +00:00
|
|
|
return false;
|
2020-10-11 15:08:04 +00:00
|
|
|
*pCmd = Command;
|
|
|
|
pCmd->m_pNext = nullptr;
|
|
|
|
|
|
|
|
if(m_pCmdBufferTail)
|
|
|
|
m_pCmdBufferTail->m_pNext = pCmd;
|
|
|
|
if(!m_pCmdBufferHead)
|
|
|
|
m_pCmdBufferHead = pCmd;
|
|
|
|
m_pCmdBufferTail = pCmd;
|
|
|
|
|
2012-01-03 21:01:37 +00:00
|
|
|
return true;
|
2011-12-31 00:11:24 +00:00
|
|
|
}
|
|
|
|
|
2020-10-11 15:08:04 +00:00
|
|
|
SCommand *Head()
|
2011-12-31 00:11:24 +00:00
|
|
|
{
|
2020-10-11 15:08:04 +00:00
|
|
|
return m_pCmdBufferHead;
|
2011-12-31 00:11:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Reset()
|
|
|
|
{
|
2020-10-11 15:08:04 +00:00
|
|
|
m_pCmdBufferHead = m_pCmdBufferTail = nullptr;
|
2011-12-31 00:11:24 +00:00
|
|
|
m_CmdBuffer.Reset();
|
|
|
|
m_DataBuffer.Reset();
|
2012-01-03 21:01:37 +00:00
|
|
|
}
|
2011-12-31 00:11:24 +00:00
|
|
|
};
|
|
|
|
|
2020-08-22 06:09:10 +00:00
|
|
|
enum EGraphicsBackendErrorCodes
|
|
|
|
{
|
|
|
|
GRAPHICS_BACKEND_ERROR_CODE_UNKNOWN = -1,
|
|
|
|
GRAPHICS_BACKEND_ERROR_CODE_NONE = 0,
|
|
|
|
GRAPHICS_BACKEND_ERROR_CODE_OPENGL_CONTEXT_FAILED,
|
|
|
|
GRAPHICS_BACKEND_ERROR_CODE_OPENGL_VERSION_FAILED,
|
|
|
|
GRAPHICS_BACKEND_ERROR_CODE_SDL_INIT_FAILED,
|
|
|
|
GRAPHICS_BACKEND_ERROR_CODE_SDL_SCREEN_REQUEST_FAILED,
|
|
|
|
GRAPHICS_BACKEND_ERROR_CODE_SDL_SCREEN_INFO_REQUEST_FAILED,
|
|
|
|
GRAPHICS_BACKEND_ERROR_CODE_SDL_SCREEN_RESOLUTION_REQUEST_FAILED,
|
|
|
|
GRAPHICS_BACKEND_ERROR_CODE_SDL_WINDOW_CREATE_FAILED,
|
|
|
|
};
|
|
|
|
|
2012-01-03 20:39:10 +00:00
|
|
|
// interface for the graphics backend
|
|
|
|
// all these functions are called on the main thread
|
|
|
|
class IGraphicsBackend
|
2011-12-31 00:11:24 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-01-03 20:39:10 +00:00
|
|
|
enum
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
INITFLAG_FULLSCREEN = 1 << 0,
|
|
|
|
INITFLAG_VSYNC = 1 << 1,
|
|
|
|
INITFLAG_RESIZABLE = 1 << 2,
|
|
|
|
INITFLAG_BORDERLESS = 1 << 3,
|
|
|
|
INITFLAG_HIGHDPI = 1 << 4,
|
2012-01-03 20:39:10 +00:00
|
|
|
};
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2012-08-16 22:03:53 +00:00
|
|
|
virtual ~IGraphicsBackend() {}
|
|
|
|
|
2017-12-02 21:19:57 +00:00
|
|
|
virtual int Init(const char *pName, int *Screen, int *pWidth, int *pHeight, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight, int *pCurrentWidth, int *pCurrentHeight, class IStorage *pStorage) = 0;
|
2012-01-03 20:39:10 +00:00
|
|
|
virtual int Shutdown() = 0;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2012-10-06 21:31:02 +00:00
|
|
|
virtual int MemoryUsage() const = 0;
|
|
|
|
|
2016-04-29 22:34:12 +00:00
|
|
|
virtual int GetNumScreens() const = 0;
|
|
|
|
|
2012-01-03 20:39:10 +00:00
|
|
|
virtual void Minimize() = 0;
|
|
|
|
virtual void Maximize() = 0;
|
2016-04-29 19:07:10 +00:00
|
|
|
virtual bool Fullscreen(bool State) = 0;
|
2016-04-29 22:34:12 +00:00
|
|
|
virtual void SetWindowBordered(bool State) = 0;
|
|
|
|
virtual bool SetWindowScreen(int Index) = 0;
|
|
|
|
virtual int GetWindowScreen() = 0;
|
2012-01-03 20:39:10 +00:00
|
|
|
virtual int WindowActive() = 0;
|
|
|
|
virtual int WindowOpen() = 0;
|
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-01-01 13:15:35 +00:00
|
|
|
|
2012-01-03 20:39:10 +00:00
|
|
|
virtual void RunBuffer(CCommandBuffer *pBuffer) = 0;
|
|
|
|
virtual bool IsIdle() const = 0;
|
|
|
|
virtual void WaitForIdle() = 0;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2020-08-18 18:26:35 +00:00
|
|
|
virtual bool IsNewOpenGL() { return false; }
|
2020-08-22 06:09:10 +00:00
|
|
|
virtual bool HasTileBuffering() { return false; }
|
|
|
|
virtual bool HasQuadBuffering() { return false; }
|
|
|
|
virtual bool HasTextBuffering() { return false; }
|
|
|
|
virtual bool HasQuadContainerBuffering() { return false; }
|
|
|
|
virtual bool Has2DTextureArrays() { return false; }
|
2011-12-31 00:11:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CGraphics_Threaded : public IEngineGraphics
|
|
|
|
{
|
2012-01-03 21:01:37 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
NUM_CMDBUFFERS = 2,
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
DRAWING_QUADS = 1,
|
|
|
|
DRAWING_LINES = 2
|
2012-01-03 21:01:37 +00:00
|
|
|
};
|
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
CCommandBuffer::SState m_State;
|
2012-01-03 20:39:10 +00:00
|
|
|
IGraphicsBackend *m_pBackend;
|
2020-08-22 06:09:10 +00:00
|
|
|
bool m_OpenGLTileBufferingEnabled;
|
|
|
|
bool m_OpenGLQuadBufferingEnabled;
|
|
|
|
bool m_OpenGLTextBufferingEnabled;
|
|
|
|
bool m_OpenGLQuadContainerBufferingEnabled;
|
2020-08-19 05:05:51 +00:00
|
|
|
bool m_OpenGLHasTextureArrays;
|
2020-08-18 18:26:35 +00:00
|
|
|
bool m_IsNewOpenGL;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2012-01-03 21:01:37 +00:00
|
|
|
CCommandBuffer *m_apCommandBuffers[NUM_CMDBUFFERS];
|
2011-12-31 00:11:24 +00:00
|
|
|
CCommandBuffer *m_pCommandBuffer;
|
|
|
|
unsigned m_CurrentCommandBuffer;
|
|
|
|
|
|
|
|
//
|
|
|
|
class IStorage *m_pStorage;
|
|
|
|
class IConsole *m_pConsole;
|
|
|
|
|
2020-09-21 03:57:54 +00:00
|
|
|
int m_CurIndex;
|
|
|
|
|
2020-10-09 07:07:05 +00:00
|
|
|
CCommandBuffer::SVertex m_aVertices[CCommandBuffer::MAX_VERTICES];
|
|
|
|
CCommandBuffer::SVertexTex3DStream m_aVerticesTex3D[CCommandBuffer::MAX_VERTICES];
|
2011-12-31 00:11:24 +00:00
|
|
|
int m_NumVertices;
|
|
|
|
|
|
|
|
CCommandBuffer::SColor m_aColor[4];
|
|
|
|
CCommandBuffer::STexCoord m_aTexture[4];
|
|
|
|
|
|
|
|
bool m_RenderEnable;
|
|
|
|
|
|
|
|
float m_Rotation;
|
|
|
|
int m_Drawing;
|
|
|
|
bool m_DoScreenshot;
|
|
|
|
char m_aScreenshotName[128];
|
|
|
|
|
2012-08-12 10:41:50 +00:00
|
|
|
CTextureHandle m_InvalidTexture;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-10-09 07:07:05 +00:00
|
|
|
int m_aTextureIndices[CCommandBuffer::MAX_TEXTURES];
|
2011-12-31 00:11:24 +00:00
|
|
|
int m_FirstFreeTexture;
|
|
|
|
int m_TextureMemoryUsage;
|
|
|
|
|
2020-10-09 07:07:05 +00:00
|
|
|
std::vector<uint8_t> m_SpriteHelper;
|
|
|
|
|
2020-10-02 13:43:52 +00:00
|
|
|
std::vector<SWarning> m_Warnings;
|
2020-08-29 10:49:45 +00:00
|
|
|
|
2018-03-13 20:47:07 +00:00
|
|
|
struct SVertexArrayInfo
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SVertexArrayInfo() :
|
|
|
|
m_FreeIndex(-1) {}
|
2018-03-13 20:47:07 +00:00
|
|
|
// keep a reference to them, so we can free their IDs
|
|
|
|
std::vector<int> m_AssociatedBufferObjectIndices;
|
|
|
|
|
|
|
|
int m_FreeIndex;
|
|
|
|
};
|
|
|
|
std::vector<SVertexArrayInfo> m_VertexArrayInfo;
|
|
|
|
int m_FirstFreeVertexArrayInfo;
|
|
|
|
|
|
|
|
std::vector<int> m_BufferObjectIndices;
|
|
|
|
int m_FirstFreeBufferObjectIndex;
|
|
|
|
|
|
|
|
struct SQuadContainer
|
|
|
|
{
|
|
|
|
SQuadContainer()
|
|
|
|
{
|
|
|
|
m_Quads.clear();
|
|
|
|
m_QuadBufferObjectIndex = m_QuadBufferContainerIndex = -1;
|
|
|
|
m_FreeIndex = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SQuad
|
|
|
|
{
|
|
|
|
CCommandBuffer::SVertex m_aVertices[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<SQuad> m_Quads;
|
|
|
|
|
|
|
|
int m_QuadBufferObjectIndex;
|
|
|
|
int m_QuadBufferContainerIndex;
|
|
|
|
|
|
|
|
int m_FreeIndex;
|
|
|
|
};
|
|
|
|
std::vector<SQuadContainer> m_QuadContainers;
|
|
|
|
int m_FirstFreeQuadContainer;
|
|
|
|
|
2018-03-21 14:48:48 +00:00
|
|
|
struct SWindowResizeListener
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SWindowResizeListener(WINDOW_RESIZE_FUNC pFunc, void *pUser) :
|
|
|
|
m_pFunc(pFunc), m_pUser(pUser) {}
|
2018-03-21 14:48:48 +00:00
|
|
|
WINDOW_RESIZE_FUNC m_pFunc;
|
|
|
|
void *m_pUser;
|
|
|
|
};
|
|
|
|
std::vector<SWindowResizeListener> m_ResizeListeners;
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
void *AllocCommandBufferData(unsigned AllocSize);
|
2018-03-13 20:47:07 +00:00
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
void AddVertices(int Count);
|
2020-09-21 03:57:54 +00:00
|
|
|
void AddVertices(int Count, CCommandBuffer::SVertex *pVertices);
|
|
|
|
void AddVertices(int Count, CCommandBuffer::SVertexTex3DStream *pVertices);
|
|
|
|
|
|
|
|
template<typename TName>
|
|
|
|
void Rotate(const CCommandBuffer::SPoint &rCenter, TName *pPoints, int NumPoints)
|
|
|
|
{
|
|
|
|
float c = cosf(m_Rotation);
|
|
|
|
float s = sinf(m_Rotation);
|
|
|
|
float x, y;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
TName *pVertices = pPoints;
|
|
|
|
for(i = 0; i < NumPoints; i++)
|
|
|
|
{
|
|
|
|
x = pVertices[i].m_Pos.x - rCenter.x;
|
|
|
|
y = pVertices[i].m_Pos.y - rCenter.y;
|
|
|
|
pVertices[i].m_Pos.x = x * c - y * s + rCenter.x;
|
|
|
|
pVertices[i].m_Pos.y = x * s + y * c + rCenter.y;
|
|
|
|
}
|
|
|
|
}
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2012-01-01 13:15:35 +00:00
|
|
|
void KickCommandBuffer();
|
|
|
|
|
2011-12-31 13:00:49 +00:00
|
|
|
int IssueInit();
|
|
|
|
int InitWindow();
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
public:
|
|
|
|
CGraphics_Threaded();
|
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void ClipEnable(int x, int y, int w, int h) override;
|
|
|
|
void ClipDisable() override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void BlendNone() override;
|
|
|
|
void BlendNormal() override;
|
|
|
|
void BlendAdditive() override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void WrapNormal() override;
|
|
|
|
void WrapClamp() override;
|
2012-01-08 00:47:53 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
int MemoryUsage() const override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void MapScreen(float TopLeftX, float TopLeftY, float BottomRightX, float BottomRightY) override;
|
|
|
|
void GetScreen(float *pTopLeftX, float *pTopLeftY, float *pBottomRightX, float *pBottomRightY) override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void LinesBegin() override;
|
|
|
|
void LinesEnd() override;
|
|
|
|
void LinesDraw(const CLineItem *pArray, int Num) override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
int UnloadTexture(IGraphics::CTextureHandle Index) override;
|
2020-10-09 07:07:05 +00:00
|
|
|
int UnloadTextureNew(CTextureHandle &TextureHandle) override;
|
2020-09-08 22:41:56 +00:00
|
|
|
IGraphics::CTextureHandle LoadTextureRaw(int Width, int Height, int Format, const void *pData, int StoreFormat, int Flags, const char *pTexName = NULL) override;
|
|
|
|
int LoadTextureRawSub(IGraphics::CTextureHandle TextureID, int x, int y, int Width, int Height, int Format, const void *pData) override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-10-09 07:07:05 +00:00
|
|
|
CTextureHandle LoadSpriteTextureImpl(CImageInfo &FromImageInfo, int x, int y, int w, int h);
|
|
|
|
CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct CDataSprite *pSprite) override;
|
|
|
|
CTextureHandle LoadSpriteTexture(CImageInfo &FromImageInfo, struct client_data7::CDataSprite *pSprite) override;
|
|
|
|
|
|
|
|
bool IsImageSubFullyTransparent(CImageInfo &FromImageInfo, int x, int y, int w, int h) override;
|
|
|
|
bool IsSpriteTextureFullyTransparent(CImageInfo &FromImageInfo, struct client_data7::CDataSprite *pSprite) override;
|
|
|
|
|
2011-12-31 00:11:24 +00:00
|
|
|
// simple uncompressed RGBA loaders
|
2020-09-08 22:41:56 +00:00
|
|
|
IGraphics::CTextureHandle LoadTexture(const char *pFilename, int StorageType, int StoreFormat, int Flags) override;
|
|
|
|
int LoadPNG(CImageInfo *pImg, const char *pFilename, int StorageType) override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-10 22:42:42 +00:00
|
|
|
void CopyTextureBufferSub(uint8_t *pDestBuffer, uint8_t *pSourceBuffer, int FullWidth, int FullHeight, int ColorChannelCount, int SubOffsetX, int SubOffsetY, int SubCopyWidth, int SubCopyHeight) override;
|
2020-10-09 07:07:05 +00:00
|
|
|
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) override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2014-01-19 03:02:01 +00:00
|
|
|
void ScreenshotDirect();
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void TextureSet(CTextureHandle TextureID) override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void Clear(float r, float g, float b) override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void QuadsBegin() override;
|
|
|
|
void QuadsEnd() override;
|
|
|
|
void TextQuadsBegin() override;
|
2020-09-10 22:42:42 +00:00
|
|
|
void TextQuadsEnd(int TextureSize, int TextTextureIndex, int TextOutlineTextureIndex, float *pOutlineTextColor) override;
|
2020-09-21 03:57:54 +00:00
|
|
|
void QuadsTex3DBegin() override;
|
|
|
|
void QuadsTex3DEnd() override;
|
2020-09-08 22:41:56 +00:00
|
|
|
void QuadsEndKeepVertices() override;
|
|
|
|
void QuadsDrawCurrentVertices(bool KeepVertices = true) override;
|
|
|
|
void QuadsSetRotation(float Angle) override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-21 03:57:54 +00:00
|
|
|
template<typename TName>
|
|
|
|
void SetColor(TName *pVertex, int ColorIndex)
|
|
|
|
{
|
|
|
|
TName *pVert = pVertex;
|
|
|
|
pVert->m_Color.r = m_aColor[ColorIndex].r;
|
|
|
|
pVert->m_Color.g = m_aColor[ColorIndex].g;
|
|
|
|
pVert->m_Color.b = m_aColor[ColorIndex].b;
|
|
|
|
pVert->m_Color.a = m_aColor[ColorIndex].a;
|
|
|
|
}
|
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void SetColorVertex(const CColorVertex *pArray, int Num) override;
|
|
|
|
void SetColor(float r, float g, float b, float a) override;
|
|
|
|
void SetColor(ColorRGBA rgb) override;
|
2020-09-11 12:25:50 +00:00
|
|
|
void SetColor4(vec4 TopLeft, vec4 TopRight, vec4 BottomLeft, vec4 BottomRight) override;
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
// go through all vertices and change their color (only works for quads)
|
2020-09-08 22:41:56 +00:00
|
|
|
void ChangeColorOfCurrentQuadVertices(float r, float g, float b, float a) override;
|
|
|
|
void ChangeColorOfQuadVertices(int QuadOffset, unsigned char r, unsigned char g, unsigned char b, unsigned char a) override;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void QuadsSetSubset(float TlU, float TlV, float BrU, float BrV) override;
|
|
|
|
void QuadsSetSubsetFree(
|
2011-12-31 00:11:24 +00:00
|
|
|
float x0, float y0, float x1, float y1,
|
2020-09-21 03:57:54 +00:00
|
|
|
float x2, float y2, float x3, float y3, int Index = -1) override;
|
2020-09-08 22:41:56 +00:00
|
|
|
|
|
|
|
void QuadsDraw(CQuadItem *pArray, int Num) override;
|
2020-09-21 03:57:54 +00:00
|
|
|
|
|
|
|
template<typename TName>
|
|
|
|
void QuadsDrawTLImpl(TName *pVertices, const CQuadItem *pArray, int Num)
|
|
|
|
{
|
|
|
|
CCommandBuffer::SPoint Center;
|
|
|
|
|
|
|
|
dbg_assert(m_Drawing == DRAWING_QUADS, "called Graphics()->QuadsDrawTL without begin");
|
|
|
|
|
|
|
|
if(g_Config.m_GfxQuadAsTriangle && !m_IsNewOpenGL)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < Num; ++i)
|
|
|
|
{
|
|
|
|
// first triangle
|
|
|
|
pVertices[m_NumVertices + 6 * i].m_Pos.x = pArray[i].m_X;
|
|
|
|
pVertices[m_NumVertices + 6 * i].m_Pos.y = pArray[i].m_Y;
|
|
|
|
pVertices[m_NumVertices + 6 * i].m_Tex = m_aTexture[0];
|
|
|
|
SetColor(&pVertices[m_NumVertices + 6 * i], 0);
|
|
|
|
|
|
|
|
pVertices[m_NumVertices + 6 * i + 1].m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
|
|
|
|
pVertices[m_NumVertices + 6 * i + 1].m_Pos.y = pArray[i].m_Y;
|
|
|
|
pVertices[m_NumVertices + 6 * i + 1].m_Tex = m_aTexture[1];
|
|
|
|
SetColor(&pVertices[m_NumVertices + 6 * i + 1], 1);
|
|
|
|
|
|
|
|
pVertices[m_NumVertices + 6 * i + 2].m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
|
|
|
|
pVertices[m_NumVertices + 6 * i + 2].m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
|
|
|
|
pVertices[m_NumVertices + 6 * i + 2].m_Tex = m_aTexture[2];
|
|
|
|
SetColor(&pVertices[m_NumVertices + 6 * i + 2], 2);
|
|
|
|
|
|
|
|
// second triangle
|
|
|
|
pVertices[m_NumVertices + 6 * i + 3].m_Pos.x = pArray[i].m_X;
|
|
|
|
pVertices[m_NumVertices + 6 * i + 3].m_Pos.y = pArray[i].m_Y;
|
|
|
|
pVertices[m_NumVertices + 6 * i + 3].m_Tex = m_aTexture[0];
|
|
|
|
SetColor(&pVertices[m_NumVertices + 6 * i + 3], 0);
|
|
|
|
|
|
|
|
pVertices[m_NumVertices + 6 * i + 4].m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
|
|
|
|
pVertices[m_NumVertices + 6 * i + 4].m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
|
|
|
|
pVertices[m_NumVertices + 6 * i + 4].m_Tex = m_aTexture[2];
|
|
|
|
SetColor(&pVertices[m_NumVertices + 6 * i + 4], 2);
|
|
|
|
|
|
|
|
pVertices[m_NumVertices + 6 * i + 5].m_Pos.x = pArray[i].m_X;
|
|
|
|
pVertices[m_NumVertices + 6 * i + 5].m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
|
|
|
|
pVertices[m_NumVertices + 6 * i + 5].m_Tex = m_aTexture[3];
|
|
|
|
SetColor(&pVertices[m_NumVertices + 6 * i + 5], 3);
|
|
|
|
|
|
|
|
if(m_Rotation != 0)
|
|
|
|
{
|
|
|
|
Center.x = pArray[i].m_X + pArray[i].m_Width / 2;
|
|
|
|
Center.y = pArray[i].m_Y + pArray[i].m_Height / 2;
|
|
|
|
|
|
|
|
Rotate(Center, &pVertices[m_NumVertices + 6 * i], 6);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AddVertices(3 * 2 * Num, pVertices);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for(int i = 0; i < Num; ++i)
|
|
|
|
{
|
|
|
|
pVertices[m_NumVertices + 4 * i].m_Pos.x = pArray[i].m_X;
|
|
|
|
pVertices[m_NumVertices + 4 * i].m_Pos.y = pArray[i].m_Y;
|
|
|
|
pVertices[m_NumVertices + 4 * i].m_Tex = m_aTexture[0];
|
|
|
|
SetColor(&pVertices[m_NumVertices + 4 * i], 0);
|
|
|
|
|
|
|
|
pVertices[m_NumVertices + 4 * i + 1].m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
|
|
|
|
pVertices[m_NumVertices + 4 * i + 1].m_Pos.y = pArray[i].m_Y;
|
|
|
|
pVertices[m_NumVertices + 4 * i + 1].m_Tex = m_aTexture[1];
|
|
|
|
SetColor(&pVertices[m_NumVertices + 4 * i + 1], 1);
|
|
|
|
|
|
|
|
pVertices[m_NumVertices + 4 * i + 2].m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
|
|
|
|
pVertices[m_NumVertices + 4 * i + 2].m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
|
|
|
|
pVertices[m_NumVertices + 4 * i + 2].m_Tex = m_aTexture[2];
|
|
|
|
SetColor(&pVertices[m_NumVertices + 4 * i + 2], 2);
|
|
|
|
|
|
|
|
pVertices[m_NumVertices + 4 * i + 3].m_Pos.x = pArray[i].m_X;
|
|
|
|
pVertices[m_NumVertices + 4 * i + 3].m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
|
|
|
|
pVertices[m_NumVertices + 4 * i + 3].m_Tex = m_aTexture[3];
|
|
|
|
SetColor(&pVertices[m_NumVertices + 4 * i + 3], 3);
|
|
|
|
|
|
|
|
if(m_Rotation != 0)
|
|
|
|
{
|
|
|
|
Center.x = pArray[i].m_X + pArray[i].m_Width / 2;
|
|
|
|
Center.y = pArray[i].m_Y + pArray[i].m_Height / 2;
|
|
|
|
|
|
|
|
Rotate(Center, &pVertices[m_NumVertices + 4 * i], 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AddVertices(4 * Num, pVertices);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void QuadsDrawTL(const CQuadItem *pArray, int Num) override;
|
2020-09-21 03:57:54 +00:00
|
|
|
|
|
|
|
void QuadsTex3DDrawTL(const CQuadItem *pArray, int Num) override;
|
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void QuadsDrawFreeform(const CFreeformItem *pArray, int Num) override;
|
|
|
|
void QuadsText(float x, float y, float Size, const char *pText) override;
|
|
|
|
|
|
|
|
int CreateQuadContainer() override;
|
|
|
|
void QuadContainerUpload(int ContainerIndex) override;
|
|
|
|
void QuadContainerAddQuads(int ContainerIndex, CQuadItem *pArray, int Num) override;
|
|
|
|
void QuadContainerAddQuads(int ContainerIndex, CFreeformItem *pArray, int Num) override;
|
|
|
|
void QuadContainerReset(int ContainerIndex) override;
|
|
|
|
void DeleteQuadContainer(int ContainerIndex) override;
|
|
|
|
void RenderQuadContainer(int ContainerIndex, int QuadDrawNum) override;
|
|
|
|
void RenderQuadContainer(int ContainerIndex, int QuadOffset, int QuadDrawNum) override;
|
|
|
|
void RenderQuadContainerAsSprite(int ContainerIndex, int QuadOffset, float X, float Y, float ScaleX = 1.f, float ScaleY = 1.f) override;
|
|
|
|
void RenderQuadContainerAsSpriteMultiple(int ContainerIndex, int QuadOffset, int DrawCount, SRenderSpriteInfo *pRenderInfo) override;
|
|
|
|
|
2020-09-21 03:57:54 +00:00
|
|
|
template<typename TName>
|
|
|
|
void FlushVerticesImpl(bool KeepVertices, int &PrimType, int &PrimCount, int &NumVerts, TName &Command, size_t VertSize)
|
|
|
|
{
|
|
|
|
Command.m_pVertices = NULL;
|
|
|
|
if(m_NumVertices == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
NumVerts = m_NumVertices;
|
|
|
|
|
|
|
|
if(!KeepVertices)
|
|
|
|
m_NumVertices = 0;
|
|
|
|
|
|
|
|
if(m_Drawing == DRAWING_QUADS)
|
|
|
|
{
|
|
|
|
if(g_Config.m_GfxQuadAsTriangle && !m_IsNewOpenGL)
|
|
|
|
{
|
|
|
|
PrimType = CCommandBuffer::PRIMTYPE_TRIANGLES;
|
|
|
|
PrimCount = NumVerts / 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PrimType = CCommandBuffer::PRIMTYPE_QUADS;
|
|
|
|
PrimCount = NumVerts / 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(m_Drawing == DRAWING_LINES)
|
|
|
|
{
|
|
|
|
PrimType = CCommandBuffer::PRIMTYPE_LINES;
|
|
|
|
PrimCount = NumVerts / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
Command.m_pVertices = (decltype(Command.m_pVertices))m_pCommandBuffer->AllocData(VertSize * NumVerts);
|
|
|
|
if(Command.m_pVertices == NULL)
|
|
|
|
{
|
|
|
|
// kick command buffer and try again
|
|
|
|
KickCommandBuffer();
|
|
|
|
|
|
|
|
Command.m_pVertices = (decltype(Command.m_pVertices))m_pCommandBuffer->AllocData(VertSize * NumVerts);
|
|
|
|
if(Command.m_pVertices == NULL)
|
|
|
|
{
|
|
|
|
dbg_msg("graphics", "failed to allocate data for vertices");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Command.m_State = m_State;
|
|
|
|
|
|
|
|
Command.m_PrimType = PrimType;
|
|
|
|
Command.m_PrimCount = PrimCount;
|
|
|
|
|
|
|
|
// check if we have enough free memory in the commandbuffer
|
|
|
|
if(!m_pCommandBuffer->AddCommand(Command))
|
|
|
|
{
|
|
|
|
// kick command buffer and try again
|
|
|
|
KickCommandBuffer();
|
|
|
|
|
|
|
|
Command.m_pVertices = (decltype(Command.m_pVertices))m_pCommandBuffer->AllocData(VertSize * NumVerts);
|
|
|
|
if(Command.m_pVertices == NULL)
|
|
|
|
{
|
|
|
|
dbg_msg("graphics", "failed to allocate data for vertices");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!m_pCommandBuffer->AddCommand(Command))
|
|
|
|
{
|
|
|
|
dbg_msg("graphics", "failed to allocate memory for render command");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void FlushVertices(bool KeepVertices = false) override;
|
|
|
|
void FlushTextVertices(int TextureSize, int TextTextureIndex, int TextOutlineTextureIndex, float *pOutlineTextColor) override;
|
2020-09-21 03:57:54 +00:00
|
|
|
void FlushVerticesTex3D() override;
|
2020-09-08 22:41:56 +00:00
|
|
|
|
|
|
|
void RenderTileLayer(int BufferContainerIndex, float *pColor, char **pOffsets, unsigned int *IndicedVertexDrawNum, size_t NumIndicesOffet) override;
|
|
|
|
void RenderBorderTiles(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, int JumpIndex, unsigned int DrawNum) override;
|
|
|
|
void RenderBorderTileLines(int BufferContainerIndex, float *pColor, char *pIndexBufferOffset, float *pOffset, float *pDir, unsigned int IndexDrawNum, unsigned int RedrawNum) override;
|
2020-09-10 22:42:42 +00:00
|
|
|
void RenderQuadLayer(int BufferContainerIndex, SQuadRenderInfo *pQuadInfo, int QuadNum) override;
|
|
|
|
void RenderText(int BufferContainerIndex, int TextQuadNum, int TextureSize, int TextureTextIndex, int TextureTextOutlineIndex, float *pTextColor, float *pTextoutlineColor) override;
|
2018-03-13 20:47:07 +00:00
|
|
|
|
|
|
|
// opengl 3.3 functions
|
2020-10-13 17:33:02 +00:00
|
|
|
int CreateBufferObject(size_t UploadDataSize, void *pUploadData, bool IsMovedPointer = false) override;
|
|
|
|
void RecreateBufferObject(int BufferIndex, size_t UploadDataSize, void *pUploadData, bool IsMovedPointer = false) override;
|
|
|
|
void UpdateBufferObject(int BufferIndex, size_t UploadDataSize, void *pUploadData, void *pOffset, bool IsMovedPointer = false) override;
|
2020-09-08 22:41:56 +00:00
|
|
|
void CopyBufferObject(int WriteBufferIndex, int ReadBufferIndex, size_t WriteOffset, size_t ReadOffset, size_t CopyDataSize) override;
|
|
|
|
void DeleteBufferObject(int BufferIndex) override;
|
2018-03-13 20:47:07 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
int CreateBufferContainer(SBufferContainerInfo *pContainerInfo) override;
|
2018-03-13 20:47:07 +00:00
|
|
|
// destroying all buffer objects means, that all referenced VBOs are destroyed automatically, so the user does not need to save references to them
|
2020-09-08 22:41:56 +00:00
|
|
|
void DeleteBufferContainer(int ContainerIndex, bool DestroyAllBO = true) override;
|
|
|
|
void UpdateBufferContainer(int ContainerIndex, SBufferContainerInfo *pContainerInfo) override;
|
|
|
|
void IndicesNumRequiredNotify(unsigned int RequiredIndicesCount) override;
|
2018-03-13 20:47:07 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
int GetNumScreens() const override;
|
|
|
|
void Minimize() override;
|
|
|
|
void Maximize() override;
|
|
|
|
bool Fullscreen(bool State) override;
|
|
|
|
void SetWindowBordered(bool State) override;
|
|
|
|
bool SetWindowScreen(int Index) override;
|
|
|
|
void Resize(int w, int h) override;
|
|
|
|
void AddWindowResizeListener(WINDOW_RESIZE_FUNC pFunc, void *pUser) override;
|
|
|
|
int GetWindowScreen() override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
int WindowActive() override;
|
|
|
|
int WindowOpen() override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void SetWindowGrab(bool Grab) override;
|
|
|
|
void NotifyWindow() override;
|
2014-10-18 14:17:36 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
int Init() override;
|
|
|
|
void Shutdown() override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
void TakeScreenshot(const char *pFilename) override;
|
|
|
|
void TakeCustomScreenshot(const char *pFilename) override;
|
|
|
|
void Swap() override;
|
|
|
|
bool SetVSync(bool State) override;
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
int GetVideoModes(CVideoMode *pModes, int MaxModes, int Screen) override;
|
2015-08-24 20:46:28 +00:00
|
|
|
|
|
|
|
virtual int GetDesktopScreenWidth() { return m_DesktopScreenWidth; }
|
|
|
|
virtual int GetDesktopScreenHeight() { return m_DesktopScreenHeight; }
|
2011-12-31 00:11:24 +00:00
|
|
|
|
2018-02-04 15:00:47 +00:00
|
|
|
// synchronization
|
2020-09-08 22:41:56 +00:00
|
|
|
void InsertSignal(semaphore *pSemaphore) override;
|
|
|
|
bool IsIdle() override;
|
|
|
|
void WaitForIdle() override;
|
2019-04-26 22:11:15 +00:00
|
|
|
|
2020-10-02 13:43:52 +00:00
|
|
|
SWarning *GetCurWarning() override;
|
2020-08-29 10:49:45 +00:00
|
|
|
|
2020-09-08 22:41:56 +00:00
|
|
|
bool IsTileBufferingEnabled() override { return m_OpenGLTileBufferingEnabled; }
|
|
|
|
bool IsQuadBufferingEnabled() override { return m_OpenGLQuadBufferingEnabled; }
|
|
|
|
bool IsTextBufferingEnabled() override { return m_OpenGLTextBufferingEnabled; }
|
|
|
|
bool IsQuadContainerBufferingEnabled() override { return m_OpenGLQuadContainerBufferingEnabled; }
|
|
|
|
bool HasTextureArrays() override { return m_OpenGLHasTextureArrays; }
|
2012-01-03 20:39:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern IGraphicsBackend *CreateGraphicsBackend();
|
2018-07-06 14:11:38 +00:00
|
|
|
|
|
|
|
#endif // ENGINE_CLIENT_GRAPHICS_THREADED_H
|