From 6c6aed98c52be3b114ed5f5261705ba8fa7e2e2c Mon Sep 17 00:00:00 2001 From: skyjake Date: Wed, 8 Aug 2007 18:00:46 +0000 Subject: [PATCH] Mystery solved: HQ2x filter lookup tables weren't initialized in time for the worker thread. Now the fonts are looking really sharp! I can use menu-scale 1.0 without everything turning into a blurry mush... --- doomsday/engine/portable/src/gl_texmanager.c | 57 ++++++++++++-------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/doomsday/engine/portable/src/gl_texmanager.c b/doomsday/engine/portable/src/gl_texmanager.c index 91742068fa..f76f8c3cbc 100644 --- a/doomsday/engine/portable/src/gl_texmanager.c +++ b/doomsday/engine/portable/src/gl_texmanager.c @@ -3,8 +3,8 @@ * License: GPL * Online License Link: http://www.gnu.org/licenses/gpl.html * - *\author Copyright © 2003-2007 Jaakko Keränen - *\author Copyright © 2005-2007 Daniel Swanson + *\author Copyright © 2003-2007 Jaakko Keränen + *\author Copyright © 2005-2007 Daniel Swanson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -128,7 +128,7 @@ int filterSprites = true; int texMagMode = 1; // Linear. int texAniso = -1; // Use best. -float texGamma = 0; +float texGamma = 0; byte gammatable[256]; // Convert a 18-bit RGB (666) value to a playpal index. @@ -229,6 +229,9 @@ void GL_EarlyInitTextureManager(void) { int i; + // Initialize the smart texture filtering routines. + GL_InitSmartFilter(); + // The palette lump, for color information (really??!!?!?!). pallump = W_GetNumForName(PALLUMPNAME); @@ -297,9 +300,6 @@ void GL_InitTextureManager(void) // Initialization done. texInited = true; - - // Initialize the smart texture filtering routines. - GL_InitSmartFilter(); } /* @@ -334,7 +334,7 @@ static void LoadPalette(void) { int i, c; byte *playpal; - byte paldata[256 * 3]; + byte paldata[256 * 3]; double invgamma; pallump = W_GetNumForName(PALLUMPNAME); @@ -342,7 +342,7 @@ static void LoadPalette(void) // Clamp to a sane range. invgamma = 1.0f - MINMAX_OF(0, texGamma, 1); - for(i = 0; i < 256; ++i) + for(i = 0; i < 256; ++i) gammatable[i] = (byte)(255.0f * pow(i / 255.0f, invgamma)); // Prepare the color table. @@ -2626,46 +2626,61 @@ DGLuint GL_BindTexPatch(patch_t *p) else { // Use data from the normal lump. - int addBorder = (upscaleAndSharpenPatches? 1 : 0); + boolean scaleSharp = (upscaleAndSharpenPatches || + (p->info.modFlags & TXIF_UPSCALE_AND_SHARPEN)); + int addBorder = (scaleSharp? 1 : 0); int patchWidth = SHORT(patch->width) + addBorder*2; int patchHeight = SHORT(patch->height) + addBorder*2; int numpels = patchWidth * patchHeight, alphaChannel; byte *buffer; - boolean scaleSharp = (upscaleAndSharpenPatches || - (p->info.modFlags & TXIF_UPSCALE_AND_SHARPEN)); if(!numpels) return 0; // This won't do! - + // Allocate memory for the patch. buffer = M_Calloc(2 * numpels); alphaChannel = DrawRealPatch(buffer, patchWidth, patchHeight, patch, addBorder, addBorder, false, 0, true); - + if(filloutlines && !scaleSharp) ColorOutlines(buffer, patchWidth, patchHeight); - + if(monochrome || (p->info.modFlags & TXIF_MONOCHROME)) { DeSaturate(buffer, GL_GetPalette(), patchWidth, patchHeight); p->info.modFlags |= TXIF_MONOCHROME; } - + if(scaleSharp) { byte* rgbaPixels = M_Malloc(numpels * 4 * 2); // also for the final output byte* upscaledPixels = M_Malloc(numpels * 4 * 4); + GL_ConvertBuffer(patchWidth, patchHeight, 2, 4, buffer, rgbaPixels, GL_GetPalette(), false); + GL_SmartFilter2x(rgbaPixels, upscaledPixels, patchWidth, patchHeight, patchWidth * 8); patchWidth *= 2; patchHeight *= 2; - + + /* + { + static int counter = 1; + FILE *f; + char buf[100]; + sprintf(buf, "dumped-%s-%i.dat", W_LumpName(p->lump), counter++); + f = fopen(buf, "wb"); + fwrite(upscaledPixels, 4 * 4 * numpels, 1, f); + fclose(f); + } + */ + /* Con_Message("upscale and sharpen on %s (lump %i) monochrome:%i\n", W_LumpName(p->lump), p->lump, p->info.modFlags & TXIF_MONOCHROME); + */ //EnhanceContrast(upscaledPixels, patchWidth, patchHeight); SharpenPixels(upscaledPixels, patchWidth, patchHeight); @@ -3010,12 +3025,12 @@ void GL_TexReset(void) /** * Called when changing the value of the texture gamma cvar. */ -void GL_DoUpdateTexGamma(cvar_t *unused) -{ - GL_TexReset(); +void GL_DoUpdateTexGamma(cvar_t *unused) +{ + GL_TexReset(); LoadPalette(); - - Con_Printf("Gamma correction set to %f.\n", texGamma); + + Con_Printf("Gamma correction set to %f.\n", texGamma); } /**