reduce upload size by normalizing color values, fix slow upload for some

iGPUs and force old opengl context, if issueinit fails
This commit is contained in:
Jupeyy 2017-09-27 12:16:34 +02:00
parent a85f542d1d
commit 91216fb90c
5 changed files with 397 additions and 372 deletions

View file

@ -337,9 +337,9 @@ void CCommandProcessorFragment_OpenGL::Cmd_Render(const CCommandBuffer::SCommand
{
SetState(pCommand->m_State);
glVertexPointer(2, GL_FLOAT, sizeof(CCommandBuffer::SVertex), (char*)pCommand->m_pVertices);
glTexCoordPointer(2, GL_FLOAT, sizeof(CCommandBuffer::SVertex), (char*)pCommand->m_pVertices + sizeof(float)*2);
glColorPointer(4, GL_FLOAT, sizeof(CCommandBuffer::SVertex), (char*)pCommand->m_pVertices + sizeof(float)*4);
glVertexPointer(2, GL_FLOAT, sizeof(CCommandBuffer::SVertexOld), (char*)pCommand->m_pVertices);
glTexCoordPointer(2, GL_FLOAT, sizeof(CCommandBuffer::SVertexOld), (char*)pCommand->m_pVertices + sizeof(float)*2);
glColorPointer(4, GL_FLOAT, sizeof(CCommandBuffer::SVertexOld), (char*)pCommand->m_pVertices + sizeof(float)*4);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
@ -726,13 +726,23 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
}
glGenBuffers(1, &m_PrimitiveDrawBufferID);
glBindBuffer(GL_ARRAY_BUFFER, m_PrimitiveDrawBufferID);
glGenVertexArrays(1, &m_PrimitiveDrawVertexID);
glBindBuffer(GL_ARRAY_BUFFER, m_PrimitiveDrawBufferID);
glBindVertexArray(m_PrimitiveDrawVertexID);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(CCommandBuffer::SVertex), 0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(CCommandBuffer::SVertex), (void*)(sizeof(float) * 2));
glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(CCommandBuffer::SVertex), (void*)(sizeof(float) * 4));
m_UsePreinitializedVertexBuffer = g_Config.m_GfxUsePreinitBuffer;
if(m_UsePreinitializedVertexBuffer)
glBufferData(GL_ARRAY_BUFFER, sizeof(CCommandBuffer::SVertex) * CCommandBuffer::MAX_VERTICES, NULL, GL_STREAM_DRAW);
//query maximum of allowed textures
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &m_MaxTextureUnits);
m_TextureSlotBoundToUnit.resize(m_MaxTextureUnits);
@ -742,24 +752,28 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
m_TextureSlotBoundToUnit[i].m_LastWrapMode = -1;
}
glGenBuffers(1, &m_PrimitiveDrawIndexBufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_PrimitiveDrawIndexBufferID);
glGenBuffers(1, &m_QuadDrawIndexBufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID);
unsigned int Indices[CCommandBuffer::MAX_VERTICES/4 * 6];
int Primq = 0;
for(int i = 0; i < CCommandBuffer::MAX_VERTICES/4 * 6; i+=6)
{
Indices[i] = Primq;
Indices[i+1] = Primq + 3;
Indices[i+2] = Primq + 1;
Indices[i+3] = Primq + 3;
Indices[i+4] = Primq + 1;
Indices[i+5] = Primq + 2;
Indices[i+1] = Primq + 1;
Indices[i+2] = Primq + 2;
Indices[i+3] = Primq;
Indices[i+4] = Primq + 2;
Indices[i+5] = Primq + 3;
Primq+=4;
}
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(unsigned int) * CCommandBuffer::MAX_VERTICES/4 * 6, Indices, GL_STATIC_DRAW);
m_CurrentIndicesInBuffer = CCommandBuffer::MAX_VERTICES/4 * 6;
mem_zero(m_aTextures, sizeof(m_aTextures));
m_ClearColor.r = m_ClearColor.g = m_ClearColor.b = -1.f;
}
void CCommandProcessorFragment_OpenGL3_3::Cmd_Shutdown(const SCommand_Shutdown *pCommand)
@ -776,7 +790,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Shutdown(const SCommand_Shutdown *
glBindVertexArray(0);
glDeleteBuffers(1, &m_PrimitiveDrawBufferID);
glDeleteBuffers(1, &m_PrimitiveDrawIndexBufferID);
glDeleteBuffers(1, &m_QuadDrawIndexBufferID);
glDeleteVertexArrays(1, &m_PrimitiveDrawVertexID);
for(int i = 0; i < CCommandBuffer::MAX_TEXTURES; ++i)
@ -800,6 +814,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Update(const CCommandBuffe
//just tell, that we using this texture now
IsAndUpdateTextureSlotBound(Slot, pCommand->m_Slot);
glActiveTexture(GL_TEXTURE0 + Slot);
glBindSampler(Slot, m_aTextures[pCommand->m_Slot].m_Sampler);
}
//fix the alignment to allow even 1byte changes, e.g. for alpha components
@ -903,6 +918,8 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Create(const CCommandBuffe
if(pCommand->m_Flags&CCommandBuffer::TEXFLAG_NOMIPMAPS)
{
glTexParameteri(m_aTextures[pCommand->m_Slot].m_Tex, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(m_aTextures[pCommand->m_Slot].m_Tex, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glSamplerParameteri(m_aTextures[pCommand->m_Slot].m_Sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glSamplerParameteri(m_aTextures[pCommand->m_Slot].m_Sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, StoreOglformat, Width, Height, 0, Oglformat, GL_UNSIGNED_BYTE, pTexData);
@ -929,8 +946,12 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Create(const CCommandBuffe
void CCommandProcessorFragment_OpenGL3_3::Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand)
{
glClearColor(pCommand->m_Color.r, pCommand->m_Color.g, pCommand->m_Color.b, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(pCommand->m_Color.r != m_ClearColor.r || pCommand->m_Color.g != m_ClearColor.g || pCommand->m_Color.b != m_ClearColor.b)
{
glClearColor(pCommand->m_Color.r, pCommand->m_Color.g, pCommand->m_Color.b, 0.0f);
m_ClearColor = pCommand->m_Color;
}
glClear(GL_COLOR_BUFFER_BIT);
}
void CCommandProcessorFragment_OpenGL3_3::Cmd_Render(const CCommandBuffer::SCommand_Render *pCommand)
@ -950,14 +971,22 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Render(const CCommandBuffer::SComm
default:
return;
};
glBindBuffer(GL_ARRAY_BUFFER, m_PrimitiveDrawBufferID);
glBufferData(GL_ARRAY_BUFFER, sizeof(CCommandBuffer::SVertex) * Count, (char*)pCommand->m_pVertices, GL_STREAM_DRAW);
if(!m_UsePreinitializedVertexBuffer)
glBufferData(GL_ARRAY_BUFFER, sizeof(CCommandBuffer::SVertex) * Count, (char*)pCommand->m_pVertices, GL_STREAM_DRAW);
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);
mem_copy(pData, pCommand->m_pVertices, sizeof(CCommandBuffer::SVertex) * Count);
glUnmapBuffer(GL_ARRAY_BUFFER);
}
glBindVertexArray(m_PrimitiveDrawVertexID);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(CCommandBuffer::SVertex), 0);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(CCommandBuffer::SVertex), (void*)(sizeof(float) * 2));
glVertexAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(CCommandBuffer::SVertex), (void*)(sizeof(float) * 4));
switch(pCommand->m_PrimType)
{
@ -966,7 +995,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Render(const CCommandBuffer::SComm
glDrawArrays(GL_LINES, 0, pCommand->m_PrimCount*2);
break;
case CCommandBuffer::PRIMTYPE_QUADS:
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_PrimitiveDrawIndexBufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID);
glDrawElements(GL_TRIANGLES, pCommand->m_PrimCount*6, GL_UNSIGNED_INT, 0);
break;
default:
@ -1031,8 +1060,6 @@ bool CCommandProcessorFragment_OpenGL3_3::RunCommand(const CCommandBuffer::SComm
case CCommandBuffer::CMD_CREATE_VERTEX_BUFFER_OBJECT: Cmd_CreateVertBuffer(static_cast<const CCommandBuffer::SCommand_CreateVertexBufferObject *>(pBaseCommand)); break;
case CCommandBuffer::CMD_APPEND_VERTEX_BUFFER_OBJECT: Cmd_AppendVertBuffer(static_cast<const CCommandBuffer::SCommand_AppendVertexBufferObject *>(pBaseCommand)); break;
case CCommandBuffer::CMD_CREATE_VERTEX_ARRAY_OBJECT: Cmd_CreateVertArray(static_cast<const CCommandBuffer::SCommand_CreateVertexArrayObject *>(pBaseCommand)); break;
case CCommandBuffer::CMD_CREATE_INDEX_BUFFER_OBJECT: Cmd_CreateIndexBuffer(static_cast<const CCommandBuffer::SCommand_CreateIndexBufferObject *>(pBaseCommand)); break;
case CCommandBuffer::CMD_APPEND_INDEX_BUFFER_OBJECT: Cmd_AppendIndexBuffer(static_cast<const CCommandBuffer::SCommand_AppendIndexBufferObject *>(pBaseCommand)); break;
case CCommandBuffer::CMD_RENDER_IBO_VERTEX_ARRAY: Cmd_RenderVertexArray(static_cast<const CCommandBuffer::SCommand_RenderVertexArray *>(pBaseCommand)); break;
case CCommandBuffer::CMD_DESTROY_VISUAL: Cmd_DestroyVertexArray(static_cast<const CCommandBuffer::SCommand_DestroyVisual *>(pBaseCommand)); break;
case CCommandBuffer::CMD_RENDER_BORDER_TILE: Cmd_RenderBorderTile(static_cast<const CCommandBuffer::SCommand_RenderBorderTile *>(pBaseCommand)); break;
@ -1069,14 +1096,49 @@ void CCommandProcessorFragment_OpenGL3_3::DestroyVisualObjects(int Index)
SVisualObject& VisualObject = m_VisualObjects[Index];
if(VisualObject.m_VertArrayID != 0) glDeleteVertexArrays(1, &VisualObject.m_VertArrayID);
if(VisualObject.m_VertBufferID != 0) glDeleteBuffers(1, &VisualObject.m_VertBufferID);//this line should never be called
if(VisualObject.m_IndexBufferID != 0) glDeleteBuffers(1, &VisualObject.m_IndexBufferID);
VisualObject.m_NumElements = 0;
VisualObject.m_IsTextured = false;
VisualObject.m_NumIndices = 0;
VisualObject.m_IndexBufferID = VisualObject.m_VertBufferID = VisualObject.m_VertArrayID = 0;
VisualObject.m_VertBufferID = VisualObject.m_VertArrayID = 0;
}
void CCommandProcessorFragment_OpenGL3_3::AppendIndices(unsigned int NewIndicesCount)
{
if(NewIndicesCount <= m_CurrentIndicesInBuffer) return;
unsigned int AddCount = NewIndicesCount - m_CurrentIndicesInBuffer;
unsigned int* Indices = new unsigned int[AddCount];
int Primq = (m_CurrentIndicesInBuffer/6) * 4;
for(int i = 0; i < AddCount; i+=6)
{
Indices[i] = Primq;
Indices[i+1] = Primq + 1;
Indices[i+2] = Primq + 2;
Indices[i+3] = Primq;
Indices[i+4] = Primq + 2;
Indices[i+5] = Primq + 3;
Primq+=4;
}
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_COPY_READ_BUFFER, m_QuadDrawIndexBufferID);
GLuint NewIndexBufferID;
glGenBuffers(1, &NewIndexBufferID);
glBindBuffer(GL_COPY_WRITE_BUFFER, NewIndexBufferID);
GLsizeiptr size = sizeof(unsigned int);
glBufferData(GL_COPY_WRITE_BUFFER, (GLsizeiptr)NewIndicesCount * size, NULL, GL_STATIC_DRAW);
glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, (GLsizeiptr)m_CurrentIndicesInBuffer * size);
glBufferSubData(GL_COPY_WRITE_BUFFER, (GLsizeiptr)m_CurrentIndicesInBuffer * size, (GLsizeiptr)AddCount * size, Indices);
glBindBuffer(GL_COPY_WRITE_BUFFER, 0);
glBindBuffer(GL_COPY_READ_BUFFER, 0);
glDeleteBuffers(1, &m_QuadDrawIndexBufferID);
m_QuadDrawIndexBufferID = NewIndexBufferID;
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID);
m_CurrentIndicesInBuffer = NewIndicesCount;
delete[] Indices;
}
void CCommandProcessorFragment_OpenGL3_3::Cmd_DestroyVertexArray(const CCommandBuffer::SCommand_DestroyVisual *pCommand)
{
int Index = pCommand->m_VisualObjectIDX;
@ -1094,7 +1156,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTile(const CCommandBuf
return;
SVisualObject& VisualObject = m_VisualObjects[Index];
if(VisualObject.m_VertArrayID == 0 || VisualObject.m_IndexBufferID == 0) return;
if(VisualObject.m_VertArrayID == 0) return;
CGLSLBorderTileProgram* pProgram = NULL;
if(VisualObject.m_IsTextured)
@ -1113,8 +1175,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTile(const CCommandBuf
pProgram->SetUniform(pProgram->m_LocJumpIndex, (int)pCommand->m_JumpIndex);
glBindVertexArray(VisualObject.m_VertArrayID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VisualObject.m_IndexBufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID);
glDrawElementsInstanced(GL_TRIANGLES, 6, GL_UNSIGNED_INT, pCommand->m_pIndicesOffset, pCommand->m_DrawNum);
}
@ -1126,7 +1187,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTileLine(const CComman
return;
SVisualObject& VisualObject = m_VisualObjects[Index];
if(VisualObject.m_VertArrayID == 0 || VisualObject.m_IndexBufferID == 0) return;
if(VisualObject.m_VertArrayID == 0) return;
CGLSLBorderTileLineProgram* pProgram = NULL;
if(VisualObject.m_IsTextured)
@ -1142,8 +1203,7 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderBorderTileLine(const CComman
pProgram->SetUniformVec2(pProgram->m_LocDir, 1, (float*)&pCommand->m_Dir);
glBindVertexArray(VisualObject.m_VertArrayID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VisualObject.m_IndexBufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID);
glDrawElementsInstanced(GL_TRIANGLES, pCommand->m_IndexDrawNum, GL_UNSIGNED_INT, pCommand->m_pIndicesOffset, pCommand->m_DrawNum);
}
@ -1155,21 +1215,10 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderVertexArray(const CCommandBu
return;
SVisualObject& VisualObject = m_VisualObjects[Index];
if(VisualObject.m_VertArrayID == 0 || VisualObject.m_IndexBufferID == 0) return;
if(VisualObject.m_VertArrayID == 0) return;
GLsizei* DrawCount = new GLsizei[pCommand->m_IndicesDrawNum];
GLvoid** Offsets = new GLvoid*[pCommand->m_IndicesDrawNum];
int c = 0;
for (int i = 0; i < pCommand->m_IndicesDrawNum; ++i)
if (pCommand->m_IndicesDrawNum == 0)
{
if (pCommand->m_pIndicesOffsets[i].m_DrawCount == 0) continue;
DrawCount[c] = pCommand->m_pIndicesOffsets[i].m_DrawCount;
Offsets[c++] = pCommand->m_pIndicesOffsets[i].m_Offset;
}
if (c == 0)
{
delete[] DrawCount;
delete[] Offsets;
return; //nothing to draw
}
@ -1187,17 +1236,13 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_RenderVertexArray(const CCommandBu
pProgram->SetUniformVec4(pProgram->m_LocColor, 1, (float*)&pCommand->m_Color);
glBindVertexArray(VisualObject.m_VertArrayID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VisualObject.m_IndexBufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_QuadDrawIndexBufferID);
//for some reasons this function seems not to be in the coreprofile for quite some gpus
//glMultiDrawElements(GL_TRIANGLES, DrawCount, GL_UNSIGNED_INT, Offsets, c);
for (int i = 0; i < c; ++i)
//glMultiDrawElements(GL_TRIANGLES, pCommand->m_pDrawCount, GL_UNSIGNED_INT, pCommand->m_pIndicesOffsets, pCommand->m_IndicesDrawNum);
for (int i = 0; i < pCommand->m_IndicesDrawNum; ++i)
{
glDrawElements(GL_TRIANGLES, DrawCount[i], GL_UNSIGNED_INT, Offsets[i]);
glDrawElements(GL_TRIANGLES, pCommand->m_pDrawCount[i], GL_UNSIGNED_INT, pCommand->m_pIndicesOffsets[i]);
}
delete[] DrawCount;
delete[] Offsets;
}
void CCommandProcessorFragment_OpenGL3_3::Cmd_CreateVertBuffer(const CCommandBuffer::SCommand_CreateVertexBufferObject *pCommand)
@ -1260,6 +1305,9 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_CreateVertArray(const CCommandBuff
if(Index >= m_VisualObjects.size())
return;
if(pCommand->m_RequiredIndicesCount > m_CurrentIndicesInBuffer)
AppendIndices(pCommand->m_RequiredIndicesCount);
SVisualObject& VisualObject = m_VisualObjects[Index];
glGenVertexArrays(1, &VisualObject.m_VertArrayID);
@ -1289,52 +1337,6 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_CreateVertArray(const CCommandBuff
VisualObject.m_VertBufferID = 0;
}
void CCommandProcessorFragment_OpenGL3_3::Cmd_CreateIndexBuffer(const CCommandBuffer::SCommand_CreateIndexBufferObject *pCommand)
{
int Index = pCommand->m_VisualObjectIDX;
//if space not there return
if(Index >= m_VisualObjects.size())
{
return;
}
SVisualObject& VisualObject = m_VisualObjects[Index];
VisualObject.m_NumIndices = pCommand->m_NumIndices;
glGenBuffers(1, &VisualObject.m_IndexBufferID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VisualObject.m_IndexBufferID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)(VisualObject.m_NumIndices * sizeof(unsigned int)), pCommand->m_Indices, GL_STATIC_DRAW);
}
void CCommandProcessorFragment_OpenGL3_3::Cmd_AppendIndexBuffer(const CCommandBuffer::SCommand_AppendIndexBufferObject *pCommand)
{
int Index = pCommand->m_VisualObjectIDX;
//if space not there return
if(Index >= m_VisualObjects.size())
{
return;
}
SVisualObject& VisualObject = m_VisualObjects[Index];
glBindBuffer(GL_COPY_READ_BUFFER, VisualObject.m_IndexBufferID);
GLuint NewIndexBufferID;
glGenBuffers(1, &NewIndexBufferID);
glBindBuffer(GL_COPY_WRITE_BUFFER, NewIndexBufferID);
glBufferData(GL_COPY_WRITE_BUFFER, (GLsizeiptr)((VisualObject.m_NumIndices + pCommand->m_NumIndices) * sizeof(unsigned int)), NULL, GL_STATIC_DRAW);
glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0, (GLsizeiptr)(VisualObject.m_NumIndices * sizeof(unsigned int)));
glBufferSubData(GL_COPY_WRITE_BUFFER, (GLsizeiptr)(VisualObject.m_NumIndices * sizeof(unsigned int)), (GLsizeiptr)(pCommand->m_NumIndices * sizeof(unsigned int)), pCommand->m_Indices);
glBindBuffer(GL_COPY_WRITE_BUFFER, 0);
glBindBuffer(GL_COPY_READ_BUFFER, 0);
glDeleteBuffers(1, &VisualObject.m_IndexBufferID);
VisualObject.m_IndexBufferID = NewIndexBufferID;
VisualObject.m_NumIndices += pCommand->m_NumIndices;
}
// ------------ CCommandProcessorFragment_SDL
void CCommandProcessorFragment_SDL::Cmd_Init(const SCommand_Init *pCommand)
@ -1482,21 +1484,64 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
#endif
}
SDL_ClearError();
const char* pErr = NULL;
//query default values, since they are platform dependend
static bool s_InitDefaultParams = false;
static int s_SDLGLContextProfileMask, s_SDLGLContextMajorVersion, s_SDLGLContextMinorVersion;
if(!s_InitDefaultParams)
{
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &s_SDLGLContextProfileMask);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &s_SDLGLContextMajorVersion);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &s_SDLGLContextMinorVersion);
s_InitDefaultParams = true;
}
m_UseOpenGL3_3 = false;
if (!g_Config.m_GfxForceOldOpenGL && SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE) == 0)
{
if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) == 0 && SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3) == 0)
pErr = SDL_GetError();
if(pErr[0] != '\0')
{
m_UseOpenGL3_3 = true;
int vMaj, vMin;
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &vMaj);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &vMin);
dbg_msg("gfx", "Using OpenGL version %d.%d.", vMaj, vMin);
dbg_msg("gfx", "Using old OpenGL context, because an error occurred while trying to use OpenGL context 3.3: %s.", pErr);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, s_SDLGLContextProfileMask);
}
else {
dbg_msg("gfx", "Couldn't create OpenGL 3.3 context.");
else
{
if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3) == 0 && SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3) == 0)
{
pErr = SDL_GetError();
if(pErr[0] != '\0')
{
dbg_msg("gfx", "Using old OpenGL context, because an error occurred while trying to use OpenGL context 3.3: %s.", pErr);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, s_SDLGLContextMajorVersion);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, s_SDLGLContextMinorVersion);
}
else
{
m_UseOpenGL3_3 = true;
int vMaj, vMin;
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, &vMaj);
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &vMin);
dbg_msg("gfx", "Using OpenGL version %d.%d.", vMaj, vMin);
}
}
else
{
dbg_msg("gfx", "Couldn't create OpenGL 3.3 context.");
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, s_SDLGLContextMajorVersion);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, s_SDLGLContextMinorVersion);
}
}
}
else
{
//set default attributes
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, s_SDLGLContextProfileMask);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, s_SDLGLContextMajorVersion);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, s_SDLGLContextMinorVersion);
}
// set screen
SDL_Rect ScreenPos;

View file

@ -117,7 +117,6 @@ public:
bool RunCommand(const CCommandBuffer::SCommand * pBaseCommand);
};
class CGLSLProgram;
class CGLSLTWProgram;
class CGLSLPrimitiveProgram;
@ -129,6 +128,7 @@ class CGLSLBorderTileLineProgram;
class CCommandProcessorFragment_OpenGL3_3
{
bool m_UseMultipleTextureUnits;
bool m_UsePreinitializedVertexBuffer;
struct CTexture
{
@ -150,7 +150,9 @@ class CCommandProcessorFragment_OpenGL3_3
GLuint m_PrimitiveDrawVertexID;
GLuint m_PrimitiveDrawBufferID;
GLuint m_PrimitiveDrawIndexBufferID;
GLuint m_QuadDrawIndexBufferID;
unsigned int m_CurrentIndicesInBuffer;
GLint m_MaxTextureUnits;
@ -167,17 +169,18 @@ class CCommandProcessorFragment_OpenGL3_3
void DestroyTexture(int Slot);
void DestroyVisualObjects(int Index);
void AppendIndices(unsigned int NewIndicesCount);
struct SVisualObject{
SVisualObject() : m_VertArrayID(0), m_VertBufferID(0), m_NumElements(0), m_IsTextured(false), m_IndexBufferID(0), m_NumIndices(0) {}
SVisualObject() : m_VertArrayID(0), m_VertBufferID(0), m_NumElements(0), m_IsTextured(false) {}
GLuint m_VertArrayID;
GLuint m_VertBufferID;
int m_NumElements; //vertices and texture coordinates
bool m_IsTextured;
GLuint m_IndexBufferID;
int m_NumIndices;
};
std::vector<SVisualObject> m_VisualObjects;
CCommandBuffer::SColorf m_ClearColor;
public:
enum
{
@ -215,8 +218,6 @@ private:
void Cmd_CreateVertBuffer(const CCommandBuffer::SCommand_CreateVertexBufferObject *pCommand);
void Cmd_AppendVertBuffer(const CCommandBuffer::SCommand_AppendVertexBufferObject *pCommand);
void Cmd_CreateVertArray(const CCommandBuffer::SCommand_CreateVertexArrayObject *pCommand);
void Cmd_CreateIndexBuffer(const CCommandBuffer::SCommand_CreateIndexBufferObject *pCommand);
void Cmd_AppendIndexBuffer(const CCommandBuffer::SCommand_AppendIndexBufferObject *pCommand);
void Cmd_RenderVertexArray(const CCommandBuffer::SCommand_RenderVertexArray *pCommand);
void Cmd_DestroyVertexArray(const CCommandBuffer::SCommand_DestroyVisual *pCommand);

View file

@ -50,6 +50,10 @@ void CGraphics_Threaded::FlushVertices()
{
if(m_NumVertices == 0)
return;
size_t VertSize = 0;
if(!m_UseOpenGL3_3) VertSize = sizeof(CCommandBuffer::SVertexOld);
else VertSize = sizeof(CCommandBuffer::SVertex);
int NumVerts = m_NumVertices;
m_NumVertices = 0;
@ -78,13 +82,13 @@ void CGraphics_Threaded::FlushVertices()
else
return;
Cmd.m_pVertices = (CCommandBuffer::SVertex *)m_pCommandBuffer->AllocData(sizeof(CCommandBuffer::SVertex)*NumVerts);
Cmd.m_pVertices = (CCommandBuffer::SVertexBase *)m_pCommandBuffer->AllocData(VertSize*NumVerts);
if(Cmd.m_pVertices == 0x0)
{
// kick command buffer and try again
KickCommandBuffer();
Cmd.m_pVertices = (CCommandBuffer::SVertex *)m_pCommandBuffer->AllocData(sizeof(CCommandBuffer::SVertex)*NumVerts);
Cmd.m_pVertices = (CCommandBuffer::SVertexBase *)m_pCommandBuffer->AllocData(VertSize*NumVerts);
if(Cmd.m_pVertices == 0x0)
{
dbg_msg("graphics", "failed to allocate data for vertices");
@ -98,7 +102,7 @@ void CGraphics_Threaded::FlushVertices()
// kick command buffer and try again
KickCommandBuffer();
Cmd.m_pVertices = (CCommandBuffer::SVertex *)m_pCommandBuffer->AllocData(sizeof(CCommandBuffer::SVertex)*NumVerts);
Cmd.m_pVertices = (CCommandBuffer::SVertexBase *)m_pCommandBuffer->AllocData(VertSize*NumVerts);
if(Cmd.m_pVertices == 0x0)
{
dbg_msg("graphics", "failed to allocate data for vertices");
@ -112,7 +116,7 @@ void CGraphics_Threaded::FlushVertices()
}
}
mem_copy(Cmd.m_pVertices, m_aVertices, sizeof(CCommandBuffer::SVertex)*NumVerts);
mem_copy(Cmd.m_pVertices, m_pVertices, VertSize*NumVerts);
}
void CGraphics_Threaded::AddVertices(int Count)
@ -122,19 +126,35 @@ void CGraphics_Threaded::AddVertices(int Count)
FlushVertices();
}
void CGraphics_Threaded::Rotate(const CCommandBuffer::SPoint &rCenter, CCommandBuffer::SVertex *pPoints, int NumPoints)
void CGraphics_Threaded::Rotate(const CCommandBuffer::SPoint &rCenter, CCommandBuffer::SVertexBase *pPoints, int NumPoints)
{
float c = cosf(m_Rotation);
float s = sinf(m_Rotation);
float x, y;
int i;
for(i = 0; i < NumPoints; i++)
if(m_UseOpenGL3_3)
{
x = pPoints[i].m_Pos.x - rCenter.x;
y = pPoints[i].m_Pos.y - rCenter.y;
pPoints[i].m_Pos.x = x * c - y * s + rCenter.x;
pPoints[i].m_Pos.y = x * s + y * c + rCenter.y;
CCommandBuffer::SVertex* pVertices = (CCommandBuffer::SVertex*) pPoints;
for(i = 0; i < NumPoints; i++)
{
x = pVertices[i].m_Pos.x - rCenter.x;
y = pVertices[i].m_Pos.y - rCenter.y;
pVertices[i].m_Pos.x = x * c - y * s + rCenter.x;
pVertices[i].m_Pos.y = x * s + y * c + rCenter.y;
}
}
else
{
CCommandBuffer::SVertexOld* pVertices = (CCommandBuffer::SVertexOld*) pPoints;
for(i = 0; i < NumPoints; i++)
{
x = pVertices[i].m_Pos.x - rCenter.x;
y = pVertices[i].m_Pos.y - rCenter.y;
pVertices[i].m_Pos.x = x * c - y * s + rCenter.x;
pVertices[i].m_Pos.y = x * s + y * c + rCenter.y;
}
}
}
@ -263,15 +283,15 @@ void CGraphics_Threaded::LinesDraw(const CLineItem *pArray, int Num)
for(int i = 0; i < Num; ++i)
{
m_aVertices[m_NumVertices + 2*i].m_Pos.x = pArray[i].m_X0;
m_aVertices[m_NumVertices + 2*i].m_Pos.y = pArray[i].m_Y0;
m_aVertices[m_NumVertices + 2*i].m_Tex = m_aTexture[0];
m_aVertices[m_NumVertices + 2*i].m_Color = m_aColor[0];
GetVertex(m_NumVertices + 2*i)->m_Pos.x = pArray[i].m_X0;
GetVertex(m_NumVertices + 2*i)->m_Pos.y = pArray[i].m_Y0;
GetVertex(m_NumVertices + 2*i)->m_Tex = m_aTexture[0];
SetColor(GetVertex(m_NumVertices + 2*i), 0);
m_aVertices[m_NumVertices + 2*i + 1].m_Pos.x = pArray[i].m_X1;
m_aVertices[m_NumVertices + 2*i + 1].m_Pos.y = pArray[i].m_Y1;
m_aVertices[m_NumVertices + 2*i + 1].m_Tex = m_aTexture[1];
m_aVertices[m_NumVertices + 2*i + 1].m_Color = m_aColor[1];
GetVertex(m_NumVertices + 2*i + 1)->m_Pos.x = pArray[i].m_X1;
GetVertex(m_NumVertices + 2*i + 1)->m_Pos.y = pArray[i].m_Y1;
GetVertex(m_NumVertices + 2*i + 1)->m_Tex = m_aTexture[1];
SetColor(GetVertex(m_NumVertices + 2*i + 1), 1);
}
AddVertices(2*Num);
@ -545,16 +565,36 @@ void CGraphics_Threaded::QuadsSetRotation(float Angle)
m_Rotation = Angle;
}
inline void clampf(float& Value, float Min, float Max){
if(Value > Max) Value = Max;
else if(Value < Min) Value = Min;
}
void CGraphics_Threaded::SetColorVertex(const CColorVertex *pArray, int Num)
{
dbg_assert(m_Drawing != 0, "called Graphics()->SetColorVertex without begin");
for(int i = 0; i < Num; ++i)
{
m_aColor[pArray[i].m_Index].r = pArray[i].m_R;
m_aColor[pArray[i].m_Index].g = pArray[i].m_G;
m_aColor[pArray[i].m_Index].b = pArray[i].m_B;
m_aColor[pArray[i].m_Index].a = pArray[i].m_A;
if(m_UseOpenGL3_3)
{
float r = pArray[i].m_R, g = pArray[i].m_G, b = pArray[i].m_B, a = pArray[i].m_A;
clampf(r, 0.f, 1.f);
clampf(g, 0.f, 1.f);
clampf(b, 0.f, 1.f);
clampf(a, 0.f, 1.f);
m_aColor[pArray[i].m_Index].r = (unsigned char)(r*255.f);
m_aColor[pArray[i].m_Index].g = (unsigned char)(g*255.f);
m_aColor[pArray[i].m_Index].b = (unsigned char)(b*255.f);
m_aColor[pArray[i].m_Index].a = (unsigned char)(a*255.f);
}
else
{
m_aColorOld[pArray[i].m_Index].r = pArray[i].m_R;
m_aColorOld[pArray[i].m_Index].g = pArray[i].m_G;
m_aColorOld[pArray[i].m_Index].b = pArray[i].m_B;
m_aColorOld[pArray[i].m_Index].a = pArray[i].m_A;
}
}
}
@ -569,6 +609,34 @@ void CGraphics_Threaded::SetColor(float r, float g, float b, float a)
SetColorVertex(Array, 4);
}
void CGraphics_Threaded::SetColor(CCommandBuffer::SVertexBase* pVertex, int ColorIndex)
{
if(m_UseOpenGL3_3)
{
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;
pVert->m_Color.a = m_aColor[ColorIndex].a;
}
else
{
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;
pVert->m_Color.a = m_aColorOld[ColorIndex].a;
}
}
CCommandBuffer::SVertexBase* CGraphics_Threaded::GetVertex(int Index)
{
if(!m_UseOpenGL3_3)
return &((CCommandBuffer::SVertexOld*)m_pVertices)[Index];
else
return &((CCommandBuffer::SVertex*)m_pVertices)[Index];
}
void CGraphics_Threaded::QuadsSetSubset(float TlU, float TlV, float BrU, float BrV)
{
dbg_assert(m_Drawing == DRAWING_QUADS, "called Graphics()->QuadsSetSubset without begin");
@ -612,43 +680,43 @@ void CGraphics_Threaded::QuadsDrawTL(const CQuadItem *pArray, int Num)
for(int i = 0; i < Num; ++i)
{
// first triangle
m_aVertices[m_NumVertices + 6*i].m_Pos.x = pArray[i].m_X;
m_aVertices[m_NumVertices + 6*i].m_Pos.y = pArray[i].m_Y;
m_aVertices[m_NumVertices + 6*i].m_Tex = m_aTexture[0];
m_aVertices[m_NumVertices + 6*i].m_Color = m_aColor[0];
GetVertex(m_NumVertices + 6*i)->m_Pos.x = pArray[i].m_X;
GetVertex(m_NumVertices + 6*i)->m_Pos.y = pArray[i].m_Y;
GetVertex(m_NumVertices + 6*i)->m_Tex = m_aTexture[0];
SetColor(GetVertex(m_NumVertices + 6*i), 0);
m_aVertices[m_NumVertices + 6*i + 1].m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
m_aVertices[m_NumVertices + 6*i + 1].m_Pos.y = pArray[i].m_Y;
m_aVertices[m_NumVertices + 6*i + 1].m_Tex = m_aTexture[1];
m_aVertices[m_NumVertices + 6*i + 1].m_Color = m_aColor[1];
GetVertex(m_NumVertices + 6*i + 1)->m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
GetVertex(m_NumVertices + 6*i + 1)->m_Pos.y = pArray[i].m_Y;
GetVertex(m_NumVertices + 6*i + 1)->m_Tex = m_aTexture[1];
SetColor(GetVertex(m_NumVertices + 6*i + 1), 1);
m_aVertices[m_NumVertices + 6*i + 2].m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
m_aVertices[m_NumVertices + 6*i + 2].m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
m_aVertices[m_NumVertices + 6*i + 2].m_Tex = m_aTexture[2];
m_aVertices[m_NumVertices + 6*i + 2].m_Color = m_aColor[2];
GetVertex(m_NumVertices + 6*i + 2)->m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
GetVertex(m_NumVertices + 6*i + 2)->m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
GetVertex(m_NumVertices + 6*i + 2)->m_Tex = m_aTexture[2];
SetColor(GetVertex(m_NumVertices + 6*i + 2), 2);
// second triangle
m_aVertices[m_NumVertices + 6*i + 3].m_Pos.x = pArray[i].m_X;
m_aVertices[m_NumVertices + 6*i + 3].m_Pos.y = pArray[i].m_Y;
m_aVertices[m_NumVertices + 6*i + 3].m_Tex = m_aTexture[0];
m_aVertices[m_NumVertices + 6*i + 3].m_Color = m_aColor[0];
GetVertex(m_NumVertices + 6*i + 3)->m_Pos.x = pArray[i].m_X;
GetVertex(m_NumVertices + 6*i + 3)->m_Pos.y = pArray[i].m_Y;
GetVertex(m_NumVertices + 6*i + 3)->m_Tex = m_aTexture[0];
SetColor(GetVertex(m_NumVertices + 6*i + 3), 0);
m_aVertices[m_NumVertices + 6*i + 4].m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
m_aVertices[m_NumVertices + 6*i + 4].m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
m_aVertices[m_NumVertices + 6*i + 4].m_Tex = m_aTexture[2];
m_aVertices[m_NumVertices + 6*i + 4].m_Color = m_aColor[2];
GetVertex(m_NumVertices + 6*i + 4)->m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
GetVertex(m_NumVertices + 6*i + 4)->m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
GetVertex(m_NumVertices + 6*i + 4)->m_Tex = m_aTexture[2];
SetColor(GetVertex(m_NumVertices + 6*i + 4), 2);
m_aVertices[m_NumVertices + 6*i + 5].m_Pos.x = pArray[i].m_X;
m_aVertices[m_NumVertices + 6*i + 5].m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
m_aVertices[m_NumVertices + 6*i + 5].m_Tex = m_aTexture[3];
m_aVertices[m_NumVertices + 6*i + 5].m_Color = m_aColor[3];
GetVertex(m_NumVertices + 6*i + 5)->m_Pos.x = pArray[i].m_X;
GetVertex(m_NumVertices + 6*i + 5)->m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
GetVertex(m_NumVertices + 6*i + 5)->m_Tex = m_aTexture[3];
SetColor(GetVertex(m_NumVertices + 6*i + 5), 3);
if(m_Rotation != 0)
{
Center.x = pArray[i].m_X + pArray[i].m_Width/2;
Center.y = pArray[i].m_Y + pArray[i].m_Height/2;
Rotate(Center, &m_aVertices[m_NumVertices + 6*i], 6);
Rotate(Center, GetVertex(m_NumVertices + 6*i), 6);
}
}
@ -658,32 +726,32 @@ void CGraphics_Threaded::QuadsDrawTL(const CQuadItem *pArray, int Num)
{
for(int i = 0; i < Num; ++i)
{
m_aVertices[m_NumVertices + 4*i].m_Pos.x = pArray[i].m_X;
m_aVertices[m_NumVertices + 4*i].m_Pos.y = pArray[i].m_Y;
m_aVertices[m_NumVertices + 4*i].m_Tex = m_aTexture[0];
m_aVertices[m_NumVertices + 4*i].m_Color = m_aColor[0];
GetVertex(m_NumVertices + 4*i)->m_Pos.x = pArray[i].m_X;
GetVertex(m_NumVertices + 4*i)->m_Pos.y = pArray[i].m_Y;
GetVertex(m_NumVertices + 4*i)->m_Tex = m_aTexture[0];
SetColor(GetVertex(m_NumVertices + 4*i), 0);
m_aVertices[m_NumVertices + 4*i + 1].m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
m_aVertices[m_NumVertices + 4*i + 1].m_Pos.y = pArray[i].m_Y;
m_aVertices[m_NumVertices + 4*i + 1].m_Tex = m_aTexture[1];
m_aVertices[m_NumVertices + 4*i + 1].m_Color = m_aColor[1];
GetVertex(m_NumVertices + 4*i + 1)->m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
GetVertex(m_NumVertices + 4*i + 1)->m_Pos.y = pArray[i].m_Y;
GetVertex(m_NumVertices + 4*i + 1)->m_Tex = m_aTexture[1];
SetColor(GetVertex(m_NumVertices + 4*i + 1), 1);
m_aVertices[m_NumVertices + 4*i + 2].m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
m_aVertices[m_NumVertices + 4*i + 2].m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
m_aVertices[m_NumVertices + 4*i + 2].m_Tex = m_aTexture[2];
m_aVertices[m_NumVertices + 4*i + 2].m_Color = m_aColor[2];
GetVertex(m_NumVertices + 4*i + 2)->m_Pos.x = pArray[i].m_X + pArray[i].m_Width;
GetVertex(m_NumVertices + 4*i + 2)->m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
GetVertex(m_NumVertices + 4*i + 2)->m_Tex = m_aTexture[2];
SetColor(GetVertex(m_NumVertices + 4*i + 2), 2);
m_aVertices[m_NumVertices + 4*i + 3].m_Pos.x = pArray[i].m_X;
m_aVertices[m_NumVertices + 4*i + 3].m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
m_aVertices[m_NumVertices + 4*i + 3].m_Tex = m_aTexture[3];
m_aVertices[m_NumVertices + 4*i + 3].m_Color = m_aColor[3];
GetVertex(m_NumVertices + 4*i + 3)->m_Pos.x = pArray[i].m_X;
GetVertex(m_NumVertices + 4*i + 3)->m_Pos.y = pArray[i].m_Y + pArray[i].m_Height;
GetVertex(m_NumVertices + 4*i + 3)->m_Tex = m_aTexture[3];
SetColor(GetVertex(m_NumVertices + 4*i + 3), 3);
if(m_Rotation != 0)
{
Center.x = pArray[i].m_X + pArray[i].m_Width/2;
Center.y = pArray[i].m_Y + pArray[i].m_Height/2;
Rotate(Center, &m_aVertices[m_NumVertices + 4*i], 4);
Rotate(Center, GetVertex(m_NumVertices + 4*i), 4);
}
}
@ -699,35 +767,35 @@ void CGraphics_Threaded::QuadsDrawFreeform(const CFreeformItem *pArray, int Num)
{
for(int i = 0; i < Num; ++i)
{
m_aVertices[m_NumVertices + 6*i].m_Pos.x = pArray[i].m_X0;
m_aVertices[m_NumVertices + 6*i].m_Pos.y = pArray[i].m_Y0;
m_aVertices[m_NumVertices + 6*i].m_Tex = m_aTexture[0];
m_aVertices[m_NumVertices + 6*i].m_Color = m_aColor[0];
GetVertex(m_NumVertices + 6*i)->m_Pos.x = pArray[i].m_X0;
GetVertex(m_NumVertices + 6*i)->m_Pos.y = pArray[i].m_Y0;
GetVertex(m_NumVertices + 6*i)->m_Tex = m_aTexture[0];
SetColor(GetVertex(m_NumVertices + 6*i), 0);
m_aVertices[m_NumVertices + 6*i + 1].m_Pos.x = pArray[i].m_X1;
m_aVertices[m_NumVertices + 6*i + 1].m_Pos.y = pArray[i].m_Y1;
m_aVertices[m_NumVertices + 6*i + 1].m_Tex = m_aTexture[1];
m_aVertices[m_NumVertices + 6*i + 1].m_Color = m_aColor[1];
GetVertex(m_NumVertices + 6*i + 1)->m_Pos.x = pArray[i].m_X1;
GetVertex(m_NumVertices + 6*i + 1)->m_Pos.y = pArray[i].m_Y1;
GetVertex(m_NumVertices + 6*i + 1)->m_Tex = m_aTexture[1];
SetColor(GetVertex(m_NumVertices + 6*i + 1), 1);
m_aVertices[m_NumVertices + 6*i + 2].m_Pos.x = pArray[i].m_X3;
m_aVertices[m_NumVertices + 6*i + 2].m_Pos.y = pArray[i].m_Y3;
m_aVertices[m_NumVertices + 6*i + 2].m_Tex = m_aTexture[3];
m_aVertices[m_NumVertices + 6*i + 2].m_Color = m_aColor[3];
GetVertex(m_NumVertices + 6*i + 2)->m_Pos.x = pArray[i].m_X3;
GetVertex(m_NumVertices + 6*i + 2)->m_Pos.y = pArray[i].m_Y3;
GetVertex(m_NumVertices + 6*i + 2)->m_Tex = m_aTexture[3];
SetColor(GetVertex(m_NumVertices + 6*i + 2), 3);
m_aVertices[m_NumVertices + 6*i + 3].m_Pos.x = pArray[i].m_X0;
m_aVertices[m_NumVertices + 6*i + 3].m_Pos.y = pArray[i].m_Y0;
m_aVertices[m_NumVertices + 6*i + 3].m_Tex = m_aTexture[0];
m_aVertices[m_NumVertices + 6*i + 3].m_Color = m_aColor[0];
GetVertex(m_NumVertices + 6*i + 3)->m_Pos.x = pArray[i].m_X0;
GetVertex(m_NumVertices + 6*i + 3)->m_Pos.y = pArray[i].m_Y0;
GetVertex(m_NumVertices + 6*i + 3)->m_Tex = m_aTexture[0];
SetColor(GetVertex(m_NumVertices + 6*i + 3), 0);
m_aVertices[m_NumVertices + 6*i + 4].m_Pos.x = pArray[i].m_X3;
m_aVertices[m_NumVertices + 6*i + 4].m_Pos.y = pArray[i].m_Y3;
m_aVertices[m_NumVertices + 6*i + 4].m_Tex = m_aTexture[3];
m_aVertices[m_NumVertices + 6*i + 4].m_Color = m_aColor[3];
GetVertex(m_NumVertices + 6*i + 4)->m_Pos.x = pArray[i].m_X3;
GetVertex(m_NumVertices + 6*i + 4)->m_Pos.y = pArray[i].m_Y3;
GetVertex(m_NumVertices + 6*i + 4)->m_Tex = m_aTexture[3];
SetColor(GetVertex(m_NumVertices + 6*i + 4), 3);
m_aVertices[m_NumVertices + 6*i + 5].m_Pos.x = pArray[i].m_X2;
m_aVertices[m_NumVertices + 6*i + 5].m_Pos.y = pArray[i].m_Y2;
m_aVertices[m_NumVertices + 6*i + 5].m_Tex = m_aTexture[2];
m_aVertices[m_NumVertices + 6*i + 5].m_Color = m_aColor[2];
GetVertex(m_NumVertices + 6*i + 5)->m_Pos.x = pArray[i].m_X2;
GetVertex(m_NumVertices + 6*i + 5)->m_Pos.y = pArray[i].m_Y2;
GetVertex(m_NumVertices + 6*i + 5)->m_Tex = m_aTexture[2];
SetColor(GetVertex(m_NumVertices + 6*i + 5), 2);
}
AddVertices(3*2*Num);
@ -736,25 +804,25 @@ void CGraphics_Threaded::QuadsDrawFreeform(const CFreeformItem *pArray, int Num)
{
for(int i = 0; i < Num; ++i)
{
m_aVertices[m_NumVertices + 4*i].m_Pos.x = pArray[i].m_X0;
m_aVertices[m_NumVertices + 4*i].m_Pos.y = pArray[i].m_Y0;
m_aVertices[m_NumVertices + 4*i].m_Tex = m_aTexture[0];
m_aVertices[m_NumVertices + 4*i].m_Color = m_aColor[0];
GetVertex(m_NumVertices + 4*i)->m_Pos.x = pArray[i].m_X0;
GetVertex(m_NumVertices + 4*i)->m_Pos.y = pArray[i].m_Y0;
GetVertex(m_NumVertices + 4*i)->m_Tex = m_aTexture[0];
SetColor(GetVertex(m_NumVertices + 4*i), 0);
m_aVertices[m_NumVertices + 4*i + 1].m_Pos.x = pArray[i].m_X1;
m_aVertices[m_NumVertices + 4*i + 1].m_Pos.y = pArray[i].m_Y1;
m_aVertices[m_NumVertices + 4*i + 1].m_Tex = m_aTexture[1];
m_aVertices[m_NumVertices + 4*i + 1].m_Color = m_aColor[1];
GetVertex(m_NumVertices + 4*i + 1)->m_Pos.x = pArray[i].m_X1;
GetVertex(m_NumVertices + 4*i + 1)->m_Pos.y = pArray[i].m_Y1;
GetVertex(m_NumVertices + 4*i + 1)->m_Tex = m_aTexture[1];
SetColor(GetVertex(m_NumVertices + 4*i + 1), 1);
m_aVertices[m_NumVertices + 4*i + 2].m_Pos.x = pArray[i].m_X3;
m_aVertices[m_NumVertices + 4*i + 2].m_Pos.y = pArray[i].m_Y3;
m_aVertices[m_NumVertices + 4*i + 2].m_Tex = m_aTexture[3];
m_aVertices[m_NumVertices + 4*i + 2].m_Color = m_aColor[3];
GetVertex(m_NumVertices + 4*i + 2)->m_Pos.x = pArray[i].m_X3;
GetVertex(m_NumVertices + 4*i + 2)->m_Pos.y = pArray[i].m_Y3;
GetVertex(m_NumVertices + 4*i + 2)->m_Tex = m_aTexture[3];
SetColor(GetVertex(m_NumVertices + 4*i + 2), 3);
m_aVertices[m_NumVertices + 4*i + 3].m_Pos.x = pArray[i].m_X2;
m_aVertices[m_NumVertices + 4*i + 3].m_Pos.y = pArray[i].m_Y2;
m_aVertices[m_NumVertices + 4*i + 3].m_Tex = m_aTexture[2];
m_aVertices[m_NumVertices + 4*i + 3].m_Color = m_aColor[2];
GetVertex(m_NumVertices + 4*i + 3)->m_Pos.x = pArray[i].m_X2;
GetVertex(m_NumVertices + 4*i + 3)->m_Pos.y = pArray[i].m_Y2;
GetVertex(m_NumVertices + 4*i + 3)->m_Tex = m_aTexture[2];
SetColor(GetVertex(m_NumVertices + 4*i + 3), 2);
}
AddVertices(4*Num);
@ -812,32 +880,36 @@ void CGraphics_Threaded::DrawVisualObject(int VisualObjectIDX, float* pColor, ch
mem_copy(&Cmd.m_Color, pColor, sizeof(Cmd.m_Color));
Cmd.m_ZoomScreenRatio = (m_State.m_ScreenBR.x - m_State.m_ScreenTL.x) / ScreenWidth();
Cmd.m_pIndicesOffsets = (CCommandBuffer::SIndicesArray *)m_pCommandBuffer->AllocData(sizeof(CCommandBuffer::SIndicesArray)*NumIndicesOffet);
if(Cmd.m_pIndicesOffsets == 0x0)
void* Data = m_pCommandBuffer->AllocData((sizeof(char*) + sizeof(unsigned int))*NumIndicesOffet);
if(Data == 0x0)
{
// kick command buffer and try again
KickCommandBuffer();
Cmd.m_pIndicesOffsets = (CCommandBuffer::SIndicesArray *)m_pCommandBuffer->AllocData(sizeof(CCommandBuffer::SIndicesArray)*NumIndicesOffet);
if(Cmd.m_pIndicesOffsets == 0x0)
void* Data = m_pCommandBuffer->AllocData((sizeof(char*) + sizeof(unsigned int))*NumIndicesOffet);
if(Data == 0x0)
{
dbg_msg("graphics", "failed to allocate data for vertices");
return;
}
}
Cmd.m_pIndicesOffsets = (char**)Data;
Cmd.m_pDrawCount = (unsigned int*)(((char*)Data) + (sizeof(char*)*NumIndicesOffet));
// check if we have enough free memory in the commandbuffer
if(!m_pCommandBuffer->AddCommand(Cmd))
{
// kick command buffer and try again
KickCommandBuffer();
Cmd.m_pIndicesOffsets = (CCommandBuffer::SIndicesArray *)m_pCommandBuffer->AllocData(sizeof(CCommandBuffer::SIndicesArray)*NumIndicesOffet);
if(Cmd.m_pIndicesOffsets == 0x0)
Data = m_pCommandBuffer->AllocData((sizeof(char*) + sizeof(unsigned int))*NumIndicesOffet);
if(Data == 0x0)
{
dbg_msg("graphics", "failed to allocate data for vertices");
return;
}
Cmd.m_pIndicesOffsets = (char**)Data;
Cmd.m_pDrawCount = (unsigned int*)(((char*)Data) + (sizeof(char*)*NumIndicesOffet));
if(!m_pCommandBuffer->AddCommand(Cmd))
{
@ -846,14 +918,16 @@ void CGraphics_Threaded::DrawVisualObject(int VisualObjectIDX, float* pColor, ch
}
}
mem_copy_special(Cmd.m_pIndicesOffsets, pOffsets, sizeof(char*), NumIndicesOffet, sizeof(unsigned int));
mem_copy_special(((char*)Cmd.m_pIndicesOffsets) + sizeof(char*), IndicedVertexDrawNum, sizeof(unsigned int), NumIndicesOffet, sizeof(char*));
mem_copy(Cmd.m_pIndicesOffsets, pOffsets, sizeof(char*)*NumIndicesOffet);
mem_copy(Cmd.m_pDrawCount, IndicedVertexDrawNum, sizeof(unsigned int)*NumIndicesOffet);
//todo max indices group check!!
}
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
CCommandBuffer::SCommand_RenderBorderTile Cmd;
Cmd.m_State = m_State;
@ -939,9 +1013,9 @@ void CGraphics_Threaded::DestroyVisual(int VisualObjectIDX)
m_FirstFreeVertexArrayIndex = VisualObjectIDX;
}
int CGraphics_Threaded::CreateVisualObjects(float* pVertices, unsigned char* pTexCoords, int NumTiles, unsigned int* pIndices, unsigned int NumIndices)
int CGraphics_Threaded::CreateVisualObjects(float* pVertices, unsigned char* pTexCoords, int NumTiles, unsigned int NumIndicesRequired)
{
if(!pVertices || !pIndices) return -1;
if(!pVertices) return -1;
//first create an index
int index = -1;
@ -1017,61 +1091,10 @@ int CGraphics_Threaded::CreateVisualObjects(float* pVertices, unsigned char* pTe
if(pTexCoords) pTexCoords += NumVerts*2;
AppendAllVertices(pVertices, pTexCoords, NumTiles - MaxTileNumUpload, index);
}
//now upload the index buffer
unsigned int MaxIndices = (1024*1024*2) / (sizeof(unsigned int));
unsigned int RealNumIndices = NumIndices;
if(NumIndices > MaxIndices) RealNumIndices = MaxIndices;
CCommandBuffer::SCommand_CreateIndexBufferObject CmdIndex;
CmdIndex.m_VisualObjectIDX = index;
unsigned int NumIndicesUploaded = (CmdIndex.m_NumIndices = RealNumIndices); //number of indices to upload
CmdIndex.m_Indices = (unsigned int*)m_pCommandBuffer->AllocData(RealNumIndices * (sizeof(unsigned int)));
if(CmdIndex.m_Indices == 0x0)
{
// kick command buffer and try again
KickCommandBuffer();
CmdIndex.m_Indices = (unsigned int*)m_pCommandBuffer->AllocData(RealNumIndices * (sizeof(unsigned int)));
if(CmdIndex.m_Indices == 0x0)
{
dbg_msg("graphics", "failed to allocate data for indices");
return -1;
}
}
// check if we have enough free memory in the commandbuffer
if(!m_pCommandBuffer->AddCommand(CmdIndex))
{
// kick command buffer and try again
KickCommandBuffer();
CmdIndex.m_Indices = (unsigned int*)m_pCommandBuffer->AllocData(RealNumIndices * (sizeof(unsigned int)));
if(CmdIndex.m_Indices == 0x0)
{
dbg_msg("graphics", "failed to allocate data for indices");
return -1;
}
if(!m_pCommandBuffer->AddCommand(CmdIndex))
{
dbg_msg("graphics", "failed to allocate memory for create index buffer command");
return -1;
}
}
mem_copy(CmdIndex.m_Indices, pIndices, RealNumIndices * (sizeof(unsigned int)));
if(NumIndices > RealNumIndices)
{
pIndices += NumIndicesUploaded;
AppendAllIndices(pIndices, NumIndices - RealNumIndices, index);
}
CCommandBuffer::SCommand_CreateVertexArrayObject VertArrayCmd;
VertArrayCmd.m_VisualObjectIDX = index;
VertArrayCmd.m_RequiredIndicesCount = NumIndicesRequired;
// check if we have enough free memory in the commandbuffer
if(!m_pCommandBuffer->AddCommand(VertArrayCmd))
{
@ -1155,61 +1178,6 @@ void CGraphics_Threaded::AppendAllVertices(float* pVertices, unsigned char* pTex
}
}
void CGraphics_Threaded::AppendAllIndices(unsigned int* pIndices, unsigned int NumIndices, int VisualObjectIDX)
{
if(NumIndices == 0) return;
unsigned int MaxIndices = (1024*1024*2) / (sizeof(unsigned int));
unsigned int RealNumIndices = NumIndices;
if(NumIndices > MaxIndices) RealNumIndices = MaxIndices;
CCommandBuffer::SCommand_AppendIndexBufferObject CmdIndex;
CmdIndex.m_VisualObjectIDX = VisualObjectIDX;
unsigned int NumIndicesUploaded = (CmdIndex.m_NumIndices = RealNumIndices); //number of indices to upload
CmdIndex.m_Indices = (unsigned int*)m_pCommandBuffer->AllocData(RealNumIndices * (sizeof(unsigned int)));
if (CmdIndex.m_Indices == 0x0)
{
// kick command buffer and try again
KickCommandBuffer();
CmdIndex.m_Indices = (unsigned int*)m_pCommandBuffer->AllocData(RealNumIndices * (sizeof(unsigned int)));
if (CmdIndex.m_Indices == 0x0)
{
dbg_msg("graphics", "failed to allocate data for indices");
return;
}
}
// check if we have enough free memory in the commandbuffer
if (!m_pCommandBuffer->AddCommand(CmdIndex))
{
// kick command buffer and try again
KickCommandBuffer();
CmdIndex.m_Indices = (unsigned int*)m_pCommandBuffer->AllocData(RealNumIndices * (sizeof(unsigned int)));
if (CmdIndex.m_Indices == 0x0)
{
dbg_msg("graphics", "failed to allocate data for indices");
return;
}
if (!m_pCommandBuffer->AddCommand(CmdIndex))
{
dbg_msg("graphics", "failed to allocate memory for create index buffer command");
return;
}
}
mem_copy(CmdIndex.m_Indices, pIndices, RealNumIndices * (sizeof(unsigned int)));
if(NumIndices > RealNumIndices)
{
pIndices += NumIndicesUploaded;
AppendAllIndices(pIndices, NumIndices - RealNumIndices, VisualObjectIDX);
}
}
int CGraphics_Threaded::IssueInit()
{
int Flags = 0;
@ -1242,6 +1210,14 @@ int CGraphics_Threaded::InitWindow()
if(IssueInit() == 0)
return 0;
}
//try using old opengl context
if(!g_Config.m_GfxForceOldOpenGL)
{
g_Config.m_GfxForceOldOpenGL = 1;
if(IssueInit() == 0)
return 0;
}
// try lowering the resolution
if(g_Config.m_GfxScreenWidth != 640 || g_Config.m_GfxScreenHeight != 480)
@ -1276,6 +1252,11 @@ int CGraphics_Threaded::Init()
m_pBackend = CreateGraphicsBackend();
if(InitWindow() != 0)
return -1;
if(m_UseOpenGL3_3)
m_pVertices = m_aVertices;
else
m_pVertices = m_aVerticesOld;
// fetch final resolution
m_ScreenWidth = g_Config.m_GfxScreenWidth;

View file

@ -86,8 +86,6 @@ public:
CMD_CREATE_VERTEX_ARRAY_OBJECT,//create vao
CMD_CREATE_VERTEX_BUFFER_OBJECT,//create vbo
CMD_APPEND_VERTEX_BUFFER_OBJECT,//append data to the vbo
CMD_CREATE_INDEX_BUFFER_OBJECT,//create ibo
CMD_APPEND_INDEX_BUFFER_OBJECT,//append data to ibo
CMD_RENDER_IBO_VERTEX_ARRAY,//render a specific amount of the index buffer from a vao
CMD_RENDER_BORDER_TILE,//render one tile multiple times
CMD_RENDER_BORDER_TILE_LINE,//render an amount of tiles multiple times
@ -143,20 +141,25 @@ public:
struct SPoint { float x, y; };
struct STexCoord { float u, v; };
struct SColor { float r, g, b, a; };
struct SColorf { float r, g, b, a; };
//use normalized color values
struct SColor { unsigned char r, g, b, a; };
struct SVertex
struct SVertexBase
{
SPoint m_Pos;
STexCoord m_Tex;
SColor m_Color;
};
};
//the char offset of all indices that should be rendered, and the amount of renders
struct SIndicesArray
struct SVertexOld : public SVertexBase
{
char* m_Offset;
unsigned int m_DrawCount;
SColorf m_Color;
};
struct SVertex : public SVertexBase
{
SColor m_Color;
};
struct SCommand
@ -186,7 +189,7 @@ public:
struct SCommand_Clear : public SCommand
{
SCommand_Clear() : SCommand(CMD_CLEAR) {}
SColor m_Color;
SColorf m_Color;
};
struct SCommand_Signal : public SCommand
@ -207,7 +210,7 @@ public:
SState m_State;
unsigned m_PrimType;
unsigned m_PrimCount;
SVertex *m_pVertices; // you should use the command buffer data to allocate vertices for this command
SVertexBase *m_pVertices; // you should use the command buffer data to allocate vertices for this command
};
struct SCommand_CreateVertexBufferObject : public SCommand
@ -233,22 +236,7 @@ public:
{
SCommand_CreateVertexArrayObject() : SCommand(CMD_CREATE_VERTEX_ARRAY_OBJECT) {}
int m_VisualObjectIDX;
};
struct SCommand_CreateIndexBufferObject : public SCommand
{
SCommand_CreateIndexBufferObject() : SCommand(CMD_CREATE_INDEX_BUFFER_OBJECT) {}
unsigned int* m_Indices;
int m_NumIndices;
int m_VisualObjectIDX;
};
struct SCommand_AppendIndexBufferObject : public SCommand
{
SCommand_AppendIndexBufferObject() : SCommand(CMD_APPEND_INDEX_BUFFER_OBJECT) {}
unsigned int* m_Indices;
int m_NumIndices;
int m_VisualObjectIDX;
unsigned int m_RequiredIndicesCount;
};
struct SCommand_RenderVertexArray : public SCommand
@ -256,8 +244,12 @@ public:
SCommand_RenderVertexArray() : SCommand(CMD_RENDER_IBO_VERTEX_ARRAY) {}
//even if clipping should be enabled, we will render all
SState m_State;
SColor m_Color; //the color of the whole tilelayer -- already envelopped
SIndicesArray *m_pIndicesOffsets; // you should use the command buffer data to allocate vertices for this command
SColorf m_Color; //the color of the whole tilelayer -- already envelopped
//the char offset of all indices that should be rendered, and the amount of renders
char** m_pIndicesOffsets;
unsigned int* m_pDrawCount;
int m_IndicesDrawNum;
int m_VisualObjectIDX;
float m_ZoomScreenRatio;
@ -267,7 +259,7 @@ public:
{
SCommand_RenderBorderTile() : SCommand(CMD_RENDER_BORDER_TILE) {}
SState m_State;
SColor m_Color; //the color of the whole tilelayer -- already envelopped
SColorf m_Color; //the color of the whole tilelayer -- already envelopped
char *m_pIndicesOffset; // you should use the command buffer data to allocate vertices for this command
unsigned int m_DrawNum;
int m_VisualObjectIDX;
@ -282,7 +274,7 @@ public:
{
SCommand_RenderBorderTileLine() : SCommand(CMD_RENDER_BORDER_TILE_LINE) {}
SState m_State;
SColor m_Color; //the color of the whole tilelayer -- already envelopped
SColorf m_Color; //the color of the whole tilelayer -- already envelopped
char *m_pIndicesOffset; // you should use the command buffer data to allocate vertices for this command
unsigned int m_IndexDrawNum;
unsigned int m_DrawNum;
@ -488,8 +480,11 @@ class CGraphics_Threaded : public IEngineGraphics
class IConsole *m_pConsole;
CCommandBuffer::SVertex m_aVertices[MAX_VERTICES];
CCommandBuffer::SVertexOld m_aVerticesOld[MAX_VERTICES];
CCommandBuffer::SVertexBase* m_pVertices;
int m_NumVertices;
CCommandBuffer::SColorf m_aColorOld[4];
CCommandBuffer::SColor m_aColor[4];
CCommandBuffer::STexCoord m_aTexture[4];
@ -511,7 +506,7 @@ class CGraphics_Threaded : public IEngineGraphics
void FlushVertices();
void AddVertices(int Count);
void Rotate(const CCommandBuffer::SPoint &rCenter, CCommandBuffer::SVertex *pPoints, int NumPoints);
void Rotate(const CCommandBuffer::SPoint &rCenter, CCommandBuffer::SVertexBase *pPoints, int NumPoints);
void KickCommandBuffer();
@ -559,6 +554,9 @@ 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);
virtual void QuadsSetSubset(float TlU, float TlV, float BrU, float BrV);
virtual void QuadsSetSubsetFree(
@ -574,9 +572,8 @@ public:
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* Indices, unsigned int NumIndices);
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 void AppendAllIndices(unsigned int* pIndices, unsigned int NumIndices, int VisualObjectIDX);
virtual int GetNumScreens() const;
virtual void Minimize();

View file

@ -401,4 +401,5 @@ MACRO_CONFIG_INT(ClDemoShowSpeed, cl_demo_show_speed, 0, 0, 1, CFGFLAG_SAVE|CFGF
//opengl
MACRO_CONFIG_INT(GfxForceOldOpenGL, gfx_force_old_opengl, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Forces to use the old opengl version.")
MACRO_CONFIG_INT(GfxEnableTextureUnitOptimization, gfx_enable_texture_unit_optimization, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Use multiple texture units, instead of only one.")
MACRO_CONFIG_INT(GfxUsePreinitBuffer, gfx_use_preinitialized_buffer, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Use only one buffer for data, that is uploaded to the GPU(might help when using an iGPUs).")
#endif