From 69eac1f37fed01175c843d0d409986161979a96b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 2 Oct 2019 00:17:22 +0200 Subject: [PATCH] - added a texture that can display the start screen Needed to experiment with this part of the engine. At the moment this only compiles on Windows because the other platforms do not have the needed backing code. --- src/CMakeLists.txt | 11 +- .../textures/formats/startscreentexture.cpp | 113 ++++++++++++++++++ src/posix/cocoa/st_start.mm | 16 --- src/{win32 => }/st_start_util.cpp | 18 +++ 4 files changed, 137 insertions(+), 21 deletions(-) create mode 100644 src/gamedata/textures/formats/startscreentexture.cpp rename src/{win32 => }/st_start_util.cpp (98%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a82fdd2d1e0..23133b604c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -500,16 +500,15 @@ set( PLAT_WIN32_SOURCES win32/i_system.cpp win32/i_specialpaths.cpp win32/st_start.cpp - win32/st_start_util.cpp win32/gl_sysfb.cpp win32/base_sysfb.cpp win32/win32basevideo.cpp win32/win32glvideo.cpp) - + if (HAVE_VULKAN) set (PLAT_WIN32_SOURCES ${PLAT_WIN32_SOURCES} win32/win32vulkanvideo.cpp ) endif() - + set( PLAT_POSIX_SOURCES posix/i_steam.cpp ) set( PLAT_SDL_SOURCES @@ -839,7 +838,7 @@ set( FASTMATH_SOURCES r_data/models/models.cpp utility/matrix.cpp ) - + #Vulkan stuff must go into a separate list later because it needs to be disabled for some platforms set (VULKAN_SOURCES rendering/vulkan/system/vk_device.cpp @@ -934,6 +933,7 @@ set (PCH_SOURCES serializer.cpp scriptutil.cpp st_stuff.cpp + st_start_util.cpp rendering/v_framebuffer.cpp r_data/v_palette.cpp rendering/v_video.cpp @@ -1090,6 +1090,7 @@ set (PCH_SOURCES gamedata/textures/formats/emptytexture.cpp gamedata/textures/formats/shadertexture.cpp gamedata/textures/formats/tgatexture.cpp + gamedata/textures/formats/startscreentexture.cpp gamedata/textures/hires/hqresize.cpp gamedata/textures/hires/hirestex.cpp gamedata/fonts/singlelumpfont.cpp @@ -1098,7 +1099,7 @@ set (PCH_SOURCES gamedata/fonts/font.cpp gamedata/fonts/hexfont.cpp gamedata/fonts/v_font.cpp - gamedata/fonts/v_text.cpp + gamedata/fonts/v_text.cpp gamedata/p_xlat.cpp gamedata/xlat/parse_xlat.cpp gamedata/xlat/parsecontext.cpp diff --git a/src/gamedata/textures/formats/startscreentexture.cpp b/src/gamedata/textures/formats/startscreentexture.cpp new file mode 100644 index 00000000000..b3305808c69 --- /dev/null +++ b/src/gamedata/textures/formats/startscreentexture.cpp @@ -0,0 +1,113 @@ +/* +** startscreentexture.cpp +** Texture class to create a texture from the start screen's imagé +** +**--------------------------------------------------------------------------- +** Copyright 2004-2006 Randy Heit +** Copyright 2019 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 "doomtype.h" +#include "files.h" +#include "w_wad.h" +#include "gi.h" +#include "bitmap.h" +#include "textures/textures.h" +#include "imagehelpers.h" +#include "image.h" +#include "st_start.h" + + +//========================================================================== +// +// +// +//========================================================================== + +class FStartScreenTexture : public FImageSource +{ + BitmapInfo *info; // This must remain constant for the lifetime of this texture + +public: + FStartScreenTexture (BitmapInfo *srcdata); + int CopyPixels(FBitmap *bmp, int conversion) override; +}; + +//========================================================================== +// +// +// +//========================================================================== + +FImageSource *CreateStartScreenTexture(BitmapInfo *srcdata) +{ + return new FStartScreenTexture(srcdata); +} + + +//========================================================================== +// +// +// +//========================================================================== + +FStartScreenTexture::FStartScreenTexture (BitmapInfo *srcdata) +: FImageSource(-1) +{ + Width = srcdata->bmiHeader.biWidth; + Height = srcdata->bmiHeader.biHeight; + info = srcdata; + bUseGamePalette = false; + +} + +//========================================================================== +// +// +// +//========================================================================== + +int FStartScreenTexture::CopyPixels(FBitmap *bmp, int conversion) +{ + const RgbQuad *psource = info->bmiColors; + PalEntry paldata[256] = {}; + auto pixels = ST_Util_BitsForBitmap(info); + for (uint32_t i = 0; i < info->bmiHeader.biClrUsed; i++) + { + PalEntry &pe = paldata[i]; + pe.r = psource[i].rgbRed; + pe.g = psource[i].rgbGreen; + pe.b = psource[i].rgbBlue; + pe.a = 255; + } + bmp->CopyPixelData(0, 0, pixels, Width, Height, 1, (Width + 3) & ~3, 0, paldata); + + return 0; +} diff --git a/src/posix/cocoa/st_start.mm b/src/posix/cocoa/st_start.mm index 508cdf0bfe0..e85a61f999f 100644 --- a/src/posix/cocoa/st_start.mm +++ b/src/posix/cocoa/st_start.mm @@ -60,22 +60,6 @@ // --------------------------------------------------------------------------- -class FBasicStartupScreen : public FStartupScreen -{ -public: - FBasicStartupScreen(int maxProgress, bool showBar); - ~FBasicStartupScreen(); - - virtual void Progress(); - - virtual void NetInit(const char* message, int playerCount); - virtual void NetProgress(int count); - virtual void NetMessage(const char *format, ...); - virtual void NetDone(); - virtual bool NetLoop(bool (*timerCallback)(void*), void* userData); -}; - - FBasicStartupScreen::FBasicStartupScreen(int maxProgress, bool showBar) : FStartupScreen(maxProgress) { diff --git a/src/win32/st_start_util.cpp b/src/st_start_util.cpp similarity index 98% rename from src/win32/st_start_util.cpp rename to src/st_start_util.cpp index 7a0593b73b7..d6c52523872 100644 --- a/src/win32/st_start_util.cpp +++ b/src/st_start_util.cpp @@ -42,6 +42,8 @@ #include "s_sound.h" #include "s_music.h" #include "d_main.h" +#include "textures.h" +#include "image.h" void I_GetEvent(); // i_input.h pulls in too much garbage. @@ -308,6 +310,7 @@ static const uint16_t IBM437ToUnicode[] = { }; BitmapInfo* StartupBitmap; +FTexture * StartupTexture; // Hexen startup screen #define ST_MAX_NOTCHES 32 @@ -392,6 +395,21 @@ static const int StrifeStartupPicSizes[4 + 2 + 1] = 2304 }; +FImageSource *CreateStartScreenTexture(BitmapInfo *srcdata); + +void InvalidateTexture() +{ + if (StartupTexture == nullptr) + { + auto imgsource = CreateStartScreenTexture(StartupBitmap); + StartupTexture = new FImageTexture(imgsource); + StartupTexture->SetUseType(ETextureType::Override); + } + else + { + StartupTexture->SystemTextures.Clean(true, true); + } +} //========================================================================== //