From 6e57620c2ca9042732d67134e2986a4ad96d2534 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Sat, 31 Dec 2011 11:18:55 +0100 Subject: added flags for mipmap generation on textures. fixes missing texts --- src/engine/client/graphics_threaded.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/engine/client/graphics_threaded.cpp') diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 2b9147ff..21e9ef2f 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -163,9 +163,20 @@ public: glGenTextures(1, &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); - gluBuild2DMipmaps(GL_TEXTURE_2D, StoreOglformat, pCommand->m_Width, pCommand->m_Height, Oglformat, GL_UNSIGNED_BYTE, pCommand->m_pData); + + if(pCommand->m_Flags&CCommandBuffer::TEXFLAG_NOMIPMAPS) + { + 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); } @@ -760,6 +771,11 @@ int CGraphics_Threaded::LoadTextureRaw(int Width, int Height, int Format, const Cmd.m_Format = ImageFormatToTexFormat(Format); Cmd.m_StoreFormat = ImageFormatToTexFormat(StoreFormat); + // flags + Cmd.m_Flags = 0; + if(Flags&IGraphics::TEXLOAD_NOMIPMAPS) + Cmd.m_Flags |= CCommandBuffer::TEXFLAG_NOMIPMAPS; + // calculate memory usage int PixelSize = 4; if(Format == CImageInfo::FORMAT_RGB) -- cgit 1.4.1