mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 23:33:00 +00:00
- moved texture code to 'common'.
This commit is contained in:
parent
5bde737be9
commit
580e463498
86 changed files with 218 additions and 177 deletions
|
@ -529,17 +529,17 @@ if( HAVE_MMX )
|
||||||
add_definitions( -DHAVE_MMX=1 )
|
add_definitions( -DHAVE_MMX=1 )
|
||||||
|
|
||||||
set( SYSTEM_SOURCES ${SYSTEM_SOURCES}
|
set( SYSTEM_SOURCES ${SYSTEM_SOURCES}
|
||||||
gamedata/textures/hires/hqnx_asm/hq2x_asm.cpp
|
common/textures/hires/hqnx_asm/hq2x_asm.cpp
|
||||||
gamedata/textures/hires/hqnx_asm/hq3x_asm.cpp
|
common/textures/hires/hqnx_asm/hq3x_asm.cpp
|
||||||
gamedata/textures/hires/hqnx_asm/hq4x_asm.cpp
|
common/textures/hires/hqnx_asm/hq4x_asm.cpp
|
||||||
gamedata/textures/hires/hqnx_asm/hqnx_asm_Image.cpp)
|
common/textures/hires/hqnx_asm/hqnx_asm_Image.cpp)
|
||||||
|
|
||||||
if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
|
if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
|
||||||
set_source_files_properties(
|
set_source_files_properties(
|
||||||
gamedata/textures/hires/hqnx_asm/hq2x_asm.cpp
|
common/textures/hires/hqnx_asm/hq2x_asm.cpp
|
||||||
gamedata/textures/hires/hqnx_asm/hq3x_asm.cpp
|
common/textures/hires/hqnx_asm/hq3x_asm.cpp
|
||||||
gamedata/textures/hires/hqnx_asm/hq4x_asm.cpp
|
common/textures/hires/hqnx_asm/hq4x_asm.cpp
|
||||||
gamedata/textures/hires/hqresize.cpp
|
common/textures/hires/hqresize.cpp
|
||||||
PROPERTIES COMPILE_FLAGS "-mmmx" )
|
PROPERTIES COMPILE_FLAGS "-mmmx" )
|
||||||
endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
|
endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
|
||||||
endif( HAVE_MMX )
|
endif( HAVE_MMX )
|
||||||
|
@ -593,10 +593,6 @@ file( GLOB HEADER_FILES
|
||||||
gamedata/*.h
|
gamedata/*.h
|
||||||
gamedata/resourcefiles/*.h
|
gamedata/resourcefiles/*.h
|
||||||
gamedata/fonts/*.h
|
gamedata/fonts/*.h
|
||||||
gamedata/textures/*.h
|
|
||||||
gamedata/textures/hires/hqnx/*.h
|
|
||||||
gamedata/textures/hires/hqnx_asm/*.h
|
|
||||||
gamedata/textures/hires/xbr/*.h
|
|
||||||
gamedata/xlat/*.h
|
gamedata/xlat/*.h
|
||||||
intermission/*.h
|
intermission/*.h
|
||||||
maploader/*.h
|
maploader/*.h
|
||||||
|
@ -616,6 +612,9 @@ file( GLOB HEADER_FILES
|
||||||
common/utility/*.h
|
common/utility/*.h
|
||||||
common/engine/*.h
|
common/engine/*.h
|
||||||
common/filesystem/*.h
|
common/filesystem/*.h
|
||||||
|
common/textures/hires/hqnx/*.h
|
||||||
|
common/textures/hires/hqnx_asm/*.h
|
||||||
|
common/textures/hires/xbr/*.h
|
||||||
common/thirdparty/*.h
|
common/thirdparty/*.h
|
||||||
common/thirdparty/rapidjson/*.h
|
common/thirdparty/rapidjson/*.h
|
||||||
common/thirdparty/math./*h
|
common/thirdparty/math./*h
|
||||||
|
@ -758,12 +757,12 @@ set( FASTMATH_SOURCES
|
||||||
rendering/swrenderer/r_all.cpp
|
rendering/swrenderer/r_all.cpp
|
||||||
rendering/swrenderer/r_swscene.cpp
|
rendering/swrenderer/r_swscene.cpp
|
||||||
rendering/polyrenderer/poly_all.cpp
|
rendering/polyrenderer/poly_all.cpp
|
||||||
gamedata/textures/hires/hqnx/init.cpp
|
common/textures/hires/hqnx/init.cpp
|
||||||
gamedata/textures/hires/hqnx/hq2x.cpp
|
common/textures/hires/hqnx/hq2x.cpp
|
||||||
gamedata/textures/hires/hqnx/hq3x.cpp
|
common/textures/hires/hqnx/hq3x.cpp
|
||||||
gamedata/textures/hires/hqnx/hq4x.cpp
|
common/textures/hires/hqnx/hq4x.cpp
|
||||||
gamedata/textures/hires/xbr/xbrz.cpp
|
common/textures/hires/xbr/xbrz.cpp
|
||||||
gamedata/textures/hires/xbr/xbrz_old.cpp
|
common/textures/hires/xbr/xbrz_old.cpp
|
||||||
rendering/gl_load/gl_load.c
|
rendering/gl_load/gl_load.c
|
||||||
rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp
|
rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp
|
||||||
rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp
|
rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp
|
||||||
|
@ -1004,34 +1003,7 @@ set (PCH_SOURCES
|
||||||
menu/resolutionmenu.cpp
|
menu/resolutionmenu.cpp
|
||||||
gamedata/textures/animations.cpp
|
gamedata/textures/animations.cpp
|
||||||
gamedata/textures/anim_switches.cpp
|
gamedata/textures/anim_switches.cpp
|
||||||
gamedata/textures/bitmap.cpp
|
|
||||||
gamedata/textures/texture.cpp
|
|
||||||
gamedata/textures/image.cpp
|
|
||||||
gamedata/textures/imagetexture.cpp
|
|
||||||
gamedata/textures/texturemanager.cpp
|
|
||||||
gamedata/textures/multipatchtexturebuilder.cpp
|
|
||||||
gamedata/textures/skyboxtexture.cpp
|
|
||||||
gamedata/textures/buildloader.cpp
|
gamedata/textures/buildloader.cpp
|
||||||
gamedata/textures/formats/automaptexture.cpp
|
|
||||||
gamedata/textures/formats/brightmaptexture.cpp
|
|
||||||
gamedata/textures/formats/buildtexture.cpp
|
|
||||||
gamedata/textures/formats/canvastexture.cpp
|
|
||||||
gamedata/textures/formats/ddstexture.cpp
|
|
||||||
gamedata/textures/formats/flattexture.cpp
|
|
||||||
gamedata/textures/formats/fontchars.cpp
|
|
||||||
gamedata/textures/formats/imgztexture.cpp
|
|
||||||
gamedata/textures/formats/jpegtexture.cpp
|
|
||||||
gamedata/textures/formats/md5check.cpp
|
|
||||||
gamedata/textures/formats/multipatchtexture.cpp
|
|
||||||
gamedata/textures/formats/patchtexture.cpp
|
|
||||||
gamedata/textures/formats/pcxtexture.cpp
|
|
||||||
gamedata/textures/formats/pngtexture.cpp
|
|
||||||
gamedata/textures/formats/rawpagetexture.cpp
|
|
||||||
gamedata/textures/formats/emptytexture.cpp
|
|
||||||
gamedata/textures/formats/shadertexture.cpp
|
|
||||||
gamedata/textures/formats/tgatexture.cpp
|
|
||||||
gamedata/textures/formats/stbtexture.cpp
|
|
||||||
gamedata/textures/hires/hqresize.cpp
|
|
||||||
gamedata/fonts/singlelumpfont.cpp
|
gamedata/fonts/singlelumpfont.cpp
|
||||||
gamedata/fonts/singlepicfont.cpp
|
gamedata/fonts/singlepicfont.cpp
|
||||||
gamedata/fonts/specialfont.cpp
|
gamedata/fonts/specialfont.cpp
|
||||||
|
@ -1107,7 +1079,35 @@ set (PCH_SOURCES
|
||||||
common/audio/music/i_soundfont.cpp
|
common/audio/music/i_soundfont.cpp
|
||||||
common/audio/music/music_config.cpp
|
common/audio/music/music_config.cpp
|
||||||
common/thirdparty/sfmt/SFMT.cpp
|
common/thirdparty/sfmt/SFMT.cpp
|
||||||
|
common/textures/hw_ihwtexture.cpp
|
||||||
|
common/textures/bitmap.cpp
|
||||||
common/textures/m_png.cpp
|
common/textures/m_png.cpp
|
||||||
|
common/textures/texture.cpp
|
||||||
|
common/textures/image.cpp
|
||||||
|
common/textures/imagetexture.cpp
|
||||||
|
common/textures/texturemanager.cpp
|
||||||
|
common/textures/multipatchtexturebuilder.cpp
|
||||||
|
common/textures/skyboxtexture.cpp
|
||||||
|
common/textures/formats/automaptexture.cpp
|
||||||
|
common/textures/formats/brightmaptexture.cpp
|
||||||
|
common/textures/formats/buildtexture.cpp
|
||||||
|
common/textures/formats/canvastexture.cpp
|
||||||
|
common/textures/formats/ddstexture.cpp
|
||||||
|
common/textures/formats/flattexture.cpp
|
||||||
|
common/textures/formats/fontchars.cpp
|
||||||
|
common/textures/formats/imgztexture.cpp
|
||||||
|
common/textures/formats/jpegtexture.cpp
|
||||||
|
common/textures/formats/md5check.cpp
|
||||||
|
common/textures/formats/multipatchtexture.cpp
|
||||||
|
common/textures/formats/patchtexture.cpp
|
||||||
|
common/textures/formats/pcxtexture.cpp
|
||||||
|
common/textures/formats/pngtexture.cpp
|
||||||
|
common/textures/formats/rawpagetexture.cpp
|
||||||
|
common/textures/formats/emptytexture.cpp
|
||||||
|
common/textures/formats/shadertexture.cpp
|
||||||
|
common/textures/formats/tgatexture.cpp
|
||||||
|
common/textures/formats/stbtexture.cpp
|
||||||
|
common/textures/hires/hqresize.cpp
|
||||||
common/console/c_commandline.cpp
|
common/console/c_commandline.cpp
|
||||||
common/console/c_buttons.cpp
|
common/console/c_buttons.cpp
|
||||||
common/console/c_bind.cpp
|
common/console/c_bind.cpp
|
||||||
|
@ -1233,6 +1233,8 @@ include_directories( .
|
||||||
common/audio/sound
|
common/audio/sound
|
||||||
common/audio/music
|
common/audio/music
|
||||||
common/thirdparty
|
common/thirdparty
|
||||||
|
common/textures/formats
|
||||||
|
common/textures/hires
|
||||||
common/filesystem
|
common/filesystem
|
||||||
common/utility
|
common/utility
|
||||||
common/console
|
common/console
|
||||||
|
@ -1361,12 +1363,6 @@ install(TARGETS zdoom
|
||||||
source_group("Audio Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/.+")
|
source_group("Audio Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/.+")
|
||||||
source_group("Game Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/.+")
|
source_group("Game Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/.+")
|
||||||
source_group("Game Data\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/fonts/.+")
|
source_group("Game Data\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/fonts/.+")
|
||||||
source_group("Game Data\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/.+")
|
|
||||||
source_group("Game Data\\Textures\\Hires" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/hires/.+")
|
|
||||||
source_group("Game Data\\Textures\\Hires\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/hires/hqnx/.+")
|
|
||||||
source_group("Game Data\\Textures\\Hires\\HQ Resize MMX version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/hires/hqnx_asm/.+")
|
|
||||||
source_group("Game Data\\Textures\\Hires\\XBRZ" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/hires/xbr/.+")
|
|
||||||
source_group("Game Data\\Textures\\Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/formats/.+")
|
|
||||||
source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+")
|
source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+")
|
||||||
source_group("Map Loader" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/maploader/.+")
|
source_group("Map Loader" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/maploader/.+")
|
||||||
source_group("Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/menu/.+")
|
source_group("Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/menu/.+")
|
||||||
|
@ -1440,6 +1436,11 @@ source_group("Common\\Console" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/
|
||||||
source_group("Common\\Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/utility/.+")
|
source_group("Common\\Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/utility/.+")
|
||||||
source_group("Common\\Engine" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/engine/.+")
|
source_group("Common\\Engine" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/engine/.+")
|
||||||
source_group("Common\\File System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/.+")
|
source_group("Common\\File System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/.+")
|
||||||
|
source_group("Common\\Textures\\Hires" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/.+")
|
||||||
|
source_group("Common\\Textures\\Hires\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/hqnx/.+")
|
||||||
|
source_group("Common\\Textures\\Hires\\HQ Resize MMX version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/hqnx_asm/.+")
|
||||||
|
source_group("Common\\Textures\\Hires\\XBRZ" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/xbr/.+")
|
||||||
|
source_group("Common\\Textures\\Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/formats/.+")
|
||||||
source_group("Common\\Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/.+")
|
source_group("Common\\Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/.+")
|
||||||
source_group("Common\\Third Party\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/math/.+")
|
source_group("Common\\Third Party\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/math/.+")
|
||||||
source_group("Common\\Third Party\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/rapidjson/.+")
|
source_group("Common\\Third Party\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/rapidjson/.+")
|
||||||
|
|
137
src/common/textures/hw_ihwtexture.cpp
Normal file
137
src/common/textures/hw_ihwtexture.cpp
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
/*
|
||||||
|
** ihwtexture.cpp
|
||||||
|
** Interface for hardware textures
|
||||||
|
**
|
||||||
|
**---------------------------------------------------------------------------
|
||||||
|
** Copyright 2006-2020 Christoph Oelckers
|
||||||
|
** All rights reserved.
|
||||||
|
**
|
||||||
|
** Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions
|
||||||
|
** are met:
|
||||||
|
**
|
||||||
|
** 1. Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in the
|
||||||
|
** documentation and/or other materials provided with the distribution.
|
||||||
|
** 3. The name of the author may not be used to endorse or promote products
|
||||||
|
** derived from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
**---------------------------------------------------------------------------
|
||||||
|
**
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "hw_ihwtexture.h"
|
||||||
|
#include "templates.h"
|
||||||
|
#include "tarray.h"
|
||||||
|
#include "xs_Float.h"
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
//
|
||||||
|
// Quick'n dirty image rescaling.
|
||||||
|
//
|
||||||
|
// This will only be used when the source texture is larger than
|
||||||
|
// what the hardware can manage (extremely rare in Doom)
|
||||||
|
//
|
||||||
|
// Code taken from wxWidgets
|
||||||
|
//
|
||||||
|
//===========================================================================
|
||||||
|
|
||||||
|
struct BoxPrecalc
|
||||||
|
{
|
||||||
|
int boxStart;
|
||||||
|
int boxEnd;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void ResampleBoxPrecalc(TArray<BoxPrecalc>& boxes, int oldDim)
|
||||||
|
{
|
||||||
|
int newDim = boxes.Size();
|
||||||
|
const double scale_factor_1 = double(oldDim) / newDim;
|
||||||
|
const int scale_factor_2 = (int)(scale_factor_1 / 2);
|
||||||
|
|
||||||
|
for (int dst = 0; dst < newDim; ++dst)
|
||||||
|
{
|
||||||
|
// Source pixel in the Y direction
|
||||||
|
const int src_p = int(dst * scale_factor_1);
|
||||||
|
|
||||||
|
BoxPrecalc& precalc = boxes[dst];
|
||||||
|
precalc.boxStart = clamp<int>(int(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1);
|
||||||
|
precalc.boxEnd = clamp<int>(MAX<int>(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IHardwareTexture::Resize(int swidth, int sheight, int width, int height, unsigned char *src_data, unsigned char *dst_data)
|
||||||
|
{
|
||||||
|
|
||||||
|
// This function implements a simple pre-blur/box averaging method for
|
||||||
|
// downsampling that gives reasonably smooth results To scale the image
|
||||||
|
// down we will need to gather a grid of pixels of the size of the scale
|
||||||
|
// factor in each direction and then do an averaging of the pixels.
|
||||||
|
|
||||||
|
TArray<BoxPrecalc> vPrecalcs(height, true);
|
||||||
|
TArray<BoxPrecalc> hPrecalcs(width, true);
|
||||||
|
|
||||||
|
ResampleBoxPrecalc(vPrecalcs, sheight);
|
||||||
|
ResampleBoxPrecalc(hPrecalcs, swidth);
|
||||||
|
|
||||||
|
int averaged_pixels, averaged_alpha, src_pixel_index;
|
||||||
|
double sum_r, sum_g, sum_b, sum_a;
|
||||||
|
|
||||||
|
for (int y = 0; y < height; y++) // Destination image - Y direction
|
||||||
|
{
|
||||||
|
// Source pixel in the Y direction
|
||||||
|
const BoxPrecalc& vPrecalc = vPrecalcs[y];
|
||||||
|
|
||||||
|
for (int x = 0; x < width; x++) // Destination image - X direction
|
||||||
|
{
|
||||||
|
// Source pixel in the X direction
|
||||||
|
const BoxPrecalc& hPrecalc = hPrecalcs[x];
|
||||||
|
|
||||||
|
// Box of pixels to average
|
||||||
|
averaged_pixels = 0;
|
||||||
|
averaged_alpha = 0;
|
||||||
|
sum_r = sum_g = sum_b = sum_a = 0.0;
|
||||||
|
|
||||||
|
for (int j = vPrecalc.boxStart; j <= vPrecalc.boxEnd; ++j)
|
||||||
|
{
|
||||||
|
for (int i = hPrecalc.boxStart; i <= hPrecalc.boxEnd; ++i)
|
||||||
|
{
|
||||||
|
// Calculate the actual index in our source pixels
|
||||||
|
src_pixel_index = j * swidth + i;
|
||||||
|
|
||||||
|
int a = src_data[src_pixel_index * 4 + 3];
|
||||||
|
if (a > 0) // do not use color from fully transparent pixels
|
||||||
|
{
|
||||||
|
sum_r += src_data[src_pixel_index * 4 + 0];
|
||||||
|
sum_g += src_data[src_pixel_index * 4 + 1];
|
||||||
|
sum_b += src_data[src_pixel_index * 4 + 2];
|
||||||
|
sum_a += a;
|
||||||
|
averaged_pixels++;
|
||||||
|
}
|
||||||
|
averaged_alpha++;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the average from the sum and number of averaged pixels
|
||||||
|
dst_data[0] = (unsigned char)xs_CRoundToInt(sum_r / averaged_pixels);
|
||||||
|
dst_data[1] = (unsigned char)xs_CRoundToInt(sum_g / averaged_pixels);
|
||||||
|
dst_data[2] = (unsigned char)xs_CRoundToInt(sum_b / averaged_pixels);
|
||||||
|
dst_data[3] = (unsigned char)xs_CRoundToInt(sum_a / averaged_alpha);
|
||||||
|
dst_data += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "hwrenderer/textures/hw_ihwtexture.h"
|
#include "hw_ihwtexture.h"
|
||||||
#include "palettecontainer.h"
|
#include "palettecontainer.h"
|
||||||
|
|
||||||
struct FTextureBuffer;
|
struct FTextureBuffer;
|
|
@ -41,7 +41,7 @@
|
||||||
#include "renderstyle.h"
|
#include "renderstyle.h"
|
||||||
#include "textureid.h"
|
#include "textureid.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "hwrenderer/textures/hw_texcontainer.h"
|
#include "hw_texcontainer.h"
|
||||||
|
|
||||||
// 15 because 0th texture is our texture
|
// 15 because 0th texture is our texture
|
||||||
#define MAX_CUSTOM_HW_SHADER_TEXTURES 15
|
#define MAX_CUSTOM_HW_SHADER_TEXTURES 15
|
|
@ -56,8 +56,8 @@
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
#include "myiswalpha.h"
|
#include "myiswalpha.h"
|
||||||
#include "textures/formats/fontchars.h"
|
#include "fontchars.h"
|
||||||
#include "textures/formats/multipatchtexture.h"
|
#include "multipatchtexture.h"
|
||||||
#include "texturemanager.h"
|
#include "texturemanager.h"
|
||||||
#include "r_translate.h"
|
#include "r_translate.h"
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include "v_font.h"
|
#include "v_font.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
#include "textures/formats/fontchars.h"
|
#include "fontchars.h"
|
||||||
#include "texturemanager.h"
|
#include "texturemanager.h"
|
||||||
|
|
||||||
#include "fontinternals.h"
|
#include "fontinternals.h"
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include "v_font.h"
|
#include "v_font.h"
|
||||||
#include "textures.h"
|
#include "textures.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "textures/formats/fontchars.h"
|
#include "fontchars.h"
|
||||||
#include "texturemanager.h"
|
#include "texturemanager.h"
|
||||||
|
|
||||||
#include "fontinternals.h"
|
#include "fontinternals.h"
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
#include "textures/formats/fontchars.h"
|
#include "fontchars.h"
|
||||||
#include "texturemanager.h"
|
#include "texturemanager.h"
|
||||||
|
|
||||||
#include "fontinternals.h"
|
#include "fontinternals.h"
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#define __P_TERRAIN_H__
|
#define __P_TERRAIN_H__
|
||||||
|
|
||||||
#include "s_sound.h"
|
#include "s_sound.h"
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
|
|
||||||
class PClass;
|
class PClass;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
#include "s_sound.h"
|
#include "s_sound.h"
|
||||||
#include "r_state.h"
|
#include "r_state.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "colormatcher.h"
|
#include "colormatcher.h"
|
||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
#include "resourcefile.h"
|
#include "resourcefile.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "animations.h"
|
#include "animations.h"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
#include "dobject.h"
|
#include "dobject.h"
|
||||||
#include "m_fixed.h"
|
#include "m_fixed.h"
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
#include "s_sound.h"
|
#include "s_sound.h"
|
||||||
#include "v_font.h"
|
#include "v_font.h"
|
||||||
#include "g_game.h"
|
#include "g_game.h"
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "c_cvars.h"
|
#include "c_cvars.h"
|
||||||
#include "v_font.h"
|
#include "v_font.h"
|
||||||
#include "gi.h"
|
#include "gi.h"
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
|
|
||||||
EXTERN_CVAR(Float, snd_menuvolume)
|
EXTERN_CVAR(Float, snd_menuvolume)
|
||||||
EXTERN_CVAR(Int, m_use_mouse);
|
EXTERN_CVAR(Int, m_use_mouse);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <tarray.h>
|
#include <tarray.h>
|
||||||
|
|
||||||
#include "s_sound.h"
|
#include "s_sound.h"
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
|
|
||||||
struct FStrifeDialogueReply;
|
struct FStrifeDialogueReply;
|
||||||
class FTexture;
|
class FTexture;
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
#include "info.h"
|
#include "info.h"
|
||||||
|
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
#include "renderstyle.h"
|
#include "renderstyle.h"
|
||||||
#include "s_sound.h"
|
#include "s_sound.h"
|
||||||
#include "memarena.h"
|
#include "memarena.h"
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "actor.h"
|
#include "actor.h"
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
|
|
||||||
struct sector_t;
|
struct sector_t;
|
||||||
struct line_t;
|
struct line_t;
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
#include "a_dynlight.h"
|
#include "a_dynlight.h"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "textures/skyboxtexture.h"
|
#include "skyboxtexture.h"
|
||||||
#include "hwrenderer/postprocessing/hw_postprocessshader.h"
|
#include "hwrenderer/postprocessing/hw_postprocessshader.h"
|
||||||
#include "hwrenderer/textures/hw_material.h"
|
#include "hwrenderer/textures/hw_material.h"
|
||||||
#include "texturemanager.h"
|
#include "texturemanager.h"
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "textures/formats/multipatchtexture.h"
|
#include "multipatchtexture.h"
|
||||||
|
|
||||||
#include "gstrings.h"
|
#include "gstrings.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "gl_load/gl_interface.h"
|
#include "gl_load/gl_interface.h"
|
||||||
#include "hwrenderer/textures/hw_ihwtexture.h"
|
#include "hw_ihwtexture.h"
|
||||||
|
|
||||||
class FCanvasTexture;
|
class FCanvasTexture;
|
||||||
class AActor;
|
class AActor;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
#include "r_defs.h"
|
#include "r_defs.h"
|
||||||
#include "renderstyle.h"
|
#include "renderstyle.h"
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
#include "r_data/colormaps.h"
|
#include "r_data/colormaps.h"
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
#include "r_sky.h"
|
#include "r_sky.h"
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
|
|
||||||
#include "textures/skyboxtexture.h"
|
#include "skyboxtexture.h"
|
||||||
#include "hwrenderer/textures/hw_material.h"
|
#include "hwrenderer/textures/hw_material.h"
|
||||||
#include "hw_skydome.h"
|
#include "hw_skydome.h"
|
||||||
#include "hw_renderstate.h"
|
#include "hw_renderstate.h"
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "hwrenderer/scene/hw_skydome.h"
|
#include "hwrenderer/scene/hw_skydome.h"
|
||||||
#include "hwrenderer/scene/hw_portal.h"
|
#include "hwrenderer/scene/hw_portal.h"
|
||||||
#include "hwrenderer/scene/hw_renderstate.h"
|
#include "hwrenderer/scene/hw_renderstate.h"
|
||||||
#include "textures/skyboxtexture.h"
|
#include "skyboxtexture.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,103 +31,6 @@
|
||||||
#include "hw_material.h"
|
#include "hw_material.h"
|
||||||
#include "texturemanager.h"
|
#include "texturemanager.h"
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// Quick'n dirty image rescaling.
|
|
||||||
//
|
|
||||||
// This will only be used when the source texture is larger than
|
|
||||||
// what the hardware can manage (extremely rare in Doom)
|
|
||||||
//
|
|
||||||
// Code taken from wxWidgets
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
struct BoxPrecalc
|
|
||||||
{
|
|
||||||
int boxStart;
|
|
||||||
int boxEnd;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void ResampleBoxPrecalc(TArray<BoxPrecalc>& boxes, int oldDim)
|
|
||||||
{
|
|
||||||
int newDim = boxes.Size();
|
|
||||||
const double scale_factor_1 = double(oldDim) / newDim;
|
|
||||||
const int scale_factor_2 = (int)(scale_factor_1 / 2);
|
|
||||||
|
|
||||||
for (int dst = 0; dst < newDim; ++dst)
|
|
||||||
{
|
|
||||||
// Source pixel in the Y direction
|
|
||||||
const int src_p = int(dst * scale_factor_1);
|
|
||||||
|
|
||||||
BoxPrecalc& precalc = boxes[dst];
|
|
||||||
precalc.boxStart = clamp<int>(int(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1);
|
|
||||||
precalc.boxEnd = clamp<int>(MAX<int>(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IHardwareTexture::Resize(int swidth, int sheight, int width, int height, unsigned char *src_data, unsigned char *dst_data)
|
|
||||||
{
|
|
||||||
|
|
||||||
// This function implements a simple pre-blur/box averaging method for
|
|
||||||
// downsampling that gives reasonably smooth results To scale the image
|
|
||||||
// down we will need to gather a grid of pixels of the size of the scale
|
|
||||||
// factor in each direction and then do an averaging of the pixels.
|
|
||||||
|
|
||||||
TArray<BoxPrecalc> vPrecalcs(height, true);
|
|
||||||
TArray<BoxPrecalc> hPrecalcs(width, true);
|
|
||||||
|
|
||||||
ResampleBoxPrecalc(vPrecalcs, sheight);
|
|
||||||
ResampleBoxPrecalc(hPrecalcs, swidth);
|
|
||||||
|
|
||||||
int averaged_pixels, averaged_alpha, src_pixel_index;
|
|
||||||
double sum_r, sum_g, sum_b, sum_a;
|
|
||||||
|
|
||||||
for (int y = 0; y < height; y++) // Destination image - Y direction
|
|
||||||
{
|
|
||||||
// Source pixel in the Y direction
|
|
||||||
const BoxPrecalc& vPrecalc = vPrecalcs[y];
|
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) // Destination image - X direction
|
|
||||||
{
|
|
||||||
// Source pixel in the X direction
|
|
||||||
const BoxPrecalc& hPrecalc = hPrecalcs[x];
|
|
||||||
|
|
||||||
// Box of pixels to average
|
|
||||||
averaged_pixels = 0;
|
|
||||||
averaged_alpha = 0;
|
|
||||||
sum_r = sum_g = sum_b = sum_a = 0.0;
|
|
||||||
|
|
||||||
for (int j = vPrecalc.boxStart; j <= vPrecalc.boxEnd; ++j)
|
|
||||||
{
|
|
||||||
for (int i = hPrecalc.boxStart; i <= hPrecalc.boxEnd; ++i)
|
|
||||||
{
|
|
||||||
// Calculate the actual index in our source pixels
|
|
||||||
src_pixel_index = j * swidth + i;
|
|
||||||
|
|
||||||
int a = src_data[src_pixel_index * 4 + 3];
|
|
||||||
if (a > 0) // do not use color from fully transparent pixels
|
|
||||||
{
|
|
||||||
sum_r += src_data[src_pixel_index * 4 + 0];
|
|
||||||
sum_g += src_data[src_pixel_index * 4 + 1];
|
|
||||||
sum_b += src_data[src_pixel_index * 4 + 2];
|
|
||||||
sum_a += a;
|
|
||||||
averaged_pixels++;
|
|
||||||
}
|
|
||||||
averaged_alpha++;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate the average from the sum and number of averaged pixels
|
|
||||||
dst_data[0] = (unsigned char)xs_CRoundToInt(sum_r / averaged_pixels);
|
|
||||||
dst_data[1] = (unsigned char)xs_CRoundToInt(sum_g / averaged_pixels);
|
|
||||||
dst_data[2] = (unsigned char)xs_CRoundToInt(sum_b / averaged_pixels);
|
|
||||||
dst_data[3] = (unsigned char)xs_CRoundToInt(sum_a / averaged_alpha);
|
|
||||||
dst_data += 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#define __GL_MATERIAL_H
|
#define __GL_MATERIAL_H
|
||||||
|
|
||||||
#include "m_fixed.h"
|
#include "m_fixed.h"
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
|
|
||||||
#include "r_defs.h"
|
#include "r_defs.h"
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "r_state.h"
|
#include "r_state.h"
|
||||||
#include "actor.h"
|
#include "actor.h"
|
||||||
#include "r_data/models/models.h"
|
#include "r_data/models/models.h"
|
||||||
#include "textures/skyboxtexture.h"
|
#include "skyboxtexture.h"
|
||||||
#include "hwrenderer/textures/hw_material.h"
|
#include "hwrenderer/textures/hw_material.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#define DIRECT_PALETTE -2
|
#define DIRECT_PALETTE -2
|
||||||
|
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "hwrenderer/textures/hw_ihwtexture.h"
|
#include "hw_ihwtexture.h"
|
||||||
#include "volk/volk.h"
|
#include "volk/volk.h"
|
||||||
|
|
||||||
struct FMaterialState;
|
struct FMaterialState;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#ifndef __R_SKY_H__
|
#ifndef __R_SKY_H__
|
||||||
#define __R_SKY_H__
|
#define __R_SKY_H__
|
||||||
|
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
|
|
||||||
struct FLevelLocals;
|
struct FLevelLocals;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#include "scene/r_opaque_pass.h"
|
#include "scene/r_opaque_pass.h"
|
||||||
#include "scene/r_3dfloors.h"
|
#include "scene/r_3dfloors.h"
|
||||||
#include "scene/r_portal.h"
|
#include "scene/r_portal.h"
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
#include "r_data/voxels.h"
|
#include "r_data/voxels.h"
|
||||||
#include "drawers/r_draw_rgba.h"
|
#include "drawers/r_draw_rgba.h"
|
||||||
#include "p_setup.h"
|
#include "p_setup.h"
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hwrenderer/textures/hw_ihwtexture.h"
|
#include "hw_ihwtexture.h"
|
||||||
#include "hwrenderer/textures/hw_material.h"
|
#include "hwrenderer/textures/hw_material.h"
|
||||||
#include "swrenderer/r_renderer.h"
|
#include "swrenderer/r_renderer.h"
|
||||||
#include "r_swscene.h"
|
#include "r_swscene.h"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "textures/textures.h"
|
#include "textures.h"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#define DIRECT_PALETTE -2
|
#define DIRECT_PALETTE -2
|
||||||
|
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "hwrenderer/textures/hw_ihwtexture.h"
|
#include "hw_ihwtexture.h"
|
||||||
#include "volk/volk.h"
|
#include "volk/volk.h"
|
||||||
#include "vk_imagetransition.h"
|
#include "vk_imagetransition.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue