mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 01:24:18 +00:00
parent
7450e354de
commit
a07e9ac2cf
|
@ -1107,6 +1107,8 @@ set(EXPECTED_DATA
|
|||
maps7/Gold\ Mine.map
|
||||
maps7/readme.txt
|
||||
particles.png
|
||||
shader/pipeline.frag
|
||||
shader/pipeline.vert
|
||||
shader/prim.frag
|
||||
shader/prim.vert
|
||||
shader/quad.frag
|
||||
|
|
18
data/shader/pipeline.frag
Normal file
18
data/shader/pipeline.frag
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifdef TW_TEXTURED
|
||||
#ifdef TW_3D_TEXTURED
|
||||
uniform sampler3D gTextureSampler;
|
||||
#else
|
||||
uniform sampler2DArray gTextureSampler;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef TW_TEXTURED
|
||||
vec4 TexColor = texture(gTextureSampler, gl_TexCoord[0].xyz).rgba;
|
||||
gl_FragColor = TexColor.rgba * gl_Color.rgba;
|
||||
#else
|
||||
gl_FragColor = gl_Color.rgba;
|
||||
#endif
|
||||
}
|
||||
|
11
data/shader/pipeline.vert
Normal file
11
data/shader/pipeline.vert
Normal file
|
@ -0,0 +1,11 @@
|
|||
uniform mat4x2 gPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(gPos * vec4(gl_Vertex.xy, 0.0, 1.0), 0.0, 1.0);
|
||||
#ifdef TW_TEXTURED
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
#endif
|
||||
gl_FrontColor = gl_Color.rgba;
|
||||
gl_BackColor = gl_Color.rgba;
|
||||
}
|
|
@ -16,7 +16,7 @@ out vec4 FragClr;
|
|||
void main()
|
||||
{
|
||||
#ifdef TW_TILE_TEXTURED
|
||||
vec4 TexColor = texture(gTextureSampler, TexCoord);
|
||||
vec4 TexColor = texture(gTextureSampler, TexCoord.xyz);
|
||||
FragClr = TexColor * gVertColor;
|
||||
#else
|
||||
FragClr = gVertColor;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include "graphics_threaded.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
# if defined(CONF_PLATFORM_MACOSX)
|
||||
#include <objc/objc-runtime.h>
|
||||
|
||||
|
@ -73,58 +75,25 @@ public:
|
|||
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand);
|
||||
};
|
||||
|
||||
// takes care of opengl related rendering
|
||||
class CCommandProcessorFragment_OpenGL
|
||||
|
||||
struct SBackendCapabilites
|
||||
{
|
||||
struct CTexture
|
||||
{
|
||||
GLuint m_Tex;
|
||||
int m_MemSize;
|
||||
bool m_TileBuffering;
|
||||
bool m_QuadBuffering;
|
||||
bool m_TextBuffering;
|
||||
bool m_QuadContainerBuffering;
|
||||
|
||||
int m_Width;
|
||||
int m_Height;
|
||||
int m_RescaleCount;
|
||||
};
|
||||
CTexture m_aTextures[CCommandBuffer::MAX_TEXTURES];
|
||||
volatile int *m_pTextureMemoryUsage;
|
||||
bool m_MipMapping;
|
||||
bool m_3DTextures;
|
||||
bool m_2DArrayTextures;
|
||||
bool m_2DArrayTexturesAsExtension;
|
||||
bool m_ShaderSupport;
|
||||
|
||||
GLint m_MaxTexSize;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
CMD_INIT = CCommandBuffer::CMDGROUP_PLATFORM_OPENGL,
|
||||
};
|
||||
|
||||
struct SCommand_Init : public CCommandBuffer::SCommand
|
||||
{
|
||||
SCommand_Init() : SCommand(CMD_INIT) {}
|
||||
volatile int *m_pTextureMemoryUsage;
|
||||
};
|
||||
|
||||
private:
|
||||
static int TexFormatToOpenGLFormat(int TexFormat);
|
||||
static unsigned char Sample(int w, int h, const unsigned char *pData, int u, int v, int Offset, int ScaleW, int ScaleH, int Bpp);
|
||||
static void *Rescale(int Width, int Height, int NewWidth, int NewHeight, int Format, const unsigned char *pData);
|
||||
|
||||
void SetState(const CCommandBuffer::SState &State);
|
||||
|
||||
void Cmd_Init(const SCommand_Init *pCommand);
|
||||
void Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand);
|
||||
void Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand);
|
||||
void Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand);
|
||||
void Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand);
|
||||
void Cmd_Render(const CCommandBuffer::SCommand_Render *pCommand);
|
||||
void Cmd_Screenshot(const CCommandBuffer::SCommand_Screenshot *pCommand);
|
||||
|
||||
public:
|
||||
CCommandProcessorFragment_OpenGL();
|
||||
|
||||
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand);
|
||||
int m_ContextMajor;
|
||||
int m_ContextMinor;
|
||||
int m_ContextPatch;
|
||||
};
|
||||
|
||||
|
||||
#define MAX_STREAM_BUFFER_COUNT 30
|
||||
|
||||
class CGLSLProgram;
|
||||
class CGLSLTWProgram;
|
||||
class CGLSLPrimitiveProgram;
|
||||
|
@ -133,36 +102,187 @@ class CGLSLTileProgram;
|
|||
class CGLSLTextProgram;
|
||||
class CGLSLSpriteProgram;
|
||||
class CGLSLSpriteMultipleProgram;
|
||||
// takes care of opengl 3.3+ related rendering
|
||||
class CCommandProcessorFragment_OpenGL3_3
|
||||
|
||||
// takes care of opengl related rendering
|
||||
class CCommandProcessorFragment_OpenGL
|
||||
{
|
||||
bool m_UseMultipleTextureUnits;
|
||||
bool m_UsePreinitializedVertexBuffer;
|
||||
|
||||
protected:
|
||||
struct CTexture
|
||||
{
|
||||
CTexture() : m_Tex2DArray(0), m_Sampler2DArray(0) {}
|
||||
GLuint m_Tex;
|
||||
GLuint m_Tex2DArray;
|
||||
GLuint m_Tex2DArray; //or 3D texture as fallback
|
||||
GLuint m_Sampler;
|
||||
GLuint m_Sampler2DArray;
|
||||
GLuint m_Sampler2DArray; //or 3D texture as fallback
|
||||
int m_LastWrapMode;
|
||||
|
||||
int m_MemSize;
|
||||
|
||||
int m_Width;
|
||||
int m_Height;
|
||||
|
||||
int m_RescaleCount;
|
||||
};
|
||||
CTexture m_aTextures[CCommandBuffer::MAX_TEXTURES];
|
||||
volatile int *m_pTextureMemoryUsage;
|
||||
std::atomic<int> *m_pTextureMemoryUsage;
|
||||
|
||||
GLint m_MaxTexSize;
|
||||
|
||||
bool m_Has2DArrayTextures;
|
||||
bool m_Has2DArrayTexturesAsExtension;
|
||||
GLenum m_2DArrayTarget;
|
||||
bool m_Has3DTextures;
|
||||
bool m_HasMipMaps;
|
||||
|
||||
bool m_HasShaders;
|
||||
int m_LastBlendMode; //avoid all possible opengl state changes
|
||||
bool m_LastClipEnable;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
CMD_INIT = CCommandBuffer::CMDGROUP_PLATFORM_OPENGL,
|
||||
CMD_SHUTDOWN = CMD_INIT + 1,
|
||||
};
|
||||
|
||||
struct SCommand_Init : public CCommandBuffer::SCommand
|
||||
{
|
||||
SCommand_Init() : SCommand(CMD_INIT) {}
|
||||
class IStorage *m_pStorage;
|
||||
std::atomic<int> *m_pTextureMemoryUsage;
|
||||
const SBackendCapabilites* m_pCapabilities;
|
||||
};
|
||||
|
||||
struct SCommand_Shutdown : public CCommandBuffer::SCommand
|
||||
{
|
||||
SCommand_Shutdown() : SCommand(CMD_SHUTDOWN) {}
|
||||
};
|
||||
|
||||
protected:
|
||||
void SetState(const CCommandBuffer::SState &State, bool Use2DArrayTexture = false);
|
||||
virtual bool IsNewApi() { return false; }
|
||||
|
||||
static int TexFormatToOpenGLFormat(int TexFormat);
|
||||
static int TexFormatToImageColorChannelCount(int TexFormat);
|
||||
static unsigned char Sample(int w, int h, const unsigned char *pData, int u, int v, int Offset, int ScaleW, int ScaleH, int Bpp);
|
||||
static void *Rescale(int Width, int Height, int NewWidth, int NewHeight, int Format, const unsigned char *pData);
|
||||
|
||||
virtual void Cmd_Init(const SCommand_Init *pCommand);
|
||||
virtual void Cmd_Shutdown(const SCommand_Shutdown *pCommand) {}
|
||||
virtual void Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand);
|
||||
virtual void Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand);
|
||||
virtual void Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand);
|
||||
virtual void Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand);
|
||||
virtual void Cmd_Render(const CCommandBuffer::SCommand_Render *pCommand);
|
||||
virtual void Cmd_Screenshot(const CCommandBuffer::SCommand_Screenshot *pCommand);
|
||||
|
||||
virtual void Cmd_CreateBufferObject(const CCommandBuffer::SCommand_CreateBufferObject *pCommand) {}
|
||||
virtual void Cmd_RecreateBufferObject(const CCommandBuffer::SCommand_RecreateBufferObject *pCommand) {}
|
||||
virtual void Cmd_UpdateBufferObject(const CCommandBuffer::SCommand_UpdateBufferObject *pCommand) {}
|
||||
virtual void Cmd_CopyBufferObject(const CCommandBuffer::SCommand_CopyBufferObject *pCommand) {}
|
||||
virtual void Cmd_DeleteBufferObject(const CCommandBuffer::SCommand_DeleteBufferObject *pCommand) {}
|
||||
|
||||
virtual void Cmd_CreateBufferContainer(const CCommandBuffer::SCommand_CreateBufferContainer *pCommand) {}
|
||||
virtual void Cmd_UpdateBufferContainer(const CCommandBuffer::SCommand_UpdateBufferContainer *pCommand) {}
|
||||
virtual void Cmd_DeleteBufferContainer(const CCommandBuffer::SCommand_DeleteBufferContainer *pCommand) {}
|
||||
virtual void Cmd_IndicesRequiredNumNotify(const CCommandBuffer::SCommand_IndicesRequiredNumNotify *pCommand) {}
|
||||
|
||||
virtual void Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand) {}
|
||||
virtual void Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand) {}
|
||||
virtual void Cmd_RenderBorderTileLine(const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand) {}
|
||||
virtual void Cmd_RenderQuadLayer(const CCommandBuffer::SCommand_RenderQuadLayer *pCommand) {}
|
||||
virtual void Cmd_RenderText(const CCommandBuffer::SCommand_RenderText *pCommand) {}
|
||||
virtual void Cmd_RenderTextStream(const CCommandBuffer::SCommand_RenderTextStream *pCommand) {}
|
||||
virtual void Cmd_RenderQuadContainer(const CCommandBuffer::SCommand_RenderQuadContainer *pCommand) {}
|
||||
virtual void Cmd_RenderQuadContainerAsSprite(const CCommandBuffer::SCommand_RenderQuadContainerAsSprite *pCommand) {}
|
||||
virtual void Cmd_RenderQuadContainerAsSpriteMultiple(const CCommandBuffer::SCommand_RenderQuadContainerAsSpriteMultiple *pCommand) {}
|
||||
public:
|
||||
CCommandProcessorFragment_OpenGL();
|
||||
|
||||
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand);
|
||||
};
|
||||
|
||||
class CCommandProcessorFragment_OpenGL2 : public CCommandProcessorFragment_OpenGL {
|
||||
struct SBufferContainer
|
||||
{
|
||||
SBufferContainer() {}
|
||||
SBufferContainerInfo m_ContainerInfo;
|
||||
};
|
||||
std::vector<SBufferContainer> m_BufferContainers;
|
||||
|
||||
GL_SVertexTex3D m_aStreamVertices[1024 * 4];
|
||||
|
||||
struct SBufferObject
|
||||
{
|
||||
SBufferObject(GLuint BufferObjectID) : m_BufferObjectID(BufferObjectID)
|
||||
{
|
||||
m_pData = NULL;
|
||||
m_DataSize = 0;
|
||||
}
|
||||
GLuint m_BufferObjectID;
|
||||
void* m_pData;
|
||||
size_t m_DataSize;
|
||||
};
|
||||
|
||||
std::vector<SBufferObject> m_BufferObjectIndices;
|
||||
|
||||
void RenderBorderTileEmulation(SBufferContainer& BufferContainer, const CCommandBuffer::SState& State, const float* pColor, const char *pBuffOffset, unsigned int DrawNum, const float* pOffset, const float* pDir, int JumpIndex);
|
||||
void RenderBorderTileLineEmulation(SBufferContainer& BufferContainer, const CCommandBuffer::SState& State, const float* pColor, const char *pBuffOffset, unsigned int IndexDrawNum, unsigned int DrawNum, const float* pOffset, const float* pDir);
|
||||
|
||||
void UseProgram(CGLSLTWProgram *pProgram);
|
||||
protected:
|
||||
void SetState(const CCommandBuffer::SState &State, CGLSLTWProgram *pProgram, bool Use2DArrayTextures = false);
|
||||
|
||||
void Cmd_Init(const SCommand_Init *pCommand) override;
|
||||
|
||||
void Cmd_CreateBufferObject(const CCommandBuffer::SCommand_CreateBufferObject *pCommand) override;
|
||||
void Cmd_RecreateBufferObject(const CCommandBuffer::SCommand_RecreateBufferObject *pCommand) override;
|
||||
void Cmd_UpdateBufferObject(const CCommandBuffer::SCommand_UpdateBufferObject *pCommand) override;
|
||||
void Cmd_CopyBufferObject(const CCommandBuffer::SCommand_CopyBufferObject *pCommand) override;
|
||||
void Cmd_DeleteBufferObject(const CCommandBuffer::SCommand_DeleteBufferObject *pCommand) override;
|
||||
|
||||
void Cmd_CreateBufferContainer(const CCommandBuffer::SCommand_CreateBufferContainer *pCommand) override;
|
||||
void Cmd_UpdateBufferContainer(const CCommandBuffer::SCommand_UpdateBufferContainer *pCommand) override;
|
||||
void Cmd_DeleteBufferContainer(const CCommandBuffer::SCommand_DeleteBufferContainer *pCommand) override;
|
||||
void Cmd_IndicesRequiredNumNotify(const CCommandBuffer::SCommand_IndicesRequiredNumNotify *pCommand) override;
|
||||
|
||||
void Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand) override;
|
||||
void Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand) override;
|
||||
void Cmd_RenderBorderTileLine(const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand) override;
|
||||
|
||||
CGLSLTileProgram *m_pTileProgram;
|
||||
CGLSLTileProgram *m_pTileProgramTextured;
|
||||
CGLSLPrimitiveProgram *m_pPrimitive3DProgram;
|
||||
CGLSLPrimitiveProgram *m_pPrimitive3DProgramTextured;
|
||||
|
||||
bool m_UseMultipleTextureUnits;
|
||||
|
||||
GLint m_MaxTextureUnits;
|
||||
|
||||
struct STextureBound{
|
||||
int m_TextureSlot;
|
||||
bool m_Is2DArray;
|
||||
};
|
||||
std::vector<STextureBound> m_TextureSlotBoundToUnit; //the texture index generated by loadtextureraw is stored in an index calculated by max texture units
|
||||
|
||||
bool IsAndUpdateTextureSlotBound(int IDX, int Slot, bool Is2DArray = false);
|
||||
public:
|
||||
CCommandProcessorFragment_OpenGL2() : CCommandProcessorFragment_OpenGL(), m_UseMultipleTextureUnits(false) {}
|
||||
};
|
||||
|
||||
class CCommandProcessorFragment_OpenGL3 : public CCommandProcessorFragment_OpenGL2 {
|
||||
|
||||
};
|
||||
|
||||
#define MAX_STREAM_BUFFER_COUNT 30
|
||||
|
||||
// takes care of opengl 3.3+ related rendering
|
||||
class CCommandProcessorFragment_OpenGL3_3 : public CCommandProcessorFragment_OpenGL3
|
||||
{
|
||||
bool m_UsePreinitializedVertexBuffer;
|
||||
|
||||
int m_MaxQuadsAtOnce;
|
||||
static const int m_MaxQuadsPossible = 256;
|
||||
|
||||
CGLSLPrimitiveProgram *m_pPrimitiveProgram;
|
||||
CGLSLTileProgram *m_pTileProgram;
|
||||
CGLSLTileProgram *m_pTileProgramTextured;
|
||||
CGLSLTileProgram *m_pBorderTileProgram;
|
||||
CGLSLTileProgram *m_pBorderTileProgramTextured;
|
||||
CGLSLTileProgram *m_pBorderTileLineProgram;
|
||||
|
@ -184,20 +304,7 @@ class CCommandProcessorFragment_OpenGL3_3
|
|||
|
||||
GLuint m_QuadDrawIndexBufferID;
|
||||
unsigned int m_CurrentIndicesInBuffer;
|
||||
|
||||
GLint m_MaxTextureUnits;
|
||||
GLint m_MaxTexSize;
|
||||
|
||||
int m_LastBlendMode; //avoid all possible opengl state changes
|
||||
bool m_LastClipEnable;
|
||||
|
||||
struct STextureBound{
|
||||
int m_TextureSlot;
|
||||
bool m_Is2DArray;
|
||||
};
|
||||
std::vector<STextureBound> m_TextureSlotBoundToUnit; //the texture index generated by loadtextureraw is stored in an index calculated by max texture units
|
||||
|
||||
bool IsAndUpdateTextureSlotBound(int IDX, int Slot, bool Is2DArray = false);
|
||||
|
||||
void DestroyTexture(int Slot);
|
||||
void DestroyBufferContainer(int Index, bool DeleteBOs = true);
|
||||
|
||||
|
@ -215,69 +322,45 @@ class CCommandProcessorFragment_OpenGL3_3
|
|||
std::vector<GLuint> m_BufferObjectIndices;
|
||||
|
||||
CCommandBuffer::SColorf m_ClearColor;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
CMD_INIT = CCommandBuffer::CMDGROUP_PLATFORM_OPENGL3_3,
|
||||
CMD_SHUTDOWN,
|
||||
};
|
||||
protected:
|
||||
static int TexFormatToNewOpenGLFormat(int TexFormat);
|
||||
bool IsNewApi() override { return true; }
|
||||
|
||||
struct SCommand_Init : public CCommandBuffer::SCommand
|
||||
{
|
||||
SCommand_Init() : SCommand(CMD_INIT) {}
|
||||
class IStorage *m_pStorage;
|
||||
volatile int *m_pTextureMemoryUsage;
|
||||
};
|
||||
|
||||
struct SCommand_Shutdown : public CCommandBuffer::SCommand
|
||||
{
|
||||
SCommand_Shutdown() : SCommand(CMD_SHUTDOWN) {}
|
||||
};
|
||||
|
||||
private:
|
||||
static int TexFormatToOpenGLFormat(int TexFormat);
|
||||
static int TexFormatToImageColorChannelCount(int TexFormat);
|
||||
static unsigned char Sample(int w, int h, const unsigned char *pData, int u, int v, int Offset, int ScaleW, int ScaleH, int Bpp);
|
||||
static void *Rescale(int Width, int Height, int NewWidth, int NewHeight, int Format, const unsigned char *pData);
|
||||
|
||||
void SetState(const CCommandBuffer::SState &State, CGLSLTWProgram *pProgram, bool Use2DArrayTextures = false);
|
||||
void UseProgram(CGLSLTWProgram *pProgram);
|
||||
void UploadStreamBufferData(unsigned int PrimitiveType, const void* pVertices, unsigned int PrimitiveCount);
|
||||
void RenderText(const CCommandBuffer::SState& State, int DrawNum, int TextTextureIndex, int TextOutlineTextureIndex, int TextureSize, const float* pTextColor, const float* pTextOutlineColor);
|
||||
|
||||
void Cmd_Init(const SCommand_Init *pCommand);
|
||||
void Cmd_Shutdown(const SCommand_Shutdown *pCommand);
|
||||
void Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand);
|
||||
void Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand);
|
||||
void Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand);
|
||||
void Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand);
|
||||
void Cmd_Render(const CCommandBuffer::SCommand_Render *pCommand);
|
||||
void Cmd_Screenshot(const CCommandBuffer::SCommand_Screenshot *pCommand);
|
||||
void Cmd_Init(const SCommand_Init *pCommand) override;
|
||||
void Cmd_Shutdown(const SCommand_Shutdown *pCommand) override;
|
||||
void Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand) override;
|
||||
void Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand) override;
|
||||
void Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand) override;
|
||||
void Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand) override;
|
||||
void Cmd_Render(const CCommandBuffer::SCommand_Render *pCommand) override;
|
||||
void Cmd_Screenshot(const CCommandBuffer::SCommand_Screenshot *pCommand) override;
|
||||
|
||||
void Cmd_CreateBufferObject(const CCommandBuffer::SCommand_CreateBufferObject *pCommand);
|
||||
void Cmd_RecreateBufferObject(const CCommandBuffer::SCommand_RecreateBufferObject *pCommand);
|
||||
void Cmd_UpdateBufferObject(const CCommandBuffer::SCommand_UpdateBufferObject *pCommand);
|
||||
void Cmd_CopyBufferObject(const CCommandBuffer::SCommand_CopyBufferObject *pCommand);
|
||||
void Cmd_DeleteBufferObject(const CCommandBuffer::SCommand_DeleteBufferObject *pCommand);
|
||||
void Cmd_CreateBufferObject(const CCommandBuffer::SCommand_CreateBufferObject *pCommand) override;
|
||||
void Cmd_RecreateBufferObject(const CCommandBuffer::SCommand_RecreateBufferObject *pCommand) override;
|
||||
void Cmd_UpdateBufferObject(const CCommandBuffer::SCommand_UpdateBufferObject *pCommand) override;
|
||||
void Cmd_CopyBufferObject(const CCommandBuffer::SCommand_CopyBufferObject *pCommand) override;
|
||||
void Cmd_DeleteBufferObject(const CCommandBuffer::SCommand_DeleteBufferObject *pCommand) override;
|
||||
|
||||
void Cmd_CreateBufferContainer(const CCommandBuffer::SCommand_CreateBufferContainer *pCommand);
|
||||
void Cmd_UpdateBufferContainer(const CCommandBuffer::SCommand_UpdateBufferContainer *pCommand);
|
||||
void Cmd_DeleteBufferContainer(const CCommandBuffer::SCommand_DeleteBufferContainer *pCommand);
|
||||
void Cmd_IndicesRequiredNumNotify(const CCommandBuffer::SCommand_IndicesRequiredNumNotify *pCommand);
|
||||
void Cmd_CreateBufferContainer(const CCommandBuffer::SCommand_CreateBufferContainer *pCommand) override;
|
||||
void Cmd_UpdateBufferContainer(const CCommandBuffer::SCommand_UpdateBufferContainer *pCommand) override;
|
||||
void Cmd_DeleteBufferContainer(const CCommandBuffer::SCommand_DeleteBufferContainer *pCommand) override;
|
||||
void Cmd_IndicesRequiredNumNotify(const CCommandBuffer::SCommand_IndicesRequiredNumNotify *pCommand) override;
|
||||
|
||||
void Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand);
|
||||
void Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand);
|
||||
void Cmd_RenderBorderTileLine(const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand);
|
||||
void Cmd_RenderQuadLayer(const CCommandBuffer::SCommand_RenderQuadLayer *pCommand);
|
||||
void Cmd_RenderText(const CCommandBuffer::SCommand_RenderText *pCommand);
|
||||
void Cmd_RenderTextStream(const CCommandBuffer::SCommand_RenderTextStream *pCommand);
|
||||
void Cmd_RenderQuadContainer(const CCommandBuffer::SCommand_RenderQuadContainer *pCommand);
|
||||
void Cmd_RenderQuadContainerAsSprite(const CCommandBuffer::SCommand_RenderQuadContainerAsSprite *pCommand);
|
||||
void Cmd_RenderQuadContainerAsSpriteMultiple(const CCommandBuffer::SCommand_RenderQuadContainerAsSpriteMultiple *pCommand);
|
||||
void Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand) override;
|
||||
void Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand) override;
|
||||
void Cmd_RenderBorderTileLine(const CCommandBuffer::SCommand_RenderBorderTileLine *pCommand) override;
|
||||
void Cmd_RenderQuadLayer(const CCommandBuffer::SCommand_RenderQuadLayer *pCommand) override;
|
||||
void Cmd_RenderText(const CCommandBuffer::SCommand_RenderText *pCommand) override;
|
||||
void Cmd_RenderTextStream(const CCommandBuffer::SCommand_RenderTextStream *pCommand) override;
|
||||
void Cmd_RenderQuadContainer(const CCommandBuffer::SCommand_RenderQuadContainer *pCommand) override;
|
||||
void Cmd_RenderQuadContainerAsSprite(const CCommandBuffer::SCommand_RenderQuadContainerAsSprite *pCommand) override;
|
||||
void Cmd_RenderQuadContainerAsSpriteMultiple(const CCommandBuffer::SCommand_RenderQuadContainerAsSpriteMultiple *pCommand) override;
|
||||
public:
|
||||
CCommandProcessorFragment_OpenGL3_3();
|
||||
|
||||
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand);
|
||||
CCommandProcessorFragment_OpenGL3_3() = default;
|
||||
};
|
||||
|
||||
// takes care of sdl related commands
|
||||
|
@ -299,6 +382,13 @@ public:
|
|||
SCommand_Init() : SCommand(CMD_INIT) {}
|
||||
SDL_Window *m_pWindow;
|
||||
SDL_GLContext m_GLContext;
|
||||
SBackendCapabilites* m_pCapabilities;
|
||||
|
||||
int* m_pInitError;
|
||||
|
||||
int m_RequestedMajor;
|
||||
int m_RequestedMinor;
|
||||
int m_RequestedPatch;
|
||||
};
|
||||
|
||||
struct SCommand_Update_Viewport : public CCommandBuffer::SCommand
|
||||
|
@ -332,14 +422,11 @@ public:
|
|||
// command processor impelementation, uses the fragments to combine into one processor
|
||||
class CCommandProcessor_SDL_OpenGL : public CGraphicsBackend_Threaded::ICommandProcessor
|
||||
{
|
||||
CCommandProcessorFragment_OpenGL m_OpenGL;
|
||||
CCommandProcessorFragment_OpenGL3_3 m_OpenGL3_3;
|
||||
CCommandProcessorFragment_OpenGL *m_pOpenGL;
|
||||
CCommandProcessorFragment_SDL m_SDL;
|
||||
CCommandProcessorFragment_General m_General;
|
||||
|
||||
bool m_UseOpenGL3_3;
|
||||
public:
|
||||
void UseOpenGL3_3(bool Use) { m_UseOpenGL3_3 = Use; }
|
||||
CCommandProcessor_SDL_OpenGL(int OpenGLMajor, int OpenGLMinor, int OpenGLPatch);
|
||||
virtual void RunBuffer(CCommandBuffer *pBuffer);
|
||||
};
|
||||
|
||||
|
@ -349,8 +436,10 @@ class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded
|
|||
SDL_Window *m_pWindow;
|
||||
SDL_GLContext m_GLContext;
|
||||
ICommandProcessor *m_pProcessor;
|
||||
volatile int m_TextureMemoryUsage;
|
||||
std::atomic<int> m_TextureMemoryUsage;
|
||||
int m_NumScreens;
|
||||
|
||||
SBackendCapabilites m_Capabilites;
|
||||
|
||||
bool m_UseNewOpenGL;
|
||||
public:
|
||||
|
@ -373,6 +462,11 @@ public:
|
|||
virtual void NotifyWindow();
|
||||
|
||||
virtual bool IsNewOpenGL() { return m_UseNewOpenGL; }
|
||||
virtual bool HasTileBuffering() { return m_Capabilites.m_TileBuffering; }
|
||||
virtual bool HasQuadBuffering() { return m_Capabilites.m_QuadBuffering; }
|
||||
virtual bool HasTextBuffering() { return m_Capabilites.m_TextBuffering; }
|
||||
virtual bool HasQuadContainerBuffering() { return m_Capabilites.m_QuadContainerBuffering; }
|
||||
virtual bool Has2DTextureArrays() { return m_Capabilites.m_2DArrayTextures; }
|
||||
};
|
||||
|
||||
#endif // ENGINE_CLIENT_BACKEND_SDL_H
|
||||
|
|
|
@ -1207,7 +1207,7 @@ int CGraphics_Threaded::CreateQuadContainer()
|
|||
|
||||
void CGraphics_Threaded::QuadContainerUpload(int ContainerIndex)
|
||||
{
|
||||
if(m_IsNewOpenGL)
|
||||
if(IsQuadContainerBufferingEnabled())
|
||||
{
|
||||
SQuadContainer& Container = m_QuadContainers[ContainerIndex];
|
||||
if(Container.m_Quads.size() > 0)
|
||||
|
@ -1343,7 +1343,7 @@ void CGraphics_Threaded::QuadContainerAddQuads(int ContainerIndex, CFreeformItem
|
|||
void CGraphics_Threaded::QuadContainerReset(int ContainerIndex)
|
||||
{
|
||||
SQuadContainer& Container = m_QuadContainers[ContainerIndex];
|
||||
if(m_IsNewOpenGL)
|
||||
if(IsQuadContainerBufferingEnabled())
|
||||
{
|
||||
if(Container.m_QuadBufferContainerIndex != -1)
|
||||
DeleteBufferContainer(Container.m_QuadBufferContainerIndex, true);
|
||||
|
@ -1376,7 +1376,7 @@ void CGraphics_Threaded::RenderQuadContainer(int ContainerIndex, int QuadOffset,
|
|||
if((int)Container.m_Quads.size() < QuadOffset + QuadDrawNum || QuadDrawNum == 0)
|
||||
return;
|
||||
|
||||
if(m_IsNewOpenGL)
|
||||
if(IsQuadContainerBufferingEnabled())
|
||||
{
|
||||
if(Container.m_QuadBufferContainerIndex == -1)
|
||||
return;
|
||||
|
@ -1434,7 +1434,7 @@ void CGraphics_Threaded::RenderQuadContainerAsSprite(int ContainerIndex, int Qua
|
|||
if((int)Container.m_Quads.size() < QuadOffset + 1)
|
||||
return;
|
||||
|
||||
if(m_IsNewOpenGL)
|
||||
if(IsQuadContainerBufferingEnabled())
|
||||
{
|
||||
if(Container.m_QuadBufferContainerIndex == -1)
|
||||
return;
|
||||
|
@ -1560,7 +1560,7 @@ void CGraphics_Threaded::RenderQuadContainerAsSpriteMultiple(int ContainerIndex,
|
|||
if(DrawCount == 0)
|
||||
return;
|
||||
|
||||
if(m_IsNewOpenGL)
|
||||
if(IsQuadContainerBufferingEnabled())
|
||||
{
|
||||
if(Container.m_QuadBufferContainerIndex == -1)
|
||||
return;
|
||||
|
@ -2037,14 +2037,18 @@ int CGraphics_Threaded::IssueInit()
|
|||
|
||||
int r = m_pBackend->Init("DDNet Client", &g_Config.m_GfxScreen, &g_Config.m_GfxScreenWidth, &g_Config.m_GfxScreenHeight, g_Config.m_GfxFsaaSamples, Flags, &m_DesktopScreenWidth, &m_DesktopScreenHeight, &m_ScreenWidth, &m_ScreenHeight, m_pStorage);
|
||||
m_IsNewOpenGL = m_pBackend->IsNewOpenGL();
|
||||
m_OpenGLBufferingEnabled = m_IsNewOpenGL;
|
||||
m_OpenGLHasTextureArrays = m_IsNewOpenGL;
|
||||
m_OpenGLTileBufferingEnabled = m_IsNewOpenGL || m_pBackend->HasTileBuffering();
|
||||
m_OpenGLQuadBufferingEnabled = m_IsNewOpenGL || m_pBackend->HasQuadBuffering();
|
||||
m_OpenGLQuadContainerBufferingEnabled = m_IsNewOpenGL || m_pBackend->HasQuadContainerBuffering();
|
||||
m_OpenGLTextBufferingEnabled = m_IsNewOpenGL || (m_OpenGLQuadContainerBufferingEnabled && m_pBackend->HasTextBuffering());
|
||||
m_OpenGLHasTextureArrays = m_IsNewOpenGL || m_pBackend->Has2DTextureArrays();
|
||||
return r;
|
||||
}
|
||||
|
||||
int CGraphics_Threaded::InitWindow()
|
||||
{
|
||||
if(IssueInit() == 0)
|
||||
int ErrorCode = IssueInit();
|
||||
if(ErrorCode == 0)
|
||||
return 0;
|
||||
|
||||
// try disabling fsaa
|
||||
|
@ -2057,21 +2061,85 @@ int CGraphics_Threaded::InitWindow()
|
|||
else
|
||||
dbg_msg("gfx", "disabling FSAA and trying again");
|
||||
|
||||
if(IssueInit() == 0)
|
||||
ErrorCode = IssueInit();
|
||||
if(ErrorCode == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// try using old opengl context
|
||||
bool IsNewOpenGL = (g_Config.m_GfxOpenGLMajor == 3 && g_Config.m_GfxOpenGLMinor == 3) || g_Config.m_GfxOpenGLMajor >= 4;
|
||||
if(IsNewOpenGL)
|
||||
size_t OpenGLInitTryCount = 0;
|
||||
while(ErrorCode == EGraphicsBackendErrorCodes::GRAPHICS_BACKEND_ERROR_CODE_OPENGL_CONTEXT_FAILED || ErrorCode == EGraphicsBackendErrorCodes::GRAPHICS_BACKEND_ERROR_CODE_OPENGL_VERSION_FAILED)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 2;
|
||||
g_Config.m_GfxOpenGLMinor = 1;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
if(IssueInit() == 0)
|
||||
if(ErrorCode == EGraphicsBackendErrorCodes::GRAPHICS_BACKEND_ERROR_CODE_OPENGL_CONTEXT_FAILED)
|
||||
{
|
||||
// try next smaller major/minor or patch version
|
||||
if(g_Config.m_GfxOpenGLMajor >= 4)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 3;
|
||||
g_Config.m_GfxOpenGLMinor = 3;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
}
|
||||
else if(g_Config.m_GfxOpenGLMajor == 3 && g_Config.m_GfxOpenGLMinor >= 1)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 3;
|
||||
g_Config.m_GfxOpenGLMinor = 0;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
}
|
||||
else if(g_Config.m_GfxOpenGLMajor == 3 && g_Config.m_GfxOpenGLMinor == 0)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 2;
|
||||
g_Config.m_GfxOpenGLMinor = 1;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
}
|
||||
else if(g_Config.m_GfxOpenGLMajor == 2 && g_Config.m_GfxOpenGLMinor >= 1)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 2;
|
||||
g_Config.m_GfxOpenGLMinor = 0;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
}
|
||||
else if(g_Config.m_GfxOpenGLMajor == 2 && g_Config.m_GfxOpenGLMinor == 0)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 1;
|
||||
g_Config.m_GfxOpenGLMinor = 5;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
}
|
||||
else if(g_Config.m_GfxOpenGLMajor == 1 && g_Config.m_GfxOpenGLMinor == 5)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 1;
|
||||
g_Config.m_GfxOpenGLMinor = 4;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
}
|
||||
else if(g_Config.m_GfxOpenGLMajor == 1 && g_Config.m_GfxOpenGLMinor == 4)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 1;
|
||||
g_Config.m_GfxOpenGLMinor = 3;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
}
|
||||
else if(g_Config.m_GfxOpenGLMajor == 1 && g_Config.m_GfxOpenGLMinor == 3)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 1;
|
||||
g_Config.m_GfxOpenGLMinor = 2;
|
||||
g_Config.m_GfxOpenGLPatch = 1;
|
||||
}
|
||||
else if(g_Config.m_GfxOpenGLMajor == 1 && g_Config.m_GfxOpenGLMinor == 2)
|
||||
{
|
||||
g_Config.m_GfxOpenGLMajor = 1;
|
||||
g_Config.m_GfxOpenGLMinor = 1;
|
||||
g_Config.m_GfxOpenGLPatch = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// new opengl version was set by backend, try again
|
||||
ErrorCode = IssueInit();
|
||||
if(ErrorCode == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(++OpenGLInitTryCount >= 9)
|
||||
{
|
||||
// try something else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// try lowering the resolution
|
||||
|
|
|
@ -66,7 +66,6 @@ public:
|
|||
CMDGROUP_CORE = 0, // commands that everyone has to implement
|
||||
CMDGROUP_PLATFORM_OPENGL = 10000, // commands specific to a platform
|
||||
CMDGROUP_PLATFORM_SDL = 20000,
|
||||
CMDGROUP_PLATFORM_OPENGL3_3 = 30000,
|
||||
|
||||
//
|
||||
CMD_NOP = CMDGROUP_CORE,
|
||||
|
@ -86,7 +85,7 @@ public:
|
|||
CMD_CLEAR,
|
||||
CMD_RENDER,
|
||||
|
||||
//opengl 3.3 commands
|
||||
//opengl 2.0+ commands (some are just emulated and only exist in opengl 3.3+)
|
||||
CMD_CREATE_BUFFER_OBJECT, // create vbo
|
||||
CMD_RECREATE_BUFFER_OBJECT, // recreate vbo
|
||||
CMD_UPDATE_BUFFER_OBJECT, // update vbo
|
||||
|
@ -555,6 +554,19 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
// interface for the graphics backend
|
||||
// all these functions are called on the main thread
|
||||
class IGraphicsBackend
|
||||
|
@ -594,6 +606,11 @@ public:
|
|||
virtual void WaitForIdle() = 0;
|
||||
|
||||
virtual bool IsNewOpenGL() { return false; }
|
||||
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; }
|
||||
};
|
||||
|
||||
class CGraphics_Threaded : public IEngineGraphics
|
||||
|
@ -611,7 +628,10 @@ class CGraphics_Threaded : public IEngineGraphics
|
|||
|
||||
CCommandBuffer::SState m_State;
|
||||
IGraphicsBackend *m_pBackend;
|
||||
bool m_OpenGLBufferingEnabled;
|
||||
bool m_OpenGLTileBufferingEnabled;
|
||||
bool m_OpenGLQuadBufferingEnabled;
|
||||
bool m_OpenGLTextBufferingEnabled;
|
||||
bool m_OpenGLQuadContainerBufferingEnabled;
|
||||
bool m_OpenGLHasTextureArrays;
|
||||
bool m_IsNewOpenGL;
|
||||
|
||||
|
@ -830,7 +850,10 @@ public:
|
|||
virtual bool IsIdle();
|
||||
virtual void WaitForIdle();
|
||||
|
||||
virtual bool IsBufferingEnabled() { return m_OpenGLBufferingEnabled; }
|
||||
virtual bool IsTileBufferingEnabled() { return m_OpenGLTileBufferingEnabled; }
|
||||
virtual bool IsQuadBufferingEnabled() { return m_OpenGLQuadBufferingEnabled; }
|
||||
virtual bool IsTextBufferingEnabled() { return m_OpenGLTextBufferingEnabled; }
|
||||
virtual bool IsQuadContainerBufferingEnabled() { return m_OpenGLQuadContainerBufferingEnabled; }
|
||||
virtual bool HasTextureArrays() { return m_OpenGLHasTextureArrays; }
|
||||
};
|
||||
|
||||
|
|
|
@ -14,21 +14,49 @@ bool CGLSL::LoadShader(CGLSLCompiler* pCompiler, IStorage *pStorage, const char
|
|||
std::vector<std::string> Lines;
|
||||
if (f)
|
||||
{
|
||||
bool IsNewOpenGL = pCompiler->m_OpenGLVersionMajor >= 4 || (pCompiler->m_OpenGLVersionMajor == 3 && pCompiler->m_OpenGLVersionMinor == 3);
|
||||
//add compiler specific values
|
||||
Lines.push_back(std::string("#version ") + std::string(std::to_string(pCompiler->m_OpenGLVersionMajor)) + std::string(std::to_string(pCompiler->m_OpenGLVersionMinor)) + std::string(std::to_string(pCompiler->m_OpenGLVersionPatch)) + std::string(" core\r\n"));
|
||||
if(IsNewOpenGL)
|
||||
Lines.push_back(std::string("#version ") + std::string(std::to_string(pCompiler->m_OpenGLVersionMajor)) + std::string(std::to_string(pCompiler->m_OpenGLVersionMinor)) + std::string(std::to_string(pCompiler->m_OpenGLVersionPatch)) + std::string(" core\r\n"));
|
||||
else
|
||||
{
|
||||
if(pCompiler->m_OpenGLVersionMajor == 3)
|
||||
{
|
||||
if(pCompiler->m_OpenGLVersionMinor == 0)
|
||||
Lines.push_back(std::string("#version 130 \r\n"));
|
||||
if(pCompiler->m_OpenGLVersionMinor == 1)
|
||||
Lines.push_back(std::string("#version 140 \r\n"));
|
||||
if(pCompiler->m_OpenGLVersionMinor == 2)
|
||||
Lines.push_back(std::string("#version 150 \r\n"));
|
||||
}
|
||||
else if(pCompiler->m_OpenGLVersionMajor == 2)
|
||||
{
|
||||
if(pCompiler->m_OpenGLVersionMinor == 0)
|
||||
Lines.push_back(std::string("#version 110 \r\n"));
|
||||
if(pCompiler->m_OpenGLVersionMinor == 1)
|
||||
Lines.push_back(std::string("#version 120 \r\n"));
|
||||
}
|
||||
}
|
||||
|
||||
for(CGLSLCompiler::SGLSLCompilerDefine& Define : pCompiler->m_Defines)
|
||||
{
|
||||
Lines.push_back(std::string("#define ") + Define.m_DefineName + std::string(" ") + Define.m_DefineValue + std::string("\r\n"));
|
||||
}
|
||||
|
||||
if(Type == GL_FRAGMENT_SHADER && !IsNewOpenGL && pCompiler->m_OpenGLVersionMajor <= 3 && pCompiler->m_HasTextureArray)
|
||||
{
|
||||
Lines.push_back(std::string("#extension GL_EXT_texture_array : enable\r\n"));
|
||||
}
|
||||
|
||||
CLineReader LineReader;
|
||||
LineReader.Init(f);
|
||||
char* ReadLine = NULL;
|
||||
while ((ReadLine = LineReader.Get()))
|
||||
{
|
||||
Lines.push_back(ReadLine);
|
||||
Lines.back().append("\r\n");
|
||||
std::string Line;
|
||||
pCompiler->ParseLine(Line, ReadLine, Type);
|
||||
Line.append("\r\n");
|
||||
Lines.push_back(Line);
|
||||
}
|
||||
io_close(f);
|
||||
|
||||
|
@ -58,7 +86,7 @@ bool CGLSL::LoadShader(CGLSLCompiler* pCompiler, IStorage *pStorage, const char
|
|||
|
||||
glGetShaderInfoLog(shader, maxLength, &maxLength, buff);
|
||||
|
||||
dbg_msg("GLSL", "%s", buff);
|
||||
dbg_msg("GLSL", "%s: %s", pFile, buff);
|
||||
glDeleteShader(shader);
|
||||
return false;
|
||||
}
|
||||
|
@ -105,6 +133,9 @@ CGLSLCompiler::CGLSLCompiler(int OpenGLVersionMajor, int OpenGLVersionMinor, int
|
|||
m_OpenGLVersionMajor = OpenGLVersionMajor;
|
||||
m_OpenGLVersionMinor = OpenGLVersionMinor;
|
||||
m_OpenGLVersionPatch = OpenGLVersionPatch;
|
||||
|
||||
m_HasTextureArray = false;
|
||||
m_TextureReplaceType = 0;
|
||||
}
|
||||
|
||||
void CGLSLCompiler::AddDefine(const std::string& DefineName, const std::string& DefineValue)
|
||||
|
@ -121,3 +152,127 @@ void CGLSLCompiler::ClearDefines()
|
|||
{
|
||||
m_Defines.clear();
|
||||
}
|
||||
|
||||
void CGLSLCompiler::ParseLine(std::string& Line, const char* pReadLine, int Type)
|
||||
{
|
||||
bool IsNewOpenGL = m_OpenGLVersionMajor >= 4 || (m_OpenGLVersionMajor == 3 && m_OpenGLVersionMinor == 3);
|
||||
if(!IsNewOpenGL)
|
||||
{
|
||||
const char* pBuff = pReadLine;
|
||||
char aTmpStr[1024];
|
||||
size_t TmpStrSize = 0;
|
||||
while(*pBuff)
|
||||
{
|
||||
while(*pBuff && str_isspace(*pBuff))
|
||||
{
|
||||
Line.append(1, *pBuff);
|
||||
++pBuff;
|
||||
}
|
||||
|
||||
while(*pBuff && !str_isspace(*pBuff) && *pBuff != '(' && *pBuff != '.')
|
||||
{
|
||||
aTmpStr[TmpStrSize++] = *pBuff;
|
||||
++pBuff;
|
||||
}
|
||||
|
||||
if(TmpStrSize > 0)
|
||||
{
|
||||
aTmpStr[TmpStrSize] = 0;
|
||||
TmpStrSize = 0;
|
||||
if(str_comp(aTmpStr, "layout") == 0)
|
||||
{
|
||||
//search for ' in'
|
||||
while(*pBuff && (*pBuff != ' ' || (*(pBuff + 1) && *(pBuff + 1) != 'i') || *(pBuff + 2) != 'n'))
|
||||
{
|
||||
++pBuff;
|
||||
}
|
||||
|
||||
if(*pBuff && *pBuff == ' ' && *(pBuff + 1) && *(pBuff + 1) == 'i' && *(pBuff + 2) == 'n')
|
||||
{
|
||||
pBuff += 3;
|
||||
Line.append("attribute");
|
||||
Line.append(pBuff);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_msg("Shader compiler", "Fix shader for older OpenGL versions.");
|
||||
}
|
||||
}
|
||||
else if(str_comp(aTmpStr, "noperspective") == 0 || str_comp(aTmpStr, "smooth") == 0 || str_comp(aTmpStr, "flat") == 0)
|
||||
{
|
||||
//search for 'in' or 'out'
|
||||
while(*pBuff && ((*pBuff != 'i' || *(pBuff + 1) != 'n') && (*pBuff != 'o' || (*(pBuff + 1) && *(pBuff + 1) != 'u') || *(pBuff + 2) != 't')))
|
||||
{
|
||||
++pBuff;
|
||||
}
|
||||
|
||||
bool Found = false;
|
||||
if(*pBuff)
|
||||
{
|
||||
if(*pBuff == 'i' && *(pBuff + 1) == 'n')
|
||||
{
|
||||
pBuff += 2;
|
||||
Found = true;
|
||||
}
|
||||
else if(*pBuff == 'o' && *(pBuff + 1) && *(pBuff + 1) == 'u' && *(pBuff + 2) == 't')
|
||||
{
|
||||
pBuff += 3;
|
||||
Found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!Found)
|
||||
{
|
||||
dbg_msg("Shader compiler", "Fix shader for older OpenGL versions.");
|
||||
}
|
||||
|
||||
Line.append("varying");
|
||||
Line.append(pBuff);
|
||||
return;
|
||||
}
|
||||
else if(str_comp(aTmpStr, "out") == 0 || str_comp(aTmpStr, "in") == 0)
|
||||
{
|
||||
if(Type == GL_FRAGMENT_SHADER && str_comp(aTmpStr, "out") == 0)
|
||||
return;
|
||||
Line.append("varying");
|
||||
Line.append(pBuff);
|
||||
return;
|
||||
}
|
||||
else if(str_comp(aTmpStr, "FragClr") == 0)
|
||||
{
|
||||
Line.append("gl_FragColor");
|
||||
Line.append(pBuff);
|
||||
return;
|
||||
}
|
||||
else if(str_comp(aTmpStr, "texture") == 0)
|
||||
{
|
||||
if(m_TextureReplaceType == GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D)
|
||||
Line.append("texture2D");
|
||||
else if(m_TextureReplaceType == GLSL_COMPILER_TEXTURE_REPLACE_TYPE_3D)
|
||||
Line.append("texture3D");
|
||||
else if(m_TextureReplaceType == GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D_ARRAY)
|
||||
Line.append("texture2DArray");
|
||||
std::string RestLine;
|
||||
ParseLine(RestLine, pBuff, Type);
|
||||
Line.append(RestLine);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Line.append(aTmpStr);
|
||||
}
|
||||
}
|
||||
|
||||
if(*pBuff)
|
||||
{
|
||||
Line.append(1, *pBuff);
|
||||
++pBuff;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Line = pReadLine;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,12 +44,26 @@ private:
|
|||
int m_OpenGLVersionMajor;
|
||||
int m_OpenGLVersionMinor;
|
||||
int m_OpenGLVersionPatch;
|
||||
|
||||
bool m_HasTextureArray;
|
||||
int m_TextureReplaceType; // @see EGLSLCompilerTextureReplaceType
|
||||
public:
|
||||
CGLSLCompiler(int OpenGLVersionMajor, int OpenGLVersionMinor, int OpenGLVersionPatch);
|
||||
void SetHasTextureArray(bool TextureArray) { m_HasTextureArray = TextureArray; }
|
||||
void SetTextureReplaceType(int TextureReplaceType) { m_TextureReplaceType = TextureReplaceType; }
|
||||
|
||||
void AddDefine(const std::string& DefineName, const std::string& DefineValue);
|
||||
void AddDefine(const char* pDefineName, const char* pDefineValue);
|
||||
void ClearDefines();
|
||||
|
||||
void ParseLine(std::string& Line, const char* pReadLine, int Type);
|
||||
|
||||
enum EGLSLCompilerTextureReplaceType
|
||||
{
|
||||
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D = 0,
|
||||
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_3D,
|
||||
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D_ARRAY,
|
||||
};
|
||||
};
|
||||
|
||||
#endif // ENGINE_CLIENT_OPENGL_SL_H
|
||||
|
|
|
@ -860,7 +860,7 @@ public:
|
|||
// make sure there are no vertices
|
||||
Graphics()->FlushVertices();
|
||||
|
||||
if(Graphics()->IsBufferingEnabled())
|
||||
if(Graphics()->IsTextBufferingEnabled())
|
||||
{
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->TextQuadsBegin();
|
||||
|
@ -966,7 +966,7 @@ public:
|
|||
|
||||
if(pCursor->m_Flags&TEXTFLAG_RENDER && m_Color.a != 0.f)
|
||||
{
|
||||
if(Graphics()->IsBufferingEnabled())
|
||||
if(Graphics()->IsTextBufferingEnabled())
|
||||
Graphics()->QuadsSetSubset(pChr->m_aUVs[0], pChr->m_aUVs[3], pChr->m_aUVs[2], pChr->m_aUVs[1]);
|
||||
else
|
||||
Graphics()->QuadsSetSubset(pChr->m_aUVs[0] * UVScale, pChr->m_aUVs[3] * UVScale, pChr->m_aUVs[2] * UVScale, pChr->m_aUVs[1] * UVScale);
|
||||
|
@ -1011,7 +1011,7 @@ public:
|
|||
|
||||
if(pCursor->m_Flags&TEXTFLAG_RENDER)
|
||||
{
|
||||
if(Graphics()->IsBufferingEnabled())
|
||||
if(Graphics()->IsTextBufferingEnabled())
|
||||
{
|
||||
float OutlineColor[4] = { m_OutlineColor.r, m_OutlineColor.g, m_OutlineColor.b, m_OutlineColor.a*m_Color.a };
|
||||
Graphics()->TextQuadsEnd(pFont->m_CurTextureDimensions[0], pFont->m_aTextures[0], pFont->m_aTextures[1], OutlineColor);
|
||||
|
@ -1094,7 +1094,7 @@ public:
|
|||
else
|
||||
{
|
||||
TextContainer.m_StringInfo.m_QuadNum = TextContainer.m_StringInfo.m_CharacterQuads.size();
|
||||
if(Graphics()->IsBufferingEnabled())
|
||||
if(Graphics()->IsTextBufferingEnabled())
|
||||
{
|
||||
size_t DataSize = TextContainer.m_StringInfo.m_CharacterQuads.size() * sizeof(STextCharQuad);
|
||||
void *pUploadData = &TextContainer.m_StringInfo.m_CharacterQuads[0];
|
||||
|
@ -1349,7 +1349,7 @@ public:
|
|||
{
|
||||
TextContainer.m_StringInfo.m_QuadNum = TextContainer.m_StringInfo.m_CharacterQuads.size();
|
||||
// setup the buffers
|
||||
if(Graphics()->IsBufferingEnabled())
|
||||
if(Graphics()->IsTextBufferingEnabled())
|
||||
{
|
||||
size_t DataSize = TextContainer.m_StringInfo.m_CharacterQuads.size() * sizeof(STextCharQuad);
|
||||
void *pUploadData = &TextContainer.m_StringInfo.m_CharacterQuads[0];
|
||||
|
@ -1604,7 +1604,7 @@ public:
|
|||
virtual void DeleteTextContainer(int TextContainerIndex)
|
||||
{
|
||||
STextContainer& TextContainer = GetTextContainer(TextContainerIndex);
|
||||
if(Graphics()->IsBufferingEnabled())
|
||||
if(Graphics()->IsTextBufferingEnabled())
|
||||
{
|
||||
if(TextContainer.m_StringInfo.m_QuadBufferContainerIndex != -1)
|
||||
Graphics()->DeleteBufferContainer(TextContainer.m_StringInfo.m_QuadBufferContainerIndex, true);
|
||||
|
@ -1632,7 +1632,7 @@ public:
|
|||
s_CursorRenderTime = time_get_microseconds();
|
||||
}
|
||||
|
||||
if(Graphics()->IsBufferingEnabled())
|
||||
if(Graphics()->IsTextBufferingEnabled())
|
||||
{
|
||||
Graphics()->TextureClear();
|
||||
// render buffered text
|
||||
|
@ -1712,7 +1712,7 @@ public:
|
|||
Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1);
|
||||
}
|
||||
|
||||
virtual void UploadEntityLayerText(void* pTexBuff, int TexWidth, int TexHeight, const char *pText, int Length, float x, float y, int FontSize)
|
||||
virtual void UploadEntityLayerText(void* pTexBuff, int ImageColorChannelCount, int TexWidth, int TexHeight, const char *pText, int Length, float x, float y, int FontSize)
|
||||
{
|
||||
if (FontSize < 1)
|
||||
return;
|
||||
|
@ -1762,13 +1762,25 @@ public:
|
|||
uint8_t* pImageBuff = (uint8_t*)pTexBuff;
|
||||
for(int OffY = 0; OffY < SlotH; ++OffY)
|
||||
{
|
||||
size_t ImageOffset = (y + OffY) * TexWidth + (x + WidthLastChars);
|
||||
size_t GlyphOffset = (OffY) * SlotW;
|
||||
mem_copy(pImageBuff + ImageOffset, ms_aGlyphData + GlyphOffset, sizeof(uint8_t) * SlotW);
|
||||
for(int OffX = 0; OffX < SlotW; ++OffX)
|
||||
{
|
||||
size_t ImageOffset = (y + OffY) * (TexWidth * ImageColorChannelCount) + ((x + OffX) + WidthLastChars) * ImageColorChannelCount;
|
||||
size_t GlyphOffset = (OffY) * SlotW + OffX;
|
||||
for(size_t i = 0; i < (size_t)ImageColorChannelCount; ++i)
|
||||
{
|
||||
if(i != (size_t)ImageColorChannelCount - 1)
|
||||
{
|
||||
*(pImageBuff + ImageOffset + i) = 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
*(pImageBuff + ImageOffset + i) = *(ms_aGlyphData + GlyphOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WidthLastChars += (SlotW + 1);
|
||||
|
||||
}
|
||||
pCurrent = pTmp;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,22 @@ struct SQuadRenderInfo
|
|||
float m_Rotation;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class CImageInfo
|
||||
{
|
||||
public:
|
||||
|
@ -80,6 +96,7 @@ public:
|
|||
|
||||
struct GL_SPoint { float x, y; };
|
||||
struct GL_STexCoord { float u, v; };
|
||||
struct GL_STexCoord3D { float u, v, w; };
|
||||
struct GL_SColorf { float r, g, b, a; };
|
||||
|
||||
//use normalized color values
|
||||
|
@ -92,6 +109,13 @@ struct GL_SVertex
|
|||
GL_SColor m_Color;
|
||||
};
|
||||
|
||||
struct GL_SVertexTex3D
|
||||
{
|
||||
GL_SPoint m_Pos;
|
||||
GL_SColorf m_Color;
|
||||
GL_STexCoord3D m_Tex;
|
||||
};
|
||||
|
||||
typedef void(*WINDOW_RESIZE_FUNC)(void *pUser);
|
||||
|
||||
class IGraphics : public IInterface
|
||||
|
@ -190,7 +214,10 @@ public:
|
|||
virtual void UpdateBufferContainer(int ContainerIndex, struct SBufferContainerInfo *pContainerInfo) = 0;
|
||||
virtual void IndicesNumRequiredNotify(unsigned int RequiredIndicesCount) = 0;
|
||||
|
||||
virtual bool IsBufferingEnabled() = 0;
|
||||
virtual bool IsTileBufferingEnabled() = 0;
|
||||
virtual bool IsQuadBufferingEnabled() = 0;
|
||||
virtual bool IsTextBufferingEnabled() = 0;
|
||||
virtual bool IsQuadContainerBufferingEnabled() = 0;
|
||||
virtual bool HasTextureArrays() = 0;
|
||||
|
||||
struct CLineItem
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <base/color.h>
|
||||
#include <engine/graphics.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -99,7 +100,7 @@ public:
|
|||
virtual void RenderTextContainer(int TextContainerIndex, STextRenderColor *pTextColor, STextRenderColor *pTextOutlineColor) = 0;
|
||||
virtual void RenderTextContainer(int TextContainerIndex, STextRenderColor *pTextColor, STextRenderColor *pTextOutlineColor, float X, float Y) = 0;
|
||||
|
||||
virtual void UploadEntityLayerText(void* pTexBuff, int TexWidth, int TexHeight, const char *pText, int Length, float x, float y, int FontHeight) = 0;
|
||||
virtual void UploadEntityLayerText(void* pTexBuff, int ImageColorChannelCount, int TexWidth, int TexHeight, const char *pText, int Length, float x, float y, int FontHeight) = 0;
|
||||
virtual int AdjustFontSize(const char *pText, int TextLength, int MaxSize = -1) = 0;
|
||||
virtual int CalculateTextWidth(const char *pText, int TextLength, int FontWidth, int FontHeight) = 0;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ void CCamera::ScaleZoom(float Factor)
|
|||
|
||||
void CCamera::ChangeZoom(float Target)
|
||||
{
|
||||
if(Target >= (Graphics()->IsBufferingEnabled()? 60 : 30))
|
||||
if(Target >= (Graphics()->IsTileBufferingEnabled()? 60 : 30))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -178,20 +178,20 @@ int CMapImages::GetTextureScale()
|
|||
|
||||
IGraphics::CTextureHandle CMapImages::UploadEntityLayerText(int TextureSize, int YOffset)
|
||||
{
|
||||
void *pMem = calloc(1024 * 1024, 1);
|
||||
void *pMem = calloc(1024 * 1024 * 4, 1);
|
||||
|
||||
UpdateEntityLayerText(pMem, 1024, 1024, TextureSize, YOffset, 0);
|
||||
UpdateEntityLayerText(pMem, 1024, 1024, TextureSize, YOffset, 1);
|
||||
UpdateEntityLayerText(pMem, 1024, 1024, TextureSize, YOffset, 2, 255);
|
||||
UpdateEntityLayerText(pMem, 4, 1024, 1024, TextureSize, YOffset, 0);
|
||||
UpdateEntityLayerText(pMem, 4, 1024, 1024, TextureSize, YOffset, 1);
|
||||
UpdateEntityLayerText(pMem, 4, 1024, 1024, TextureSize, YOffset, 2, 255);
|
||||
|
||||
int TextureLoadFlag = Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
IGraphics::CTextureHandle Texture = Graphics()->LoadTextureRaw(1024, 1024, CImageInfo::FORMAT_ALPHA, pMem, CImageInfo::FORMAT_ALPHA, TextureLoadFlag);
|
||||
IGraphics::CTextureHandle Texture = Graphics()->LoadTextureRaw(1024, 1024, CImageInfo::FORMAT_RGBA, pMem, CImageInfo::FORMAT_RGBA, TextureLoadFlag);
|
||||
free(pMem);
|
||||
|
||||
return Texture;
|
||||
}
|
||||
|
||||
void CMapImages::UpdateEntityLayerText(void* pTexBuffer, int TexWidth, int TexHeight, int TextureSize, int YOffset, int NumbersPower, int MaxNumber)
|
||||
void CMapImages::UpdateEntityLayerText(void* pTexBuffer, int ImageColorChannelCount, int TexWidth, int TexHeight, int TextureSize, int YOffset, int NumbersPower, int MaxNumber)
|
||||
{
|
||||
char aBuf[4];
|
||||
int DigitsCount = NumbersPower+1;
|
||||
|
@ -217,7 +217,7 @@ void CMapImages::UpdateEntityLayerText(void* pTexBuffer, int TexWidth, int TexHe
|
|||
float x = (CurrentNumber%16)*64;
|
||||
float y = (CurrentNumber/16)*64;
|
||||
|
||||
TextRender()->UploadEntityLayerText(pTexBuffer, TexWidth, TexHeight, aBuf, DigitsCount, x+XOffSet, y+YOffset, UniversalSuitableFontSize);
|
||||
TextRender()->UploadEntityLayerText(pTexBuffer, ImageColorChannelCount, TexWidth, TexHeight, aBuf, DigitsCount, x+XOffSet, y+YOffset, UniversalSuitableFontSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ private:
|
|||
|
||||
void InitOverlayTextures();
|
||||
IGraphics::CTextureHandle UploadEntityLayerText(int TextureSize, int YOffset);
|
||||
void UpdateEntityLayerText(void* pTexBuffer, int TexWidth, int TexHeight, int TextureSize, int YOffset, int NumbersPower, int MaxNumber = -1);
|
||||
void UpdateEntityLayerText(void* pTexBuffer, int ImageColorChannelCount, int TexWidth, int TexHeight, int TextureSize, int YOffset, int NumbersPower, int MaxNumber = -1);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -125,23 +125,7 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void
|
|||
}
|
||||
}
|
||||
|
||||
struct STmpTile
|
||||
{
|
||||
vec2 m_TopLeft;
|
||||
vec2 m_TopRight;
|
||||
vec2 m_BottomRight;
|
||||
vec2 m_BottomLeft;
|
||||
};
|
||||
|
||||
struct STmpTileTexCoord
|
||||
{
|
||||
vec3 m_TexCoordTopLeft;
|
||||
vec3 m_TexCoordTopRight;
|
||||
vec3 m_TexCoordBottomRight;
|
||||
vec3 m_TexCoordBottomLeft;
|
||||
};
|
||||
|
||||
void FillTmpTileSpeedup(STmpTile* pTmpTile, STmpTileTexCoord* pTmpTex, unsigned char Flags, unsigned char Index, int x, int y, int Scale, CMapItemGroup* pGroup, short AngleRotate)
|
||||
void FillTmpTileSpeedup(SGraphicTile* pTmpTile, SGraphicTileTexureCoords* pTmpTex, bool As3DTextureCoord, unsigned char Flags, unsigned char Index, int x, int y, int Scale, CMapItemGroup* pGroup, short AngleRotate)
|
||||
{
|
||||
if(pTmpTex)
|
||||
{
|
||||
|
@ -156,16 +140,27 @@ void FillTmpTileSpeedup(STmpTile* pTmpTile, STmpTileTexCoord* pTmpTex, unsigned
|
|||
|
||||
pTmpTex->m_TexCoordTopLeft.x = x0;
|
||||
pTmpTex->m_TexCoordTopLeft.y = y0;
|
||||
pTmpTex->m_TexCoordTopLeft.z = Index;
|
||||
pTmpTex->m_TexCoordBottomLeft.x = x3;
|
||||
pTmpTex->m_TexCoordBottomLeft.y = y3;
|
||||
pTmpTex->m_TexCoordBottomLeft.z = Index;
|
||||
pTmpTex->m_TexCoordTopRight.x = x1;
|
||||
pTmpTex->m_TexCoordTopRight.y = y1;
|
||||
pTmpTex->m_TexCoordTopRight.z = Index;
|
||||
pTmpTex->m_TexCoordBottomRight.x = x2;
|
||||
pTmpTex->m_TexCoordBottomRight.y = y2;
|
||||
pTmpTex->m_TexCoordBottomRight.z = Index;
|
||||
|
||||
if(As3DTextureCoord)
|
||||
{
|
||||
pTmpTex->m_TexCoordTopLeft.z = ((float)Index + 0.5f) / 256.f;
|
||||
pTmpTex->m_TexCoordBottomLeft.z = ((float)Index + 0.5f) / 256.f;
|
||||
pTmpTex->m_TexCoordTopRight.z = ((float)Index + 0.5f) / 256.f;
|
||||
pTmpTex->m_TexCoordBottomRight.z = ((float)Index + 0.5f) / 256.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
pTmpTex->m_TexCoordTopLeft.z = Index;
|
||||
pTmpTex->m_TexCoordBottomLeft.z = Index;
|
||||
pTmpTex->m_TexCoordTopRight.z = Index;
|
||||
pTmpTex->m_TexCoordBottomRight.z = Index;
|
||||
}
|
||||
}
|
||||
|
||||
//same as in rotate from Graphics()
|
||||
|
@ -200,7 +195,7 @@ void FillTmpTileSpeedup(STmpTile* pTmpTile, STmpTileTexCoord* pTmpTex, unsigned
|
|||
}
|
||||
}
|
||||
|
||||
void FillTmpTile(STmpTile* pTmpTile, STmpTileTexCoord* pTmpTex, unsigned char Flags, unsigned char Index, int x, int y, int Scale, CMapItemGroup* pGroup)
|
||||
void FillTmpTile(SGraphicTile* pTmpTile, SGraphicTileTexureCoords* pTmpTex, bool As3DTextureCoord, unsigned char Flags, unsigned char Index, int x, int y, int Scale, CMapItemGroup* pGroup)
|
||||
{
|
||||
if(pTmpTex)
|
||||
{
|
||||
|
@ -245,16 +240,27 @@ void FillTmpTile(STmpTile* pTmpTile, STmpTileTexCoord* pTmpTex, unsigned char Fl
|
|||
|
||||
pTmpTex->m_TexCoordTopLeft.x = x0;
|
||||
pTmpTex->m_TexCoordTopLeft.y = y0;
|
||||
pTmpTex->m_TexCoordTopLeft.z = Index;
|
||||
pTmpTex->m_TexCoordBottomLeft.x = x3;
|
||||
pTmpTex->m_TexCoordBottomLeft.y = y3;
|
||||
pTmpTex->m_TexCoordBottomLeft.z = Index;
|
||||
pTmpTex->m_TexCoordTopRight.x = x1;
|
||||
pTmpTex->m_TexCoordTopRight.y = y1;
|
||||
pTmpTex->m_TexCoordTopRight.z = Index;
|
||||
pTmpTex->m_TexCoordBottomRight.x = x2;
|
||||
pTmpTex->m_TexCoordBottomRight.y = y2;
|
||||
pTmpTex->m_TexCoordBottomRight.z = Index;
|
||||
|
||||
if(As3DTextureCoord)
|
||||
{
|
||||
pTmpTex->m_TexCoordTopLeft.z = ((float)Index + 0.5f) / 256.f;
|
||||
pTmpTex->m_TexCoordBottomLeft.z = ((float)Index + 0.5f) / 256.f;
|
||||
pTmpTex->m_TexCoordTopRight.z = ((float)Index + 0.5f) / 256.f;
|
||||
pTmpTex->m_TexCoordBottomRight.z = ((float)Index + 0.5f) / 256.f;
|
||||
}
|
||||
else
|
||||
{
|
||||
pTmpTex->m_TexCoordTopLeft.z = Index;
|
||||
pTmpTex->m_TexCoordBottomLeft.z = Index;
|
||||
pTmpTex->m_TexCoordTopRight.z = Index;
|
||||
pTmpTex->m_TexCoordBottomRight.z = Index;
|
||||
}
|
||||
}
|
||||
|
||||
pTmpTile->m_TopLeft.x = x*Scale;
|
||||
|
@ -312,23 +318,23 @@ CMapLayers::STileLayerVisuals::~STileLayerVisuals()
|
|||
m_BorderRight = NULL;
|
||||
}
|
||||
|
||||
bool AddTile(std::vector<STmpTile>& TmpTiles, std::vector<STmpTileTexCoord>& TmpTileTexCoords, unsigned char Index, unsigned char Flags, int x, int y, CMapItemGroup* pGroup, bool DoTextureCoords, bool FillSpeedup = false, int AngleRotate = -1)
|
||||
bool AddTile(std::vector<SGraphicTile>& TmpTiles, std::vector<SGraphicTileTexureCoords>& TmpTileTexCoords, bool As3DTextureCoord, unsigned char Index, unsigned char Flags, int x, int y, CMapItemGroup* pGroup, bool DoTextureCoords, bool FillSpeedup = false, int AngleRotate = -1)
|
||||
{
|
||||
if(Index)
|
||||
{
|
||||
TmpTiles.push_back(STmpTile());
|
||||
STmpTile& Tile = TmpTiles.back();
|
||||
STmpTileTexCoord* pTileTex = NULL;
|
||||
TmpTiles.push_back(SGraphicTile());
|
||||
SGraphicTile& Tile = TmpTiles.back();
|
||||
SGraphicTileTexureCoords* pTileTex = NULL;
|
||||
if(DoTextureCoords)
|
||||
{
|
||||
TmpTileTexCoords.push_back(STmpTileTexCoord());
|
||||
STmpTileTexCoord& TileTex = TmpTileTexCoords.back();
|
||||
TmpTileTexCoords.push_back(SGraphicTileTexureCoords());
|
||||
SGraphicTileTexureCoords& TileTex = TmpTileTexCoords.back();
|
||||
pTileTex = &TileTex;
|
||||
}
|
||||
if(FillSpeedup)
|
||||
FillTmpTileSpeedup(&Tile, pTileTex, Flags, 0, x, y, 32.f, pGroup, AngleRotate);
|
||||
FillTmpTileSpeedup(&Tile, pTileTex, As3DTextureCoord, Flags, 0, x, y, 32.f, pGroup, AngleRotate);
|
||||
else
|
||||
FillTmpTile(&Tile, pTileTex, Flags, Index, x, y, 32.f, pGroup);
|
||||
FillTmpTile(&Tile, pTileTex, As3DTextureCoord, Flags, Index, x, y, 32.f, pGroup);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -370,7 +376,7 @@ void mem_copy_special(void *pDest, void *pSource, size_t Size, size_t Count, siz
|
|||
|
||||
void CMapLayers::OnMapLoad()
|
||||
{
|
||||
if(!Graphics()->IsBufferingEnabled())
|
||||
if(!Graphics()->IsTileBufferingEnabled() && !Graphics()->IsQuadBufferingEnabled())
|
||||
return;
|
||||
//clear everything and destroy all buffers
|
||||
if(m_TileLayerVisuals.size() != 0)
|
||||
|
@ -396,22 +402,24 @@ void CMapLayers::OnMapLoad()
|
|||
|
||||
bool PassedGameLayer = false;
|
||||
//prepare all visuals for all tile layers
|
||||
std::vector<STmpTile> tmpTiles;
|
||||
std::vector<STmpTileTexCoord> tmpTileTexCoords;
|
||||
std::vector<STmpTile> tmpBorderTopTiles;
|
||||
std::vector<STmpTileTexCoord> tmpBorderTopTilesTexCoords;
|
||||
std::vector<STmpTile> tmpBorderLeftTiles;
|
||||
std::vector<STmpTileTexCoord> tmpBorderLeftTilesTexCoords;
|
||||
std::vector<STmpTile> tmpBorderRightTiles;
|
||||
std::vector<STmpTileTexCoord> tmpBorderRightTilesTexCoords;
|
||||
std::vector<STmpTile> tmpBorderBottomTiles;
|
||||
std::vector<STmpTileTexCoord> tmpBorderBottomTilesTexCoords;
|
||||
std::vector<STmpTile> tmpBorderCorners;
|
||||
std::vector<STmpTileTexCoord> tmpBorderCornersTexCoords;
|
||||
std::vector<SGraphicTile> tmpTiles;
|
||||
std::vector<SGraphicTileTexureCoords> tmpTileTexCoords;
|
||||
std::vector<SGraphicTile> tmpBorderTopTiles;
|
||||
std::vector<SGraphicTileTexureCoords> tmpBorderTopTilesTexCoords;
|
||||
std::vector<SGraphicTile> tmpBorderLeftTiles;
|
||||
std::vector<SGraphicTileTexureCoords> tmpBorderLeftTilesTexCoords;
|
||||
std::vector<SGraphicTile> tmpBorderRightTiles;
|
||||
std::vector<SGraphicTileTexureCoords> tmpBorderRightTilesTexCoords;
|
||||
std::vector<SGraphicTile> tmpBorderBottomTiles;
|
||||
std::vector<SGraphicTileTexureCoords> tmpBorderBottomTilesTexCoords;
|
||||
std::vector<SGraphicTile> tmpBorderCorners;
|
||||
std::vector<SGraphicTileTexureCoords> tmpBorderCornersTexCoords;
|
||||
|
||||
std::vector<STmpQuad> tmpQuads;
|
||||
std::vector<STmpQuadTextured> tmpQuadsTextured;
|
||||
|
||||
bool As3DTextureCoords = !Graphics()->HasTextureArrays();
|
||||
|
||||
for(int g = 0; g < m_pLayers->NumGroups(); g++)
|
||||
{
|
||||
CMapItemGroup *pGroup = m_pLayers->GetGroup(g);
|
||||
|
@ -467,7 +475,7 @@ void CMapLayers::OnMapLoad()
|
|||
continue;
|
||||
}
|
||||
|
||||
if(pLayer->m_Type == LAYERTYPE_TILES)
|
||||
if(pLayer->m_Type == LAYERTYPE_TILES && Graphics()->IsTileBufferingEnabled())
|
||||
{
|
||||
bool DoTextureCoords = false;
|
||||
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
||||
|
@ -548,6 +556,23 @@ void CMapLayers::OnMapLoad()
|
|||
tmpBorderBottomTilesTexCoords.clear();
|
||||
tmpBorderCornersTexCoords.clear();
|
||||
|
||||
if(!DoTextureCoords) {
|
||||
tmpTiles.reserve((size_t)(pTMap->m_Width*pTMap->m_Height));
|
||||
tmpBorderTopTiles.reserve((size_t)pTMap->m_Width);
|
||||
tmpBorderBottomTiles.reserve((size_t)pTMap->m_Width);
|
||||
tmpBorderLeftTiles.reserve((size_t)pTMap->m_Height);
|
||||
tmpBorderRightTiles.reserve((size_t)pTMap->m_Height);
|
||||
tmpBorderCorners.reserve((size_t)4);
|
||||
}
|
||||
else {
|
||||
tmpTileTexCoords.reserve((size_t)(pTMap->m_Width*pTMap->m_Height));
|
||||
tmpBorderTopTilesTexCoords.reserve((size_t)pTMap->m_Width);
|
||||
tmpBorderBottomTilesTexCoords.reserve((size_t)pTMap->m_Width);
|
||||
tmpBorderLeftTilesTexCoords.reserve((size_t)pTMap->m_Height);
|
||||
tmpBorderRightTilesTexCoords.reserve((size_t)pTMap->m_Height);
|
||||
tmpBorderCornersTexCoords.reserve((size_t)4);
|
||||
}
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
for(y = 0; y < pTMap->m_Height; ++y)
|
||||
|
@ -636,7 +661,7 @@ void CMapLayers::OnMapLoad()
|
|||
if(IsSpeedupLayer && CurOverlay == 0)
|
||||
AddAsSpeedup = true;
|
||||
|
||||
if(AddTile(tmpTiles, tmpTileTexCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
if(AddTile(tmpTiles, tmpTileTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_TilesOfLayer[y*pTMap->m_Width + x].Draw(true);
|
||||
|
||||
//do the border tiles
|
||||
|
@ -645,20 +670,20 @@ void CMapLayers::OnMapLoad()
|
|||
if(y == 0)
|
||||
{
|
||||
Visuals.m_BorderTopLeft.SetIndexBufferByteOffset((offset_ptr32)(tmpBorderCorners.size()*6*sizeof(unsigned int)));
|
||||
if(AddTile(tmpBorderCorners, tmpBorderCornersTexCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
if(AddTile(tmpBorderCorners, tmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderTopLeft.Draw(true);
|
||||
}
|
||||
else if(y == pTMap->m_Height - 1)
|
||||
{
|
||||
Visuals.m_BorderBottomLeft.SetIndexBufferByteOffset((offset_ptr32)(tmpBorderCorners.size()*6*sizeof(unsigned int)));
|
||||
if(AddTile(tmpBorderCorners, tmpBorderCornersTexCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
if(AddTile(tmpBorderCorners, tmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderBottomLeft.Draw(true);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Visuals.m_BorderLeft[y-1].SetIndexBufferByteOffset((offset_ptr32)(tmpBorderLeftTiles.size()*6*sizeof(unsigned int)));
|
||||
if(AddTile(tmpBorderLeftTiles, tmpBorderLeftTilesTexCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
if(AddTile(tmpBorderLeftTiles, tmpBorderLeftTilesTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderLeft[y-1].Draw(true);
|
||||
}
|
||||
}
|
||||
|
@ -667,21 +692,21 @@ void CMapLayers::OnMapLoad()
|
|||
if(y == 0)
|
||||
{
|
||||
Visuals.m_BorderTopRight.SetIndexBufferByteOffset((offset_ptr32)(tmpBorderCorners.size()*6*sizeof(unsigned int)));
|
||||
if(AddTile(tmpBorderCorners, tmpBorderCornersTexCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
if(AddTile(tmpBorderCorners, tmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderTopRight.Draw(true);
|
||||
|
||||
}
|
||||
else if(y == pTMap->m_Height - 1)
|
||||
{
|
||||
Visuals.m_BorderBottomRight.SetIndexBufferByteOffset((offset_ptr32)(tmpBorderCorners.size()*6*sizeof(unsigned int)));
|
||||
if(AddTile(tmpBorderCorners, tmpBorderCornersTexCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
if(AddTile(tmpBorderCorners, tmpBorderCornersTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderBottomRight.Draw(true);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Visuals.m_BorderRight[y-1].SetIndexBufferByteOffset((offset_ptr32)(tmpBorderRightTiles.size()*6*sizeof(unsigned int)));
|
||||
if(AddTile(tmpBorderRightTiles, tmpBorderRightTilesTexCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
if(AddTile(tmpBorderRightTiles, tmpBorderRightTilesTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderRight[y-1].Draw(true);
|
||||
}
|
||||
}
|
||||
|
@ -690,7 +715,7 @@ void CMapLayers::OnMapLoad()
|
|||
if(x > 0 && x < pTMap->m_Width - 1)
|
||||
{
|
||||
Visuals.m_BorderTop[x-1].SetIndexBufferByteOffset((offset_ptr32)(tmpBorderTopTiles.size()*6*sizeof(unsigned int)));
|
||||
if(AddTile(tmpBorderTopTiles, tmpBorderTopTilesTexCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
if(AddTile(tmpBorderTopTiles, tmpBorderTopTilesTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderTop[x-1].Draw(true);
|
||||
}
|
||||
}
|
||||
|
@ -699,7 +724,7 @@ void CMapLayers::OnMapLoad()
|
|||
if(x > 0 && x < pTMap->m_Width - 1)
|
||||
{
|
||||
Visuals.m_BorderBottom[x-1].SetIndexBufferByteOffset((offset_ptr32)(tmpBorderBottomTiles.size()*6*sizeof(unsigned int)));
|
||||
if(AddTile(tmpBorderBottomTiles, tmpBorderBottomTilesTexCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
if(AddTile(tmpBorderBottomTiles, tmpBorderBottomTilesTexCoords, As3DTextureCoords, Index, Flags, x, y, pGroup, DoTextureCoords, AddAsSpeedup, AngleRotate))
|
||||
Visuals.m_BorderBottom[x-1].Draw(true);
|
||||
}
|
||||
}
|
||||
|
@ -710,7 +735,7 @@ void CMapLayers::OnMapLoad()
|
|||
if(IsGameLayer)
|
||||
{
|
||||
Visuals.m_BorderKillTile.SetIndexBufferByteOffset((offset_ptr32)(tmpTiles.size() * 6 * sizeof(unsigned int)));
|
||||
if(AddTile(tmpTiles, tmpTileTexCoords, TILE_DEATH, 0, 0, 0, pGroup, DoTextureCoords))
|
||||
if(AddTile(tmpTiles, tmpTileTexCoords, As3DTextureCoords, TILE_DEATH, 0, 0, 0, pGroup, DoTextureCoords))
|
||||
Visuals.m_BorderKillTile.Draw(true);
|
||||
}
|
||||
|
||||
|
@ -773,51 +798,55 @@ void CMapLayers::OnMapLoad()
|
|||
float* pTmpTiles = (tmpTiles.size() == 0) ? NULL : (float*)&tmpTiles[0];
|
||||
unsigned char* pTmpTileTexCoords = (tmpTileTexCoords.size() == 0) ? NULL : (unsigned char*)&tmpTileTexCoords[0];
|
||||
|
||||
size_t UploadDataSize = tmpTileTexCoords.size() * sizeof(STmpTileTexCoord) + tmpTiles.size() * sizeof(STmpTile);
|
||||
char* pUploadData = new char[UploadDataSize];
|
||||
|
||||
mem_copy_special(pUploadData, pTmpTiles, sizeof(vec2), tmpTiles.size() * 4, (DoTextureCoords ? sizeof(vec3) : 0));
|
||||
if(DoTextureCoords)
|
||||
Visuals.m_BufferContainerIndex = -1;
|
||||
size_t UploadDataSize = tmpTileTexCoords.size() * sizeof(SGraphicTileTexureCoords) + tmpTiles.size() * sizeof(SGraphicTile);
|
||||
if(UploadDataSize > 0)
|
||||
{
|
||||
mem_copy_special(pUploadData + sizeof(vec2), pTmpTileTexCoords, sizeof(vec3), tmpTiles.size() * 4, (DoTextureCoords ? (sizeof(vec2)) : 0));
|
||||
}
|
||||
char* pUploadData = new char[UploadDataSize];
|
||||
|
||||
// first create the buffer object
|
||||
int BufferObjectIndex = Graphics()->CreateBufferObject(UploadDataSize, pUploadData);
|
||||
delete[] pUploadData;
|
||||
mem_copy_special(pUploadData, pTmpTiles, sizeof(vec2), tmpTiles.size() * 4, (DoTextureCoords ? sizeof(vec3) : 0));
|
||||
if(DoTextureCoords)
|
||||
{
|
||||
mem_copy_special(pUploadData + sizeof(vec2), pTmpTileTexCoords, sizeof(vec3), tmpTiles.size() * 4, (DoTextureCoords ? (sizeof(vec2)) : 0));
|
||||
}
|
||||
|
||||
// then create the buffer container
|
||||
SBufferContainerInfo ContainerInfo;
|
||||
ContainerInfo.m_Stride = (DoTextureCoords ? (sizeof(float) * 2 + sizeof(vec3)) : 0);
|
||||
ContainerInfo.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
|
||||
SBufferContainerInfo::SAttribute* pAttr = &ContainerInfo.m_Attributes.back();
|
||||
pAttr->m_DataTypeCount = 2;
|
||||
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
|
||||
pAttr->m_Normalized = false;
|
||||
pAttr->m_pOffset = 0;
|
||||
pAttr->m_FuncType = 0;
|
||||
pAttr->m_VertBufferBindingIndex = BufferObjectIndex;
|
||||
if(DoTextureCoords)
|
||||
{
|
||||
// first create the buffer object
|
||||
int BufferObjectIndex = Graphics()->CreateBufferObject(UploadDataSize, pUploadData);
|
||||
delete[] pUploadData;
|
||||
|
||||
// then create the buffer container
|
||||
SBufferContainerInfo ContainerInfo;
|
||||
ContainerInfo.m_Stride = (DoTextureCoords ? (sizeof(float) * 2 + sizeof(vec3)) : 0);
|
||||
ContainerInfo.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
|
||||
pAttr = &ContainerInfo.m_Attributes.back();
|
||||
pAttr->m_DataTypeCount = 3;
|
||||
SBufferContainerInfo::SAttribute* pAttr = &ContainerInfo.m_Attributes.back();
|
||||
pAttr->m_DataTypeCount = 2;
|
||||
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
|
||||
pAttr->m_Normalized = false;
|
||||
pAttr->m_pOffset = (void*)(sizeof(vec2));
|
||||
pAttr->m_pOffset = 0;
|
||||
pAttr->m_FuncType = 0;
|
||||
pAttr->m_VertBufferBindingIndex = BufferObjectIndex;
|
||||
}
|
||||
if(DoTextureCoords)
|
||||
{
|
||||
ContainerInfo.m_Attributes.push_back(SBufferContainerInfo::SAttribute());
|
||||
pAttr = &ContainerInfo.m_Attributes.back();
|
||||
pAttr->m_DataTypeCount = 3;
|
||||
pAttr->m_Type = GRAPHICS_TYPE_FLOAT;
|
||||
pAttr->m_Normalized = false;
|
||||
pAttr->m_pOffset = (void*)(sizeof(vec2));
|
||||
pAttr->m_FuncType = 0;
|
||||
pAttr->m_VertBufferBindingIndex = BufferObjectIndex;
|
||||
}
|
||||
|
||||
Visuals.m_BufferContainerIndex = Graphics()->CreateBufferContainer(&ContainerInfo);
|
||||
// and finally inform the backend how many indices are required
|
||||
Graphics()->IndicesNumRequiredNotify(tmpTiles.size() * 6);
|
||||
Visuals.m_BufferContainerIndex = Graphics()->CreateBufferContainer(&ContainerInfo);
|
||||
// and finally inform the backend how many indices are required
|
||||
Graphics()->IndicesNumRequiredNotify(tmpTiles.size() * 6);
|
||||
}
|
||||
|
||||
++CurOverlay;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(pLayer->m_Type == LAYERTYPE_QUADS)
|
||||
else if(pLayer->m_Type == LAYERTYPE_QUADS && Graphics()->IsQuadBufferingEnabled())
|
||||
{
|
||||
CMapItemLayerQuads *pQLayer = (CMapItemLayerQuads *)pLayer;
|
||||
|
||||
|
@ -1666,7 +1695,7 @@ void CMapLayers::OnRender()
|
|||
Color = ColorRGBA(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
||||
else if(!IsGameLayer && g_Config.m_ClOverlayEntities && !(m_Type == TYPE_BACKGROUND_FORCE))
|
||||
Color = ColorRGBA(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*(100-g_Config.m_ClOverlayEntities)/100.0f);
|
||||
if(!Graphics()->IsBufferingEnabled())
|
||||
if(!Graphics()->IsTileBufferingEnabled())
|
||||
{
|
||||
Graphics()->BlendNone();
|
||||
RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE,
|
||||
|
@ -1689,7 +1718,8 @@ void CMapLayers::OnRender()
|
|||
|
||||
RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT,
|
||||
EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics()->BlendNormal();
|
||||
// draw kill tiles outside the entity clipping rectangle
|
||||
|
@ -1719,7 +1749,7 @@ void CMapLayers::OnRender()
|
|||
{
|
||||
if(g_Config.m_ClShowQuads)
|
||||
{
|
||||
if(!Graphics()->IsBufferingEnabled())
|
||||
if(!Graphics()->IsQuadBufferingEnabled())
|
||||
{
|
||||
//Graphics()->BlendNone();
|
||||
//RenderTools()->ForceRenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_OPAQUE, EnvelopeEval, this, 1.f);
|
||||
|
@ -1733,7 +1763,7 @@ void CMapLayers::OnRender()
|
|||
}
|
||||
} else
|
||||
{
|
||||
if(!Graphics()->IsBufferingEnabled())
|
||||
if(!Graphics()->IsQuadBufferingEnabled())
|
||||
{
|
||||
//Graphics()->BlendNone();
|
||||
//RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_OPAQUE, EnvelopeEval, this);
|
||||
|
@ -1758,7 +1788,7 @@ void CMapLayers::OnRender()
|
|||
if(Size >= pTMap->m_Width*pTMap->m_Height*sizeof(CTile))
|
||||
{
|
||||
ColorRGBA Color = ColorRGBA(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
||||
if(!Graphics()->IsBufferingEnabled())
|
||||
if(!Graphics()->IsTileBufferingEnabled())
|
||||
{
|
||||
Graphics()->BlendNone();
|
||||
RenderTools()->RenderTilemap(pFrontTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE,
|
||||
|
@ -1785,7 +1815,7 @@ void CMapLayers::OnRender()
|
|||
if(Size >= pTMap->m_Width*pTMap->m_Height*sizeof(CSwitchTile))
|
||||
{
|
||||
ColorRGBA Color = ColorRGBA(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
||||
if(!Graphics()->IsBufferingEnabled())
|
||||
if(!Graphics()->IsTileBufferingEnabled())
|
||||
{
|
||||
Graphics()->BlendNone();
|
||||
RenderTools()->RenderSwitchmap(pSwitchTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
|
||||
|
@ -1818,7 +1848,7 @@ void CMapLayers::OnRender()
|
|||
if(Size >= pTMap->m_Width*pTMap->m_Height*sizeof(CTeleTile))
|
||||
{
|
||||
ColorRGBA Color = ColorRGBA(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
||||
if(!Graphics()->IsBufferingEnabled())
|
||||
if(!Graphics()->IsTileBufferingEnabled())
|
||||
{
|
||||
Graphics()->BlendNone();
|
||||
RenderTools()->RenderTelemap(pTeleTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
|
||||
|
@ -1849,7 +1879,7 @@ void CMapLayers::OnRender()
|
|||
if(Size >= pTMap->m_Width*pTMap->m_Height*sizeof(CSpeedupTile))
|
||||
{
|
||||
ColorRGBA Color = ColorRGBA(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
||||
if(!Graphics()->IsBufferingEnabled())
|
||||
if(!Graphics()->IsTileBufferingEnabled())
|
||||
{
|
||||
Graphics()->BlendNone();
|
||||
RenderTools()->RenderSpeedupmap(pSpeedupTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
|
||||
|
@ -1887,7 +1917,7 @@ void CMapLayers::OnRender()
|
|||
if(Size >= pTMap->m_Width*pTMap->m_Height*sizeof(CTuneTile))
|
||||
{
|
||||
ColorRGBA Color = ColorRGBA(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
||||
if(!Graphics()->IsBufferingEnabled())
|
||||
if(!Graphics()->IsTileBufferingEnabled())
|
||||
{
|
||||
Graphics()->BlendNone();
|
||||
RenderTools()->RenderTunemap(pTuneTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
|
||||
|
|
|
@ -178,7 +178,7 @@ void CParticles::RenderGroup(int Group)
|
|||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_PARTICLES].m_Id);
|
||||
|
||||
// don't use the buffer methods here, else the old renderer gets many draw calls
|
||||
if(Graphics()->IsBufferingEnabled())
|
||||
if(Graphics()->IsQuadContainerBufferingEnabled())
|
||||
{
|
||||
int i = m_aFirstPart[Group];
|
||||
|
||||
|
|
Loading…
Reference in a new issue