mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
use wrap mode for every individual texture
This commit is contained in:
parent
92edbf4d37
commit
43fa2fd1a7
|
@ -530,7 +530,7 @@ void CCommandProcessorFragment_OpenGL3_3::SetState(const CCommandBuffer::SState
|
|||
if(pProgram->m_LocIsTextured != -1) pProgram->SetUniform(pProgram->m_LocIsTextured, (int)1);
|
||||
pProgram->SetUniform(pProgram->m_LocTextureSampler, (int)Slot);
|
||||
|
||||
if(m_TextureSlotBoundToUnit[Slot].m_LastWrapMode != State.m_WrapMode)
|
||||
if(m_aTextures[State.m_Texture].m_LastWrapMode != State.m_WrapMode)
|
||||
{
|
||||
switch (State.m_WrapMode)
|
||||
{
|
||||
|
@ -545,7 +545,7 @@ void CCommandProcessorFragment_OpenGL3_3::SetState(const CCommandBuffer::SState
|
|||
default:
|
||||
dbg_msg("render", "unknown wrapmode %d\n", State.m_WrapMode);
|
||||
};
|
||||
m_TextureSlotBoundToUnit[Slot].m_LastWrapMode = State.m_WrapMode;
|
||||
m_aTextures[State.m_Texture].m_LastWrapMode = State.m_WrapMode;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -751,7 +751,6 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Init(const SCommand_Init *pCommand
|
|||
for(int i = 0; i < m_MaxTextureUnits; ++i)
|
||||
{
|
||||
m_TextureSlotBoundToUnit[i].m_TextureSlot = -1;
|
||||
m_TextureSlotBoundToUnit[i].m_LastWrapMode = -1;
|
||||
}
|
||||
|
||||
glGenBuffers(1, &m_QuadDrawIndexBufferID);
|
||||
|
@ -839,7 +838,6 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Destroy(const CCommandBuff
|
|||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glBindSampler(Slot, 0);
|
||||
m_TextureSlotBoundToUnit[Slot].m_TextureSlot = -1;
|
||||
m_TextureSlotBoundToUnit[Slot].m_LastWrapMode = -1;
|
||||
DestroyTexture(pCommand->m_Slot);
|
||||
}
|
||||
|
||||
|
@ -920,8 +918,6 @@ 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);
|
||||
|
@ -933,6 +929,9 @@ void CCommandProcessorFragment_OpenGL3_3::Cmd_Texture_Create(const CCommandBuffe
|
|||
gluBuild2DMipmaps(GL_TEXTURE_2D, StoreOglformat, Width, Height, Oglformat, GL_UNSIGNED_BYTE, pTexData);
|
||||
}
|
||||
|
||||
//this is the initial value for the wrap modes
|
||||
m_aTextures[pCommand->m_Slot].m_LastWrapMode = CCommandBuffer::WRAP_REPEAT;
|
||||
|
||||
// calculate memory usage
|
||||
m_aTextures[pCommand->m_Slot].m_MemSize = Width*Height*pCommand->m_PixelSize;
|
||||
while(Width > 2 && Height > 2)
|
||||
|
@ -1079,7 +1078,6 @@ bool CCommandProcessorFragment_OpenGL3_3::IsAndUpdateTextureSlotBound(int IDX, i
|
|||
{
|
||||
//the texture slot uses this index now
|
||||
m_TextureSlotBoundToUnit[IDX].m_TextureSlot = Slot;
|
||||
m_TextureSlotBoundToUnit[IDX].m_LastWrapMode = -1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,6 +134,7 @@ class CCommandProcessorFragment_OpenGL3_3
|
|||
{
|
||||
GLuint m_Tex;
|
||||
GLuint m_Sampler;
|
||||
int m_LastWrapMode;
|
||||
int m_MemSize;
|
||||
};
|
||||
CTexture m_aTextures[CCommandBuffer::MAX_TEXTURES];
|
||||
|
@ -161,7 +162,6 @@ class CCommandProcessorFragment_OpenGL3_3
|
|||
|
||||
struct STextureBound{
|
||||
int m_TextureSlot;
|
||||
int m_LastWrapMode;
|
||||
};
|
||||
std::vector<STextureBound> m_TextureSlotBoundToUnit; //the texture index generated by loadtextureraw is stored in an index calculated by max texture units
|
||||
|
||||
|
|
Loading…
Reference in a new issue