mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
remove dublicated GL queries
This commit is contained in:
parent
78a9fbb9b5
commit
78c06e180f
|
@ -263,8 +263,9 @@ void CCommandProcessorFragment_OpenGL::Cmd_Texture_Create(const CCommandBuffer::
|
||||||
// resample if needed
|
// resample if needed
|
||||||
if(pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGBA || pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGB)
|
if(pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGBA || pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGB)
|
||||||
{
|
{
|
||||||
int MaxTexSize;
|
static int MaxTexSize = -1;
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxTexSize);
|
if(MaxTexSize == -1)
|
||||||
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxTexSize);
|
||||||
if(Width > MaxTexSize || Height > MaxTexSize)
|
if(Width > MaxTexSize || Height > MaxTexSize)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
|
@ -753,6 +754,9 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
||||||
if(m_UsePreinitializedVertexBuffer)
|
if(m_UsePreinitializedVertexBuffer)
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(CCommandBuffer::SVertex) * CCommandBuffer::MAX_VERTICES, NULL, GL_STREAM_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, sizeof(CCommandBuffer::SVertex) * CCommandBuffer::MAX_VERTICES, NULL, GL_STREAM_DRAW);
|
||||||
|
|
||||||
|
//query the image max size only once
|
||||||
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_MaxTexSize);
|
||||||
|
|
||||||
//query maximum of allowed textures
|
//query maximum of allowed textures
|
||||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &m_MaxTextureUnits);
|
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &m_MaxTextureUnits);
|
||||||
m_TextureSlotBoundToUnit.resize(m_MaxTextureUnits);
|
m_TextureSlotBoundToUnit.resize(m_MaxTextureUnits);
|
||||||
|
@ -785,6 +789,9 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
||||||
mem_zero(m_aTextures, sizeof(m_aTextures));
|
mem_zero(m_aTextures, sizeof(m_aTextures));
|
||||||
|
|
||||||
m_ClearColor.r = m_ClearColor.g = m_ClearColor.b = -1.f;
|
m_ClearColor.r = m_ClearColor.g = m_ClearColor.b = -1.f;
|
||||||
|
|
||||||
|
//fix the alignment to allow even 1byte changes, e.g. for alpha components
|
||||||
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCommandProcessorFragment_OpenGL3_3::Cmd_Shutdown(const SCommand_Shutdown *pCommand)
|
void CCommandProcessorFragment_OpenGL3_3::Cmd_Shutdown(const SCommand_Shutdown *pCommand)
|
||||||
|
@ -828,8 +835,6 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Update(const CCommandBuffe
|
||||||
glBindSampler(Slot, m_aTextures[pCommand->m_Slot].m_Sampler);
|
glBindSampler(Slot, m_aTextures[pCommand->m_Slot].m_Sampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fix the alignment to allow even 1byte changes, e.g. for alpha components
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_aTextures[pCommand->m_Slot].m_Tex);
|
glBindTexture(GL_TEXTURE_2D, m_aTextures[pCommand->m_Slot].m_Tex);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, pCommand->m_X, pCommand->m_Y, pCommand->m_Width, pCommand->m_Height,
|
glTexSubImage2D(GL_TEXTURE_2D, 0, pCommand->m_X, pCommand->m_Y, pCommand->m_Width, pCommand->m_Height,
|
||||||
TexFormatToOpenGLFormat(pCommand->m_Format), GL_UNSIGNED_BYTE, pCommand->m_pData);
|
TexFormatToOpenGLFormat(pCommand->m_Format), GL_UNSIGNED_BYTE, pCommand->m_pData);
|
||||||
|
@ -860,16 +865,14 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Create(const CCommandBuffe
|
||||||
// resample if needed
|
// resample if needed
|
||||||
if(pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGBA || pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGB)
|
if(pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGBA || pCommand->m_Format == CCommandBuffer::TEXFORMAT_RGB)
|
||||||
{
|
{
|
||||||
int MaxTexSize;
|
if(Width > m_MaxTexSize || Height > m_MaxTexSize)
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &MaxTexSize);
|
|
||||||
if(Width > MaxTexSize || Height > MaxTexSize)
|
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Width>>=1;
|
Width>>=1;
|
||||||
Height>>=1;
|
Height>>=1;
|
||||||
}
|
}
|
||||||
while(Width > MaxTexSize || Height > MaxTexSize);
|
while(Width > m_MaxTexSize || Height > m_MaxTexSize);
|
||||||
|
|
||||||
void *pTmpData = Rescale(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast<const unsigned char *>(pCommand->m_pData));
|
void *pTmpData = Rescale(pCommand->m_Width, pCommand->m_Height, Width, Height, pCommand->m_Format, static_cast<const unsigned char *>(pCommand->m_pData));
|
||||||
mem_free(pTexData);
|
mem_free(pTexData);
|
||||||
|
|
|
@ -156,6 +156,7 @@ class CCommandProcessorFragment_OpenGL3_3
|
||||||
unsigned int m_CurrentIndicesInBuffer;
|
unsigned int m_CurrentIndicesInBuffer;
|
||||||
|
|
||||||
GLint m_MaxTextureUnits;
|
GLint m_MaxTextureUnits;
|
||||||
|
GLint m_MaxTexSize;
|
||||||
|
|
||||||
int m_LastBlendMode; //avoid all possible opengl state changes
|
int m_LastBlendMode; //avoid all possible opengl state changes
|
||||||
bool m_LastClipEnable;
|
bool m_LastClipEnable;
|
||||||
|
|
Loading…
Reference in a new issue