mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
added flags for mipmap generation on textures. fixes missing texts
This commit is contained in:
parent
b31abc4053
commit
6e57620c2c
|
@ -349,9 +349,18 @@ int CGraphics_OpenGL::LoadTextureRaw(int Width, int Height, int Format, const vo
|
||||||
glGenTextures(1, &m_aTextures[Tex].m_Tex);
|
glGenTextures(1, &m_aTextures[Tex].m_Tex);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_aTextures[Tex].m_Tex);
|
glBindTexture(GL_TEXTURE_2D, m_aTextures[Tex].m_Tex);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
if(Flags&TEXLOAD_NOMIPMAPS)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
{
|
||||||
gluBuild2DMipmaps(GL_TEXTURE_2D, StoreOglformat, Width, Height, Oglformat, GL_UNSIGNED_BYTE, pTexData);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, StoreOglformat, Width, Height, 0, Oglformat, GL_UNSIGNED_BYTE, pData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||||
|
gluBuild2DMipmaps(GL_TEXTURE_2D, StoreOglformat, Width, Height, Oglformat, GL_UNSIGNED_BYTE, pTexData);
|
||||||
|
}
|
||||||
|
|
||||||
// calculate memory usage
|
// calculate memory usage
|
||||||
{
|
{
|
||||||
|
|
|
@ -163,9 +163,20 @@ public:
|
||||||
|
|
||||||
glGenTextures(1, &m_aTextures[pCommand->m_Slot]);
|
glGenTextures(1, &m_aTextures[pCommand->m_Slot]);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_aTextures[pCommand->m_Slot]);
|
glBindTexture(GL_TEXTURE_2D, m_aTextures[pCommand->m_Slot]);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
if(pCommand->m_Flags&CCommandBuffer::TEXFLAG_NOMIPMAPS)
|
||||||
gluBuild2DMipmaps(GL_TEXTURE_2D, StoreOglformat, pCommand->m_Width, pCommand->m_Height, Oglformat, GL_UNSIGNED_BYTE, pCommand->m_pData);
|
{
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, StoreOglformat, pCommand->m_Width, pCommand->m_Height, 0, Oglformat, GL_UNSIGNED_BYTE, pCommand->m_pData);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||||
|
gluBuild2DMipmaps(GL_TEXTURE_2D, StoreOglformat, pCommand->m_Width, pCommand->m_Height, Oglformat, GL_UNSIGNED_BYTE, pCommand->m_pData);
|
||||||
|
}
|
||||||
|
|
||||||
mem_free(pCommand->m_pData);
|
mem_free(pCommand->m_pData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -760,6 +771,11 @@ int CGraphics_Threaded::LoadTextureRaw(int Width, int Height, int Format, const
|
||||||
Cmd.m_Format = ImageFormatToTexFormat(Format);
|
Cmd.m_Format = ImageFormatToTexFormat(Format);
|
||||||
Cmd.m_StoreFormat = ImageFormatToTexFormat(StoreFormat);
|
Cmd.m_StoreFormat = ImageFormatToTexFormat(StoreFormat);
|
||||||
|
|
||||||
|
// flags
|
||||||
|
Cmd.m_Flags = 0;
|
||||||
|
if(Flags&IGraphics::TEXLOAD_NOMIPMAPS)
|
||||||
|
Cmd.m_Flags |= CCommandBuffer::TEXFLAG_NOMIPMAPS;
|
||||||
|
|
||||||
// calculate memory usage
|
// calculate memory usage
|
||||||
int PixelSize = 4;
|
int PixelSize = 4;
|
||||||
if(Format == CImageInfo::FORMAT_RGB)
|
if(Format == CImageInfo::FORMAT_RGB)
|
||||||
|
|
|
@ -86,6 +86,8 @@ public:
|
||||||
TEXFORMAT_RGB,
|
TEXFORMAT_RGB,
|
||||||
TEXFORMAT_RGBA,
|
TEXFORMAT_RGBA,
|
||||||
TEXFORMAT_ALPHA,
|
TEXFORMAT_ALPHA,
|
||||||
|
|
||||||
|
TEXFLAG_NOMIPMAPS = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -186,6 +188,7 @@ public:
|
||||||
int m_Height;
|
int m_Height;
|
||||||
int m_Format;
|
int m_Format;
|
||||||
int m_StoreFormat;
|
int m_StoreFormat;
|
||||||
|
int m_Flags;
|
||||||
void *m_pData; // will be freed by the command processor
|
void *m_pData; // will be freed by the command processor
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ class CTextRender : public IEngineTextRender
|
||||||
pSizeData->m_aTextures[i] = 0;
|
pSizeData->m_aTextures[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pSizeData->m_aTextures[i] = Graphics()->LoadTextureRaw(Width, Height, CImageInfo::FORMAT_ALPHA, pMem, CImageInfo::FORMAT_ALPHA, 0);
|
pSizeData->m_aTextures[i] = Graphics()->LoadTextureRaw(Width, Height, CImageInfo::FORMAT_ALPHA, pMem, CImageInfo::FORMAT_ALPHA, IGraphics::TEXLOAD_NOMIPMAPS);
|
||||||
FontMemoryUsage += Width*Height;
|
FontMemoryUsage += Width*Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,8 @@ public:
|
||||||
*/
|
*/
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TEXLOAD_NORESAMPLE=1,
|
TEXLOAD_NORESAMPLE = 1,
|
||||||
|
TEXLOAD_NOMIPMAPS = 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
int ScreenWidth() const { return m_ScreenWidth; }
|
int ScreenWidth() const { return m_ScreenWidth; }
|
||||||
|
|
Loading…
Reference in a new issue