mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
parent
1e8c70e3d4
commit
060f6fd36e
|
@ -7,6 +7,7 @@
|
|||
#endif
|
||||
|
||||
#include "engine/external/glew/GL/glew.h"
|
||||
#include <engine/storage.h>
|
||||
|
||||
#include <base/detect.h>
|
||||
#include <base/math.h>
|
||||
|
@ -120,7 +121,7 @@ void CCommandProcessorFragment_General::Cmd_Signal(const CCommandBuffer::SComman
|
|||
pCommand->m_pSemaphore->signal();
|
||||
}
|
||||
|
||||
bool CCommandProcessorFragment_General::RunCommand(const CCommandBuffer::SCommand * pBaseCommand)
|
||||
bool CCommandProcessorFragment_General::RunCommand(const CCommandBuffer::SCommand *pBaseCommand)
|
||||
{
|
||||
switch(pBaseCommand->m_Cmd)
|
||||
{
|
||||
|
@ -415,7 +416,7 @@ CCommandProcessorFragment_OpenGL::CCommandProcessorFragment_OpenGL()
|
|||
m_pTextureMemoryUsage = 0;
|
||||
}
|
||||
|
||||
bool CCommandProcessorFragment_OpenGL::RunCommand(const CCommandBuffer::SCommand * pBaseCommand)
|
||||
bool CCommandProcessorFragment_OpenGL::RunCommand(const CCommandBuffer::SCommand *pBaseCommand)
|
||||
{
|
||||
switch(pBaseCommand->m_Cmd)
|
||||
{
|
||||
|
@ -477,7 +478,7 @@ void *CCommandProcessorFragment_OpenGL3_3::Rescale(int Width, int Height, int Ne
|
|||
return pTmpData;
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_OpenGL3_3::SetState(const CCommandBuffer::SState &State, CGLSLTWProgram* pProgram)
|
||||
void CCommandProcessorFragment_OpenGL3_3::SetState(const CCommandBuffer::SState &State, CGLSLTWProgram *pProgram)
|
||||
{
|
||||
if(State.m_BlendMode != m_LastBlendMode && State.m_BlendMode != CCommandBuffer::BLEND_NONE)
|
||||
{
|
||||
|
@ -599,8 +600,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
{
|
||||
CGLSL PrimitiveVertexShader;
|
||||
CGLSL PrimitiveFragmentShader;
|
||||
PrimitiveVertexShader.LoadShader("data/shader/prim.vert", GL_VERTEX_SHADER);
|
||||
PrimitiveFragmentShader.LoadShader("data/shader/prim.frag", GL_FRAGMENT_SHADER);
|
||||
PrimitiveVertexShader.LoadShader(pCommand->m_pStorage, "shader/prim.vert", GL_VERTEX_SHADER);
|
||||
PrimitiveFragmentShader.LoadShader(pCommand->m_pStorage, "shader/prim.frag", GL_FRAGMENT_SHADER);
|
||||
|
||||
m_pPrimitiveProgram->CreateProgram();
|
||||
m_pPrimitiveProgram->AddShader(&PrimitiveVertexShader);
|
||||
|
@ -616,8 +617,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
VertexShader.LoadShader("data/shader/tile.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader("data/shader/tile.frag", GL_FRAGMENT_SHADER);
|
||||
VertexShader.LoadShader(pCommand->m_pStorage, "shader/tile.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(pCommand->m_pStorage, "shader/tile.frag", GL_FRAGMENT_SHADER);
|
||||
|
||||
m_pTileProgram->CreateProgram();
|
||||
m_pTileProgram->AddShader(&VertexShader);
|
||||
|
@ -635,8 +636,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
VertexShader.LoadShader("data/shader/tiletex.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader("data/shader/tiletex.frag", GL_FRAGMENT_SHADER);
|
||||
VertexShader.LoadShader(pCommand->m_pStorage, "shader/tiletex.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(pCommand->m_pStorage, "shader/tiletex.frag", GL_FRAGMENT_SHADER);
|
||||
|
||||
m_pTileProgramTextured->CreateProgram();
|
||||
m_pTileProgramTextured->AddShader(&VertexShader);
|
||||
|
@ -654,8 +655,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
VertexShader.LoadShader("data/shader/bordertile.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader("data/shader/bordertile.frag", GL_FRAGMENT_SHADER);
|
||||
VertexShader.LoadShader(pCommand->m_pStorage, "shader/bordertile.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(pCommand->m_pStorage, "shader/bordertile.frag", GL_FRAGMENT_SHADER);
|
||||
|
||||
m_pBorderTileProgram->CreateProgram();
|
||||
m_pBorderTileProgram->AddShader(&VertexShader);
|
||||
|
@ -676,9 +677,9 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
VertexShader.LoadShader("data/shader/bordertiletex.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader("data/shader/bordertiletex.frag", GL_FRAGMENT_SHADER);
|
||||
|
||||
VertexShader.LoadShader(pCommand->m_pStorage, "shader/bordertiletex.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(pCommand->m_pStorage, "shader/bordertiletex.frag", GL_FRAGMENT_SHADER);
|
||||
|
||||
m_pBorderTileProgramTextured->CreateProgram();
|
||||
m_pBorderTileProgramTextured->AddShader(&VertexShader);
|
||||
m_pBorderTileProgramTextured->AddShader(&FragmentShader);
|
||||
|
@ -698,8 +699,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
VertexShader.LoadShader("data/shader/bordertileline.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader("data/shader/bordertileline.frag", GL_FRAGMENT_SHADER);
|
||||
VertexShader.LoadShader(pCommand->m_pStorage, "shader/bordertileline.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(pCommand->m_pStorage, "shader/bordertileline.frag", GL_FRAGMENT_SHADER);
|
||||
|
||||
m_pBorderTileLineProgram->CreateProgram();
|
||||
m_pBorderTileLineProgram->AddShader(&VertexShader);
|
||||
|
@ -718,8 +719,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
{
|
||||
CGLSL VertexShader;
|
||||
CGLSL FragmentShader;
|
||||
VertexShader.LoadShader("data/shader/bordertilelinetex.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader("data/shader/bordertilelinetex.frag", GL_FRAGMENT_SHADER);
|
||||
VertexShader.LoadShader(pCommand->m_pStorage, "shader/bordertilelinetex.vert", GL_VERTEX_SHADER);
|
||||
FragmentShader.LoadShader(pCommand->m_pStorage, "shader/bordertilelinetex.frag", GL_FRAGMENT_SHADER);
|
||||
|
||||
m_pBorderTileLineProgramTextured->CreateProgram();
|
||||
m_pBorderTileLineProgramTextured->AddShader(&VertexShader);
|
||||
|
@ -1002,7 +1003,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Render(const CCommandBuffer::SComm
|
|||
else
|
||||
{
|
||||
//this is better for some iGPUs. Probably due to not initializing a new buffer in the system memory again and again...(driver dependend)
|
||||
void* pData = glMapBufferRange(GL_ARRAY_BUFFER, 0, sizeof(CCommandBuffer::SVertex) * Count, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
|
||||
void *pData = glMapBufferRange(GL_ARRAY_BUFFER, 0, sizeof(CCommandBuffer::SVertex) * Count, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
|
||||
|
||||
mem_copy(pData, pCommand->m_pVertices, sizeof(CCommandBuffer::SVertex) * Count);
|
||||
|
||||
|
@ -1071,7 +1072,7 @@ CCommandProcessorFragment_OpenGL3_3::CCommandProcessorFragment_OpenGL3_3()
|
|||
m_pTextureMemoryUsage = 0;
|
||||
}
|
||||
|
||||
bool CCommandProcessorFragment_OpenGL3_3::RunCommand(const CCommandBuffer::SCommand * pBaseCommand)
|
||||
bool CCommandProcessorFragment_OpenGL3_3::RunCommand(const CCommandBuffer::SCommand *pBaseCommand)
|
||||
{
|
||||
switch(pBaseCommand->m_Cmd)
|
||||
{
|
||||
|
@ -1136,7 +1137,7 @@ void CCommandProcessorFragment_OpenGL3_3::AppendIndices(unsigned int NewIndicesC
|
|||
{
|
||||
if(NewIndicesCount <= m_CurrentIndicesInBuffer) return;
|
||||
unsigned int AddCount = NewIndicesCount - m_CurrentIndicesInBuffer;
|
||||
unsigned int* Indices = new unsigned int[AddCount];
|
||||
unsigned int *Indices = new unsigned int[AddCount];
|
||||
int Primq = (m_CurrentIndicesInBuffer/6) * 4;
|
||||
for(unsigned int i = 0; i < AddCount; i+=6)
|
||||
{
|
||||
|
@ -1192,7 +1193,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTile(const CCommandBuf
|
|||
SVisualObject& VisualObject = m_VisualObjects[Index];
|
||||
if(VisualObject.m_VertArrayID == 0) return;
|
||||
|
||||
CGLSLBorderTileProgram* pProgram = NULL;
|
||||
CGLSLBorderTileProgram *pProgram = NULL;
|
||||
if(VisualObject.m_IsTextured)
|
||||
{
|
||||
pProgram = m_pBorderTileProgramTextured;
|
||||
|
@ -1227,7 +1228,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTileLine(const CComman
|
|||
SVisualObject& VisualObject = m_VisualObjects[Index];
|
||||
if(VisualObject.m_VertArrayID == 0) return;
|
||||
|
||||
CGLSLBorderTileLineProgram* pProgram = NULL;
|
||||
CGLSLBorderTileLineProgram *pProgram = NULL;
|
||||
if(VisualObject.m_IsTextured)
|
||||
{
|
||||
pProgram = m_pBorderTileLineProgramTextured;
|
||||
|
@ -1264,7 +1265,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderVertexArray(const CCommandBu
|
|||
return; //nothing to draw
|
||||
}
|
||||
|
||||
CGLSLTileProgram* pProgram = NULL;
|
||||
CGLSLTileProgram *pProgram = NULL;
|
||||
if(VisualObject.m_IsTextured)
|
||||
{
|
||||
pProgram = m_pTileProgramTextured;
|
||||
|
@ -1398,7 +1399,7 @@ void CCommandProcessorFragment_SDL::Cmd_Init(const SCommand_Init *pCommand)
|
|||
glDepthMask(0);
|
||||
}
|
||||
|
||||
void CCommandProcessorFragment_SDL::Cmd_Update_Viewport(const SCommand_Update_Viewport* pCommand)
|
||||
void CCommandProcessorFragment_SDL::Cmd_Update_Viewport(const SCommand_Update_Viewport *pCommand)
|
||||
{
|
||||
glViewport(pCommand->m_X, pCommand->m_Y, pCommand->m_Width, pCommand->m_Height);
|
||||
}
|
||||
|
@ -1517,7 +1518,7 @@ void CCommandProcessor_SDL_OpenGL::RunBuffer(CCommandBuffer *pBuffer)
|
|||
|
||||
// ------------ CGraphicsBackend_SDL_OpenGL
|
||||
|
||||
int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidth, int *pHeight, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight, int* pCurrentWidth, int* pCurrentHeight)
|
||||
int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidth, int *pHeight, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight, int *pCurrentWidth, int *pCurrentHeight, IStorage *pStorage)
|
||||
{
|
||||
if(!SDL_WasInit(SDL_INIT_VIDEO))
|
||||
{
|
||||
|
@ -1534,7 +1535,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
|||
}
|
||||
|
||||
SDL_ClearError();
|
||||
const char* pErr = NULL;
|
||||
const char *pErr = NULL;
|
||||
|
||||
//query default values, since they are platform dependend
|
||||
static bool s_InitDefaultParams = false;
|
||||
|
@ -1759,6 +1760,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
|||
WaitForIdle();
|
||||
CCommandProcessorFragment_OpenGL3_3::SCommand_Init CmdOpenGL;
|
||||
CmdOpenGL.m_pTextureMemoryUsage = &m_TextureMemoryUsage;
|
||||
CmdOpenGL.m_pStorage = pStorage;
|
||||
CmdBuffer.AddCommand(CmdOpenGL);
|
||||
RunBuffer(&CmdBuffer);
|
||||
WaitForIdle();
|
||||
|
|
|
@ -70,7 +70,7 @@ class CCommandProcessorFragment_General
|
|||
void Cmd_Nop();
|
||||
void Cmd_Signal(const CCommandBuffer::SCommand_Signal *pCommand);
|
||||
public:
|
||||
bool RunCommand(const CCommandBuffer::SCommand * pBaseCommand);
|
||||
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand);
|
||||
};
|
||||
|
||||
// takes care of opengl related rendering
|
||||
|
@ -114,7 +114,7 @@ private:
|
|||
public:
|
||||
CCommandProcessorFragment_OpenGL();
|
||||
|
||||
bool RunCommand(const CCommandBuffer::SCommand * pBaseCommand);
|
||||
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand);
|
||||
};
|
||||
|
||||
class CGLSLProgram;
|
||||
|
@ -140,13 +140,13 @@ class CCommandProcessorFragment_OpenGL3_3
|
|||
CTexture m_aTextures[CCommandBuffer::MAX_TEXTURES];
|
||||
volatile int *m_pTextureMemoryUsage;
|
||||
|
||||
CGLSLPrimitiveProgram* m_pPrimitiveProgram;
|
||||
CGLSLTileProgram* m_pTileProgram;
|
||||
CGLSLTileProgram* m_pTileProgramTextured;
|
||||
CGLSLBorderTileProgram* m_pBorderTileProgram;
|
||||
CGLSLBorderTileProgram* m_pBorderTileProgramTextured;
|
||||
CGLSLBorderTileLineProgram* m_pBorderTileLineProgram;
|
||||
CGLSLBorderTileLineProgram* m_pBorderTileLineProgramTextured;
|
||||
CGLSLPrimitiveProgram *m_pPrimitiveProgram;
|
||||
CGLSLTileProgram *m_pTileProgram;
|
||||
CGLSLTileProgram *m_pTileProgramTextured;
|
||||
CGLSLBorderTileProgram *m_pBorderTileProgram;
|
||||
CGLSLBorderTileProgram *m_pBorderTileProgramTextured;
|
||||
CGLSLBorderTileLineProgram *m_pBorderTileLineProgram;
|
||||
CGLSLBorderTileLineProgram *m_pBorderTileLineProgramTextured;
|
||||
|
||||
GLuint m_PrimitiveDrawVertexID;
|
||||
GLuint m_PrimitiveDrawBufferID;
|
||||
|
@ -193,6 +193,7 @@ public:
|
|||
struct SCommand_Init : public CCommandBuffer::SCommand
|
||||
{
|
||||
SCommand_Init() : SCommand(CMD_INIT) {}
|
||||
class IStorage *m_pStorage;
|
||||
volatile int *m_pTextureMemoryUsage;
|
||||
};
|
||||
|
||||
|
@ -206,7 +207,7 @@ private:
|
|||
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);
|
||||
void SetState(const CCommandBuffer::SState &State, CGLSLTWProgram *pProgram);
|
||||
|
||||
void Cmd_Init(const SCommand_Init *pCommand);
|
||||
void Cmd_Shutdown(const SCommand_Shutdown *pCommand);
|
||||
|
@ -228,7 +229,7 @@ private:
|
|||
public:
|
||||
CCommandProcessorFragment_OpenGL3_3();
|
||||
|
||||
bool RunCommand(const CCommandBuffer::SCommand * pBaseCommand);
|
||||
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand);
|
||||
};
|
||||
|
||||
// takes care of sdl related commands
|
||||
|
@ -268,7 +269,7 @@ public:
|
|||
|
||||
private:
|
||||
void Cmd_Init(const SCommand_Init *pCommand);
|
||||
void Cmd_Update_Viewport(const SCommand_Update_Viewport* pCommand);
|
||||
void Cmd_Update_Viewport(const SCommand_Update_Viewport *pCommand);
|
||||
void Cmd_Shutdown(const SCommand_Shutdown *pCommand);
|
||||
void Cmd_Swap(const CCommandBuffer::SCommand_Swap *pCommand);
|
||||
void Cmd_VSync(const CCommandBuffer::SCommand_VSync *pCommand);
|
||||
|
@ -305,7 +306,7 @@ class CGraphicsBackend_SDL_OpenGL : public CGraphicsBackend_Threaded
|
|||
|
||||
bool m_UseOpenGL3_3;
|
||||
public:
|
||||
virtual int Init(const char *pName, int *Screen, int *pWidth, int *pHeight, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight, int* pCurrentWidth, int* pCurrentHeight);
|
||||
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);
|
||||
virtual int Shutdown();
|
||||
|
||||
virtual int MemoryUsage() const;
|
||||
|
|
|
@ -136,7 +136,7 @@ void CGraphics_Threaded::Rotate(const CCommandBuffer::SPoint &rCenter, CCommandB
|
|||
|
||||
if(m_UseOpenGL3_3)
|
||||
{
|
||||
CCommandBuffer::SVertex* pVertices = (CCommandBuffer::SVertex*) pPoints;
|
||||
CCommandBuffer::SVertex *pVertices = (CCommandBuffer::SVertex*) pPoints;
|
||||
for(i = 0; i < NumPoints; i++)
|
||||
{
|
||||
x = pVertices[i].m_Pos.x - rCenter.x;
|
||||
|
@ -147,7 +147,7 @@ void CGraphics_Threaded::Rotate(const CCommandBuffer::SPoint &rCenter, CCommandB
|
|||
}
|
||||
else
|
||||
{
|
||||
CCommandBuffer::SVertexOld* pVertices = (CCommandBuffer::SVertexOld*) pPoints;
|
||||
CCommandBuffer::SVertexOld *pVertices = (CCommandBuffer::SVertexOld*) pPoints;
|
||||
for(i = 0; i < NumPoints; i++)
|
||||
{
|
||||
x = pVertices[i].m_Pos.x - rCenter.x;
|
||||
|
@ -610,11 +610,11 @@ void CGraphics_Threaded::SetColor(float r, float g, float b, float a)
|
|||
SetColorVertex(Array, 4);
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::SetColor(CCommandBuffer::SVertexBase* pVertex, int ColorIndex)
|
||||
void CGraphics_Threaded::SetColor(CCommandBuffer::SVertexBase *pVertex, int ColorIndex)
|
||||
{
|
||||
if(m_UseOpenGL3_3)
|
||||
{
|
||||
CCommandBuffer::SVertex* pVert = (CCommandBuffer::SVertex*)pVertex;
|
||||
CCommandBuffer::SVertex *pVert = (CCommandBuffer::SVertex*)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;
|
||||
|
@ -622,7 +622,7 @@ void CGraphics_Threaded::SetColor(CCommandBuffer::SVertexBase* pVertex, int Colo
|
|||
}
|
||||
else
|
||||
{
|
||||
CCommandBuffer::SVertexOld* pVert = (CCommandBuffer::SVertexOld*)pVertex;
|
||||
CCommandBuffer::SVertexOld *pVert = (CCommandBuffer::SVertexOld*)pVertex;
|
||||
pVert->m_Color.r = m_aColorOld[ColorIndex].r;
|
||||
pVert->m_Color.g = m_aColorOld[ColorIndex].g;
|
||||
pVert->m_Color.b = m_aColorOld[ColorIndex].b;
|
||||
|
@ -630,7 +630,7 @@ void CGraphics_Threaded::SetColor(CCommandBuffer::SVertexBase* pVertex, int Colo
|
|||
}
|
||||
}
|
||||
|
||||
CCommandBuffer::SVertexBase* CGraphics_Threaded::GetVertex(int Index)
|
||||
CCommandBuffer::SVertexBase *CGraphics_Threaded::GetVertex(int Index)
|
||||
{
|
||||
if(!m_UseOpenGL3_3)
|
||||
return &((CCommandBuffer::SVertexOld*)m_pVertices)[Index];
|
||||
|
@ -859,7 +859,7 @@ void CGraphics_Threaded::QuadsText(float x, float y, float Size, const char *pTe
|
|||
}
|
||||
}
|
||||
|
||||
void mem_copy_special(void* pDest, void* pSource, size_t Size, size_t Count, size_t Steps)
|
||||
void mem_copy_special(void *pDest, void *pSource, size_t Size, size_t Count, size_t Steps)
|
||||
{
|
||||
size_t CurStep = 0;
|
||||
for(size_t i = 0; i < Count; ++i)
|
||||
|
@ -869,7 +869,7 @@ void mem_copy_special(void* pDest, void* pSource, size_t Size, size_t Count, siz
|
|||
}
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::DrawVisualObject(int VisualObjectIDX, float* pColor, char** pOffsets, unsigned int* IndicedVertexDrawNum, size_t NumIndicesOffet)
|
||||
void CGraphics_Threaded::DrawVisualObject(int VisualObjectIDX, float *pColor, char** pOffsets, unsigned int *IndicedVertexDrawNum, size_t NumIndicesOffet)
|
||||
{
|
||||
if(NumIndicesOffet == 0) return;
|
||||
|
||||
|
@ -889,13 +889,13 @@ void CGraphics_Threaded::DrawVisualObject(int VisualObjectIDX, float* pColor, ch
|
|||
if(LOD < 0) LOD = 0;
|
||||
Cmd.m_LOD = LOD;
|
||||
|
||||
void* Data = m_pCommandBuffer->AllocData((sizeof(char*) + sizeof(unsigned int))*NumIndicesOffet);
|
||||
void *Data = m_pCommandBuffer->AllocData((sizeof(char*) + sizeof(unsigned int))*NumIndicesOffet);
|
||||
if(Data == 0x0)
|
||||
{
|
||||
// kick command buffer and try again
|
||||
KickCommandBuffer();
|
||||
|
||||
void* Data = m_pCommandBuffer->AllocData((sizeof(char*) + sizeof(unsigned int))*NumIndicesOffet);
|
||||
void *Data = m_pCommandBuffer->AllocData((sizeof(char*) + sizeof(unsigned int))*NumIndicesOffet);
|
||||
if(Data == 0x0)
|
||||
{
|
||||
dbg_msg("graphics", "failed to allocate data for vertices");
|
||||
|
@ -934,7 +934,7 @@ void CGraphics_Threaded::DrawVisualObject(int VisualObjectIDX, float* pColor, ch
|
|||
//todo max indices group check!!
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::DrawBorderTile(int VisualObjectIDX, float* pColor, char* pOffset, float* Offset, float* Dir, int JumpIndex, unsigned int DrawNum)
|
||||
void CGraphics_Threaded::DrawBorderTile(int VisualObjectIDX, float *pColor, char *pOffset, float *Offset, float *Dir, int JumpIndex, unsigned int DrawNum)
|
||||
{
|
||||
if(DrawNum == 0) return;
|
||||
//draw a border tile alot of times
|
||||
|
@ -974,7 +974,7 @@ void CGraphics_Threaded::DrawBorderTile(int VisualObjectIDX, float* pColor, char
|
|||
}
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::DrawBorderTileLine(int VisualObjectIDX, float* pColor, char* pOffset, float* Dir, unsigned int IndexDrawNum, unsigned int RedrawNum)
|
||||
void CGraphics_Threaded::DrawBorderTileLine(int VisualObjectIDX, float *pColor, char *pOffset, float *Dir, unsigned int IndexDrawNum, unsigned int RedrawNum)
|
||||
{
|
||||
if(IndexDrawNum == 0 || RedrawNum == 0) return;
|
||||
//draw a border tile alot of times
|
||||
|
@ -1036,7 +1036,7 @@ void CGraphics_Threaded::DestroyVisual(int VisualObjectIDX)
|
|||
m_FirstFreeVertexArrayIndex = VisualObjectIDX;
|
||||
}
|
||||
|
||||
int CGraphics_Threaded::CreateVisualObjects(float* pVertices, unsigned char* pTexCoords, int NumTiles, unsigned int NumIndicesRequired)
|
||||
int CGraphics_Threaded::CreateVisualObjects(float *pVertices, unsigned char *pTexCoords, int NumTiles, unsigned int NumIndicesRequired)
|
||||
{
|
||||
if(!pVertices) return -1;
|
||||
|
||||
|
@ -1139,7 +1139,7 @@ int CGraphics_Threaded::CreateVisualObjects(float* pVertices, unsigned char* pTe
|
|||
return index;
|
||||
}
|
||||
|
||||
void CGraphics_Threaded::AppendAllVertices(float* pVertices, unsigned char* pTexCoords, int NumTiles, int VisualObjectIDX)
|
||||
void CGraphics_Threaded::AppendAllVertices(float *pVertices, unsigned char *pTexCoords, int NumTiles, int VisualObjectIDX)
|
||||
{
|
||||
//the size of the cmd data buffer is 2MB -- we create 4 vertices of each 2 floats plus 2 shorts(2*unsigned char each) if TexCoordinates are used
|
||||
char AddTexture = (pTexCoords == NULL ? 0 : 1);
|
||||
|
@ -1212,7 +1212,7 @@ int CGraphics_Threaded::IssueInit()
|
|||
if(g_Config.m_GfxVsync) Flags |= IGraphicsBackend::INITFLAG_VSYNC;
|
||||
if(g_Config.m_GfxResizable) Flags |= IGraphicsBackend::INITFLAG_RESIZABLE;
|
||||
|
||||
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);
|
||||
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_UseOpenGL3_3 = m_pBackend->IsOpenGL3_3();
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public:
|
|||
struct SCommand_CreateVertexBufferObject : public SCommand
|
||||
{
|
||||
SCommand_CreateVertexBufferObject() : SCommand(CMD_CREATE_VERTEX_BUFFER_OBJECT) {}
|
||||
void* m_Elements; //vertices and optinally textureCoords
|
||||
void *m_Elements; //vertices and optinally textureCoords
|
||||
|
||||
bool m_IsTextured;
|
||||
|
||||
|
@ -224,7 +224,7 @@ public:
|
|||
struct SCommand_AppendVertexBufferObject : public SCommand
|
||||
{
|
||||
SCommand_AppendVertexBufferObject() : SCommand(CMD_APPEND_VERTEX_BUFFER_OBJECT) {}
|
||||
void* m_Elements; //vertices and optinally textureCoords
|
||||
void *m_Elements; //vertices and optinally textureCoords
|
||||
int m_NumVertices;
|
||||
int m_VisualObjectIDX;
|
||||
};
|
||||
|
@ -245,7 +245,7 @@ public:
|
|||
|
||||
//the char offset of all indices that should be rendered, and the amount of renders
|
||||
char** m_pIndicesOffsets;
|
||||
unsigned int* m_pDrawCount;
|
||||
unsigned int *m_pDrawCount;
|
||||
|
||||
int m_IndicesDrawNum;
|
||||
int m_VisualObjectIDX;
|
||||
|
@ -424,7 +424,7 @@ public:
|
|||
|
||||
virtual ~IGraphicsBackend() {}
|
||||
|
||||
virtual int Init(const char *pName, int *Screen, int *pWidth, int *pHeight, int FsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight, int* pCurrentWidth, int* pCurrentHeight) = 0;
|
||||
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;
|
||||
virtual int Shutdown() = 0;
|
||||
|
||||
virtual int MemoryUsage() const = 0;
|
||||
|
@ -476,7 +476,7 @@ class CGraphics_Threaded : public IEngineGraphics
|
|||
|
||||
CCommandBuffer::SVertex m_aVertices[MAX_VERTICES];
|
||||
CCommandBuffer::SVertexOld m_aVerticesOld[MAX_VERTICES];
|
||||
CCommandBuffer::SVertexBase* m_pVertices;
|
||||
CCommandBuffer::SVertexBase *m_pVertices;
|
||||
int m_NumVertices;
|
||||
|
||||
CCommandBuffer::SColorf m_aColorOld[4];
|
||||
|
@ -550,8 +550,8 @@ public:
|
|||
virtual void SetColorVertex(const CColorVertex *pArray, int Num);
|
||||
virtual void SetColor(float r, float g, float b, float a);
|
||||
|
||||
void SetColor(CCommandBuffer::SVertexBase* pVertex, int ColorIndex);
|
||||
CCommandBuffer::SVertexBase* GetVertex(int Index);
|
||||
void SetColor(CCommandBuffer::SVertexBase *pVertex, int ColorIndex);
|
||||
CCommandBuffer::SVertexBase *GetVertex(int Index);
|
||||
|
||||
virtual void QuadsSetSubset(float TlU, float TlV, float BrU, float BrV);
|
||||
virtual void QuadsSetSubsetFree(
|
||||
|
@ -563,12 +563,12 @@ public:
|
|||
virtual void QuadsDrawFreeform(const CFreeformItem *pArray, int Num);
|
||||
virtual void QuadsText(float x, float y, float Size, const char *pText);
|
||||
|
||||
virtual void DrawVisualObject(int VisualObjectIDX, float* pColor, char** pOffsets, unsigned int* IndicedVertexDrawNum, size_t NumIndicesOffet);
|
||||
virtual void DrawBorderTile(int VisualObjectIDX, float* pColor, char* pOffset, float* Offset, float* Dir, int JumpIndex, unsigned int DrawNum);
|
||||
virtual void DrawBorderTileLine(int VisualObjectIDX, float* pColor, char* pOffset, float* Dir, unsigned int IndexDrawNum, unsigned int RedrawNum);
|
||||
virtual void DrawVisualObject(int VisualObjectIDX, float *pColor, char** pOffsets, unsigned int *IndicedVertexDrawNum, size_t NumIndicesOffet);
|
||||
virtual void DrawBorderTile(int VisualObjectIDX, float *pColor, char *pOffset, float *Offset, float *Dir, int JumpIndex, unsigned int DrawNum);
|
||||
virtual void DrawBorderTileLine(int VisualObjectIDX, float *pColor, char *pOffset, float *Dir, unsigned int IndexDrawNum, unsigned int RedrawNum);
|
||||
virtual void DestroyVisual(int VisualObjectIDX);
|
||||
virtual int CreateVisualObjects(float* pVertices, unsigned char* pTexCoords, int NumTiles, unsigned int NumIndicesRequired);
|
||||
virtual void AppendAllVertices(float* pVertices, unsigned char* pTexCoords, int NumTiles, int VisualObjectIDX);
|
||||
virtual int CreateVisualObjects(float *pVertices, unsigned char *pTexCoords, int NumTiles, unsigned int NumIndicesRequired);
|
||||
virtual void AppendAllVertices(float *pVertices, unsigned char *pTexCoords, int NumTiles, int VisualObjectIDX);
|
||||
|
||||
virtual int GetNumScreens() const;
|
||||
virtual void Minimize();
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
#include "opengl_sl.h"
|
||||
#include <engine/shared/linereader.h>
|
||||
#include <engine/storage.h>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
bool CGLSL::LoadShader(const char* pFile, int Type)
|
||||
bool CGLSL::LoadShader(IStorage *pStorage, const char *pFile, int Type)
|
||||
{
|
||||
if (m_IsLoaded) return true;
|
||||
IOHANDLE f;
|
||||
f = io_open(pFile, IOFLAG_READ);
|
||||
|
||||
if (m_IsLoaded)
|
||||
return true;
|
||||
IOHANDLE f = pStorage->OpenFile(pFile, IOFLAG_READ, IStorage::TYPE_ALL);
|
||||
|
||||
std::vector<std::string> Lines;
|
||||
if (f)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
class CGLSL {
|
||||
public:
|
||||
bool LoadShader(const char* pFile, int Type);
|
||||
bool LoadShader(class IStorage *pStorage, const char *pFile, int Type);
|
||||
void DeleteShader();
|
||||
|
||||
bool IsLoaded();
|
||||
|
|
Loading…
Reference in a new issue