about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2011-12-31 11:18:55 +0100
committerMagnus Auvinen <magnus.auvinen@gmail.com>2011-12-31 11:18:55 +0100
commit6e57620c2ca9042732d67134e2986a4ad96d2534 (patch)
treed5f7aa0cf266fe695ca3240f1b267b02104e51c7 /src
parentb31abc40537bff7e159091ff61d5af442296c4d9 (diff)
downloadzcatch-6e57620c2ca9042732d67134e2986a4ad96d2534.tar.gz
zcatch-6e57620c2ca9042732d67134e2986a4ad96d2534.zip
added flags for mipmap generation on textures. fixes missing texts
Diffstat (limited to 'src')
-rw-r--r--src/engine/client/graphics.cpp15
-rw-r--r--src/engine/client/graphics_threaded.cpp22
-rw-r--r--src/engine/client/graphics_threaded.h3
-rw-r--r--src/engine/client/text.cpp2
-rw-r--r--src/engine/graphics.h3
5 files changed, 37 insertions, 8 deletions
diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp
index fda85312..d16f10fc 100644
--- a/src/engine/client/graphics.cpp
+++ b/src/engine/client/graphics.cpp
@@ -349,9 +349,18 @@ int CGraphics_OpenGL::LoadTextureRaw(int Width, int Height, int Format, const vo
 	glGenTextures(1, &m_aTextures[Tex].m_Tex);
 	glBindTexture(GL_TEXTURE_2D, m_aTextures[Tex].m_Tex);
 
-	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);
+	if(Flags&TEXLOAD_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, 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
 	{
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)
diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h
index a4c4ab40..41565ca2 100644
--- a/src/engine/client/graphics_threaded.h
+++ b/src/engine/client/graphics_threaded.h
@@ -86,6 +86,8 @@ public:
 		TEXFORMAT_RGB,
 		TEXFORMAT_RGBA,
 		TEXFORMAT_ALPHA,
+
+		TEXFLAG_NOMIPMAPS = 1,
 	};
 
 	enum
@@ -186,6 +188,7 @@ public:
 		int m_Height;
 		int m_Format;
 		int m_StoreFormat;
+		int m_Flags;
 		void *m_pData; // will be freed by the command processor
 	};
 
diff --git a/src/engine/client/text.cpp b/src/engine/client/text.cpp
index 51eed547..f00247d2 100644
--- a/src/engine/client/text.cpp
+++ b/src/engine/client/text.cpp
@@ -157,7 +157,7 @@ class CTextRender : public IEngineTextRender
 				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;
 		}
 
diff --git a/src/engine/graphics.h b/src/engine/graphics.h
index be113b2d..94d9c1a2 100644
--- a/src/engine/graphics.h
+++ b/src/engine/graphics.h
@@ -57,7 +57,8 @@ public:
 	*/
 	enum
 	{
-		TEXLOAD_NORESAMPLE=1,
+		TEXLOAD_NORESAMPLE = 1,
+		TEXLOAD_NOMIPMAPS = 2,
 	};
 
 	int ScreenWidth() const { return m_ScreenWidth; }