The only thing I can think of would be that sharpened images are less
amenable to texture compression (I do not know if that is true - it is
just a conjecture), and the textures take more space in the GPU cache
or need to be swapped out. How much GPU RAM do you have?

We do not currently request texture compression, but I guess cards may
do a little bit compression anyway. I heard they do really strange
things to textures in GPU memory.

Anyway, this got me inspired to port over some code I wrote for
another project that adds OpenGL texture compression, if available.
This gave me *much* slower loading times, around 20x slower, and FPS
was about 40% slower as well. So as I suspected earlier, texture
compression does not give us anything useful at the moment (although
granted, the patch is a hack and not optimal in any way). It is
attached if you want to play with it (but note that backdrops do not
work, maybe because I added alpha channel to them?).

 - Per
Index: lib/ivis_opengl/tex.c
===================================================================
--- lib/ivis_opengl/tex.c	(revision 697)
+++ lib/ivis_opengl/tex.c	(working copy)
@@ -41,6 +41,8 @@
 #include "lib/ivis_common/bug.h"
 #include "lib/ivis_common/ivispatch.h"
 
+#include "screen.h"
+
 //*************************************************************************
 
 iTexPage _TEX_PAGE[iV_TEX_MAX];
@@ -120,7 +122,7 @@
 
 	if (   (s->width & (s->width-1)) == 0
 	    && (s->height & (s->height-1)) == 0) {
-		gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, s->width, s->height,
+		gluBuild2DMipmaps(GL_TEXTURE_2D, wz_texture_compression, s->width, s->height,
 			     GL_RGBA, GL_UNSIGNED_BYTE, s->bmp);
 	} else {
 		debug(LOG_TEXTURE, "pie_AddBMPtoTexPages: non POT texture %s", filename);
Index: lib/ivis_opengl/pieblitfunc.c
===================================================================
--- lib/ivis_opengl/pieblitfunc.c	(revision 697)
+++ lib/ivis_opengl/pieblitfunc.c	(working copy)
@@ -478,7 +478,7 @@
 		}
 	}
 	pie_SetTexturePage(radarTexture);
-	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0,
+	glTexImage2D(GL_TEXTURE_2D, 0, wz_texture_compression, 128, 128, 0,
 		     GL_RGBA, GL_UNSIGNED_BYTE, radarBitmap);
 	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
 	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
Index: lib/ivis_opengl/screen.c
===================================================================
--- lib/ivis_opengl/screen.c	(revision 697)
+++ lib/ivis_opengl/screen.c	(working copy)
@@ -32,10 +32,6 @@
 #include <stdio.h>
 #include <string.h>
 #include <SDL/SDL.h>
-#ifdef _MSC_VER
-#include <windows.h>  //needed for gl.h!  --Qamly
-#endif
-#include <SDL/SDL_opengl.h>
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -63,6 +59,9 @@
 
 SDL_Surface     *screen;
 
+/* global used to indicate preferred internal OpenGL format */
+GLint wz_texture_compression;
+
 //backDrop
 #define BACKDROP_WIDTH	640
 #define BACKDROP_HEIGHT	480
@@ -93,7 +92,8 @@
 			)
 {
 	static int video_flags = 0;
-	int bpp = 0;
+	int bpp = 0, value;
+	GLint glval;
 
 	/* Store the screen information */
 	screenWidth = width;
@@ -174,6 +174,12 @@
 		debug( LOG_ERROR, "Error: SDL_SetVideoMode failed (%s).\n", SDL_GetError() );
 		return FALSE;
 	}
+	if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &value) == -1) 
+	{
+		debug(LOG_ERROR, "OpenGL initialization did not give double buffering!\n");
+	}
+	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glval);
+	debug(LOG_TEXTURE, "Maximum texture size: %dx%d", (int)glval, (int)glval);
 
 	glViewport(0, 0, width, height);
 	glMatrixMode(GL_PROJECTION);
@@ -378,7 +384,7 @@
 
 		pie_SetTexturePage(-1);
 		glBindTexture(GL_TEXTURE_2D, texture);
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+		glTexImage2D(GL_TEXTURE_2D, 0, wz_texture_compression,
 			     image.width, image.height,
 			     0, GL_RGB, GL_UNSIGNED_BYTE, image.data);
 		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@@ -408,7 +414,7 @@
 
 		pie_SetTexturePage(-1);
 		glBindTexture(GL_TEXTURE_2D, backDropTexture);
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+		glTexImage2D(GL_TEXTURE_2D, 0, wz_texture_compression,
 			     image.width, image.height,
 			     0, GL_RGB, GL_UNSIGNED_BYTE, image.data);
 		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@@ -446,7 +452,7 @@
 	glGenTextures(1, &backDropTexture);
 	pie_SetTexturePage(-1);
 	glBindTexture(GL_TEXTURE_2D, backDropTexture);
-	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
+	glTexImage2D(GL_TEXTURE_2D, 0, wz_texture_compression,
 		   512,512,//backDropWidth, backDropHeight,
 			0, GL_RGB, GL_UNSIGNED_BYTE, newBackDropBmp);
 
Index: lib/ivis_opengl/piemode.c
===================================================================
--- lib/ivis_opengl/piemode.c	(revision 697)
+++ lib/ivis_opengl/piemode.c	(working copy)
@@ -49,6 +49,7 @@
  */
 /***************************************************************************/
 #define DIVIDE_TABLE_SIZE		1024
+
 /***************************************************************************/
 /*
  *	Local Variables
@@ -91,6 +92,22 @@
 		_iVPRIM_DIVTABLE[i-0] = MAKEINT ( FRACTdiv(MAKEFRACT(1),MAKEFRACT(i)) *  iV_DIVMULTP);
 	}
 
+	/* Find texture compression extension */
+	if (check_extension("GL_ARB_texture_compression")) 
+	{
+		if (!check_extension("GL_EXT_texture_compression_s3tc")) 
+		{
+			debug(LOG_TEXTURE, "Texture compression: Yes, but no s3tc");
+			wz_texture_compression = GL_COMPRESSED_RGBA_ARB;
+		} else {
+			debug(LOG_TEXTURE, "Texture compression: Yes (including s3tc)");
+			wz_texture_compression = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
+		}
+	} else {
+		debug(LOG_TEXTURE, "Texture compression: No");
+		wz_texture_compression = GL_RGBA;
+	}
+
 	pie_MatInit();
 	_TEX_INDEX = 0;
 
Index: lib/ivis_opengl/screen.h
===================================================================
--- lib/ivis_opengl/screen.h	(revision 697)
+++ lib/ivis_opengl/screen.h	(working copy)
@@ -20,7 +20,7 @@
 /*
  * Screen.h
  *
- * Interface to the Direct Draw double buffered display.
+ * Interface to the OpenGL double buffered display.
  *
  */
 #ifndef _screen_h
@@ -35,6 +35,11 @@
 
 #include "lib/framework/types.h"
 
+#ifdef _MSC_VER
+#include <windows.h>  //needed for gl.h!  --Qamly
+#endif
+#include <SDL/SDL_opengl.h>
+
 /* ------------------------------------------------------------------------------------------- */
 
 /* Legacy stuff 
@@ -82,4 +87,9 @@
 /* Toggle the display between full screen or windowed */
 extern void	screenToggleMode(void);
 
+extern GLint wz_texture_compression;
+
+/* defined in piedraw.c */
+BOOL check_extension(const char* extension_name);
+
 #endif
Index: lib/ivis_opengl/piedraw.c
===================================================================
--- lib/ivis_opengl/piedraw.c	(revision 697)
+++ lib/ivis_opengl/piedraw.c	(working copy)
@@ -52,7 +52,8 @@
  */
 /***************************************************************************/
 
-static BOOL check_extension(const char* extension_name) {
+BOOL check_extension(const char* extension_name) 
+{
 	const char *extension_list = (const char *)glGetString(GL_EXTENSIONS);
 	unsigned int extension_name_length = strlen(extension_name);
 	const char *tmp = extension_list;
_______________________________________________
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev

Reply via email to