added flags for mipmap generation on textures. fixes missing texts

This commit is contained in:
Magnus Auvinen 2011-12-31 11:18:55 +01:00
parent b31abc4053
commit 6e57620c2c
5 changed files with 37 additions and 8 deletions

View file

@ -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
{ {

View file

@ -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)

View file

@ -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
}; };

View file

@ -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;
} }

View file

@ -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; }