From f83dc2e8912a72ffef41f2aa9d228d9b57f35c8d Mon Sep 17 00:00:00 2001 From: Garux Date: Sun, 10 Jun 2018 01:27:49 +0300 Subject: [PATCH] * use external textures mipmaps generation, draw NPoT textures correctly --- libs/gtkutil/glfont.cpp | 2 +- radiant/textures.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libs/gtkutil/glfont.cpp b/libs/gtkutil/glfont.cpp index 8ea30d07..65a8d9a8 100644 --- a/libs/gtkutil/glfont.cpp +++ b/libs/gtkutil/glfont.cpp @@ -350,7 +350,7 @@ void renderString( const char *s, const GLuint& tex, const unsigned int colour[3 glTexSubImage2D( GL_TEXTURE_2D, 0, wid, 0, wid, hei, GL_BGRA, GL_UNSIGNED_BYTE, buf ); memset( buf, 0x00, 4 * hei * wid ); - /* orange childSselected with shadow */ + /* orange childSelected with shadow */ gray_to_texture( wid, hei, bitmap.buffer, buf, 255, 128, 0 ); glTexSubImage2D( GL_TEXTURE_2D, 0, wid * 2, 0, wid, hei, GL_BGRA, GL_UNSIGNED_BYTE, buf ); diff --git a/radiant/textures.cpp b/radiant/textures.cpp index d0bb7e59..ee2e0124 100644 --- a/radiant/textures.cpp +++ b/radiant/textures.cpp @@ -202,7 +202,14 @@ void LoadTextureRGBA( qtexture_t* q, unsigned char* pPixels, int nWidth, int nHe SetTexParameters( g_texture_mode ); SetTexAnisotropy( g_TextureAnisotropy ); +#if 1 + glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE ); + glTexImage2D( GL_TEXTURE_2D, 0, g_texture_globals.texture_components, nWidth, nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, pPixels ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, std::min( max_texture_quality - g_Textures_textureQuality.m_value, static_cast( log2( static_cast( std::max( nWidth, nHeight ) ) ) ) ) ); + + glBindTexture( GL_TEXTURE_2D, 0 ); +#else int gl_width = 1; while ( gl_width < nWidth ) gl_width <<= 1; @@ -258,6 +265,7 @@ void LoadTextureRGBA( qtexture_t* q, unsigned char* pPixels, int nWidth, int nHe if ( resampled ) { free( outpixels ); } +#endif } #if 0