diff --git a/.gitignore b/.gitignore index cfa4882e6..ed486271a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ /Release /wadsrc_wad *.user +/build /debug /release */debug @@ -37,3 +38,6 @@ /jpeg-6b/x64/ /lzma/x64/ /zlib/x64/ +/build_vc2013_64bit +/build_vc2015 +build_cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e375a2df..197593646 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required( VERSION 2.4 ) -project(ZDoom) +project(GZDoom) if( COMMAND cmake_policy ) if( POLICY CMP0011 ) @@ -78,7 +78,7 @@ IF( NOT CMAKE_BUILD_TYPE ) ENDIF( NOT CMAKE_BUILD_TYPE ) set( ZDOOM_OUTPUT_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Directory where zdoom.pk3 and the executable will be created." ) -set( ZDOOM_EXE_NAME "zdoom" CACHE FILEPATH "Name of the executable to create." ) +set( ZDOOM_EXE_NAME "gzdoom" CACHE FILEPATH "Name of the executable to create" ) if( MSVC ) # Allow the user to use ZDOOM_OUTPUT_DIR as a single release point. # Use zdoom, zdoomd, zdoom64, and zdoomd64 for the binary names @@ -113,7 +113,7 @@ find_package( BZip2 ) find_package( JPEG ) find_package( ZLIB ) # GME -find_path( GME_INCLUDE_DIR gme.h ) +find_path( GME_INCLUDE_DIR gme/gme.h ) find_library( GME_LIBRARIES gme ) mark_as_advanced( GME_INCLUDE_DIR GME_LIBRARIES ) FIND_PACKAGE_HANDLE_STANDARD_ARGS( GME @@ -128,7 +128,8 @@ if( MSVC ) # String pooling # Function-level linking # Disable run-time type information - set( ALL_C_FLAGS "/GF /Gy /GR-" ) + # Set floating point model to fast or the GL render will suffer for it. + set( ALL_C_FLAGS "/GF /Gy /GR- /fp:fast" ) if( CMAKE_SIZEOF_VOID_P MATCHES "4") # SSE2 option (mostly to switch it off in VC2012 and later where it's the default @@ -250,6 +251,8 @@ add_subdirectory( tools ) add_subdirectory( dumb ) add_subdirectory( gdtoa ) add_subdirectory( wadsrc ) +add_subdirectory( wadsrc_bm ) +add_subdirectory( wadsrc_lights ) add_subdirectory( src ) if( NOT WIN32 AND NOT APPLE ) diff --git a/bzip2/bzip2.vcproj b/bzip2/bzip2.vcproj index 72510949d..4b8aef564 100644 --- a/bzip2/bzip2.vcproj +++ b/bzip2/bzip2.vcproj @@ -1,11 +1,12 @@ - @@ -402,6 +402,8 @@ /> - @@ -602,10 +601,6 @@ RelativePath=".\gme\Spc_Emu.cpp" > - - @@ -708,10 +703,6 @@ RelativePath=".\gme\Gme_File.h" > - - @@ -832,10 +823,6 @@ RelativePath=".\gme\Spc_Emu.h" > - - diff --git a/gdtoa/gdtoa.vcproj b/gdtoa/gdtoa.vcproj index 3ac6ce39d..12a3e40b3 100644 --- a/gdtoa/gdtoa.vcproj +++ b/gdtoa/gdtoa.vcproj @@ -1,11 +1,12 @@ + int main(void) { __m64 v = _m_from_int(0); }" + HAVE_MMX) + + set( CMAKE_CXX_FLAGS ${SAFE_CMAKE_CXX_FLAGS} ) +endif( X64 ) + # Set up flags for GCC if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) @@ -587,6 +616,7 @@ set( PLAT_WIN32_SOURCES win32/i_movie.cpp win32/i_system.cpp win32/st_start.cpp + win32/win32gliface.cpp win32/win32video.cpp ) set( PLAT_POSIX_SOURCES posix/i_cd.cpp @@ -602,7 +632,8 @@ set( PLAT_SDL_SOURCES posix/sdl/i_joystick.cpp posix/sdl/i_main.cpp posix/sdl/i_timer.cpp - posix/sdl/sdlvideo.cpp ) + posix/sdl/sdlvideo.cpp + posix/sdl/sdlglvideo.cpp ) set( PLAT_OSX_SOURCES posix/osx/iwadpicker_cocoa.mm posix/osx/zdoom.icns ) @@ -650,6 +681,25 @@ else( WIN32 ) set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} ) endif( WIN32 ) +if( HAVE_MMX ) + add_definitions( -DHAVE_MMX=1 ) + + set( SYSTEM_SOURCES ${SYSTEM_SOURCES} + gl/hqnx_asm/hq2x_asm.cpp + gl/hqnx_asm/hq3x_asm.cpp + gl/hqnx_asm/hq4x_asm.cpp + gl/hqnx_asm/hqnx_asm_Image.cpp) + + if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + set_source_files_properties( + gl/hqnx_asm/hq2x_asm.cpp + gl/hqnx_asm/hq3x_asm.cpp + gl/hqnx_asm/hq4x_asm.cpp + gl/textures/gl_hqresize.cpp + PROPERTIES COMPILE_FLAGS "-mmmx" ) + endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) +endif( HAVE_MMX ) + if( NOT ASM_SOURCES ) set( ASM_SOURCES "" ) endif( NOT ASM_SOURCES ) @@ -740,6 +790,20 @@ file( GLOB HEADER_FILES textures/*.h thingdef/*.h xlat/*.h + gl/*.h + gl/api/*.h + gl/data/*.h + gl/dynlights/*.h + gl/hqnx/*.h + gl/hqnx_asm/*.h + gl/models/*.h + gl/renderer/*.h + gl/scene/*.h + gl/stereo3d/*.h + gl/shaders/*.h + gl/system/*.h + gl/textures/*.h + gl/utility/*.h *.h ) @@ -1056,6 +1120,68 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE menu/playermenu.cpp menu/readthis.cpp menu/videomenu.cpp + gl/data/gl_data.cpp + gl/data/gl_portaldata.cpp + gl/data/gl_setup.cpp + gl/data/gl_matrix.cpp + gl/data/gl_vertexbuffer.cpp + gl/dynlights/a_dynlight.cpp + gl/utility/gl_clock.cpp + gl/utility/gl_cycler.cpp + gl/utility/gl_geometric.cpp + gl/renderer/gl_renderer.cpp + gl/renderer/gl_renderstate.cpp + gl/renderer/gl_lightdata.cpp + gl/hqnx/init.cpp + gl/hqnx/hq2x.cpp + gl/hqnx/hq3x.cpp + gl/hqnx/hq4x.cpp + gl/textures/gl_hwtexture.cpp + gl/textures/gl_texture.cpp + gl/textures/gl_material.cpp + gl/textures/gl_hirestex.cpp + gl/textures/gl_bitmap.cpp + gl/textures/gl_samplers.cpp + gl/textures/gl_translate.cpp + gl/textures/gl_hqresize.cpp + gl/textures/gl_skyboxtexture.cpp + gl/scene/gl_bsp.cpp + gl/scene/gl_fakeflat.cpp + gl/scene/gl_clipper.cpp + gl/scene/gl_decal.cpp + gl/scene/gl_drawinfo.cpp + gl/scene/gl_flats.cpp + gl/scene/gl_walls.cpp + gl/scene/gl_sprite.cpp + gl/scene/gl_skydome.cpp + gl/scene/gl_renderhacks.cpp + gl/scene/gl_weapon.cpp + gl/scene/gl_scene.cpp + gl/scene/gl_sky.cpp + gl/scene/gl_portal.cpp + gl/scene/gl_walls_draw.cpp + gl/scene/gl_vertex.cpp + gl/scene/gl_spritelight.cpp + gl/stereo3d/gl_stereo3d.cpp + gl/stereo3d/gl_stereo_cvars.cpp + gl/stereo3d/gl_stereo_leftright.cpp + gl/stereo3d/scoped_view_shifter.cpp + gl/stereo3d/gl_anaglyph.cpp + gl/dynlights/gl_dynlight.cpp + gl/dynlights/gl_glow.cpp + gl/dynlights/gl_dynlight1.cpp + gl/dynlights/gl_lightbuffer.cpp + gl/shaders/gl_shader.cpp + gl/shaders/gl_texshader.cpp + gl/system/gl_interface.cpp + gl/system/gl_framebuffer.cpp + gl/system/gl_menu.cpp + gl/system/gl_wipe.cpp + gl/system/gl_load.c + gl/models/gl_models_md3.cpp + gl/models/gl_models_md2.cpp + gl/models/gl_models.cpp + gl/models/gl_voxels.cpp oplsynth/fmopl.cpp oplsynth/mlopl.cpp oplsynth/mlopl_io.cpp @@ -1292,6 +1418,19 @@ source_group("Games\\Raven Shared" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_D source_group("Games\\Strife Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_strife/.+") source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+") source_group("Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/menu/.+") +source_group("OpenGL Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/.+") +source_group("OpenGL Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/data/.+") +source_group("OpenGL Renderer\\Dynamic Lights" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/dynlights/.+") +source_group("OpenGL Renderer\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx/.+") +source_group("OpenGL Renderer\\HQ Resize Assembly version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx_asm/.+") +source_group("OpenGL Renderer\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/models/.+") +source_group("OpenGL Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/renderer/.+") +source_group("OpenGL Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/scene/.+") +source_group("OpenGL Renderer\\Stereo3D" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/stereo3d/.+") +source_group("OpenGL Renderer\\Shaders" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/shaders/.+") +source_group("OpenGL Renderer\\System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/system/.+") +source_group("OpenGL Renderer\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/textures/.+") +source_group("OpenGL Renderer\\Utilities" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/utility/.+") source_group("Render Core\\Render Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_.+\\.h$") source_group("Render Core\\Render Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_.+\\.cpp$") source_group("Render Data\\Resource Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/.+\\.h$") diff --git a/src/actor.h b/src/actor.h index cb0524587..c9a4436ea 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1099,6 +1099,14 @@ public: } bool HasSpecialDeathStates () const; + + // begin of GZDoom specific additions + TArray > dynamiclights; + void * lightassociations; + bool hasmodel; + // end of GZDoom specific additions + + size_t PropagateMark(); }; class FActorIterator diff --git a/src/g_level.cpp b/src/g_level.cpp index 03474a5b7..be1adb322 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1449,12 +1449,14 @@ void G_AirControlChanged () // // //========================================================================== +void gl_SerializeGlobals(FArchive &arc); void G_SerializeLevel (FArchive &arc, bool hubLoad) { int i = level.totaltime; Renderer->StartSerialize(arc); + gl_SerializeGlobals(arc); arc << level.flags << level.flags2 diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp new file mode 100644 index 000000000..182b818b3 --- /dev/null +++ b/src/gl/data/gl_data.cpp @@ -0,0 +1,539 @@ +/* +** gl_data.cpp +** Maintenance data for GL renderer (mostly to handle rendering hacks) +** +**--------------------------------------------------------------------------- +** Copyright 2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" + +#include "doomtype.h" +#include "colormatcher.h" +#include "i_system.h" +#include "p_local.h" +#include "p_lnspec.h" +#include "c_dispatch.h" +#include "r_sky.h" +#include "sc_man.h" +#include "w_wad.h" +#include "gi.h" +#include "g_level.h" + +#include "gl/system/gl_interface.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/models/gl_models.h" +#include "gl/utility/gl_clock.h" +#include "gl/shaders/gl_shader.h" +#include "gl/gl_functions.h" + +GLRenderSettings glset; +long gl_frameMS; +long gl_frameCount; + +EXTERN_CVAR(Int, gl_lightmode) +EXTERN_CVAR(Bool, gl_brightfog) + +CUSTOM_CVAR(Float, maxviewpitch, 90.f, CVAR_ARCHIVE|CVAR_SERVERINFO) +{ + if (self>90.f) self=90.f; + else if (self<-90.f) self=-90.f; +} + +CUSTOM_CVAR(Bool, gl_notexturefill, false, 0) +{ + glset.notexturefill = self; +} + + +CUSTOM_CVAR(Bool, gl_nocoloredspritelighting, false, 0) +{ + glset.nocoloredspritelighting = self; +} + +void gl_CreateSections(); + +//----------------------------------------------------------------------------- +// +// Adjust sprite offsets for GL rendering (IWAD resources only) +// +//----------------------------------------------------------------------------- + +void AdjustSpriteOffsets() +{ + static bool done=false; + char name[30]; + + if (done) return; + done=true; + + mysnprintf(name, countof(name), "sprofs/%s.sprofs", GameNames[gameinfo.gametype]); + int lump = Wads.CheckNumForFullName(name); + if (lump>=0) + { + FScanner sc; + sc.OpenLumpNum(lump); + GLRenderer->FlushTextures(); + int ofslumpno = Wads.GetLumpFile(lump); + while (sc.GetString()) + { + int x,y; + FTextureID texno = TexMan.CheckForTexture(sc.String, FTexture::TEX_Sprite); + sc.GetNumber(); + x=sc.Number; + sc.GetNumber(); + y=sc.Number; + + if (texno.isValid()) + { + FTexture * tex = TexMan[texno]; + + int lumpnum = tex->GetSourceLump(); + // We only want to change texture offsets for sprites in the IWAD or the file this lump originated from. + if (lumpnum >= 0 && lumpnum < Wads.GetNumLumps()) + { + int wadno = Wads.GetLumpFile(lumpnum); + if (wadno==FWadCollection::IWAD_FILENUM || wadno == ofslumpno) + { + tex->LeftOffset=x; + tex->TopOffset=y; + tex->KillNative(); + } + } + } + } + } +} + + + +// Normally this would be better placed in p_lnspec.cpp. +// But I have accidentally overwritten that file several times +// so I'd rather place it here. +static int LS_Sector_SetPlaneReflection (line_t *ln, AActor *it, bool backSide, + int arg0, int arg1, int arg2, int arg3, int arg4) +{ +// Sector_SetPlaneReflection (tag, floor, ceiling) + int secnum; + FSectorTagIterator itr(arg0); + + while ((secnum = itr.Next()) >= 0) + { + sector_t * s = §ors[secnum]; + if (s->floorplane.a==0 && s->floorplane.b==0) s->reflect[sector_t::floor] = arg1/255.f; + if (s->ceilingplane.a==0 && s->ceilingplane.b==0) sectors[secnum].reflect[sector_t::ceiling] = arg2/255.f; + } + + return true; +} + +static int LS_SetGlobalFogParameter (line_t *ln, AActor *it, bool backSide, + int arg0, int arg1, int arg2, int arg3, int arg4) +{ +// SetGlobalFogParameter (type, value) + switch(arg0) + { + case 0: + fogdensity = arg1>>1; + return true; + + case 1: + outsidefogdensity = arg1>>1; + return true; + + case 2: + skyfog = arg1; + return true; + + default: + return false; + } +} + + +//========================================================================== +// +// Portal identifier lists +// +//========================================================================== + + +//========================================================================== +// +// MAPINFO stuff +// +//========================================================================== + +struct FGLROptions : public FOptionalMapinfoData +{ + FGLROptions() + { + identifier = "gl_renderer"; + fogdensity = 0; + outsidefogdensity = 0; + skyfog = 0; + brightfog = false; + lightmode = -1; + nocoloredspritelighting = -1; + notexturefill = -1; + skyrotatevector = FVector3(0,0,1); + skyrotatevector2 = FVector3(0,0,1); + pixelstretch = 1.2f; + } + virtual FOptionalMapinfoData *Clone() const + { + FGLROptions *newopt = new FGLROptions; + newopt->identifier = identifier; + newopt->fogdensity = fogdensity; + newopt->outsidefogdensity = outsidefogdensity; + newopt->skyfog = skyfog; + newopt->lightmode = lightmode; + newopt->nocoloredspritelighting = nocoloredspritelighting; + newopt->notexturefill = notexturefill; + newopt->skyrotatevector = skyrotatevector; + newopt->skyrotatevector2 = skyrotatevector2; + newopt->pixelstretch = pixelstretch; + return newopt; + } + int fogdensity; + int outsidefogdensity; + int skyfog; + int lightmode; + int brightfog; + SBYTE nocoloredspritelighting; + SBYTE notexturefill; + FVector3 skyrotatevector; + FVector3 skyrotatevector2; + float pixelstretch; +}; + +DEFINE_MAP_OPTION(fogdensity, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + parse.ParseAssign(); + parse.sc.MustGetNumber(); + opt->fogdensity = parse.sc.Number; +} + +DEFINE_MAP_OPTION(brightfog, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + parse.ParseAssign(); + parse.sc.MustGetNumber(); + opt->brightfog = parse.sc.Number; +} + +DEFINE_MAP_OPTION(outsidefogdensity, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + parse.ParseAssign(); + parse.sc.MustGetNumber(); + opt->outsidefogdensity = parse.sc.Number; +} + +DEFINE_MAP_OPTION(skyfog, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + parse.ParseAssign(); + parse.sc.MustGetNumber(); + opt->skyfog = parse.sc.Number; +} + +DEFINE_MAP_OPTION(lightmode, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + parse.ParseAssign(); + parse.sc.MustGetNumber(); + opt->lightmode = BYTE(parse.sc.Number); +} + +DEFINE_MAP_OPTION(nocoloredspritelighting, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + if (parse.CheckAssign()) + { + parse.sc.MustGetNumber(); + opt->nocoloredspritelighting = !!parse.sc.Number; + } + else + { + opt->nocoloredspritelighting = true; + } +} + +DEFINE_MAP_OPTION(notexturefill, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + if (parse.CheckAssign()) + { + parse.sc.MustGetNumber(); + opt->notexturefill = !!parse.sc.Number; + } + else + { + opt->notexturefill = true; + } +} + +DEFINE_MAP_OPTION(skyrotate, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + + parse.ParseAssign(); + parse.sc.MustGetFloat(); + opt->skyrotatevector.X = (float)parse.sc.Float; + if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(","); + parse.sc.MustGetFloat(); + opt->skyrotatevector.Y = (float)parse.sc.Float; + if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(","); + parse.sc.MustGetFloat(); + opt->skyrotatevector.Z = (float)parse.sc.Float; + opt->skyrotatevector.MakeUnit(); +} + +DEFINE_MAP_OPTION(skyrotate2, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + + parse.ParseAssign(); + parse.sc.MustGetFloat(); + opt->skyrotatevector2.X = (float)parse.sc.Float; + if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(","); + parse.sc.MustGetFloat(); + opt->skyrotatevector2.Y = (float)parse.sc.Float; + if (parse.format_type == FMapInfoParser::FMT_New) parse.sc.MustGetStringName(","); + parse.sc.MustGetFloat(); + opt->skyrotatevector2.Z = (float)parse.sc.Float; + opt->skyrotatevector2.MakeUnit(); +} + +DEFINE_MAP_OPTION(pixelratio, false) +{ + FGLROptions *opt = info->GetOptData("gl_renderer"); + + parse.ParseAssign(); + parse.sc.MustGetFloat(); + opt->pixelstretch = (float)parse.sc.Float; +} + +bool IsLightmodeValid() +{ + return (glset.map_lightmode >= 0 && glset.map_lightmode <= 4) || glset.map_lightmode == 8; +} + +void InitGLRMapinfoData() +{ + FGLROptions *opt = level.info->GetOptData("gl_renderer", false); + + if (opt != NULL) + { + gl_SetFogParams(opt->fogdensity, level.info->outsidefog, opt->outsidefogdensity, opt->skyfog); + glset.map_lightmode = opt->lightmode; + glset.map_brightfog = opt->brightfog; + glset.map_nocoloredspritelighting = opt->nocoloredspritelighting; + glset.map_notexturefill = opt->notexturefill; + glset.skyrotatevector = opt->skyrotatevector; + glset.skyrotatevector2 = opt->skyrotatevector2; + glset.pixelstretch = opt->pixelstretch; + } + else + { + gl_SetFogParams(0, level.info->outsidefog, 0, 0); + glset.map_lightmode = -1; + glset.map_brightfog = -1; + glset.map_nocoloredspritelighting = -1; + glset.map_notexturefill = -1; + glset.skyrotatevector = FVector3(0,0,1); + glset.skyrotatevector2 = FVector3(0,0,1); + glset.pixelstretch = 1.2f; + } + + if (!IsLightmodeValid()) glset.lightmode = gl_lightmode; + else glset.lightmode = glset.map_lightmode; + if (glset.map_nocoloredspritelighting == -1) glset.nocoloredspritelighting = gl_nocoloredspritelighting; + else glset.nocoloredspritelighting = !!glset.map_nocoloredspritelighting; + if (glset.map_notexturefill == -1) glset.notexturefill = gl_notexturefill; + else glset.notexturefill = !!glset.map_notexturefill; + if (glset.map_brightfog == -1) glset.brightfog = gl_brightfog; + else glset.brightfog = !!glset.map_brightfog; +} + +CCMD(gl_resetmap) +{ + if (!IsLightmodeValid()) glset.lightmode = gl_lightmode; + else glset.lightmode = glset.map_lightmode; + if (glset.map_nocoloredspritelighting == -1) glset.nocoloredspritelighting = gl_nocoloredspritelighting; + else glset.nocoloredspritelighting = !!glset.map_nocoloredspritelighting; + if (glset.map_notexturefill == -1) glset.notexturefill = gl_notexturefill; + else glset.notexturefill = !!glset.map_notexturefill; + if (glset.map_brightfog == -1) glset.brightfog = gl_brightfog; + else glset.brightfog = !!glset.map_brightfog; +} + + +//=========================================================================== +// +// Gets the texture index for a sprite frame +// +//=========================================================================== + +FTextureID gl_GetSpriteFrame(unsigned sprite, int frame, int rot, angle_t ang, bool *mirror) +{ + spritedef_t *sprdef = &sprites[sprite]; + if (frame >= sprdef->numframes) + { + // If there are no frames at all for this sprite, don't draw it. + return FNullTextureID(); + } + else + { + //picnum = SpriteFrames[sprdef->spriteframes + thing->frame].Texture[0]; + // choose a different rotation based on player view + spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + frame]; + if (rot==-1) + { + if (sprframe->Texture[0] == sprframe->Texture[1]) + { + rot = (ang + (angle_t)(ANGLE_45/2)*9) >> 28; + } + else + { + rot = (ang + (angle_t)(ANGLE_45/2)*9-(angle_t)(ANGLE_180/16)) >> 28; + } + } + if (mirror) *mirror = !!(sprframe->Flip&(1<Texture[rot]; + } +} + + +//========================================================================== +// +// Recalculate all heights affectting this vertex. +// +//========================================================================== +void gl_RecalcVertexHeights(vertex_t * v) +{ + int i,j,k; + float height; + + v->numheights=0; + for(i=0;inumsectors;i++) + { + for(j=0;j<2;j++) + { + if (j==0) height=FIXED2FLOAT(v->sectors[i]->ceilingplane.ZatPoint(v)); + else height=FIXED2FLOAT(v->sectors[i]->floorplane.ZatPoint(v)); + + for(k=0;knumheights;k++) + { + if (height == v->heightlist[k]) break; + if (height < v->heightlist[k]) + { + memmove(&v->heightlist[k+1], &v->heightlist[k], sizeof(float) * (v->numheights-k)); + v->heightlist[k]=height; + v->numheights++; + break; + } + } + if (k==v->numheights) v->heightlist[v->numheights++]=height; + } + } + if (v->numheights<=2) v->numheights=0; // is not in need of any special attention + v->dirty = false; +} + + + + +void gl_InitData() +{ + LineSpecials[157] = LS_SetGlobalFogParameter; + LineSpecials[159] = LS_Sector_SetPlaneReflection; + AdjustSpriteOffsets(); +} + +//========================================================================== +// +// dumpgeometry +// +//========================================================================== + +CCMD(dumpgeometry) +{ + for(int i=0;isubsectorcount;j++) + { + subsector_t * sub = sector->subsectors[j]; + + Printf(PRINT_LOG, " Subsector %d - real sector = %d - %s\n", int(sub-subsectors), sub->sector->sectornum, sub->hacked&1? "hacked":""); + for(DWORD k=0;knumlines;k++) + { + seg_t * seg = sub->firstline + k; + if (seg->linedef) + { + Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, linedef %d, side %d", + FIXED2FLOAT(seg->v1->x), FIXED2FLOAT(seg->v1->y), FIXED2FLOAT(seg->v2->x), FIXED2FLOAT(seg->v2->y), + int(seg-segs), int(seg->linedef-lines), seg->sidedef != seg->linedef->sidedef[0]); + } + else + { + Printf(PRINT_LOG, " (%4.4f, %4.4f), (%4.4f, %4.4f) - seg %d, miniseg", + FIXED2FLOAT(seg->v1->x), FIXED2FLOAT(seg->v1->y), FIXED2FLOAT(seg->v2->x), FIXED2FLOAT(seg->v2->y), + int(seg-segs)); + } + if (seg->PartnerSeg) + { + subsector_t * sub2 = seg->PartnerSeg->Subsector; + Printf(PRINT_LOG, ", back sector = %d, real back sector = %d", sub2->render_sector->sectornum, seg->PartnerSeg->frontsector->sectornum); + } + else if (seg->backsector) + { + Printf(PRINT_LOG, ", back sector = %d (no partnerseg)", seg->backsector->sectornum); + } + + Printf(PRINT_LOG, "\n"); + } + } + } +} diff --git a/src/gl/data/gl_data.h b/src/gl/data/gl_data.h new file mode 100644 index 000000000..ac2fe0285 --- /dev/null +++ b/src/gl/data/gl_data.h @@ -0,0 +1,66 @@ + +#ifndef __GLC_DATA_H +#define __GLC_DATA_H + +#include "doomtype.h" + +struct GLRenderSettings +{ + + SBYTE lightmode; + bool nocoloredspritelighting; + bool notexturefill; + bool brightfog; + + SBYTE map_lightmode; + SBYTE map_nocoloredspritelighting; + SBYTE map_notexturefill; + SBYTE map_brightfog; + + FVector3 skyrotatevector; + FVector3 skyrotatevector2; + + float pixelstretch; + +}; + +extern GLRenderSettings glset; + +#include "r_defs.h" +#include "a_sharedglobal.h" +#include "c_cvars.h" + +extern int extralight; +EXTERN_CVAR(Int, gl_weaponlight); + +inline int getExtraLight() +{ + return extralight * gl_weaponlight; +} + +void gl_RecalcVertexHeights(vertex_t * v); +FTextureID gl_GetSpriteFrame(unsigned sprite, int frame, int rot, angle_t ang, bool *mirror); + +class AStackPoint; +struct GLSectorStackPortal; + +struct FPortal +{ + fixed_t xDisplacement; + fixed_t yDisplacement; + int plane; + GLSectorStackPortal *glportal; // for quick access to the render data. This is only valid during BSP traversal! + + GLSectorStackPortal *GetGLPortal(); +}; + +extern TArray portals; +extern TArray currentmapsection; + +void gl_InitPortals(); +void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, FPortal *portal); +void gl_InitData(); + +extern long gl_frameMS; + +#endif diff --git a/src/gl/data/gl_matrix.cpp b/src/gl/data/gl_matrix.cpp new file mode 100644 index 000000000..35683dbb8 --- /dev/null +++ b/src/gl/data/gl_matrix.cpp @@ -0,0 +1,495 @@ +/* -------------------------------------------------- + +Lighthouse3D + +VSMatrix - Very Simple Matrix Library + +http://www.lighthouse3d.com/very-simple-libs + +This is a simplified version of VSMatrix that has been adjusted for GZDoom's needs. + +----------------------------------------------------*/ + +#include "gl/system/gl_system.h" +#include +#include +#include +#include +#include "doomtype.h" +#include "gl/data/gl_matrix.h" + +static inline FLOATTYPE +DegToRad(FLOATTYPE degrees) +{ + return (FLOATTYPE)(degrees * (M_PI / 180.0f)); +}; + +// sets the square matrix mat to the identity matrix, +// size refers to the number of rows (or columns) +void +VSMatrix::setIdentityMatrix( FLOATTYPE *mat, int size) { + + // fill matrix with 0s + for (int i = 0; i < size * size; ++i) + mat[i] = 0.0f; + + // fill diagonal with 1s + for (int i = 0; i < size; ++i) + mat[i + i * size] = 1.0f; +} + + + +// gl LoadIdentity implementation +void +VSMatrix::loadIdentity() +{ + // fill matrix with 0s + for (int i = 0; i < 16; ++i) + mMatrix[i] = 0.0f; + + // fill diagonal with 1s + for (int i = 0; i < 4; ++i) + mMatrix[i + i * 4] = 1.0f; +} + + +// gl MultMatrix implementation +void +VSMatrix::multMatrix(const FLOATTYPE *aMatrix) +{ + + FLOATTYPE res[16]; + + for (int i = 0; i < 4; ++i) + { + for (int j = 0; j < 4; ++j) + { + res[j*4 + i] = 0.0f; + for (int k = 0; k < 4; ++k) + { + res[j*4 + i] += mMatrix[k*4 + i] * aMatrix[j*4 + k]; + } + } + } + memcpy(mMatrix, res, 16 * sizeof(FLOATTYPE)); +} + +#ifdef USE_DOUBLE +// gl MultMatrix implementation +void +VSMatrix::multMatrix(const float *aMatrix) +{ + + FLOATTYPE res[16]; + + for (int i = 0; i < 4; ++i) + { + for (int j = 0; j < 4; ++j) + { + res[j * 4 + i] = 0.0f; + for (int k = 0; k < 4; ++k) + { + res[j*4 + i] += mMatrix[k*4 + i] * aMatrix[j*4 + k]; + } + } + } + memcpy(mMatrix, res, 16 * sizeof(FLOATTYPE)); +} +#endif + + + +// gl LoadMatrix implementation +void +VSMatrix::loadMatrix(const FLOATTYPE *aMatrix) +{ + memcpy(mMatrix, aMatrix, 16 * sizeof(FLOATTYPE)); +} + +#ifdef USE_DOUBLE +// gl LoadMatrix implementation +void +VSMatrix::loadMatrix(const float *aMatrix) +{ + for (int i = 0; i < 16; ++i) + { + mMatrix[i] = aMatrix[i]; + } +} +#endif + + +// gl Translate implementation with matrix selection +void +VSMatrix::translate(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) +{ + FLOATTYPE mat[16]; + + setIdentityMatrix(mat); + mat[12] = x; + mat[13] = y; + mat[14] = z; + + multMatrix(mat); +} + + +// gl Scale implementation with matrix selection +void +VSMatrix::scale(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) +{ + FLOATTYPE mat[16]; + + setIdentityMatrix(mat,4); + mat[0] = x; + mat[5] = y; + mat[10] = z; + + multMatrix(mat); +} + + +// gl Rotate implementation with matrix selection +void +VSMatrix::rotate(FLOATTYPE angle, FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) +{ + FLOATTYPE mat[16]; + FLOATTYPE v[3]; + + v[0] = x; + v[1] = y; + v[2] = z; + + FLOATTYPE radAngle = DegToRad(angle); + FLOATTYPE co = cos(radAngle); + FLOATTYPE si = sin(radAngle); + normalize(v); + FLOATTYPE x2 = v[0]*v[0]; + FLOATTYPE y2 = v[1]*v[1]; + FLOATTYPE z2 = v[2]*v[2]; + +// mat[0] = x2 + (y2 + z2) * co; + mat[0] = co + x2 * (1 - co);// + (y2 + z2) * co; + mat[4] = v[0] * v[1] * (1 - co) - v[2] * si; + mat[8] = v[0] * v[2] * (1 - co) + v[1] * si; + mat[12]= 0.0f; + + mat[1] = v[0] * v[1] * (1 - co) + v[2] * si; +// mat[5] = y2 + (x2 + z2) * co; + mat[5] = co + y2 * (1 - co); + mat[9] = v[1] * v[2] * (1 - co) - v[0] * si; + mat[13]= 0.0f; + + mat[2] = v[0] * v[2] * (1 - co) - v[1] * si; + mat[6] = v[1] * v[2] * (1 - co) + v[0] * si; +// mat[10]= z2 + (x2 + y2) * co; + mat[10]= co + z2 * (1 - co); + mat[14]= 0.0f; + + mat[3] = 0.0f; + mat[7] = 0.0f; + mat[11]= 0.0f; + mat[15]= 1.0f; + + multMatrix(mat); +} + + +// gluLookAt implementation +void +VSMatrix::lookAt(FLOATTYPE xPos, FLOATTYPE yPos, FLOATTYPE zPos, + FLOATTYPE xLook, FLOATTYPE yLook, FLOATTYPE zLook, + FLOATTYPE xUp, FLOATTYPE yUp, FLOATTYPE zUp) +{ + FLOATTYPE dir[3], right[3], up[3]; + + up[0] = xUp; up[1] = yUp; up[2] = zUp; + + dir[0] = (xLook - xPos); + dir[1] = (yLook - yPos); + dir[2] = (zLook - zPos); + normalize(dir); + + crossProduct(dir,up,right); + normalize(right); + + crossProduct(right,dir,up); + normalize(up); + + FLOATTYPE m1[16],m2[16]; + + m1[0] = right[0]; + m1[4] = right[1]; + m1[8] = right[2]; + m1[12] = 0.0f; + + m1[1] = up[0]; + m1[5] = up[1]; + m1[9] = up[2]; + m1[13] = 0.0f; + + m1[2] = -dir[0]; + m1[6] = -dir[1]; + m1[10] = -dir[2]; + m1[14] = 0.0f; + + m1[3] = 0.0f; + m1[7] = 0.0f; + m1[11] = 0.0f; + m1[15] = 1.0f; + + setIdentityMatrix(m2,4); + m2[12] = -xPos; + m2[13] = -yPos; + m2[14] = -zPos; + + multMatrix(m1); + multMatrix(m2); +} + + +// gluPerspective implementation +void +VSMatrix::perspective(FLOATTYPE fov, FLOATTYPE ratio, FLOATTYPE nearp, FLOATTYPE farp) +{ + FLOATTYPE f = 1.0f / tan (fov * (M_PI / 360.0f)); + + loadIdentity(); + mMatrix[0] = f / ratio; + mMatrix[1 * 4 + 1] = f; + mMatrix[2 * 4 + 2] = (farp + nearp) / (nearp - farp); + mMatrix[3 * 4 + 2] = (2.0f * farp * nearp) / (nearp - farp); + mMatrix[2 * 4 + 3] = -1.0f; + mMatrix[3 * 4 + 3] = 0.0f; +} + + +// gl Ortho implementation +void +VSMatrix::ortho(FLOATTYPE left, FLOATTYPE right, + FLOATTYPE bottom, FLOATTYPE top, + FLOATTYPE nearp, FLOATTYPE farp) +{ + loadIdentity(); + + mMatrix[0 * 4 + 0] = 2 / (right - left); + mMatrix[1 * 4 + 1] = 2 / (top - bottom); + mMatrix[2 * 4 + 2] = -2 / (farp - nearp); + mMatrix[3 * 4 + 0] = -(right + left) / (right - left); + mMatrix[3 * 4 + 1] = -(top + bottom) / (top - bottom); + mMatrix[3 * 4 + 2] = -(farp + nearp) / (farp - nearp); +} + + +// gl Frustum implementation +void +VSMatrix::frustum(FLOATTYPE left, FLOATTYPE right, + FLOATTYPE bottom, FLOATTYPE top, + FLOATTYPE nearp, FLOATTYPE farp) +{ + FLOATTYPE m[16]; + + setIdentityMatrix(m,4); + + m[0 * 4 + 0] = 2 * nearp / (right-left); + m[1 * 4 + 1] = 2 * nearp / (top - bottom); + m[2 * 4 + 0] = (right + left) / (right - left); + m[2 * 4 + 1] = (top + bottom) / (top - bottom); + m[2 * 4 + 2] = - (farp + nearp) / (farp - nearp); + m[2 * 4 + 3] = -1.0f; + m[3 * 4 + 2] = - 2 * farp * nearp / (farp-nearp); + m[3 * 4 + 3] = 0.0f; + + multMatrix(m); +} + + +/* +// returns a pointer to the requested matrix +FLOATTYPE * +VSMatrix::get(MatrixTypes aType) +{ + return mMatrix[aType]; +} +*/ + + +/* ----------------------------------------------------- + SEND MATRICES TO OPENGL +------------------------------------------------------*/ + + + + +// universal +void +VSMatrix::matrixToGL(int loc) +{ +#ifdef USE_DOUBLE + float copyto[16]; + copy(copyto); + glUniformMatrix4fv(loc, 1, false, copyto); +#else + glUniformMatrix4fv(loc, 1, false, mMatrix); +#endif +} + +// ----------------------------------------------------- +// AUX functions +// ----------------------------------------------------- + + +// Compute res = M * point +void +VSMatrix::multMatrixPoint(const FLOATTYPE *point, FLOATTYPE *res) +{ + + for (int i = 0; i < 4; ++i) + { + + res[i] = 0.0f; + + for (int j = 0; j < 4; j++) { + + res[i] += point[j] * mMatrix[j*4 + i]; + } + } +} + +// res = a cross b; +void +VSMatrix::crossProduct(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res) { + + res[0] = a[1] * b[2] - b[1] * a[2]; + res[1] = a[2] * b[0] - b[2] * a[0]; + res[2] = a[0] * b[1] - b[0] * a[1]; +} + + +// returns a . b +FLOATTYPE +VSMatrix::dotProduct(const FLOATTYPE *a, const FLOATTYPE *b) { + + FLOATTYPE res = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; + + return res; +} + + +// Normalize a vec3 +void +VSMatrix::normalize(FLOATTYPE *a) { + + FLOATTYPE mag = sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]); + + a[0] /= mag; + a[1] /= mag; + a[2] /= mag; +} + + +// res = b - a +void +VSMatrix::subtract(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res) { + + res[0] = b[0] - a[0]; + res[1] = b[1] - a[1]; + res[2] = b[2] - a[2]; +} + + +// res = a + b +void +VSMatrix::add(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res) { + + res[0] = b[0] + a[0]; + res[1] = b[1] + a[1]; + res[2] = b[2] + a[2]; +} + + +// returns |a| +FLOATTYPE +VSMatrix::length(const FLOATTYPE *a) { + + return(sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])); + +} + + +static inline int +M3(int i, int j) +{ + return (i*3+j); +}; + + + +// computes the derived normal matrix for the view matrix +void +VSMatrix::computeNormalMatrix(const FLOATTYPE *aMatrix) +{ + + FLOATTYPE mMat3x3[9]; + + mMat3x3[0] = aMatrix[0]; + mMat3x3[1] = aMatrix[1]; + mMat3x3[2] = aMatrix[2]; + + mMat3x3[3] = aMatrix[4]; + mMat3x3[4] = aMatrix[5]; + mMat3x3[5] = aMatrix[6]; + + mMat3x3[6] = aMatrix[8]; + mMat3x3[7] = aMatrix[9]; + mMat3x3[8] = aMatrix[10]; + + FLOATTYPE det, invDet; + + det = mMat3x3[0] * (mMat3x3[4] * mMat3x3[8] - mMat3x3[5] * mMat3x3[7]) + + mMat3x3[1] * (mMat3x3[5] * mMat3x3[6] - mMat3x3[8] * mMat3x3[3]) + + mMat3x3[2] * (mMat3x3[3] * mMat3x3[7] - mMat3x3[4] * mMat3x3[6]); + + invDet = 1.0f/det; + + mMatrix[0] = (mMat3x3[4] * mMat3x3[8] - mMat3x3[5] * mMat3x3[7]) * invDet; + mMatrix[1] = (mMat3x3[5] * mMat3x3[6] - mMat3x3[8] * mMat3x3[3]) * invDet; + mMatrix[2] = (mMat3x3[3] * mMat3x3[7] - mMat3x3[4] * mMat3x3[6]) * invDet; + mMatrix[3] = 0.0f; + mMatrix[4] = (mMat3x3[2] * mMat3x3[7] - mMat3x3[1] * mMat3x3[8]) * invDet; + mMatrix[5] = (mMat3x3[0] * mMat3x3[8] - mMat3x3[2] * mMat3x3[6]) * invDet; + mMatrix[6] = (mMat3x3[1] * mMat3x3[6] - mMat3x3[7] * mMat3x3[0]) * invDet; + mMatrix[7] = 0.0f; + mMatrix[8] = (mMat3x3[1] * mMat3x3[5] - mMat3x3[4] * mMat3x3[2]) * invDet; + mMatrix[9] = (mMat3x3[2] * mMat3x3[3] - mMat3x3[0] * mMat3x3[5]) * invDet; + mMatrix[10] =(mMat3x3[0] * mMat3x3[4] - mMat3x3[3] * mMat3x3[1]) * invDet; + mMatrix[11] = 0.0; + mMatrix[12] = 0.0; + mMatrix[13] = 0.0; + mMatrix[14] = 0.0; + mMatrix[15] = 1.0; + +} + + +// aux function resMat = resMat * aMatrix +void +VSMatrix::multMatrix(FLOATTYPE *resMat, const FLOATTYPE *aMatrix) +{ + + FLOATTYPE res[16]; + + for (int i = 0; i < 4; ++i) + { + for (int j = 0; j < 4; ++j) + { + res[j*4 + i] = 0.0f; + for (int k = 0; k < 4; ++k) + { + res[j*4 + i] += resMat[k*4 + i] * aMatrix[j*4 + k]; + } + } + } + memcpy(resMat, res, 16 * sizeof(FLOATTYPE)); +} diff --git a/src/gl/data/gl_matrix.h b/src/gl/data/gl_matrix.h new file mode 100644 index 000000000..de4b400da --- /dev/null +++ b/src/gl/data/gl_matrix.h @@ -0,0 +1,112 @@ + +// Matrix class based on code from VSML: + +/** ---------------------------------------------------------- + * \class VSMathLib + * + * Lighthouse3D + * + * VSMathLib - Very Simple Matrix Library + * + * Full documentation at + * http://www.lighthouse3d.com/very-simple-libs + * + * This class aims at easing geometric transforms, camera + * placement and projection definition for programmers + * working with OpenGL core versions. + * + * + ---------------------------------------------------------------*/ +#ifndef __VSMatrix__ +#define __VSMatrix__ + +#include + +#ifdef USE_DOUBLE +typedef double FLOATTYPE; +#else +typedef float FLOATTYPE; +#endif + +class VSMatrix { + + public: + + VSMatrix() + { + } + + VSMatrix(int) + { + loadIdentity(); + } + + void translate(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); + void scale(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); + void rotate(FLOATTYPE angle, FLOATTYPE x, FLOATTYPE y, FLOATTYPE z); + void loadIdentity(); +#ifdef USE_DOUBLE + void multMatrix(const float *aMatrix); +#endif + void multMatrix(const FLOATTYPE *aMatrix); + void multMatrix(const VSMatrix &aMatrix) + { + multMatrix(aMatrix.mMatrix); + } + void loadMatrix(const FLOATTYPE *aMatrix); +#ifdef USE_DOUBLE + void loadMatrix(const float *aMatrix); +#endif + void lookAt(FLOATTYPE xPos, FLOATTYPE yPos, FLOATTYPE zPos, FLOATTYPE xLook, FLOATTYPE yLook, FLOATTYPE zLook, FLOATTYPE xUp, FLOATTYPE yUp, FLOATTYPE zUp); + void perspective(FLOATTYPE fov, FLOATTYPE ratio, FLOATTYPE nearp, FLOATTYPE farp); + void ortho(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp=-1.0f, FLOATTYPE farp=1.0f); + void frustum(FLOATTYPE left, FLOATTYPE right, FLOATTYPE bottom, FLOATTYPE top, FLOATTYPE nearp, FLOATTYPE farp); + void copy(FLOATTYPE * pDest) + { + memcpy(pDest, mMatrix, 16 * sizeof(FLOATTYPE)); + } + +#ifdef USE_DOUBLE + void copy(float * pDest) + { + for (int i = 0; i < 16; i++) + { + pDest[i] = (float)mMatrix[i]; + } + } +#endif + + const FLOATTYPE *get() const + { + return mMatrix; + } + + void matrixToGL(int location); + void multMatrixPoint(const FLOATTYPE *point, FLOATTYPE *res); + +#ifdef USE_DOUBLE + void computeNormalMatrix(const float *aMatrix); +#endif + void computeNormalMatrix(const FLOATTYPE *aMatrix); + void computeNormalMatrix(const VSMatrix &aMatrix) + { + computeNormalMatrix(aMatrix.mMatrix); + } + + protected: + static void crossProduct(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res); + static FLOATTYPE dotProduct(const FLOATTYPE *a, const FLOATTYPE * b); + static void normalize(FLOATTYPE *a); + static void subtract(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res); + static void add(const FLOATTYPE *a, const FLOATTYPE *b, FLOATTYPE *res); + static FLOATTYPE length(const FLOATTYPE *a); + static void multMatrix(FLOATTYPE *resMatrix, const FLOATTYPE *aMatrix); + + static void setIdentityMatrix(FLOATTYPE *mat, int size = 4); + + /// The storage for matrices + FLOATTYPE mMatrix[16]; + +}; + +#endif \ No newline at end of file diff --git a/src/gl/data/gl_portaldata.cpp b/src/gl/data/gl_portaldata.cpp new file mode 100644 index 000000000..676f6a630 --- /dev/null +++ b/src/gl/data/gl_portaldata.cpp @@ -0,0 +1,473 @@ +/* +** gl_setup.cpp +** Initializes the data structures required by the GL renderer to handle +** a level +** +**--------------------------------------------------------------------------- +** Copyright 2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "colormatcher.h" +#include "i_system.h" +#include "p_local.h" +#include "p_lnspec.h" +#include "c_dispatch.h" +#include "r_sky.h" +#include "sc_man.h" +#include "w_wad.h" +#include "gi.h" +#include "g_level.h" +#include "a_sharedglobal.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/scene/gl_clipper.h" +#include "gl/scene/gl_portal.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/utility/gl_clock.h" +#include "gl/gl_functions.h" + +struct FPortalID +{ + fixed_t mXDisplacement; + fixed_t mYDisplacement; + + // for the hash code + operator intptr_t() const { return (mXDisplacement >> 8) + (mYDisplacement << 8); } + bool operator != (const FPortalID &other) const + { + return mXDisplacement != other.mXDisplacement || + mYDisplacement != other.mYDisplacement; + } +}; + +struct FPortalSector +{ + sector_t *mSub; + int mPlane; +}; + +typedef TArray FPortalSectors; + +typedef TMap FPortalMap; + +TArray portals; + +//========================================================================== +// +// +// +//========================================================================== + +GLSectorStackPortal *FPortal::GetGLPortal() +{ + if (glportal == NULL) glportal = new GLSectorStackPortal(this); + return glportal; +} + +//========================================================================== +// +// +// +//========================================================================== + +struct FCoverageVertex +{ + fixed_t x, y; + + bool operator !=(FCoverageVertex &other) + { + return x != other.x || y != other.y; + } +}; + +struct FCoverageLine +{ + FCoverageVertex v[2]; +}; + +struct FCoverageBuilder +{ + subsector_t *target; + FPortal *portal; + TArray collect; + FCoverageVertex center; + + //========================================================================== + // + // + // + //========================================================================== + + FCoverageBuilder(subsector_t *sub, FPortal *port) + { + target = sub; + portal = port; + } + + //========================================================================== + // + // GetIntersection + // + // adapted from P_InterceptVector + // + //========================================================================== + + bool GetIntersection(FCoverageVertex *v1, FCoverageVertex *v2, node_t *bsp, FCoverageVertex *v) + { + double frac; + double num; + double den; + + double v2x = (double)v1->x; + double v2y = (double)v1->y; + double v2dx = (double)(v2->x - v1->x); + double v2dy = (double)(v2->y - v1->y); + double v1x = (double)bsp->x; + double v1y = (double)bsp->y; + double v1dx = (double)bsp->dx; + double v1dy = (double)bsp->dy; + + den = v1dy*v2dx - v1dx*v2dy; + + if (den == 0) + return false; // parallel + + num = (v1x - v2x)*v1dy + (v2y - v1y)*v1dx; + frac = num / den; + + if (frac < 0. || frac > 1.) return false; + + v->x = xs_RoundToInt(v2x + frac * v2dx); + v->y = xs_RoundToInt(v2y + frac * v2dy); + return true; + } + + //========================================================================== + // + // + // + //========================================================================== + + double PartitionDistance(FCoverageVertex *vt, node_t *node) + { + return fabs(double(-node->dy) * (vt->x - node->x) + double(node->dx) * (vt->y - node->y)) / node->len; + } + + //========================================================================== + // + // + // + //========================================================================== + + int PointOnSide(FCoverageVertex *vt, node_t *node) + { + return R_PointOnSide(vt->x, vt->y, node); + } + + //========================================================================== + // + // adapted from polyobject splitter + // + //========================================================================== + + void CollectNode(void *node, TArray &shape) + { + static TArray lists[2]; + const double COVERAGE_EPSILON = 6.; // same epsilon as the node builder + + if (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + + int centerside = R_PointOnSide(center.x, center.y, bsp); + + lists[0].Clear(); + lists[1].Clear(); + for(unsigned i=0;ichildren[0], shape); + } + else if (lists[0].Size() == 0) + { + CollectNode(bsp->children[1], shape); + } + else + { + // copy the static arrays into local ones + TArray locallists[2]; + + for(int l=0;l<2;l++) + { + for (unsigned i=0;ichildren[0], locallists[0]); + CollectNode(bsp->children[1], locallists[1]); + } + } + else + { + // we reached a subsector so we can link the node with this subsector + subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + collect.Push(int(sub-subsectors)); + } + } +}; + +//========================================================================== +// +// Calculate portal coverage for a single subsector +// +//========================================================================== + +void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, FPortal *portal) +{ + TArray shape; + double centerx=0, centery=0; + + shape.Resize(subsector->numlines); + for(unsigned i=0; inumlines; i++) + { + centerx += (shape[i].x = subsector->firstline[i].v1->x + portal->xDisplacement); + centery += (shape[i].y = subsector->firstline[i].v1->y + portal->yDisplacement); + } + + FCoverageBuilder build(subsector, portal); + build.center.x = xs_CRoundToInt(centerx / subsector->numlines); + build.center.y = xs_CRoundToInt(centery / subsector->numlines); + + build.CollectNode(nodes + numnodes - 1, shape); + coverage->subsectors = new DWORD[build.collect.Size()]; + coverage->sscount = build.collect.Size(); + memcpy(coverage->subsectors, &build.collect[0], build.collect.Size() * sizeof(DWORD)); +} + +//========================================================================== +// +// portal initialization +// +//========================================================================== + +static void CollectPortalSectors(FPortalMap &collection) +{ + for (int i=0;iCeilingSkyBox != NULL && sec->CeilingSkyBox->bAlways && sec->CeilingSkyBox->Mate != NULL) + { + FPortalID id = { sec->CeilingSkyBox->x - sec->CeilingSkyBox->Mate->x, + sec->CeilingSkyBox->y - sec->CeilingSkyBox->Mate->y}; + + FPortalSectors &sss = collection[id]; + FPortalSector ss = { sec, sector_t::ceiling }; + sss.Push(ss); + } + + if (sec->FloorSkyBox != NULL && sec->FloorSkyBox->bAlways && sec->FloorSkyBox->Mate != NULL) + { + FPortalID id = { sec->FloorSkyBox->x - sec->FloorSkyBox->Mate->x, + sec->FloorSkyBox->y - sec->FloorSkyBox->Mate->y }; + + FPortalSectors &sss = collection[id]; + FPortalSector ss = { sec, sector_t::floor }; + sss.Push(ss); + } + } +} + +void gl_InitPortals() +{ + FPortalMap collection; + + if (numnodes == 0) return; + + for(int i=0;idx; + double fdy = (double)no->dy; + no->len = (float)sqrt(fdx * fdx + fdy * fdy); + } + + CollectPortalSectors(collection); + portals.Clear(); + + FPortalMap::Iterator it(collection); + FPortalMap::Pair *pair; + int c = 0; + int planeflags = 0; + while (it.NextPair(pair)) + { + for(unsigned i=0;iValue.Size(); i++) + { + if (pair->Value[i].mPlane == sector_t::floor) planeflags |= 1; + else if (pair->Value[i].mPlane == sector_t::ceiling) planeflags |= 2; + } + for (int i=1;i<=2;i<<=1) + { + // For now, add separate portals for floor and ceiling. They can be merged once + // proper plane clipping is in. + if (planeflags & i) + { + FPortal *portal = new FPortal; + portal->xDisplacement = pair->Key.mXDisplacement; + portal->yDisplacement = pair->Key.mYDisplacement; + portal->plane = (i==1? sector_t::floor : sector_t::ceiling); /**/ + portal->glportal = NULL; + portals.Push(portal); + for(unsigned j=0;jValue.Size(); j++) + { + sector_t *sec = pair->Value[j].mSub; + int plane = pair->Value[j].mPlane; + if (portal->plane == plane) + { + for(int k=0;ksubsectorcount; k++) + { + subsector_t *sub = sec->subsectors[k]; + gl_BuildPortalCoverage(&sub->portalcoverage[plane], sub, portal); + } + sec->portals[plane] = portal; + } + } + } + } + } +} + +CCMD(dumpportals) +{ + for(unsigned i=0;ixDisplacement/65536.; + double ydisp = portals[i]->yDisplacement/65536.; + Printf(PRINT_LOG, "Portal #%d, %s, displacement = (%f,%f)\n", i, portals[i]->plane==0? "floor":"ceiling", + xdisp, ydisp); + Printf(PRINT_LOG, "Coverage:\n"); + for(int j=0;jrender_sector->portals[portals[i]->plane]; + if (port == portals[i]) + { + Printf(PRINT_LOG, "\tSubsector %d (%d):\n\t\t", j, sub->render_sector->sectornum); + for(unsigned k = 0;k< sub->numlines; k++) + { + Printf(PRINT_LOG, "(%.3f,%.3f), ", sub->firstline[k].v1->x/65536. + xdisp, sub->firstline[k].v1->y/65536. + ydisp); + } + Printf(PRINT_LOG, "\n\t\tCovered by subsectors:\n"); + FPortalCoverage *cov = &sub->portalcoverage[portals[i]->plane]; + for(int l = 0;l< cov->sscount; l++) + { + subsector_t *csub = &subsectors[cov->subsectors[l]]; + Printf(PRINT_LOG, "\t\t\t%5d (%4d): ", cov->subsectors[l], csub->render_sector->sectornum); + for(unsigned m = 0;m< csub->numlines; m++) + { + Printf(PRINT_LOG, "(%.3f,%.3f), ", csub->firstline[m].v1->x/65536., csub->firstline[m].v1->y/65536.); + } + Printf(PRINT_LOG, "\n"); + } + } + } + } +} diff --git a/src/gl/data/gl_setup.cpp b/src/gl/data/gl_setup.cpp new file mode 100644 index 000000000..5e6e0767b --- /dev/null +++ b/src/gl/data/gl_setup.cpp @@ -0,0 +1,751 @@ +/* +** gl_setup.cpp +** Initializes the data structures required by the GL renderer to handle +** a level +** +**--------------------------------------------------------------------------- +** Copyright 2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "doomtype.h" +#include "colormatcher.h" +#include "i_system.h" +#include "p_local.h" +#include "p_lnspec.h" +#include "c_dispatch.h" +#include "r_sky.h" +#include "sc_man.h" +#include "w_wad.h" +#include "gi.h" +#include "p_setup.h" +#include "g_level.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/utility/gl_clock.h" +#include "gl/gl_functions.h" + +void InitGLRMapinfoData(); + +//========================================================================== +// +// +// +//========================================================================== + +static void DoSetMapSection(subsector_t *sub, int num) +{ + sub->mapsection = num; + + for(DWORD i=0;inumlines;i++) + { + seg_t * seg = sub->firstline + i; + + if (seg->PartnerSeg) + { + subsector_t * sub2 = seg->PartnerSeg->Subsector; + + if (sub2->mapsection != num) + { + assert(sub2->mapsection == 0); + DoSetMapSection(sub2, num); + } + } + } +} + +//========================================================================== +// +// Merge sections. This is needed in case the map contains errors +// like overlapping lines resulting in abnormal subsectors. +// +// This function ensures that any vertex position can only be in one section. +// +//========================================================================== + +struct cvertex_t +{ + fixed_t x, y; + + operator int () const { return ((x>>16)&0xffff) | y; } + bool operator!= (const cvertex_t &other) const { return x != other.x || y != other.y; } + cvertex_t& operator =(const vertex_t *v) { x = v->x; y = v->y; return *this; } +}; + +typedef TMap FSectionVertexMap; + +static int MergeMapSections(int num) +{ + FSectionVertexMap vmap; + FSectionVertexMap::Pair *pair; + TArray sectmap; + TArray sectvalid; + sectmap.Resize(num); + sectvalid.Resize(num); + for(int i=0;iSubsector->mapsection; + for(int j=0;j<2;j++) + { + vt = j==0? seg->v1:seg->v2; + vmap[vt] = section; + } + } + + // second step: Check if any seg references more than one mapsection, either by subsector or by vertex + for(DWORD i=0;i<(DWORD)numsegs;i++) + { + seg_t * seg = &segs[i]; + int section = seg->Subsector->mapsection; + for(int j=0;j<2;j++) + { + vt = j==0? seg->v1:seg->v2; + int vsection = vmap[vt]; + + if (vsection != section) + { + // These 2 sections should be merged + for(int k=0;kValue == vsection) pair->Value = section; + } + sectvalid[vsection-1] = false; + } + } + } + for(int i=0;inumlines;i++) + { + seg_t * seg = sub->firstline + i; + + if (seg->PartnerSeg) + { + subsector_t * sub2 = seg->PartnerSeg->Subsector; + + if (!(sub2->hacked&1) && sub2->render_sector == sub->render_sector) + { + sub2->hacked|=1; + sub->hacked &= ~4; + SpreadHackedFlag (sub2); + } + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +static void PrepareSectorData() +{ + int i; + TArray undetermined; + subsector_t * ss; + + // now group the subsectors by sector + subsector_t ** subsectorbuffer = new subsector_t * [numsubsectors]; + + for(i=0, ss=subsectors; irender_sector->subsectorcount++; + } + + for (i=0; irender_sector->subsectors[ss->render_sector->subsectorcount++]=ss; + } + + // marks all malformed subsectors so rendering tricks using them can be handled more easily + for (i = 0; i < numsubsectors; i++) + { + if (subsectors[i].sector == subsectors[i].render_sector) + { + seg_t * seg = subsectors[i].firstline; + for(DWORD j=0;jSubsector->render_sector) + { + DPrintf("Found hack: (%d,%d) (%d,%d)\n", seg[j].v1->x>>16, seg[j].v1->y>>16, seg[j].v2->x>>16, seg[j].v2->y>>16); + subsectors[i].hacked|=5; + SpreadHackedFlag(&subsectors[i]); + } + if (seg[j].PartnerSeg==NULL) subsectors[i].hacked|=2; // used for quick termination checks + } + } + } + SetMapSections(); +} + +//========================================================================== +// +// Some processing for transparent door hacks using a floor raised by 1 map unit +// - This will be used to lower the floor of such sectors by one map unit +// +//========================================================================== + +static void PrepareTransparentDoors(sector_t * sector) +{ + bool solidwall=false; + int notextures=0; + int nobtextures=0; + int selfref=0; + int i; + sector_t * nextsec=NULL; + +#ifdef _DEBUG + if (sector-sectors==2) + { + int a = 0; + } +#endif + + P_Recalculate3DFloors(sector); + if (sector->subsectorcount==0) return; + + sector->transdoorheight=sector->GetPlaneTexZ(sector_t::floor); + sector->transdoor= !(sector->e->XFloor.ffloors.Size() || sector->heightsec || sector->floorplane.a || sector->floorplane.b); + + if (sector->transdoor) + { + for (i=0; ilinecount; i++) + { + if (sector->lines[i]->frontsector==sector->lines[i]->backsector) + { + selfref++; + continue; + } + + sector_t * sec=getNextSector(sector->lines[i], sector); + if (sec==NULL) + { + solidwall=true; + continue; + } + else + { + nextsec=sec; + + int side = sector->lines[i]->sidedef[0]->sector == sec; + + if (sector->GetPlaneTexZ(sector_t::floor)!=sec->GetPlaneTexZ(sector_t::floor)+FRACUNIT) + { + sector->transdoor=false; + return; + } + if (!sector->lines[i]->sidedef[1-side]->GetTexture(side_t::top).isValid()) notextures++; + if (!sector->lines[i]->sidedef[1-side]->GetTexture(side_t::bottom).isValid()) nobtextures++; + } + } + if (sector->GetTexture(sector_t::ceiling)==skyflatnum) + { + sector->transdoor=false; + return; + } + + if (selfref+nobtextures!=sector->linecount) + { + sector->transdoor=false; + } + + if (selfref+notextures!=sector->linecount) + { + // This is a crude attempt to fix an incorrect transparent door effect I found in some + // WolfenDoom maps but considering the amount of code required to handle it I left it in. + // Do this only if the sector only contains one-sided walls or ones with no lower texture. + if (solidwall) + { + if (solidwall+nobtextures+selfref==sector->linecount && nextsec) + { + sector->heightsec=nextsec; + sector->heightsec->MoreFlags=0; + } + sector->transdoor=false; + } + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +static void AddToVertex(const sector_t * sec, TArray & list) +{ + int secno = int(sec-sectors); + + for(unsigned i=0;i * vt_sectorlists; + + int i,j,k; + unsigned int l; + + vt_sectorlists = new TArray[numvertexes]; + + + for(i=0;iv1 : line->v2; + + for(k=0;k<2;k++) + { + sector_t * sec = k==0? line->frontsector : line->backsector; + + if (sec) + { + extsector_t::xfloor &x = sec->e->XFloor; + + AddToVertex(sec, vt_sectorlists[v-vertexes]); + if (sec->heightsec) AddToVertex(sec->heightsec, vt_sectorlists[v-vertexes]); + + for(l=0;lflags & FF_EXISTS)) continue; + if (rover->flags&FF_NOSHADE) continue; // FF_NOSHADE doesn't create any wall splits + + AddToVertex(rover->model, vt_sectorlists[v-vertexes]); + } + } + } + } + } + + for(i=0;i1) + { + vertexes[i].numsectors= cnt; + vertexes[i].sectors=new sector_t*[cnt]; + vertexes[i].heightlist = new float[cnt*2]; + for(int j=0;jsidedef[0] == &sides[sdnum]) + { + v1->X = ln->v1->fx; + v1->Y = ln->v1->fy; + v2->X = ln->v2->fx; + v2->Y = ln->v2->fy; + } + else + { + v2->X = ln->v1->fx; + v2->Y = ln->v1->fy; + v1->X = ln->v2->fx; + v1->Y = ln->v2->fy; + } +} + +static int STACK_ARGS segcmp(const void *a, const void *b) +{ + seg_t *A = *(seg_t**)a; + seg_t *B = *(seg_t**)b; + return xs_RoundToInt(FRACUNIT*(A->sidefrac - B->sidefrac)); +} + +//========================================================================== +// +// Group segs to sidedefs +// +//========================================================================== + +static void PrepareSegs() +{ + int *segcount = new int[numsides]; + int realsegs = 0; + + // Get floatng point coordinates of vertices + for(int i = 0; i < numvertexes; i++) + { + vertexes[i].fx = FIXED2FLOAT(vertexes[i].x); + vertexes[i].fy = FIXED2FLOAT(vertexes[i].y); + vertexes[i].dirty = true; + } + + // count the segs + memset(segcount, 0, numsides * sizeof(int)); + + // set up the extra data in case the map was loaded with regular nodes that might pass as GL nodes. + if (glsegextras == NULL) + { + for(int i=0;iPartnerSeg = &segs[partner]; + else seg->PartnerSeg = NULL; + seg->Subsector = glsegextras[i].Subsector; + } + } + + for(int i=0;isidedef == NULL) continue; // miniseg + int sidenum = int(seg->sidedef - sides); + + realsegs++; + segcount[sidenum]++; + FVector2 sidestart, sideend, segend(seg->v2->fx, seg->v2->fy); + GetSideVertices(sidenum, &sidestart, &sideend); + + sideend -=sidestart; + segend -= sidestart; + + seg->sidefrac = float(segend.Length() / sideend.Length()); + } + + // allocate memory + sides[0].segs = new seg_t*[realsegs]; + sides[0].numsegs = 0; + + for(int i = 1; i < numsides; i++) + { + sides[i].segs = sides[i-1].segs + segcount[i-1]; + sides[i].numsegs = 0; + } + delete [] segcount; + + // assign the segs + for(int i=0;isidedef != NULL) seg->sidedef->segs[seg->sidedef->numsegs++] = seg; + } + + // sort the segs + for(int i = 0; i < numsides; i++) + { + if (sides[i].numsegs > 1) qsort(sides[i].segs, sides[i].numsegs, sizeof(seg_t*), segcmp); + } +} + +//========================================================================== +// +// Initialize the level data for the GL renderer +// +//========================================================================== +extern int restart; + +void gl_PreprocessLevel() +{ + int i; + + PrepareSegs(); + PrepareSectorData(); + InitVertexData(); + int *checkmap = new int[numvertexes]; + memset(checkmap, -1, sizeof(int)*numvertexes); + for(i=0;isidedef[0]->Flags & WALLF_POLYOBJ) continue; // don't bother with polyobjects + + int vtnum1 = int(l->v1 - vertexes); + int vtnum2 = int(l->v2 - vertexes); + + if (checkmap[vtnum1] < i) + { + checkmap[vtnum1] = i; + sectors[i].e->vertices.Push(&vertexes[vtnum1]); + vertexes[vtnum1].dirty = true; + } + + if (checkmap[vtnum2] < i) + { + checkmap[vtnum2] = i; + sectors[i].e->vertices.Push(&vertexes[vtnum2]); + vertexes[vtnum2].dirty = true; + } + } + } + delete[] checkmap; + + gl_InitPortals(); + + if (GLRenderer != NULL) + { + GLRenderer->SetupLevel(); + } + +#if 0 + gl_CreateSections(); +#endif + + InitGLRMapinfoData(); +} + + + +//========================================================================== +// +// Cleans up all the GL data for the last level +// +//========================================================================== + +void gl_CleanLevelData() +{ + // Dynamic lights must be destroyed before the sector information here is deleted. + TThinkerIterator it(STAT_DLIGHT); + AActor * mo=it.Next(); + while (mo) + { + AActor * next = it.Next(); + mo->Destroy(); + mo=next; + } + + if (vertexes != NULL) + { + for(int i = 0; i < numvertexes; i++) if (vertexes[i].numsectors > 0) + { + if (vertexes[i].sectors != NULL) + { + delete [] vertexes[i].sectors; + vertexes[i].sectors = NULL; + } + if (vertexes[i].heightlist != NULL) + { + delete [] vertexes[i].heightlist; + vertexes[i].heightlist = NULL; + } + } + } + + if (sides && sides[0].segs) + { + delete [] sides[0].segs; + sides[0].segs = NULL; + } + if (sectors && sectors[0].subsectors) + { + delete [] sectors[0].subsectors; + sectors[0].subsectors = NULL; + } + for (int i=0;isectornum, int(subsectors[j].firstline->linedef-lines)); + break; + } + } + } +} diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp new file mode 100644 index 000000000..0e9065557 --- /dev/null +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -0,0 +1,383 @@ +/* +** glc_vertexbuffer.cpp +** Vertex buffer handling. +** +**--------------------------------------------------------------------------- +** Copyright 2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "doomtype.h" +#include "p_local.h" +#include "m_argv.h" +#include "c_cvars.h" +#include "gl/system/gl_interface.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/shaders/gl_shader.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" + + +//========================================================================== +// +// Create / destroy the VBO +// +//========================================================================== + +FVertexBuffer::FVertexBuffer() +{ + vao_id = vbo_id = 0; + glGenBuffers(1, &vbo_id); + glGenVertexArrays(1, &vao_id); + +} + +FVertexBuffer::~FVertexBuffer() +{ + if (vbo_id != 0) + { + glDeleteBuffers(1, &vbo_id); + } + if (vao_id != 0) + { + glDeleteVertexArrays(1, &vao_id); + } +} + +void FVertexBuffer::BindVBO() +{ + glBindVertexArray(vao_id); +} + +//========================================================================== +// +// +// +//========================================================================== + +FFlatVertexBuffer::FFlatVertexBuffer() +: FVertexBuffer() +{ + if (gl.flags & RFL_BUFFER_STORAGE) + { + unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferStorage(GL_ARRAY_BUFFER, bytesize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + + glBindVertexArray(vao_id); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glVertexAttribPointer(VATTR_VERTEX, 3,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2,GL_FLOAT, false, sizeof(FFlatVertex), &VTO->u); + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); + glBindVertexArray(0); + } + else + { + vbo_shadowdata.Reserve(BUFFER_SIZE); + map = &vbo_shadowdata[0]; + } + mNumReserved = mIndex = mCurIndex = 0; +} + +FFlatVertexBuffer::~FFlatVertexBuffer() +{ + if (gl.flags & RFL_BUFFER_STORAGE) + { + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glUnmapBuffer(GL_ARRAY_BUFFER); + glBindBuffer(GL_ARRAY_BUFFER, 0); + } +} + +//========================================================================== +// +// immediate mode fallback for drivers without GL_ARB_buffer_storage +// +// No single core method is performant enough to handle this adequately +// so we have to resort to immediate mode instead... +// +//========================================================================== + +void FFlatVertexBuffer::ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count) +{ + // this will only get called if we can't acquire a persistently mapped buffer. +#ifndef CORE_PROFILE + glBegin(primtype); + for (unsigned int i = 0; i < count; i++) + { + glVertexAttrib2fv(VATTR_TEXCOORD, &map[offset + i].u); + glVertexAttrib3fv(VATTR_VERTEX, &map[offset + i].x); + } + glEnd(); +#endif +} + +//========================================================================== +// +// Initialize a single vertex +// +//========================================================================== + +void FFlatVertex::SetFlatVertex(vertex_t *vt, const secplane_t & plane) +{ + x = vt->fx; + y = vt->fy; + z = plane.ZatPoint(vt->fx, vt->fy); + u = vt->fx/64.f; + v = -vt->fy/64.f; +} + +//========================================================================== +// +// Find a 3D floor +// +//========================================================================== + +static F3DFloor *Find3DFloor(sector_t *target, sector_t *model) +{ + for(unsigned i=0; ie->XFloor.ffloors.Size(); i++) + { + F3DFloor *ffloor = target->e->XFloor.ffloors[i]; + if (ffloor->model == model) return ffloor; + } + return NULL; +} + +//========================================================================== +// +// Creates the vertices for one plane in one subsector +// +//========================================================================== + +int FFlatVertexBuffer::CreateSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor) +{ + int idx = vbo_shadowdata.Reserve(sub->numlines); + for(unsigned int k=0; knumlines; k++, idx++) + { + vbo_shadowdata[idx].SetFlatVertex(sub->firstline[k].v1, plane); + if (sub->sector->transdoor && floor) vbo_shadowdata[idx].z -= 1.f; + } + return idx; +} + +//========================================================================== +// +// Creates the vertices for one plane in one subsector +// +//========================================================================== + +int FFlatVertexBuffer::CreateSectorVertices(sector_t *sec, const secplane_t &plane, int floor) +{ + int rt = vbo_shadowdata.Size(); + // First calculate the vertices for the sector itself + for(int j=0; jsubsectorcount; j++) + { + subsector_t *sub = sec->subsectors[j]; + CreateSubsectorVertices(sub, plane, floor); + } + return rt; +} + +//========================================================================== +// +// +// +//========================================================================== + +int FFlatVertexBuffer::CreateVertices(int h, sector_t *sec, const secplane_t &plane, int floor) +{ + // First calculate the vertices for the sector itself + sec->vboheight[h] = sec->GetPlaneTexZ(h); + sec->vboindex[h] = CreateSectorVertices(sec, plane, floor); + + // Next are all sectors using this one as heightsec + TArray &fakes = sec->e->FakeFloor.Sectors; + for (unsigned g=0; gvboindex[2+h] = CreateSectorVertices(fsec, plane, false); + } + + // and finally all attached 3D floors + TArray &xf = sec->e->XFloor.attached; + for (unsigned g=0; gflags & FF_RENDERPLANES) + { + bool dotop = (ffloor->top.model == sec) && (ffloor->top.isceiling == h); + bool dobottom = (ffloor->bottom.model == sec) && (ffloor->bottom.isceiling == h); + + if (dotop || dobottom) + { + if (dotop) ffloor->top.vindex = vbo_shadowdata.Size(); + if (dobottom) ffloor->bottom.vindex = vbo_shadowdata.Size(); + + CreateSectorVertices(fsec, plane, false); + } + } + } + sec->vbocount[h] = vbo_shadowdata.Size() - sec->vboindex[h]; + return sec->vboindex[h]; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::CreateFlatVBO() +{ + for (int h = sector_t::floor; h <= sector_t::ceiling; h++) + { + for(int i=0; iXFloor.ffloors.Size(); j++) + { + F3DFloor *ff = sectors[i].e->XFloor.ffloors[j]; + + if (ff->top.model == §ors[i]) + { + ff->top.vindex = sectors[i].vboindex[ff->top.isceiling]; + } + if (ff->bottom.model == §ors[i]) + { + ff->bottom.vindex = sectors[i].vboindex[ff->top.isceiling]; + } + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) +{ + int startvt = sec->vboindex[plane]; + int countvt = sec->vbocount[plane]; + secplane_t &splane = sec->GetSecPlane(plane); + FFlatVertex *vt = &vbo_shadowdata[startvt]; + FFlatVertex *mapvt = &map[startvt]; + for(int i=0; iz = splane.ZatPoint(vt->x, vt->y); + if (plane == sector_t::floor && sec->transdoor) vt->z -= 1; + mapvt->z = vt->z; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::CreateVBO() +{ + if (gl.flags & RFL_BUFFER_STORAGE) + { + vbo_shadowdata.Resize(mNumReserved); + CreateFlatVBO(); + mCurIndex = mIndex = vbo_shadowdata.Size(); + memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); + } + else if (sectors) + { + // set all VBO info to invalid values so that we can save some checks in the rendering code + for(int i=0;iGetPlaneTexZ(sector_t::ceiling) != sector->vboheight[sector_t::ceiling]) + { + UpdatePlaneVertices(sector, sector_t::ceiling); + sector->vboheight[sector_t::ceiling] = sector->GetPlaneTexZ(sector_t::ceiling); + } + if (sector->GetPlaneTexZ(sector_t::floor) != sector->vboheight[sector_t::floor]) + { + UpdatePlaneVertices(sector, sector_t::floor); + sector->vboheight[sector_t::floor] = sector->GetPlaneTexZ(sector_t::floor); + } +} + +//========================================================================== +// +// checks the validity of all planes attached to this sector +// and updates them if possible. +// +//========================================================================== + +void FFlatVertexBuffer::CheckUpdate(sector_t *sector) +{ + if (gl.flags & RFL_BUFFER_STORAGE) + { + CheckPlanes(sector); + sector_t *hs = sector->GetHeightSec(); + if (hs != NULL) CheckPlanes(hs); + for (unsigned i = 0; i < sector->e->XFloor.ffloors.Size(); i++) + CheckPlanes(sector->e->XFloor.ffloors[i]->model); + } +} \ No newline at end of file diff --git a/src/gl/data/gl_vertexbuffer.h b/src/gl/data/gl_vertexbuffer.h new file mode 100644 index 000000000..12b536f10 --- /dev/null +++ b/src/gl/data/gl_vertexbuffer.h @@ -0,0 +1,216 @@ +#ifndef __VERTEXBUFFER_H +#define __VERTEXBUFFER_H + +#include "tarray.h" +#include "gl/utility/gl_clock.h" +#include "gl/system/gl_interface.h" + +struct vertex_t; +struct secplane_t; +struct subsector_t; +struct sector_t; + + +class FVertexBuffer +{ +protected: + unsigned int vbo_id; + unsigned int vao_id; + +public: + FVertexBuffer(); + virtual ~FVertexBuffer(); + void BindVBO(); +}; + +struct FFlatVertex +{ + float x,z,y; // world position + float u,v; // texture coordinates + + void SetFlatVertex(vertex_t *vt, const secplane_t &plane); + void Set(float xx, float zz, float yy, float uu, float vv) + { + x = xx; + z = zz; + y = yy; + u = uu; + v = vv; + } +}; + +#define VTO ((FFlatVertex*)NULL) + + +class FFlatVertexBuffer : public FVertexBuffer +{ + FFlatVertex *map; + unsigned int mIndex; + unsigned int mCurIndex; + unsigned int mNumReserved; + + void CheckPlanes(sector_t *sector); + + static const unsigned int BUFFER_SIZE = 2000000; + static const unsigned int BUFFER_SIZE_TO_USE = 1999500; + + void ImmRenderBuffer(unsigned int primtype, unsigned int offset, unsigned int count); + +public: + TArray vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer and as stand-in for pre GL 4.x + + FFlatVertexBuffer(); + ~FFlatVertexBuffer(); + + void CreateVBO(); + void CheckUpdate(sector_t *sector); + + FFlatVertex *GetBuffer() + { + return &map[mCurIndex]; + } + unsigned int GetCount(FFlatVertex *newptr, unsigned int *poffset) + { + + unsigned int newofs = (unsigned int)(newptr - map); + unsigned int diff = newofs - mCurIndex; + *poffset = mCurIndex; + mCurIndex = newofs; + if (mCurIndex >= BUFFER_SIZE_TO_USE) mCurIndex = mIndex; + return diff; + } +#ifdef __GL_PCH_H // we need the system includes for this but we cannot include them ourselves without creating #define clashes. The affected files wouldn't try to draw anyway. + void RenderArray(unsigned int primtype, unsigned int offset, unsigned int count) + { + drawcalls.Clock(); + if (gl.flags & RFL_BUFFER_STORAGE) + { + glDrawArrays(primtype, offset, count); + } + else + { + ImmRenderBuffer(primtype, offset, count); + } + drawcalls.Unclock(); + } + + void RenderCurrent(FFlatVertex *newptr, unsigned int primtype, unsigned int *poffset = NULL, unsigned int *pcount = NULL) + { + unsigned int offset; + unsigned int count = GetCount(newptr, &offset); + RenderArray(primtype, offset, count); + if (poffset) *poffset = offset; + if (pcount) *pcount = count; + } + +#endif + void Reset() + { + mCurIndex = mIndex; + } + +private: + int CreateSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor); + int CreateSectorVertices(sector_t *sec, const secplane_t &plane, int floor); + int CreateVertices(int h, sector_t *sec, const secplane_t &plane, int floor); + void CreateFlatVBO(); + void UpdatePlaneVertices(sector_t *sec, int plane); + +}; + + +struct FSkyVertex +{ + float x, y, z, u, v; + PalEntry color; + + void Set(float xx, float zz, float yy, float uu=0, float vv=0, PalEntry col=0xffffffff) + { + x = xx; + z = zz; + y = yy; + u = uu; + v = vv; + color = col; + } + +}; + +class FSkyVertexBuffer : public FVertexBuffer +{ +public: + static const int SKYHEMI_UPPER = 1; + static const int SKYHEMI_LOWER = 2; + + enum + { + SKYMODE_MAINLAYER = 0, + SKYMODE_SECONDLAYER = 1, + SKYMODE_FOGLAYER = 2 + }; + +private: + TArray mVertices; + TArray mPrimStart; + + int mRows, mColumns; + + void SkyVertex(int r, int c, bool yflip); + void CreateSkyHemisphere(int hemi); + void CreateDome(); + void RenderRow(int prim, int row); + +public: + + FSkyVertexBuffer(); + virtual ~FSkyVertexBuffer(); + void RenderDome(FMaterial *tex, int mode); + +}; + +#define VSO ((FSkyVertex*)NULL) + +struct FModelVertex +{ + float x, y, z; // world position + float u, v; // texture coordinates + + void Set(float xx, float yy, float zz, float uu, float vv) + { + x = xx; + y = yy; + z = zz; + u = uu; + v = vv; + } + + void SetNormal(float nx, float ny, float nz) + { + // GZDoom currently doesn't use normals. This function is so that the high level code can pretend it does. + } +}; + + +class FModelVertexBuffer : public FVertexBuffer +{ + int mIndexFrame[2]; + unsigned int ibo_id; + +public: + + FModelVertexBuffer(bool needindex); + ~FModelVertexBuffer(); + + FModelVertex *LockVertexBuffer(unsigned int size); + void UnlockVertexBuffer(); + + unsigned int *LockIndexBuffer(unsigned int size); + void UnlockIndexBuffer(); + + unsigned int SetupFrame(unsigned int frame1, unsigned int frame2); +}; + +#define VMO ((FModelVertex*)NULL) + + +#endif \ No newline at end of file diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp new file mode 100644 index 000000000..4507e783c --- /dev/null +++ b/src/gl/dynlights/a_dynlight.cpp @@ -0,0 +1,768 @@ +/* +** a_dynlight.cpp +** Implements actors representing dynamic lights (hardware independent) +** +**--------------------------------------------------------------------------- +** Copyright 2003 Timothy Stump +** Copyright 2005 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. +** 4. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "templates.h" +#include "m_random.h" +#include "p_local.h" +#include "c_dispatch.h" +#include "g_level.h" +#include "thingdef/thingdef.h" +#include "i_system.h" + + +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/utility/gl_convert.h" +#include "gl/utility/gl_templates.h" + +EXTERN_CVAR (Float, gl_lights_size); +EXTERN_CVAR (Bool, gl_lights_additive); +EXTERN_CVAR(Int, vid_renderer) + + +//========================================================================== +// +//========================================================================== +DEFINE_CLASS_PROPERTY(type, S, DynamicLight) +{ + PROP_STRING_PARM(str, 0); + static const char * ltype_names[]={ + "Point","Pulse","Flicker","Sector","RandomFlicker", "ColorPulse", "ColorFlicker", "RandomColorFlicker", NULL}; + + static const int ltype_values[]={ + PointLight, PulseLight, FlickerLight, SectorLight, RandomFlickerLight, ColorPulseLight, ColorFlickerLight, RandomColorFlickerLight }; + + int style = MatchString(str, ltype_names); + if (style < 0) I_Error("Unknown light type '%s'", str); + defaults->lighttype = ltype_values[style]; +} + +//========================================================================== +// +// Actor classes +// +// For flexibility all functionality has been packed into a single class +// which is controlled by flags +// +//========================================================================== +IMPLEMENT_CLASS (ADynamicLight) +IMPLEMENT_CLASS (AVavoomLight) +IMPLEMENT_CLASS (AVavoomLightWhite) +IMPLEMENT_CLASS (AVavoomLightColor) + +void AVavoomLight::BeginPlay () +{ + // This must not call Super::BeginPlay! + ChangeStatNum(STAT_DLIGHT); + if (Sector) z -= Sector->floorplane.ZatPoint(x, y); + lighttype = PointLight; +} + +void AVavoomLightWhite::BeginPlay () +{ + m_intensity[0] = args[0] * 4; + args[LIGHT_RED] = 128; + args[LIGHT_GREEN] = 128; + args[LIGHT_BLUE] = 128; + + Super::BeginPlay(); +} + +void AVavoomLightColor::BeginPlay () +{ + int l_args[5]; + memcpy(l_args, args, sizeof(l_args)); + memset(args, 0, sizeof(args)); + m_intensity[0] = l_args[0] * 4; + args[LIGHT_RED] = l_args[1] >> 1; + args[LIGHT_GREEN] = l_args[2] >> 1; + args[LIGHT_BLUE] = l_args[3] >> 1; + + Super::BeginPlay(); +} + +static FRandom randLight; + +//========================================================================== +// +// Base class +// +//========================================================================== + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::Serialize(FArchive &arc) +{ + Super::Serialize (arc); + arc << lightflags << lighttype; + arc << m_tickCount << m_currentIntensity; + arc << m_intensity[0] << m_intensity[1]; + + if (lighttype == PulseLight) arc << m_lastUpdate << m_cycler; + if (arc.IsLoading()) LinkLight(); + +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::BeginPlay() +{ + //Super::BeginPlay(); + ChangeStatNum(STAT_DLIGHT); + + m_intensity[0] = args[LIGHT_INTENSITY]; + m_intensity[1] = args[LIGHT_SECONDARY_INTENSITY]; +} + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::PostBeginPlay() +{ + Super::PostBeginPlay(); + + if (!(SpawnFlags & MTF_DORMANT)) + { + Activate (NULL); + } + + subsector = R_PointInSubsector(x,y); +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::Activate(AActor *activator) +{ + //Super::Activate(activator); + flags2&=~MF2_DORMANT; + + m_currentIntensity = float(m_intensity[0]); + m_tickCount = 0; + + if (lighttype == PulseLight) + { + float pulseTime = ANGLE_TO_FLOAT(this->angle) / TICRATE; + + m_lastUpdate = level.maptime; + m_cycler.SetParams(float(m_intensity[1]), float(m_intensity[0]), pulseTime); + m_cycler.ShouldCycle(true); + m_cycler.SetCycleType(CYCLE_Sin); + m_currentIntensity = (BYTE)m_cycler.GetVal(); + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::Deactivate(AActor *activator) +{ + //Super::Deactivate(activator); + flags2|=MF2_DORMANT; +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::Tick() +{ + if (vid_renderer == 0) + { + return; + } + if (IsOwned()) + { + if (!target || !target->state) + { + this->Destroy(); + return; + } + if (target->flags & MF_UNMORPHED) return; + } + + // Don't bother if the light won't be shown + if (!IsActive()) return; + + // I am doing this with a type field so that I can dynamically alter the type of light + // without having to create or maintain multiple objects. + switch(lighttype) + { + case PulseLight: + { + float diff = (level.maptime - m_lastUpdate) / (float)TICRATE; + + m_lastUpdate = level.maptime; + m_cycler.Update(diff); + m_currentIntensity = m_cycler.GetVal(); + break; + } + + case FlickerLight: + { + BYTE rnd = randLight(); + float pct = ANGLE_TO_FLOAT(angle)/360.f; + + m_currentIntensity = float(m_intensity[rnd >= pct * 255]); + break; + } + + case RandomFlickerLight: + { + int flickerRange = m_intensity[1] - m_intensity[0]; + float amt = randLight() / 255.f; + + m_tickCount++; + + if (m_tickCount > ANGLE_TO_FLOAT(angle)) + { + m_currentIntensity = float(m_intensity[0] + (amt * flickerRange)); + m_tickCount = 0; + } + break; + } + +#if 0 + // These need some more work elsewhere + case ColorFlickerLight: + { + BYTE rnd = randLight(); + float pct = ANGLE_TO_FLOAT(angle)/360.f; + + m_currentIntensity = m_intensity[rnd >= pct * 255]; + break; + } + + case RandomColorFlickerLight: + { + int flickerRange = m_intensity[1] - m_intensity[0]; + float amt = randLight() / 255.f; + + m_tickCount++; + + if (m_tickCount > ANGLE_TO_FLOAT(angle)) + { + m_currentIntensity = m_intensity[0] + (amt * flickerRange); + m_tickCount = 0; + } + break; + } +#endif + + case SectorLight: + { + float intensity; + float scale = args[LIGHT_SCALE] / 8.f; + + if (scale == 0.f) scale = 1.f; + + intensity = Sector->lightlevel * scale; + intensity = clamp(intensity, 0.f, 255.f); + + m_currentIntensity = intensity; + break; + } + + case PointLight: + m_currentIntensity = float(m_intensity[0]); + break; + } + + UpdateLocation(); +} + + + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::UpdateLocation() +{ + fixed_t oldx=x; + fixed_t oldy=y; + fixed_t oldradius=radius; + float intensity; + + if (IsActive()) + { + if (target) + { + angle_t angle = target->angle>>ANGLETOFINESHIFT; + PrevX = x = target->x + FixedMul(m_offX, finecosine[angle]) + FixedMul(m_offZ, finesine[angle]); + PrevY = y = target->y + FixedMul(m_offX, finesine[angle]) - FixedMul(m_offZ, finecosine[angle]); + PrevZ = z = target->z + m_offY + target->GetBobOffset(); + subsector = R_PointInSubsector(x, y); + Sector = subsector->sector; + } + + + // The radius being used here is always the maximum possible with the + // current settings. This avoids constant relinking of flickering lights + + if (lighttype == FlickerLight || lighttype == RandomFlickerLight) + { + intensity = float(m_intensity[1]); + } + else + { + intensity = m_currentIntensity; + } + radius = FLOAT2FIXED(intensity * 2.0f * gl_lights_size); + + if (x!=oldx || y!=oldy || radius!=oldradius) + { + //Update the light lists + LinkLight(); + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::SetOffset(fixed_t x, fixed_t y, fixed_t z) +{ + m_offX = x; + m_offY = y; + m_offZ = z; + UpdateLocation(); +} + + +//========================================================================== +// +// The target pointer in dynamic lights should never be substituted unless +// notOld is NULL (which indicates that the object was destroyed by force.) +// +//========================================================================== +size_t ADynamicLight::PointerSubstitution (DObject *old, DObject *notOld) +{ + AActor *saved_target = target; + size_t ret = Super::PointerSubstitution(old, notOld); + if (notOld != NULL) target = saved_target; + return ret; +} + +//============================================================================= +// +// These have been copied from the secnode code and modified for the light links +// +// P_AddSecnode() searches the current list to see if this sector is +// already there. If not, it adds a sector node at the head of the list of +// sectors this object appears in. This is called when creating a list of +// nodes that will get linked in later. Returns a pointer to the new node. +// +//============================================================================= + +FLightNode * AddLightNode(FLightNode ** thread, void * linkto, ADynamicLight * light, FLightNode *& nextnode) +{ + FLightNode * node; + + node = nextnode; + while (node) + { + if (node->targ==linkto) // Already have a node for this sector? + { + node->lightsource = light; // Yes. Setting m_thing says 'keep it'. + return(nextnode); + } + node = node->nextTarget; + } + + // Couldn't find an existing node for this sector. Add one at the head + // of the list. + + node = new FLightNode; + + node->targ = linkto; + node->lightsource = light; + + node->prevTarget = &nextnode; + node->nextTarget = nextnode; + + if (nextnode) nextnode->prevTarget = &node->nextTarget; + + // Add new node at head of sector thread starting at s->touching_thinglist + + node->prevLight = thread; + node->nextLight = *thread; + if (node->nextLight) node->nextLight->prevLight=&node->nextLight; + *thread = node; + return(node); +} + + +//============================================================================= +// +// P_DelSecnode() deletes a sector node from the list of +// sectors this object appears in. Returns a pointer to the next node +// on the linked list, or NULL. +// +//============================================================================= + +static FLightNode * DeleteLightNode(FLightNode * node) +{ + FLightNode * tn; // next node on thing thread + + if (node) + { + + *node->prevTarget = node->nextTarget; + if (node->nextTarget) node->nextTarget->prevTarget=node->prevTarget; + + *node->prevLight = node->nextLight; + if (node->nextLight) node->nextLight->prevLight=node->prevLight; + + // Return this node to the freelist + tn=node->nextTarget; + delete node; + return(tn); + } + return(NULL); +} // phares 3/13/98 + + + +//========================================================================== +// +// Gets the light's distance to a line +// +//========================================================================== + +float ADynamicLight::DistToSeg(seg_t *seg) +{ + float u, px, py; + + float seg_dx = FIXED2FLOAT(seg->v2->x - seg->v1->x); + float seg_dy = FIXED2FLOAT(seg->v2->y - seg->v1->y); + float seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy; + + u = ( FIXED2FLOAT(x - seg->v1->x) * seg_dx + FIXED2FLOAT(y - seg->v1->y) * seg_dy) / seg_length_sq; + if (u < 0.f) u = 0.f; // clamp the test point to the line segment + if (u > 1.f) u = 1.f; + + px = FIXED2FLOAT(seg->v1->x) + (u * seg_dx); + py = FIXED2FLOAT(seg->v1->y) + (u * seg_dy); + + px -= FIXED2FLOAT(x); + py -= FIXED2FLOAT(y); + + return (px*px) + (py*py); +} + + +//========================================================================== +// +// Collect all touched sidedefs and subsectors +// to sidedefs and sector parts. +// +//========================================================================== + +void ADynamicLight::CollectWithinRadius(subsector_t *subSec, float radius) +{ + if (!subSec) return; + + subSec->validcount = ::validcount; + + touching_subsectors = AddLightNode(&subSec->lighthead, subSec, this, touching_subsectors); + if (subSec->sector->validcount != ::validcount) + { + touching_sector = AddLightNode(&subSec->render_sector->lighthead, subSec->sector, this, touching_sector); + subSec->sector->validcount = ::validcount; + } + + for (unsigned int i = 0; i < subSec->numlines; i++) + { + seg_t * seg = subSec->firstline + i; + + if (seg->sidedef && seg->linedef && seg->linedef->validcount!=::validcount) + { + // light is in front of the seg + if (DMulScale32 (y-seg->v1->y, seg->v2->x-seg->v1->x, seg->v1->x-x, seg->v2->y-seg->v1->y) <=0) + { + seg->linedef->validcount=validcount; + touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); + } + } + + seg_t *partner = seg->PartnerSeg; + if (partner) + { + subsector_t *sub = partner->Subsector; + if (sub != NULL && sub->validcount!=::validcount) + { + // check distance from x/y to seg and if within radius add opposing subsector (lather/rinse/repeat) + if (DistToSeg(seg) <= radius) + { + CollectWithinRadius(sub, radius); + } + } + } + } +} + +//========================================================================== +// +// Link the light into the world +// +//========================================================================== + +void ADynamicLight::LinkLight() +{ + // mark the old light nodes + FLightNode * node; + + node = touching_sides; + while (node) + { + node->lightsource = NULL; + node = node->nextTarget; + } + node = touching_subsectors; + while (node) + { + node->lightsource = NULL; + node = node->nextTarget; + } + node = touching_sector; + while (node) + { + node->lightsource = NULL; + node = node->nextTarget; + } + + if (radius>0) + { + // passing in radius*radius allows us to do a distance check without any calls to sqrtf + subsector_t * subSec = R_PointInSubsector(x, y); + if (subSec) + { + float fradius = FIXED2FLOAT(radius); + ::validcount++; + CollectWithinRadius(subSec, fradius*fradius); + } + } + + // Now delete any nodes that won't be used. These are the ones where + // m_thing is still NULL. + + node = touching_sides; + while (node) + { + if (node->lightsource == NULL) + { + node = DeleteLightNode(node); + } + else + node = node->nextTarget; + } + + node = touching_subsectors; + while (node) + { + if (node->lightsource == NULL) + { + node = DeleteLightNode(node); + } + else + node = node->nextTarget; + } + + node = touching_sector; + while (node) + { + if (node->lightsource == NULL) + { + node = DeleteLightNode(node); + } + else + node = node->nextTarget; + } +} + + +//========================================================================== +// +// Deletes the link lists +// +//========================================================================== +void ADynamicLight::UnlinkLight () +{ + if (owned && target != NULL) + { + // Delete reference in owning actor + for(int c=target->dynamiclights.Size()-1; c>=0; c--) + { + if (target->dynamiclights[c] == this) + { + target->dynamiclights.Delete(c); + break; + } + } + } + while (touching_sides) touching_sides = DeleteLightNode(touching_sides); + while (touching_subsectors) touching_subsectors = DeleteLightNode(touching_subsectors); + while (touching_sector) touching_sector = DeleteLightNode(touching_sector); +} + +void ADynamicLight::Destroy() +{ + UnlinkLight(); + Super::Destroy(); +} + + +//========================================================================== +// +// Needed for garbage collection +// +//========================================================================== + +size_t AActor::PropagateMark() +{ + for (unsigned i=0; i it; + + while ((dl=it.Next())) + { + walls=0; + sectors=0; + subsecs = 0; + Printf("%s at (%f, %f, %f), color = 0x%02x%02x%02x, radius = %f ", + dl->target? dl->target->GetClass()->TypeName.GetChars() : dl->GetClass()->TypeName.GetChars(), + FIXED2FLOAT(dl->x), FIXED2FLOAT(dl->y), FIXED2FLOAT(dl->z), dl->args[LIGHT_RED], + dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], FIXED2FLOAT(dl->radius)); + i++; + + if (dl->target) + { + FTextureID spr = gl_GetSpriteFrame(dl->target->sprite, dl->target->frame, 0, 0, NULL); + Printf(", frame = %s ", TexMan[spr]->Name.GetChars()); + } + + + FLightNode * node; + + node=dl->touching_sides; + + while (node) + { + walls++; + allwalls++; + node = node->nextTarget; + } + + node=dl->touching_subsectors; + + while (node) + { + allsubsecs++; + subsecs++; + node = node->nextTarget; + } + + node = dl->touching_sector; + + while (node) + { + allsectors++; + sectors++; + node = node->nextTarget; + } + Printf("- %d walls, %d subsectors, %d sectors\n", walls, subsecs, sectors); + + } + Printf("%i dynamic lights, %d walls, %d subsectors, %d sectors\n\n\n", i, allwalls, allsubsecs, allsectors); +} + +CCMD(listsublights) +{ + for(int i=0;ilighthead; + while (node != NULL) + { + lights++; + node = node->nextLight; + } + + Printf(PRINT_LOG, "Subsector %d - %d lights\n", i, lights); + } +} + + diff --git a/src/gl/dynlights/gl_dynlight.cpp b/src/gl/dynlights/gl_dynlight.cpp new file mode 100644 index 000000000..f143a479b --- /dev/null +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -0,0 +1,1365 @@ +/* +** gl_dynlight.cpp +** Light definitions for actors. +** +**--------------------------------------------------------------------------- +** Copyright 2003 Timothy Stump +** Copyright 2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 +#include "i_system.h" +#include "doomtype.h" +#include "c_cvars.h" +#include "c_dispatch.h" +#include "m_random.h" +#include "sc_man.h" +#include "templates.h" +#include "w_wad.h" +#include "gi.h" +#include "r_state.h" +#include "stats.h" +#include "zstring.h" +#include "d_dehacked.h" + + +#include "gl/dynlights/gl_dynlight.h" +#include "gl/textures/gl_skyboxtexture.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_convert.h" + +EXTERN_CVAR (Float, gl_lights_intensity); +EXTERN_CVAR (Float, gl_lights_size); +int ScriptDepth; +void gl_InitGlow(FScanner &sc); +void gl_ParseBrightmap(FScanner &sc, int); +void gl_DestroyUserShaders(); +void gl_ParseHardwareShader(FScanner &sc, int deflump); +void gl_ParseSkybox(FScanner &sc); +void gl_ParseDetailTexture(FScanner &sc); +void gl_ParseVavoomSkybox(); + +//========================================================================== +// +// Dehacked aliasing +// +//========================================================================== + +inline const PClass * GetRealType(const PClass * ti) +{ + FActorInfo *rep = ti->ActorInfo->GetReplacement(false); + if (rep != ti->ActorInfo && rep != NULL && rep->Class->IsDescendantOf(RUNTIME_CLASS(ADehackedPickup))) + { + return rep->Class; + } + return ti; +} + + + +//========================================================================== +// +// Light associations +// +//========================================================================== +class FLightAssociation +{ +public: + //FLightAssociation(); + FLightAssociation(FName actorName, const char *frameName, FName lightName) + : m_ActorName(actorName), m_AssocLight(lightName) + { + strncpy(m_FrameName, frameName, 8); + } + + FName ActorName() { return m_ActorName; } + const char *FrameName() { return m_FrameName; } + FName Light() { return m_AssocLight; } + void ReplaceLightName(FName newName) { m_AssocLight = newName; } +protected: + char m_FrameName[8]; + FName m_ActorName, m_AssocLight; +}; + +TArray LightAssociations; + + +//========================================================================== +// +// Light definitions +// +//========================================================================== +class FLightDefaults +{ +public: + FLightDefaults(FName name, ELightType type); + + void ApplyProperties(ADynamicLight * light) const; + FName GetName() const { return m_Name; } + void SetAngle(angle_t angle) { m_Angle = angle; } + void SetArg(int arg, BYTE val) { m_Args[arg] = val; } + BYTE GetArg(int arg) { return m_Args[arg]; } + void SetOffset(float* ft) { m_X = FLOAT2FIXED(ft[0]); m_Y = FLOAT2FIXED(ft[1]); m_Z = FLOAT2FIXED(ft[2]); } + void SetSubtractive(bool subtract) { m_subtractive = subtract; } + void SetAdditive(bool add) { m_additive = add; } + void SetDontLightSelf(bool add) { m_dontlightself = add; } + void SetHalo(bool halo) { m_halo = halo; } +protected: + FName m_Name; + unsigned char m_Args[5]; + angle_t m_Angle; + fixed_t m_X, m_Y, m_Z; + ELightType m_type; + bool m_subtractive, m_additive, m_halo, m_dontlightself; +}; + +TArray LightDefaults; + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +FLightDefaults::FLightDefaults(FName name, ELightType type) +{ + m_Name = name; + m_type = type; + + m_X = m_Y = m_Z = 0; + memset(m_Args, 0, 5); + + m_subtractive = false; + m_additive = false; + m_halo = false; + m_dontlightself = false; +} + +void FLightDefaults::ApplyProperties(ADynamicLight * light) const +{ + light->lighttype = m_type; + light->angle = m_Angle; + light->SetOffset(m_X, m_Y, m_Z); + light->halo = m_halo; + for (int a = 0; a < 3; a++) light->args[a] = clamp((int)(m_Args[a] * gl_lights_intensity), 0, 255); + light->m_intensity[0] = int(m_Args[LIGHT_INTENSITY]); + light->m_intensity[1] = int(m_Args[LIGHT_SECONDARY_INTENSITY]); + light->flags4&=~(MF4_ADDITIVE|MF4_SUBTRACTIVE|MF4_DONTLIGHTSELF); + if (m_subtractive) light->flags4|=MF4_SUBTRACTIVE; + if (m_additive) light->flags4|=MF4_ADDITIVE; + if (m_dontlightself) light->flags4|=MF4_DONTLIGHTSELF; +} + + +//========================================================================== +// +// light definition file parser +// +//========================================================================== + + +static const char *LightTags[]= +{ + "color", + "size", + "secondarySize", + "offset", + "chance", + "interval", + "scale", + "frame", + "light", + "{", + "}", + "subtractive", + "additive", + "halo", + "dontlightself", + NULL +}; + + +enum { + LIGHTTAG_COLOR, + LIGHTTAG_SIZE, + LIGHTTAG_SECSIZE, + LIGHTTAG_OFFSET, + LIGHTTAG_CHANCE, + LIGHTTAG_INTERVAL, + LIGHTTAG_SCALE, + LIGHTTAG_FRAME, + LIGHTTAG_LIGHT, + LIGHTTAG_OPENBRACE, + LIGHTTAG_CLOSEBRACE, + LIGHTTAG_SUBTRACTIVE, + LIGHTTAG_ADDITIVE, + LIGHTTAG_HALO, + LIGHTTAG_DONTLIGHTSELF, +}; + + +extern int ScriptDepth; + + +//========================================================================== +// +// +// +//========================================================================== + +inline float gl_ParseFloat(FScanner &sc) +{ + sc.GetFloat(); + + return float(sc.Float); +} + + +inline int gl_ParseInt(FScanner &sc) +{ + sc.GetNumber(); + + return sc.Number; +} + + +inline char *gl_ParseString(FScanner &sc) +{ + sc.GetString(); + + return sc.String; +} + + +void gl_ParseTriple(FScanner &sc, float floatVal[3]) +{ + for (int i = 0; i < 3; i++) + { + floatVal[i] = gl_ParseFloat(sc); + } +} + + +void gl_AddLightDefaults(FLightDefaults *defaults) +{ + FLightDefaults *temp; + unsigned int i; + + // remove duplicates + for (i = 0; i < LightDefaults.Size(); i++) + { + temp = LightDefaults[i]; + if (temp->GetName() == defaults->GetName()) + { + delete temp; + LightDefaults.Delete(i); + break; + } + } + + LightDefaults.Push(defaults); +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParsePointLight(FScanner &sc) +{ + int type; + float floatTriple[3]; + int intVal; + FLightDefaults *defaults; + + // get name + sc.GetString(); + FName name = sc.String; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + defaults = new FLightDefaults(name, PointLight); + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_COLOR: + gl_ParseTriple(sc, floatTriple); + defaults->SetArg(LIGHT_RED, clamp((int)(floatTriple[0] * 255), 0, 255)); + defaults->SetArg(LIGHT_GREEN, clamp((int)(floatTriple[1] * 255), 0, 255)); + defaults->SetArg(LIGHT_BLUE, clamp((int)(floatTriple[2] * 255), 0, 255)); + break; + case LIGHTTAG_OFFSET: + gl_ParseTriple(sc, floatTriple); + defaults->SetOffset(floatTriple); + break; + case LIGHTTAG_SIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_INTENSITY, intVal); + break; + case LIGHTTAG_SUBTRACTIVE: + defaults->SetSubtractive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_ADDITIVE: + defaults->SetAdditive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_HALO: + defaults->SetHalo(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_DONTLIGHTSELF: + defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + gl_AddLightDefaults(defaults); + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParsePulseLight(FScanner &sc) +{ + int type; + float floatVal, floatTriple[3]; + int intVal; + FLightDefaults *defaults; + + // get name + sc.GetString(); + FName name = sc.String; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + defaults = new FLightDefaults(name, PulseLight); + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_COLOR: + gl_ParseTriple(sc, floatTriple); + defaults->SetArg(LIGHT_RED, clamp((int)(floatTriple[0] * 255), 0, 255)); + defaults->SetArg(LIGHT_GREEN, clamp((int)(floatTriple[1] * 255), 0, 255)); + defaults->SetArg(LIGHT_BLUE, clamp((int)(floatTriple[2] * 255), 0, 255)); + break; + case LIGHTTAG_OFFSET: + gl_ParseTriple(sc, floatTriple); + defaults->SetOffset(floatTriple); + break; + case LIGHTTAG_SIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_INTENSITY, intVal); + break; + case LIGHTTAG_SECSIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_SECONDARY_INTENSITY, intVal); + break; + case LIGHTTAG_INTERVAL: + floatVal = gl_ParseFloat(sc); + defaults->SetAngle(FLOAT_TO_ANGLE(floatVal * TICRATE)); + break; + case LIGHTTAG_SUBTRACTIVE: + defaults->SetSubtractive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_HALO: + defaults->SetHalo(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_DONTLIGHTSELF: + defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + gl_AddLightDefaults(defaults); + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseFlickerLight(FScanner &sc) +{ + int type; + float floatVal, floatTriple[3]; + int intVal; + FLightDefaults *defaults; + + // get name + sc.GetString(); + FName name = sc.String; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + defaults = new FLightDefaults(name, FlickerLight); + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_COLOR: + gl_ParseTriple(sc, floatTriple); + defaults->SetArg(LIGHT_RED, clamp((int)(floatTriple[0] * 255), 0, 255)); + defaults->SetArg(LIGHT_GREEN, clamp((int)(floatTriple[1] * 255), 0, 255)); + defaults->SetArg(LIGHT_BLUE, clamp((int)(floatTriple[2] * 255), 0, 255)); + break; + case LIGHTTAG_OFFSET: + gl_ParseTriple(sc, floatTriple); + defaults->SetOffset(floatTriple); + break; + case LIGHTTAG_SIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_INTENSITY, intVal); + break; + case LIGHTTAG_SECSIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_SECONDARY_INTENSITY, intVal); + break; + case LIGHTTAG_CHANCE: + floatVal = gl_ParseFloat(sc); + defaults->SetAngle((angle_t)(floatVal * ANGLE_MAX)); + break; + case LIGHTTAG_SUBTRACTIVE: + defaults->SetSubtractive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_HALO: + defaults->SetHalo(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_DONTLIGHTSELF: + defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + gl_AddLightDefaults(defaults); + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseFlickerLight2(FScanner &sc) +{ + int type; + float floatVal, floatTriple[3]; + int intVal; + FLightDefaults *defaults; + + // get name + sc.GetString(); + FName name = sc.String; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + defaults = new FLightDefaults(name, RandomFlickerLight); + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_COLOR: + gl_ParseTriple(sc, floatTriple); + defaults->SetArg(LIGHT_RED, clamp((int)(floatTriple[0] * 255), 0, 255)); + defaults->SetArg(LIGHT_GREEN, clamp((int)(floatTriple[1] * 255), 0, 255)); + defaults->SetArg(LIGHT_BLUE, clamp((int)(floatTriple[2] * 255), 0, 255)); + break; + case LIGHTTAG_OFFSET: + gl_ParseTriple(sc, floatTriple); + defaults->SetOffset(floatTriple); + break; + case LIGHTTAG_SIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_INTENSITY, intVal); + break; + case LIGHTTAG_SECSIZE: + intVal = clamp(gl_ParseInt(sc), 0, 255); + defaults->SetArg(LIGHT_SECONDARY_INTENSITY, intVal); + break; + case LIGHTTAG_INTERVAL: + floatVal = gl_ParseFloat(sc); + defaults->SetAngle((angle_t)(floatVal * ANGLE_MAX)); + break; + case LIGHTTAG_SUBTRACTIVE: + defaults->SetSubtractive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_HALO: + defaults->SetHalo(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_DONTLIGHTSELF: + defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + if (defaults->GetArg(LIGHT_SECONDARY_INTENSITY) < defaults->GetArg(LIGHT_INTENSITY)) + { + BYTE v = defaults->GetArg(LIGHT_SECONDARY_INTENSITY); + defaults->SetArg(LIGHT_SECONDARY_INTENSITY, defaults->GetArg(LIGHT_INTENSITY)); + defaults->SetArg(LIGHT_INTENSITY, v); + } + gl_AddLightDefaults(defaults); + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseSectorLight(FScanner &sc) +{ + int type; + float floatVal; + float floatTriple[3]; + FLightDefaults *defaults; + + // get name + sc.GetString(); + FName name = sc.String; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + defaults = new FLightDefaults(name, SectorLight); + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_COLOR: + gl_ParseTriple(sc, floatTriple); + defaults->SetArg(LIGHT_RED, clamp((int)(floatTriple[0] * 255), 0, 255)); + defaults->SetArg(LIGHT_GREEN, clamp((int)(floatTriple[1] * 255), 0, 255)); + defaults->SetArg(LIGHT_BLUE, clamp((int)(floatTriple[2] * 255), 0, 255)); + break; + case LIGHTTAG_OFFSET: + gl_ParseTriple(sc, floatTriple); + defaults->SetOffset(floatTriple); + break; + case LIGHTTAG_SCALE: + floatVal = gl_ParseFloat(sc); + defaults->SetArg(LIGHT_SCALE, (BYTE)(floatVal * 255)); + break; + case LIGHTTAG_SUBTRACTIVE: + defaults->SetSubtractive(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_HALO: + defaults->SetHalo(gl_ParseInt(sc) != 0); + break; + case LIGHTTAG_DONTLIGHTSELF: + defaults->SetDontLightSelf(gl_ParseInt(sc) != 0); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + gl_AddLightDefaults(defaults); + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_AddLightAssociation(const char *actor, const char *frame, const char *light) +{ + FLightAssociation *temp; + unsigned int i; + FLightAssociation assoc(actor, frame, light); + + for (i = 0; i < LightAssociations.Size(); i++) + { + temp = &LightAssociations[i]; + if (temp->ActorName() == assoc.ActorName()) + { + if (strcmp(temp->FrameName(), assoc.FrameName()) == 0) + { + temp->ReplaceLightName(assoc.Light()); + return; + } + } + } + + LightAssociations.Push(assoc); +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseFrame(FScanner &sc, FString name) +{ + int type, startDepth; + FString frameName; + + // get name + sc.GetString(); + if (strlen(sc.String) > 8) + { + sc.ScriptError("Name longer than 8 characters: %s\n", sc.String); + } + frameName = sc.String; + + startDepth = ScriptDepth; + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + ScriptDepth++; + while (ScriptDepth > startDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_LIGHT: + gl_ParseString(sc); + gl_AddLightAssociation(name, frameName, sc.String); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseObject(FScanner &sc) +{ + int type; + FString name; + + // get name + sc.GetString(); + name = sc.String; + if (!PClass::FindClass(name)) + sc.ScriptMessage("Warning: dynamic lights attached to non-existent actor %s\n", name.GetChars()); + + // check for opening brace + sc.GetString(); + if (sc.Compare("{")) + { + ScriptDepth++; + while (ScriptDepth) + { + sc.GetString(); + type = sc.MatchString(LightTags); + switch (type) + { + case LIGHTTAG_OPENBRACE: + ScriptDepth++; + break; + case LIGHTTAG_CLOSEBRACE: + ScriptDepth--; + break; + case LIGHTTAG_FRAME: + gl_ParseFrame(sc, name); + break; + default: + sc.ScriptError("Unknown tag: %s\n", sc.String); + } + } + } + else + { + sc.ScriptError("Expected '{'.\n"); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ReleaseLights() +{ + unsigned int i; + + for (i = 0; i < LightDefaults.Size(); i++) + { + delete LightDefaults[i]; + } + + LightAssociations.Clear(); + LightDefaults.Clear(); +} + +//========================================================================== +// +// +// +//========================================================================== + +// these are the core types available in the *DEFS lump +static const char *CoreKeywords[]= +{ + "pointlight", + "pulselight", + "flickerlight", + "flickerlight2", + "sectorlight", + "object", + "clearlights", + "shader", + "clearshaders", + "skybox", + "glow", + "brightmap", + "disable_fullbright", + "hardwareshader", + "detail", + "#include", + NULL +}; + + +enum +{ + LIGHT_POINT, + LIGHT_PULSE, + LIGHT_FLICKER, + LIGHT_FLICKER2, + LIGHT_SECTOR, + LIGHT_OBJECT, + LIGHT_CLEAR, + TAG_SHADER, + TAG_CLEARSHADERS, + TAG_SKYBOX, + TAG_GLOW, + TAG_BRIGHTMAP, + TAG_DISABLE_FB, + TAG_HARDWARESHADER, + TAG_DETAIL, + TAG_INCLUDE, +}; + + +//========================================================================== +// +// This is only here so any shader definition for ZDoomGL can be skipped +// There is no functionality for this stuff! +// +//========================================================================== +bool gl_ParseShader(FScanner &sc) +{ + int ShaderDepth = 0; + + if (sc.GetString()) + { + char *tmp; + + tmp = strstr(sc.String, "{"); + while (tmp) + { + ShaderDepth++; + tmp++; + tmp = strstr(tmp, "{"); + } + + tmp = strstr(sc.String, "}"); + while (tmp) + { + ShaderDepth--; + tmp++; + tmp = strstr(tmp, "}"); + } + + if (ShaderDepth == 0) return true; + } + return false; +} + +//========================================================================== +// +// Light associations per actor class +// +// Turn this inefficient mess into something that can be used at run time. +// +//========================================================================== + +class FInternalLightAssociation +{ +public: + FInternalLightAssociation(FLightAssociation * asso); + int Sprite() const { return m_sprite; } + int Frame() const { return m_frame; } + const FLightDefaults *Light() const { return m_AssocLight; } +protected: + int m_sprite; + int m_frame; + FLightDefaults * m_AssocLight; +}; + +//========================================================================== +// +// +// +//========================================================================== + +FInternalLightAssociation::FInternalLightAssociation(FLightAssociation * asso) +{ + + m_AssocLight=NULL; + for(unsigned int i=0;iGetName() == asso->Light()) + { + m_AssocLight = LightDefaults[i]; + break; + } + } + + m_sprite=-1; + m_frame = -1; + for (unsigned i = 0; i < sprites.Size (); ++i) + { + if (strncmp (sprites[i].name, asso->FrameName(), 4) == 0) + { + m_sprite = (int)i; + break; + } + } + + // Only handle lights for full frames. + // I won't bother with special lights for single rotations + // because there is no decent use for them! + if (strlen(asso->FrameName())==5 || asso->FrameName()[5]=='0') + { + m_frame = toupper(asso->FrameName()[4])-'A'; + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +inline TDeletingArray * gl_GetActorLights(AActor * actor) +{ + return (TDeletingArray*)actor->lightassociations; +} + +TDeletingArray< TDeletingArray * > AssoDeleter; + +//========================================================================== +// +// State lights +// +//========================================================================== +TArray ParsedStateLights; +TArray StateLights; + + + +//========================================================================== +// +// +// +//========================================================================== + +void gl_InitializeActorLights() +{ + for(unsigned int i=0;ilightassociations) + { + TDeletingArray *p =new TDeletingArray; + defaults->lightassociations = p; + AssoDeleter.Push(p); + } + TDeletingArray * lights = gl_GetActorLights(defaults); + if (iasso->Light()==NULL) + { + // The definition was not valid. + delete iasso; + } + else + { + lights->Push(iasso); + } + } + } + } + // we don't need the parser data for the light associations anymore + LightAssociations.Clear(); + LightAssociations.ShrinkToFit(); + + StateLights.Resize(ParsedStateLights.Size()+1); + for(unsigned i=0; iGetName() == ParsedStateLights[i]) + { + StateLights[i] = LightDefaults[j]; + break; + } + } + } + else StateLights[i] = NULL; + } + StateLights[StateLights.Size()-1] = NULL; // terminator + ParsedStateLights.Clear(); + ParsedStateLights.ShrinkToFit(); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void gl_AttachLight(AActor *actor, unsigned int count, const FLightDefaults *lightdef) +{ + ADynamicLight *light; + + // I'm skipping the single rotations because that really doesn't make sense! + if (count < actor->dynamiclights.Size()) + { + light = barrier_cast(actor->dynamiclights[count]); + assert(light != NULL); + } + else + { + light = Spawn(actor->x, actor->y, actor->z, NO_REPLACE); + light->target = actor; + light->owned = true; + actor->dynamiclights.Push(light); + } + light->flags2&=~MF2_DORMANT; + lightdef->ApplyProperties(light); +} + +//========================================================================== +// +// per-state light adjustment +// +//========================================================================== + +void gl_SetActorLights(AActor *actor) +{ + TArray * l = gl_GetActorLights(actor); + unsigned int count = 0; + + All.Clock(); + if (actor->state == NULL) return; + if (l) + { + TArray & LightAssociations=*l; + ADynamicLight *lights, *tmpLight; + unsigned int i; + + int sprite = actor->sprite; + int frame = actor->frame; + + lights = tmpLight = NULL; + + + for (i = 0; i < LightAssociations.Size(); i++) + { + if (LightAssociations[i]->Sprite() == sprite && + (LightAssociations[i]->Frame()==frame || LightAssociations[i]->Frame()==-1)) + { + gl_AttachLight(actor, count++, LightAssociations[i]->Light()); + } + } + } + if (count == 0 && actor->state->Light > 0) + { + for(int i= actor->state->Light; StateLights[i] != NULL; i++) + { + if (StateLights[i] != (FLightDefaults*)-1) + { + gl_AttachLight(actor, count++, StateLights[i]); + } + } + } + + for(;countdynamiclights.Size();count++) + { + actor->dynamiclights[count]->flags2|=MF2_DORMANT; + memset(actor->dynamiclights[count]->args, 0, sizeof(actor->args)); + } + All.Unclock(); +} + +//========================================================================== +// +// This is called before saving the game +// +//========================================================================== + +void gl_DeleteAllAttachedLights() +{ + TThinkerIterator it; + AActor * a; + ADynamicLight * l; + + while ((a=it.Next())) + { + a->dynamiclights.Clear(); + } + + TThinkerIterator it2; + + l=it2.Next(); + while (l) + { + ADynamicLight * ll = it2.Next(); + if (l->owned) l->Destroy(); + l=ll; + } + + +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_RecreateAllAttachedLights() +{ + TThinkerIterator it; + AActor * a; + + while ((a=it.Next())) + { + gl_SetActorLights(a); + } +} + + +//========================================================================== +// The actual light def parsing code is there. +// DoParseDefs is no longer called directly by ParseDefs, now it's called +// by LoadDynLightDefs, which wasn't simply integrated into ParseDefs +// because of the way the code needs to load two out of five lumps. +//========================================================================== +void gl_DoParseDefs(FScanner &sc, int workingLump) +{ + int recursion=0; + int lump, type; + + // Get actor class name. + while (true) + { + sc.SavePos(); + if (!sc.GetToken ()) + { + return; + } + type = sc.MatchString(CoreKeywords); + switch (type) + { + case TAG_INCLUDE: + { + sc.MustGetString(); + // This is not using sc.Open because it can print a more useful error message when done here + lump = Wads.CheckNumForFullName(sc.String, true); + if (lump==-1) + sc.ScriptError("Lump '%s' not found", sc.String); + + FScanner newscanner(lump); + gl_DoParseDefs(newscanner, lump); + break; + } + case LIGHT_POINT: + gl_ParsePointLight(sc); + break; + case LIGHT_PULSE: + gl_ParsePulseLight(sc); + break; + case LIGHT_FLICKER: + gl_ParseFlickerLight(sc); + break; + case LIGHT_FLICKER2: + gl_ParseFlickerLight2(sc); + break; + case LIGHT_SECTOR: + gl_ParseSectorLight(sc); + break; + case LIGHT_OBJECT: + gl_ParseObject(sc); + break; + case LIGHT_CLEAR: + gl_ReleaseLights(); + break; + case TAG_SHADER: + gl_ParseShader(sc); + break; + case TAG_CLEARSHADERS: + break; + case TAG_SKYBOX: + gl_ParseSkybox(sc); + break; + case TAG_GLOW: + gl_InitGlow(sc); + break; + case TAG_BRIGHTMAP: + gl_ParseBrightmap(sc, workingLump); + break; + case TAG_HARDWARESHADER: + gl_ParseHardwareShader(sc, workingLump); + break; + case TAG_DETAIL: + gl_ParseDetailTexture(sc); + break; + case TAG_DISABLE_FB: + { + /* not implemented. + sc.MustGetString(); + const PClass *cls = PClass::FindClass(sc.String); + if (cls) GetDefaultByType(cls)->renderflags |= RF_NEVERFULLBRIGHT; + */ + } + break; + default: + sc.ScriptError("Error parsing defs. Unknown tag: %s.\n", sc.String); + break; + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_LoadGLDefs(const char * defsLump) +{ + int workingLump, lastLump; + + lastLump = 0; + while ((workingLump = Wads.FindLump(defsLump, &lastLump)) != -1) + { + FScanner sc(workingLump); + gl_DoParseDefs(sc, workingLump); + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +void gl_ParseDefs() +{ + const char *defsLump = NULL; + + atterm( gl_ReleaseLights ); + gl_ReleaseLights(); + gl_DestroyUserShaders(); + switch (gameinfo.gametype) + { + case GAME_Heretic: + defsLump = "HTICDEFS"; + break; + case GAME_Hexen: + defsLump = "HEXNDEFS"; + break; + case GAME_Strife: + defsLump = "STRFDEFS"; + break; + case GAME_Doom: + defsLump = "DOOMDEFS"; + break; + case GAME_Chex: + defsLump = "CHEXDEFS"; + break; + default: // silence GCC + break; + } + gl_ParseVavoomSkybox(); + if (defsLump != NULL) gl_LoadGLDefs(defsLump); + gl_LoadGLDefs("GLDEFS"); + gl_InitializeActorLights(); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void AddStateLight(FState *State, const char *lname) +{ + if (State->Light == 0) + { + ParsedStateLights.Push(NAME_None); + State->Light = ParsedStateLights.Push(FName(lname)); + } + else + { + ParsedStateLights.Push(FName(lname)); + } +} diff --git a/src/gl/dynlights/gl_dynlight.h b/src/gl/dynlights/gl_dynlight.h new file mode 100644 index 000000000..568630898 --- /dev/null +++ b/src/gl/dynlights/gl_dynlight.h @@ -0,0 +1,190 @@ +#ifndef __GLC_DYNLIGHT_H +#define __GLC_DYNLIGHT_H + +#include "c_cvars.h" +#include "gl/utility/gl_geometric.h" +#include "gl/utility/gl_cycler.h" + + +EXTERN_CVAR(Bool, gl_lights) +EXTERN_CVAR(Bool, gl_attachedlights) + +class ADynamicLight; +class FArchive; + + + +enum +{ + LIGHT_RED = 0, + LIGHT_GREEN = 1, + LIGHT_BLUE = 2, + LIGHT_INTENSITY = 3, + LIGHT_SECONDARY_INTENSITY = 4, + LIGHT_SCALE = 3, +}; + +// This is as good as something new - and it can be set directly in the ActorInfo! +#define MF4_SUBTRACTIVE MF4_MISSILEEVENMORE +#define MF4_ADDITIVE MF4_MISSILEMORE +#define MF4_DONTLIGHTSELF MF4_SEESDAGGERS + +enum ELightType +{ + PointLight, + PulseLight, + FlickerLight, + RandomFlickerLight, + SectorLight, + SpotLight, + ColorPulseLight, + ColorFlickerLight, + RandomColorFlickerLight +}; + + +struct FLightNode +{ + FLightNode ** prevTarget; + FLightNode * nextTarget; + FLightNode ** prevLight; + FLightNode * nextLight; + ADynamicLight * lightsource; + union + { + side_t * targLine; + subsector_t * targSubsector; + void * targ; + }; +}; + + +// +// Base class +// +// [CO] I merged everything together in this one class so that I don't have +// to create and re-create an excessive amount of objects +// + +class ADynamicLight : public AActor +{ + DECLARE_CLASS (ADynamicLight, AActor) +public: + virtual void Tick(); + void Serialize(FArchive &arc); + BYTE GetRed() const { return args[LIGHT_RED]; } + BYTE GetGreen() const { return args[LIGHT_GREEN]; } + BYTE GetBlue() const { return args[LIGHT_BLUE]; } + float GetIntensity() const { return m_currentIntensity; } + float GetRadius() const { return (IsActive() ? GetIntensity() * 2.f : 0.f); } + void LinkLight(); + void UnlinkLight(); + size_t PointerSubstitution (DObject *old, DObject *notOld); + + virtual void BeginPlay(); + void PostBeginPlay(); + void Destroy(); + void Activate(AActor *activator); + void Deactivate(AActor *activator); + void SetOffset(fixed_t x, fixed_t y, fixed_t z); + void UpdateLocation(); + bool IsOwned() const { return owned; } + bool IsActive() const { return !(flags2&MF2_DORMANT); } + bool IsSubtractive() { return !!(flags4&MF4_SUBTRACTIVE); } + bool IsAdditive() { return !!(flags4&MF4_ADDITIVE); } + FState *targetState; + FLightNode * touching_sides; + FLightNode * touching_subsectors; + FLightNode * touching_sector; + +private: + float DistToSeg(seg_t *seg); + void CollectWithinRadius(subsector_t *subSec, float radius); + +protected: + fixed_t m_offX, m_offY, m_offZ; + float m_currentIntensity; + int m_tickCount; + unsigned int m_lastUpdate; + FCycler m_cycler; + subsector_t * subsector; + +public: + int m_intensity[2]; + BYTE lightflags; + BYTE lighttype; + bool owned; + bool halo; + BYTE color2[3]; + int bufferindex; + + // intermediate texture coordinate data + // this is stored in the light object to avoid recalculating it + // several times during rendering of a flat + Vector nearPt, up, right; + float scale; + +}; + +class AVavoomLight : public ADynamicLight +{ + DECLARE_CLASS (AVavoomLight, ADynamicLight) +public: + virtual void BeginPlay(); +}; + +class AVavoomLightWhite : public AVavoomLight +{ + DECLARE_CLASS (AVavoomLightWhite, AVavoomLight) +public: + virtual void BeginPlay(); +}; + +class AVavoomLightColor : public AVavoomLight +{ + DECLARE_CLASS (AVavoomLightColor, AVavoomLight) +public: + void BeginPlay(); +}; + + +enum +{ + STAT_DLIGHT=64 +}; + +struct FDynLightData +{ + TArray arrays[3]; + + void Clear() + { + arrays[0].Clear(); + arrays[1].Clear(); + arrays[2].Clear(); + } + + void Combine(int *siz, int max) + { + siz[0] = arrays[0].Size(); + siz[1] = siz[0] + arrays[1].Size(); + siz[2] = siz[1] + arrays[2].Size(); + arrays[0].Resize(arrays[0].Size() + arrays[1].Size() + arrays[2].Size()); + memcpy(&arrays[0][siz[0]], &arrays[1][0], arrays[1].Size() * sizeof(float)); + memcpy(&arrays[0][siz[1]], &arrays[2][0], arrays[2].Size() * sizeof(float)); + siz[0]>>=2; + siz[1]>>=2; + siz[2]>>=2; + if (siz[0] > max) siz[0] = max; + if (siz[1] > max) siz[1] = max; + if (siz[2] > max) siz[2] = max; + } +}; + + + +bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &data); +void gl_UploadLights(FDynLightData &data); + + +#endif diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp new file mode 100644 index 000000000..c504a33c4 --- /dev/null +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -0,0 +1,146 @@ +/* +** gl_dynlight1.cpp +** dynamic light application +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "c_dispatch.h" +#include "p_local.h" +#include "vectors.h" +#include "gl/gl_functions.h" +#include "g_level.h" + +#include "gl/system/gl_interface.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" + + +//========================================================================== +// +// Light related CVARs +// +//========================================================================== + +CUSTOM_CVAR (Bool, gl_lights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self) gl_RecreateAllAttachedLights(); + else gl_DeleteAllAttachedLights(); +} + +CVAR (Bool, gl_attachedlights, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR (Bool, gl_lights_checkside, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR (Float, gl_lights_intensity, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR (Float, gl_lights_size, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR (Bool, gl_light_sprites, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR (Bool, gl_light_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CUSTOM_CVAR (Bool, gl_lights_additive, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + gl_DeleteAllAttachedLights(); + gl_RecreateAllAttachedLights(); +} + +//========================================================================== +// +// Sets up the parameters to render one dynamic light onto one plane +// +//========================================================================== +bool gl_GetLight(Plane & p, ADynamicLight * light, bool checkside, bool forceadditive, FDynLightData &ldata) +{ + Vector fn, pos; + int i = 0; + + float x = FIXED2FLOAT(light->x); + float y = FIXED2FLOAT(light->y); + float z = FIXED2FLOAT(light->z); + + float dist = fabsf(p.DistToPoint(x, z, y)); + float radius = (light->GetRadius() * gl_lights_size); + + if (radius <= 0.f) return false; + if (dist > radius) return false; + if (checkside && gl_lights_checkside && p.PointOnSide(x, z, y)) + { + return false; + } + + + float cs; + if (gl_lights_additive || light->flags4&MF4_ADDITIVE || forceadditive) + { + cs = 0.2f; + i = 2; + } + else + { + cs = 1.0f; + } + + float r = light->GetRed() / 255.0f * cs * gl_lights_intensity; + float g = light->GetGreen() / 255.0f * cs * gl_lights_intensity; + float b = light->GetBlue() / 255.0f * cs * gl_lights_intensity; + + if (light->IsSubtractive()) + { + Vector v; + + v.Set(r, g, b); + r = v.Length() - r; + g = v.Length() - g; + b = v.Length() - b; + i = 1; + } + + float *data = &ldata.arrays[i][ldata.arrays[i].Reserve(8)]; + data[0] = x; + data[1] = z; + data[2] = y; + data[3] = radius; + data[4] = r; + data[5] = g; + data[6] = b; + data[7] = 0; + return true; +} + + diff --git a/src/gl/dynlights/gl_glow.cpp b/src/gl/dynlights/gl_glow.cpp new file mode 100644 index 000000000..ce763109d --- /dev/null +++ b/src/gl/dynlights/gl_glow.cpp @@ -0,0 +1,139 @@ +/* +** gl_glow.cpp +** Glowing flats like Doomsday +** +**--------------------------------------------------------------------------- +** Copyright 2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "w_wad.h" +#include "sc_man.h" +#include "v_video.h" +#include "r_defs.h" +#include "textures/textures.h" + +#include "gl/dynlights/gl_glow.h" + +//=========================================================================== +// +// Reads glow definitions from GLDEFS +// +//=========================================================================== +void gl_InitGlow(FScanner &sc) +{ + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + sc.MustGetString(); + if (sc.Compare("FLATS")) + { + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + sc.MustGetString(); + FTextureID flump=TexMan.CheckForTexture(sc.String, FTexture::TEX_Flat,FTextureManager::TEXMAN_TryAny); + FTexture *tex = TexMan[flump]; + if (tex) tex->gl_info.bGlowing = tex->gl_info.bFullbright = true; + } + } + else if (sc.Compare("WALLS")) + { + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + sc.MustGetString(); + FTextureID flump=TexMan.CheckForTexture(sc.String, FTexture::TEX_Wall,FTextureManager::TEXMAN_TryAny); + FTexture *tex = TexMan[flump]; + if (tex) tex->gl_info.bGlowing = tex->gl_info.bFullbright = true; + } + } + else if (sc.Compare("TEXTURE")) + { + sc.SetCMode(true); + sc.MustGetString(); + FTextureID flump=TexMan.CheckForTexture(sc.String, FTexture::TEX_Flat,FTextureManager::TEXMAN_TryAny); + FTexture *tex = TexMan[flump]; + sc.MustGetStringName(","); + sc.MustGetString(); + PalEntry color = V_GetColor(NULL, sc.String); + //sc.MustGetStringName(","); + //sc.MustGetNumber(); + if (sc.CheckString(",")) + { + if (sc.CheckNumber()) + { + if (tex) tex->gl_info.GlowHeight = sc.Number; + if (!sc.CheckString(",")) goto skip_fb; + } + + sc.MustGetStringName("fullbright"); + if (tex) tex->gl_info.bFullbright = true; + } + skip_fb: + sc.SetCMode(false); + + if (tex && color != 0) + { + tex->gl_info.bGlowing = true; + tex->gl_info.GlowColor = color; + } + } + } +} + + +//========================================================================== +// +// Checks whether a sprite should be affected by a glow +// +//========================================================================== +int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, int x, int y, int z) +{ + FTextureID floorpic = sec->GetTexture(sector_t::floor); + FTexture *tex = TexMan[floorpic]; + if (tex != NULL && tex->isGlowing()) + { + fixed_t floordiff = z - sec->floorplane.ZatPoint(x, y); + if (floordiff < tex->gl_info.GlowHeight*FRACUNIT && tex->gl_info.GlowHeight != 0) + { + int maxlight = (255+lightlevel)>>1; + fixed_t lightfrac = floordiff / tex->gl_info.GlowHeight; + if (lightfrac<0) lightfrac=0; + lightlevel= (lightfrac*lightlevel + maxlight*(FRACUNIT-lightfrac))>>FRACBITS; + } + } + return lightlevel; +} + diff --git a/src/gl/dynlights/gl_glow.h b/src/gl/dynlights/gl_glow.h new file mode 100644 index 000000000..bc3235685 --- /dev/null +++ b/src/gl/dynlights/gl_glow.h @@ -0,0 +1,10 @@ + +#ifndef __GL_GLOW +#define __GL_GLOW + +struct sector_t; + +void gl_InitGlow(const char * lumpnm); +int gl_CheckSpriteGlow(sector_t *sec, int lightlevel, int x, int y, int z); + +#endif diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp new file mode 100644 index 000000000..4fd3b985a --- /dev/null +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -0,0 +1,224 @@ +/* +** gl_lightbuffer.cpp +** Buffer data maintenance for dynamic lights +** +**--------------------------------------------------------------------------- +** Copyright 2014 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "gl/shaders/gl_shader.h" +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/system/gl_interface.h" +#include "gl/utility//gl_clock.h" + +static const int INITIAL_BUFFER_SIZE = 160000; // This means 80000 lights per frame and 160000*16 bytes == 2.56 MB. + +float *mMap; + +FLightBuffer::FLightBuffer() +{ + + mBufferSize = INITIAL_BUFFER_SIZE; + mByteSize = mBufferSize * sizeof(float); + if (gl.flags & RFL_SHADER_STORAGE_BUFFER) + { + mBufferType = GL_SHADER_STORAGE_BUFFER; + mBlockAlign = 0; + mBlockSize = mBufferSize; + } + else + { + mBufferType = GL_UNIFORM_BUFFER; + mBlockSize = gl.maxuniformblock / 16; + if (mBlockSize > 2048) mBlockSize = 2048; // we don't really need a larger buffer + mBlockAlign = mBlockSize / 2; + } + + glGenBuffers(1, &mBufferId); + glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, mBufferId); + glBindBuffer(mBufferType, mBufferId); // Note: Some older AMD drivers don't do that in glBindBufferBase, as they should. + if (gl.flags & RFL_BUFFER_STORAGE) + { + glBufferStorage(mBufferType, mByteSize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + } + else + { + glBufferData(mBufferType, mByteSize, NULL, GL_DYNAMIC_DRAW); + mBufferPointer = NULL; + } + + Clear(); + mLastMappedIndex = UINT_MAX; +} + +FLightBuffer::~FLightBuffer() +{ + glBindBuffer(mBufferType, 0); + glDeleteBuffers(1, &mBufferId); +} + +void FLightBuffer::Clear() +{ + mIndex = 0; + mIndices.Clear(); + mUploadIndex = 0; +} + +int FLightBuffer::UploadLights(FDynLightData &data) +{ + int size0 = data.arrays[0].Size()/4; + int size1 = data.arrays[1].Size()/4; + int size2 = data.arrays[2].Size()/4; + int totalsize = size0 + size1 + size2 + 1; + + // pointless type casting because some compilers can't print enough warnings. + if (mBlockAlign > 0 && (unsigned int)totalsize + (mIndex % mBlockAlign) > mBlockSize) + { + mIndex = ((mIndex + mBlockAlign) / mBlockAlign) * mBlockAlign; + + // can't be rendered all at once. + if ((unsigned int)totalsize > mBlockSize) + { + int diff = totalsize - (int)mBlockSize; + + size2 -= diff; + if (size2 < 0) + { + size1 += size2; + size2 = 0; + } + if (size1 < 0) + { + size0 += size1; + size1 = 0; + } + totalsize = size0 + size1 + size2 + 1; + } + } + + if (totalsize <= 1) return -1; + + if (mIndex + totalsize > mBufferSize/4) + { + // reallocate the buffer with twice the size + unsigned int newbuffer; + + // first unmap the old buffer + glBindBuffer(mBufferType, mBufferId); + glUnmapBuffer(mBufferType); + + // create and bind the new buffer, bind the old one to a copy target (too bad that DSA is not yet supported well enough to omit this crap.) + glGenBuffers(1, &newbuffer); + glBindBufferBase(mBufferType, LIGHTBUF_BINDINGPOINT, newbuffer); + glBindBuffer(mBufferType, newbuffer); // Note: Some older AMD drivers don't do that in glBindBufferBase, as they should. + glBindBuffer(GL_COPY_READ_BUFFER, mBufferId); + + // create the new buffer's storage (twice as large as the old one) + mBufferSize *= 2; + mByteSize *= 2; + if (gl.flags & RFL_BUFFER_STORAGE) + { + glBufferStorage(mBufferType, mByteSize, NULL, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); + } + else + { + glBufferData(mBufferType, mByteSize, NULL, GL_DYNAMIC_DRAW); + mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT); + } + + // copy contents and delete the old buffer. + glCopyBufferSubData(GL_COPY_READ_BUFFER, mBufferType, 0, 0, mByteSize/2); + glBindBuffer(GL_COPY_READ_BUFFER, 0); + glDeleteBuffers(1, &mBufferId); + mBufferId = newbuffer; + } + + float *copyptr; + + assert(mBufferPointer != NULL); + if (mBufferPointer == NULL) return -1; + copyptr = mBufferPointer + mIndex * 4; + + float parmcnt[] = { 0, float(size0), float(size0 + size1), float(size0 + size1 + size2) }; + + memcpy(©ptr[0], parmcnt, 4 * sizeof(float)); + memcpy(©ptr[4], &data.arrays[0][0], 4 * size0*sizeof(float)); + memcpy(©ptr[4 + 4*size0], &data.arrays[1][0], 4 * size1*sizeof(float)); + memcpy(©ptr[4 + 4*(size0 + size1)], &data.arrays[2][0], 4 * size2*sizeof(float)); + + unsigned int bufferindex = mIndex; + mIndex += totalsize; + draw_dlight += (totalsize-1) / 2; + return bufferindex; +} + +void FLightBuffer::Begin() +{ + if (!(gl.flags & RFL_BUFFER_STORAGE)) + { + glBindBuffer(mBufferType, mBufferId); + mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT); + } +} + +void FLightBuffer::Finish() +{ + if (!(gl.flags & RFL_BUFFER_STORAGE)) + { + glBindBuffer(mBufferType, mBufferId); + glUnmapBuffer(mBufferType); + mBufferPointer = NULL; + } +} + +int FLightBuffer::BindUBO(unsigned int index) +{ + unsigned int offset = (index / mBlockAlign) * mBlockAlign; + + if (offset != mLastMappedIndex) + { + // this will only get called if a uniform buffer is used. For a shader storage buffer we only need to bind the buffer once at the start to all shader programs + mLastMappedIndex = offset; + glBindBufferRange(GL_UNIFORM_BUFFER, LIGHTBUF_BINDINGPOINT, mBufferId, offset*16, mBlockSize*16); // we go from counting vec4's to counting bytes here. + } + return (index - offset); +} + + + diff --git a/src/gl/dynlights/gl_lightbuffer.h b/src/gl/dynlights/gl_lightbuffer.h new file mode 100644 index 000000000..8781ccb57 --- /dev/null +++ b/src/gl/dynlights/gl_lightbuffer.h @@ -0,0 +1,39 @@ +#ifndef __GL_LIGHTBUFFER_H +#define __GL_LIGHTBUFFER_H + +#include "tarray.h" +struct FDynLightData; + +class FLightBuffer +{ + TArray mIndices; + unsigned int mBufferId; + float * mBufferPointer; + + unsigned int mBufferType; + unsigned int mIndex; + unsigned int mUploadIndex; + unsigned int mLastMappedIndex; + unsigned int mBlockAlign; + unsigned int mBlockSize; + unsigned int mBufferSize; + unsigned int mByteSize; + +public: + + FLightBuffer(); + ~FLightBuffer(); + void Clear(); + int UploadLights(FDynLightData &data); + void Begin(); + void Finish(); + int BindUBO(unsigned int index); + unsigned int GetBlockSize() const { return mBlockSize; } + unsigned int GetBufferType() const { return mBufferType; } + unsigned int GetIndexPtr() const { return mIndices.Size(); } + void StoreIndex(int index) { mIndices.Push(index); } + int GetIndex(int i) const { return mIndices[i]; } +}; + +#endif + diff --git a/src/gl/gl_builddraw.cpp b/src/gl/gl_builddraw.cpp new file mode 100644 index 000000000..60b94b984 --- /dev/null +++ b/src/gl/gl_builddraw.cpp @@ -0,0 +1,594 @@ +/* +** gl_builddraw.cpp +** a build-like rendering algorithm +** Uses the sections created in gl_sections.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2008 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "i_system.h" +#include "p_local.h" +#include "c_dispatch.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/scene/gl_clipper.h" +#include "gl/utility/gl_clock.h" +#include "gl/data/gl_sections.h" +#include "gl/scene/gl_wall.h" + +#ifdef BUILD_TEST +#define D(x) x +#else +#define D(x) do{}while(0) +#endif + +EXTERN_CVAR (Bool, dumpsections) + +struct FBunch +{ + int startline; + int endline; + angle_t startangle; + angle_t endangle; + fixed_t minviewdist; + fixed_t maxviewdist; +}; + +void DoSubsector(subsector_t * sub, bool handlelines); + +EXTERN_CVAR(Bool, gl_render_walls) + +//========================================================================== +// +// From Build but changed to use doubles to prevent overflows +// +//========================================================================== + +static int WallInFront(FGLSectionLine *wal1, FGLSectionLine *wal2) +{ + double x11, y11, x21, y21, x12, y12, x22, y22, dx, dy, t1, t2; + + x11 = wal1->start->x; + y11 = wal1->start->y; + x21 = wal1->end->x; + y21 = wal1->end->y; + x12 = wal2->start->x; + y12 = wal2->start->y; + x22 = wal2->end->x; + y22 = wal2->end->y; + + dx = x21-x11; dy = y21-y11; + + t1 = (x12-x11)*dy - (y12-y11)*dx; + t2 = (x22-x11)*dy - (y22-y11)*dx; + if (t1 == 0) + { + t1 = t2; + if (t1 == 0) return(-1); + } + if (t2 == 0) t2 = t1; + + if ((t1*t2) >= 0) + { + t2 = (double(viewx)-x11) * dy - (double(viewy)-y11)*dx; + return((t2*t1) < 0); + } + + dx = x22-x12; dy = y22-y12; + t1 = (x11-x12)*dy - (y11-y12)*dx; + t2 = (x21-x12)*dy - (y21-y12)*dx; + if (t1 == 0) + { + t1 = t2; + if (t1 == 0) return(-1); + } + if (t2 == 0) t2 = t1; + if ((t1*t2) >= 0) + { + t2 = (double(viewx)-x12) * dy - (double(viewy)-y12)*dx; + return((t2*t1) >= 0); + } + return(-2); +} + +//========================================================================== +// +// This is a bit more complicated than it looks because angles can wrap +// around so we can only compare angle differences. +// +// Rules: +// 1. Any bunch can span at most 180°. +// 2. 2 bunches can never overlap at both ends +// 3. if there is an overlap one of the 2 starting points must be in the +// overlapping area. +// +//========================================================================== + +static int BunchInFront(FBunch *b1, FBunch *b2) +{ + angle_t anglecheck, endang; + + if (b2->startangle - b1->startangle < b1->endangle - b1->startangle) + { + // we have an overlap at b2->startangle + anglecheck = b2->startangle - b1->startangle; + + // Find the wall in b1 that overlaps b2->startangle + for(int i = b1->startline; i <= b1->endline; i++) + { + #ifdef _DEBUG + angle_t startang = SectionLines[i].start->GetClipAngleInverse() - b1->startangle; + #endif + endang = SectionLines[i].end->GetClipAngleInverse() - b1->startangle; + if (endang > anglecheck) + { + assert (startang <= anglecheck); + + // found a line + int ret = WallInFront(&SectionLines[b2->startline], &SectionLines[i]); + + D(Printf (PRINT_LOG, "Line %d <-> line %d: Result = %d.\n", + SectionLines[b2->startline].linedef-lines, + SectionLines[i].linedef-lines, ret)); + + return ret; + } + } + } + else if (b1->startangle - b2->startangle < b2->endangle - b2->startangle) + { + // we have an overlap at b1->startangle + anglecheck = b1->startangle - b2->startangle; + + // Find the wall in b2 that overlaps b1->startangle + for(int i = b2->startline; i <= b2->endline; i++) + { + #ifdef _DEBUG + angle_t startang = SectionLines[i].start->GetClipAngleInverse() - b2->startangle; + #endif + endang = SectionLines[i].end->GetClipAngleInverse() - b2->startangle; + if (endang > anglecheck) + { + assert (startang <= anglecheck); + + // found a line + int ret = WallInFront(&SectionLines[i], &SectionLines[b1->startline]); + + D(Printf (PRINT_LOG, "Line %d <-> line %d: Result = %d,\n", + SectionLines[i].linedef-lines, + SectionLines[b1->endline].linedef-lines, ret)); + + return ret; + } + } + } + // we have no overlap + return -1; +} + + +// ---------------------------------------------------------------------------- +// +// Bunches are groups of continuous lines +// This array stores the amount of points per bunch, +// the view angles for each point and the line index for the starting line +// +// ---------------------------------------------------------------------------- + +class BunchDrawer +{ + int LastBunch; + int StartTime; + TArray Bunches; + TArray CompareData; + sector_t fakebacksec; + + //========================================================================== + // + // + // + //========================================================================== +public: + BunchDrawer() + { + StartScene(); + } + + //========================================================================== + // + // + // + //========================================================================== +private: + void StartScene() + { + LastBunch = 0; + StartTime = I_MSTime(); + Bunches.Clear(); + } + + //========================================================================== + // + // + // + //========================================================================== + + void StartBunch(int linenum, angle_t startan, angle_t endan, vertex_t *startpt, vertex_t *endpt) + { + FBunch *bunch = &Bunches[LastBunch = Bunches.Reserve(1)]; + + bunch->startline = bunch->endline = linenum; + bunch->startangle = startan; + bunch->endangle = endan; + } + + //========================================================================== + // + // + // + //========================================================================== + + void AddLineToBunch(int newan) + { + Bunches[LastBunch].endline++; + Bunches[LastBunch].endangle = newan; + } + + //========================================================================== + // + // + // + //========================================================================== + + void DeleteBunch(int index) + { + Bunches.Delete(index); + } + + //========================================================================== + // + // ClipLine + // Clips the given segment + // + //========================================================================== + + enum + { + CL_Skip = 0, + CL_Draw = 1, + CL_Pass = 2, + }; + + + int ClipLine (FGLSectionLine *line, sector_t * sector, sector_t **pbacksector) + { + angle_t startAngle, endAngle; + sector_t * backsector = NULL; + bool blocking; + + startAngle = line->end->GetClipAngle(); + endAngle = line->start->GetClipAngle(); + *pbacksector = NULL; + + // Back side, i.e. backface culling - read: endAngle >= startAngle! + if (startAngle-endAngleotherside == -1) + { + // one-sided + clipper.SafeAddClipRange(startAngle, endAngle); + return CL_Draw; + } + else if (line->polysub == NULL) + { + // two sided and not a polyobject + if (line->linedef == NULL) + { + // Miniseg + return CL_Pass; + } + if (sector->sectornum == line->refseg->backsector->sectornum) + { + FTexture *tex = TexMan(line->sidedef->GetTexture(side_t::mid)); + if (!tex || tex->UseType==FTexture::TEX_Null) + { + // no mid texture: nothing to do here + return CL_Pass; + } + *pbacksector = sector; + return CL_Draw|CL_Pass; + } + else + { + // clipping checks are only needed when the backsector is not the same as the front sector + gl_CheckViewArea(line->start, line->end, line->refseg->frontsector, line->refseg->backsector); + + *pbacksector = backsector = gl_FakeFlat(line->refseg->backsector, &fakebacksec, true); + + blocking = gl_CheckClip(line->sidedef, sector, backsector); + if (blocking) + { + clipper.SafeAddClipRange(startAngle, endAngle); + return CL_Draw; + } + return CL_Draw|CL_Pass; + } + } + else + { + *pbacksector = sector; + return CL_Draw; + } + } + + //========================================================================== + // + // + // + //========================================================================== + + void ProcessBunch(int bnch) + { + FBunch *bunch = &Bunches[bnch]; + + sector_t fake; + sector_t *sec; + sector_t *backsector; + + D(Printf(PRINT_LOG, "------------------------------\nProcessing bunch %d (Startline %d)\n",bnch,SectionLines[bunch->startline].linedef-lines)); + ClipWall.Clock(); + for(int i=bunch->startline; i <= bunch->endline; i++) + { + FGLSectionLine *ln = &SectionLines[i]; + + + // Draw this line. todo: optimize + sec = gl_FakeFlat(ln->refseg->frontsector, &fake, false); + + int clipped = ClipLine(ln, sec, &backsector); + + D(Printf(PRINT_LOG, "line %d clip result is %d\n", ln->linedef - lines, clipped)); + + if (clipped & CL_Draw) + { + ln->linedef->flags |= ML_MAPPED; + + if (ln->linedef->validcount!=validcount) + { + ln->linedef->validcount=validcount; + + #ifndef BUILD_TEST + if (gl_render_walls) + { + SetupWall.Clock(); + + GLWall wall; + wall.Process(ln->refseg, sec, backsector, ln->polysub); + rendered_lines++; + + SetupWall.Unclock(); + } + #endif + } + } + + if (clipped & CL_Pass) + { + ClipWall.Unclock(); + ProcessSection(ln->otherside); + ClipWall.Clock(); + } + } + D(Printf(PRINT_LOG, "Bunch %d done\n------------------------------\n",bnch)); + ClipWall.Unclock(); + } + + //========================================================================== + // + // + // + //========================================================================== + + int FindClosestBunch() + { + int closest = 0; //Almost works, but not quite :( + + CompareData.Clear(); + for(unsigned i = 1; i < Bunches.Size(); i++) + { + switch (BunchInFront(&Bunches[i], &Bunches[closest])) + { + case 0: // i is in front + closest = i; + continue; + + case 1: // i is behind + continue; + + default: // can't determine + CompareData.Push(i); // mark for later comparison + continue; + } + } + + // we need to do a second pass to see how the marked bunches relate to the currently closest one. + for(unsigned i = 0; i < CompareData.Size(); i++) + { + switch (BunchInFront(&Bunches[CompareData[i]], &Bunches[closest])) + { + case 0: // is in front + closest = i; + CompareData.Delete(i); + i = 0; // we need to recheck everything that's still marked. + continue; + + case 1: // is behind + CompareData.Delete(i); + i--; + continue; + + default: + continue; + + } + } + return closest; + } + + //========================================================================== + // + // + // + //========================================================================== + + void ProcessSection(int sectnum) + { + FGLSection *sect = &Sections[sectnum]; + bool inbunch; + angle_t startangle; + + if (sect->validcount == StartTime) return; + sect->validcount = StartTime; + D(Printf(PRINT_LOG, "------------------------------\nProcessing section %d (sector %d)\n",sectnum, sect->sector->sectornum)); + + #ifndef BUILD_TEST + for(unsigned i = 0; i < sect->subsectors.Size(); i++) + { + DoSubsector(sect->subsectors[i], false); + if (sect->subsectors[i]->poly != NULL) + { + // ProcessPolyobject() + } + } + #endif + + //Todo: process subsectors + for(int i=0; inumloops; i++) + { + FGLSectionLoop *loop = sect->GetLoop(i); + inbunch = false; + + for(int j=0; jnumlines; j++) + { + FGLSectionLine *ln = loop->GetLine(j); + + angle_t ang1 = ln->start->GetClipAngle(); + angle_t ang2 = ln->end->GetClipAngle(); + + if (ang2 - ang1 < ANGLE_180) + { + // Backside + D(Printf(PRINT_LOG, "line %d facing backwards\n", ln->linedef - lines)); + inbunch = false; + } + else if (!clipper.SafeCheckRange(ang2, ang1)) + { + // is it visible? + D(Printf(PRINT_LOG, "line %d not in view\n", ln->linedef - lines)); + inbunch = false; + } + else if (!inbunch || startangle - ang2 >= ANGLE_180) + { + // don't let a bunch span more than 180° to avoid problems. + // This limitation ensures that the combined range of 2 + // bunches will always be less than 360° which simplifies + // the distance comparison code because it prevents a + // situation where 2 bunches may overlap at both ends. + D(Printf(PRINT_LOG, "Starting bunch %d at line %d\n",Bunches.Size(), ln->linedef - lines)); + + startangle = ang2; + // Clipping angles are backward which makes this code very hard to read so let's use the inverse + StartBunch(loop->startline + j, 0 - ang1, 0 - ang2); + inbunch = true; + } + else + { + D(Printf(PRINT_LOG, " Adding line %d\n", ln->linedef - lines)); + AddLineToBunch(0 - ang2); + } + } + } + D(Printf(PRINT_LOG, "Section %d done\n------------------------------\n",sectnum)); + } + + //========================================================================== + // + // + // + //========================================================================== + +public: + void RenderScene(int viewsection) + { + ProcessSection(viewsection); + while (Bunches.Size() > 0) + { + int closest = FindClosestBunch(); + ProcessBunch(closest); + DeleteBunch(closest); + } + } +}; + + +void gl_RenderBuild() +{ + subsector_t *sub = R_PointInSubsector(viewx, viewy); + + clipper.Clear(); + angle_t a1 = GLRenderer->FrustumAngle(); + clipper.SafeAddClipRangeRealAngles(viewangle+a1, viewangle-a1); + if (Sections.Size() == 0) gl_CreateSections(); + + int startsection = SectionForSubsector[sub-subsectors]; + + BunchDrawer bd; + bd.RenderScene(startsection); +} + +#ifdef BUILD_TEST +CCMD(testrender) +{ + gl_RenderBuild(); +} +#endif diff --git a/src/gl/gl_functions.h b/src/gl/gl_functions.h new file mode 100644 index 000000000..aa08d19be --- /dev/null +++ b/src/gl/gl_functions.h @@ -0,0 +1,13 @@ +#ifndef __GL_FUNCT +#define __GL_FUNCT + +#include "v_palette.h" + +class AActor; + +void gl_PreprocessLevel(); +void gl_CleanLevelData(); +void gl_LinkLights(); +void gl_SetActorLights(AActor *); + +#endif diff --git a/src/gl/hqnx/common.h b/src/gl/hqnx/common.h new file mode 100644 index 000000000..3388651bf --- /dev/null +++ b/src/gl/hqnx/common.h @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com ) + * + * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net) + * Copyright (C) 2011 Francois Gannaz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __HQX_COMMON_H_ +#define __HQX_COMMON_H_ + +#include +#include "mystdint.h" + +#define MASK_2 0x0000FF00 +#define MASK_13 0x00FF00FF +#define MASK_RGB 0x00FFFFFF +#define MASK_ALPHA 0xFF000000 + +#define Ymask 0x00FF0000 +#define Umask 0x0000FF00 +#define Vmask 0x000000FF +#define trY 0x00300000 +#define trU 0x00000700 +#define trV 0x00000006 + +/* RGB to YUV lookup table */ +extern uint32_t *RGBtoYUV; + +static inline uint32_t rgb_to_yuv(uint32_t c) +{ + // Mask against MASK_RGB to discard the alpha channel + return RGBtoYUV[MASK_RGB & c]; +} + +/* Test if there is difference in color */ +static inline int yuv_diff(uint32_t yuv1, uint32_t yuv2) { + return (( abs((int64_t)(yuv1 & Ymask) - (int64_t)(yuv2 & Ymask)) > trY ) || + ( abs((int64_t)(yuv1 & Umask) - (int64_t)(yuv2 & Umask)) > trU ) || + ( abs((int64_t)(yuv1 & Vmask) - (int64_t)(yuv2 & Vmask)) > trV ) ); +} + +static inline int Diff(uint32_t c1, uint32_t c2) +{ + return yuv_diff(rgb_to_yuv(c1), rgb_to_yuv(c2)); +} + +/* Interpolate functions */ +static inline uint32_t Interpolate_2(uint32_t c1, int w1, uint32_t c2, int w2, int s) +{ + if (c1 == c2) { + return c1; + } + return + (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2) << (24-s)) & MASK_ALPHA) + + ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2) >> s) & MASK_2) + + ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2) >> s) & MASK_13); +} + +static inline uint32_t Interpolate_3(uint32_t c1, int w1, uint32_t c2, int w2, uint32_t c3, int w3, int s) +{ + return + (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2 + ((c3 & MASK_ALPHA) >> 24) * w3) << (24-s)) & MASK_ALPHA) + + ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2 + (c3 & MASK_2) * w3) >> s) & MASK_2) + + ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2 + (c3 & MASK_13) * w3) >> s) & MASK_13); +} + +static inline uint32_t Interp1(uint32_t c1, uint32_t c2) +{ + //(c1*3+c2) >> 2; + return Interpolate_2(c1, 3, c2, 1, 2); +} + +static inline uint32_t Interp2(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*2+c2+c3) >> 2; + return Interpolate_3(c1, 2, c2, 1, c3, 1, 2); +} + +static inline uint32_t Interp3(uint32_t c1, uint32_t c2) +{ + //(c1*7+c2)/8; + return Interpolate_2(c1, 7, c2, 1, 3); +} + +static inline uint32_t Interp4(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*2+(c2+c3)*7)/16; + return Interpolate_3(c1, 2, c2, 7, c3, 7, 4); +} + +static inline uint32_t Interp5(uint32_t c1, uint32_t c2) +{ + //(c1+c2) >> 1; + return Interpolate_2(c1, 1, c2, 1, 1); +} + +static inline uint32_t Interp6(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*5+c2*2+c3)/8; + return Interpolate_3(c1, 5, c2, 2, c3, 1, 3); +} + +static inline uint32_t Interp7(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*6+c2+c3)/8; + return Interpolate_3(c1, 6, c2, 1, c3, 1, 3); +} + +static inline uint32_t Interp8(uint32_t c1, uint32_t c2) +{ + //(c1*5+c2*3)/8; + return Interpolate_2(c1, 5, c2, 3, 3); +} + +static inline uint32_t Interp9(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*2+(c2+c3)*3)/8; + return Interpolate_3(c1, 2, c2, 3, c3, 3, 3); +} + +static inline uint32_t Interp10(uint32_t c1, uint32_t c2, uint32_t c3) +{ + //(c1*14+c2+c3)/16; + return Interpolate_3(c1, 14, c2, 1, c3, 1, 4); +} + +#endif diff --git a/src/gl/hqnx/hq2x.cpp b/src/gl/hqnx/hq2x.cpp new file mode 100644 index 000000000..679a8c2b6 --- /dev/null +++ b/src/gl/hqnx/hq2x.cpp @@ -0,0 +1,2809 @@ +/* + * Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com ) + * + * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "mystdint.h" +#include "common.h" +#include "hqx.h" + +#define PIXEL00_0 *dp = w[5]; +#define PIXEL00_10 *dp = Interp1(w[5], w[1]); +#define PIXEL00_11 *dp = Interp1(w[5], w[4]); +#define PIXEL00_12 *dp = Interp1(w[5], w[2]); +#define PIXEL00_20 *dp = Interp2(w[5], w[4], w[2]); +#define PIXEL00_21 *dp = Interp2(w[5], w[1], w[2]); +#define PIXEL00_22 *dp = Interp2(w[5], w[1], w[4]); +#define PIXEL00_60 *dp = Interp6(w[5], w[2], w[4]); +#define PIXEL00_61 *dp = Interp6(w[5], w[4], w[2]); +#define PIXEL00_70 *dp = Interp7(w[5], w[4], w[2]); +#define PIXEL00_90 *dp = Interp9(w[5], w[4], w[2]); +#define PIXEL00_100 *dp = Interp10(w[5], w[4], w[2]); +#define PIXEL01_0 *(dp+1) = w[5]; +#define PIXEL01_10 *(dp+1) = Interp1(w[5], w[3]); +#define PIXEL01_11 *(dp+1) = Interp1(w[5], w[2]); +#define PIXEL01_12 *(dp+1) = Interp1(w[5], w[6]); +#define PIXEL01_20 *(dp+1) = Interp2(w[5], w[2], w[6]); +#define PIXEL01_21 *(dp+1) = Interp2(w[5], w[3], w[6]); +#define PIXEL01_22 *(dp+1) = Interp2(w[5], w[3], w[2]); +#define PIXEL01_60 *(dp+1) = Interp6(w[5], w[6], w[2]); +#define PIXEL01_61 *(dp+1) = Interp6(w[5], w[2], w[6]); +#define PIXEL01_70 *(dp+1) = Interp7(w[5], w[2], w[6]); +#define PIXEL01_90 *(dp+1) = Interp9(w[5], w[2], w[6]); +#define PIXEL01_100 *(dp+1) = Interp10(w[5], w[2], w[6]); +#define PIXEL10_0 *(dp+dpL) = w[5]; +#define PIXEL10_10 *(dp+dpL) = Interp1(w[5], w[7]); +#define PIXEL10_11 *(dp+dpL) = Interp1(w[5], w[8]); +#define PIXEL10_12 *(dp+dpL) = Interp1(w[5], w[4]); +#define PIXEL10_20 *(dp+dpL) = Interp2(w[5], w[8], w[4]); +#define PIXEL10_21 *(dp+dpL) = Interp2(w[5], w[7], w[4]); +#define PIXEL10_22 *(dp+dpL) = Interp2(w[5], w[7], w[8]); +#define PIXEL10_60 *(dp+dpL) = Interp6(w[5], w[4], w[8]); +#define PIXEL10_61 *(dp+dpL) = Interp6(w[5], w[8], w[4]); +#define PIXEL10_70 *(dp+dpL) = Interp7(w[5], w[8], w[4]); +#define PIXEL10_90 *(dp+dpL) = Interp9(w[5], w[8], w[4]); +#define PIXEL10_100 *(dp+dpL) = Interp10(w[5], w[8], w[4]); +#define PIXEL11_0 *(dp+dpL+1) = w[5]; +#define PIXEL11_10 *(dp+dpL+1) = Interp1(w[5], w[9]); +#define PIXEL11_11 *(dp+dpL+1) = Interp1(w[5], w[6]); +#define PIXEL11_12 *(dp+dpL+1) = Interp1(w[5], w[8]); +#define PIXEL11_20 *(dp+dpL+1) = Interp2(w[5], w[6], w[8]); +#define PIXEL11_21 *(dp+dpL+1) = Interp2(w[5], w[9], w[8]); +#define PIXEL11_22 *(dp+dpL+1) = Interp2(w[5], w[9], w[6]); +#define PIXEL11_60 *(dp+dpL+1) = Interp6(w[5], w[8], w[6]); +#define PIXEL11_61 *(dp+dpL+1) = Interp6(w[5], w[6], w[8]); +#define PIXEL11_70 *(dp+dpL+1) = Interp7(w[5], w[6], w[8]); +#define PIXEL11_90 *(dp+dpL+1) = Interp9(w[5], w[6], w[8]); +#define PIXEL11_100 *(dp+dpL+1) = Interp10(w[5], w[6], w[8]); + +HQX_API void HQX_CALLCONV hq2x_32_rb( uint32_t * sp, uint32_t srb, uint32_t * dp, uint32_t drb, int Xres, int Yres ) +{ + int i, j, k; + int prevline, nextline; + uint32_t w[10]; + int dpL = (drb >> 2); + int spL = (srb >> 2); + uint8_t *sRowP = (uint8_t *) sp; + uint8_t *dRowP = (uint8_t *) dp; + uint32_t yuv1, yuv2; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + for (j=0; j0) prevline = -spL; else prevline = 0; + if (j0) + { + w[1] = *(sp + prevline - 1); + w[4] = *(sp - 1); + w[7] = *(sp + nextline - 1); + } + else + { + w[1] = w[2]; + w[4] = w[5]; + w[7] = w[8]; + } + + if (i> 2); + int spL = (srb >> 2); + uint8_t *sRowP = (uint8_t *) sp; + uint8_t *dRowP = (uint8_t *) dp; + uint32_t yuv1, yuv2; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + for (j=0; j0) prevline = -spL; else prevline = 0; + if (j0) + { + w[1] = *(sp + prevline - 1); + w[4] = *(sp - 1); + w[7] = *(sp + nextline - 1); + } + else + { + w[1] = w[2]; + w[4] = w[5]; + w[7] = w[8]; + } + + if (i> 2); + int spL = (srb >> 2); + uint8_t *sRowP = (uint8_t *) sp; + uint8_t *dRowP = (uint8_t *) dp; + uint32_t yuv1, yuv2; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + for (j=0; j0) prevline = -spL; else prevline = 0; + if (j0) + { + w[1] = *(sp + prevline - 1); + w[4] = *(sp - 1); + w[7] = *(sp + nextline - 1); + } + else + { + w[1] = w[2]; + w[4] = w[5]; + w[7] = w[8]; + } + + if (i> 16; + g = (c & 0x00FF00) >> 8; + b = c & 0x0000FF; + y = (uint32_t)(0.299*r + 0.587*g + 0.114*b); + u = (uint32_t)(-0.169*r - 0.331*g + 0.5*b) + 128; + v = (uint32_t)(0.5*r - 0.419*g - 0.081*b) + 128; + RGBtoYUV[c] = (y << 16) + (u << 8) + v; + } +} diff --git a/src/gl/hqnx/mystdint.h b/src/gl/hqnx/mystdint.h new file mode 100644 index 000000000..b2da9df8c --- /dev/null +++ b/src/gl/hqnx/mystdint.h @@ -0,0 +1,19 @@ +#ifndef __MYSTDINT_H +#define __MYSTDINT_H + +#ifndef _MSC_VER +#include +#else +typedef unsigned __int64 uint64_t; +typedef signed __int64 int64_t; +typedef unsigned __int32 uint32_t; +typedef signed __int32 int32_t; +typedef unsigned __int16 uint16_t; +typedef signed __int16 int16_t; +typedef unsigned __int8 uint8_t; +typedef signed __int8 int8_t; +#endif + + + +#endif \ No newline at end of file diff --git a/src/gl/hqnx_asm/hq2x_asm.cpp b/src/gl/hqnx_asm/hq2x_asm.cpp new file mode 100644 index 000000000..65e460377 --- /dev/null +++ b/src/gl/hqnx_asm/hq2x_asm.cpp @@ -0,0 +1,2943 @@ +//hq2x filter demo program +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +//Copyright (C) 2012-2014 Alexey Lysiuk +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#include "hqnx_asm.h" + +namespace HQnX_asm +{ + +extern int LUT16to32[65536*2]; +extern int RGBtoYUV[65536*2]; + +static const hq_vec const3 = hq_vec::expand(0x0003); +static const hq_vec const5 = hq_vec::expand(0x0005); +static const hq_vec const6 = hq_vec::expand(0x0006); +static const hq_vec const14 = hq_vec::expand(0x000E); + +inline void Interp1(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*3+c2)/4; + + hq_vec result = hq_vec::load(c1); + + result *= const3; + result += hq_vec::load(c2); + result >> 2; + + result.store(pc); +} + +inline void Interp2(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*2+c2+c3) >> 2; + + hq_vec result = hq_vec::load(c1); + + result << 1; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 2; + + result.store(pc); +} + +inline void Interp5(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1+c2)/2; + + hq_vec result = hq_vec::load(c1); + + result += hq_vec::load(c2); + result >> 1; + + result.store(pc); +} + +inline void Interp6(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*5+c2*2+c3)/8; + + hq_vec result = hq_vec::load(c1); + + result *= const5; + result += hq_vec::load(c2) << 1; + result += hq_vec::load(c3); + result >> 3; + + result.store(pc); +} + +inline void Interp7(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*6+c2+c3)/8; + + hq_vec result = hq_vec::load(c1); + + result *= const6; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 3; + + result.store(pc); +} + +inline void Interp9(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*2+(c2+c3)*3)/8; + + hq_vec result = hq_vec::load(c2); + + result += hq_vec::load(c3); + result *= const3; + result += hq_vec::load(c1) << 1; + result >> 3; + + result.store(pc); +} + +inline void Interp10(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*14+c2+c3)/16; + + hq_vec result = hq_vec::load(c1); + + result *= const14; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 4; + + result.store(pc); +} + +#define PIXEL00_0 *((int*)(pOut)) = c[5]; +#define PIXEL00_10 Interp1(pOut, c[5], c[1]); +#define PIXEL00_11 Interp1(pOut, c[5], c[4]); +#define PIXEL00_12 Interp1(pOut, c[5], c[2]); +#define PIXEL00_20 Interp2(pOut, c[5], c[4], c[2]); +#define PIXEL00_21 Interp2(pOut, c[5], c[1], c[2]); +#define PIXEL00_22 Interp2(pOut, c[5], c[1], c[4]); +#define PIXEL00_60 Interp6(pOut, c[5], c[2], c[4]); +#define PIXEL00_61 Interp6(pOut, c[5], c[4], c[2]); +#define PIXEL00_70 Interp7(pOut, c[5], c[4], c[2]); +#define PIXEL00_90 Interp9(pOut, c[5], c[4], c[2]); +#define PIXEL00_100 Interp10(pOut, c[5], c[4], c[2]); +#define PIXEL01_0 *((int*)(pOut+4)) = c[5]; +#define PIXEL01_10 Interp1(pOut+4, c[5], c[3]); +#define PIXEL01_11 Interp1(pOut+4, c[5], c[2]); +#define PIXEL01_12 Interp1(pOut+4, c[5], c[6]); +#define PIXEL01_20 Interp2(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_21 Interp2(pOut+4, c[5], c[3], c[6]); +#define PIXEL01_22 Interp2(pOut+4, c[5], c[3], c[2]); +#define PIXEL01_60 Interp6(pOut+4, c[5], c[6], c[2]); +#define PIXEL01_61 Interp6(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_70 Interp7(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_90 Interp9(pOut+4, c[5], c[2], c[6]); +#define PIXEL01_100 Interp10(pOut+4, c[5], c[2], c[6]); +#define PIXEL10_0 *((int*)(pOut+BpL)) = c[5]; +#define PIXEL10_10 Interp1(pOut+BpL, c[5], c[7]); +#define PIXEL10_11 Interp1(pOut+BpL, c[5], c[8]); +#define PIXEL10_12 Interp1(pOut+BpL, c[5], c[4]); +#define PIXEL10_20 Interp2(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_21 Interp2(pOut+BpL, c[5], c[7], c[4]); +#define PIXEL10_22 Interp2(pOut+BpL, c[5], c[7], c[8]); +#define PIXEL10_60 Interp6(pOut+BpL, c[5], c[4], c[8]); +#define PIXEL10_61 Interp6(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_70 Interp7(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_90 Interp9(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL10_100 Interp10(pOut+BpL, c[5], c[8], c[4]); +#define PIXEL11_0 *((int*)(pOut+BpL+4)) = c[5]; +#define PIXEL11_10 Interp1(pOut+BpL+4, c[5], c[9]); +#define PIXEL11_11 Interp1(pOut+BpL+4, c[5], c[6]); +#define PIXEL11_12 Interp1(pOut+BpL+4, c[5], c[8]); +#define PIXEL11_20 Interp2(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_21 Interp2(pOut+BpL+4, c[5], c[9], c[8]); +#define PIXEL11_22 Interp2(pOut+BpL+4, c[5], c[9], c[6]); +#define PIXEL11_60 Interp6(pOut+BpL+4, c[5], c[8], c[6]); +#define PIXEL11_61 Interp6(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_70 Interp7(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_90 Interp9(pOut+BpL+4, c[5], c[6], c[8]); +#define PIXEL11_100 Interp10(pOut+BpL+4, c[5], c[6], c[8]); + + +bool Diff(const unsigned int, const unsigned int); + +void DLL hq2x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) +{ + int i, j, k; + int w[10]; + unsigned int c[10]; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + for (j=0; j0) + { + w[1] = *(pIn - Xres - 1); + } + else + { + w[1] = 0; + } + + w[2] = *(pIn - Xres); + + if (i0) + { + w[4] = *(pIn - 1); + } + else + { + w[4] = 0; + } + + w[5] = *(pIn); + if (i0) + { + w[7] = *(pIn + Xres - 1); + } + else + { + w[7] = 0; + } + + w[8] = *(pIn + Xres); + if (i> 2; + + result.store(pc); +} + +inline void Interp2(unsigned char * pc, int c1, int c2, int c3) +{ +// *((int*)pc) = (c1*2+c2+c3)/4; + + hq_vec result = hq_vec::load(c1); + + result << 1; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 2; + + result.store(pc); +} + +inline void Interp3(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*7+c2)/8; + + hq_vec result = hq_vec::load(c1); + + result *= const7; + result += hq_vec::load(c2); + result >> 3; + + result.store(pc); +} + +inline void Interp4(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*2+(c2+c3)*7)/16; + + hq_vec result = hq_vec::load(c2); + + result += hq_vec::load(c3); + result *= const7; + result += hq_vec::load(c1) << 1; + result >> 4; + + result.store(pc); +} + +inline void Interp5(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1+c2)/2; + + hq_vec result = hq_vec::load(c1); + + result += hq_vec::load(c2); + result >> 1; + + result.store(pc); +} + +#define PIXEL00_1M Interp1(pOut, c[5], c[1]); +#define PIXEL00_1U Interp1(pOut, c[5], c[2]); +#define PIXEL00_1L Interp1(pOut, c[5], c[4]); +#define PIXEL00_2 Interp2(pOut, c[5], c[4], c[2]); +#define PIXEL00_4 Interp4(pOut, c[5], c[4], c[2]); +#define PIXEL00_5 Interp5(pOut, c[4], c[2]); +#define PIXEL00_C *((int*)(pOut)) = c[5]; + +#define PIXEL01_1 Interp1(pOut+4, c[5], c[2]); +#define PIXEL01_3 Interp3(pOut+4, c[5], c[2]); +#define PIXEL01_6 Interp1(pOut+4, c[2], c[5]); +#define PIXEL01_C *((int*)(pOut+4)) = c[5]; + +#define PIXEL02_1M Interp1(pOut+8, c[5], c[3]); +#define PIXEL02_1U Interp1(pOut+8, c[5], c[2]); +#define PIXEL02_1R Interp1(pOut+8, c[5], c[6]); +#define PIXEL02_2 Interp2(pOut+8, c[5], c[2], c[6]); +#define PIXEL02_4 Interp4(pOut+8, c[5], c[2], c[6]); +#define PIXEL02_5 Interp5(pOut+8, c[2], c[6]); +#define PIXEL02_C *((int*)(pOut+8)) = c[5]; + +#define PIXEL10_1 Interp1(pOut+BpL, c[5], c[4]); +#define PIXEL10_3 Interp3(pOut+BpL, c[5], c[4]); +#define PIXEL10_6 Interp1(pOut+BpL, c[4], c[5]); +#define PIXEL10_C *((int*)(pOut+BpL)) = c[5]; + +#define PIXEL11 *((int*)(pOut+BpL+4)) = c[5]; + +#define PIXEL12_1 Interp1(pOut+BpL+8, c[5], c[6]); +#define PIXEL12_3 Interp3(pOut+BpL+8, c[5], c[6]); +#define PIXEL12_6 Interp1(pOut+BpL+8, c[6], c[5]); +#define PIXEL12_C *((int*)(pOut+BpL+8)) = c[5]; + +#define PIXEL20_1M Interp1(pOut+BpL+BpL, c[5], c[7]); +#define PIXEL20_1D Interp1(pOut+BpL+BpL, c[5], c[8]); +#define PIXEL20_1L Interp1(pOut+BpL+BpL, c[5], c[4]); +#define PIXEL20_2 Interp2(pOut+BpL+BpL, c[5], c[8], c[4]); +#define PIXEL20_4 Interp4(pOut+BpL+BpL, c[5], c[8], c[4]); +#define PIXEL20_5 Interp5(pOut+BpL+BpL, c[8], c[4]); +#define PIXEL20_C *((int*)(pOut+BpL+BpL)) = c[5]; + +#define PIXEL21_1 Interp1(pOut+BpL+BpL+4, c[5], c[8]); +#define PIXEL21_3 Interp3(pOut+BpL+BpL+4, c[5], c[8]); +#define PIXEL21_6 Interp1(pOut+BpL+BpL+4, c[8], c[5]); +#define PIXEL21_C *((int*)(pOut+BpL+BpL+4)) = c[5]; + +#define PIXEL22_1M Interp1(pOut+BpL+BpL+8, c[5], c[9]); +#define PIXEL22_1D Interp1(pOut+BpL+BpL+8, c[5], c[8]); +#define PIXEL22_1R Interp1(pOut+BpL+BpL+8, c[5], c[6]); +#define PIXEL22_2 Interp2(pOut+BpL+BpL+8, c[5], c[6], c[8]); +#define PIXEL22_4 Interp4(pOut+BpL+BpL+8, c[5], c[6], c[8]); +#define PIXEL22_5 Interp5(pOut+BpL+BpL+8, c[6], c[8]); +#define PIXEL22_C *((int*)(pOut+BpL+BpL+8)) = c[5]; + +bool Diff(const unsigned int, const unsigned int); + +void DLL hq3x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) +{ + int i, j, k; + int w[10]; + unsigned int c[10]; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + for (j=0; j0) w[1] = *(pIn - Xres - 1); else w[1] = 0; + w[2] = *(pIn - Xres); + if (i0) w[4] = *(pIn - 1); else w[4] = 0; + w[5] = *(pIn); + if (i0) w[7] = *(pIn + Xres - 1); else w[7] = 0; + w[8] = *(pIn + Xres); + if (i +#include +#include +#include "hqnx_asm.h" + +namespace HQnX_asm +{ + +int LUT16to32[65536*2]; +int RGBtoYUV[65536*2]; + +static const hq_vec const3 = hq_vec::expand(0x0003); +static const hq_vec const5 = hq_vec::expand(0x0005); +static const hq_vec const6 = hq_vec::expand(0x0006); +static const hq_vec const7 = hq_vec::expand(0x0007); + + +inline void Interp1(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*3+c2)/4; + + hq_vec result = hq_vec::load(c1); + + result *= const3; + result += hq_vec::load(c2); + result >> 2; + + result.store(pc); +} + +inline void Interp2(unsigned char * pc, int c1, int c2, int c3) +{ +// *((int*)pc) = (c1*2+c2+c3)/4; + + hq_vec result = hq_vec::load(c1); + + result << 1; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 2; + + result.store(pc); +} + +inline void Interp3(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*7+c2)/8; + + hq_vec result = hq_vec::load(c1); + + result *= const7; + result += hq_vec::load(c2); + result >> 3; + + result.store(pc); +} + +inline void Interp5(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1+c2)/2; + + hq_vec result = hq_vec::load(c1); + + result += hq_vec::load(c2); + result >> 1; + + result.store(pc); +} + +inline void Interp6(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*5+c2*2+c3)/8; + + hq_vec result = hq_vec::load(c1); + + result *= const5; + result += hq_vec::load(c2) << 1; + result += hq_vec::load(c3); + result >> 3; + + result.store(pc); +} + +inline void Interp7(unsigned char * pc, int c1, int c2, int c3) +{ + //*((int*)pc) = (c1*6+c2+c3)/8; + + hq_vec result = hq_vec::load(c1); + + result *= const6; + result += hq_vec::load(c2); + result += hq_vec::load(c3); + result >> 3; + + result.store(pc); +} + +inline void Interp8(unsigned char * pc, int c1, int c2) +{ + //*((int*)pc) = (c1*5+c2*3)/8; + + hq_vec result = hq_vec::load(c1); + + result *= const5; + result += hq_vec::load(c2) * const3; + result >> 3; + + result.store(pc); +} + +#define PIXEL00_0 *((int*)(pOut)) = c[5]; +#define PIXEL00_11 Interp1(pOut, c[5], c[4]); +#define PIXEL00_12 Interp1(pOut, c[5], c[2]); +#define PIXEL00_20 Interp2(pOut, c[5], c[2], c[4]); +#define PIXEL00_50 Interp5(pOut, c[2], c[4]); +#define PIXEL00_80 Interp8(pOut, c[5], c[1]); +#define PIXEL00_81 Interp8(pOut, c[5], c[4]); +#define PIXEL00_82 Interp8(pOut, c[5], c[2]); +#define PIXEL01_0 *((int*)(pOut+4)) = c[5]; +#define PIXEL01_10 Interp1(pOut+4, c[5], c[1]); +#define PIXEL01_12 Interp1(pOut+4, c[5], c[2]); +#define PIXEL01_14 Interp1(pOut+4, c[2], c[5]); +#define PIXEL01_21 Interp2(pOut+4, c[2], c[5], c[4]); +#define PIXEL01_31 Interp3(pOut+4, c[5], c[4]); +#define PIXEL01_50 Interp5(pOut+4, c[2], c[5]); +#define PIXEL01_60 Interp6(pOut+4, c[5], c[2], c[4]); +#define PIXEL01_61 Interp6(pOut+4, c[5], c[2], c[1]); +#define PIXEL01_82 Interp8(pOut+4, c[5], c[2]); +#define PIXEL01_83 Interp8(pOut+4, c[2], c[4]); +#define PIXEL02_0 *((int*)(pOut+8)) = c[5]; +#define PIXEL02_10 Interp1(pOut+8, c[5], c[3]); +#define PIXEL02_11 Interp1(pOut+8, c[5], c[2]); +#define PIXEL02_13 Interp1(pOut+8, c[2], c[5]); +#define PIXEL02_21 Interp2(pOut+8, c[2], c[5], c[6]); +#define PIXEL02_32 Interp3(pOut+8, c[5], c[6]); +#define PIXEL02_50 Interp5(pOut+8, c[2], c[5]); +#define PIXEL02_60 Interp6(pOut+8, c[5], c[2], c[6]); +#define PIXEL02_61 Interp6(pOut+8, c[5], c[2], c[3]); +#define PIXEL02_81 Interp8(pOut+8, c[5], c[2]); +#define PIXEL02_83 Interp8(pOut+8, c[2], c[6]); +#define PIXEL03_0 *((int*)(pOut+12)) = c[5]; +#define PIXEL03_11 Interp1(pOut+12, c[5], c[2]); +#define PIXEL03_12 Interp1(pOut+12, c[5], c[6]); +#define PIXEL03_20 Interp2(pOut+12, c[5], c[2], c[6]); +#define PIXEL03_50 Interp5(pOut+12, c[2], c[6]); +#define PIXEL03_80 Interp8(pOut+12, c[5], c[3]); +#define PIXEL03_81 Interp8(pOut+12, c[5], c[2]); +#define PIXEL03_82 Interp8(pOut+12, c[5], c[6]); +#define PIXEL10_0 *((int*)(pOut+BpL)) = c[5]; +#define PIXEL10_10 Interp1(pOut+BpL, c[5], c[1]); +#define PIXEL10_11 Interp1(pOut+BpL, c[5], c[4]); +#define PIXEL10_13 Interp1(pOut+BpL, c[4], c[5]); +#define PIXEL10_21 Interp2(pOut+BpL, c[4], c[5], c[2]); +#define PIXEL10_32 Interp3(pOut+BpL, c[5], c[2]); +#define PIXEL10_50 Interp5(pOut+BpL, c[4], c[5]); +#define PIXEL10_60 Interp6(pOut+BpL, c[5], c[4], c[2]); +#define PIXEL10_61 Interp6(pOut+BpL, c[5], c[4], c[1]); +#define PIXEL10_81 Interp8(pOut+BpL, c[5], c[4]); +#define PIXEL10_83 Interp8(pOut+BpL, c[4], c[2]); +#define PIXEL11_0 *((int*)(pOut+BpL+4)) = c[5]; +#define PIXEL11_30 Interp3(pOut+BpL+4, c[5], c[1]); +#define PIXEL11_31 Interp3(pOut+BpL+4, c[5], c[4]); +#define PIXEL11_32 Interp3(pOut+BpL+4, c[5], c[2]); +#define PIXEL11_70 Interp7(pOut+BpL+4, c[5], c[4], c[2]); +#define PIXEL12_0 *((int*)(pOut+BpL+8)) = c[5]; +#define PIXEL12_30 Interp3(pOut+BpL+8, c[5], c[3]); +#define PIXEL12_31 Interp3(pOut+BpL+8, c[5], c[2]); +#define PIXEL12_32 Interp3(pOut+BpL+8, c[5], c[6]); +#define PIXEL12_70 Interp7(pOut+BpL+8, c[5], c[6], c[2]); +#define PIXEL13_0 *((int*)(pOut+BpL+12)) = c[5]; +#define PIXEL13_10 Interp1(pOut+BpL+12, c[5], c[3]); +#define PIXEL13_12 Interp1(pOut+BpL+12, c[5], c[6]); +#define PIXEL13_14 Interp1(pOut+BpL+12, c[6], c[5]); +#define PIXEL13_21 Interp2(pOut+BpL+12, c[6], c[5], c[2]); +#define PIXEL13_31 Interp3(pOut+BpL+12, c[5], c[2]); +#define PIXEL13_50 Interp5(pOut+BpL+12, c[6], c[5]); +#define PIXEL13_60 Interp6(pOut+BpL+12, c[5], c[6], c[2]); +#define PIXEL13_61 Interp6(pOut+BpL+12, c[5], c[6], c[3]); +#define PIXEL13_82 Interp8(pOut+BpL+12, c[5], c[6]); +#define PIXEL13_83 Interp8(pOut+BpL+12, c[6], c[2]); +#define PIXEL20_0 *((int*)(pOut+BpL+BpL)) = c[5]; +#define PIXEL20_10 Interp1(pOut+BpL+BpL, c[5], c[7]); +#define PIXEL20_12 Interp1(pOut+BpL+BpL, c[5], c[4]); +#define PIXEL20_14 Interp1(pOut+BpL+BpL, c[4], c[5]); +#define PIXEL20_21 Interp2(pOut+BpL+BpL, c[4], c[5], c[8]); +#define PIXEL20_31 Interp3(pOut+BpL+BpL, c[5], c[8]); +#define PIXEL20_50 Interp5(pOut+BpL+BpL, c[4], c[5]); +#define PIXEL20_60 Interp6(pOut+BpL+BpL, c[5], c[4], c[8]); +#define PIXEL20_61 Interp6(pOut+BpL+BpL, c[5], c[4], c[7]); +#define PIXEL20_82 Interp8(pOut+BpL+BpL, c[5], c[4]); +#define PIXEL20_83 Interp8(pOut+BpL+BpL, c[4], c[8]); +#define PIXEL21_0 *((int*)(pOut+BpL+BpL+4)) = c[5]; +#define PIXEL21_30 Interp3(pOut+BpL+BpL+4, c[5], c[7]); +#define PIXEL21_31 Interp3(pOut+BpL+BpL+4, c[5], c[8]); +#define PIXEL21_32 Interp3(pOut+BpL+BpL+4, c[5], c[4]); +#define PIXEL21_70 Interp7(pOut+BpL+BpL+4, c[5], c[4], c[8]); +#define PIXEL22_0 *((int*)(pOut+BpL+BpL+8)) = c[5]; +#define PIXEL22_30 Interp3(pOut+BpL+BpL+8, c[5], c[9]); +#define PIXEL22_31 Interp3(pOut+BpL+BpL+8, c[5], c[6]); +#define PIXEL22_32 Interp3(pOut+BpL+BpL+8, c[5], c[8]); +#define PIXEL22_70 Interp7(pOut+BpL+BpL+8, c[5], c[6], c[8]); +#define PIXEL23_0 *((int*)(pOut+BpL+BpL+12)) = c[5]; +#define PIXEL23_10 Interp1(pOut+BpL+BpL+12, c[5], c[9]); +#define PIXEL23_11 Interp1(pOut+BpL+BpL+12, c[5], c[6]); +#define PIXEL23_13 Interp1(pOut+BpL+BpL+12, c[6], c[5]); +#define PIXEL23_21 Interp2(pOut+BpL+BpL+12, c[6], c[5], c[8]); +#define PIXEL23_32 Interp3(pOut+BpL+BpL+12, c[5], c[8]); +#define PIXEL23_50 Interp5(pOut+BpL+BpL+12, c[6], c[5]); +#define PIXEL23_60 Interp6(pOut+BpL+BpL+12, c[5], c[6], c[8]); +#define PIXEL23_61 Interp6(pOut+BpL+BpL+12, c[5], c[6], c[9]); +#define PIXEL23_81 Interp8(pOut+BpL+BpL+12, c[5], c[6]); +#define PIXEL23_83 Interp8(pOut+BpL+BpL+12, c[6], c[8]); +#define PIXEL30_0 *((int*)(pOut+BpL+BpL+BpL)) = c[5]; +#define PIXEL30_11 Interp1(pOut+BpL+BpL+BpL, c[5], c[8]); +#define PIXEL30_12 Interp1(pOut+BpL+BpL+BpL, c[5], c[4]); +#define PIXEL30_20 Interp2(pOut+BpL+BpL+BpL, c[5], c[8], c[4]); +#define PIXEL30_50 Interp5(pOut+BpL+BpL+BpL, c[8], c[4]); +#define PIXEL30_80 Interp8(pOut+BpL+BpL+BpL, c[5], c[7]); +#define PIXEL30_81 Interp8(pOut+BpL+BpL+BpL, c[5], c[8]); +#define PIXEL30_82 Interp8(pOut+BpL+BpL+BpL, c[5], c[4]); +#define PIXEL31_0 *((int*)(pOut+BpL+BpL+BpL+4)) = c[5]; +#define PIXEL31_10 Interp1(pOut+BpL+BpL+BpL+4, c[5], c[7]); +#define PIXEL31_11 Interp1(pOut+BpL+BpL+BpL+4, c[5], c[8]); +#define PIXEL31_13 Interp1(pOut+BpL+BpL+BpL+4, c[8], c[5]); +#define PIXEL31_21 Interp2(pOut+BpL+BpL+BpL+4, c[8], c[5], c[4]); +#define PIXEL31_32 Interp3(pOut+BpL+BpL+BpL+4, c[5], c[4]); +#define PIXEL31_50 Interp5(pOut+BpL+BpL+BpL+4, c[8], c[5]); +#define PIXEL31_60 Interp6(pOut+BpL+BpL+BpL+4, c[5], c[8], c[4]); +#define PIXEL31_61 Interp6(pOut+BpL+BpL+BpL+4, c[5], c[8], c[7]); +#define PIXEL31_81 Interp8(pOut+BpL+BpL+BpL+4, c[5], c[8]); +#define PIXEL31_83 Interp8(pOut+BpL+BpL+BpL+4, c[8], c[4]); +#define PIXEL32_0 *((int*)(pOut+BpL+BpL+BpL+8)) = c[5]; +#define PIXEL32_10 Interp1(pOut+BpL+BpL+BpL+8, c[5], c[9]); +#define PIXEL32_12 Interp1(pOut+BpL+BpL+BpL+8, c[5], c[8]); +#define PIXEL32_14 Interp1(pOut+BpL+BpL+BpL+8, c[8], c[5]); +#define PIXEL32_21 Interp2(pOut+BpL+BpL+BpL+8, c[8], c[5], c[6]); +#define PIXEL32_31 Interp3(pOut+BpL+BpL+BpL+8, c[5], c[6]); +#define PIXEL32_50 Interp5(pOut+BpL+BpL+BpL+8, c[8], c[5]); +#define PIXEL32_60 Interp6(pOut+BpL+BpL+BpL+8, c[5], c[8], c[6]); +#define PIXEL32_61 Interp6(pOut+BpL+BpL+BpL+8, c[5], c[8], c[9]); +#define PIXEL32_82 Interp8(pOut+BpL+BpL+BpL+8, c[5], c[8]); +#define PIXEL32_83 Interp8(pOut+BpL+BpL+BpL+8, c[8], c[6]); +#define PIXEL33_0 *((int*)(pOut+BpL+BpL+BpL+12)) = c[5]; +#define PIXEL33_11 Interp1(pOut+BpL+BpL+BpL+12, c[5], c[6]); +#define PIXEL33_12 Interp1(pOut+BpL+BpL+BpL+12, c[5], c[8]); +#define PIXEL33_20 Interp2(pOut+BpL+BpL+BpL+12, c[5], c[8], c[6]); +#define PIXEL33_50 Interp5(pOut+BpL+BpL+BpL+12, c[8], c[6]); +#define PIXEL33_80 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[9]); +#define PIXEL33_81 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[6]); +#define PIXEL33_82 Interp8(pOut+BpL+BpL+BpL+12, c[5], c[8]); + +bool Diff(const unsigned int rgb1, const unsigned int rgb2) +{ + if (rgb1 == rgb2) + { + return false; + } + + static const hq_vec THRESHOLD = 0x00300706; + + const hq_vec yuv1 = RGBtoYUV[rgb1]; + const hq_vec yuv2 = RGBtoYUV[rgb2]; + + const hq_vec delta1 = yuv1 - yuv2; + const hq_vec delta2 = yuv2 - yuv1; + + const hq_vec delta = delta1 | delta2; + const hq_vec result = delta - THRESHOLD; + + return 0 != result; +} + +void DLL hq4x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ) +{ + int i, j, k; + int w[10]; + int c[10]; + + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ + + for (j = 0; j < Yres; j++) + { + for (i = 0; i < Xres; i++) + { + if (j == 0) + { + w[1] = 0; + w[2] = 0; + w[3] = 0; + } + else + { + if (i > 0) + w[1] = *(pIn - Xres - 1); + else + w[1] = 0; + + w[2] = *(pIn - Xres); + + if (i < Xres - 1) + w[3] = *(pIn - Xres + 1); + else + w[3] = 0; + } + + if (i > 0) + w[4] = *(pIn - 1); + else + w[4] = 0; + + w[5] = *(pIn); + + if (i < Xres - 1) + w[6] = *(pIn + 1); + else + w[6] = 0; + + if (j == Yres - 1) + { + w[7] = 0; + w[8] = 0; + w[9] = 0; + } + else + { + if (i > 0) + w[7] = *(pIn + Xres - 1); + else + w[7] = 0; + + w[8] = *(pIn + Xres); + + if (i < Xres-1) + w[9] = *(pIn + Xres + 1); + else + w[9] = 0; + } + + int pattern = 0; + + if ( Diff(w[5],w[1]) ) pattern |= 0x0001; + if ( Diff(w[5],w[2]) ) pattern |= 0x0002; + if ( Diff(w[5],w[3]) ) pattern |= 0x0004; + if ( Diff(w[5],w[4]) ) pattern |= 0x0008; + if ( Diff(w[5],w[6]) ) pattern |= 0x0010; + if ( Diff(w[5],w[7]) ) pattern |= 0x0020; + if ( Diff(w[5],w[8]) ) pattern |= 0x0040; + if ( Diff(w[5],w[9]) ) pattern |= 0x0080; + + for (k=1; k<=9; k++) + c[k] = LUT16to32[w[k]]; + + switch (pattern) + { + case 0: + case 1: + case 4: + case 32: + case 128: + case 5: + case 132: + case 160: + case 33: + case 129: + case 36: + case 133: + case 164: + case 161: + case 37: + case 165: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 2: + case 34: + case 130: + case 162: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 16: + case 17: + case 48: + case 49: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 64: + case 65: + case 68: + case 69: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 8: + case 12: + case 136: + case 140: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 3: + case 35: + case 131: + case 163: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 6: + case 38: + case 134: + case 166: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 20: + case 21: + case 52: + case 53: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 144: + case 145: + case 176: + case 177: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 192: + case 193: + case 196: + case 197: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 96: + case 97: + case 100: + case 101: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 40: + case 44: + case 168: + case 172: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 9: + case 13: + case 137: + case 141: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 18: + case 50: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL12_0 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 80: + case 81: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 72: + case 76: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_50 + PIXEL21_0 + PIXEL30_50 + PIXEL31_50 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 10: + case 138: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 66: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 24: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 7: + case 39: + case 135: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 148: + case 149: + case 180: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 224: + case 228: + case 225: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 41: + case 169: + case 45: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 22: + case 54: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 208: + case 209: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 104: + case 108: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 11: + case 139: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 19: + case 51: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 146: + case 178: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; + } + case 84: + case 85: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 112: + case 113: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 200: + case 204: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 73: + case 77: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 42: + case 170: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 14: + case 142: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 67: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 70: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 28: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 152: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 194: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 98: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 56: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 25: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 26: + case 31: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 82: + case 214: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 88: + case 248: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 74: + case 107: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 27: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 86: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 216: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 106: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 30: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 210: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 120: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 75: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 29: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; + } + case 198: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 184: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 99: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 57: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 71: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 156: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 226: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 60: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 195: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 102: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 153: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 58: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 83: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 92: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 202: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 78: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 154: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 114: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 89: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 90: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 55: + case 23: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; + } + case 182: + case 150: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; + } + case 213: + case 212: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 241: + case 240: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 236: + case 232: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 109: + case 105: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 171: + case 43: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + PIXEL11_0 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 143: + case 15: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; + } + case 124: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 203: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 62: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 211: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 118: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 217: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 110: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 155: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 188: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 185: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 61: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 157: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 103: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 227: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 230: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 199: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 220: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 158: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 234: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 242: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 59: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL11_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 121: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 87: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 79: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_32 + PIXEL03_82 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 122: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 94: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 218: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 91: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL11_0 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 229: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 167: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; + } + case 173: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 181: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 186: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 115: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 93: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; + } + case 206: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 205: + case 201: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; + } + case 174: + case 46: + { + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 179: + case 147: + { + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 117: + case 116: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; + } + case 189: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 231: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; + } + case 126: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 219: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 125: + { + if (Diff(w[8], w[4])) + { + PIXEL00_82 + PIXEL10_32 + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 221: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + if (Diff(w[6], w[8])) + { + PIXEL03_81 + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; + } + case 207: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + } + else + { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; + } + case 238: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + } + else + { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; + } + case 190: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 + } + else + { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_10 + PIXEL11_30 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + break; + } + case 187: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + PIXEL11_0 + PIXEL20_31 + PIXEL30_81 + } + else + { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 243: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; + } + case 119: + { + if (Diff(w[2], w[6])) + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + } + else + { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; + } + case 237: + case 233: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 175: + case 47: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; + } + case 183: + case 151: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; + } + case 245: + case 244: + { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 250: + { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; + } + case 123: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 95: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 222: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 252: + { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 249: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + break; + } + case 235: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 111: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; + } + case 63: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; + } + case 159: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; + } + case 215: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 246: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 254: + { + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 253: + { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 251: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + break; + } + case 239: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; + } + case 127: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; + } + case 191: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; + } + case 223: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; + } + case 247: + { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + case 255: + { + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; + } + } + pIn++; // next source pixel (just increment since it's an int*) + pOut += 16; // skip 4 pixels (4 bytes * 4 pixels) + } + pOut += BpL; // skip next 3 rows + pOut += BpL; + pOut += BpL; + } + hq_vec::reset(); +} + +void DLL InitLUTs() +{ + int i, j, k, r, g, b, Y, u, v; + +#if 0 // colorOutlines() after hqresize + for (i=0; i<65536; i++) + LUT16to32[i] = 0x00404040; + for (i=0; i<65536; i++) + LUT16to32[i+65536] = 0xFF000000 + ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3); +#else // colorOutlines() before hqresize + for (i=0; i<65536; i++) + LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3); + for (i=0; i<65536; i++) + LUT16to32[i+65536] = 0xFF000000 + LUT16to32[i]; +#endif + + for (i=0; i<65536; i++) + RGBtoYUV[i] = 0xFF000000; + + for (i=0; i<32; i++) + for (j=0; j<64; j++) + for (k=0; k<32; k++) + { + r = i << 3; + g = j << 2; + b = k << 3; + Y = (r + g + b) >> 2; + u = 128 + ((r - b) >> 2); + v = 128 + ((-r + 2*g -b)>>3); + RGBtoYUV[ 65536 + (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v; + } +} + +/* +int DLL hq4x_32 ( CImage &ImageIn, CImage &ImageOut ) +{ + if ( ImageIn.Convert32To17() != 0 ) + { + printf( "ERROR: conversion to 17 bit failed\n" ); + return 1; + } + + if ( ImageOut.Init( ImageIn.m_Xres*4, ImageIn.m_Yres*4, 32 ) != 0 ) + { + printf( "ERROR: ImageOut.Init()\n" ); + return 1; + }; + + InitLUTs(); + hq4x_32( (int*)ImageIn.m_pBitmap, ImageOut.m_pBitmap, ImageIn.m_Xres, ImageIn.m_Yres, ImageOut.m_Xres*4 ); + + printf( "\nOK\n" ); + return 0; +} +*/ + +} \ No newline at end of file diff --git a/src/gl/hqnx_asm/hqnx_asm.h b/src/gl/hqnx_asm/hqnx_asm.h new file mode 100644 index 000000000..9ced349fa --- /dev/null +++ b/src/gl/hqnx_asm/hqnx_asm.h @@ -0,0 +1,234 @@ +//hqnx filter library +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +//Copyright (C) 2009 Benjamin Berkels +//Copyright (C) 2012-2014 Alexey Lysiuk +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#ifndef __HQNX_H__ +#define __HQNX_H__ + +#ifdef _MSC_VER +#pragma warning(disable:4799) +#endif // _MSC_VER + +#include "hqnx_asm_Image.h" + +// IMPORTANT NOTE! +// The following is not a generic vectorized math class +// Each member function or overloaded operator does specific task to simplify client code +// To re-implement this class for different platform you need check very carefully +// the Intel C++ Intrinsic Reference at http://software.intel.com/file/18072/ + +#if defined _MSC_VER && defined _M_X64 + +// Implementation via SSE2 intrinsics +// MSVC doesn't support MMX intrinsics on x64 + +#include + +class hq_vec +{ +public: + hq_vec(const int value) + : m_value(_mm_cvtsi32_si128(value)) + { + } + + static hq_vec load(const int source) + { + return _mm_unpacklo_epi8(_mm_cvtsi32_si128(source), _mm_cvtsi32_si128(0)); + } + + static hq_vec expand(const short source) + { + return _mm_set_epi16(source, source, source, source, source, source, source, source); + } + + void store(unsigned char* const destination) const + { + *reinterpret_cast(destination) = _mm_cvtsi128_si32(_mm_packus_epi16(m_value, _mm_cvtsi32_si128(0))); + } + + static void reset() + { + } + + hq_vec& operator+=(const hq_vec& right) + { + m_value = _mm_add_epi16(m_value, right.m_value); + return *this; + } + + hq_vec& operator*=(const hq_vec& right) + { + m_value = _mm_mullo_epi16(m_value, right.m_value); + return *this; + } + + hq_vec& operator<<(const int count) + { + m_value = _mm_sll_epi16(m_value, _mm_cvtsi32_si128(count)); + return *this; + } + + hq_vec& operator>>(const int count) + { + m_value = _mm_srl_epi16(m_value, _mm_cvtsi32_si128(count)); + return *this; + } + +private: + __m128i m_value; + + hq_vec(const __m128i value) + : m_value(value) + { + } + + friend hq_vec operator- (const hq_vec&, const hq_vec&); + friend hq_vec operator* (const hq_vec&, const hq_vec&); + friend hq_vec operator| (const hq_vec&, const hq_vec&); + friend bool operator!=(const int, const hq_vec&); +}; + +inline hq_vec operator-(const hq_vec& left, const hq_vec& right) +{ + return _mm_subs_epu8(left.m_value, right.m_value); +} + +inline hq_vec operator*(const hq_vec& left, const hq_vec& right) +{ + return _mm_mullo_epi16(left.m_value, right.m_value); +} + +inline hq_vec operator|(const hq_vec& left, const hq_vec& right) +{ + return _mm_or_si128(left.m_value, right.m_value); +} + +inline bool operator!=(const int left, const hq_vec& right) +{ + return left != _mm_cvtsi128_si32(right.m_value); +} + +#else // _M_X64 + +// Implementation via MMX intrinsics + +#include + +class hq_vec +{ +public: + hq_vec(const int value) + : m_value(_mm_cvtsi32_si64(value)) + { + } + + static hq_vec load(const int source) + { + return _mm_unpacklo_pi8(_mm_cvtsi32_si64(source), _mm_cvtsi32_si64(0)); + } + + static hq_vec expand(const short source) + { + return _mm_set_pi16(source, source, source, source); + } + + void store(unsigned char* const destination) const + { + *reinterpret_cast(destination) = _mm_cvtsi64_si32(_mm_packs_pu16(m_value, _mm_cvtsi32_si64(0))); + } + + static void reset() + { + _mm_empty(); + } + + hq_vec& operator+=(const hq_vec& right) + { + m_value = _mm_add_pi16(m_value, right.m_value); + return *this; + } + + hq_vec& operator*=(const hq_vec& right) + { + m_value = _mm_mullo_pi16(m_value, right.m_value); + return *this; + } + + hq_vec& operator<<(const int count) + { + m_value = _mm_sll_pi16(m_value, _mm_cvtsi32_si64(count)); + return *this; + } + + hq_vec& operator>>(const int count) + { + m_value = _mm_srl_pi16(m_value, _mm_cvtsi32_si64(count)); + return *this; + } + +private: + __m64 m_value; + + hq_vec(const __m64 value) + : m_value(value) + { + } + + friend hq_vec operator- (const hq_vec&, const hq_vec&); + friend hq_vec operator* (const hq_vec&, const hq_vec&); + friend hq_vec operator| (const hq_vec&, const hq_vec&); + friend bool operator!=(const int, const hq_vec&); +}; + +inline hq_vec operator-(const hq_vec& left, const hq_vec& right) +{ + return _mm_subs_pu8(left.m_value, right.m_value); +} + +inline hq_vec operator*(const hq_vec& left, const hq_vec& right) +{ + return _mm_mullo_pi16(left.m_value, right.m_value); +} + +inline hq_vec operator|(const hq_vec& left, const hq_vec& right) +{ + return _mm_or_si64(left.m_value, right.m_value); +} + +inline bool operator!=(const int left, const hq_vec& right) +{ + return left != _mm_cvtsi64_si32(right.m_value); +} + +#endif // _MSC_VER && _M_X64 + +namespace HQnX_asm +{ +void DLL hq2x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ); +void DLL hq3x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ); +void DLL hq4x_32( int * pIn, unsigned char * pOut, int Xres, int Yres, int BpL ); +int DLL hq4x_32 ( CImage &ImageIn, CImage &ImageOut ); + +void DLL InitLUTs(); + +} + + +#endif //__HQNX_H__ \ No newline at end of file diff --git a/src/gl/hqnx_asm/hqnx_asm_Image.cpp b/src/gl/hqnx_asm/hqnx_asm_Image.cpp new file mode 100644 index 000000000..7af120173 --- /dev/null +++ b/src/gl/hqnx_asm/hqnx_asm_Image.cpp @@ -0,0 +1,1183 @@ +//CImage class - loading and saving BMP and TGA files +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +#include +#include +#include "hqnx_asm_Image.h" + +#ifndef _MSC_VER +#define _stricmp strcasecmp +#endif + +namespace HQnX_asm +{ + +DLL CImage::CImage() +{ + m_Xres = m_Yres = m_NumPixel = 0; + m_pBitmap = NULL; +} + +DLL CImage::~CImage() +{ + Destroy(); +} + +int DLL CImage::Init( int X, int Y, unsigned short BitPerPixel ) +{ + if (m_pBitmap != NULL) + free(m_pBitmap); + + m_Xres = X; + m_Yres = Y; + m_BitPerPixel = BitPerPixel<=8 ? 8 : BitPerPixel<=16 ? 16 : BitPerPixel<=24 ? 24 : 32; + m_BytePerPixel = m_BitPerPixel >> 3; + m_NumPixel = m_Xres*m_Yres; + int size = m_NumPixel*((m_BitPerPixel+7)/8); + m_pBitmap=(unsigned char *)malloc(size); + return (m_pBitmap != NULL) ? 0 : 1; +} + +int DLL CImage::SetImage(unsigned char *img, int width, int height, int bpp) +{ + Init(width, height, bpp); + + memcpy(m_pBitmap, img, m_NumPixel * m_BytePerPixel); + + return 0; +} + +int DLL CImage::Destroy() +{ + if (m_pBitmap) + { + free(m_pBitmap); + m_pBitmap = NULL; + } + m_Xres = 0; + m_Yres = 0; + m_NumPixel = 0; + m_BitPerPixel = 0; + return 0; +} + +int DLL CImage::Convert32To17( void ) +{ + int nRes = eConvUnknownFormat; + + if ( m_BitPerPixel == 32 ) + { + if ( m_pBitmap != NULL ) + { + unsigned char * pTemp8 = m_pBitmap; + unsigned int * pTemp32 = (unsigned int *)m_pBitmap; + unsigned int a, r, g, b; + for ( int i=0; i> 3; + g = (*(pTemp8++)) >> 2; + r = (*(pTemp8++)) >> 3; + a = *(pTemp8++); + *pTemp32 = (r << 11) + (g << 5) + b + (a > 127 ? 0x10000 : 0); + pTemp32++; + } + } + else + nRes = eConvSourceMemory; + + nRes = 0; + } + + return nRes; +} + +int DLL CImage::ConvertTo32( void ) +{ + int nRes = eConvUnknownFormat; + + if ( m_pBitmap == NULL ) + return eConvSourceMemory; + + switch ( m_BitPerPixel ) + { + case 8: + { + nRes = 0; + m_BitPerPixel = 32; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*4); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp8 = m_pBitmap; + unsigned char * pTemp32 = pNewBitmap; + unsigned char c; + for ( int i=0; i> 3); + *(pTemp24++) = ((rgb & 0xF800) >> 8); + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + case 32: + { + nRes = 0; + m_BitPerPixel = 24; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*3); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp32 = m_pBitmap; + unsigned char * pTemp24 = pNewBitmap; + for ( int i=0; i> 3; + g = m_Pal[c].g >> 2; + b = m_Pal[c].b >> 3; + *(pTemp16++) = (r << 11) + (g << 5) + b; + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + case 24: + { + nRes = 0; + m_BitPerPixel = 16; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*2); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp24 = m_pBitmap; + unsigned short * pTemp16 = (unsigned short *)pNewBitmap; + unsigned short r, g, b; + for ( int i=0; i> 3; + g = (*(pTemp24++)) >> 2; + r = (*(pTemp24++)) >> 3; + *(pTemp16++) = (r << 11) + (g << 5) + b; + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + case 32: + { + nRes = 0; + m_BitPerPixel = 16; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*2); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp32 = m_pBitmap; + unsigned short * pTemp16 = (unsigned short *)pNewBitmap; + unsigned short r, g, b; + for ( int i=0; i> 3; + g = (*(pTemp32++)) >> 2; + r = (*(pTemp32++)) >> 3; + pTemp32++; + *(pTemp16++) = (r << 11) + (g << 5) + b; + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + break; + } + } + + return nRes; +} + +int CImage::Convert8To17( int transindex ) +{ + int nRes = eConvUnknownFormat; + + if ( m_BitPerPixel == 8 ) + { + m_BitPerPixel = 32; + unsigned char * pNewBitmap = (unsigned char *)malloc(m_NumPixel*4); + if ( pNewBitmap != NULL ) + { + unsigned char * pTemp8 = m_pBitmap; + unsigned int * pTemp32 = (unsigned int *)pNewBitmap; + unsigned int r, g, b; + unsigned char c; + for ( int i=0; i> 3; + g = m_Pal[c].g >> 2; + b = m_Pal[c].b >> 3; + *(pTemp32++) = (r << 11) + (g << 5) + b + (transindex != c ? 0x10000 : 0); + } + free(m_pBitmap); + m_pBitmap = pNewBitmap; + } + else + nRes = eConvDestMemory; + + nRes = 0; + } + + return nRes; +} + +int CImage::SaveBmp(char *szFilename) +{ + _BMPFILEHEADER fh; + _BMPIMAGEHEADER ih; + unsigned char BmpPal[256][4]; + long int SuffLen; + long int Dummy = 0; + unsigned char * pBuf; + short i; + + if (!(f = fopen(szFilename, "wb"))) return eSaveBmpFileOpen; + if ( m_pBitmap == NULL ) return eSaveBmpSourceMemory; + + fh.bfType=0x4D42; + if (m_BitPerPixel==8) + { + SuffLen=((m_Xres+3)/4)*4-m_Xres; + ih.biSize=0x28; + ih.biWidth=m_Xres; + ih.biHeight=m_Yres; + ih.biPlanes=1; + ih.biBitCount=8; + ih.biCompression=0; + ih.biSizeImage=(m_Xres+SuffLen)*m_Yres; + ih.biXPelsPerMeter=ih.biYPelsPerMeter=0x2E23; // 300dpi (pixels per meter) + ih.biClrUsed=ih.biClrImportant=0; + fh.bfSize=(ih.biSizeImage)+0x0436; + fh.bfRes1=0; + fh.bfOffBits=0x0436; + if (fwrite(&fh, 14, 1, f) != 1) return eSaveBmpFileWrite; + if (fwrite(&ih, 40, 1, f) != 1) return eSaveBmpFileWrite; + for (i=0; i<256; i++) + { + BmpPal[i][0]=m_Pal[i].b; + BmpPal[i][1]=m_Pal[i].g; + BmpPal[i][2]=m_Pal[i].r; + BmpPal[i][3]=0; + } + if (fwrite(&BmpPal, 1024, 1, f) != 1) return eSaveBmpFileWrite; + pBuf=m_pBitmap; + pBuf+=m_NumPixel; + for (i=0; i0) + { + if (fwrite(&Dummy, SuffLen, 1, f) != 1) return eSaveBmpFileWrite; + } + } + } + else + if (m_BitPerPixel==24) + { + SuffLen=((m_Xres*3+3)/4)*4-m_Xres*3; + ih.biSize=0x28; + ih.biWidth=m_Xres; + ih.biHeight=m_Yres; + ih.biPlanes=1; + ih.biBitCount=24; + ih.biCompression=0; + ih.biSizeImage=(m_Xres*3+SuffLen)*m_Yres; + ih.biXPelsPerMeter=ih.biYPelsPerMeter=0x2E23; // 300dpi (pixels per meter) + ih.biClrUsed=ih.biClrImportant=0; + fh.bfSize=(ih.biSizeImage)+0x0036; + fh.bfRes1=0; + fh.bfOffBits=0x0036; + if (fwrite(&fh, 14, 1, f) != 1) return eSaveBmpFileWrite; + if (fwrite(&ih, 40, 1, f) != 1) return eSaveBmpFileWrite; + pBuf=m_pBitmap; + pBuf+=m_NumPixel*3; + for (i=0; i0) + { + if (fwrite(&Dummy, SuffLen, 1, f) != 1) return eSaveBmpFileWrite; + } + } + } + else + return eSaveBmpColorDepth; + + fclose(f); + + return 0; +} + +int CImage::LoadBmp(char *szFilename) +{ + _BMPFILEHEADER fh; + _BMPIMAGEHEADEROLD ih_old; + _BMPIMAGEHEADER ih; + unsigned char BmpPal[256][4]; + long int biSize; + long int SuffLen; + long int Dummy = 0; + unsigned char * pBuf; + short i; + long int xres, yres; + unsigned short bits; + + if (!(f = fopen(szFilename, "rb"))) return eLoadBmpFileOpen; + if (fread(&fh, 14, 1, f) != 1) return eLoadBmpFileRead; + if (fh.bfType != 0x4D42) return eLoadBmpBadFormat; + if (fread(&biSize, 4, 1, f) != 1) return eLoadBmpFileRead; + if (biSize > 12) + { + fseek( f, -4, SEEK_CUR ); + if (fread(&ih, biSize, 1, f) != 1) return eLoadBmpFileRead; + xres = ih.biWidth; + yres = ih.biHeight; + bits = ih.biBitCount; + } + else + { + fseek( f, -4, SEEK_CUR ); + if (fread(&ih_old, biSize, 1, f) != 1) return eLoadBmpFileRead; + xres = ih_old.biWidth; + yres = ih_old.biHeight; + bits = ih_old.biBitCount; + } + + if ( Init( xres, yres, bits ) != 0 ) return eLoadBmpInit; + if (m_BitPerPixel==8) + { + SuffLen=((m_Xres+3)/4)*4-m_Xres; + if (fread(&BmpPal, 1024, 1, f) != 1) return eLoadBmpFileRead; + for (i=0; i<256; i++) + { + m_Pal[i].b=BmpPal[i][0]; + m_Pal[i].g=BmpPal[i][1]; + m_Pal[i].r=BmpPal[i][2]; + } + pBuf=m_pBitmap; + pBuf+=m_NumPixel; + for (i=0; i0) + { + if (fread(&Dummy, SuffLen, 1, f) != 1) return eLoadBmpFileRead; + } + } + } + else + if (m_BitPerPixel==24) + { + SuffLen=((m_Xres*3+3)/4)*4-(m_Xres*3); + pBuf=m_pBitmap; + pBuf+=m_NumPixel*3; + for (i=0; i0) + { + if (fread(&Dummy, SuffLen, 1, f) != 1) return eLoadBmpFileRead; + } + } + } + else + return eLoadBmpColorDepth; + + fclose(f); + + return 0; +} + +void CImage::Output( void ) +{ + fwrite(m_cBuf, m_nCount, 1, f); + m_nCount=0; +} + +void CImage::Output( char c ) +{ + if ( m_nCount == sizeof(m_cBuf) ) + { + fwrite(m_cBuf, m_nCount, 1, f); + m_nCount=0; + } + m_cBuf[m_nCount++] = c; +} + +void CImage::Output( char * pcData, int nSize ) +{ + for ( int i=0; i 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+i-nDif-nRep), nDif ); + } + nDif = 1; + } + } + else + { + if ( bEqual && (nRep<127) ) + nRep++; + else + { + Output( nRep+128 ); + Output( (char*)&colOld, 1 ); + nRep = 0; + nDif = 1; + } + } + } + + if ( nRep == 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+m_Xres-nDif), nDif ); + } + else + { + Output( nRep+128 ); + Output( (char*)&colOld, 1 ); + } + Output(); + } + } + } + else + if (m_BitPerPixel==24) + { + fh.tiImageType = bCompressed ? 10 : 2; + if (fwrite(&fh, sizeof(fh), 1, f) != 1) return eSaveTgaFileWrite; + + _BGR * pcolBuf = (_BGR *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+i-nDif-nRep), sizeof(_BGR)*nDif ); + } + nDif = 1; + } + } + else + { + if ( bEqual && (nRep<127) ) + nRep++; + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGR) ); + nRep = 0; + nDif = 1; + } + } + } + + if ( nRep == 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+m_Xres-nDif), sizeof(_BGR)*nDif ); + } + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGR) ); + } + Output(); + } + } + } + else + if (m_BitPerPixel==32) + { + fh.tiImageType = bCompressed ? 10 : 2; + fh.tiAttrBits = 8; + if (fwrite(&fh, sizeof(fh), 1, f) != 1) return eSaveTgaFileWrite; + + _BGRA * pcolBuf = (_BGRA *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+i-nDif-nRep), sizeof(_BGRA)*nDif ); + } + nDif = 1; + } + } + else + { + if ( bEqual && (nRep<127) ) + nRep++; + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGRA) ); + nRep = 0; + nDif = 1; + } + } + } + + if ( nRep == 0 ) + { + Output( nDif-1 ); + Output( (char*)(pcolBuf+m_Xres-nDif), sizeof(_BGRA)*nDif ); + } + else + { + Output( nRep+128 ); + Output( (char*)&colOld, sizeof(_BGRA) ); + } + Output(); + } + } + } + else + return eSaveTgaColorDepth; + + fclose(f); + + return 0; +} + +int CImage::LoadTga(char *szFilename) +{ + _TGAHEADER fh; + int i, j, k; + unsigned char nCount; + + if (!(f = fopen(szFilename, "rb"))) return eLoadTgaFileOpen; + if (fread(&fh, sizeof(fh), 1, f) != 1) return eLoadTgaFileRead; + bool bCompressed = (( fh.tiImageType & 8 ) != 0); + if ((fh.tiBitPerPixel<=0) || (fh.tiBitPerPixel>32)) + return eLoadTgaBadFormat; + + if ( Init( fh.tiXres, fh.tiYres, fh.tiBitPerPixel ) != 0 ) + return eLoadTgaInit; + + if ( m_BitPerPixel == 8 ) + { + if ( fh.tiPaletteIncluded == 1 ) + { + if ( fh.tiPaletteBpp == 24) + { + if (fread(&m_Pal, 3, fh.tiPaletteSize, f) != fh.tiPaletteSize) + return eLoadTgaFileRead; + } + else + if ( fh.tiPaletteBpp == 32) + { + unsigned char BmpPal[256][4]; + + if (fread(&BmpPal, 4, fh.tiPaletteSize, f) != fh.tiPaletteSize) + return eLoadTgaFileRead; + + for (i=0; i= m_pBitmap ) + { + nCount = Input(); + if ((nCount & 128)==0) + { + for (k=0; k<=nCount; k++) + { + colCur = Input(); + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + else + { + colCur = Input(); + for (k=0; k<=nCount-128; k++) + { + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + } + } + } + else + if ( m_BitPerPixel == 24 ) + { + _BGR * pcolBuf = (_BGR *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j= (_BGR *)m_pBitmap ) + { + nCount = Input(); + if ((nCount & 128)==0) + { + for (k=0; k<=nCount; k++) + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + else + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + for (k=0; k<=nCount-128; k++) + { + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + } + } + } + else + if ( m_BitPerPixel == 32 ) + { + _BGRA * pcolBuf = (_BGRA *)m_pBitmap; + pcolBuf += m_NumPixel; + + if ( !bCompressed ) + { + for (j=0; j= (_BGRA *)m_pBitmap ) + { + nCount = Input(); + if ((nCount & 128)==0) + { + for (k=0; k<=nCount; k++) + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + colCur.a = Input(); + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + else + { + colCur.b = Input(); + colCur.g = Input(); + colCur.r = Input(); + colCur.a = Input(); + for (k=0; k<=nCount-128; k++) + { + *(pcolBuf+i) = colCur; + if ( (++i) == m_Xres ) + { + i=0; + pcolBuf -= m_Xres; + break; + } + } + } + } + } + } + else + return eLoadTgaColorDepth; + + fclose(f); + + return 0; +} + +int DLL CImage::Load(char *szFilename) +{ + int nRes = 0; + + if ( szFilename != NULL ) + { + char * szExt = strrchr( szFilename, '.' ); + int nNotTGA = 1; + + if ( szExt != NULL ) + nNotTGA = _stricmp( szExt, ".tga" ); + + if ( nNotTGA != 0 ) + nRes = LoadBmp( szFilename ); + else + nRes = LoadTga( szFilename ); + } + else + nRes = eLoadFilename; + + return nRes; +} + +int DLL CImage::Save(char *szFilename) +{ + int nRes = 0; + int nNotTGA = 1; + + if ( szFilename != NULL ) + { + char * szExt = strrchr( szFilename, '.' ); + + if ( szExt != NULL ) + nNotTGA = _stricmp( szExt, ".tga" ); + + if ( nNotTGA != 0 ) + { + if (( m_BitPerPixel == 16 ) || ( m_BitPerPixel == 32 )) + nRes = ConvertTo24(); + + if (nRes == 0) + nRes = SaveBmp( szFilename ); + } + else + { + if ( m_BitPerPixel == 16 ) + nRes = ConvertTo24(); + + if (nRes == 0) + nRes = SaveTga( szFilename, true ); + } + } + else + nRes = eSaveFilename; + + return nRes; +} + +} \ No newline at end of file diff --git a/src/gl/hqnx_asm/hqnx_asm_Image.h b/src/gl/hqnx_asm/hqnx_asm_Image.h new file mode 100644 index 000000000..e4157a7b5 --- /dev/null +++ b/src/gl/hqnx_asm/hqnx_asm_Image.h @@ -0,0 +1,152 @@ +//CImage class - loading and saving BMP and TGA files +//---------------------------------------------------------- +//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) +// +//This program is free software; you can redistribute it and/or +//modify it under the terms of the GNU Lesser General Public +//License as published by the Free Software Foundation; either +//version 2.1 of the License, or (at your option) any later version. +// +//This program is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +//Lesser General Public License for more details. +// +//You should have received a copy of the GNU Lesser General Public +//License along with this program; if not, write to the Free Software +//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +//#ifdef WIN32 +//#define DLL __declspec(dllexport) +//#else +#define DLL +//#endif + +#include +#pragma once +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif // _MSC_VER +#pragma pack(1) + +namespace HQnX_asm +{ + +typedef struct { unsigned char b, g, r; } _BGR; +typedef struct { unsigned char b, g, r, a; } _BGRA; + +class CImage +{ + public: + DLL CImage(); + DLL ~CImage(); + + enum CImageErrors + { + eConvUnknownFormat = 10, + eConvSourceMemory = 11, + eConvDestMemory = 12, + + eSaveBmpFileOpen = 20, + eSaveBmpFileWrite = 21, + eSaveBmpSourceMemory = 22, + eSaveBmpColorDepth = 23, + + eLoadBmpFileOpen = 30, + eLoadBmpFileRead = 31, + eLoadBmpBadFormat = 32, + eLoadBmpInit = 33, + eLoadBmpColorDepth = 34, + + eSaveTgaFileOpen = 40, + eSaveTgaFileWrite = 41, + eSaveTgaSourceMemory = 42, + eSaveTgaColorDepth = 43, + + eLoadTgaFileOpen = 50, + eLoadTgaFileRead = 51, + eLoadTgaBadFormat = 52, + eLoadTgaInit = 53, + eLoadTgaColorDepth = 54, + + eLoadFilename = 60, + eSaveFilename = 61, + }; + + struct _BMPFILEHEADER + { + unsigned short bfType; + long int bfSize, bfRes1, bfOffBits; + }; + + struct _BMPIMAGEHEADEROLD + { + long int biSize; + unsigned short biWidth, biHeight; + unsigned short biPlanes, biBitCount; + }; + + struct _BMPIMAGEHEADER + { + long int biSize, biWidth, biHeight; + unsigned short biPlanes, biBitCount; + long int biCompression, biSizeImage; + long int biXPelsPerMeter, biYPelsPerMeter; + long int biClrUsed, biClrImportant; + }; + + struct _TGAHEADER + { + unsigned char tiIdentSize; + unsigned char tiPaletteIncluded; + unsigned char tiImageType; + unsigned short tiPaletteStart; + unsigned short tiPaletteSize; + unsigned char tiPaletteBpp; + unsigned short tiX0; + unsigned short tiY0; + unsigned short tiXres; + unsigned short tiYres; + unsigned char tiBitPerPixel; + unsigned char tiAttrBits; + }; + + public: + int DLL Init( int Xres, int Yres, unsigned short BitPerPixel ); + int DLL SetImage(unsigned char *img, int width, int height, int bpp); + int DLL Destroy(); + int DLL ConvertTo32( void ); + int DLL ConvertTo24( void ); + int DLL ConvertTo16( void ); + int DLL Convert8To17( int transindex ); + int DLL Convert32To17( void ); + int SaveBmp(char *szFilename); + int LoadBmp(char *szFilename); + int SaveTga(char *szFilename, bool bCompressed ); + int LoadTga(char *szFilename); + int DLL Load(char *szFilename); + int DLL Save(char *szFilename); + + private: + void Output( char * pcData, int nSize ); + void Output( char c ); + void Output( void ); + unsigned char Input( void ); + + public: + int m_Xres, m_Yres; + unsigned short m_BitPerPixel; + unsigned short m_BytePerPixel; + unsigned char * m_pBitmap; + _BGR m_Pal[256]; + + private: + int m_NumPixel; + FILE * f; + int m_nCount; + char m_cBuf[32768]; +}; + +#pragma pack(8) + +} \ No newline at end of file diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp new file mode 100644 index 000000000..fb63c2cf6 --- /dev/null +++ b/src/gl/models/gl_models.cpp @@ -0,0 +1,1013 @@ +/* +** gl_models.cpp +** +** General model handling code +** +**--------------------------------------------------------------------------- +** Copyright 2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** 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 "gl/system/gl_system.h" +#include "w_wad.h" +#include "cmdlib.h" +#include "sc_man.h" +#include "m_crc32.h" +#include "c_console.h" +#include "g_game.h" +#include "doomstat.h" +#include "g_level.h" +#include "r_state.h" +#include "d_player.h" +//#include "resources/voxels.h" +//#include "gl/gl_intern.h" + +#include "gl/system/gl_interface.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/models/gl_models.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_geometric.h" +#include "gl/utility/gl_convert.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/shaders/gl_shader.h" + +static inline float GetTimeFloat() +{ + return (float)I_MSTime() * (float)TICRATE / 1000.0f; +} + +CVAR(Bool, gl_interpolate_model_frames, true, CVAR_ARCHIVE) +CVAR(Bool, gl_light_models, true, CVAR_ARCHIVE) +EXTERN_CVAR(Int, gl_fogmode) + +extern TDeletingArray Voxels; +extern TDeletingArray VoxelDefs; + + +class DeletingModelArray : public TArray +{ +public: + +#if 1 + ~DeletingModelArray() + { + for(unsigned i=0;i= 0; i--) + { + Models[i]->BuildVertexBuffer(); + } +} + +void gl_FlushModels() +{ + for (int i = Models.Size() - 1; i >= 0; i--) + { + Models[i]->DestroyVertexBuffer(); + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FModelVertexBuffer::FModelVertexBuffer(bool needindex) +{ + glBindVertexArray(vao_id); + + ibo_id = 0; + if (needindex) + { + glGenBuffers(1, &ibo_id); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + } + + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); + glEnableVertexAttribArray(VATTR_VERTEX2); + glBindVertexArray(0); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FModelVertexBuffer::~FModelVertexBuffer() +{ + if (ibo_id != 0) + { + glDeleteBuffers(1, &ibo_id); + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FModelVertex *FModelVertexBuffer::LockVertexBuffer(unsigned int size) +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, size * sizeof(FModelVertex), NULL, GL_STATIC_DRAW); + return (FModelVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, size * sizeof(FModelVertex), GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FModelVertexBuffer::UnlockVertexBuffer() +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glUnmapBuffer(GL_ARRAY_BUFFER); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +unsigned int *FModelVertexBuffer::LockIndexBuffer(unsigned int size) +{ + if (ibo_id != 0) + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, size * sizeof(unsigned int), NULL, GL_STATIC_DRAW); + return (unsigned int*)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, size * sizeof(unsigned int), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + } + else + { + return NULL; + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FModelVertexBuffer::UnlockIndexBuffer() +{ + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); +} + + +//=========================================================================== +// +// Sets up the buffer starts for frame interpolation +// This must be called after gl_RenderState.Apply! +// +//=========================================================================== + +unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2) +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame1].u); + glVertexAttribPointer(VATTR_VERTEX2, 3, GL_FLOAT, false, sizeof(FModelVertex), &VMO[frame2].x); + return frame1; +} + +//=========================================================================== +// +// FModel::~FModel +// +//=========================================================================== + +FModel::~FModel() +{ + if (mVBuf != NULL) delete mVBuf; +} + + + + +static TArray SpriteModelFrames; +static int * SpriteModelHash; +//TArray StateModelFrames; + +static void DeleteModelHash() +{ + if (SpriteModelHash != NULL) delete [] SpriteModelHash; + SpriteModelHash = NULL; +} + +//=========================================================================== +// +// FindGFXFile +// +//=========================================================================== + +static int FindGFXFile(FString & fn) +{ + int best = -1; + int dot = fn.LastIndexOf('.'); + int slash = fn.LastIndexOf('/'); + if (dot > slash) fn.Truncate(dot); + + static const char * extensions[] = { ".png", ".jpg", ".tga", ".pcx", NULL }; + + for (const char ** extp=extensions; *extp; extp++) + { + int lump = Wads.CheckNumForFullName(fn + *extp); + if (lump >= best) best = lump; + } + return best; +} + + +//=========================================================================== +// +// LoadSkin +// +//=========================================================================== + +FTexture * LoadSkin(const char * path, const char * fn) +{ + FString buffer; + + buffer.Format("%s%s", path, fn); + + int texlump = FindGFXFile(buffer); + if (texlump>=0) + { + return TexMan.FindTexture(Wads.GetLumpFullName(texlump), FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny); + } + else + { + return NULL; + } +} + +//=========================================================================== +// +// ModelFrameHash +// +//=========================================================================== + +static int ModelFrameHash(FSpriteModelFrame * smf) +{ + const DWORD *table = GetCRCTable (); + DWORD hash = 0xffffffff; + + const char * s = (const char *)(&smf->type); // this uses type, sprite and frame for hashing + const char * se= (const char *)(&smf->hashnext); + + for (; smFileName.CompareNoCase(fullname)) return Models[i]; + } + + int len = Wads.LumpLength(lump); + FMemLump lumpd = Wads.ReadLump(lump); + char * buffer = (char*)lumpd.GetMem(); + + if (!memcmp(buffer, "DMDM", 4)) + { + model = new FDMDModel; + } + else if (!memcmp(buffer, "IDP2", 4)) + { + model = new FMD2Model; + } + else if (!memcmp(buffer, "IDP3", 4)) + { + model = new FMD3Model; + } + + if (model != NULL) + { + if (!model->Load(path, lump, buffer, len)) + { + delete model; + return NULL; + } + } + else + { + // try loading as a voxel + FVoxel *voxel = R_LoadKVX(lump); + if (voxel != NULL) + { + model = new FVoxelModel(voxel, true); + } + else + { + Printf("LoadModel: Unknown model format in '%s'\n", fullname.GetChars()); + return NULL; + } + } + // The vertex buffer cannot be initialized here because this gets called before OpenGL is initialized + model->mFileName = fullname; + Models.Push(model); + return model; +} + +//=========================================================================== +// +// gl_InitModels +// +//=========================================================================== + +void gl_InitModels() +{ + int Lump, lastLump; + FString path; + int index; + int i; + + FSpriteModelFrame smf; + + lastLump = 0; + + for(unsigned i=0;iVoxelIndex = Models.Push(md); + } + // now create GL model frames for the voxeldefs + for (unsigned i = 0; i < VoxelDefs.Size(); i++) + { + FVoxelModel *md = (FVoxelModel*)Models[VoxelDefs[i]->Voxel->VoxelIndex]; + memset(&smf, 0, sizeof(smf)); + smf.models[0] = md; + smf.skins[0] = md->GetPaletteTexture(); + smf.xscale = smf.yscale = smf.zscale = FIXED2FLOAT(VoxelDefs[i]->Scale); + smf.angleoffset = VoxelDefs[i]->AngleOffset; + if (VoxelDefs[i]->PlacedSpin != 0) + { + smf.yrotate = 1.f; + smf.rotationSpeed = VoxelDefs[i]->PlacedSpin / 55.55f; + smf.flags |= MDL_ROTATING; + } + VoxelDefs[i]->VoxeldefIndex = SpriteModelFrames.Push(smf); + if (VoxelDefs[i]->PlacedSpin != VoxelDefs[i]->DroppedSpin) + { + if (VoxelDefs[i]->DroppedSpin != 0) + { + smf.yrotate = 1.f; + smf.rotationSpeed = VoxelDefs[i]->DroppedSpin / 55.55f; + smf.flags |= MDL_ROTATING; + } + else + { + smf.yrotate = 0; + smf.rotationSpeed = 0; + smf.flags &= ~MDL_ROTATING; + } + SpriteModelFrames.Push(smf); + } + } + + memset(&smf, 0, sizeof(smf)); + while ((Lump = Wads.FindLump("MODELDEF", &lastLump)) != -1) + { + FScanner sc(Lump); + while (sc.GetString()) + { + if (sc.Compare("model")) + { + sc.MustGetString(); + memset(&smf, 0, sizeof(smf)); + smf.xscale=smf.yscale=smf.zscale=1.f; + + smf.type = PClass::FindClass(sc.String); + if (!smf.type || smf.type->Defaults == NULL) + { + sc.ScriptError("MODELDEF: Unknown actor type '%s'\n", sc.String); + } + GetDefaultByType(smf.type)->hasmodel=true; + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + sc.MustGetString(); + if (sc.Compare("path")) + { + sc.MustGetString(); + FixPathSeperator(sc.String); + path = sc.String; + if (path[(int)path.Len()-1]!='/') path+='/'; + } + else if (sc.Compare("model")) + { + sc.MustGetNumber(); + index=sc.Number; + if (index<0 || index>=MAX_MODELS_PER_FRAME) + { + sc.ScriptError("Too many models in %s", smf.type->TypeName.GetChars()); + } + sc.MustGetString(); + FixPathSeperator(sc.String); + smf.models[index] = FindModel(path.GetChars(), sc.String); + if (!smf.models[index]) + { + Printf("%s: model not found in %s\n", sc.String, path.GetChars()); + } + } + else if (sc.Compare("scale")) + { + sc.MustGetFloat(); + smf.xscale=sc.Float; + sc.MustGetFloat(); + smf.yscale=sc.Float; + sc.MustGetFloat(); + smf.zscale=sc.Float; + } + // [BB] Added zoffset reading. + // Now it must be considered deprecated. + else if (sc.Compare("zoffset")) + { + sc.MustGetFloat(); + smf.zoffset=sc.Float; + } + // Offset reading. + else if (sc.Compare("offset")) + { + sc.MustGetFloat(); + smf.xoffset = sc.Float; + sc.MustGetFloat(); + smf.yoffset = sc.Float; + sc.MustGetFloat(); + smf.zoffset = sc.Float; + } + // angleoffset, pitchoffset and rolloffset reading. + else if (sc.Compare("angleoffset")) + { + sc.MustGetFloat(); + smf.angleoffset = FLOAT_TO_ANGLE(sc.Float); + } + else if (sc.Compare("pitchoffset")) + { + sc.MustGetFloat(); + smf.pitchoffset = sc.Float; + } + else if (sc.Compare("rolloffset")) + { + sc.MustGetFloat(); + smf.rolloffset = sc.Float; + } + // [BB] Added model flags reading. + else if (sc.Compare("ignoretranslation")) + { + smf.flags |= MDL_IGNORETRANSLATION; + } + else if (sc.Compare("pitchfrommomentum")) + { + smf.flags |= MDL_PITCHFROMMOMENTUM; + } + else if (sc.Compare("inheritactorpitch")) + { + smf.flags |= MDL_INHERITACTORPITCH; + } + else if (sc.Compare("inheritactorroll")) + { + smf.flags |= MDL_INHERITACTORROLL; + } + else if (sc.Compare("rotating")) + { + smf.flags |= MDL_ROTATING; + smf.xrotate = 0.; + smf.yrotate = 1.; + smf.zrotate = 0.; + smf.rotationCenterX = 0.; + smf.rotationCenterY = 0.; + smf.rotationCenterZ = 0.; + smf.rotationSpeed = 1.; + } + else if (sc.Compare("rotation-speed")) + { + sc.MustGetFloat(); + smf.rotationSpeed = sc.Float; + } + else if (sc.Compare("rotation-vector")) + { + sc.MustGetFloat(); + smf.xrotate = sc.Float; + sc.MustGetFloat(); + smf.yrotate = sc.Float; + sc.MustGetFloat(); + smf.zrotate = sc.Float; + } + else if (sc.Compare("rotation-center")) + { + sc.MustGetFloat(); + smf.rotationCenterX = sc.Float; + sc.MustGetFloat(); + smf.rotationCenterY = sc.Float; + sc.MustGetFloat(); + smf.rotationCenterZ = sc.Float; + } + else if (sc.Compare("interpolatedoubledframes")) + { + smf.flags |= MDL_INTERPOLATEDOUBLEDFRAMES; + } + else if (sc.Compare("nointerpolation")) + { + smf.flags |= MDL_NOINTERPOLATION; + } + else if (sc.Compare("skin")) + { + sc.MustGetNumber(); + index=sc.Number; + if (index<0 || index>=MAX_MODELS_PER_FRAME) + { + sc.ScriptError("Too many models in %s", smf.type->TypeName.GetChars()); + } + sc.MustGetString(); + FixPathSeperator(sc.String); + if (sc.Compare("")) + { + smf.skins[index]=NULL; + } + else + { + smf.skins[index]=LoadSkin(path.GetChars(), sc.String); + if (smf.skins[index] == NULL) + { + Printf("Skin '%s' not found in '%s'\n", + sc.String, smf.type->TypeName.GetChars()); + } + } + } + else if (sc.Compare("frameindex") || sc.Compare("frame")) + { + bool isframe=!!sc.Compare("frame"); + + sc.MustGetString(); + smf.sprite = -1; + for (i = 0; i < (int)sprites.Size (); ++i) + { + if (strnicmp (sprites[i].name, sc.String, 4) == 0) + { + if (sprites[i].numframes==0) + { + //sc.ScriptError("Sprite %s has no frames", sc.String); + } + smf.sprite = i; + break; + } + } + if (smf.sprite==-1) + { + sc.ScriptError("Unknown sprite %s in model definition for %s", sc.String, smf.type->TypeName.GetChars()); + } + + sc.MustGetString(); + FString framechars = sc.String; + + sc.MustGetNumber(); + index=sc.Number; + if (index<0 || index>=MAX_MODELS_PER_FRAME) + { + sc.ScriptError("Too many models in %s", smf.type->TypeName.GetChars()); + } + if (isframe) + { + sc.MustGetString(); + if (smf.models[index]!=NULL) + { + smf.modelframes[index] = smf.models[index]->FindFrame(sc.String); + if (smf.modelframes[index]==-1) sc.ScriptError("Unknown frame '%s' in %s", sc.String, smf.type->TypeName.GetChars()); + } + else smf.modelframes[index] = -1; + } + else + { + sc.MustGetNumber(); + smf.modelframes[index] = sc.Number; + } + + for(i=0; framechars[i]>0; i++) + { + char map[29]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + int c = toupper(framechars[i])-'A'; + + if (c<0 || c>=29) + { + sc.ScriptError("Invalid frame character %c found", c+'A'); + } + if (map[c]) continue; + smf.frame=c; + SpriteModelFrames.Push(smf); + map[c]=1; + } + } + else + { + sc.ScriptMessage("Unrecognized string \"%s\"", sc.String); + } + } + } + } + } + + // create a hash table for quick access + SpriteModelHash = new int[SpriteModelFrames.Size ()]; + atterm(DeleteModelHash); + memset(SpriteModelHash, 0xff, SpriteModelFrames.Size () * sizeof(int)); + + for (i = 0; i < (int)SpriteModelFrames.Size (); i++) + { + int j = ModelFrameHash(&SpriteModelFrames[i]) % SpriteModelFrames.Size (); + + SpriteModelFrames[i].hashnext = SpriteModelHash[j]; + SpriteModelHash[j]=i; + } +} + + +//=========================================================================== +// +// gl_FindModelFrame +// +//=========================================================================== +EXTERN_CVAR (Bool, r_drawvoxels) + +FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped) +{ + if (GetDefaultByType(ti)->hasmodel) + { + FSpriteModelFrame smf; + + memset(&smf, 0, sizeof(smf)); + smf.type=ti; + smf.sprite=sprite; + smf.frame=frame; + + int hash = SpriteModelHash[ModelFrameHash(&smf) % SpriteModelFrames.Size()]; + + while (hash>=0) + { + FSpriteModelFrame * smff = &SpriteModelFrames[hash]; + if (smff->type==ti && smff->sprite==sprite && smff->frame==frame) return smff; + hash=smff->hashnext; + } + } + + // Check for voxel replacements + if (r_drawvoxels) + { + spritedef_t *sprdef = &sprites[sprite]; + if (frame < sprdef->numframes) + { + spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + frame]; + if (sprframe->Voxel != NULL) + { + int index = sprframe->Voxel->VoxeldefIndex; + if (dropped && sprframe->Voxel->DroppedSpin !=sprframe->Voxel->PlacedSpin) index++; + return &SpriteModelFrames[index]; + } + } + } + return NULL; +} + + +//=========================================================================== +// +// gl_RenderModel +// +//=========================================================================== + +void gl_RenderFrameModels( const FSpriteModelFrame *smf, + const FState *curState, + const int curTics, + const PClass *ti, + Matrix3x4 *normaltransform, + int translation) +{ + // [BB] Frame interpolation: Find the FSpriteModelFrame smfNext which follows after smf in the animation + // and the scalar value inter ( element of [0,1) ), both necessary to determine the interpolated frame. + FSpriteModelFrame * smfNext = NULL; + double inter = 0.; + if( gl_interpolate_model_frames && !(smf->flags & MDL_NOINTERPOLATION) ) + { + FState *nextState = curState->GetNextState( ); + if( curState != nextState && nextState ) + { + // [BB] To interpolate at more than 35 fps we take tic fractions into account. + float ticFraction = 0.; + // [BB] In case the tic counter is frozen we have to leave ticFraction at zero. + if ( ConsoleState == c_up && menuactive != MENU_On && !(level.flags2 & LEVEL2_FROZEN) ) + { + float time = GetTimeFloat(); + ticFraction = (time - static_cast(time)); + } + inter = static_cast(curState->Tics - curTics - ticFraction)/static_cast(curState->Tics); + + // [BB] For some actors (e.g. ZPoisonShroom) spr->actor->tics can be bigger than curState->Tics. + // In this case inter is negative and we need to set it to zero. + if ( inter < 0. ) + inter = 0.; + else + { + // [BB] Workaround for actors that use the same frame twice in a row. + // Most of the standard Doom monsters do this in their see state. + if ( (smf->flags & MDL_INTERPOLATEDOUBLEDFRAMES) ) + { + const FState *prevState = curState - 1; + if ( (curState->sprite == prevState->sprite) && ( curState->Frame == prevState->Frame) ) + { + inter /= 2.; + inter += 0.5; + } + if ( (curState->sprite == nextState->sprite) && ( curState->Frame == nextState->Frame) ) + { + inter /= 2.; + nextState = nextState->GetNextState( ); + } + } + if ( inter != 0.0 ) + smfNext = gl_FindModelFrame(ti, nextState->sprite, nextState->Frame, false); + } + } + } + + for(int i=0; imodels[i]; + + if (mdl!=NULL) + { + mdl->BuildVertexBuffer(); + gl_RenderState.SetVertexBuffer(mdl->mVBuf); + + if ( smfNext && smf->modelframes[i] != smfNext->modelframes[i] ) + mdl->RenderFrame(smf->skins[i], smf->modelframes[i], smfNext->modelframes[i], inter, translation); + else + mdl->RenderFrame(smf->skins[i], smf->modelframes[i], smf->modelframes[i], 0.f, translation); + + gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); + } + } +} + +void gl_RenderModel(GLSprite * spr) +{ + FSpriteModelFrame * smf = spr->modelframe; + + + // Setup transformation. + glDepthFunc(GL_LEQUAL); + gl_RenderState.EnableTexture(true); + // [BB] In case the model should be rendered translucent, do back face culling. + // This solves a few of the problems caused by the lack of depth sorting. + // TO-DO: Implement proper depth sorting. + if (!( spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) + { + glEnable(GL_CULL_FACE); + glFrontFace(GL_CW); + } + + int translation = 0; + if ( !(smf->flags & MDL_IGNORETRANSLATION) ) + translation = spr->actor->Translation; + + + // y scale for a sprite means height, i.e. z in the world! + float scaleFactorX = FIXED2FLOAT(spr->actor->scaleX) * smf->xscale; + float scaleFactorY = FIXED2FLOAT(spr->actor->scaleX) * smf->yscale; + float scaleFactorZ = FIXED2FLOAT(spr->actor->scaleY) * smf->zscale; + float pitch = 0; + float roll = 0; + float rotateOffset = 0; + float angle = ANGLE_TO_FLOAT(spr->actor->angle); + + // [BB] Workaround for the missing pitch information. + if ( (smf->flags & MDL_PITCHFROMMOMENTUM) ) + { + const double x = static_cast(spr->actor->velx); + const double y = static_cast(spr->actor->vely); + const double z = static_cast(spr->actor->velz); + + // [BB] Calculate the pitch using spherical coordinates. + if(z || x || y) pitch = float(atan( z/sqrt(x*x+y*y) ) / M_PI * 180); + + // Correcting pitch if model is moving backwards + if(x || y) + { + if((x * cos(angle * M_PI / 180) + y * sin(angle * M_PI / 180)) / sqrt(x * x + y * y) < 0) pitch *= -1; + } + else pitch = fabs(pitch); + } + + if( smf->flags & MDL_ROTATING ) + { + const float time = smf->rotationSpeed*GetTimeFloat()/200.f; + rotateOffset = float((time - xs_FloorToInt(time)) *360.f ); + } + + // Added MDL_INHERITACTORPITCH and MDL_INHERITACTORROLL flags processing. + // If both flags MDL_INHERITACTORPITCH and MDL_PITCHFROMMOMENTUM are set, the pitch sums up the actor pitch and the momentum vector pitch. + // This is rather crappy way to transfer fixet_t type into angle in degrees, but its works! + if(smf->flags & MDL_INHERITACTORPITCH) pitch += float(static_cast(spr->actor->pitch >> 16) / (1 << 13) * 45 + static_cast(spr->actor->pitch & 0x0000FFFF) / (1 << 29) * 45); + if(smf->flags & MDL_INHERITACTORROLL) roll += float(static_cast(spr->actor->roll >> 16) / (1 << 13) * 45 + static_cast(spr->actor->roll & 0x0000FFFF) / (1 << 29) * 45); + + gl_RenderState.mModelMatrix.loadIdentity(); + + // Model space => World space + gl_RenderState.mModelMatrix.translate(spr->x, spr->z, spr->y ); + + // Applying model transformations: + // 1) Applying actor angle, pitch and roll to the model + gl_RenderState.mModelMatrix.rotate(-angle, 0, 1, 0); + gl_RenderState.mModelMatrix.rotate(pitch, 0, 0, 1); + gl_RenderState.mModelMatrix.rotate(-roll, 1, 0, 0); + + // 2) Applying Doomsday like rotation of the weapon pickup models + // The rotation angle is based on the elapsed time. + + if( smf->flags & MDL_ROTATING ) + { + gl_RenderState.mModelMatrix.translate(smf->rotationCenterX, smf->rotationCenterY, smf->rotationCenterZ); + gl_RenderState.mModelMatrix.rotate(rotateOffset, smf->xrotate, smf->yrotate, smf->zrotate); + gl_RenderState.mModelMatrix.translate(-smf->rotationCenterX, -smf->rotationCenterY, -smf->rotationCenterZ); + } + + // 3) Scaling model. + gl_RenderState.mModelMatrix.scale(scaleFactorX, scaleFactorZ, scaleFactorY); + + // 4) Aplying model offsets (model offsets do not depend on model scalings). + gl_RenderState.mModelMatrix.translate(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); + + // 5) Applying model rotations. + gl_RenderState.mModelMatrix.rotate(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); + gl_RenderState.mModelMatrix.rotate(smf->pitchoffset, 0, 0, 1); + gl_RenderState.mModelMatrix.rotate(-smf->rolloffset, 1, 0, 0); + + // consider the pixel stretching. For non-voxels this must be factored out here + float stretch = (smf->models[0] != NULL ? smf->models[0]->getAspectFactor() : 1.f) / glset.pixelstretch; + gl_RenderState.mModelMatrix.scale(1, stretch, 1); + + + gl_RenderState.EnableModelMatrix(true); + gl_RenderFrameModels( smf, spr->actor->state, spr->actor->tics, RUNTIME_TYPE(spr->actor), NULL, translation ); + gl_RenderState.EnableModelMatrix(false); + + glDepthFunc(GL_LESS); + if (!( spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) + glDisable(GL_CULL_FACE); +} + + +//=========================================================================== +// +// gl_RenderHUDModel +// +//=========================================================================== + +void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy) +{ + AActor * playermo=players[consoleplayer].camera; + FSpriteModelFrame *smf = gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->state->sprite, psp->state->GetFrame(), false); + + // [BB] No model found for this sprite, so we can't render anything. + if ( smf == NULL ) + return; + + glDepthFunc(GL_LEQUAL); + + // [BB] In case the model should be rendered translucent, do back face culling. + // This solves a few of the problems caused by the lack of depth sorting. + // TO-DO: Implement proper depth sorting. + if (!( playermo->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) + { + glEnable(GL_CULL_FACE); + glFrontFace(GL_CCW); + } + + // [BB] The model has to be drawn independently from the position of the player, + // so we have to reset the view matrix. + gl_RenderState.mViewMatrix.loadIdentity(); + + // Scaling model (y scale for a sprite means height, i.e. z in the world!). + gl_RenderState.mViewMatrix.scale(smf->xscale, smf->zscale, smf->yscale); + + // Aplying model offsets (model offsets do not depend on model scalings). + gl_RenderState.mViewMatrix.translate(smf->xoffset / smf->xscale, smf->zoffset / smf->zscale, smf->yoffset / smf->yscale); + + // [BB] Weapon bob, very similar to the normal Doom weapon bob. + gl_RenderState.mViewMatrix.rotate(FIXED2FLOAT(ofsx)/4, 0, 1, 0); + gl_RenderState.mViewMatrix.rotate(-FIXED2FLOAT(ofsy-WEAPONTOP)/4, 1, 0, 0); + + // [BB] For some reason the jDoom models need to be rotated. + gl_RenderState.mViewMatrix.rotate(90.f, 0, 1, 0); + + // Applying angleoffset, pitchoffset, rolloffset. + gl_RenderState.mViewMatrix.rotate(-ANGLE_TO_FLOAT(smf->angleoffset), 0, 1, 0); + gl_RenderState.mViewMatrix.rotate(smf->pitchoffset, 0, 0, 1); + gl_RenderState.mViewMatrix.rotate(-smf->rolloffset, 1, 0, 0); + gl_RenderState.ApplyMatrices(); + + gl_RenderFrameModels( smf, psp->state, psp->tics, playermo->player->ReadyWeapon->GetClass(), NULL, 0 ); + + glDepthFunc(GL_LESS); + if (!( playermo->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) + glDisable(GL_CULL_FACE); +} + +//=========================================================================== +// +// gl_IsHUDModelForPlayerAvailable +// +//=========================================================================== + +bool gl_IsHUDModelForPlayerAvailable (player_t * player) +{ + if ( (player == NULL) || (player->ReadyWeapon == NULL) || (player->psprites[0].state == NULL) ) + return false; + + FState* state = player->psprites[0].state; + FSpriteModelFrame *smf = gl_FindModelFrame(player->ReadyWeapon->GetClass(), state->sprite, state->GetFrame(), false); + return ( smf != NULL ); +} + diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h new file mode 100644 index 000000000..af7af7c0f --- /dev/null +++ b/src/gl/models/gl_models.h @@ -0,0 +1,371 @@ +#ifndef __GL_MODELS_H_ +#define __GL_MODELS_H_ + +#include "gl/utility/gl_geometric.h" +#include "gl/data/gl_vertexbuffer.h" +#include "p_pspr.h" +#include "r_data/voxels.h" + + +#define MAX_LODS 4 + +enum { VX, VZ, VY }; + +#define MD2_MAGIC 0x32504449 +#define DMD_MAGIC 0x4D444D44 +#define MD3_MAGIC 0x33504449 +#define NUMVERTEXNORMALS 162 + +FTexture * LoadSkin(const char * path, const char * fn); + + +class FModel +{ +public: + + FModel() + { + mVBuf = NULL; + } + virtual ~FModel(); + + virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0; + virtual int FindFrame(const char * name) = 0; + virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; + virtual void BuildVertexBuffer() = 0; + void DestroyVertexBuffer() + { + delete mVBuf; + mVBuf = NULL; + } + virtual float getAspectFactor() { return 1.f; } + + FModelVertexBuffer *mVBuf; + FString mFileName; +}; + +class FDMDModel : public FModel +{ +protected: + + struct FTriangle + { + unsigned short vertexIndices[3]; + unsigned short textureIndices[3]; + }; + + + struct DMDHeader + { + int magic; + int version; + int flags; + }; + + struct DMDModelVertex + { + float xyz[3]; + }; + + struct FTexCoord + { + short s, t; + }; + + struct FGLCommandVertex + { + float s, t; + int index; + }; + + struct DMDInfo + { + int skinWidth; + int skinHeight; + int frameSize; + int numSkins; + int numVertices; + int numTexCoords; + int numFrames; + int numLODs; + int offsetSkins; + int offsetTexCoords; + int offsetFrames; + int offsetLODs; + int offsetEnd; + }; + + struct ModelFrame + { + char name[16]; + unsigned int vindex; + }; + + struct ModelFrameVertexData + { + DMDModelVertex *vertices; + DMDModelVertex *normals; + }; + + struct DMDLoDInfo + { + int numTriangles; + int numGlCommands; + int offsetTriangles; + int offsetGlCommands; + }; + + struct DMDLoD + { + FTriangle * triangles; + }; + + + int mLumpNum; + DMDHeader header; + DMDInfo info; + FTexture ** skins; + ModelFrame * frames; + bool allowTexComp; // Allow texture compression with this. + + // Temp data only needed for buffer construction + FTexCoord * texCoords; + ModelFrameVertexData *framevtx; + DMDLoDInfo lodInfo[MAX_LODS]; + DMDLoD lods[MAX_LODS]; + +public: + FDMDModel() + { + mLumpNum = -1; + frames = NULL; + skins = NULL; + for (int i = 0; i < MAX_LODS; i++) + { + lods[i].triangles = NULL; + } + info.numLODs = 0; + texCoords = NULL; + framevtx = NULL; + } + virtual ~FDMDModel(); + + virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); + virtual int FindFrame(const char * name); + virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); + virtual void LoadGeometry(); + void UnloadGeometry(); + void BuildVertexBuffer(); + +}; + +// This uses the same internal representation as DMD +class FMD2Model : public FDMDModel +{ +public: + FMD2Model() {} + virtual ~FMD2Model(); + + virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); + virtual void LoadGeometry(); + +}; + + +class FMD3Model : public FModel +{ + struct MD3Tag + { + // Currently I have no use for this + }; + + struct MD3TexCoord + { + float s,t; + }; + + struct MD3Vertex + { + float x,y,z; + float nx,ny,nz; + }; + + struct MD3Triangle + { + int VertIndex[3]; + }; + + struct MD3Surface + { + int numVertices; + int numTriangles; + int numSkins; + + FTexture ** skins; + MD3Triangle * tris; + MD3TexCoord * texcoords; + MD3Vertex * vertices; + + unsigned int vindex; // contains numframes arrays of vertices + unsigned int iindex; + + MD3Surface() + { + tris=NULL; + vertices=NULL; + texcoords=NULL; + vindex = iindex = UINT_MAX; + } + + ~MD3Surface() + { + if (skins) delete [] skins; + UnloadGeometry(); + } + + void UnloadGeometry() + { + if (tris) delete [] tris; + if (vertices) delete [] vertices; + if (texcoords) delete [] texcoords; + tris = NULL; + vertices = NULL; + texcoords = NULL; + } + }; + + struct MD3Frame + { + // The bounding box information is of no use in the Doom engine + // That will still be done with the actor's size information. + char Name[16]; + float origin[3]; + }; + + int numFrames; + int numTags; + int numSurfaces; + int mLumpNum; + + MD3Frame * frames; + MD3Surface * surfaces; + +public: + FMD3Model() { } + virtual ~FMD3Model(); + + virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length); + virtual int FindFrame(const char * name); + virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); + void LoadGeometry(); + void BuildVertexBuffer(); +}; + +struct FVoxelVertexHash +{ + // Returns the hash value for a key. + hash_t Hash(const FModelVertex &key) + { + int ix = xs_RoundToInt(key.x); + int iy = xs_RoundToInt(key.y); + int iz = xs_RoundToInt(key.z); + return (hash_t)(ix + (iy<<9) + (iz<<18)); + } + + // Compares two keys, returning zero if they are the same. + int Compare(const FModelVertex &left, const FModelVertex &right) + { + return left.x != right.x || left.y != right.y || left.z != right.z || left.u != right.u || left.v != right.v; + } +}; + +struct FIndexInit +{ + void Init(unsigned int &value) + { + value = 0xffffffff; + } +}; + +typedef TMap FVoxelMap; + + +class FVoxelModel : public FModel +{ +protected: + FVoxel *mVoxel; + bool mOwningVoxel; // if created through MODELDEF deleting this object must also delete the voxel object + FTexture *mPalette; + unsigned int mNumIndices; + TArray mVertices; + TArray mIndices; + + void MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &check); + void AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int x4, int y4, int z4, BYTE color, FVoxelMap &check); + unsigned int AddVertex(FModelVertex &vert, FVoxelMap &check); + +public: + FVoxelModel(FVoxel *voxel, bool owned); + ~FVoxelModel(); + bool Load(const char * fn, int lumpnum, const char * buffer, int length); + void Initialize(); + virtual int FindFrame(const char * name); + virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); + FTexture *GetPaletteTexture() const { return mPalette; } + void BuildVertexBuffer(); + float getAspectFactor(); +}; + + + +#define MAX_MODELS_PER_FRAME 4 + +// +// [BB] Model rendering flags. +// +enum +{ + // [BB] Color translations for the model skin are ignored. This is + // useful if the skin texture is not using the game palette. + MDL_IGNORETRANSLATION = 1, + MDL_PITCHFROMMOMENTUM = 2, + MDL_ROTATING = 4, + MDL_INTERPOLATEDOUBLEDFRAMES = 8, + MDL_NOINTERPOLATION = 16, + MDL_INHERITACTORPITCH = 32, + MDL_INHERITACTORROLL = 64, // useless for now +}; + +struct FSpriteModelFrame +{ + FModel * models[MAX_MODELS_PER_FRAME]; + FTexture * skins[MAX_MODELS_PER_FRAME]; + int modelframes[MAX_MODELS_PER_FRAME]; + float xscale, yscale, zscale; + // [BB] Added zoffset, rotation parameters and flags. + // Added xoffset, yoffset + float xoffset, yoffset, zoffset; + float xrotate, yrotate, zrotate; + float rotationCenterX, rotationCenterY, rotationCenterZ; + float rotationSpeed; + unsigned int flags; + const PClass * type; + short sprite; + short frame; + FState * state; // for later! + int hashnext; + angle_t angleoffset; + // added pithoffset, rolloffset. + float pitchoffset, rolloffset; // I don't want to bother with type transformations, so I made this variables float. +}; + +class GLSprite; + +FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped); + +void gl_RenderModel(GLSprite * spr); +// [BB] HUD weapon model rendering functions. +void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy); +bool gl_IsHUDModelForPlayerAvailable (player_t * player); + +#endif diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp new file mode 100644 index 000000000..c40e20d90 --- /dev/null +++ b/src/gl/models/gl_models_md2.cpp @@ -0,0 +1,554 @@ +/* +** gl_models.cpp +** +** MD2/DMD model format code +** +**--------------------------------------------------------------------------- +** Copyright 2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** 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 "gl/system/gl_system.h" +#include "w_wad.h" +#include "cmdlib.h" +#include "sc_man.h" +#include "m_crc32.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/models/gl_models.h" +#include "gl/textures/gl_material.h" +#include "gl/shaders/gl_shader.h" +#include "gl/data/gl_vertexbuffer.h" + +static float avertexnormals[NUMVERTEXNORMALS][3] = { +#include "tab_anorms.h" +}; + +//=========================================================================== +// +// UnpackVector +// Packed: pppppppy yyyyyyyy. Yaw is on the XY plane. +// +//=========================================================================== + +static void UnpackVector(unsigned short packed, float vec[3]) +{ + float yaw = (packed & 511) / 512.0f * 2 * PI; + float pitch = ((packed >> 9) / 127.0f - 0.5f) * PI; + float cosp = (float) cos(pitch); + + vec[VX] = (float) cos(yaw) * cosp; + vec[VY] = (float) sin(yaw) * cosp; + vec[VZ] = (float) sin(pitch); +} + + +//=========================================================================== +// +// DMD file structure +// +//=========================================================================== + +struct dmd_chunk_t +{ + int type; + int length; // Next chunk follows... +}; + +#pragma pack(1) +struct dmd_packedVertex_t +{ + byte vertex[3]; + unsigned short normal; // Yaw and pitch. +}; + +struct dmd_packedFrame_t +{ + float scale[3]; + float translate[3]; + char name[16]; + dmd_packedVertex_t vertices[1]; +}; +#pragma pack() + +// Chunk types. +enum +{ + DMC_END, // Must be the last chunk. + DMC_INFO // Required; will be expected to exist. +}; + +//=========================================================================== +// +// FDMDModel::Load +// +//=========================================================================== + +bool FDMDModel::Load(const char * path, int lumpnum, const char * buffer, int length) +{ + dmd_chunk_t * chunk = (dmd_chunk_t*)(buffer + 12); + char *temp; + ModelFrame *frame; + int i; + + int fileoffset = 12 + sizeof(dmd_chunk_t); + + chunk->type = LittleLong(chunk->type); + while (chunk->type != DMC_END) + { + switch (chunk->type) + { + case DMC_INFO: // Standard DMD information chunk. + memcpy(&info, buffer + fileoffset, LittleLong(chunk->length)); + info.skinWidth = LittleLong(info.skinWidth); + info.skinHeight = LittleLong(info.skinHeight); + info.frameSize = LittleLong(info.frameSize); + info.numSkins = LittleLong(info.numSkins); + info.numVertices = LittleLong(info.numVertices); + info.numTexCoords = LittleLong(info.numTexCoords); + info.numFrames = LittleLong(info.numFrames); + info.numLODs = LittleLong(info.numLODs); + info.offsetSkins = LittleLong(info.offsetSkins); + info.offsetTexCoords = LittleLong(info.offsetTexCoords); + info.offsetFrames = LittleLong(info.offsetFrames); + info.offsetLODs = LittleLong(info.offsetLODs); + info.offsetEnd = LittleLong(info.offsetEnd); + fileoffset += chunk->length; + break; + + default: + // Just skip all unknown chunks. + fileoffset += chunk->length; + break; + } + // Read the next chunk header. + chunk = (dmd_chunk_t*)(buffer + fileoffset); + chunk->type = LittleLong(chunk->type); + fileoffset += sizeof(dmd_chunk_t); + } + + // Allocate and load in the data. + skins = new FTexture *[info.numSkins]; + + for (i = 0; i < info.numSkins; i++) + { + skins[i] = LoadSkin(path, buffer + info.offsetSkins + i * 64); + } + temp = (char*)buffer + info.offsetFrames; + frames = new ModelFrame[info.numFrames]; + + for (i = 0, frame = frames; i < info.numFrames; i++, frame++) + { + dmd_packedFrame_t *pfr = (dmd_packedFrame_t *)(temp + info.frameSize * i); + + memcpy(frame->name, pfr->name, sizeof(pfr->name)); + frame->vindex = UINT_MAX; + } + mLumpNum = lumpnum; + return true; +} + +//=========================================================================== +// +// FDMDModel::LoadGeometry +// +//=========================================================================== + +void FDMDModel::LoadGeometry() +{ + static int axis[3] = { VX, VY, VZ }; + FMemLump lumpdata = Wads.ReadLump(mLumpNum); + const char *buffer = (const char *)lumpdata.GetMem(); + texCoords = new FTexCoord[info.numTexCoords]; + memcpy(texCoords, buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); + + const char *temp = buffer + info.offsetFrames; + framevtx= new ModelFrameVertexData[info.numFrames]; + + ModelFrameVertexData *framev; + int i, k, c; + for(i = 0, framev = framevtx; i < info.numFrames; i++, framev++) + { + dmd_packedFrame_t *pfr = (dmd_packedFrame_t *) (temp + info.frameSize * i); + dmd_packedVertex_t *pVtx; + + framev->vertices = new DMDModelVertex[info.numVertices]; + framev->normals = new DMDModelVertex[info.numVertices]; + + // Translate each vertex. + for(k = 0, pVtx = pfr->vertices; k < info.numVertices; k++, pVtx++) + { + UnpackVector((unsigned short)(pVtx->normal), framev->normals[k].xyz); + for(c = 0; c < 3; c++) + { + framev->vertices[k].xyz[axis[c]] = + (pVtx->vertex[c] * FLOAT(pfr->scale[c]) + FLOAT(pfr->translate[c])); + } + } + } + + memcpy(lodInfo, buffer+info.offsetLODs, info.numLODs * sizeof(DMDLoDInfo)); + for(i = 0; i < info.numLODs; i++) + { + lodInfo[i].numTriangles = LittleLong(lodInfo[i].numTriangles); + lodInfo[i].offsetTriangles = LittleLong(lodInfo[i].offsetTriangles); + if (lodInfo[i].numTriangles > 0) + { + lods[i].triangles = new FTriangle[lodInfo[i].numTriangles]; + memcpy(lods[i].triangles, buffer + lodInfo[i].offsetTriangles, lodInfo[i].numTriangles * sizeof(FTriangle)); + for (int j = 0; j < lodInfo[i].numTriangles; j++) + { + for (int k = 0; k < 3; k++) + { + lods[i].triangles[j].textureIndices[k] = LittleShort(lods[i].triangles[j].textureIndices[k]); + lods[i].triangles[j].vertexIndices[k] = LittleShort(lods[i].triangles[j].vertexIndices[k]); + } + } + } + } + +} + +//=========================================================================== +// +// Deletes everything that's no longer needed after building the vertex buffer +// +//=========================================================================== + +void FDMDModel::UnloadGeometry() +{ + int i; + + if (framevtx != NULL) + { + for (i=0;iLockVertexBuffer(VertexBufferSize); + + for (int i = 0; i < info.numFrames; i++) + { + DMDModelVertex *vert = framevtx[i].vertices; + DMDModelVertex *norm = framevtx[i].normals; + + frames[i].vindex = vindex; + + FTriangle *tri = lods[0].triangles; + + for (int i = 0; i < lodInfo[0].numTriangles; i++) + { + for (int j = 0; j < 3; j++) + { + + int ti = tri->textureIndices[j]; + int vi = tri->vertexIndices[j]; + + FModelVertex *bvert = &vertptr[vindex++]; + bvert->Set(vert[vi].xyz[0], vert[vi].xyz[1], vert[vi].xyz[2], (float)texCoords[ti].s / info.skinWidth, (float)texCoords[ti].t / info.skinHeight); + bvert->SetNormal(norm[vi].xyz[0], norm[vi].xyz[1], norm[vi].xyz[2]); + } + tri++; + } + } + mVBuf->UnlockVertexBuffer(); + UnloadGeometry(); + } +} + + + +//=========================================================================== +// +// FDMDModel::FindFrame +// +//=========================================================================== +int FDMDModel::FindFrame(const char * name) +{ + for (int i=0;i= info.numFrames || frameno2 >= info.numFrames) return; + + if (!skin) + { + if (info.numSkins == 0) return; + skin = skins[0]; + if (!skin) return; + } + + FMaterial * tex = FMaterial::ValidateTexture(skin, false); + + gl_RenderState.SetMaterial(tex, CLAMP_NONE, translation, -1, false); + gl_RenderState.SetInterpolationFactor((float)inter); + + gl_RenderState.Apply(); + mVBuf->SetupFrame(frames[frameno].vindex, frames[frameno2].vindex); + glDrawArrays(GL_TRIANGLES, 0, lodInfo[0].numTriangles * 3); + gl_RenderState.SetInterpolationFactor(0.f); +} + + + +//=========================================================================== +// +// Internal data structures of MD2 files - only used during loading +// +//=========================================================================== + +struct md2_header_t +{ + int magic; + int version; + int skinWidth; + int skinHeight; + int frameSize; + int numSkins; + int numVertices; + int numTexCoords; + int numTriangles; + int numGlCommands; + int numFrames; + int offsetSkins; + int offsetTexCoords; + int offsetTriangles; + int offsetFrames; + int offsetGlCommands; + int offsetEnd; +}; + +struct md2_triangleVertex_t +{ + byte vertex[3]; + byte lightNormalIndex; +}; + +struct md2_packedFrame_t +{ + float scale[3]; + float translate[3]; + char name[16]; + md2_triangleVertex_t vertices[1]; +}; + +//=========================================================================== +// +// FMD2Model::Load +// +//=========================================================================== + +bool FMD2Model::Load(const char * path, int lumpnum, const char * buffer, int length) +{ + md2_header_t * md2header = (md2_header_t *)buffer; + ModelFrame *frame; + byte *md2_frames; + int i; + + // Convert it to DMD. + header.magic = MD2_MAGIC; + header.version = 8; + header.flags = 0; + info.skinWidth = LittleLong(md2header->skinWidth); + info.skinHeight = LittleLong(md2header->skinHeight); + info.frameSize = LittleLong(md2header->frameSize); + info.numLODs = 1; + info.numSkins = LittleLong(md2header->numSkins); + info.numTexCoords = LittleLong(md2header->numTexCoords); + info.numVertices = LittleLong(md2header->numVertices); + info.numFrames = LittleLong(md2header->numFrames); + info.offsetSkins = LittleLong(md2header->offsetSkins); + info.offsetTexCoords = LittleLong(md2header->offsetTexCoords); + info.offsetFrames = LittleLong(md2header->offsetFrames); + info.offsetLODs = LittleLong(md2header->offsetEnd); // Doesn't exist. + lodInfo[0].numTriangles = LittleLong(md2header->numTriangles); + lodInfo[0].numGlCommands = LittleLong(md2header->numGlCommands); + lodInfo[0].offsetTriangles = LittleLong(md2header->offsetTriangles); + lodInfo[0].offsetGlCommands = LittleLong(md2header->offsetGlCommands); + info.offsetEnd = LittleLong(md2header->offsetEnd); + + if (info.offsetFrames + info.frameSize * info.numFrames > length) + { + Printf("LoadModel: Model '%s' file too short\n", path); + return false; + } + if (lodInfo[0].numGlCommands <= 0) + { + Printf("LoadModel: Model '%s' invalid NumGLCommands\n", path); + return false; + } + + skins = new FTexture *[info.numSkins]; + + for (i = 0; i < info.numSkins; i++) + { + skins[i] = LoadSkin(path, buffer + info.offsetSkins + i * 64); + } + + // The frames need to be unpacked. + md2_frames = (byte*)buffer + info.offsetFrames; + frames = new ModelFrame[info.numFrames]; + + for (i = 0, frame = frames; i < info.numFrames; i++, frame++) + { + md2_packedFrame_t *pfr = (md2_packedFrame_t *)(md2_frames + info.frameSize * i); + + memcpy(frame->name, pfr->name, sizeof(pfr->name)); + frame->vindex = UINT_MAX; + } + mLumpNum = lumpnum; + return true; +} + +//=========================================================================== +// +// FMD2Model::LoadGeometry +// +//=========================================================================== + +void FMD2Model::LoadGeometry() +{ + static int axis[3] = { VX, VY, VZ }; + byte *md2_frames; + FMemLump lumpdata = Wads.ReadLump(mLumpNum); + const char *buffer = (const char *)lumpdata.GetMem(); + + texCoords = new FTexCoord[info.numTexCoords]; + memcpy(texCoords, (byte*)buffer + info.offsetTexCoords, info.numTexCoords * sizeof(FTexCoord)); + + md2_frames = (byte*)buffer + info.offsetFrames; + framevtx = new ModelFrameVertexData[info.numFrames]; + ModelFrameVertexData *framev; + int i, k, c; + + for(i = 0, framev = framevtx; i < info.numFrames; i++, framev++) + { + md2_packedFrame_t *pfr = (md2_packedFrame_t *) (md2_frames + info.frameSize * i); + md2_triangleVertex_t *pVtx; + + framev->vertices = new DMDModelVertex[info.numVertices]; + framev->normals = new DMDModelVertex[info.numVertices]; + + // Translate each vertex. + for(k = 0, pVtx = pfr->vertices; k < info.numVertices; k++, pVtx++) + { + memcpy(framev->normals[k].xyz, + avertexnormals[pVtx->lightNormalIndex], sizeof(float) * 3); + + for(c = 0; c < 3; c++) + { + framev->vertices[k].xyz[axis[c]] = + (pVtx->vertex[c] * pfr->scale[c] + pfr->translate[c]); + } + } + } + + lods[0].triangles = new FTriangle[lodInfo[0].numTriangles]; + + int cnt = lodInfo[0].numTriangles; + memcpy(lods[0].triangles, buffer + lodInfo[0].offsetTriangles, sizeof(FTriangle) * cnt); + for (int j = 0; j < cnt; j++) + { + for (int k = 0; k < 3; k++) + { + lods[0].triangles[j].textureIndices[k] = LittleShort(lods[0].triangles[j].textureIndices[k]); + lods[0].triangles[j].vertexIndices[k] = LittleShort(lods[0].triangles[j].vertexIndices[k]); + } + } +} + +FMD2Model::~FMD2Model() +{ +} + diff --git a/src/gl/models/gl_models_md3.cpp b/src/gl/models/gl_models_md3.cpp new file mode 100644 index 000000000..13f02bc0a --- /dev/null +++ b/src/gl/models/gl_models_md3.cpp @@ -0,0 +1,375 @@ +/* +** gl_models_md3.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2006 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** 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 "gl/system/gl_system.h" +#include "w_wad.h" +#include "cmdlib.h" +#include "sc_man.h" +#include "m_crc32.h" + +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/models/gl_models.h" +#include "gl/textures/gl_material.h" +#include "gl/shaders/gl_shader.h" + +#define MAX_QPATH 64 + +//=========================================================================== +// +// decode the lat/lng normal to a 3 float normal +// +//=========================================================================== + +static void UnpackVector(unsigned short packed, float & nx, float & ny, float & nz) +{ + double lat = ( packed >> 8 ) & 0xff; + double lng = ( packed & 0xff ); + lat *= PI/128; + lng *= PI/128; + + nx = cos(lat) * sin(lng); + ny = sin(lat) * sin(lng); + nz = cos(lng); +} + +//=========================================================================== +// +// MD3 File structure +// +//=========================================================================== + +#pragma pack(4) +struct md3_header_t +{ + DWORD Magic; + DWORD Version; + char Name[MAX_QPATH]; + DWORD Flags; + DWORD Num_Frames; + DWORD Num_Tags; + DWORD Num_Surfaces; + DWORD Num_Skins; + DWORD Ofs_Frames; + DWORD Ofs_Tags; + DWORD Ofs_Surfaces; + DWORD Ofs_Eof; +}; + +struct md3_surface_t +{ + DWORD Magic; + char Name[MAX_QPATH]; + DWORD Flags; + DWORD Num_Frames; + DWORD Num_Shaders; + DWORD Num_Verts; + DWORD Num_Triangles; + DWORD Ofs_Triangles; + DWORD Ofs_Shaders; + DWORD Ofs_Texcoord; + DWORD Ofs_XYZNormal; + DWORD Ofs_End; +}; + +struct md3_triangle_t +{ + DWORD vt_index[3]; +}; + +struct md3_shader_t +{ + char Name[MAX_QPATH]; + DWORD index; +}; + +struct md3_texcoord_t +{ + float s, t; +}; + +struct md3_vertex_t +{ + short x, y, z, n; +}; + +struct md3_frame_t +{ + float min_Bounds[3]; + float max_Bounds[3]; + float localorigin[3]; + float radius; + char Name[16]; +}; +#pragma pack() + + +//=========================================================================== +// +// +// +//=========================================================================== + +bool FMD3Model::Load(const char * path, int lumpnum, const char * buffer, int length) +{ + md3_header_t * hdr = (md3_header_t *)buffer; + + numFrames = LittleLong(hdr->Num_Frames); + numTags = LittleLong(hdr->Num_Tags); + numSurfaces = LittleLong(hdr->Num_Surfaces); + + md3_frame_t * frm = (md3_frame_t*)(buffer + LittleLong(hdr->Ofs_Frames)); + + frames = new MD3Frame[numFrames]; + for (int i = 0; i < numFrames; i++) + { + strncpy(frames[i].Name, frm[i].Name, 16); + for (int j = 0; j < 3; j++) frames[i].origin[j] = frm[i].localorigin[j]; + } + + md3_surface_t * surf = (md3_surface_t*)(buffer + LittleLong(hdr->Ofs_Surfaces)); + + surfaces = new MD3Surface[numSurfaces]; + + for (int i = 0; i < numSurfaces; i++) + { + MD3Surface * s = &surfaces[i]; + md3_surface_t * ss = surf; + + surf = (md3_surface_t *)(((char*)surf) + LittleLong(surf->Ofs_End)); + + s->numSkins = LittleLong(ss->Num_Shaders); + s->numTriangles = LittleLong(ss->Num_Triangles); + s->numVertices = LittleLong(ss->Num_Verts); + + // copy shaders (skins) + md3_shader_t * shader = (md3_shader_t*)(((char*)ss) + LittleLong(ss->Ofs_Shaders)); + s->skins = new FTexture *[s->numSkins]; + + for (int i = 0; i < s->numSkins; i++) + { + // [BB] According to the MD3 spec, Name is supposed to include the full path. + s->skins[i] = LoadSkin("", shader[i].Name); + // [BB] Fall back and check if Name is relative. + if (s->skins[i] == NULL) + s->skins[i] = LoadSkin(path, shader[i].Name); + } + } + mLumpNum = lumpnum; + return true; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FMD3Model::LoadGeometry() +{ + FMemLump lumpdata = Wads.ReadLump(mLumpNum); + const char *buffer = (const char *)lumpdata.GetMem(); + md3_header_t * hdr = (md3_header_t *)buffer; + md3_surface_t * surf = (md3_surface_t*)(buffer + LittleLong(hdr->Ofs_Surfaces)); + + for(int i=0;iOfs_End)); + + // copy triangle indices + md3_triangle_t * tris = (md3_triangle_t*)(((char*)ss)+LittleLong(ss->Ofs_Triangles)); + s->tris = new MD3Triangle[s->numTriangles]; + + for(int i=0;inumTriangles;i++) for (int j=0;j<3;j++) + { + s->tris[i].VertIndex[j]=LittleLong(tris[i].vt_index[j]); + } + + // Load texture coordinates + md3_texcoord_t * tc = (md3_texcoord_t*)(((char*)ss)+LittleLong(ss->Ofs_Texcoord)); + s->texcoords = new MD3TexCoord[s->numVertices]; + + for(int i=0;inumVertices;i++) + { + s->texcoords[i].s = tc[i].s; + s->texcoords[i].t = tc[i].t; + } + + // Load vertices and texture coordinates + md3_vertex_t * vt = (md3_vertex_t*)(((char*)ss)+LittleLong(ss->Ofs_XYZNormal)); + s->vertices = new MD3Vertex[s->numVertices * numFrames]; + + for(int i=0;inumVertices * numFrames;i++) + { + s->vertices[i].x = LittleShort(vt[i].x)/64.f; + s->vertices[i].y = LittleShort(vt[i].y)/64.f; + s->vertices[i].z = LittleShort(vt[i].z)/64.f; + UnpackVector( LittleShort(vt[i].n), s->vertices[i].nx, s->vertices[i].ny, s->vertices[i].nz); + } + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FMD3Model::BuildVertexBuffer() +{ + if (mVBuf == NULL) + { + LoadGeometry(); + + unsigned int vbufsize = 0; + unsigned int ibufsize = 0; + + for (int i = 0; i < numSurfaces; i++) + { + MD3Surface * surf = &surfaces[i]; + vbufsize += numFrames * surf->numVertices; + ibufsize += 3 * surf->numTriangles; + } + + mVBuf = new FModelVertexBuffer(true); + FModelVertex *vertptr = mVBuf->LockVertexBuffer(vbufsize); + unsigned int *indxptr = mVBuf->LockIndexBuffer(ibufsize); + + assert(vertptr != NULL && indxptr != NULL); + + unsigned int vindex = 0, iindex = 0; + + for (int i = 0; i < numSurfaces; i++) + { + MD3Surface * surf = &surfaces[i]; + + surf->vindex = vindex; + surf->iindex = iindex; + for (int j = 0; j < numFrames * surf->numVertices; j++) + { + MD3Vertex* vert = surf->vertices + j; + + FModelVertex *bvert = &vertptr[vindex++]; + + int tc = j % surf->numVertices; + bvert->Set(vert->x, vert->z, vert->y, surf->texcoords[tc].s, surf->texcoords[tc].t); + bvert->SetNormal(vert->nx, vert->nz, vert->ny); + } + + for (int k = 0; k < surf->numTriangles; k++) + { + for (int l = 0; l < 3; l++) + { + indxptr[iindex++] = surf->tris[k].VertIndex[l]; + } + } + surf->UnloadGeometry(); + } + mVBuf->UnlockVertexBuffer(); + mVBuf->UnlockIndexBuffer(); + } +} + + +//=========================================================================== +// +// +// +//=========================================================================== + +int FMD3Model::FindFrame(const char * name) +{ + for (int i=0;i=numFrames || frameno2>=numFrames) return; + + gl_RenderState.SetInterpolationFactor((float)inter); + for(int i=0;inumSkins==0) return; + surfaceSkin = surf->skins[0]; + if (!surfaceSkin) return; + } + + FMaterial * tex = FMaterial::ValidateTexture(surfaceSkin, false); + + gl_RenderState.SetMaterial(tex, CLAMP_NONE, translation, -1, false); + + gl_RenderState.Apply(); + mVBuf->SetupFrame(surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices); + glDrawElements(GL_TRIANGLES, surf->numTriangles * 3, GL_UNSIGNED_INT, (void*)(intptr_t)(surf->iindex * sizeof(unsigned int))); + } + gl_RenderState.SetInterpolationFactor(0.f); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FMD3Model::~FMD3Model() +{ + if (frames) delete [] frames; + if (surfaces) delete [] surfaces; + frames = NULL; + surfaces = NULL; +} diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp new file mode 100644 index 000000000..c092f9dd7 --- /dev/null +++ b/src/gl/models/gl_voxels.cpp @@ -0,0 +1,449 @@ +/* +** gl_voxels.cpp +** +** Voxel management +** +**--------------------------------------------------------------------------- +** Copyright 2010 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** 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 "gl/system/gl_system.h" +#include "w_wad.h" +#include "cmdlib.h" +#include "sc_man.h" +#include "m_crc32.h" +#include "c_console.h" +#include "g_game.h" +#include "doomstat.h" +#include "g_level.h" +#include "colormatcher.h" +#include "textures/bitmap.h" +//#include "gl/gl_intern.h" + +#include "gl/system/gl_interface.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/models/gl_models.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_geometric.h" +#include "gl/utility/gl_convert.h" +#include "gl/renderer/gl_renderstate.h" + + +//=========================================================================== +// +// Creates a 16x16 texture from the palette so that we can +// use the existing palette manipulation code to render the voxel +// Otherwise all shaders had to be duplicated and the non-shader code +// would be a lot less efficient. +// +//=========================================================================== + +class FVoxelTexture : public FTexture +{ +public: + + FVoxelTexture(FVoxel *voxel); + ~FVoxelTexture(); + const BYTE *GetColumn (unsigned int column, const Span **spans_out); + const BYTE *GetPixels (); + void Unload (); + + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf); + bool UseBasePalette() { return false; } + +protected: + FVoxel *SourceVox; + BYTE *Pixels; + +}; + +//=========================================================================== +// +// +// +//=========================================================================== + +FVoxelTexture::FVoxelTexture(FVoxel *vox) +{ + SourceVox = vox; + Width = 16; + Height = 16; + WidthBits = 4; + HeightBits = 4; + WidthMask = 15; + Pixels = NULL; + gl_info.bNoFilter = true; + gl_info.bNoCompress = true; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FVoxelTexture::~FVoxelTexture() +{ +} + +const BYTE *FVoxelTexture::GetColumn (unsigned int column, const Span **spans_out) +{ + // not needed + return NULL; +} + +const BYTE *FVoxelTexture::GetPixels () +{ + // GetPixels gets called when a translated palette is used so we still need to implement it here. + if (Pixels == NULL) + { + Pixels = new BYTE[256]; + + BYTE *pp = SourceVox->Palette; + + if(pp != NULL) + { + for(int i=0;i<256;i++, pp+=3) + { + PalEntry pe; + pe.r = (pp[0] << 2) | (pp[0] >> 4); + pe.g = (pp[1] << 2) | (pp[1] >> 4); + pe.b = (pp[2] << 2) | (pp[2] >> 4); + Pixels[i] = ColorMatcher.Pick(pe); + } + } + else + { + for(int i=0;i<256;i++, pp+=3) + { + Pixels[i] = (BYTE)i; + } + } + } + return Pixels; +} + +void FVoxelTexture::Unload () +{ + if (Pixels != NULL) + { + delete[] Pixels; + Pixels = NULL; + } +} + +//=========================================================================== +// +// FVoxelTexture::CopyTrueColorPixels +// +// This creates a dummy 16x16 paletted bitmap and converts that using the +// voxel palette +// +//=========================================================================== + +int FVoxelTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +{ + PalEntry pe[256]; + BYTE bitmap[256]; + BYTE *pp = SourceVox->Palette; + + if(pp != NULL) + { + for(int i=0;i<256;i++, pp+=3) + { + bitmap[i] = (BYTE)i; + pe[i].r = (pp[0] << 2) | (pp[0] >> 4); + pe[i].g = (pp[1] << 2) | (pp[1] >> 4); + pe[i].b = (pp[2] << 2) | (pp[2] >> 4); + pe[i].a = 255; + } + } + else + { + for(int i=0;i<256;i++, pp+=3) + { + bitmap[i] = (BYTE)i; + pe[i] = GPalette.BaseColors[i]; + pe[i].a = 255; + } + } + bmp->CopyPixelData(x, y, bitmap, Width, Height, 1, 16, rotate, pe, inf); + return 0; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned) +{ + mVoxel = voxel; + mOwningVoxel = owned; + mPalette = new FVoxelTexture(voxel); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FVoxelModel::~FVoxelModel() +{ + delete mPalette; + if (mOwningVoxel) delete mVoxel; +} + + +//=========================================================================== +// +// +// +//=========================================================================== + +unsigned int FVoxelModel::AddVertex(FModelVertex &vert, FVoxelMap &check) +{ + unsigned int index = check[vert]; + if (index == 0xffffffff) + { + index = check[vert] =mVertices.Push(vert); + } + return index; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3, int y3, int z3, int x4, int y4, int z4, BYTE col, FVoxelMap &check) +{ + float PivotX = mVoxel->Mips[0].PivotX / 256.f; + float PivotY = mVoxel->Mips[0].PivotY / 256.f; + float PivotZ = mVoxel->Mips[0].PivotZ / 256.f; + int h = mVoxel->Mips[0].SizeZ; + FModelVertex vert; + unsigned int indx[4]; + + vert.u = (((col & 15) * 255 / 16) + 7) / 255.f; + vert.v = (((col / 16) * 255 / 16) + 7) / 255.f; + + vert.x = x1 - PivotX; + vert.z = -y1 + PivotY; + vert.y = -z1 + PivotZ; + indx[0] = AddVertex(vert, check); + + vert.x = x2 - PivotX; + vert.z = -y2 + PivotY; + vert.y = -z2 + PivotZ; + indx[1] = AddVertex(vert, check); + + vert.x = x4 - PivotX; + vert.z = -y4 + PivotY; + vert.y = -z4 + PivotZ; + indx[2] = AddVertex(vert, check); + + vert.x = x3 - PivotX; + vert.z = -y3 + PivotY; + vert.y = -z3 + PivotZ; + indx[3] = AddVertex(vert, check); + + mIndices.Push(indx[0]); + mIndices.Push(indx[1]); + mIndices.Push(indx[3]); + mIndices.Push(indx[1]); + mIndices.Push(indx[3]); + mIndices.Push(indx[2]); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &check) +{ + const BYTE *col = voxptr->col; + int zleng = voxptr->zleng; + int ztop = voxptr->ztop; + int cull = voxptr->backfacecull; + + if (cull & 16) + { + AddFace(x, y, ztop, x+1, y, ztop, x, y+1, ztop, x+1, y+1, ztop, *col, check); + } + int z = ztop; + while (z < ztop+zleng) + { + int c = 0; + while (z+c < ztop+zleng && col[c] == col[0]) c++; + + if (cull & 1) + { + AddFace(x, y, z, x, y+1, z, x, y, z+c, x, y+1, z+c, *col, check); + } + if (cull & 2) + { + AddFace(x+1, y+1, z, x+1, y, z, x+1, y+1, z+c, x+1, y, z+c, *col, check); + } + if (cull & 4) + { + AddFace(x, y, z, x+1, y, z, x, y, z+c, x+1, y, z+c, *col, check); + } + if (cull & 8) + { + AddFace(x+1, y+1, z, x, y+1, z, x+1, y+1, z+c, x, y+1, z+c, *col, check); + } + z+=c; + col+=c; + } + if (cull & 32) + { + int z = ztop+zleng-1; + AddFace(x+1, y, z+1, x, y, z+1, x+1, y+1, z+1, x, y+1, z+1, voxptr->col[zleng-1], check); + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::Initialize() +{ + FVoxelMap check; + FVoxelMipLevel *mip = &mVoxel->Mips[0]; + for (int x = 0; x < mip->SizeX; x++) + { + BYTE *slabxoffs = &mip->SlabData[mip->OffsetX[x]]; + short *xyoffs = &mip->OffsetXY[x * (mip->SizeY + 1)]; + for (int y = 0; y < mip->SizeY; y++) + { + kvxslab_t *voxptr = (kvxslab_t *)(slabxoffs + xyoffs[y]); + kvxslab_t *voxend = (kvxslab_t *)(slabxoffs + xyoffs[y+1]); + for (; voxptr < voxend; voxptr = (kvxslab_t *)((BYTE *)voxptr + voxptr->zleng + 3)) + { + MakeSlabPolys(x, y, voxptr, check); + } + } + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FVoxelModel::BuildVertexBuffer() +{ + if (mVBuf == NULL) + { + Initialize(); + + mVBuf = new FModelVertexBuffer(true); + FModelVertex *vertptr = mVBuf->LockVertexBuffer(mVertices.Size()); + unsigned int *indxptr = mVBuf->LockIndexBuffer(mIndices.Size()); + + memcpy(vertptr, &mVertices[0], sizeof(FModelVertex)* mVertices.Size()); + memcpy(indxptr, &mIndices[0], sizeof(unsigned int)* mIndices.Size()); + + mVBuf->UnlockVertexBuffer(); + mVBuf->UnlockIndexBuffer(); + mNumIndices = mIndices.Size(); + + // delete our temporary buffers + mVertices.Clear(); + mIndices.Clear(); + mVertices.ShrinkToFit(); + mIndices.ShrinkToFit(); + } +} + + +//=========================================================================== +// +// +// +//=========================================================================== + +bool FVoxelModel::Load(const char * fn, int lumpnum, const char * buffer, int length) +{ + return false; // not needed +} + +//=========================================================================== +// +// Voxels don't have frames so always return 0 +// +//=========================================================================== + +int FVoxelModel::FindFrame(const char * name) +{ + return 0; +} + +//=========================================================================== +// +// Voxels need aspect ratio correction according to the current map's setting +// +//=========================================================================== + +float FVoxelModel::getAspectFactor() +{ + return glset.pixelstretch; +} + +//=========================================================================== +// +// Voxels never interpolate between frames, they only have one. +// +//=========================================================================== + +void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation) +{ + FMaterial * tex = FMaterial::ValidateTexture(skin, false); + gl_RenderState.SetMaterial(tex, CLAMP_NOFILTER, translation, -1, false); + + gl_RenderState.Apply(); + mVBuf->SetupFrame(0, 0); + glDrawElements(GL_TRIANGLES, mNumIndices, GL_UNSIGNED_INT, (void*)(intptr_t)0); +} + diff --git a/src/gl/models/tab_anorms.h b/src/gl/models/tab_anorms.h new file mode 100644 index 000000000..46467b460 --- /dev/null +++ b/src/gl/models/tab_anorms.h @@ -0,0 +1,489 @@ +#ifdef WIN32 +#pragma warning(disable:4305) +#endif + +{ +-0.525731, 0.000000, 0.850651}, + +{ +-0.442863, 0.238856, 0.864188}, + +{ +-0.295242, 0.000000, 0.955423}, + +{ +-0.309017, 0.500000, 0.809017}, + +{ +-0.162460, 0.262866, 0.951056}, + +{ +0.000000, 0.000000, 1.000000}, + +{ +0.000000, 0.850651, 0.525731}, + +{ +-0.147621, 0.716567, 0.681718}, + +{ +0.147621, 0.716567, 0.681718}, + +{ +0.000000, 0.525731, 0.850651}, + +{ +0.309017, 0.500000, 0.809017}, + +{ +0.525731, 0.000000, 0.850651}, + +{ +0.295242, 0.000000, 0.955423}, + +{ +0.442863, 0.238856, 0.864188}, + +{ +0.162460, 0.262866, 0.951056}, + +{ +-0.681718, 0.147621, 0.716567}, + +{ +-0.809017, 0.309017, 0.500000}, + +{ +-0.587785, 0.425325, 0.688191}, + +{ +-0.850651, 0.525731, 0.000000}, + +{ +-0.864188, 0.442863, 0.238856}, + +{ +-0.716567, 0.681718, 0.147621}, + +{ +-0.688191, 0.587785, 0.425325}, + +{ +-0.500000, 0.809017, 0.309017}, + +{ +-0.238856, 0.864188, 0.442863}, + +{ +-0.425325, 0.688191, 0.587785}, + +{ +-0.716567, 0.681718, -0.147621}, + +{ +-0.500000, 0.809017, -0.309017}, + +{ +-0.525731, 0.850651, 0.000000}, + +{ +0.000000, 0.850651, -0.525731}, + +{ +-0.238856, 0.864188, -0.442863}, + +{ +0.000000, 0.955423, -0.295242}, + +{ +-0.262866, 0.951056, -0.162460}, + +{ +0.000000, 1.000000, 0.000000}, + +{ +0.000000, 0.955423, 0.295242}, + +{ +-0.262866, 0.951056, 0.162460}, + +{ +0.238856, 0.864188, 0.442863}, + +{ +0.262866, 0.951056, 0.162460}, + +{ +0.500000, 0.809017, 0.309017}, + +{ +0.238856, 0.864188, -0.442863}, + +{ +0.262866, 0.951056, -0.162460}, + +{ +0.500000, 0.809017, -0.309017}, + +{ +0.850651, 0.525731, 0.000000}, + +{ +0.716567, 0.681718, 0.147621}, + +{ +0.716567, 0.681718, -0.147621}, + +{ +0.525731, 0.850651, 0.000000}, + +{ +0.425325, 0.688191, 0.587785}, + +{ +0.864188, 0.442863, 0.238856}, + +{ +0.688191, 0.587785, 0.425325}, + +{ +0.809017, 0.309017, 0.500000}, + +{ +0.681718, 0.147621, 0.716567}, + +{ +0.587785, 0.425325, 0.688191}, + +{ +0.955423, 0.295242, 0.000000}, + +{ +1.000000, 0.000000, 0.000000}, + +{ +0.951056, 0.162460, 0.262866}, + +{ +0.850651, -0.525731, 0.000000}, + +{ +0.955423, -0.295242, 0.000000}, + +{ +0.864188, -0.442863, 0.238856}, + +{ +0.951056, -0.162460, 0.262866}, + +{ +0.809017, -0.309017, 0.500000}, + +{ +0.681718, -0.147621, 0.716567}, + +{ +0.850651, 0.000000, 0.525731}, + +{ +0.864188, 0.442863, -0.238856}, + +{ +0.809017, 0.309017, -0.500000}, + +{ +0.951056, 0.162460, -0.262866}, + +{ +0.525731, 0.000000, -0.850651}, + +{ +0.681718, 0.147621, -0.716567}, + +{ +0.681718, -0.147621, -0.716567}, + +{ +0.850651, 0.000000, -0.525731}, + +{ +0.809017, -0.309017, -0.500000}, + +{ +0.864188, -0.442863, -0.238856}, + +{ +0.951056, -0.162460, -0.262866}, + +{ +0.147621, 0.716567, -0.681718}, + +{ +0.309017, 0.500000, -0.809017}, + +{ +0.425325, 0.688191, -0.587785}, + +{ +0.442863, 0.238856, -0.864188}, + +{ +0.587785, 0.425325, -0.688191}, + +{ +0.688191, 0.587785, -0.425325}, + +{ +-0.147621, 0.716567, -0.681718}, + +{ +-0.309017, 0.500000, -0.809017}, + +{ +0.000000, 0.525731, -0.850651}, + +{ +-0.525731, 0.000000, -0.850651}, + +{ +-0.442863, 0.238856, -0.864188}, + +{ +-0.295242, 0.000000, -0.955423}, + +{ +-0.162460, 0.262866, -0.951056}, + +{ +0.000000, 0.000000, -1.000000}, + +{ +0.295242, 0.000000, -0.955423}, + +{ +0.162460, 0.262866, -0.951056}, + +{ +-0.442863, -0.238856, -0.864188}, + +{ +-0.309017, -0.500000, -0.809017}, + +{ +-0.162460, -0.262866, -0.951056}, + +{ +0.000000, -0.850651, -0.525731}, + +{ +-0.147621, -0.716567, -0.681718}, + +{ +0.147621, -0.716567, -0.681718}, + +{ +0.000000, -0.525731, -0.850651}, + +{ +0.309017, -0.500000, -0.809017}, + +{ +0.442863, -0.238856, -0.864188}, + +{ +0.162460, -0.262866, -0.951056}, + +{ +0.238856, -0.864188, -0.442863}, + +{ +0.500000, -0.809017, -0.309017}, + +{ +0.425325, -0.688191, -0.587785}, + +{ +0.716567, -0.681718, -0.147621}, + +{ +0.688191, -0.587785, -0.425325}, + +{ +0.587785, -0.425325, -0.688191}, + +{ +0.000000, -0.955423, -0.295242}, + +{ +0.000000, -1.000000, 0.000000}, + +{ +0.262866, -0.951056, -0.162460}, + +{ +0.000000, -0.850651, 0.525731}, + +{ +0.000000, -0.955423, 0.295242}, + +{ +0.238856, -0.864188, 0.442863}, + +{ +0.262866, -0.951056, 0.162460}, + +{ +0.500000, -0.809017, 0.309017}, + +{ +0.716567, -0.681718, 0.147621}, + +{ +0.525731, -0.850651, 0.000000}, + +{ +-0.238856, -0.864188, -0.442863}, + +{ +-0.500000, -0.809017, -0.309017}, + +{ +-0.262866, -0.951056, -0.162460}, + +{ +-0.850651, -0.525731, 0.000000}, + +{ +-0.716567, -0.681718, -0.147621}, + +{ +-0.716567, -0.681718, 0.147621}, + +{ +-0.525731, -0.850651, 0.000000}, + +{ +-0.500000, -0.809017, 0.309017}, + +{ +-0.238856, -0.864188, 0.442863}, + +{ +-0.262866, -0.951056, 0.162460}, + +{ +-0.864188, -0.442863, 0.238856}, + +{ +-0.809017, -0.309017, 0.500000}, + +{ +-0.688191, -0.587785, 0.425325}, + +{ +-0.681718, -0.147621, 0.716567}, + +{ +-0.442863, -0.238856, 0.864188}, + +{ +-0.587785, -0.425325, 0.688191}, + +{ +-0.309017, -0.500000, 0.809017}, + +{ +-0.147621, -0.716567, 0.681718}, + +{ +-0.425325, -0.688191, 0.587785}, + +{ +-0.162460, -0.262866, 0.951056}, + +{ +0.442863, -0.238856, 0.864188}, + +{ +0.162460, -0.262866, 0.951056}, + +{ +0.309017, -0.500000, 0.809017}, + +{ +0.147621, -0.716567, 0.681718}, + +{ +0.000000, -0.525731, 0.850651}, + +{ +0.425325, -0.688191, 0.587785}, + +{ +0.587785, -0.425325, 0.688191}, + +{ +0.688191, -0.587785, 0.425325}, + +{ +-0.955423, 0.295242, 0.000000}, + +{ +-0.951056, 0.162460, 0.262866}, + +{ +-1.000000, 0.000000, 0.000000}, + +{ +-0.850651, 0.000000, 0.525731}, + +{ +-0.955423, -0.295242, 0.000000}, + +{ +-0.951056, -0.162460, 0.262866}, + +{ +-0.864188, 0.442863, -0.238856}, + +{ +-0.951056, 0.162460, -0.262866}, + +{ +-0.809017, 0.309017, -0.500000}, + +{ +-0.864188, -0.442863, -0.238856}, + +{ +-0.951056, -0.162460, -0.262866}, + +{ +-0.809017, -0.309017, -0.500000}, + +{ +-0.681718, 0.147621, -0.716567}, + +{ +-0.681718, -0.147621, -0.716567}, + +{ +-0.850651, 0.000000, -0.525731}, + +{ +-0.688191, 0.587785, -0.425325}, + +{ +-0.587785, 0.425325, -0.688191}, + +{ +-0.425325, 0.688191, -0.587785}, + +{ +-0.425325, -0.688191, -0.587785}, + +{ +-0.587785, -0.425325, -0.688191}, + +{ +-0.688191, -0.587785, -0.425325}, diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h new file mode 100644 index 000000000..8126cb5d4 --- /dev/null +++ b/src/gl/renderer/gl_colormap.h @@ -0,0 +1,76 @@ +#ifndef __GL_COLORMAP +#define __GL_COLORMAP + +#include "doomtype.h" +#include "v_palette.h" +#include "r_data/colormaps.h" + +extern DWORD gl_fixedcolormap; + + +enum EColorManipulation +{ + + CM_INVALID=-1, + CM_DEFAULT=0, // untranslated + CM_FIRSTSPECIALCOLORMAP, // first special fixed colormap + + CM_FOGLAYER = 0x10000000, // Sprite shaped fog layer + + // These are not to be passed to the texture manager + CM_LITE = 0x20000000, // special values to handle these items without excessive hacking + CM_TORCH= 0x20000010, // These are not real color manipulations +}; + +#define CM_MAXCOLORMAP int(CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size()) + + // for internal use +struct FColormap +{ + PalEntry LightColor; // a is saturation (0 full, 31=b/w, other=custom colormap) + PalEntry FadeColor; // a is fadedensity>>1 + int desaturation; + int blendfactor; + + void Clear() + { + LightColor=0xffffff; + FadeColor=0; + desaturation = 0; + blendfactor=0; + } + + void ClearColor() + { + LightColor.r=LightColor.g=LightColor.b=0xff; + blendfactor=0; + desaturation = 0; + } + + + FColormap & operator=(FDynamicColormap * from) + { + LightColor = from->Color; + desaturation = from->Desaturate; + FadeColor = from->Fade; + blendfactor = from->Color.a; + return * this; + } + + void CopyLightColor(FDynamicColormap * from) + { + LightColor = from->Color; + desaturation = from->Desaturate; + blendfactor = from->Color.a; + } + + void Decolorize() // this for 'nocoloredspritelighting' and not the same as desaturation. The normal formula results in a value that's too dark. + { + int v = (LightColor.r + LightColor.g + LightColor.b) / 3; + LightColor.r = LightColor.g = LightColor.b = (255 + v + v) / 3; + } +}; + + + +#endif diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp new file mode 100644 index 000000000..5d153894f --- /dev/null +++ b/src/gl/renderer/gl_lightdata.cpp @@ -0,0 +1,559 @@ +/* +** gl_light.cpp +** Light level / fog management / dynamic lights +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/data/gl_data.h" +#include "gl/renderer/gl_colormap.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/shaders/gl_shader.h" +#include "gl/scene/gl_portal.h" +#include "c_dispatch.h" +#include "p_local.h" +#include "g_level.h" +#include "r_sky.h" + +// externally settable lighting properties +static float distfogtable[2][256]; // light to fog conversion table for black fog +static PalEntry outsidefogcolor; +int fogdensity; +int outsidefogdensity; +int skyfog; + +CUSTOM_CVAR (Int, gl_light_ambient, 20, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + // ambient of 0 does not work correctly because light level 0 is special. + if (self < 1) self = 1; +} + +CVAR(Int, gl_weaponlight, 8, CVAR_ARCHIVE); +CUSTOM_CVAR(Bool, gl_enhanced_nightvision, true, CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + // The fixed colormap state needs to be reset because if this happens when + // a shader is set to CM_LITE or CM_TORCH it won't register the change in behavior caused by this CVAR. + if (GLRenderer != NULL && GLRenderer->mShaderManager != NULL) + { + GLRenderer->mShaderManager->ResetFixedColormap(); + } +} +CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE); + + + +//========================================================================== +// +// Sets up the fog tables +// +//========================================================================== + +CUSTOM_CVAR (Int, gl_distfog, 70, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + for (int i=0;i<256;i++) + { + + if (i<164) + { + distfogtable[0][i]= (gl_distfog>>1) + (gl_distfog)*(164-i)/164; + } + else if (i<230) + { + distfogtable[0][i]= (gl_distfog>>1) - (gl_distfog>>1)*(i-164)/(230-164); + } + else distfogtable[0][i]=0; + + if (i<128) + { + distfogtable[1][i]= 6.f + (gl_distfog>>1) + (gl_distfog)*(128-i)/48; + } + else if (i<216) + { + distfogtable[1][i]= (216.f-i) / ((216.f-128.f)) * gl_distfog / 10; + } + else distfogtable[1][i]=0; + } +} + +CUSTOM_CVAR(Int,gl_fogmode,1,CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + if (self>2) self=2; + if (self<0) self=0; +} + +CUSTOM_CVAR(Int, gl_lightmode, 3 ,CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + int newself = self; + if (newself > 4) newself=8; // use 8 for software lighting to avoid conflicts with the bit mask + if (newself < 0) newself=0; + if (self != newself) self = newself; + glset.lightmode = newself; +} + + + + +//========================================================================== +// +// Sets render state to draw the given render style +// includes: Texture mode, blend equation and blend mode +// +//========================================================================== + +void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending, + int *tm, int *sb, int *db, int *be) +{ + static int blendstyles[] = { GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }; + static int renderops[] = { 0, GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1 }; + + int srcblend = blendstyles[style.SrcAlpha&3]; + int dstblend = blendstyles[style.DestAlpha&3]; + int blendequation = renderops[style.BlendOp&15]; + int texturemode = drawopaque? TM_OPAQUE : TM_MODULATE; + + if (style.Flags & STYLEF_RedIsAlpha) + { + texturemode = TM_REDTOALPHA; + } + else if (style.Flags & STYLEF_ColorIsFixed) + { + texturemode = TM_MASK; + } + else if (style.Flags & STYLEF_InvertSource) + { + // The only place where InvertSource is used is for inverted sprites with the infrared powerup. + texturemode = TM_INVERSE; + } + + if (blendequation == -1) + { + srcblend = GL_DST_COLOR; + dstblend = GL_ONE_MINUS_SRC_ALPHA; + blendequation = GL_FUNC_ADD; + } + + if (allowcolorblending && srcblend == GL_SRC_ALPHA && dstblend == GL_ONE && blendequation == GL_FUNC_ADD) + { + srcblend = GL_SRC_COLOR; + } + + *tm = texturemode; + *be = blendequation; + *sb = srcblend; + *db = dstblend; +} + + +//========================================================================== +// +// Set fog parameters for the level +// +//========================================================================== +void gl_SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog) +{ + fogdensity=_fogdensity; + outsidefogcolor=_outsidefogcolor; + outsidefogdensity=_outsidefogdensity; + skyfog=_skyfog; + + outsidefogdensity>>=1; + fogdensity>>=1; +} + + +//========================================================================== +// +// Get current light level +// +//========================================================================== + +int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon) +{ + int light; + + if (lightlevel == 0) return 0; + + if ((glset.lightmode & 2) && lightlevel < 192 && !weapon) + { + light = xs_CRoundToInt(192.f - (192-lightlevel)* 1.95f); + } + else + { + light=lightlevel; + } + + if (light>=1; + } + return clamp(light+rellight, 0, 255); +} + +//========================================================================== +// +// Get current light color +// +//========================================================================== + +static PalEntry gl_CalcLightColor(int light, PalEntry pe, int blendfactor) +{ + int r,g,b; + + if (glset.lightmode == 8) + { + return pe; + } + else if (blendfactor == 0) + { + r = pe.r * light / 255; + g = pe.g * light / 255; + b = pe.b * light / 255; + } + else + { + // This is what Legacy does with colored light in 3D volumes. No, it doesn't really make sense... + // It also doesn't translate well to software style lighting. + int mixlight = light * (255 - blendfactor); + + r = (mixlight + pe.r * blendfactor) / 255; + g = (mixlight + pe.g * blendfactor) / 255; + b = (mixlight + pe.b * blendfactor) / 255; + } + return PalEntry(255, BYTE(r), BYTE(g), BYTE(b)); +} + +//========================================================================== +// +// set current light color +// +//========================================================================== +void gl_SetColor(int sectorlightlevel, int rellight, const FColormap &cm, float alpha, bool weapon) +{ + if (gl_fixedcolormap != CM_DEFAULT) + { + gl_RenderState.SetColorAlpha(0xffffff, alpha, 0); + gl_RenderState.SetSoftLightLevel(255); + } + else + { + int hwlightlevel = gl_CalcLightLevel(sectorlightlevel, rellight, weapon); + PalEntry pe = gl_CalcLightColor(hwlightlevel, cm.LightColor, cm.blendfactor); + gl_RenderState.SetColorAlpha(pe, alpha, cm.desaturation); + gl_RenderState.SetSoftLightLevel(gl_ClampLight(sectorlightlevel + rellight)); + } +} + +//========================================================================== +// +// calculates the current fog density +// +// Rules for fog: +// +// 1. If bit 4 of gl_lightmode is set always use the level's fog density. +// This is what Legacy's GL render does. +// 2. black fog means no fog and always uses the distfogtable based on the level's fog density setting +// 3. If outside fog is defined and the current fog color is the same as the outside fog +// the engine always uses the outside fog density to make the fog uniform across the level. +// If the outside fog's density is undefined it uses the level's fog density and if that is +// not defined it uses a default of 70. +// 4. If a global fog density is specified it is being used for all fog on the level +// 5. If none of the above apply fog density is based on the light level as for the software renderer. +// +//========================================================================== + +float gl_GetFogDensity(int lightlevel, PalEntry fogcolor) +{ + float density; + + if (glset.lightmode&4) + { + // uses approximations of Legacy's default settings. + density = fogdensity? fogdensity : 18; + } + else if ((fogcolor.d & 0xffffff) == 0) + { + // case 1: black fog + if (glset.lightmode != 8) + { + density=distfogtable[glset.lightmode!=0][gl_ClampLight(lightlevel)]; + } + else + { + density = 0; + } + } + else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) + { + // case 2. outsidefogdensity has already been set as needed + density=outsidefogdensity; + } + else if (fogdensity!=0) + { + // case 3: level has fog density set + density=fogdensity; + } + else if (lightlevel < 248) + { + // case 4: use light level + density=clamp(255-lightlevel,30,255); + } + else + { + density = 0.f; + } + return density; +} + + +//========================================================================== +// +// Check fog by current lighting info +// +//========================================================================== + +bool gl_CheckFog(FColormap *cm, int lightlevel) +{ + // Check for fog boundaries. This needs a few more checks for the sectors + bool frontfog; + + PalEntry fogcolor = cm->FadeColor; + + if ((fogcolor.d & 0xffffff) == 0) + { + frontfog = false; + } + else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) + { + frontfog = true; + } + else if (fogdensity!=0 || (glset.lightmode & 4)) + { + // case 3: level has fog density set + frontfog = true; + } + else + { + // case 4: use light level + frontfog = lightlevel < 248; + } + return frontfog; +} + +//========================================================================== +// +// Check if the current linedef is a candidate for a fog boundary +// +// Requirements for a fog boundary: +// - front sector has no fog +// - back sector has fog +// - at least one of both does not have a sky ceiling. +// +//========================================================================== + +bool gl_CheckFog(sector_t *frontsector, sector_t *backsector) +{ + if (gl_fixedcolormap) return false; + if (frontsector == backsector) return false; // there can't be a boundary if both sides are in the same sector. + + // Check for fog boundaries. This needs a few more checks for the sectors + + PalEntry fogcolor = frontsector->ColorMap->Fade; + + if ((fogcolor.d & 0xffffff) == 0) + { + return false; + } + else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) + { + } + else if (fogdensity!=0 || (glset.lightmode & 4)) + { + // case 3: level has fog density set + } + else + { + // case 4: use light level + if (frontsector->lightlevel >= 248) return false; + } + + fogcolor = backsector->ColorMap->Fade; + + if ((fogcolor.d & 0xffffff) == 0) + { + } + else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff)) + { + return false; + } + else if (fogdensity!=0 || (glset.lightmode & 4)) + { + // case 3: level has fog density set + return false; + } + else + { + // case 4: use light level + if (backsector->lightlevel < 248) return false; + } + + // in all other cases this might create more problems than it solves. + return ((frontsector->GetTexture(sector_t::ceiling)!=skyflatnum || + backsector->GetTexture(sector_t::ceiling)!=skyflatnum)); +} + +//========================================================================== +// +// Lighting stuff +// +//========================================================================== + +void gl_SetShaderLight(float level, float olight) +{ + const float MAXDIST = 256.f; + const float THRESHOLD = 96.f; + const float FACTOR = 0.75f; + + if (level > 0) + { + float lightdist, lightfactor; + + if (olight < THRESHOLD) + { + lightdist = (MAXDIST/2) + (olight * MAXDIST / THRESHOLD / 2); + olight = THRESHOLD; + } + else lightdist = MAXDIST; + + lightfactor = 1.f + ((olight/level) - 1.f) * FACTOR; + if (lightfactor == 1.f) lightdist = 0.f; // save some code in the shader + gl_RenderState.SetLightParms(lightfactor, lightdist); + } + else + { + gl_RenderState.SetLightParms(1.f, 0.f); + } +} + + +//========================================================================== +// +// Sets the fog for the current polygon +// +//========================================================================== + +void gl_SetFog(int lightlevel, int rellight, const FColormap *cmap, bool isadditive) +{ + PalEntry fogcolor; + float fogdensity; + + if (level.flags&LEVEL_HASFADETABLE) + { + fogdensity=70; + fogcolor=0x808080; + } + else if (cmap != NULL && gl_fixedcolormap == 0) + { + fogcolor = cmap->FadeColor; + fogdensity = gl_GetFogDensity(lightlevel, fogcolor); + fogcolor.a=0; + } + else + { + fogcolor = 0; + fogdensity = 0; + } + + // Make fog a little denser when inside a skybox + if (GLPortal::inskybox) fogdensity+=fogdensity/2; + + + // no fog in enhanced vision modes! + if (fogdensity==0 || gl_fogmode == 0) + { + gl_RenderState.EnableFog(false); + gl_RenderState.SetFog(0,0); + } + else + { + if (glset.lightmode == 2 && fogcolor == 0) + { + float light = gl_CalcLightLevel(lightlevel, rellight, false); + gl_SetShaderLight(light, lightlevel); + } + else + { + gl_RenderState.SetLightParms(1.f, 0.f); + } + + // For additive rendering using the regular fog color here would mean applying it twice + // so always use black + if (isadditive) + { + fogcolor=0; + } + + gl_RenderState.EnableFog(true); + gl_RenderState.SetFog(fogcolor, fogdensity); + + // Korshun: fullbright fog like in software renderer. + if (glset.lightmode == 8 && glset.brightfog && fogdensity != 0 && fogcolor != 0) + { + gl_RenderState.SetSoftLightLevel(255); + } + } +} + + +//========================================================================== +// +// For testing sky fog sheets +// +//========================================================================== +CCMD(skyfog) +{ + if (argv.argc()>1) + { + skyfog=strtol(argv[1],NULL,0); + } +} + diff --git a/src/gl/renderer/gl_lightdata.h b/src/gl/renderer/gl_lightdata.h new file mode 100644 index 000000000..f76f732af --- /dev/null +++ b/src/gl/renderer/gl_lightdata.h @@ -0,0 +1,52 @@ +#ifndef __GL_LIGHTDATA +#define __GL_LIGHTDATA + +#include "v_palette.h" +#include "r_data/renderstyle.h" +#include "gl/renderer/gl_colormap.h" + +inline int gl_ClampLight(int lightlevel) +{ + return clamp(lightlevel, 0, 255); +} + +void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending, + int *tm, int *sb, int *db, int *be); +void gl_SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog); + +int gl_CalcLightLevel(int lightlevel, int rellight, bool weapon); +void gl_SetColor(int light, int rellight, const FColormap &cm, float alpha, bool weapon=false); + +float gl_GetFogDensity(int lightlevel, PalEntry fogcolor); +struct sector_t; +bool gl_CheckFog(FColormap *cm, int lightlevel); +bool gl_CheckFog(sector_t *frontsector, sector_t *backsector); + +void gl_SetFog(int lightlevel, int rellight, const FColormap *cm, bool isadditive); + +inline bool gl_isBlack(PalEntry color) +{ + return color.r + color.g + color.b == 0; +} + +inline bool gl_isWhite(PalEntry color) +{ + return color.r + color.g + color.b == 3*0xff; +} + +extern DWORD gl_fixedcolormap; + +inline bool gl_isFullbright(PalEntry color, int lightlevel) +{ + return gl_fixedcolormap || (gl_isWhite(color) && lightlevel==255); +} + +void gl_DeleteAllAttachedLights(); +void gl_RecreateAllAttachedLights(); + +extern int fogdensity; +extern int outsidefogdensity; +extern int skyfog; + + +#endif \ No newline at end of file diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp new file mode 100644 index 000000000..dd4730687 --- /dev/null +++ b/src/gl/renderer/gl_renderer.cpp @@ -0,0 +1,634 @@ +/* +** gl1_renderer.cpp +** Renderer interface +** +**--------------------------------------------------------------------------- +** Copyright 2008 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "r_data/r_translate.h" +#include "m_png.h" +#include "m_crc32.h" +#include "w_wad.h" +//#include "gl/gl_intern.h" +#include "gl/gl_functions.h" +#include "vectors.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_translate.h" +#include "gl/textures/gl_material.h" +#include "gl/textures/gl_samplers.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" +#include "gl/models/gl_models.h" +#include "gl/dynlights/gl_lightbuffer.h" + +//=========================================================================== +// +// Renderer interface +// +//=========================================================================== + +//----------------------------------------------------------------------------- +// +// Initialize +// +//----------------------------------------------------------------------------- + +FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) +{ + framebuffer = fb; + mCurrentPortal = NULL; + mMirrorCount = 0; + mPlaneMirrorCount = 0; + mLightCount = 0; + mAngles = FRotator(0,0,0); + mViewVector = FVector2(0,0); + mVBO = NULL; + mSkyVBO = NULL; + gl_spriteindex = 0; + mShaderManager = NULL; + glpart2 = glpart = mirrortexture = NULL; + mLights = NULL; +} + +void gl_LoadModels(); +void gl_FlushModels(); + +void FGLRenderer::Initialize() +{ + glpart2 = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart2.png"), FTexture::TEX_MiscPatch); + glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch); + mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch); + + mVBO = new FFlatVertexBuffer; + mSkyVBO = new FSkyVertexBuffer; + mLights = new FLightBuffer(); + gl_RenderState.SetVertexBuffer(mVBO); + mFBID = 0; + SetupLevel(); + mShaderManager = new FShaderManager; + mSamplerManager = new FSamplerManager; + gl_LoadModels(); +} + +FGLRenderer::~FGLRenderer() +{ + gl_FlushModels(); + gl_DeleteAllAttachedLights(); + FMaterial::FlushAll(); + if (mShaderManager != NULL) delete mShaderManager; + if (mSamplerManager != NULL) delete mSamplerManager; + if (mVBO != NULL) delete mVBO; + if (mSkyVBO != NULL) delete mSkyVBO; + if (mLights != NULL) delete mLights; + if (glpart2) delete glpart2; + if (glpart) delete glpart; + if (mirrortexture) delete mirrortexture; + if (mFBID != 0) glDeleteFramebuffers(1, &mFBID); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::SetupLevel() +{ + mVBO->CreateVBO(); +} + +void FGLRenderer::Begin2D() +{ + gl_RenderState.EnableFog(false); + gl_RenderState.Set2DMode(true); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector) +{ + GLWall wall; + wall.ProcessLowerMiniseg(seg, frontsector, backsector); + rendered_lines++; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::ProcessSprite(AActor *thing, sector_t *sector) +{ + GLSprite glsprite; + glsprite.Process(thing, sector); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::ProcessParticle(particle_t *part, sector_t *sector) +{ + GLSprite glsprite; + glsprite.ProcessParticle(part, sector);//, 0, 0); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::ProcessSector(sector_t *fakesector) +{ + GLFlat glflat; + glflat.ProcessSector(fakesector); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::FlushTextures() +{ + FMaterial::FlushAll(); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +bool FGLRenderer::StartOffscreen() +{ + if (mFBID == 0) glGenFramebuffers(1, &mFBID); + glBindFramebuffer(GL_FRAMEBUFFER, mFBID); + return true; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::EndOffscreen() +{ + glBindFramebuffer(GL_FRAMEBUFFER, 0); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +unsigned char *FGLRenderer::GetTextureBuffer(FTexture *tex, int &w, int &h) +{ + FMaterial * gltex = FMaterial::ValidateTexture(tex, false); + if (gltex) + { + return gltex->CreateTexBuffer(0, w, h); + } + return NULL; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::ClearBorders() +{ + OpenGLFrameBuffer *glscreen = static_cast(screen); + + // Letterbox time! Draw black top and bottom borders. + int width = glscreen->GetWidth(); + int height = glscreen->GetHeight(); + int trueHeight = glscreen->GetTrueHeight(); + + int borderHeight = (trueHeight - height) / 2; + + glViewport(0, 0, width, trueHeight); + gl_RenderState.mProjectionMatrix.loadIdentity(); + gl_RenderState.mProjectionMatrix.ortho(0.0f, width * 1.0f, 0.0f, trueHeight, -1.0f, 1.0f); + gl_RenderState.SetColor(0.f ,0.f ,0.f ,1.f); + gl_RenderState.Set2DMode(true); + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(); + gl_RenderState.ApplyMatrices(); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, borderHeight, 0, 0, 0); ptr++; + ptr->Set(0, 0, 0, 0, 0); ptr++; + ptr->Set(width, 0, 0, 0, 0); ptr++; + ptr->Set(width, borderHeight, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + ptr->Set(0, trueHeight, 0, 0, 0); ptr++; + ptr->Set(0, trueHeight - borderHeight, 0, 0, 0); ptr++; + ptr->Set(width, trueHeight - borderHeight, 0, 0, 0); ptr++; + ptr->Set(width, trueHeight, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + gl_RenderState.EnableTexture(true); + + glViewport(0, (trueHeight - height) / 2, width, height); +} + +//========================================================================== +// +// Draws a texture +// +//========================================================================== + +void FGLRenderer::DrawTexture(FTexture *img, DCanvas::DrawParms &parms) +{ + double xscale = parms.destwidth / parms.texwidth; + double yscale = parms.destheight / parms.texheight; + double x = parms.x - parms.left * xscale; + double y = parms.y - parms.top * yscale; + double w = parms.destwidth; + double h = parms.destheight; + float u1, v1, u2, v2; + int light = 255; + + FMaterial * gltex = FMaterial::ValidateTexture(img, false); + + if (parms.colorOverlay && (parms.colorOverlay & 0xffffff) == 0) + { + // Right now there's only black. Should be implemented properly later + light = 255 - APART(parms.colorOverlay); + parms.colorOverlay = 0; + } + + gl_SetRenderStyle(parms.style, !parms.masked, false); + if (!img->bHasCanvas) + { + int translation = 0; + if (!parms.alphaChannel) + { + if (parms.remap != NULL && !parms.remap->Inactive) + { + GLTranslationPalette * pal = static_cast(parms.remap->GetNative()); + if (pal) translation = -pal->GetIndex(); + } + } + gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, translation, 0, !!(parms.style.Flags & STYLEF_RedIsAlpha)); + + u1 = gltex->GetUL(); + v1 = gltex->GetVT(); + u2 = gltex->GetUR(); + v2 = gltex->GetVB(); + + } + else + { + gl_RenderState.SetMaterial(gltex, CLAMP_XY_NOMIP, 0, -1, false); + u1 = 0.f; + v1 = 1.f; + u2 = 1.f; + v2 = 0.f; + gl_RenderState.SetTextureMode(TM_OPAQUE); + } + + if (parms.flipX) + { + float temp = u1; + u1 = u2; + u2 = temp; + } + + + if (parms.windowleft > 0 || parms.windowright < parms.texwidth) + { + x += parms.windowleft * xscale; + w -= (parms.texwidth - parms.windowright + parms.windowleft) * xscale; + + u1 = float(u1 + parms.windowleft / parms.texwidth); + u2 = float(u2 - (parms.texwidth - parms.windowright) / parms.texwidth); + } + + PalEntry color; + if (parms.style.Flags & STYLEF_ColorIsFixed) + { + color = parms.fillcolor; + } + else + { + color = PalEntry(light, light, light); + } + color.a = Scale(parms.alpha, 255, FRACUNIT); + + // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates + int btm = (SCREENHEIGHT - screen->GetHeight()) / 2; + btm = SCREENHEIGHT - btm; + + glEnable(GL_SCISSOR_TEST); + int space = (static_cast(screen)->GetTrueHeight()-screen->GetHeight())/2; + glScissor(parms.lclip, btm - parms.dclip + space, parms.rclip - parms.lclip, parms.dclip - parms.uclip); + + gl_RenderState.SetColor(color); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.Apply(); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x, y, 0, u1, v1); ptr++; + ptr->Set(x, y + h, 0, u1, v2); ptr++; + ptr->Set(x + w, y, 0, u2, v1); ptr++; + ptr->Set(x + w, y + h, 0, u2, v2); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + if (parms.colorOverlay) + { + gl_RenderState.SetTextureMode(TM_MASK); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.SetColor(PalEntry(parms.colorOverlay)); + gl_RenderState.Apply(); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x, y, 0, u1, v1); ptr++; + ptr->Set(x, y + h, 0, u1, v2); ptr++; + ptr->Set(x + w, y, 0, u2, v1); ptr++; + ptr->Set(x + w, y + h, 0, u2, v2); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + + glScissor(0, 0, screen->GetWidth(), screen->GetHeight()); + glDisable(GL_SCISSOR_TEST); + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.BlendEquation(GL_FUNC_ADD); +} + +//========================================================================== +// +// +// +//========================================================================== +void FGLRenderer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color) +{ + PalEntry p = color? (PalEntry)color : GPalette.BaseColors[palcolor]; + gl_RenderState.EnableTexture(false); + gl_RenderState.SetColorAlpha(p, 1.f); + gl_RenderState.Apply(); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, 0, 0); ptr++; + ptr->Set(x2, y2, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_LINES); + + gl_RenderState.EnableTexture(true); +} + +//========================================================================== +// +// +// +//========================================================================== +void FGLRenderer::DrawPixel(int x1, int y1, int palcolor, uint32 color) +{ + PalEntry p = color? (PalEntry)color : GPalette.BaseColors[palcolor]; + gl_RenderState.EnableTexture(false); + gl_RenderState.SetColorAlpha(p, 1.f); + gl_RenderState.Apply(); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_POINTS); + + gl_RenderState.EnableTexture(true); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::Dim(PalEntry color, float damount, int x1, int y1, int w, int h) +{ + gl_RenderState.EnableTexture(false); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.AlphaFunc(GL_GREATER,0); + gl_RenderState.SetColorAlpha(color, damount); + gl_RenderState.Apply(); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, 0, 0); ptr++; + ptr->Set(x1, y1+h, 0, 0, 0); ptr++; + ptr->Set(x1+w, y1+h, 0, 0, 0); ptr++; + ptr->Set(x1+w, y1, 0, 0, 0); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + + gl_RenderState.EnableTexture(true); +} + +//========================================================================== +// +// +// +//========================================================================== +void FGLRenderer::FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin) +{ + float fU1,fU2,fV1,fV2; + + FMaterial *gltexture=FMaterial::ValidateTexture(src, false); + + if (!gltexture) return; + + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); + + // scaling is not used here. + if (!local_origin) + { + fU1 = float(left) / src->GetWidth(); + fV1 = float(top) / src->GetHeight(); + fU2 = float(right) / src->GetWidth(); + fV2 = float(bottom) / src->GetHeight(); + } + else + { + fU1 = 0; + fV1 = 0; + fU2 = float(right-left) / src->GetWidth(); + fV2 = float(bottom-top) / src->GetHeight(); + } + gl_RenderState.ResetColor(); + gl_RenderState.Apply(); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(left, top, 0, fU1, fV1); ptr++; + ptr->Set(left, bottom, 0, fU1, fV2); ptr++; + ptr->Set(right, top, 0, fU2, fV1); ptr++; + ptr->Set(right, bottom, 0, fU2, fV2); ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); +} + +//========================================================================== +// +// +// +//========================================================================== +void FGLRenderer::Clear(int left, int top, int right, int bottom, int palcolor, uint32 color) +{ + int rt; + int offY = 0; + PalEntry p = palcolor==-1 || color != 0? (PalEntry)color : GPalette.BaseColors[palcolor]; + int width = right-left; + int height= bottom-top; + + + rt = screen->GetHeight() - top; + + int space = (static_cast(screen)->GetTrueHeight()-screen->GetHeight())/2; // ugh... + rt += space; + /* + if (!m_windowed && (m_trueHeight != m_height)) + { + offY = (m_trueHeight - m_height) / 2; + rt += offY; + } + */ + + glEnable(GL_SCISSOR_TEST); + glScissor(left, rt - height, width, height); + + glClearColor(p.r/255.0f, p.g/255.0f, p.b/255.0f, 0.f); + glClear(GL_COLOR_BUFFER_BIT); + glClearColor(0.f, 0.f, 0.f, 0.f); + + glDisable(GL_SCISSOR_TEST); +} + +//========================================================================== +// +// D3DFB :: FillSimplePoly +// +// Here, "simple" means that a simple triangle fan can draw it. +// +//========================================================================== + +void FGLRenderer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + angle_t rotation, FDynamicColormap *colormap, int lightlevel) +{ + if (npoints < 3) + { // This is no polygon. + return; + } + + FMaterial *gltexture = FMaterial::ValidateTexture(texture, false); + + if (gltexture == NULL) + { + return; + } + + FColormap cm; + cm = colormap; + + // We cannot use the software light mode here because it doesn't properly calculate the light for 2D rendering. + SBYTE savedlightmode = glset.lightmode; + if (glset.lightmode == 8) glset.lightmode = 0; + + gl_SetColor(lightlevel, 0, cm, 1.f); + + glset.lightmode = savedlightmode; + + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); + + int i; + float rot = float(rotation * M_PI / float(1u << 31)); + bool dorotate = rot != 0; + + float cosrot = cos(rot); + float sinrot = sin(rot); + + //float yoffs = GatheringWipeScreen ? 0 : LBOffset; + float uscale = float(1.f / (texture->GetScaledWidth() * scalex)); + float vscale = float(1.f / (texture->GetScaledHeight() * scaley)); + if (gltexture->tex->bHasCanvas) + { + vscale = 0 - vscale; + } + float ox = float(originx); + float oy = float(originy); + + gl_RenderState.Apply(); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (i = 0; i < npoints; ++i) + { + float u = points[i].X - 0.5f - ox; + float v = points[i].Y - 0.5f - oy; + if (dorotate) + { + float t = u; + u = t * cosrot - v * sinrot; + v = v * cosrot + t * sinrot; + } + ptr->Set(points[i].X, points[i].Y, 0, u*uscale, v*vscale); + ptr++; + } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); +} + diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h new file mode 100644 index 000000000..a388ced35 --- /dev/null +++ b/src/gl/renderer/gl_renderer.h @@ -0,0 +1,168 @@ +#ifndef __GL_RENDERER_H +#define __GL_RENDERER_H + +#include "r_defs.h" +#include "v_video.h" +#include "vectors.h" +#include "r_renderer.h" +#include "gl/data/gl_matrix.h" + +struct particle_t; +class FCanvasTexture; +class FFlatVertexBuffer; +class FSkyVertexBuffer; +class OpenGLFrameBuffer; +struct FDrawInfo; +struct pspdef_t; +class FShaderManager; +class GLPortal; +class FLightBuffer; +class FSamplerManager; + +enum SectorRenderFlags +{ + // This is used to avoid creating too many drawinfos + SSRF_RENDERFLOOR = 1, + SSRF_RENDERCEILING = 2, + SSRF_RENDER3DPLANES = 4, + SSRF_RENDERALL = 7, + SSRF_PROCESSED = 8, + SSRF_SEEN = 16, +}; + +struct GL_IRECT +{ + int left,top; + int width,height; + + + void Offset(int xofs,int yofs) + { + left+=xofs; + top+=yofs; + } +}; + + +class FGLRenderer +{ +public: + + OpenGLFrameBuffer *framebuffer; + GLPortal *mCurrentPortal; + int mMirrorCount; + int mPlaneMirrorCount; + int mLightCount; + float mCurrentFoV; + AActor *mViewActor; + FShaderManager *mShaderManager; + FSamplerManager *mSamplerManager; + int gl_spriteindex; + unsigned int mFBID; + + FTexture *glpart2; + FTexture *glpart; + FTexture *mirrortexture; + + float mSky1Pos, mSky2Pos; + + FRotator mAngles; + FVector2 mViewVector; + + FFlatVertexBuffer *mVBO; + FSkyVertexBuffer *mSkyVBO; + FLightBuffer *mLights; + + + FGLRenderer(OpenGLFrameBuffer *fb); + ~FGLRenderer() ; + + angle_t FrustumAngle(); + void SetViewArea(); + void ResetViewport(); + void SetViewport(GL_IRECT *bounds); + sector_t *RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen); + void RenderView(player_t *player); + void SetViewAngle(angle_t viewangle); + void SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror); + + void Initialize(); + + void CreateScene(); + void RenderScene(int recursion); + void RenderTranslucent(); + void DrawScene(bool toscreen = false); + void DrawBlend(sector_t * viewsector); + + void DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader, bool alphatexture); + void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep); + void DrawTargeterSprites(); + + void Begin2D(); + void ClearBorders(); + void DrawTexture(FTexture *img, DCanvas::DrawParms &parms); + void DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color); + void DrawPixel(int x1, int y1, int palcolor, uint32 color); + void Dim(PalEntry color, float damount, int x1, int y1, int w, int h); + void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin); + void Clear(int left, int top, int right, int bottom, int palcolor, uint32 color); + + void ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector); + void ProcessSprite(AActor *thing, sector_t *sector); + void ProcessParticle(particle_t *part, sector_t *sector); + void ProcessSector(sector_t *fakesector); + void FlushTextures(); + unsigned char *GetTextureBuffer(FTexture *tex, int &w, int &h); + void SetupLevel(); + + void SetFixedColormap (player_t *player); + void WriteSavePic (player_t *player, FILE *file, int width, int height); + void EndDrawScene(sector_t * viewsector); + void Flush() {} + + void SetProjection(float fov, float ratio, float fovratio); + void SetProjection(VSMatrix matrix); // raw matrix input from stereo 3d modes + void SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror); + void ProcessScene(bool toscreen = false); + + bool StartOffscreen(); + void EndOffscreen(); + + void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + angle_t rotation, FDynamicColormap *colormap, int lightlevel); +}; + +// Global functions. Make them members of GLRenderer later? +void gl_RenderBSPNode (void *node); +bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector); +void gl_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector); + +typedef enum +{ + area_normal, + area_below, + area_above, + area_default +} area_t; + +extern area_t in_area; + + +sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back); +inline sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, bool back) +{ + return gl_FakeFlat(sec, dest, in_area, back); +} + +struct TexFilter_s +{ + int minfilter; + int magfilter; + bool mipmapping; +} ; + + +extern FGLRenderer *GLRenderer; + +#endif \ No newline at end of file diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp new file mode 100644 index 000000000..15aa56da9 --- /dev/null +++ b/src/gl/renderer/gl_renderstate.cpp @@ -0,0 +1,305 @@ +/* +** gl_renderstate.cpp +** Render state maintenance +** +**--------------------------------------------------------------------------- +** Copyright 2009 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "templates.h" +#include "gl/system/gl_system.h" +#include "gl/system/gl_interface.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_shader.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_colormap.h" +#include "gl/dynlights//gl_lightbuffer.h" + +void gl_SetTextureMode(int type); + +FRenderState gl_RenderState; + +CVAR(Bool, gl_direct_state_change, true, 0) + + +static VSMatrix identityMatrix(1); +TArray gl_MatrixStack; + +//========================================================================== +// +// +// +//========================================================================== + +void FRenderState::Reset() +{ + mTextureEnabled = true; + mBrightmapEnabled = mFogEnabled = mGlowEnabled = false; + mColorMask[0] = mColorMask[1] = mColorMask[2] = mColorMask[3] = true; + currentColorMask[0] = currentColorMask[1] = currentColorMask[2] = currentColorMask[3] = true; + mFogColor.d = -1; + mTextureMode = -1; + mLightIndex = -1; + mDesaturation = 0; + mSrcBlend = GL_SRC_ALPHA; + mDstBlend = GL_ONE_MINUS_SRC_ALPHA; + mAlphaThreshold = 0.5f; + mBlendEquation = GL_FUNC_ADD; + mObjectColor = 0xffffffff; + m2D = true; + mVertexBuffer = mCurrentVertexBuffer = NULL; + mColormapState = CM_DEFAULT; + mLightParms[3] = -1.f; + mSpecialEffect = EFF_NONE; + mClipHeightTop = 65536.f; + mClipHeightBottom = -65536.f; + ClearClipSplit(); + + stSrcBlend = stDstBlend = -1; + stBlendEquation = -1; + stAlphaThreshold = -1.f; + mLastDepthClamp = true; +} + +//========================================================================== +// +// Apply shader settings +// +//========================================================================== + +bool FRenderState::ApplyShader() +{ + if (mSpecialEffect > EFF_NONE) + { + activeShader = GLRenderer->mShaderManager->BindEffect(mSpecialEffect); + } + else + { + activeShader = GLRenderer->mShaderManager->Get(mTextureEnabled ? mEffectState : 4, mAlphaThreshold >= 0.f); + activeShader->Bind(); + } + + int fogset = 0; + + if (mFogEnabled) + { + if ((mFogColor & 0xffffff) == 0) + { + fogset = gl_fogmode; + } + else + { + fogset = -gl_fogmode; + } + } + + glVertexAttrib4fv(VATTR_COLOR, mColor.vec); + + activeShader->muDesaturation.Set(mDesaturation / 255.f); + activeShader->muFogEnabled.Set(fogset); + activeShader->muTextureMode.Set(mTextureMode); + activeShader->muCameraPos.Set(mCameraPos.vec); + activeShader->muLightParms.Set(mLightParms); + activeShader->muFogColor.Set(mFogColor); + activeShader->muObjectColor.Set(mObjectColor); + activeShader->muDynLightColor.Set(mDynColor.vec); + activeShader->muInterpolationFactor.Set(mInterpolationFactor); + activeShader->muClipHeightTop.Set(mClipHeightTop); + activeShader->muClipHeightBottom.Set(mClipHeightBottom); + activeShader->muTimer.Set(gl_frameMS * mShaderTimer / 1000.f); + activeShader->muAlphaThreshold.Set(mAlphaThreshold); + activeShader->muLightIndex.Set(mLightIndex); // will always be -1 for now + activeShader->muClipSplit.Set(mClipSplit); + + if (mGlowEnabled) + { + activeShader->muGlowTopColor.Set(mGlowTop.vec); + activeShader->muGlowBottomColor.Set(mGlowBottom.vec); + activeShader->muGlowTopPlane.Set(mGlowTopPlane.vec); + activeShader->muGlowBottomPlane.Set(mGlowBottomPlane.vec); + activeShader->currentglowstate = 1; + } + else if (activeShader->currentglowstate) + { + // if glowing is on, disable it. + static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f }; + activeShader->muGlowTopColor.Set(nulvec); + activeShader->muGlowBottomColor.Set(nulvec); + activeShader->muGlowTopPlane.Set(nulvec); + activeShader->muGlowBottomPlane.Set(nulvec); + activeShader->currentglowstate = 0; + } + + if (mColormapState != activeShader->currentfixedcolormap) + { + float r, g, b; + activeShader->currentfixedcolormap = mColormapState; + if (mColormapState == CM_DEFAULT) + { + activeShader->muFixedColormap.Set(0); + } + else if (mColormapState < CM_MAXCOLORMAP) + { + FSpecialColormap *scm = &SpecialColormaps[gl_fixedcolormap - CM_FIRSTSPECIALCOLORMAP]; + float m[] = { scm->ColorizeEnd[0] - scm->ColorizeStart[0], + scm->ColorizeEnd[1] - scm->ColorizeStart[1], scm->ColorizeEnd[2] - scm->ColorizeStart[2], 0.f }; + + activeShader->muFixedColormap.Set(1); + activeShader->muColormapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f); + activeShader->muColormapRange.Set(m); + } + else if (mColormapState == CM_FOGLAYER) + { + activeShader->muFixedColormap.Set(3); + } + else if (mColormapState == CM_LITE) + { + if (gl_enhanced_nightvision) + { + r = 0.375f, g = 1.0f, b = 0.375f; + } + else + { + r = g = b = 1.f; + } + activeShader->muFixedColormap.Set(2); + activeShader->muColormapStart.Set(r, g, b, 1.f); + } + else if (mColormapState >= CM_TORCH) + { + int flicker = mColormapState - CM_TORCH; + r = (0.8f + (7 - flicker) / 70.0f); + if (r > 1.0f) r = 1.0f; + b = g = r; + if (gl_enhanced_nightvision) b = g * 0.75f; + activeShader->muFixedColormap.Set(2); + activeShader->muColormapStart.Set(r, g, b, 1.f); + } + } + if (mTextureMatrixEnabled) + { + mTextureMatrix.matrixToGL(activeShader->texturematrix_index); + activeShader->currentTextureMatrixState = true; + } + else if (activeShader->currentTextureMatrixState) + { + activeShader->currentTextureMatrixState = false; + identityMatrix.matrixToGL(activeShader->texturematrix_index); + } + + if (mModelMatrixEnabled) + { + mModelMatrix.matrixToGL(activeShader->modelmatrix_index); + activeShader->currentModelMatrixState = true; + } + else if (activeShader->currentModelMatrixState) + { + activeShader->currentModelMatrixState = false; + identityMatrix.matrixToGL(activeShader->modelmatrix_index); + } + return true; +} + + +//========================================================================== +// +// Apply State +// +//========================================================================== + +void FRenderState::Apply() +{ + if (!gl_direct_state_change) + { + if (mSrcBlend != stSrcBlend || mDstBlend != stDstBlend) + { + stSrcBlend = mSrcBlend; + stDstBlend = mDstBlend; + glBlendFunc(mSrcBlend, mDstBlend); + } + if (mBlendEquation != stBlendEquation) + { + stBlendEquation = mBlendEquation; + glBlendEquation(mBlendEquation); + } + } + + //ApplyColorMask(); I don't think this is needed. + + if (mVertexBuffer != mCurrentVertexBuffer) + { + if (mVertexBuffer == NULL) glBindBuffer(GL_ARRAY_BUFFER, 0); + else mVertexBuffer->BindVBO(); + mCurrentVertexBuffer = mVertexBuffer; + } + ApplyShader(); +} + + + +void FRenderState::ApplyColorMask() +{ + if ((mColorMask[0] != currentColorMask[0]) || + (mColorMask[1] != currentColorMask[1]) || + (mColorMask[2] != currentColorMask[2]) || + (mColorMask[3] != currentColorMask[3])) + { + glColorMask(mColorMask[0], mColorMask[1], mColorMask[2], mColorMask[3]); + currentColorMask[0] = mColorMask[0]; + currentColorMask[1] = mColorMask[1]; + currentColorMask[2] = mColorMask[2]; + currentColorMask[3] = mColorMask[3]; + } +} + +void FRenderState::ApplyMatrices() +{ + if (GLRenderer->mShaderManager != NULL) + { + GLRenderer->mShaderManager->ApplyMatrices(&mProjectionMatrix, &mViewMatrix); + } +} + +void FRenderState::ApplyLightIndex(int index) +{ + if (GLRenderer->mLights->GetBufferType() == GL_UNIFORM_BUFFER && index > -1) + { + index = GLRenderer->mLights->BindUBO(index); + } + activeShader->muLightIndex.Set(index); +} \ No newline at end of file diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h new file mode 100644 index 000000000..aa24072c2 --- /dev/null +++ b/src/gl/renderer/gl_renderstate.h @@ -0,0 +1,384 @@ +#ifndef __GL_RENDERSTATE_H +#define __GL_RENDERSTATE_H + +#include +#include "gl/system/gl_interface.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_matrix.h" +#include "gl/textures/gl_material.h" +#include "c_cvars.h" +#include "r_defs.h" +#include "r_data/r_translate.h" + +class FVertexBuffer; +class FShader; +extern TArray gl_MatrixStack; + +EXTERN_CVAR(Bool, gl_direct_state_change) + +struct FStateVec4 +{ + float vec[4]; + + void Set(float r, float g, float b, float a) + { + vec[0] = r; + vec[1] = g; + vec[2] = b; + vec[3] = a; + } +}; + + +enum EEffect +{ + EFF_NONE=-1, + EFF_FOGBOUNDARY, + EFF_SPHEREMAP, + EFF_BURN, + EFF_STENCIL, + + MAX_EFFECTS +}; + +class FRenderState +{ + bool mTextureEnabled; + bool mFogEnabled; + bool mGlowEnabled; + bool mBrightmapEnabled; + bool mColorMask[4]; + bool currentColorMask[4]; + int mLightIndex; + int mSpecialEffect; + int mTextureMode; + int mDesaturation; + int mSoftLight; + float mLightParms[4]; + int mSrcBlend, mDstBlend; + float mAlphaThreshold; + int mBlendEquation; + bool mAlphaTest; + bool m2D; + bool mModelMatrixEnabled; + bool mTextureMatrixEnabled; + float mInterpolationFactor; + float mClipHeightTop, mClipHeightBottom; + float mShaderTimer; + bool mLastDepthClamp; + + FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; + FStateVec4 mColor; + FStateVec4 mCameraPos; + FStateVec4 mGlowTop, mGlowBottom; + FStateVec4 mGlowTopPlane, mGlowBottomPlane; + PalEntry mFogColor; + PalEntry mObjectColor; + FStateVec4 mDynColor; + float mClipSplit[2]; + + int mEffectState; + int mColormapState; + + float stAlphaThreshold; + int stSrcBlend, stDstBlend; + bool stAlphaTest; + int stBlendEquation; + + FShader *activeShader; + + bool ApplyShader(); + +public: + + VSMatrix mProjectionMatrix; + VSMatrix mViewMatrix; + VSMatrix mModelMatrix; + VSMatrix mTextureMatrix; + + FRenderState() + { + Reset(); + } + + void Reset(); + + void SetMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader, bool alphatexture) + { + // textures without their own palette are a special case for use as an alpha texture: + // They use the color index directly as an alpha value instead of using the palette's red. + // To handle this case, we need to set a special translation for such textures. + if (alphatexture) + { + if (mat->tex->UseBasePalette()) translation = TRANSLATION(TRANSLATION_Standard, 8); + } + mEffectState = overrideshader >= 0? overrideshader : mat->mShaderIndex; + mShaderTimer = mat->tex->gl_info.shaderspeed; + mat->Bind(clampmode, translation); + } + + void Apply(); + void ApplyColorMask(); + void ApplyMatrices(); + void ApplyLightIndex(int index); + + void SetVertexBuffer(FVertexBuffer *vb) + { + mVertexBuffer = vb; + } + + void ResetVertexBuffer() + { + // forces rebinding with the next 'apply' call. + mCurrentVertexBuffer = NULL; + } + + void SetClipHeightTop(float clip) + { + mClipHeightTop = clip; + } + + float GetClipHeightTop() + { + return mClipHeightTop; + } + + void SetClipHeightBottom(float clip) + { + mClipHeightBottom = clip; + } + + float GetClipHeightBottom() + { + return mClipHeightBottom; + } + + void SetColor(float r, float g, float b, float a = 1.f, int desat = 0) + { + mColor.Set(r, g, b, a); + mDesaturation = desat; + } + + void SetColor(PalEntry pe, int desat = 0) + { + mColor.Set(pe.r/255.f, pe.g/255.f, pe.b/255.f, pe.a/255.f); + mDesaturation = desat; + } + + void SetColorAlpha(PalEntry pe, float alpha = 1.f, int desat = 0) + { + mColor.Set(pe.r/255.f, pe.g/255.f, pe.b/255.f, alpha); + mDesaturation = desat; + } + + void ResetColor() + { + mColor.Set(1,1,1,1); + mDesaturation = 0; + } + + void GetColorMask(bool& r, bool &g, bool& b, bool& a) const + { + r = mColorMask[0]; + g = mColorMask[1]; + b = mColorMask[2]; + a = mColorMask[3]; + } + + void SetColorMask(bool r, bool g, bool b, bool a) + { + mColorMask[0] = r; + mColorMask[1] = g; + mColorMask[2] = b; + mColorMask[3] = a; + } + + void ResetColorMask() + { + for (int i = 0; i < 4; ++i) + mColorMask[i] = true; + } + + void SetTextureMode(int mode) + { + mTextureMode = mode; + } + + int GetTextureMode() + { + return mTextureMode; + } + + void EnableTexture(bool on) + { + mTextureEnabled = on; + } + + void EnableFog(bool on) + { + mFogEnabled = on; + } + + void SetEffect(int eff) + { + mSpecialEffect = eff; + } + + void EnableGlow(bool on) + { + mGlowEnabled = on; + } + + void SetLightIndex(int n) + { + mLightIndex = n; + } + + void EnableBrightmap(bool on) + { + mBrightmapEnabled = on; + } + + void EnableModelMatrix(bool on) + { + mModelMatrixEnabled = on; + } + + void EnableTextureMatrix(bool on) + { + mTextureMatrixEnabled = on; + } + + void SetCameraPos(float x, float y, float z) + { + mCameraPos.Set(x, z, y, 0); + } + + void SetGlowParams(float *t, float *b) + { + mGlowTop.Set(t[0], t[1], t[2], t[3]); + mGlowBottom.Set(b[0], b[1], b[2], b[3]); + } + + void SetSoftLightLevel(int level) + { + if (glset.lightmode == 8) mLightParms[3] = level / 255.f; + else mLightParms[3] = -1.f; + } + + void SetGlowPlanes(const secplane_t &top, const secplane_t &bottom) + { + mGlowTopPlane.Set(FIXED2FLOAT(top.a), FIXED2FLOAT(top.b), FIXED2FLOAT(top.ic), FIXED2FLOAT(top.d)); + mGlowBottomPlane.Set(FIXED2FLOAT(bottom.a), FIXED2FLOAT(bottom.b), FIXED2FLOAT(bottom.ic), FIXED2FLOAT(bottom.d)); + } + + void SetDynLight(float r, float g, float b) + { + mDynColor.Set(r, g, b, 0); + } + + void SetObjectColor(PalEntry pe) + { + mObjectColor = pe; + } + + void SetFog(PalEntry c, float d) + { + const float LOG2E = 1.442692f; // = 1/log(2) + mFogColor = c; + if (d >= 0.0f) mLightParms[2] = d * (-LOG2E / 64000.f); + } + + void SetLightParms(float f, float d) + { + mLightParms[1] = f; + mLightParms[0] = d; + } + + void SetFixedColormap(int cm) + { + mColormapState = cm; + } + + PalEntry GetFogColor() const + { + return mFogColor; + } + + void SetClipSplit(float bottom, float top) + { + mClipSplit[0] = bottom; + mClipSplit[1] = top; + } + + void SetClipSplit(float *vals) + { + memcpy(mClipSplit, vals, 2 * sizeof(float)); + } + + void GetClipSplit(float *out) + { + memcpy(out, mClipSplit, 2 * sizeof(float)); + } + + void ClearClipSplit() + { + mClipSplit[0] = -1000000.f; + mClipSplit[1] = 1000000.f; + } + + void BlendFunc(int src, int dst) + { + if (!gl_direct_state_change) + { + mSrcBlend = src; + mDstBlend = dst; + } + else + { + glBlendFunc(src, dst); + } + } + + void AlphaFunc(int func, float thresh) + { + if (func == GL_GREATER) mAlphaThreshold = thresh; + else mAlphaThreshold = thresh - 0.001f; + } + + void BlendEquation(int eq) + { + if (!gl_direct_state_change) + { + mBlendEquation = eq; + } + else + { + glBlendEquation(eq); + } + } + + // This wraps the depth clamp setting because we frequently need to read it which OpenGL is not particularly performant at... + bool SetDepthClamp(bool on) + { + bool res = mLastDepthClamp; + if (!on) glDisable(GL_DEPTH_CLAMP); + else glEnable(GL_DEPTH_CLAMP); + mLastDepthClamp = on; + return res; + } + + void Set2DMode(bool on) + { + m2D = on; + } + + void SetInterpolationFactor(float fac) + { + mInterpolationFactor = fac; + } +}; + +extern FRenderState gl_RenderState; + +#endif diff --git a/src/gl/scene/gl_bsp.cpp b/src/gl/scene/gl_bsp.cpp new file mode 100644 index 000000000..dd6df8287 --- /dev/null +++ b/src/gl/scene/gl_bsp.cpp @@ -0,0 +1,525 @@ +/* +** gl_bsp.cpp +** Main rendering loop / BSP traversal / visibility clipping +** +**--------------------------------------------------------------------------- +** Copyright 2000-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "p_lnspec.h" +#include "p_local.h" +#include "a_sharedglobal.h" +#include "r_sky.h" +#include "p_effect.h" +#include "po_man.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/scene/gl_clipper.h" +#include "gl/scene/gl_portal.h" +#include "gl/scene/gl_wall.h" +#include "gl/utility/gl_clock.h" + +EXTERN_CVAR(Bool, gl_render_segs) + +Clipper clipper; + + +CVAR(Bool, gl_render_things, true, 0) +CVAR(Bool, gl_render_walls, true, 0) +CVAR(Bool, gl_render_flats, true, 0) + + +static void UnclipSubsector(subsector_t *sub) +{ + int count = sub->numlines; + seg_t * seg = sub->firstline; + + while (count--) + { + angle_t startAngle = seg->v2->GetClipAngle(); + angle_t endAngle = seg->v1->GetClipAngle(); + + // Back side, i.e. backface culling - read: endAngle >= startAngle! + if (startAngle-endAngle >= ANGLE_180) + { + clipper.SafeRemoveClipRange(startAngle, endAngle); + } + seg++; + } +} + +//========================================================================== +// +// R_AddLine +// Clips the given segment +// and adds any visible pieces to the line list. +// +//========================================================================== + +// making these 2 variables global instead of passing them as function parameters is faster. +static subsector_t *currentsubsector; +static sector_t *currentsector; + +static void AddLine (seg_t *seg) +{ +#ifdef _DEBUG + if (seg->linedef - lines == 38) + { + int a = 0; + } +#endif + + angle_t startAngle, endAngle; + sector_t * backsector = NULL; + sector_t bs; + + if (GLRenderer->mCurrentPortal) + { + int clipres = GLRenderer->mCurrentPortal->ClipSeg(seg); + if (clipres == GLPortal::PClip_InFront) return; + } + + startAngle = seg->v2->GetClipAngle(); + endAngle = seg->v1->GetClipAngle(); + + // Back side, i.e. backface culling - read: endAngle >= startAngle! + if (startAngle-endAnglesidedef == NULL) + { + if (!(currentsubsector->flags & SSECF_DRAWN)) + { + if (clipper.SafeCheckRange(startAngle, endAngle)) + { + currentsubsector->flags |= SSECF_DRAWN; + } + } + return; + } + + if (!clipper.SafeCheckRange(startAngle, endAngle)) + { + return; + } + currentsubsector->flags |= SSECF_DRAWN; + + if (!seg->backsector) + { + clipper.SafeAddClipRange(startAngle, endAngle); + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) // Two-sided polyobjects never obstruct the view + { + if (currentsector->sectornum == seg->backsector->sectornum) + { + FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); + if (!tex || tex->UseType==FTexture::TEX_Null) + { + // nothing to do here! + seg->linedef->validcount=validcount; + return; + } + backsector=currentsector; + } + else + { + // clipping checks are only needed when the backsector is not the same as the front sector + gl_CheckViewArea(seg->v1, seg->v2, seg->frontsector, seg->backsector); + + backsector = gl_FakeFlat(seg->backsector, &bs, true); + + if (gl_CheckClip(seg->sidedef, currentsector, backsector)) + { + clipper.SafeAddClipRange(startAngle, endAngle); + } + } + } + else + { + // Backsector for polyobj segs is always the containing sector itself + backsector = currentsector; + } + + seg->linedef->flags |= ML_MAPPED; + + if ((seg->sidedef->Flags & WALLF_POLYOBJ) || seg->linedef->validcount!=validcount) + { + if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) seg->linedef->validcount=validcount; + + if (gl_render_walls) + { + SetupWall.Clock(); + + GLWall wall; + wall.sub = currentsubsector; + wall.Process(seg, currentsector, backsector); + rendered_lines++; + + SetupWall.Unclock(); + } + } +} + +//========================================================================== +// +// R_Subsector +// Determine floor/ceiling planes. +// Add sprites of things in sector. +// Draw one or more line segments. +// +//========================================================================== + +static void PolySubsector(subsector_t * sub) +{ + int count = sub->numlines; + seg_t * line = sub->firstline; + + while (count--) + { + if (line->linedef) + { + AddLine (line); + } + line++; + } +} + +//========================================================================== +// +// RenderBSPNode +// Renders all subsectors below a given node, +// traversing subtree recursively. +// Just call with BSP root. +// +//========================================================================== + +static void RenderPolyBSPNode (void *node) +{ + while (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + + // Decide which side the view point is on. + int side = R_PointOnSide(viewx, viewy, bsp); + + // Recursively divide front space (toward the viewer). + RenderPolyBSPNode (bsp->children[side]); + + // Possibly divide back space (away from the viewer). + side ^= 1; + + // It is not necessary to use the slower precise version here + if (!clipper.CheckBox(bsp->bbox[side])) + { + return; + } + + node = bsp->children[side]; + } + PolySubsector ((subsector_t *)((BYTE *)node - 1)); +} + +//========================================================================== +// +// Unlilke the software renderer this function will only draw the walls, +// not the flats. Those are handled as a whole by the parent subsector. +// +//========================================================================== + +static void AddPolyobjs(subsector_t *sub) +{ + if (sub->BSP == NULL || sub->BSP->bDirty) + { + sub->BuildPolyBSP(); + for (unsigned i = 0; i < sub->BSP->Segs.Size(); i++) + { + sub->BSP->Segs[i].Subsector = sub; + sub->BSP->Segs[i].PartnerSeg = NULL; + } + } + if (sub->BSP->Nodes.Size() == 0) + { + PolySubsector(&sub->BSP->Subsectors[0]); + } + else + { + RenderPolyBSPNode(&sub->BSP->Nodes.Last()); + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +static inline void AddLines(subsector_t * sub, sector_t * sector) +{ + currentsector = sector; + currentsubsector = sub; + + ClipWall.Clock(); + if (sub->polys != NULL) + { + AddPolyobjs(sub); + } + else + { + int count = sub->numlines; + seg_t * seg = sub->firstline; + + while (count--) + { + if (seg->linedef == NULL) + { + if (!(sub->flags & SSECF_DRAWN)) AddLine (seg); + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + AddLine (seg); + } + seg++; + } + } + ClipWall.Unclock(); +} + + +//========================================================================== +// +// R_RenderThings +// +//========================================================================== + +static inline void RenderThings(subsector_t * sub, sector_t * sector) +{ + + SetupSprite.Clock(); + sector_t * sec=sub->sector; + if (sec->thinglist != NULL) + { + // Handle all things in sector. + for (AActor * thing = sec->thinglist; thing; thing = thing->snext) + { + GLRenderer->ProcessSprite(thing, sector); + } + } + SetupSprite.Unclock(); +} + + +//========================================================================== +// +// R_Subsector +// Determine floor/ceiling planes. +// Add sprites of things in sector. +// Draw one or more line segments. +// +//========================================================================== + +static void DoSubsector(subsector_t * sub) +{ + unsigned int i; + sector_t * sector; + sector_t * fakesector; + sector_t fake; + + // check for visibility of this entire subsector. This requires GL nodes. + // (disabled because it costs more time than it saves.) + //if (!clipper.CheckBox(sub->bbox)) return; + + +#ifdef _DEBUG + if (sub->sector-sectors==931) + { + int a = 0; + } +#endif + + sector=sub->sector; + if (!sector) return; + + // If the mapsections differ this subsector can't possibly be visible from the current view point + if (!(currentmapsection[sub->mapsection>>3] & (1 << (sub->mapsection & 7)))) return; + + if (gl_drawinfo->ss_renderflags[sub-subsectors] & SSRF_SEEN) + { + // This means that we have reached a subsector in a portal that has been marked 'seen' + // from the other side of the portal. This means we must clear the clipper for the + // range this subsector spans before going on. + UnclipSubsector(sub); + } + + fakesector=gl_FakeFlat(sector, &fake, false); + + if (sector->validcount != validcount) + { + GLRenderer->mVBO->CheckUpdate(sector); + } + + // [RH] Add particles + //int shade = LIGHT2SHADE((floorlightlevel + ceilinglightlevel)/2 + r_actualextralight); + if (gl_render_things) + { + SetupSprite.Clock(); + + for (i = ParticlesInSubsec[DWORD(sub-subsectors)]; i != NO_PARTICLE; i = Particles[i].snext) + { + GLRenderer->ProcessParticle(&Particles[i], fakesector); + } + SetupSprite.Unclock(); + } + + AddLines(sub, fakesector); + + // BSP is traversed by subsector. + // A sector might have been split into several + // subsectors during BSP building. + // Thus we check whether it was already added. + if (sector->validcount != validcount) + { + // Well, now it will be done. + sector->validcount = validcount; + + if (gl_render_things) + { + RenderThings(sub, fakesector); + } + sector->MoreFlags |= SECF_DRAWN; + } + + if (gl_render_flats) + { + // Subsectors with only 2 lines cannot have any area! + if (sub->numlines>2 || (sub->hacked&1)) + { + // Exclude the case when it tries to render a sector with a heightsec + // but undetermined heightsec state. This can only happen if the + // subsector is obstructed but not excluded due to a large bounding box. + // Due to the way a BSP works such a subsector can never be visible + if (!sector->heightsec || sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC || in_area!=area_default) + { + if (sector != sub->render_sector) + { + sector = sub->render_sector; + // the planes of this subsector are faked to belong to another sector + // This means we need the heightsec parts and light info of the render sector, not the actual one. + fakesector = gl_FakeFlat(sector, &fake, false); + } + + BYTE &srf = gl_drawinfo->sectorrenderflags[sub->render_sector->sectornum]; + if (!(srf & SSRF_PROCESSED)) + { + srf |= SSRF_PROCESSED; + + SetupFlat.Clock(); + GLRenderer->ProcessSector(fakesector); + SetupFlat.Unclock(); + } + // mark subsector as processed - but mark for rendering only if it has an actual area. + gl_drawinfo->ss_renderflags[sub-subsectors] = + (sub->numlines > 2) ? SSRF_PROCESSED|SSRF_RENDERALL : SSRF_PROCESSED; + if (sub->hacked & 1) gl_drawinfo->AddHackedSubsector(sub); + + FPortal *portal; + + portal = fakesector->portals[sector_t::ceiling]; + if (portal != NULL) + { + GLSectorStackPortal *glportal = portal->GetGLPortal(); + glportal->AddSubsector(sub); + } + + portal = fakesector->portals[sector_t::floor]; + if (portal != NULL) + { + GLSectorStackPortal *glportal = portal->GetGLPortal(); + glportal->AddSubsector(sub); + } + } + } + } +} + + + + +//========================================================================== +// +// RenderBSPNode +// Renders all subsectors below a given node, +// traversing subtree recursively. +// Just call with BSP root. +// +//========================================================================== + +void gl_RenderBSPNode (void *node) +{ + if (numnodes == 0) + { + DoSubsector (subsectors); + return; + } + while (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + + // Decide which side the view point is on. + int side = R_PointOnSide(viewx, viewy, bsp); + + // Recursively divide front space (toward the viewer). + gl_RenderBSPNode (bsp->children[side]); + + // Possibly divide back space (away from the viewer). + side ^= 1; + + // It is not necessary to use the slower precise version here + if (!clipper.CheckBox(bsp->bbox[side])) + { + if (!(gl_drawinfo->no_renderflags[bsp-nodes] & SSRF_SEEN)) + return; + } + + node = bsp->children[side]; + } + DoSubsector ((subsector_t *)((BYTE *)node - 1)); +} + + diff --git a/src/gl/scene/gl_clipper.cpp b/src/gl/scene/gl_clipper.cpp new file mode 100644 index 000000000..c6f8d9019 --- /dev/null +++ b/src/gl/scene/gl_clipper.cpp @@ -0,0 +1,458 @@ +/* +* +** gl_clipper.cpp +** +** Handles visibility checks. +** Loosely based on the JDoom clipper. +** +**--------------------------------------------------------------------------- +** Copyright 2003 Tim Stump +** 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 "gl/scene/gl_clipper.h" + + + +ClipNode * ClipNode::freelist; +int Clipper::anglecache; + + +//----------------------------------------------------------------------------- +// +// Destructor +// +//----------------------------------------------------------------------------- + +Clipper::~Clipper() +{ + Clear(); + while (ClipNode::freelist != NULL) + { + ClipNode * node = ClipNode::freelist; + ClipNode::freelist = node->next; + delete node; + } +} + +//----------------------------------------------------------------------------- +// +// RemoveRange +// +//----------------------------------------------------------------------------- + +void Clipper::RemoveRange(ClipNode * range) +{ + if (range == cliphead) + { + cliphead = cliphead->next; + } + else + { + if (range->prev) range->prev->next = range->next; + if (range->next) range->next->prev = range->prev; + } + + range->Free(); +} + +//----------------------------------------------------------------------------- +// +// Clear +// +//----------------------------------------------------------------------------- + +void Clipper::Clear() +{ + ClipNode *node = cliphead; + ClipNode *temp; + + while (node != NULL) + { + temp = node; + node = node->next; + temp->Free(); + } + node = silhouette; + + while (node != NULL) + { + temp = node; + node = node->next; + temp->Free(); + } + + cliphead = NULL; + silhouette = NULL; + anglecache++; +} + +//----------------------------------------------------------------------------- +// +// SetSilhouette +// +//----------------------------------------------------------------------------- + +void Clipper::SetSilhouette() +{ + ClipNode *node = cliphead; + ClipNode *last = NULL; + + while (node != NULL) + { + ClipNode *snode = ClipNode::NewRange(node->start, node->end); + if (silhouette == NULL) silhouette = snode; + snode->prev = last; + if (last != NULL) last->next = snode; + last = snode; + node = node->next; + } +} + + +//----------------------------------------------------------------------------- +// +// IsRangeVisible +// +//----------------------------------------------------------------------------- + +bool Clipper::IsRangeVisible(angle_t startAngle, angle_t endAngle) +{ + ClipNode *ci; + ci = cliphead; + + if (endAngle==0 && ci && ci->start==0) return false; + + while (ci != NULL && ci->start < endAngle) + { + if (startAngle >= ci->start && endAngle <= ci->end) + { + return false; + } + ci = ci->next; + } + + return true; +} + +//----------------------------------------------------------------------------- +// +// AddClipRange +// +//----------------------------------------------------------------------------- + +void Clipper::AddClipRange(angle_t start, angle_t end) +{ + ClipNode *node, *temp, *prevNode; + + if (cliphead) + { + //check to see if range contains any old ranges + node = cliphead; + while (node != NULL && node->start < end) + { + if (node->start >= start && node->end <= end) + { + temp = node; + node = node->next; + RemoveRange(temp); + } + else if (node->start<=start && node->end>=end) + { + return; + } + else + { + node = node->next; + } + } + + //check to see if range overlaps a range (or possibly 2) + node = cliphead; + while (node != NULL && node->start <= end) + { + if (node->end >= start) + { + // we found the first overlapping node + if (node->start > start) + { + // the new range overlaps with this node's start point + node->start = start; + } + + if (node->end < end) + { + node->end = end; + } + + ClipNode *node2 = node->next; + while (node2 && node2->start <= node->end) + { + if (node2->end > node->end) node->end = node2->end; + ClipNode *delnode = node2; + node2 = node2->next; + RemoveRange(delnode); + } + return; + } + node = node->next; + } + + //just add range + node = cliphead; + prevNode = NULL; + temp = ClipNode::NewRange(start, end); + + while (node != NULL && node->start < end) + { + prevNode = node; + node = node->next; + } + + temp->next = node; + if (node == NULL) + { + temp->prev = prevNode; + if (prevNode) prevNode->next = temp; + if (!cliphead) cliphead = temp; + } + else + { + if (node == cliphead) + { + cliphead->prev = temp; + cliphead = temp; + } + else + { + temp->prev = prevNode; + prevNode->next = temp; + node->prev = temp; + } + } + } + else + { + temp = ClipNode::NewRange(start, end); + cliphead = temp; + return; + } +} + + +//----------------------------------------------------------------------------- +// +// RemoveClipRange +// +//----------------------------------------------------------------------------- + +void Clipper::RemoveClipRange(angle_t start, angle_t end) +{ + ClipNode *node; + + if (silhouette) + { + node = silhouette; + while (node != NULL && node->end <= start) + { + node = node->next; + } + if (node != NULL && node->start <= start) + { + if (node->end >= end) return; + start = node->end; + node = node->next; + } + while (node != NULL && node->start < end) + { + DoRemoveClipRange(start, node->start); + start = node->end; + node = node->next; + } + if (start >= end) return; + } + DoRemoveClipRange(start, end); +} + +//----------------------------------------------------------------------------- +// +// RemoveClipRange worker function +// +//----------------------------------------------------------------------------- + +void Clipper::DoRemoveClipRange(angle_t start, angle_t end) +{ + ClipNode *node, *temp; + + if (cliphead) + { + //check to see if range contains any old ranges + node = cliphead; + while (node != NULL && node->start < end) + { + if (node->start >= start && node->end <= end) + { + temp = node; + node = node->next; + RemoveRange(temp); + } + else + { + node = node->next; + } + } + + //check to see if range overlaps a range (or possibly 2) + node = cliphead; + while (node != NULL) + { + if (node->start >= start && node->start <= end) + { + node->start = end; + break; + } + else if (node->end >= start && node->end <= end) + { + node->end=start; + } + else if (node->start < start && node->end > end) + { + temp=ClipNode::NewRange(end, node->end); + node->end=start; + temp->next=node->next; + temp->prev=node; + node->next=temp; + if (temp->next) temp->next->prev=temp; + break; + } + node = node->next; + } + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +angle_t Clipper::AngleToPseudo(angle_t ang) +{ + double vecx = cos(ang * M_PI / ANGLE_180); + double vecy = sin(ang * M_PI / ANGLE_180); + + double result = vecy / (fabs(vecx) + fabs(vecy)); + if (vecx < 0) + { + result = 2.f - result; + } + return xs_Fix<30>::ToFix(result); +} + +//----------------------------------------------------------------------------- +// +// ! Returns the pseudoangle between the line p1 to (infinity, p1.y) and the +// line from p1 to p2. The pseudoangle has the property that the ordering of +// points by true angle anround p1 and ordering of points by pseudoangle are the +// same. +// +// For clipping exact angles are not needed. Only the ordering matters. +// This is about as fast as the fixed point R_PointToAngle2 but without +// the precision issues associated with that function. +// +//----------------------------------------------------------------------------- + +angle_t R_PointToPseudoAngle (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y) +{ + // Note: float won't work here as it's less precise than the BAM values being passed as parameters + double vecx = double(x-viewx); + double vecy = double(y-viewy); + + if (vecx == 0 && vecy == 0) + { + return 0; + } + else + { + double result = vecy / (fabs(vecx) + fabs(vecy)); + if (vecx < 0) + { + result = 2.f - result; + } + return xs_Fix<30>::ToFix(result); + } +} + + + + +//----------------------------------------------------------------------------- +// +// R_CheckBBox +// Checks BSP node/subtree bounding box. +// Returns true +// if some part of the bbox might be visible. +// +//----------------------------------------------------------------------------- + static const int checkcoord[12][4] = // killough -- static const + { + {3,0,2,1}, + {3,0,2,0}, + {3,1,2,0}, + {0}, + {2,0,2,1}, + {0,0,0,0}, + {3,1,3,0}, + {0}, + {2,0,3,1}, + {2,1,3,1}, + {2,1,3,0} + }; + +bool Clipper::CheckBox(const fixed_t *bspcoord) +{ + angle_t angle1, angle2; + + int boxpos; + const int* check; + + // Find the corners of the box + // that define the edges from current viewpoint. + boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT ] ? 1 : 2) + + (viewy >= bspcoord[BOXTOP ] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); + + if (boxpos == 5) return true; + + check = checkcoord[boxpos]; + angle1 = R_PointToPseudoAngle (viewx, viewy, bspcoord[check[0]], bspcoord[check[1]]); + angle2 = R_PointToPseudoAngle (viewx, viewy, bspcoord[check[2]], bspcoord[check[3]]); + + return SafeCheckRange(angle2, angle1); +} + diff --git a/src/gl/scene/gl_clipper.h b/src/gl/scene/gl_clipper.h new file mode 100644 index 000000000..637839f4f --- /dev/null +++ b/src/gl/scene/gl_clipper.h @@ -0,0 +1,152 @@ +#ifndef __GL_CLIPPER +#define __GL_CLIPPER + +#include "doomtype.h" +#include "tables.h" +#include "xs_Float.h" +#include "r_utility.h" + +class ClipNode +{ + friend class Clipper; + friend class ClipNodesFreer; + + ClipNode *prev, *next; + angle_t start, end; + static ClipNode * freelist; + + bool operator== (const ClipNode &other) + { + return other.start == start && other.end == end; + } + + void Free() + { + next=freelist; + freelist=this; + } + + static ClipNode * GetNew() + { + if (freelist) + { + ClipNode * p=freelist; + freelist=p->next; + return p; + } + else return new ClipNode; + } + + static ClipNode * NewRange(angle_t start, angle_t end) + { + ClipNode * c=GetNew(); + + c->start=start; + c->end=end; + c->next=c->prev=NULL; + return c; + } + +}; + + +class Clipper +{ + ClipNode * clipnodes; + ClipNode * cliphead; + ClipNode * silhouette; // will be preserved even when RemoveClipRange is called + + static angle_t AngleToPseudo(angle_t ang); + bool IsRangeVisible(angle_t startangle, angle_t endangle); + void RemoveRange(ClipNode * cn); + void AddClipRange(angle_t startangle, angle_t endangle); + void RemoveClipRange(angle_t startangle, angle_t endangle); + void DoRemoveClipRange(angle_t start, angle_t end); + +public: + + static int anglecache; + + Clipper() + { + clipnodes=cliphead=NULL; + } + + ~Clipper(); + + void Clear(); + + + void SetSilhouette(); + + bool SafeCheckRange(angle_t startAngle, angle_t endAngle) + { + if(startAngle > endAngle) + { + return (IsRangeVisible(startAngle, ANGLE_MAX) || IsRangeVisible(0, endAngle)); + } + + return IsRangeVisible(startAngle, endAngle); + } + + void SafeAddClipRange(angle_t startangle, angle_t endangle) + { + if(startangle > endangle) + { + // The range has to added in two parts. + AddClipRange(startangle, ANGLE_MAX); + AddClipRange(0, endangle); + } + else + { + // Add the range as usual. + AddClipRange(startangle, endangle); + } + } + + void SafeAddClipRangeRealAngles(angle_t startangle, angle_t endangle) + { + SafeAddClipRange(AngleToPseudo(startangle), AngleToPseudo(endangle)); + } + + + void SafeRemoveClipRange(angle_t startangle, angle_t endangle) + { + if(startangle > endangle) + { + // The range has to added in two parts. + RemoveClipRange(startangle, ANGLE_MAX); + RemoveClipRange(0, endangle); + } + else + { + // Add the range as usual. + RemoveClipRange(startangle, endangle); + } + } + + void SafeRemoveClipRangeRealAngles(angle_t startangle, angle_t endangle) + { + SafeRemoveClipRange(AngleToPseudo(startangle), AngleToPseudo(endangle)); + } + + bool CheckBox(const fixed_t *bspcoord); +}; + + +extern Clipper clipper; + +angle_t R_PointToPseudoAngle (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y); + +inline angle_t R_PointToAnglePrecise (fixed_t viewx, fixed_t viewy, fixed_t x, fixed_t y) +{ + return xs_RoundToUInt(atan2(double(y-viewy), double(x-viewx)) * (ANGLE_180/M_PI)); +} + +// Used to speed up angle calculations during clipping +inline angle_t vertex_t::GetClipAngle() +{ + return angletime == Clipper::anglecache? viewangle : (angletime = Clipper::anglecache, viewangle = R_PointToPseudoAngle(viewx, viewy, x,y)); +} + +#endif \ No newline at end of file diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp new file mode 100644 index 000000000..7cc766cd0 --- /dev/null +++ b/src/gl/scene/gl_decal.cpp @@ -0,0 +1,363 @@ +/* +** gl_decal.cpp +** OpenGL decal rendering code +** +**--------------------------------------------------------------------------- +** Copyright 2003-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "doomdata.h" +#include "gl/system/gl_system.h" +#include "a_sharedglobal.h" +#include "r_utility.h" + +#include "gl/system/gl_cvars.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" + +struct DecalVertex +{ + float x,y,z; + float u,v; +}; + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::DrawDecal(DBaseDecal *decal) +{ + line_t * line=seg->linedef; + side_t * side=seg->sidedef; + int i; + fixed_t zpos; + int light; + int rel; + float a; + bool flipx, flipy; + DecalVertex dv[4]; + FTextureID decalTile; + + + if (decal->RenderFlags & RF_INVISIBLE) return; + if (type==RENDERWALL_FFBLOCK && gltexture->isMasked()) return; // No decals on 3D floors with transparent textures. + + //if (decal->sprite != 0xffff) + { + decalTile = decal->PicNum; + flipx = !!(decal->RenderFlags & RF_XFLIP); + flipy = !!(decal->RenderFlags & RF_YFLIP); + } + /* + else + { + decalTile = SpriteFrames[sprites[decal->sprite].spriteframes + decal->frame].lump[0]; + flipx = SpriteFrames[sprites[decal->sprite].spriteframes + decal->frame].flip & 1; + } + */ + + FTexture *texture = TexMan[decalTile]; + if (texture == NULL) return; + + FMaterial *tex; + + + tex = FMaterial::ValidateTexture(texture, true); + + + // the sectors are only used for their texture origin coordinates + // so we don't need the fake sectors for deep water etc. + // As this is a completely split wall fragment no further splits are + // necessary for the decal. + sector_t *frontsector; + + // for 3d-floor segments use the model sector as reference + if ((decal->RenderFlags&RF_CLIPMASK)==RF_CLIPMID) frontsector=decal->Sector; + else frontsector=seg->frontsector; + + switch (decal->RenderFlags & RF_RELMASK) + { + default: + // No valid decal can have this type. If one is encountered anyway + // it is in some way invalid so skip it. + return; + //zpos = decal->z; + //break; + + case RF_RELUPPER: + if (type!=RENDERWALL_TOP) return; + if (line->flags & ML_DONTPEGTOP) + { + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); + } + else + { + zpos = decal->Z + seg->backsector->GetPlaneTexZ(sector_t::ceiling); + } + break; + case RF_RELLOWER: + if (type!=RENDERWALL_BOTTOM) return; + if (line->flags & ML_DONTPEGBOTTOM) + { + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); + } + else + { + zpos = decal->Z + seg->backsector->GetPlaneTexZ(sector_t::floor); + } + break; + case RF_RELMID: + if (type==RENDERWALL_TOP || type==RENDERWALL_BOTTOM) return; + if (line->flags & ML_DONTPEGBOTTOM) + { + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::floor); + } + else + { + zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); + } + } + + if (decal->RenderFlags & RF_FULLBRIGHT) + { + light = 255; + rel = 0; + } + else + { + light = lightlevel; + rel = rellight + getExtraLight(); + } + + FColormap p = Colormap; + + if (glset.nocoloredspritelighting) + { + p.Decolorize(); + } + + + + a = FIXED2FLOAT(decal->Alpha); + + // now clip the decal to the actual polygon + float decalwidth = tex->TextureWidth() * FIXED2FLOAT(decal->ScaleX); + float decalheight= tex->TextureHeight() * FIXED2FLOAT(decal->ScaleY); + float decallefto = tex->GetLeftOffset() * FIXED2FLOAT(decal->ScaleX); + float decaltopo = tex->GetTopOffset() * FIXED2FLOAT(decal->ScaleY); + + + float leftedge = glseg.fracleft * side->TexelLength; + float linelength = glseg.fracright * side->TexelLength - leftedge; + + // texel index of the decal's left edge + float decalpixpos = (float)side->TexelLength * decal->LeftDistance / (1<<30) - (flipx? decalwidth-decallefto : decallefto) - leftedge; + + float left,right; + float lefttex,righttex; + + // decal is off the left edge + if (decalpixpos < 0) + { + left = 0; + lefttex = -decalpixpos; + } + else + { + left = decalpixpos; + lefttex = 0; + } + + // decal is off the right edge + if (decalpixpos + decalwidth > linelength) + { + right = linelength; + righttex = right - decalpixpos; + } + else + { + right = decalpixpos + decalwidth; + righttex = decalwidth; + } + if (right<=left) return; // nothing to draw + + // one texture unit on the wall as vector + float vx=(glseg.x2-glseg.x1)/linelength; + float vy=(glseg.y2-glseg.y1)/linelength; + + dv[1].x=dv[0].x=glseg.x1+vx*left; + dv[1].y=dv[0].y=glseg.y1+vy*left; + + dv[3].x=dv[2].x=glseg.x1+vx*right; + dv[3].y=dv[2].y=glseg.y1+vy*right; + + zpos+= FRACUNIT*(flipy? decalheight-decaltopo : decaltopo); + + dv[1].z=dv[2].z = FIXED2FLOAT(zpos); + dv[0].z=dv[3].z = dv[1].z - decalheight; + dv[1].v=dv[2].v = tex->GetVT(); + + dv[1].u=dv[0].u = tex->GetU(lefttex / FIXED2FLOAT(decal->ScaleX)); + dv[3].u=dv[2].u = tex->GetU(righttex / FIXED2FLOAT(decal->ScaleX)); + dv[0].v=dv[3].v = tex->GetVB(); + + + // now clip to the top plane + float vzt=(ztop[1]-ztop[0])/linelength; + float topleft=this->ztop[0]+vzt*left; + float topright=this->ztop[0]+vzt*right; + + // completely below the wall + if (topleftzbottom[0]+vzb*left; + float bottomright=this->zbottom[0]+vzb*right; + + // completely above the wall + if (bottomleft>dv[1].z && bottomright>dv[2].z) + return; + + if (bottomleft>dv[0].z || bottomright>dv[3].z) + { + // decal has to be clipped at the bottom + // let texture clamping handle all extreme cases + dv[0].v=(dv[1].z-bottomleft)/(dv[1].z-dv[0].z)*(dv[0].v-dv[1].v) + dv[1].v; + dv[3].v=(dv[2].z-bottomright)/(dv[2].z-dv[3].z)*(dv[3].v-dv[2].v) + dv[2].v; + dv[0].z=bottomleft; + dv[3].z=bottomright; + } + + + if (flipx) + { + float ur = tex->GetUR(); + for(i=0;i<4;i++) dv[i].u=ur-dv[i].u; + } + if (flipy) + { + float vb = tex->GetVB(); + for(i=0;i<4;i++) dv[i].v=vb-dv[i].v; + } + + // calculate dynamic light effect. + if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && gl_light_sprites) + { + // Note: This should be replaced with proper shader based lighting. + fixed_t x, y; + decal->GetXY(seg->sidedef, x, y); + gl_SetDynSpriteLight(NULL, x, y, zpos, sub); + } + + // alpha color only has an effect when using an alpha texture. + if (decal->RenderStyle.Flags & STYLEF_RedIsAlpha) + { + gl_RenderState.SetObjectColor(decal->AlphaColor|0xff000000); + } + + gl_SetColor(light, rel, p, a); + + // for additively drawn decals we must temporarily set the fog color to black. + PalEntry fc = gl_RenderState.GetFogColor(); + if (decal->RenderStyle.BlendOp == STYLEOP_Add && decal->RenderStyle.DestAlpha == STYLEALPHA_One) + { + gl_RenderState.SetFog(0,-1); + } + + + gl_SetRenderStyle(decal->RenderStyle, false, false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, decal->Translation, 0, !!(decal->RenderStyle.Flags & STYLEF_RedIsAlpha)); + + + // If srcalpha is one it looks better with a higher alpha threshold + if (decal->RenderStyle.SrcAlpha == STYLEALPHA_One) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); + else gl_RenderState.AlphaFunc(GL_GREATER, 0.f); + + gl_RenderState.Apply(); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (i = 0; i < 4; i++) + { + ptr->Set(dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); + ptr++; + } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + + rendered_decals++; + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.SetObjectColor(0xffffffff); + gl_RenderState.SetFog(fc,-1); + gl_RenderState.SetDynLight(0,0,0); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::DoDrawDecals() +{ + if (seg->sidedef && seg->sidedef->AttachedDecals) + { + gl_SetFog(lightlevel, rellight + getExtraLight(), &Colormap, false); + DBaseDecal *decal = seg->sidedef->AttachedDecals; + while (decal) + { + DrawDecal(decal); + decal = decal->WallNext; + } + } +} + diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp new file mode 100644 index 000000000..4dba1a2a0 --- /dev/null +++ b/src/gl/scene/gl_drawinfo.cpp @@ -0,0 +1,1254 @@ +/* +** gl_drawinfo.cpp +** Implements the draw info structure which contains most of the +** data in a scene and the draw lists - including a very thorough BSP +** style sorting algorithm for translucent objects. +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "r_sky.h" +#include "r_utility.h" +#include "r_state.h" +#include "doomstat.h" + +#include "gl/system/gl_cvars.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" +#include "gl/shaders/gl_shader.h" +#include "gl/stereo3d/scoped_color_mask.h" + +FDrawInfo * gl_drawinfo; + +//========================================================================== +// +// +// +//========================================================================== +class StaticSortNodeArray : public TDeletingArray +{ + unsigned usecount; +public: + unsigned Size() { return usecount; } + void Clear() { usecount=0; } + void Release(int start) { usecount=start; } + SortNode * GetNew(); +}; + + +SortNode * StaticSortNodeArray::GetNew() +{ + if (usecount==TArray::Size()) + { + Push(new SortNode); + } + return operator[](usecount++); +} + + +static StaticSortNodeArray SortNodes; + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::Reset() +{ + if (sorted) SortNodes.Release(SortNodeStart); + sorted=NULL; + walls.Clear(); + flats.Clear(); + sprites.Clear(); + drawitems.Clear(); +} + + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +// Translucent polygon sorting - uses a BSP algorithm with an additional 'equal' branch + +inline double GLSprite::CalcIntersectionVertex(GLWall * w2) +{ + float ax = x1, ay=y1; + float bx = x2, by=y2; + float cx = w2->glseg.x1, cy=w2->glseg.y1; + float dx = w2->glseg.x2, dy=w2->glseg.y2; + return ((ay-cy)*(dx-cx)-(ax-cx)*(dy-cy)) / ((bx-ax)*(dy-cy)-(by-ay)*(dx-cx)); +} + + + +//========================================================================== +// +// +// +//========================================================================== +inline void SortNode::UnlinkFromChain() +{ + if (parent) parent->next=next; + if (next) next->parent=parent; + parent=next=NULL; +} + +//========================================================================== +// +// +// +//========================================================================== +inline void SortNode::Link(SortNode * hook) +{ + if (hook) + { + parent=hook->parent; + hook->parent=this; + } + next=hook; + if (parent) parent->next=this; +} + +//========================================================================== +// +// +// +//========================================================================== +inline void SortNode::AddToEqual(SortNode *child) +{ + child->UnlinkFromChain(); + child->equal=equal; + equal=child; +} + +//========================================================================== +// +// +// +//========================================================================== +inline void SortNode::AddToLeft(SortNode * child) +{ + child->UnlinkFromChain(); + child->Link(left); + left=child; +} + +//========================================================================== +// +// +// +//========================================================================== +inline void SortNode::AddToRight(SortNode * child) +{ + child->UnlinkFromChain(); + child->Link(right); + right=child; +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::MakeSortList() +{ + SortNode * p, * n, * c; + unsigned i; + + SortNodeStart=SortNodes.Size(); + p=NULL; + n=SortNodes.GetNew(); + for(i=0;iitemindex=(int)i; + n->left=n->equal=n->right=NULL; + n->parent=p; + p=n; + if (i!=drawitems.Size()-1) + { + c=SortNodes.GetNew(); + n->next=c; + n=c; + } + else + { + n->next=NULL; + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== +SortNode * GLDrawList::FindSortPlane(SortNode * head) +{ + while (head->next && drawitems[head->itemindex].rendertype!=GLDIT_FLAT) + head=head->next; + if (drawitems[head->itemindex].rendertype==GLDIT_FLAT) return head; + return NULL; +} + + +//========================================================================== +// +// +// +//========================================================================== +SortNode * GLDrawList::FindSortWall(SortNode * head) +{ + fixed_t farthest=INT_MIN; + fixed_t nearest=INT_MAX; + SortNode * best=NULL; + SortNode * node=head; + fixed_t bestdist=INT_MAX; + + while (node) + { + GLDrawItem * it=&drawitems[node->itemindex]; + if (it->rendertype==GLDIT_WALL) + { + fixed_t d=walls[it->index].viewdistance; + if (d>farthest) farthest=d; + if (dnext; + } + if (farthest==INT_MIN) return NULL; + node=head; + farthest=(farthest+nearest)>>1; + while (node) + { + GLDrawItem * it=&drawitems[node->itemindex]; + if (it->rendertype==GLDIT_WALL) + { + fixed_t di=abs(walls[it->index].viewdistance-farthest); + if (!best || dinext; + } + return best; +} + +//========================================================================== +// +// Note: sloped planes are a huge problem... +// +//========================================================================== +void GLDrawList::SortPlaneIntoPlane(SortNode * head,SortNode * sort) +{ + GLFlat * fh=&flats[drawitems[head->itemindex].index]; + GLFlat * fs=&flats[drawitems[sort->itemindex].index]; + + if (fh->z==fs->z) + head->AddToEqual(sort); + else if ( (fh->zz && fh->ceiling) || (fh->z>fs->z && !fh->ceiling)) + head->AddToLeft(sort); + else + head->AddToRight(sort); +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::SortWallIntoPlane(SortNode * head,SortNode * sort) +{ + GLFlat * fh=&flats[drawitems[head->itemindex].index]; + GLWall * ws=&walls[drawitems[sort->itemindex].index]; + + bool ceiling = fh->z > FIXED2FLOAT(viewz); + + if ((ws->ztop[0] > fh->z || ws->ztop[1] > fh->z) && (ws->zbottom[0] < fh->z || ws->zbottom[1] < fh->z)) + { + // We have to split this wall! + + // WARNING: NEVER EVER push a member of an array onto the array itself. + // Bad things will happen if the memory must be reallocated! + GLWall w = *ws; + AddWall(&w); + + // Splitting is done in the shader with clip planes. + + SortNode * sort2 = SortNodes.GetNew(); + memset(sort2, 0, sizeof(SortNode)); + sort2->itemindex = drawitems.Size() - 1; + + head->AddToLeft(sort); + head->AddToRight(sort2); + } + else if ((ws->zbottom[0]z && !ceiling) || (ws->ztop[0]>fh->z && ceiling)) // completely on the left side + { + head->AddToLeft(sort); + } + else + { + head->AddToRight(sort); + } + +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::SortSpriteIntoPlane(SortNode * head,SortNode * sort) +{ + GLFlat * fh=&flats[drawitems[head->itemindex].index]; + GLSprite * ss=&sprites[drawitems[sort->itemindex].index]; + + bool ceiling = fh->z > FIXED2FLOAT(viewz); + + if ((ss->z1>fh->z && ss->z2z) || ss->modelframe) + { + // We have to split this sprite + GLSprite s=*ss; + AddSprite(&s); // add a copy to avoid reallocation issues. + + // Splitting is done in the shader with clip planes. + + SortNode * sort2=SortNodes.GetNew(); + memset(sort2,0,sizeof(SortNode)); + sort2->itemindex=drawitems.Size()-1; + + head->AddToLeft(sort); + head->AddToRight(sort2); + } + else if ((ss->z2z && !ceiling) || (ss->z1>fh->z && ceiling)) // completely on the left side + { + head->AddToLeft(sort); + } + else + { + head->AddToRight(sort); + } + +} + + +//========================================================================== +// +// +// +//========================================================================== +#define MIN_EQ (0.0005f) + +void GLDrawList::SortWallIntoWall(SortNode * head,SortNode * sort) +{ + GLWall * wh=&walls[drawitems[head->itemindex].index]; + GLWall * ws=&walls[drawitems[sort->itemindex].index]; + GLWall * ws1; + float v1=wh->PointOnSide(ws->glseg.x1,ws->glseg.y1); + float v2=wh->PointOnSide(ws->glseg.x2,ws->glseg.y2); + + if (fabs(v1)type==RENDERWALL_FOGBOUNDARY && wh->type!=RENDERWALL_FOGBOUNDARY) + { + head->AddToRight(sort); + } + else if (ws->type!=RENDERWALL_FOGBOUNDARY && wh->type==RENDERWALL_FOGBOUNDARY) + { + head->AddToLeft(sort); + } + else + { + head->AddToEqual(sort); + } + } + else if (v1AddToLeft(sort); + } + else if (v1>-MIN_EQ && v2>-MIN_EQ) + { + head->AddToRight(sort); + } + else + { + double r=ws->CalcIntersectionVertex(wh); + + float ix=(float)(ws->glseg.x1+r*(ws->glseg.x2-ws->glseg.x1)); + float iy=(float)(ws->glseg.y1+r*(ws->glseg.y2-ws->glseg.y1)); + float iu=(float)(ws->uplft.u + r * (ws->uprgt.u - ws->uplft.u)); + float izt=(float)(ws->ztop[0]+r*(ws->ztop[1]-ws->ztop[0])); + float izb=(float)(ws->zbottom[0]+r*(ws->zbottom[1]-ws->zbottom[0])); + + GLWall w=*ws; + AddWall(&w); + ws1=&walls[walls.Size()-1]; + ws=&walls[drawitems[sort->itemindex].index]; // may have been reallocated! + + ws1->glseg.x1=ws->glseg.x2=ix; + ws1->glseg.y1=ws->glseg.y2=iy; + ws1->ztop[0]=ws->ztop[1]=izt; + ws1->zbottom[0]=ws->zbottom[1]=izb; + ws1->lolft.u = ws1->uplft.u = ws->lorgt.u = ws->uprgt.u = iu; + + SortNode * sort2=SortNodes.GetNew(); + memset(sort2,0,sizeof(SortNode)); + sort2->itemindex=drawitems.Size()-1; + + if (v1>0) + { + head->AddToLeft(sort2); + head->AddToRight(sort); + } + else + { + head->AddToLeft(sort); + head->AddToRight(sort2); + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::SortSpriteIntoWall(SortNode * head,SortNode * sort) +{ + GLWall * wh=&walls[drawitems[head->itemindex].index]; + GLSprite * ss=&sprites[drawitems[sort->itemindex].index]; + GLSprite * ss1; + + float v1 = wh->PointOnSide(ss->x1, ss->y1); + float v2 = wh->PointOnSide(ss->x2, ss->y2); + + if (fabs(v1)type==RENDERWALL_FOGBOUNDARY) + { + head->AddToLeft(sort); + } + else + { + head->AddToEqual(sort); + } + } + else if (v1AddToLeft(sort); + } + else if (v1>-MIN_EQ && v2>-MIN_EQ) + { + head->AddToRight(sort); + } + else + { + double r=ss->CalcIntersectionVertex(wh); + + float ix=(float)(ss->x1 + r * (ss->x2-ss->x1)); + float iy=(float)(ss->y1 + r * (ss->y2-ss->y1)); + float iu=(float)(ss->ul + r * (ss->ur-ss->ul)); + + GLSprite s=*ss; + AddSprite(&s); + ss1=&sprites[sprites.Size()-1]; + ss=&sprites[drawitems[sort->itemindex].index]; // may have been reallocated! + + ss1->x1=ss->x2=ix; + ss1->y1=ss->y2=iy; + ss1->ul=ss->ur=iu; + + SortNode * sort2=SortNodes.GetNew(); + memset(sort2,0,sizeof(SortNode)); + sort2->itemindex=drawitems.Size()-1; + + if (v1>0) + { + head->AddToLeft(sort2); + head->AddToRight(sort); + } + else + { + head->AddToLeft(sort); + head->AddToRight(sort2); + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +inline int GLDrawList::CompareSprites(SortNode * a,SortNode * b) +{ + GLSprite * s1=&sprites[drawitems[a->itemindex].index]; + GLSprite * s2=&sprites[drawitems[b->itemindex].index]; + + int res = s1->depth - s2->depth; + + if (res != 0) return -res; + else return (i_compatflags & COMPATF_SPRITESORT)? s1->index-s2->index : s2->index-s1->index; +} + +//========================================================================== +// +// +// +//========================================================================== +static GLDrawList * gd; +int __cdecl CompareSprite(const void * a,const void * b) +{ + return gd->CompareSprites(*(SortNode**)a,*(SortNode**)b); +} + +//========================================================================== +// +// +// +//========================================================================== +SortNode * GLDrawList::SortSpriteList(SortNode * head) +{ + SortNode * n; + int count; + unsigned i; + + static TArray sortspritelist; + + SortNode * parent=head->parent; + + sortspritelist.Clear(); + for(count=0,n=head;n;n=n->next) sortspritelist.Push(n); + gd=this; + qsort(&sortspritelist[0],sortspritelist.Size(),sizeof(SortNode *),CompareSprite); + for(i=0;inext=NULL; + if (parent) parent->equal=sortspritelist[i]; + parent=sortspritelist[i]; + } + return sortspritelist[0]; +} + +//========================================================================== +// +// +// +//========================================================================== +SortNode * GLDrawList::DoSort(SortNode * head) +{ + SortNode * node, * sn, * next; + + sn=FindSortPlane(head); + if (sn) + { + if (sn==head) head=head->next; + sn->UnlinkFromChain(); + node=head; + head=sn; + while (node) + { + next=node->next; + switch(drawitems[node->itemindex].rendertype) + { + case GLDIT_FLAT: + SortPlaneIntoPlane(head,node); + break; + + case GLDIT_WALL: + SortWallIntoPlane(head,node); + break; + + case GLDIT_SPRITE: + SortSpriteIntoPlane(head,node); + break; + } + node=next; + } + } + else + { + sn=FindSortWall(head); + if (sn) + { + if (sn==head) head=head->next; + sn->UnlinkFromChain(); + node=head; + head=sn; + while (node) + { + next=node->next; + switch(drawitems[node->itemindex].rendertype) + { + case GLDIT_WALL: + SortWallIntoWall(head,node); + break; + + case GLDIT_SPRITE: + SortSpriteIntoWall(head,node); + break; + + case GLDIT_FLAT: break; + } + node=next; + } + } + else + { + return SortSpriteList(head); + } + } + if (head->left) head->left=DoSort(head->left); + if (head->right) head->right=DoSort(head->right); + return sn; +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::DoDraw(int pass, int i, bool trans) +{ + switch(drawitems[i].rendertype) + { + case GLDIT_FLAT: + { + GLFlat * f=&flats[drawitems[i].index]; + RenderFlat.Clock(); + f->Draw(pass, trans); + RenderFlat.Unclock(); + } + break; + + case GLDIT_WALL: + { + GLWall * w=&walls[drawitems[i].index]; + RenderWall.Clock(); + w->Draw(pass); + RenderWall.Unclock(); + } + break; + + case GLDIT_SPRITE: + { + GLSprite * s=&sprites[drawitems[i].index]; + RenderSprite.Clock(); + s->Draw(pass); + RenderSprite.Unclock(); + } + break; + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::DoDrawSorted(SortNode * head) +{ + float clipsplit[2]; + int relation = 0; + float z = 0.f; + + gl_RenderState.GetClipSplit(clipsplit); + + if (drawitems[head->itemindex].rendertype == GLDIT_FLAT) + { + z = flats[drawitems[head->itemindex].index].z; + relation = z > FIXED2FLOAT(viewz)? 1 : -1; + } + + + // left is further away, i.e. for stuff above viewz its z coordinate higher, for stuff below viewz its z coordinate is lower + if (head->left) + { + if (relation == -1) + { + gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane + } + else if (relation == 1) + { + gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane + } + DoDrawSorted(head->left); + gl_RenderState.SetClipSplit(clipsplit); + } + DoDraw(GLPASS_TRANSLUCENT, head->itemindex, true); + if (head->equal) + { + SortNode * ehead=head->equal; + while (ehead) + { + DoDraw(GLPASS_TRANSLUCENT, ehead->itemindex, true); + ehead=ehead->equal; + } + } + // right is closer, i.e. for stuff above viewz its z coordinate is lower, for stuff below viewz its z coordinate is higher + if (head->right) + { + if (relation == 1) + { + gl_RenderState.SetClipSplit(clipsplit[0], z); // render below: set flat as top clip plane + } + else if (relation == -1) + { + gl_RenderState.SetClipSplit(z, clipsplit[1]); // render above: set flat as bottom clip plane + } + DoDrawSorted(head->right); + gl_RenderState.SetClipSplit(clipsplit); + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::DrawSorted() +{ + if (drawitems.Size()==0) return; + + if (!sorted) + { + MakeSortList(); + sorted=DoSort(SortNodes[SortNodeStart]); + } + gl_RenderState.ClearClipSplit(); + glEnable(GL_CLIP_DISTANCE2); + glEnable(GL_CLIP_DISTANCE3); + DoDrawSorted(sorted); + glDisable(GL_CLIP_DISTANCE2); + glDisable(GL_CLIP_DISTANCE3); + gl_RenderState.ClearClipSplit(); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::Draw(int pass, bool trans) +{ + for(unsigned i=0;iwalls[di1->index]; + + const GLDrawItem * di2 = (const GLDrawItem *)b; + GLWall * w2=&sortinfo->walls[di2->index]; + + if (w1->gltexture != w2->gltexture) return w1->gltexture - w2->gltexture; + return ((w1->flags & 3) - (w2->flags & 3)); +} + +static int __cdecl difcmp (const void *a, const void *b) +{ + const GLDrawItem * di1 = (const GLDrawItem *)a; + GLFlat * w1=&sortinfo->flats[di1->index]; + + const GLDrawItem * di2 = (const GLDrawItem *)b; + GLFlat* w2=&sortinfo->flats[di2->index]; + + return w1->gltexture - w2->gltexture; +} + + +void GLDrawList::SortWalls() +{ + if (drawitems.Size() > 1) + { + sortinfo=this; + qsort(&drawitems[0], drawitems.Size(), sizeof(drawitems[0]), diwcmp); + } +} + +void GLDrawList::SortFlats() +{ + if (drawitems.Size() > 1) + { + sortinfo=this; + qsort(&drawitems[0], drawitems.Size(), sizeof(drawitems[0]), difcmp); + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::AddWall(GLWall * wall) +{ + drawitems.Push(GLDrawItem(GLDIT_WALL,walls.Push(*wall))); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::AddFlat(GLFlat * flat) +{ + drawitems.Push(GLDrawItem(GLDIT_FLAT,flats.Push(*flat))); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLDrawList::AddSprite(GLSprite * sprite) +{ + drawitems.Push(GLDrawItem(GLDIT_SPRITE,sprites.Push(*sprite))); +} + + +//========================================================================== +// +// Try to reuse the lists as often as possible as they contain resources that +// are expensive to create and delete. +// +//========================================================================== + +FDrawInfo *FDrawInfoList::GetNew() +{ + if (mList.Size() > 0) + { + FDrawInfo *di; + mList.Pop(di); + return di; + } + return new FDrawInfo; +} + +void FDrawInfoList::Release(FDrawInfo * di) +{ + di->ClearBuffers(); + mList.Push(di); +} + +static FDrawInfoList di_list; + +//========================================================================== +// +// +// +//========================================================================== + +FDrawInfo::FDrawInfo() +{ + next = NULL; +} + +FDrawInfo::~FDrawInfo() +{ + ClearBuffers(); +} + + +//========================================================================== +// +// Sets up a new drawinfo struct +// +//========================================================================== +void FDrawInfo::StartDrawInfo() +{ + FDrawInfo *di=di_list.GetNew(); + di->StartScene(); +} + +void FDrawInfo::StartScene() +{ + ClearBuffers(); + + sectorrenderflags.Resize(numsectors); + ss_renderflags.Resize(numsubsectors); + no_renderflags.Resize(numsubsectors); + + memset(§orrenderflags[0], 0, numsectors*sizeof(sectorrenderflags[0])); + memset(&ss_renderflags[0], 0, numsubsectors*sizeof(ss_renderflags[0])); + memset(&no_renderflags[0], 0, numnodes*sizeof(no_renderflags[0])); + + next=gl_drawinfo; + gl_drawinfo=this; + for(int i=0;idrawlists[i].Reset(); + gl_drawinfo=di->next; + di_list.Release(di); +} + + +//========================================================================== +// +// Flood gaps with the back side's ceiling/floor texture +// This requires a stencil because the projected plane interferes with +// the depth buffer +// +//========================================================================== + +void FDrawInfo::SetupFloodStencil(wallseg * ws) +{ + int recursion = GLPortal::GetRecursion(); + + // Create stencil + glStencilFunc(GL_EQUAL, recursion, ~0); // create stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); // increment stencil of valid pixels + { + // Use revertible color mask, to avoid stomping on anaglyph 3D state + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // don't write to the graphics buffer + gl_RenderState.EnableTexture(false); + gl_RenderState.ResetColor(); + glEnable(GL_DEPTH_TEST); + glDepthMask(true); + + gl_RenderState.Apply(); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + + + glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil + + } // glColorMask(1, 1, 1, 1); // don't write to the graphics buffer + gl_RenderState.EnableTexture(true); + glDisable(GL_DEPTH_TEST); + glDepthMask(false); +} + +void FDrawInfo::ClearFloodStencil(wallseg * ws) +{ + int recursion = GLPortal::GetRecursion(); + + glStencilOp(GL_KEEP,GL_KEEP,GL_DECR); + gl_RenderState.EnableTexture(false); + { + // Use revertible color mask, to avoid stomping on anaglyph 3D state + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0,0,0,0); // don't write to the graphics buffer + gl_RenderState.ResetColor(); + + gl_RenderState.Apply(); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(ws->x1, ws->z1, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x1, ws->z2, ws->y1, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z2, ws->y2, 0, 0); + ptr++; + ptr->Set(ws->x2, ws->z1, ws->y2, 0, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + + // restore old stencil op. + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + glStencilFunc(GL_EQUAL, recursion, ~0); + gl_RenderState.EnableTexture(true); + } // glColorMask(1, 1, 1, 1); + glEnable(GL_DEPTH_TEST); + glDepthMask(true); +} + +//========================================================================== +// +// Draw the plane segment into the gap +// +//========================================================================== +void FDrawInfo::DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, bool ceiling) +{ + GLSectorPlane plane; + int lightlevel; + FColormap Colormap; + FMaterial * gltexture; + + plane.GetFromSector(sec, ceiling); + + gltexture=FMaterial::ValidateTexture(plane.texture, false, true); + if (!gltexture) return; + + if (gl_fixedcolormap) + { + Colormap.Clear(); + lightlevel=255; + } + else + { + Colormap=sec->ColorMap; + if (gltexture->tex->isFullbright()) + { + Colormap.LightColor.r = Colormap.LightColor.g = Colormap.LightColor.b = 0xff; + lightlevel=255; + } + else lightlevel=abs(ceiling? sec->GetCeilingLight() : sec->GetFloorLight()); + } + + int rel = getExtraLight(); + gl_SetColor(lightlevel, rel, Colormap, 1.0f); + gl_SetFog(lightlevel, rel, &Colormap, false); + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); + + float fviewx = FIXED2FLOAT(viewx); + float fviewy = FIXED2FLOAT(viewy); + float fviewz = FIXED2FLOAT(viewz); + + gl_SetPlaneTextureRotation(&plane, gltexture); + gl_RenderState.Apply(); + + float prj_fac1 = (planez-fviewz)/(ws->z1-fviewz); + float prj_fac2 = (planez-fviewz)/(ws->z2-fviewz); + + float px1 = fviewx + prj_fac1 * (ws->x1-fviewx); + float py1 = fviewy + prj_fac1 * (ws->y1-fviewy); + + float px2 = fviewx + prj_fac2 * (ws->x1-fviewx); + float py2 = fviewy + prj_fac2 * (ws->y1-fviewy); + + float px3 = fviewx + prj_fac2 * (ws->x2-fviewx); + float py3 = fviewy + prj_fac2 * (ws->y2-fviewy); + + float px4 = fviewx + prj_fac1 * (ws->x2-fviewx); + float py4 = fviewy + prj_fac1 * (ws->y2-fviewy); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(px1, planez, py1, px1 / 64, -py1 / 64); + ptr++; + ptr->Set(px2, planez, py2, px2 / 64, -py2 / 64); + ptr++; + ptr->Set(px3, planez, py3, px3 / 64, -py3 / 64); + ptr++; + ptr->Set(px4, planez, py4, px4 / 64, -py4 / 64); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + + gl_RenderState.EnableTextureMatrix(false); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::FloodUpperGap(seg_t * seg) +{ + wallseg ws; + sector_t ffake, bfake; + sector_t * fakefsector = gl_FakeFlat(seg->frontsector, &ffake, true); + sector_t * fakebsector = gl_FakeFlat(seg->backsector, &bfake, false); + + vertex_t * v1, * v2; + + // Although the plane can be sloped this code will only be called + // when the edge itself is not. + fixed_t backz = fakebsector->ceilingplane.ZatPoint(seg->v1); + fixed_t frontz = fakefsector->ceilingplane.ZatPoint(seg->v1); + + if (fakebsector->GetTexture(sector_t::ceiling)==skyflatnum) return; + if (backz < viewz) return; + + if (seg->sidedef == seg->linedef->sidedef[0]) + { + v1=seg->linedef->v1; + v2=seg->linedef->v2; + } + else + { + v1=seg->linedef->v2; + v2=seg->linedef->v1; + } + + ws.x1= FIXED2FLOAT(v1->x); + ws.y1= FIXED2FLOAT(v1->y); + ws.x2= FIXED2FLOAT(v2->x); + ws.y2= FIXED2FLOAT(v2->y); + + ws.z1= FIXED2FLOAT(frontz); + ws.z2= FIXED2FLOAT(backz); + + // Step1: Draw a stencil into the gap + SetupFloodStencil(&ws); + + // Step2: Project the ceiling plane into the gap + DrawFloodedPlane(&ws, ws.z2, fakebsector, true); + + // Step3: Delete the stencil + ClearFloodStencil(&ws); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::FloodLowerGap(seg_t * seg) +{ + wallseg ws; + sector_t ffake, bfake; + sector_t * fakefsector = gl_FakeFlat(seg->frontsector, &ffake, true); + sector_t * fakebsector = gl_FakeFlat(seg->backsector, &bfake, false); + + vertex_t * v1, * v2; + + // Although the plane can be sloped this code will only be called + // when the edge itself is not. + fixed_t backz = fakebsector->floorplane.ZatPoint(seg->v1); + fixed_t frontz = fakefsector->floorplane.ZatPoint(seg->v1); + + + if (fakebsector->GetTexture(sector_t::floor) == skyflatnum) return; + if (fakebsector->GetPlaneTexZ(sector_t::floor) > viewz) return; + + if (seg->sidedef == seg->linedef->sidedef[0]) + { + v1=seg->linedef->v1; + v2=seg->linedef->v2; + } + else + { + v1=seg->linedef->v2; + v2=seg->linedef->v1; + } + + ws.x1= FIXED2FLOAT(v1->x); + ws.y1= FIXED2FLOAT(v1->y); + ws.x2= FIXED2FLOAT(v2->x); + ws.y2= FIXED2FLOAT(v2->y); + + ws.z2= FIXED2FLOAT(frontz); + ws.z1= FIXED2FLOAT(backz); + + // Step1: Draw a stencil into the gap + SetupFloodStencil(&ws); + + // Step2: Project the ceiling plane into the gap + DrawFloodedPlane(&ws, ws.z1, fakebsector, false); + + // Step3: Delete the stencil + ClearFloodStencil(&ws); +} diff --git a/src/gl/scene/gl_drawinfo.h b/src/gl/scene/gl_drawinfo.h new file mode 100644 index 000000000..6b869ef17 --- /dev/null +++ b/src/gl/scene/gl_drawinfo.h @@ -0,0 +1,271 @@ +#ifndef __GL_DRAWINFO_H +#define __GL_DRAWINFO_H + +#include "gl/scene/gl_wall.h" + +enum GLDrawItemType +{ + GLDIT_WALL, + GLDIT_FLAT, + GLDIT_SPRITE, +}; + +enum DrawListType +{ + GLDL_PLAINWALLS, + GLDL_PLAINFLATS, + GLDL_MASKEDWALLS, + GLDL_MASKEDFLATS, + GLDL_MASKEDWALLSOFS, + GLDL_MODELS, + + GLDL_TRANSLUCENT, + GLDL_TRANSLUCENTBORDER, + + GLDL_TYPES, +}; + +enum Drawpasses +{ + GLPASS_ALL, // Main pass with dynamic lights + GLPASS_LIGHTSONLY, // only collect dynamic lights + GLPASS_PLAIN, // Main pass without dynamic lights + GLPASS_DECALS, // Draws a decal + GLPASS_TRANSLUCENT, // Draws translucent objects +}; + +//========================================================================== +// +// Intermediate struct to link one draw item into a draw list +// +// unfortunately this struct must not contain pointers because +// the arrays may be reallocated! +// +//========================================================================== + +struct GLDrawItem +{ + GLDrawItemType rendertype; + int index; + + GLDrawItem(GLDrawItemType _rendertype,int _index) : rendertype(_rendertype),index(_index) {} +}; + +struct SortNode +{ + int itemindex; + SortNode * parent; + SortNode * next; // unsorted successor + SortNode * left; // left side of this node + SortNode * equal; // equal to this node + SortNode * right; // right side of this node + + + void UnlinkFromChain(); + void Link(SortNode * hook); + void AddToEqual(SortNode * newnode); + void AddToLeft (SortNode * newnode); + void AddToRight(SortNode * newnode); +}; + +//========================================================================== +// +// One draw list. This contains all info for one type of rendering data +// +//========================================================================== + +struct GLDrawList +{ +//private: + TArray walls; + TArray flats; + TArray sprites; + TArray drawitems; + int SortNodeStart; + SortNode * sorted; + +public: + GLDrawList() + { + next=NULL; + SortNodeStart=-1; + sorted=NULL; + } + + ~GLDrawList() + { + Reset(); + } + + unsigned int Size() + { + return drawitems.Size(); + } + + void AddWall(GLWall * wall); + void AddFlat(GLFlat * flat); + void AddSprite(GLSprite * sprite); + void Reset(); + void SortWalls(); + void SortFlats(); + + + void MakeSortList(); + SortNode * FindSortPlane(SortNode * head); + SortNode * FindSortWall(SortNode * head); + void SortPlaneIntoPlane(SortNode * head,SortNode * sort); + void SortWallIntoPlane(SortNode * head,SortNode * sort); + void SortSpriteIntoPlane(SortNode * head,SortNode * sort); + void SortWallIntoWall(SortNode * head,SortNode * sort); + void SortSpriteIntoWall(SortNode * head,SortNode * sort); + int CompareSprites(SortNode * a,SortNode * b); + SortNode * SortSpriteList(SortNode * head); + SortNode * DoSort(SortNode * head); + + void DoDraw(int pass, int index, bool trans); + void DoDrawSorted(SortNode * node); + void DrawSorted(); + void Draw(int pass, bool trans = false); + void DrawWalls(int pass); + void DrawFlats(int pass); + void DrawDecals(); + + GLDrawList * next; +} ; + + +//========================================================================== +// +// these are used to link faked planes due to missing textures to a sector +// +//========================================================================== +struct gl_subsectorrendernode +{ + gl_subsectorrendernode * next; + subsector_t * sub; +}; + + +struct FDrawInfo +{ + struct wallseg + { + float x1, y1, z1, x2, y2, z2; + }; + + bool temporary; + + + + struct MissingTextureInfo + { + seg_t * seg; + subsector_t * sub; + fixed_t planez; + fixed_t planezfront; + }; + + struct MissingSegInfo + { + seg_t * seg; + int MTI_Index; // tells us which MissingTextureInfo represents this seg. + }; + + struct SubsectorHackInfo + { + subsector_t * sub; + BYTE flags; + }; + + TArray sectorrenderflags; + TArray ss_renderflags; + TArray no_renderflags; + + TArray MissingUpperTextures; + TArray MissingLowerTextures; + + TArray MissingUpperSegs; + TArray MissingLowerSegs; + + TArray SubsectorHacks; + + TArray otherfloorplanes; + TArray otherceilingplanes; + + TArray CeilingStacks; + TArray FloorStacks; + + TArray HandledSubsectors; + + FDrawInfo * next; + GLDrawList drawlists[GLDL_TYPES]; + + FDrawInfo(); + ~FDrawInfo(); + void ClearBuffers(); + + bool DoOneSectorUpper(subsector_t * subsec, fixed_t planez); + bool DoOneSectorLower(subsector_t * subsec, fixed_t planez); + bool DoFakeBridge(subsector_t * subsec, fixed_t planez); + bool DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez); + + bool CheckAnchorFloor(subsector_t * sub); + bool CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor); + bool CheckAnchorCeiling(subsector_t * sub); + bool CollectSubsectorsCeiling(subsector_t * sub, sector_t * anchor); + void CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor); + void CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor); + + void AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight); + void AddLowerMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight); + void HandleMissingTextures(); + void DrawUnhandledMissingTextures(); + void AddHackedSubsector(subsector_t * sub); + void HandleHackedSubsectors(); + void AddFloorStack(sector_t * sec); + void AddCeilingStack(sector_t * sec); + void ProcessSectorStacks(); + + void AddOtherFloorPlane(int sector, gl_subsectorrendernode * node); + void AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node); + + void StartScene(); + void SetupFloodStencil(wallseg * ws); + void ClearFloodStencil(wallseg * ws); + void DrawFloodedPlane(wallseg * ws, float planez, sector_t * sec, bool ceiling); + void FloodUpperGap(seg_t * seg); + void FloodLowerGap(seg_t * seg); + + static void StartDrawInfo(); + static void EndDrawInfo(); + + gl_subsectorrendernode * GetOtherFloorPlanes(unsigned int sector) + { + if (sector mList; + +public: + + FDrawInfo *GetNew(); + void Release(FDrawInfo *); +}; + + +extern FDrawInfo * gl_drawinfo; + +void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture); +void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending); + +#endif \ No newline at end of file diff --git a/src/gl/scene/gl_fakeflat.cpp b/src/gl/scene/gl_fakeflat.cpp new file mode 100644 index 000000000..6ff6bd113 --- /dev/null +++ b/src/gl/scene/gl_fakeflat.cpp @@ -0,0 +1,400 @@ +/* +** gl_fakeflat.cpp +** Fake flat functions to render stacked sectors +** +**--------------------------------------------------------------------------- +** Copyright 2001-2011 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "p_lnspec.h" +#include "p_local.h" +#include "a_sharedglobal.h" +#include "r_sky.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/scene/gl_clipper.h" +#include "gl/data/gl_data.h" + + +//========================================================================== +// +// Check whether the player can look beyond this line +// +//========================================================================== +CVAR(Bool, gltest_slopeopt, false, 0) + +bool gl_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsector) +{ + line_t *linedef = sidedef->linedef; + fixed_t bs_floorheight1; + fixed_t bs_floorheight2; + fixed_t bs_ceilingheight1; + fixed_t bs_ceilingheight2; + fixed_t fs_floorheight1; + fixed_t fs_floorheight2; + fixed_t fs_ceilingheight1; + fixed_t fs_ceilingheight2; + + // Mirrors and horizons always block the view + //if (linedef->special==Line_Mirror || linedef->special==Line_Horizon) return true; + + // Lines with stacked sectors must never block! + + if (backsector->portals[sector_t::ceiling] != NULL || backsector->portals[sector_t::floor] != NULL || + frontsector->portals[sector_t::ceiling] != NULL || frontsector->portals[sector_t::floor] != NULL) + { + return false; + } + + // on large levels this distinction can save some time + // That's a lot of avoided multiplications if there's a lot to see! + + if (frontsector->ceilingplane.a | frontsector->ceilingplane.b) + { + fs_ceilingheight1=frontsector->ceilingplane.ZatPoint(linedef->v1); + fs_ceilingheight2=frontsector->ceilingplane.ZatPoint(linedef->v2); + } + else + { + fs_ceilingheight2=fs_ceilingheight1=frontsector->ceilingplane.d; + } + + if (frontsector->floorplane.a | frontsector->floorplane.b) + { + fs_floorheight1=frontsector->floorplane.ZatPoint(linedef->v1); + fs_floorheight2=frontsector->floorplane.ZatPoint(linedef->v2); + } + else + { + fs_floorheight2=fs_floorheight1=-frontsector->floorplane.d; + } + + if (backsector->ceilingplane.a | backsector->ceilingplane.b) + { + bs_ceilingheight1=backsector->ceilingplane.ZatPoint(linedef->v1); + bs_ceilingheight2=backsector->ceilingplane.ZatPoint(linedef->v2); + } + else + { + bs_ceilingheight2=bs_ceilingheight1=backsector->ceilingplane.d; + } + + if (backsector->floorplane.a | backsector->floorplane.b) + { + bs_floorheight1=backsector->floorplane.ZatPoint(linedef->v1); + bs_floorheight2=backsector->floorplane.ZatPoint(linedef->v2); + } + else + { + bs_floorheight2=bs_floorheight1=-backsector->floorplane.d; + } + + // now check for closed sectors! + if (bs_ceilingheight1<=fs_floorheight1 && bs_ceilingheight2<=fs_floorheight2) + { + FTexture * tex = TexMan(sidedef->GetTexture(side_t::top)); + if (!tex || tex->UseType==FTexture::TEX_Null) return false; + if (backsector->GetTexture(sector_t::ceiling)==skyflatnum && + frontsector->GetTexture(sector_t::ceiling)==skyflatnum) return false; + return true; + } + + if (fs_ceilingheight1<=bs_floorheight1 && fs_ceilingheight2<=bs_floorheight2) + { + FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom)); + if (!tex || tex->UseType==FTexture::TEX_Null) return false; + + // properly render skies (consider door "open" if both floors are sky): + if (backsector->GetTexture(sector_t::ceiling)==skyflatnum && + frontsector->GetTexture(sector_t::ceiling)==skyflatnum) return false; + return true; + } + + if (bs_ceilingheight1<=bs_floorheight1 && bs_ceilingheight2<=bs_floorheight2) + { + // preserve a kind of transparent door/lift special effect: + if (bs_ceilingheight1 < fs_ceilingheight1 || bs_ceilingheight2 < fs_ceilingheight2) + { + FTexture * tex = TexMan(sidedef->GetTexture(side_t::top)); + if (!tex || tex->UseType==FTexture::TEX_Null) return false; + } + if (bs_floorheight1 > fs_floorheight1 || bs_floorheight2 > fs_floorheight2) + { + FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom)); + if (!tex || tex->UseType==FTexture::TEX_Null) return false; + } + if (backsector->GetTexture(sector_t::ceiling)==skyflatnum && + frontsector->GetTexture(sector_t::ceiling)==skyflatnum) return false; + if (backsector->GetTexture(sector_t::floor)==skyflatnum && frontsector->GetTexture(sector_t::floor) + ==skyflatnum) return false; + return true; + } + + return false; +} + +//========================================================================== +// +// check for levels with exposed lower areas +// +//========================================================================== + +void gl_CheckViewArea(vertex_t *v1, vertex_t *v2, sector_t *frontsector, sector_t *backsector) +{ + if (in_area==area_default && + (backsector->heightsec && !(backsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) && + (!frontsector->heightsec || frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) + { + sector_t * s = backsector->heightsec; + + fixed_t cz1 = frontsector->ceilingplane.ZatPoint(v1); + fixed_t cz2 = frontsector->ceilingplane.ZatPoint(v2); + fixed_t fz1 = s->floorplane.ZatPoint(v1); + fixed_t fz2 = s->floorplane.ZatPoint(v2); + + // allow some tolerance in case slopes are involved + if (cz1 <= fz1 + FRACUNIT/100 && cz2<=fz2 + FRACUNIT/100) + in_area=area_below; + else + in_area=area_normal; + } +} + + +//========================================================================== +// +// This is mostly like R_FakeFlat but with a few alterations necessitated +// by hardware rendering +// +//========================================================================== +sector_t * gl_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back) +{ + if (!sec->heightsec || sec->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC || sec->heightsec==sec) + { + // check for backsectors with the ceiling lower than the floor. These will create + // visual glitches because upper amd lower textures overlap. + if (back && sec->planes[sector_t::floor].TexZ > sec->planes[sector_t::ceiling].TexZ) + { + if (!(sec->floorplane.a | sec->floorplane.b | sec->ceilingplane.a | sec->ceilingplane.b)) + { + *dest = *sec; + dest->ceilingplane=sec->floorplane; + dest->ceilingplane.FlipVert(); + dest->planes[sector_t::ceiling].TexZ = dest->planes[sector_t::floor].TexZ; + return dest; + } + } + return sec; + } + +#ifdef _DEBUG + if (sec-sectors==560) + { + int a = 0; + } +#endif + + if (in_area==area_above) + { + if (sec->heightsec->MoreFlags&SECF_FAKEFLOORONLY /*|| sec->GetTexture(sector_t::ceiling)==skyflatnum*/) in_area=area_normal; + } + + int diffTex = (sec->heightsec->MoreFlags & SECF_CLIPFAKEPLANES); + sector_t * s = sec->heightsec; + +#if 0 + *dest=*sec; // This will invoke the copy operator which isn't really needed here. Memcpy is faster. +#else + memcpy(dest, sec, sizeof(sector_t)); +#endif + + // Replace floor and ceiling height with control sector's heights. + if (diffTex) + { + if (s->floorplane.CopyPlaneIfValid (&dest->floorplane, &sec->ceilingplane)) + { + dest->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false); + dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::floor)); + dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::vbo_fakefloor]; + dest->vboheight[sector_t::floor] = s->vboheight[sector_t::floor]; + } + else if (s->MoreFlags & SECF_FAKEFLOORONLY) + { + if (in_area==area_below) + { + dest->ColorMap=s->ColorMap; + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) + { + dest->lightlevel = s->lightlevel; + dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor)); + dest->SetPlaneLight(sector_t::ceiling, s->GetPlaneLight(sector_t::ceiling)); + dest->ChangeFlags(sector_t::floor, -1, s->GetFlags(sector_t::floor)); + dest->ChangeFlags(sector_t::ceiling, -1, s->GetFlags(sector_t::ceiling)); + } + return dest; + } + return sec; + } + } + else + { + dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::floor)); + dest->floorplane = s->floorplane; + + dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::vbo_fakefloor]; + dest->vboheight[sector_t::floor] = s->vboheight[sector_t::floor]; + } + + if (!(s->MoreFlags&SECF_FAKEFLOORONLY)) + { + if (diffTex) + { + if (s->ceilingplane.CopyPlaneIfValid (&dest->ceilingplane, &sec->floorplane)) + { + dest->SetTexture(sector_t::ceiling, s->GetTexture(sector_t::ceiling), false); + dest->SetPlaneTexZ(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling)); + dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakeceiling]; + dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::ceiling]; + } + } + else + { + dest->ceilingplane = s->ceilingplane; + dest->SetPlaneTexZ(sector_t::ceiling, s->GetPlaneTexZ(sector_t::ceiling)); + dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakeceiling]; + dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::ceiling]; + } + } + + if (in_area==area_below) + { + dest->ColorMap=s->ColorMap; + dest->SetPlaneTexZ(sector_t::floor, sec->GetPlaneTexZ(sector_t::floor)); + dest->SetPlaneTexZ(sector_t::ceiling, s->GetPlaneTexZ(sector_t::floor)); + dest->floorplane=sec->floorplane; + dest->ceilingplane=s->floorplane; + dest->ceilingplane.FlipVert(); + + dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::floor]; + dest->vboheight[sector_t::floor] = sec->vboheight[sector_t::floor]; + + dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::vbo_fakefloor]; + dest->vboheight[sector_t::ceiling] = s->vboheight[sector_t::floor]; + + dest->portals[sector_t::ceiling] = NULL; + + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) + { + dest->lightlevel = s->lightlevel; + } + + if (!back) + { + dest->SetTexture(sector_t::floor, diffTex ? sec->GetTexture(sector_t::floor) : s->GetTexture(sector_t::floor), false); + dest->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform; + + //dest->ceilingplane = s->floorplane; + + if (s->GetTexture(sector_t::ceiling) == skyflatnum) + { + dest->SetTexture(sector_t::ceiling, dest->GetTexture(sector_t::floor), false); + //dest->floorplane = dest->ceilingplane; + //dest->floorplane.FlipVert (); + //dest->floorplane.ChangeHeight (+1); + dest->planes[sector_t::ceiling].xform = dest->planes[sector_t::floor].xform; + + } + else + { + dest->SetTexture(sector_t::ceiling, diffTex ? s->GetTexture(sector_t::floor) : s->GetTexture(sector_t::ceiling), false); + dest->planes[sector_t::ceiling].xform = s->planes[sector_t::ceiling].xform; + } + + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) + { + dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor)); + dest->SetPlaneLight(sector_t::ceiling, s->GetPlaneLight(sector_t::ceiling)); + dest->ChangeFlags(sector_t::floor, -1, s->GetFlags(sector_t::floor)); + dest->ChangeFlags(sector_t::ceiling, -1, s->GetFlags(sector_t::ceiling)); + } + } + } + else if (in_area == area_above) + { + dest->ColorMap = s->ColorMap; + dest->SetPlaneTexZ(sector_t::ceiling, sec->GetPlaneTexZ(sector_t::ceiling)); + dest->SetPlaneTexZ(sector_t::floor, s->GetPlaneTexZ(sector_t::ceiling)); + dest->ceilingplane = sec->ceilingplane; + dest->floorplane = s->ceilingplane; + dest->floorplane.FlipVert(); + + dest->vboindex[sector_t::floor] = sec->vboindex[sector_t::vbo_fakeceiling]; + dest->vboheight[sector_t::floor] = s->vboheight[sector_t::ceiling]; + + dest->vboindex[sector_t::ceiling] = sec->vboindex[sector_t::ceiling]; + dest->vboheight[sector_t::ceiling] = sec->vboheight[sector_t::ceiling]; + + dest->portals[sector_t::floor] = NULL; + + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) + { + dest->lightlevel = s->lightlevel; + } + + if (!back) + { + dest->SetTexture(sector_t::ceiling, diffTex ? sec->GetTexture(sector_t::ceiling) : s->GetTexture(sector_t::ceiling), false); + dest->SetTexture(sector_t::floor, s->GetTexture(sector_t::ceiling), false); + dest->planes[sector_t::ceiling].xform = dest->planes[sector_t::floor].xform = s->planes[sector_t::ceiling].xform; + + if (s->GetTexture(sector_t::floor) != skyflatnum) + { + dest->SetTexture(sector_t::floor, s->GetTexture(sector_t::floor), false); + dest->planes[sector_t::floor].xform = s->planes[sector_t::floor].xform; + } + + if (!(s->MoreFlags & SECF_NOFAKELIGHT)) + { + dest->lightlevel = s->lightlevel; + dest->SetPlaneLight(sector_t::floor, s->GetPlaneLight(sector_t::floor)); + dest->SetPlaneLight(sector_t::ceiling, s->GetPlaneLight(sector_t::ceiling)); + dest->ChangeFlags(sector_t::floor, -1, s->GetFlags(sector_t::floor)); + dest->ChangeFlags(sector_t::ceiling, -1, s->GetFlags(sector_t::ceiling)); + } + } + } + return dest; +} + + diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp new file mode 100644 index 000000000..78d9b44bd --- /dev/null +++ b/src/gl/scene/gl_flats.cpp @@ -0,0 +1,725 @@ +/* +** gl_flat.cpp +** Flat rendering +** +**--------------------------------------------------------------------------- +** Copyright 2000-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "a_sharedglobal.h" +#include "r_defs.h" +#include "r_sky.h" +#include "r_utility.h" +#include "g_level.h" +#include "doomstat.h" +#include "d_player.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_convert.h" +#include "gl/utility/gl_templates.h" + +#ifdef _DEBUG +CVAR(Int, gl_breaksec, -1, 0) +#endif +//========================================================================== +// +// Sets the texture matrix according to the plane's texture positioning +// information +// +//========================================================================== +static float tics; +void gl_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * gltexture) +{ + // only manipulate the texture matrix if needed. + if (secplane->xoffs != 0 || secplane->yoffs != 0 || + secplane->xscale != FRACUNIT || secplane->yscale != FRACUNIT || + secplane->angle != 0 || + gltexture->TextureWidth() != 64 || + gltexture->TextureHeight() != 64) + { + float uoffs = FIXED2FLOAT(secplane->xoffs) / gltexture->TextureWidth(); + float voffs = FIXED2FLOAT(secplane->yoffs) / gltexture->TextureHeight(); + + float xscale1=FIXED2FLOAT(secplane->xscale); + float yscale1=FIXED2FLOAT(secplane->yscale); + if (gltexture->tex->bHasCanvas) + { + yscale1 = 0 - yscale1; + } + float angle=-ANGLE_TO_FLOAT(secplane->angle); + + float xscale2=64.f/gltexture->TextureWidth(); + float yscale2=64.f/gltexture->TextureHeight(); + + gl_RenderState.mTextureMatrix.loadIdentity(); + gl_RenderState.mTextureMatrix.scale(xscale1 ,yscale1,1.0f); + gl_RenderState.mTextureMatrix.translate(uoffs,voffs,0.0f); + gl_RenderState.mTextureMatrix.scale(xscale2 ,yscale2,1.0f); + gl_RenderState.mTextureMatrix.rotate(angle,0.0f,0.0f,1.0f); + gl_RenderState.EnableTextureMatrix(true); + } +} + + + +//========================================================================== +// +// Flats +// +//========================================================================== +extern FDynLightData lightdata; + +void GLFlat::SetupSubsectorLights(int pass, subsector_t * sub, int *dli) +{ + Plane p; + + if (dli != NULL && *dli != -1) + { + gl_RenderState.ApplyLightIndex(GLRenderer->mLights->GetIndex(*dli)); + (*dli)++; + return; + } + + lightdata.Clear(); + FLightNode * node = sub->lighthead; + while (node) + { + ADynamicLight * light = node->lightsource; + + if (light->flags2&MF2_DORMANT) + { + node=node->nextLight; + continue; + } + iter_dlightf++; + + // we must do the side check here because gl_SetupLight needs the correct plane orientation + // which we don't have for Legacy-style 3D-floors + fixed_t planeh = plane.plane.ZatPoint(light->x, light->y); + if (gl_lights_checkside && ((planehz && ceiling) || (planeh>light->z && !ceiling))) + { + node=node->nextLight; + continue; + } + + p.Set(plane.plane); + gl_GetLight(p, light, false, false, lightdata); + node = node->nextLight; + } + + int d = GLRenderer->mLights->UploadLights(lightdata); + if (pass == GLPASS_LIGHTSONLY) + { + GLRenderer->mLights->StoreIndex(d); + } + else + { + gl_RenderState.ApplyLightIndex(d); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void GLFlat::DrawSubsector(subsector_t * sub) +{ + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + if (plane.plane.a | plane.plane.b) + { + for (unsigned int k = 0; k < sub->numlines; k++) + { + vertex_t *vt = sub->firstline[k].v1; + ptr->x = vt->fx; + ptr->y = vt->fy; + ptr->z = plane.plane.ZatPoint(vt->fx, vt->fy) + dz; + ptr->u = vt->fx / 64.f; + ptr->v = -vt->fy / 64.f; + ptr++; + } + } + else + { + float zc = FIXED2FLOAT(plane.plane.Zat0()) + dz; + for (unsigned int k = 0; k < sub->numlines; k++) + { + vertex_t *vt = sub->firstline[k].v1; + ptr->x = vt->fx; + ptr->y = vt->fy; + ptr->z = zc; + ptr->u = vt->fx / 64.f; + ptr->v = -vt->fy / 64.f; + ptr++; + } + } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + + flatvertices += sub->numlines; + flatprimitives++; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void GLFlat::ProcessLights(bool istrans) +{ + dynlightindex = GLRenderer->mLights->GetIndexPtr(); + + if (sub) + { + // This represents a single subsector + SetupSubsectorLights(GLPASS_LIGHTSONLY, sub); + } + else + { + // Draw the subsectors belonging to this sector + for (int i=0; isubsectorcount; i++) + { + subsector_t * sub = sector->subsectors[i]; + if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) + { + SetupSubsectorLights(GLPASS_LIGHTSONLY, sub); + } + } + + // Draw the subsectors assigned to it due to missing textures + if (!(renderflags&SSRF_RENDER3DPLANES)) + { + gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)? + gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : + gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); + + while (node) + { + SetupSubsectorLights(GLPASS_LIGHTSONLY, node->sub); + node = node->next; + } + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +void GLFlat::DrawSubsectors(int pass, bool processlights, bool istrans) +{ + int dli = dynlightindex; + + gl_RenderState.Apply(); + if (sub) + { + // This represents a single subsector + if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); + DrawSubsector(sub); + } + else + { + if (vboindex >= 0) + { + int index = vboindex; + for (int i=0; isubsectorcount; i++) + { + subsector_t * sub = sector->subsectors[i]; + + if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) + { + if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); + drawcalls.Clock(); + glDrawArrays(GL_TRIANGLE_FAN, index, sub->numlines); + drawcalls.Unclock(); + flatvertices += sub->numlines; + flatprimitives++; + } + index += sub->numlines; + } + } + else + { + // Draw the subsectors belonging to this sector + for (int i=0; isubsectorcount; i++) + { + subsector_t * sub = sector->subsectors[i]; + if (gl_drawinfo->ss_renderflags[sub-subsectors]&renderflags || istrans) + { + if (processlights) SetupSubsectorLights(GLPASS_ALL, sub, &dli); + DrawSubsector(sub); + } + } + } + + // Draw the subsectors assigned to it due to missing textures + if (!(renderflags&SSRF_RENDER3DPLANES)) + { + gl_subsectorrendernode * node = (renderflags&SSRF_RENDERFLOOR)? + gl_drawinfo->GetOtherFloorPlanes(sector->sectornum) : + gl_drawinfo->GetOtherCeilingPlanes(sector->sectornum); + + while (node) + { + if (processlights) SetupSubsectorLights(GLPASS_ALL, node->sub, &dli); + DrawSubsector(node->sub); + node = node->next; + } + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLFlat::Draw(int pass, bool trans) // trans only has meaning for GLPASS_LIGHTSONLY +{ + int rel = getExtraLight(); + +#ifdef _DEBUG + if (sector->sectornum == gl_breaksec) + { + int a = 0; + } +#endif + + + switch (pass) + { + case GLPASS_PLAIN: // Single-pass rendering + case GLPASS_ALL: + gl_SetColor(lightlevel, rel, Colormap,1.0f); + gl_SetFog(lightlevel, rel, &Colormap, false); + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); + gl_SetPlaneTextureRotation(&plane, gltexture); + DrawSubsectors(pass, (pass == GLPASS_ALL || dynlightindex > -1), false); + gl_RenderState.EnableTextureMatrix(false); + break; + + case GLPASS_LIGHTSONLY: + if (!trans || gltexture) + { + ProcessLights(trans); + } + break; + + case GLPASS_TRANSLUCENT: + if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE); + gl_SetColor(lightlevel, rel, Colormap, alpha); + gl_SetFog(lightlevel, rel, &Colormap, false); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + if (!gltexture) + { + gl_RenderState.EnableTexture(false); + DrawSubsectors(pass, false, true); + gl_RenderState.EnableTexture(true); + } + else + { + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); + gl_SetPlaneTextureRotation(&plane, gltexture); + DrawSubsectors(pass, true, true); + gl_RenderState.EnableTextureMatrix(false); + } + if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + break; + } +} + + +//========================================================================== +// +// GLFlat::PutFlat +// +// Checks texture, lighting and translucency settings and puts this +// plane in the appropriate render list. +// +//========================================================================== +inline void GLFlat::PutFlat(bool fog) +{ + int list; + + if (gl_fixedcolormap) + { + Colormap.Clear(); + } + if (renderstyle!=STYLE_Translucent || alpha < 1.f - FLT_EPSILON || fog || gltexture == NULL) + { + // translucent 3D floors go into the regular translucent list, translucent portals go into the translucent border list. + list = (renderflags&SSRF_RENDER3DPLANES) ? GLDL_TRANSLUCENT : GLDL_TRANSLUCENTBORDER; + } + else + { + bool masked = gltexture->isMasked() && ((renderflags&SSRF_RENDER3DPLANES) || stack); + list = masked ? GLDL_MASKEDFLATS : GLDL_PLAINFLATS; + } + gl_drawinfo->drawlists[list].AddFlat (this); +} + +//========================================================================== +// +// This draws one flat +// The passed sector does not indicate the area which is rendered. +// It is only used as source for the plane data. +// The whichplane boolean indicates if the flat is a floor(false) or a ceiling(true) +// +//========================================================================== + +void GLFlat::Process(sector_t * model, int whichplane, bool fog) +{ + plane.GetFromSector(model, whichplane); + + if (!fog) + { + if (plane.texture==skyflatnum) return; + + gltexture=FMaterial::ValidateTexture(plane.texture, false, true); + if (!gltexture) return; + if (gltexture->tex->isFullbright()) + { + Colormap.LightColor.r = Colormap.LightColor.g = Colormap.LightColor.b = 0xff; + lightlevel=255; + } + } + else + { + gltexture = NULL; + lightlevel = abs(lightlevel); + } + + // get height from vplane + if (whichplane == sector_t::floor && sector->transdoor) dz = -1; + else dz = 0; + + z = plane.plane.ZatPoint(0.f, 0.f); + + PutFlat(fog); + rendered_flats++; +} + +//========================================================================== +// +// Sets 3D floor info. Common code for all 4 cases +// +//========================================================================== + +void GLFlat::SetFrom3DFloor(F3DFloor *rover, bool top, bool underside) +{ + F3DFloor::planeref & plane = top? rover->top : rover->bottom; + + // FF_FOG requires an inverted logic where to get the light from + lightlist_t *light = P_GetPlaneLight(sector, plane.plane, underside); + lightlevel = *light->p_lightlevel; + + if (rover->flags & FF_FOG) Colormap.LightColor = (light->extra_colormap)->Fade; + else Colormap.CopyLightColor(light->extra_colormap); + + alpha = rover->alpha/255.0f; + renderstyle = rover->flags&FF_ADDITIVETRANS? STYLE_Add : STYLE_Translucent; + if (plane.model->VBOHeightcheck(plane.isceiling)) + { + vboindex = plane.vindex; + } + else + { + vboindex = -1; + } +} + +//========================================================================== +// +// Process a sector's flats for rendering +// This function is only called once per sector. +// Subsequent subsectors are just quickly added to the ss_renderflags array +// +//========================================================================== + +void GLFlat::ProcessSector(sector_t * frontsector) +{ + lightlist_t * light; + +#ifdef _DEBUG + if (frontsector->sectornum==gl_breaksec) + { + int a = 0; + } +#endif + + // Get the real sector for this one. + sector=§ors[frontsector->sectornum]; + extsector_t::xfloor &x = sector->e->XFloor; + this->sub=NULL; + dynlightindex = -1; + + byte &srf = gl_drawinfo->sectorrenderflags[sector->sectornum]; + + // + // + // + // do floors + // + // + // + if (frontsector->floorplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) <= FIXED2FLOAT(viewz)) + { + // process the original floor first. + + srf |= SSRF_RENDERFLOOR; + + lightlevel = gl_ClampLight(frontsector->GetFloorLight()); + Colormap=frontsector->ColorMap; + if ((stack = (frontsector->portals[sector_t::floor] != NULL))) + { + gl_drawinfo->AddFloorStack(sector); + alpha = frontsector->GetAlpha(sector_t::floor)/65536.0f; + } + else + { + alpha = 1.0f-frontsector->GetReflect(sector_t::floor); + } + if (frontsector->VBOHeightcheck(sector_t::floor)) + { + vboindex = frontsector->vboindex[sector_t::floor]; + } + else + { + vboindex = -1; + } + + ceiling=false; + renderflags=SSRF_RENDERFLOOR; + + if (x.ffloors.Size()) + { + light = P_GetPlaneLight(sector, &frontsector->floorplane, false); + if ((!(sector->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING) || !light->fromsector) + && (light->p_lightlevel != &frontsector->lightlevel)) + { + lightlevel = *light->p_lightlevel; + } + + Colormap.CopyLightColor(light->extra_colormap); + } + renderstyle = STYLE_Translucent; + if (alpha!=0.0f) Process(frontsector, false, false); + } + + // + // + // + // do ceilings + // + // + // + if (frontsector->ceilingplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) >= FIXED2FLOAT(viewz)) + { + // process the original ceiling first. + + srf |= SSRF_RENDERCEILING; + + lightlevel = gl_ClampLight(frontsector->GetCeilingLight()); + Colormap=frontsector->ColorMap; + if ((stack = (frontsector->portals[sector_t::ceiling] != NULL))) + { + gl_drawinfo->AddCeilingStack(sector); + alpha = frontsector->GetAlpha(sector_t::ceiling)/65536.0f; + } + else + { + alpha = 1.0f-frontsector->GetReflect(sector_t::ceiling); + } + + if (frontsector->VBOHeightcheck(sector_t::ceiling)) + { + vboindex = frontsector->vboindex[sector_t::ceiling]; + } + else + { + vboindex = -1; + } + + ceiling=true; + renderflags=SSRF_RENDERCEILING; + + if (x.ffloors.Size()) + { + light = P_GetPlaneLight(sector, §or->ceilingplane, true); + + if ((!(sector->GetFlags(sector_t::ceiling)&PLANEF_ABSLIGHTING)) + && (light->p_lightlevel != &frontsector->lightlevel)) + { + lightlevel = *light->p_lightlevel; + } + Colormap.CopyLightColor(light->extra_colormap); + } + renderstyle = STYLE_Translucent; + if (alpha!=0.0f) Process(frontsector, true, false); + } + + // + // + // + // do 3D floors + // + // + // + + stack=false; + if (x.ffloors.Size()) + { + player_t * player=players[consoleplayer].camera->player; + + renderflags=SSRF_RENDER3DPLANES; + srf |= SSRF_RENDER3DPLANES; + // 3d-floors must not overlap! + fixed_t lastceilingheight=sector->CenterCeiling(); // render only in the range of the + fixed_t lastfloorheight=sector->CenterFloor(); // current sector part (if applicable) + F3DFloor * rover; + int k; + + // floors are ordered now top to bottom so scanning the list for the best match + // is no longer necessary. + + ceiling=true; + for(k=0;k<(int)x.ffloors.Size();k++) + { + rover=x.ffloors[k]; + + if ((rover->flags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES)) + { + if (rover->flags&FF_FOG && gl_fixedcolormap) continue; + if (!rover->top.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) + { + fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector)); + if (ff_toptop.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + { + SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG)); + Colormap.FadeColor=frontsector->ColorMap->Fade; + Process(rover->top.model, rover->top.isceiling, !!(rover->flags&FF_FOG)); + } + lastceilingheight=ff_top; + } + } + if (!rover->bottom.copied && !(rover->flags&FF_INVERTPLANES)) + { + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector)); + if (ff_bottombottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + { + SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG)); + Colormap.FadeColor=frontsector->ColorMap->Fade; + Process(rover->bottom.model, rover->bottom.isceiling, !!(rover->flags&FF_FOG)); + } + lastceilingheight=ff_bottom; + if (rover->alpha<255) lastceilingheight++; + } + } + } + } + + ceiling=false; + for(k=x.ffloors.Size()-1;k>=0;k--) + { + rover=x.ffloors[k]; + + if ((rover->flags&(FF_EXISTS|FF_RENDERPLANES|FF_THISINSIDE))==(FF_EXISTS|FF_RENDERPLANES)) + { + if (rover->flags&FF_FOG && gl_fixedcolormap) continue; + if (!rover->bottom.copied && rover->flags&(FF_INVERTPLANES|FF_BOTHPLANES)) + { + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(CenterSpot(sector)); + if (ff_bottom>lastfloorheight || (rover->flags&FF_FIX)) + { + if (FIXED2FLOAT(viewz) >= rover->bottom.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + { + SetFrom3DFloor(rover, false, !(rover->flags&FF_FOG)); + Colormap.FadeColor=frontsector->ColorMap->Fade; + + if (rover->flags&FF_FIX) + { + lightlevel = gl_ClampLight(rover->model->lightlevel); + Colormap = rover->GetColormap(); + } + + Process(rover->bottom.model, rover->bottom.isceiling, !!(rover->flags&FF_FOG)); + } + lastfloorheight=ff_bottom; + } + } + if (!rover->top.copied && !(rover->flags&FF_INVERTPLANES)) + { + fixed_t ff_top=rover->top.plane->ZatPoint(CenterSpot(sector)); + if (ff_top>lastfloorheight) + { + if (FIXED2FLOAT(viewz) >= rover->top.plane->ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy))) + { + SetFrom3DFloor(rover, true, !!(rover->flags&FF_FOG)); + Colormap.FadeColor=frontsector->ColorMap->Fade; + Process(rover->top.model, rover->top.isceiling, !!(rover->flags&FF_FOG)); + } + lastfloorheight=ff_top; + if (rover->alpha<255) lastfloorheight--; + } + } + } + } + } +} + diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp new file mode 100644 index 000000000..bff47e47a --- /dev/null +++ b/src/gl/scene/gl_portal.cpp @@ -0,0 +1,1090 @@ +/* +** gl_portal.cpp +** Generalized portal maintenance classes for skyboxes, horizons etc. +** Requires a stencil buffer! +** +**--------------------------------------------------------------------------- +** Copyright 2004-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "p_local.h" +#include "vectors.h" +#include "c_dispatch.h" +#include "doomstat.h" +#include "a_sharedglobal.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/scene/gl_clipper.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/stereo3d/scoped_color_mask.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" +#include "gl/utility/gl_geometric.h" + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// General portal handling code +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +EXTERN_CVAR(Bool, gl_portals) +EXTERN_CVAR(Bool, gl_noquery) +EXTERN_CVAR(Int, r_mirror_recursions) + +TArray GLPortal::portals; +TArray GLPortal::planestack; +int GLPortal::recursion; +int GLPortal::MirrorFlag; +int GLPortal::PlaneMirrorFlag; +int GLPortal::renderdepth; +int GLPortal::PlaneMirrorMode; +GLuint GLPortal::QueryObject; + +int GLPortal::instack[2]; +bool GLPortal::inskybox; + +UniqueList UniqueSkies; +UniqueList UniqueHorizons; +UniqueList UniquePlaneMirrors; + + + +//========================================================================== +// +// +// +//========================================================================== + +void GLPortal::BeginScene() +{ + UniqueSkies.Clear(); + UniqueHorizons.Clear(); + UniquePlaneMirrors.Clear(); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLPortal::ClearScreen() +{ + bool multi = !!glIsEnabled(GL_MULTISAMPLE); + gl_MatrixStack.Push(gl_RenderState.mViewMatrix); + gl_MatrixStack.Push(gl_RenderState.mProjectionMatrix); + screen->Begin2D(false); + screen->Dim(0, 1.f, 0, 0, SCREENWIDTH, SCREENHEIGHT); + glEnable(GL_DEPTH_TEST); + gl_MatrixStack.Pop(gl_RenderState.mProjectionMatrix); + gl_MatrixStack.Pop(gl_RenderState.mViewMatrix); + gl_RenderState.ApplyMatrices(); + if (multi) glEnable(GL_MULTISAMPLE); + gl_RenderState.Set2DMode(false); +} + + +//----------------------------------------------------------------------------- +// +// DrawPortalStencil +// +//----------------------------------------------------------------------------- +void GLPortal::DrawPortalStencil() +{ + if (mPrimIndices.Size() == 0) + { + bool cap = NeedCap() && lines.Size() > 1; + mPrimIndices.Resize(2 * lines.Size() + 4 * cap); + + for (unsigned int i = 0; imVBO->GetBuffer(); + ptr->Set(-32767.0f, 32767.0f, -32767.0f, 0, 0); + ptr->Set(-32767.0f, 32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, 32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, 32767.0f, -32767.0f, 0, 0); + mPrimIndices[n + 1] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n]); + ptr->Set(-32767.0f, -32767.0f, -32767.0f, 0, 0); + ptr->Set(-32767.0f, -32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, -32767.0f, 32767.0f, 0, 0); + ptr->Set(32767.0f, -32767.0f, -32767.0f, 0, 0); + mPrimIndices[n + 3] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n + 2]); + } + } + gl_RenderState.Apply(); + for (unsigned int i = 0; i < mPrimIndices.Size(); i += 2) + { + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, mPrimIndices[i], mPrimIndices[i + 1]); + } +} + + + + + + +//----------------------------------------------------------------------------- +// +// Start +// +//----------------------------------------------------------------------------- + +bool GLPortal::Start(bool usestencil, bool doquery) +{ + rendered_portals++; + PortalAll.Clock(); + if (usestencil) + { + if (!gl_portals) + { + PortalAll.Unclock(); + return false; + } + + // Create stencil + glStencilFunc(GL_EQUAL,recursion,~0); // create stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); // increment stencil of valid pixels + { + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0,0,0,0); // don't write to the graphics buffer + gl_RenderState.SetEffect(EFF_STENCIL); + gl_RenderState.EnableTexture(false); + gl_RenderState.ResetColor(); + glDepthFunc(GL_LESS); + gl_RenderState.Apply(); + + if (NeedDepthBuffer()) + { + glDepthMask(false); // don't write to Z-buffer! + if (!NeedDepthBuffer()) doquery = false; // too much overhead and nothing to gain. + else if (gl_noquery) doquery = false; + + // If occlusion query is supported let's use it to avoid rendering portals that aren't visible + if (!QueryObject) glGenQueries(1, &QueryObject); + if (QueryObject) + { + glBeginQuery(GL_SAMPLES_PASSED, QueryObject); + } + else doquery = false; // some kind of error happened + + DrawPortalStencil(); + + glEndQuery(GL_SAMPLES_PASSED); + + // Clear Z-buffer + glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil + glDepthMask(true); // enable z-buffer again + glDepthRange(1, 1); + glDepthFunc(GL_ALWAYS); + DrawPortalStencil(); + + // set normal drawing mode + gl_RenderState.EnableTexture(true); + glDepthFunc(GL_LESS); + // glColorMask(1, 1, 1, 1); + gl_RenderState.SetEffect(EFF_NONE); + glDepthRange(0, 1); + + GLuint sampleCount; + + glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT, &sampleCount); + + if (sampleCount == 0) // not visible + { + // restore default stencil op. + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + glStencilFunc(GL_EQUAL, recursion, ~0); // draw sky into stencil + PortalAll.Unclock(); + return false; + } + FDrawInfo::StartDrawInfo(); + } + else + { + // No z-buffer is needed therefore we can skip all the complicated stuff that is involved + // No occlusion queries will be done here. For these portals the overhead is far greater + // than the benefit. + // Note: We must draw the stencil with z-write enabled here because there is no second pass! + + glDepthMask(true); + DrawPortalStencil(); + glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil + gl_RenderState.EnableTexture(true); + // glColorMask(1,1,1,1); + gl_RenderState.SetEffect(EFF_NONE); + glDisable(GL_DEPTH_TEST); + glDepthMask(false); // don't write to Z-buffer! + } + } + recursion++; + + + } + else + { + if (NeedDepthBuffer()) + { + FDrawInfo::StartDrawInfo(); + } + else + { + glDepthMask(false); + glDisable(GL_DEPTH_TEST); + } + } + planestack.Push(gl_RenderState.GetClipHeightTop()); + planestack.Push(gl_RenderState.GetClipHeightBottom()); + glDisable(GL_CLIP_DISTANCE0); + glDisable(GL_CLIP_DISTANCE1); + gl_RenderState.SetClipHeightBottom(-65536.f); + gl_RenderState.SetClipHeightTop(65536.f); + + // save viewpoint + savedviewx=viewx; + savedviewy=viewy; + savedviewz=viewz; + savedviewactor=GLRenderer->mViewActor; + savedviewangle=viewangle; + savedviewarea=in_area; + + NextPortal = GLRenderer->mCurrentPortal; + GLRenderer->mCurrentPortal = NULL; // Portals which need this have to set it themselves + PortalAll.Unclock(); + return true; +} + + +inline void GLPortal::ClearClipper() +{ + fixed_t angleOffset = viewangle - savedviewangle; + + clipper.Clear(); + + static int call=0; + + // Set the clipper to the minimal visible area + clipper.SafeAddClipRange(0,0xffffffff); + for(unsigned int i=0;i0) + { + clipper.SafeRemoveClipRangeRealAngles(startAngle + angleOffset, endAngle + angleOffset); + } + } + + // and finally clip it to the visible area + angle_t a1 = GLRenderer->FrustumAngle(); + if (a1mCurrentPortal = NextPortal; + + float f; + planestack.Pop(f); + gl_RenderState.SetClipHeightBottom(f); + if (f > -65535.f) glEnable(GL_CLIP_DISTANCE0); + planestack.Pop(f); + gl_RenderState.SetClipHeightTop(f); + if (f < 65535.f) glEnable(GL_CLIP_DISTANCE1); + + if (usestencil) + { + if (needdepth) FDrawInfo::EndDrawInfo(); + + // Restore the old view + viewx=savedviewx; + viewy=savedviewy; + viewz=savedviewz; + viewangle=savedviewangle; + GLRenderer->mViewActor=savedviewactor; + in_area=savedviewarea; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); + + { + ScopedColorMask colorMask(0, 0, 0, 0); // glColorMask(0, 0, 0, 0); // no graphics + gl_RenderState.SetEffect(EFF_NONE); + gl_RenderState.ResetColor(); + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(); + + if (needdepth) + { + // first step: reset the depth buffer to max. depth + glDepthRange(1, 1); // always + glDepthFunc(GL_ALWAYS); // write the farthest depth value + DrawPortalStencil(); + } + else + { + glEnable(GL_DEPTH_TEST); + } + + // second step: restore the depth buffer to the previous values and reset the stencil + glDepthFunc(GL_LEQUAL); + glDepthRange(0, 1); + glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); + glStencilFunc(GL_EQUAL, recursion, ~0); // draw sky into stencil + DrawPortalStencil(); + glDepthFunc(GL_LESS); + + + gl_RenderState.EnableTexture(true); + gl_RenderState.SetEffect(EFF_NONE); + } // glColorMask(1, 1, 1, 1); + recursion--; + + // restore old stencil op. + glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); + glStencilFunc(GL_EQUAL,recursion,~0); // draw sky into stencil + } + else + { + if (needdepth) + { + FDrawInfo::EndDrawInfo(); + glClear(GL_DEPTH_BUFFER_BIT); + } + else + { + glEnable(GL_DEPTH_TEST); + glDepthMask(true); + } + // Restore the old view + viewx=savedviewx; + viewy=savedviewy; + viewz=savedviewz; + viewangle=savedviewangle; + GLRenderer->mViewActor=savedviewactor; + in_area=savedviewarea; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + + // This draws a valid z-buffer into the stencil's contents to ensure it + // doesn't get overwritten by the level's geometry. + + gl_RenderState.ResetColor(); + glDepthFunc(GL_LEQUAL); + glDepthRange(0, 1); + { + ScopedColorMask colorMask(0, 0, 0, 0); + // glColorMask(0,0,0,0); // no graphics + gl_RenderState.SetEffect(EFF_STENCIL); + gl_RenderState.EnableTexture(false); + DrawPortalStencil(); + gl_RenderState.SetEffect(EFF_NONE); + gl_RenderState.EnableTexture(true); + } // glColorMask(1, 1, 1, 1); + glDepthFunc(GL_LESS); + } + PortalAll.Unclock(); +} + + +//----------------------------------------------------------------------------- +// +// StartFrame +// +//----------------------------------------------------------------------------- +void GLPortal::StartFrame() +{ + GLPortal * p=NULL; + portals.Push(p); + if (renderdepth==0) + { + inskybox=false; + instack[sector_t::floor]=instack[sector_t::ceiling]=0; + } + renderdepth++; +} + + +//----------------------------------------------------------------------------- +// +// Portal info +// +//----------------------------------------------------------------------------- + +static bool gl_portalinfo; + +CCMD(gl_portalinfo) +{ + gl_portalinfo = true; +} + +FString indent; + +//----------------------------------------------------------------------------- +// +// EndFrame +// +//----------------------------------------------------------------------------- + +void GLPortal::EndFrame() +{ + GLPortal * p; + + if (gl_portalinfo) + { + Printf("%s%d portals, depth = %d\n%s{\n", indent.GetChars(), portals.Size(), renderdepth, indent.GetChars()); + indent += " "; + } + + // Only use occlusion query if there are more than 2 portals. + // Otherwise there's too much overhead. + // (And don't forget to consider the separating NULL pointers!) + bool usequery = portals.Size() > 2 + (unsigned)renderdepth; + + while (portals.Pop(p) && p) + { + if (gl_portalinfo) + { + Printf("%sProcessing %s, depth = %d, query = %d\n", indent.GetChars(), p->GetName(), renderdepth, usequery); + } + if (p->lines.Size() > 0) + { + p->RenderPortal(true, usequery); + } + delete p; + } + renderdepth--; + + if (gl_portalinfo) + { + indent.Truncate(long(indent.Len()-2)); + Printf("%s}\n", indent.GetChars()); + if (portals.Size() == 0) gl_portalinfo = false; + } +} + + +//----------------------------------------------------------------------------- +// +// Renders one sky portal without a stencil. +// In more complex scenes using a stencil for skies can severly stall +// the GPU and there's rarely more than one sky visible at a time. +// +//----------------------------------------------------------------------------- +bool GLPortal::RenderFirstSkyPortal(int recursion) +{ + GLPortal * p; + GLPortal * best = NULL; + unsigned bestindex=0; + + // Find the one with the highest amount of lines. + // Normally this is also the one that saves the largest amount + // of time by drawing it before the scene itself. + for(int i = portals.Size()-1; i >= 0 && portals[i] != NULL; --i) + { + p=portals[i]; + if (p->lines.Size() > 0 && p->IsSky()) + { + // Cannot clear the depth buffer inside a portal recursion + if (recursion && p->NeedDepthBuffer()) continue; + + if (!best || p->lines.Size()>best->lines.Size()) + { + best=p; + bestindex=i; + } + } + } + + if (best) + { + portals.Delete(bestindex); + best->RenderPortal(false, false); + delete best; + return true; + } + return false; +} + + +//----------------------------------------------------------------------------- +// +// FindPortal +// +//----------------------------------------------------------------------------- + +GLPortal * GLPortal::FindPortal(const void * src) +{ + int i=portals.Size()-1; + + while (i>=0 && portals[i] && portals[i]->GetSource()!=src) i--; + return i>=0? portals[i]:NULL; +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void GLPortal::SaveMapSection() +{ + savedmapsection.Resize(currentmapsection.Size()); + memcpy(&savedmapsection[0], ¤tmapsection[0], currentmapsection.Size()); + memset(¤tmapsection[0], 0, currentmapsection.Size()); +} + +void GLPortal::RestoreMapSection() +{ + memcpy(¤tmapsection[0], &savedmapsection[0], currentmapsection.Size()); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Skybox Portal +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// +// GLSkyboxPortal::DrawContents +// +//----------------------------------------------------------------------------- +static int skyboxrecursion=0; +void GLSkyboxPortal::DrawContents() +{ + int old_pm=PlaneMirrorMode; + int saved_extralight = extralight; + + if (skyboxrecursion>=3) + { + ClearScreen(); + return; + } + + skyboxrecursion++; + origin->flags|=MF_JUSTHIT; + extralight = 0; + + PlaneMirrorMode=0; + + bool oldclamp = gl_RenderState.SetDepthClamp(false); + viewx = origin->PrevX + FixedMul(r_TicFrac, origin->x - origin->PrevX); + viewy = origin->PrevY + FixedMul(r_TicFrac, origin->y - origin->PrevY); + viewz = origin->PrevZ + FixedMul(r_TicFrac, origin->z - origin->PrevZ); + viewangle += origin->PrevAngle + FixedMul(r_TicFrac, origin->angle - origin->PrevAngle); + + // Don't let the viewpoint be too close to a floor or ceiling! + fixed_t floorh = origin->Sector->floorplane.ZatPoint(origin->x, origin->y); + fixed_t ceilh = origin->Sector->ceilingplane.ZatPoint(origin->x, origin->y); + if (viewzceilh-4*FRACUNIT) viewz=ceilh-4*FRACUNIT; + + + GLRenderer->mViewActor = origin; + + validcount++; + inskybox=true; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + GLRenderer->SetViewArea(); + ClearClipper(); + + int mapsection = R_PointInSubsector(viewx, viewy)->mapsection; + + SaveMapSection(); + currentmapsection[mapsection>>3] |= 1 << (mapsection & 7); + + GLRenderer->DrawScene(); + origin->flags&=~MF_JUSTHIT; + inskybox=false; + gl_RenderState.SetDepthClamp(oldclamp); + skyboxrecursion--; + + PlaneMirrorMode=old_pm; + extralight = saved_extralight; + + RestoreMapSection(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Sector stack Portal +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +GLSectorStackPortal::~GLSectorStackPortal() +{ + if (origin != NULL && origin->glportal == this) + { + origin->glportal = NULL; + } +} + +//----------------------------------------------------------------------------- +// +// GLSectorStackPortal::SetupCoverage +// +//----------------------------------------------------------------------------- + +static BYTE SetCoverage(void *node) +{ + if (numnodes == 0) + { + return 0; + } + if (!((size_t)node & 1)) // Keep going until found a subsector + { + node_t *bsp = (node_t *)node; + BYTE coverage = SetCoverage(bsp->children[0]) | SetCoverage(bsp->children[1]); + gl_drawinfo->no_renderflags[bsp-nodes] = coverage; + return coverage; + } + else + { + subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + return gl_drawinfo->ss_renderflags[sub-subsectors] & SSRF_SEEN; + } +} + +void GLSectorStackPortal::SetupCoverage() +{ + for(unsigned i=0; iplane; + for(int j=0;jportalcoverage[plane].sscount; j++) + { + subsector_t *dsub = &::subsectors[sub->portalcoverage[plane].subsectors[j]]; + currentmapsection[dsub->mapsection>>3] |= 1 << (dsub->mapsection&7); + gl_drawinfo->ss_renderflags[dsub-::subsectors] |= SSRF_SEEN; + } + } + SetCoverage(&nodes[numnodes-1]); +} + +//----------------------------------------------------------------------------- +// +// GLSectorStackPortal::DrawContents +// +//----------------------------------------------------------------------------- +void GLSectorStackPortal::DrawContents() +{ + FPortal *portal = origin; + + viewx += origin->xDisplacement; + viewy += origin->yDisplacement; + GLRenderer->mViewActor = NULL; + GLRenderer->mCurrentPortal = this; + + + validcount++; + + // avoid recursions! + if (origin->plane != -1) instack[origin->plane]++; + + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + SaveMapSection(); + SetupCoverage(); + ClearClipper(); + GLRenderer->DrawScene(); + RestoreMapSection(); + + if (origin->plane != -1) instack[origin->plane]--; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Plane Mirror Portal +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// +// GLPlaneMirrorPortal::DrawContents +// +//----------------------------------------------------------------------------- + +void GLPlaneMirrorPortal::DrawContents() +{ + if (renderdepth>r_mirror_recursions) + { + ClearScreen(); + return; + } + + int old_pm=PlaneMirrorMode; + + fixed_t planez = origin->ZatPoint(viewx, viewy); + viewz = 2*planez - viewz; + GLRenderer->mViewActor = NULL; + PlaneMirrorMode = ksgn(origin->c); + + validcount++; + + PlaneMirrorFlag++; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + ClearClipper(); + + float f = FIXED2FLOAT(planez); + if (PlaneMirrorMode < 0) + { + gl_RenderState.SetClipHeightTop(f); // ceiling mirror: clip everything with a z lower than the portal's ceiling + glEnable(GL_CLIP_DISTANCE1); + } + else + { + gl_RenderState.SetClipHeightBottom(f); // floor mirror: clip everything with a z higher than the portal's floor + glEnable(GL_CLIP_DISTANCE0); + } + + GLRenderer->DrawScene(); + glDisable(GL_CLIP_DISTANCE0); + glDisable(GL_CLIP_DISTANCE1); + gl_RenderState.SetClipHeightBottom(-65536.f); + gl_RenderState.SetClipHeightTop(65536.f); + PlaneMirrorFlag--; + PlaneMirrorMode=old_pm; +} + +//----------------------------------------------------------------------------- +// +// GLPlaneMirrorPortal::DrawContents +// +//----------------------------------------------------------------------------- + + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Mirror Portal +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// +// R_EnterMirror +// +//----------------------------------------------------------------------------- +void GLMirrorPortal::DrawContents() +{ + if (renderdepth>r_mirror_recursions) + { + ClearScreen(); + return; + } + + GLRenderer->mCurrentPortal = this; + angle_t startang = viewangle; + fixed_t startx = viewx; + fixed_t starty = viewy; + + vertex_t *v1 = linedef->v1; + vertex_t *v2 = linedef->v2; + + // Reflect the current view behind the mirror. + if (linedef->dx == 0) + { + // vertical mirror + viewx = v1->x - startx + v1->x; + + // Compensation for reendering inaccuracies + if (startxx) viewx -= FRACUNIT/2; + else viewx += FRACUNIT/2; + } + else if (linedef->dy == 0) + { + // horizontal mirror + viewy = v1->y - starty + v1->y; + + // Compensation for reendering inaccuracies + if (startyy) viewy -= FRACUNIT/2; + else viewy += FRACUNIT/2; + } + else + { + // any mirror--use floats to avoid integer overflow. + // Use doubles to avoid losing precision which is very important here. + + double dx = FIXED2DBL(v2->x - v1->x); + double dy = FIXED2DBL(v2->y - v1->y); + double x1 = FIXED2DBL(v1->x); + double y1 = FIXED2DBL(v1->y); + double x = FIXED2DBL(startx); + double y = FIXED2DBL(starty); + + // the above two cases catch len == 0 + double r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy); + + viewx = FLOAT2FIXED((x1 + r * dx)*2 - x); + viewy = FLOAT2FIXED((y1 + r * dy)*2 - y); + + // Compensation for reendering inaccuracies + FVector2 v(-dx, dy); + v.MakeUnit(); + + viewx+= FLOAT2FIXED(v[1] * renderdepth / 2); + viewy+= FLOAT2FIXED(v[0] * renderdepth / 2); + } + // we cannot afford any imprecisions caused by R_PointToAngle2 here. They'd be visible as seams around the mirror. + viewangle = 2*R_PointToAnglePrecise (linedef->v1->x, linedef->v1->y, + linedef->v2->x, linedef->v2->y) - startang; + + GLRenderer->mViewActor = NULL; + + validcount++; + + MirrorFlag++; + GLRenderer->SetupView(viewx, viewy, viewz, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + + clipper.Clear(); + + angle_t af = GLRenderer->FrustumAngle(); + if (afv1->GetClipAngle(); + angle_t a1 = linedef->v2->GetClipAngle(); + clipper.SafeAddClipRange(a1,a2); + + GLRenderer->DrawScene(); + + MirrorFlag--; +} + + +int GLMirrorPortal::ClipSeg(seg_t *seg) +{ + // this seg is completely behind the mirror! + if (P_PointOnLineSide(seg->v1->x, seg->v1->y, linedef) && + P_PointOnLineSide(seg->v2->x, seg->v2->y, linedef)) + { + return PClip_InFront; + } + return PClip_Inside; +} + +int GLMirrorPortal::ClipPoint(fixed_t x, fixed_t y) +{ + if (P_PointOnLineSide(x, y, linedef)) + { + return PClip_InFront; + } + return PClip_Inside; +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Horizon Portal +// +// This simply draws the area in medium sized squares. Drawing it as a whole +// polygon creates visible inaccuracies. +// +// Originally I tried to minimize the amount of data to be drawn but there +// are 2 problems with it: +// +// 1. Setting this up completely negates any performance gains. +// 2. It doesn't work with a 360° field of view (as when you are looking up.) +// +// +// So the brute force mechanism is just as good. +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// GLHorizonPortal::DrawContents +// +//----------------------------------------------------------------------------- +void GLHorizonPortal::DrawContents() +{ + PortalAll.Clock(); + + GLSectorPlane * sp=&origin->plane; + FMaterial * gltexture; + PalEntry color; + float z; + player_t * player=&players[consoleplayer]; + + gltexture=FMaterial::ValidateTexture(sp->texture, false, true); + if (!gltexture) + { + ClearScreen(); + PortalAll.Unclock(); + return; + } + + + z=FIXED2FLOAT(sp->texheight); + + + if (gltexture && gltexture->tex->isFullbright()) + { + // glowing textures are always drawn full bright without color + gl_SetColor(255, 0, origin->colormap, 1.f); + gl_SetFog(255, 0, &origin->colormap, false); + } + else + { + int rel = getExtraLight(); + gl_SetColor(origin->lightlevel, rel, origin->colormap, 1.0f); + gl_SetFog(origin->lightlevel, rel, &origin->colormap, false); + } + + + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); + + gl_SetPlaneTextureRotation(sp, gltexture); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); + gl_RenderState.Apply(); + + + + float vx=FIXED2FLOAT(viewx); + float vy=FIXED2FLOAT(viewy); + + // Draw to some far away boundary + // This is not drawn as larher strips because it causes visual glitches. + for(float x=-32768+vx; x<32768+vx; x+=4096) + { + for(float y=-32768+vy; y<32768+vy;y+=4096) + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x, z, y, x / 64, -y / 64); + ptr++; + ptr->Set(x + 4096, z, y, x / 64 + 64, -y / 64); + ptr++; + ptr->Set(x, z, y + 4096, x / 64, -y / 64 - 64); + ptr++; + ptr->Set(x + 4096, z, y + 4096, x / 64 + 64, -y / 64 - 64); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + } + + float vz=FIXED2FLOAT(viewz); + float tz=(z-vz);///64.0f; + + // fill the gap between the polygon and the true horizon + // Since I can't draw into infinity there can always be a + // small gap + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz); + ptr++; + ptr->Set(-32768 + vx, z, 32768 + vy, -512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, 32768 + vy, -512.f, tz); + ptr++; + ptr->Set(32768 + vx, z, 32768 + vy, 512.f, 0); + ptr++; + ptr->Set(32768 + vx, vz, 32768 + vy, 512.f, tz); + ptr++; + ptr->Set(32768 + vx, z, -32768 + vy, -512.f, 0); + ptr++; + ptr->Set(32768 + vx, vz, -32768 + vy, -512.f, tz); + ptr++; + ptr->Set(-32768 + vx, z, -32768 + vy, 512.f, 0); + ptr++; + ptr->Set(-32768 + vx, vz, -32768 + vy, 512.f, tz); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + gl_RenderState.EnableTextureMatrix(false); + PortalAll.Unclock(); + +} + +const char *GLSkyPortal::GetName() { return "Sky"; } +const char *GLSkyboxPortal::GetName() { return "Skybox"; } +const char *GLSectorStackPortal::GetName() { return "Sectorstack"; } +const char *GLPlaneMirrorPortal::GetName() { return "Planemirror"; } +const char *GLMirrorPortal::GetName() { return "Mirror"; } +const char *GLHorizonPortal::GetName() { return "Horizon"; } diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h new file mode 100644 index 000000000..ccc6d174d --- /dev/null +++ b/src/gl/scene/gl_portal.h @@ -0,0 +1,301 @@ +/* +** gl_renderstruct.h +** Generalized portal maintenance classes to make rendering special effects easier +** and help add future extensions +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 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. +**--------------------------------------------------------------------------- +** +*/ + +#ifndef __GL_PORTAL_H +#define __GL_PORTAL_H + +#include "tarray.h" +//#include "gl/gl_intern.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/utility/gl_templates.h" + +class ASkyViewpoint; + +struct GLHorizonInfo +{ + GLSectorPlane plane; + int lightlevel; + FColormap colormap; +}; + +struct GLSkyInfo +{ + float x_offset[2]; + float y_offset; // doubleskies don't have a y-offset + FMaterial * texture[2]; + FTextureID skytexno1; + bool mirrored; + bool doublesky; + bool sky2; + PalEntry fadecolor; // if this isn't made part of the dome things will become more complicated when sky fog is used. + + bool operator==(const GLSkyInfo & inf) + { + return !memcmp(this, &inf, sizeof(*this)); + } + bool operator!=(const GLSkyInfo & inf) + { + return !!memcmp(this, &inf, sizeof(*this)); + } +}; + +extern UniqueList UniqueSkies; +extern UniqueList UniqueHorizons; +extern UniqueList UniquePlaneMirrors; + +class GLPortal +{ + static TArray portals; + static int recursion; + static unsigned int QueryObject; +protected: + static TArray planestack; + static int MirrorFlag; + static int PlaneMirrorFlag; + static int renderdepth; + +public: + static int PlaneMirrorMode; + static int inupperstack; + static int instack[2]; + static bool inskybox; + +private: + void DrawPortalStencil(); + + fixed_t savedviewx; + fixed_t savedviewy; + fixed_t savedviewz; + angle_t savedviewangle; + AActor * savedviewactor; + area_t savedviewarea; + GLPortal *NextPortal; + TArray savedmapsection; + TArray mPrimIndices; + +protected: + TArray lines; + int level; + + GLPortal() { portals.Push(this); } + virtual ~GLPortal() { } + + bool Start(bool usestencil, bool doquery); + void End(bool usestencil); + virtual void DrawContents()=0; + virtual void * GetSource() const =0; // GetSource MUST be implemented! + void ClearClipper(); + virtual bool IsSky() { return false; } + virtual bool NeedCap() { return true; } + virtual bool NeedDepthBuffer() { return true; } + void ClearScreen(); + virtual const char *GetName() = 0; + void SaveMapSection(); + void RestoreMapSection(); + +public: + + enum + { + PClip_InFront, + PClip_Inside, + PClip_Behind + }; + + void RenderPortal(bool usestencil, bool doquery) + { + // Start may perform an occlusion query. If that returns 0 there + // is no need to draw the stencil's contents and there's also no + // need to restore the affected area becasue there is none! + if (Start(usestencil, doquery)) + { + DrawContents(); + End(usestencil); + } + } + + void AddLine(GLWall * l) + { + lines.Push(*l); + } + + static int GetRecursion() + { + return recursion; + } + + virtual int ClipSeg(seg_t *seg) { return PClip_Inside; } + virtual int ClipPoint(fixed_t x, fixed_t y) { return PClip_Inside; } + + static void BeginScene(); + static void StartFrame(); + static bool RenderFirstSkyPortal(int recursion); + static void EndFrame(); + static GLPortal * FindPortal(const void * src); +}; + + +struct GLMirrorPortal : public GLPortal +{ + // mirror portals always consist of single linedefs! + line_t * linedef; + +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return linedef; } + virtual const char *GetName(); + +public: + + GLMirrorPortal(line_t * line) + { + linedef=line; + } + + virtual bool NeedCap() { return false; } + virtual int ClipSeg(seg_t *seg); + virtual int ClipPoint(fixed_t x, fixed_t y); +}; + + +struct GLSkyboxPortal : public GLPortal +{ + AActor * origin; + +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return origin; } + virtual bool IsSky() { return true; } // later! + virtual const char *GetName(); + +public: + + + GLSkyboxPortal(AActor * pt) + { + origin=pt; + } + +}; + + +struct GLSkyPortal : public GLPortal +{ + GLSkyInfo * origin; + +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return origin; } + virtual bool IsSky() { return true; } + virtual bool NeedDepthBuffer() { return false; } + virtual const char *GetName(); + +public: + + + GLSkyPortal(GLSkyInfo * pt) + { + origin=pt; + } + +}; + + + +struct GLSectorStackPortal : public GLPortal +{ + TArray subsectors; +protected: + virtual ~GLSectorStackPortal(); + virtual void DrawContents(); + virtual void * GetSource() const { return origin; } + virtual bool IsSky() { return true; } // although this isn't a real sky it can be handled as one. + virtual const char *GetName(); + FPortal *origin; + +public: + + GLSectorStackPortal(FPortal *pt) + { + origin=pt; + } + void SetupCoverage(); + void AddSubsector(subsector_t *sub) + { + subsectors.Push(sub); + } + +}; + +struct GLPlaneMirrorPortal : public GLPortal +{ +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return origin; } + virtual const char *GetName(); + secplane_t * origin; + +public: + + GLPlaneMirrorPortal(secplane_t * pt) + { + origin=pt; + } + +}; + + +struct GLHorizonPortal : public GLPortal +{ + GLHorizonInfo * origin; + +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return origin; } + virtual bool NeedDepthBuffer() { return false; } + virtual bool NeedCap() { return false; } + virtual const char *GetName(); + +public: + + GLHorizonPortal(GLHorizonInfo * pt) + { + origin=pt; + } + +}; + +#endif diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp new file mode 100644 index 000000000..2a3839037 --- /dev/null +++ b/src/gl/scene/gl_renderhacks.cpp @@ -0,0 +1,1238 @@ +/* +** gl_missingtexture.cpp +** Handles missing upper and lower textures and self referencing sector hacks +** +**--------------------------------------------------------------------------- +** Copyright 2000-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "a_sharedglobal.h" +#include "r_utility.h" +#include "r_defs.h" +#include "r_sky.h" +#include "g_level.h" + + +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" + + +// This is for debugging maps. + +FreeList SSR_List; + +// profiling data +static int totalupper, totallower; +static int lowershcount, uppershcount; +static glcycle_t totalms, showtotalms; +static glcycle_t totalssms; +static sector_t fakesec; + +void FDrawInfo::ClearBuffers() +{ + for(unsigned int i=0;i< otherfloorplanes.Size();i++) + { + gl_subsectorrendernode * node = otherfloorplanes[i]; + while (node) + { + gl_subsectorrendernode * n = node; + node = node->next; + SSR_List.Release(n); + } + } + otherfloorplanes.Clear(); + + for(unsigned int i=0;i< otherceilingplanes.Size();i++) + { + gl_subsectorrendernode * node = otherceilingplanes[i]; + while (node) + { + gl_subsectorrendernode * n = node; + node = node->next; + SSR_List.Release(n); + } + } + otherceilingplanes.Clear(); + + // clear all the lists that might not have been cleared already + MissingUpperTextures.Clear(); + MissingLowerTextures.Clear(); + MissingUpperSegs.Clear(); + MissingLowerSegs.Clear(); + SubsectorHacks.Clear(); + CeilingStacks.Clear(); + FloorStacks.Clear(); + HandledSubsectors.Clear(); + +} +//========================================================================== +// +// Adds a subsector plane to a sector's render list +// +//========================================================================== + +void FDrawInfo::AddOtherFloorPlane(int sector, gl_subsectorrendernode * node) +{ + int oldcnt = otherfloorplanes.Size(); + + if (oldcnt<=sector) + { + otherfloorplanes.Resize(sector+1); + for(int i=oldcnt;i<=sector;i++) otherfloorplanes[i]=NULL; + } + node->next = otherfloorplanes[sector]; + otherfloorplanes[sector] = node; +} + +void FDrawInfo::AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node) +{ + int oldcnt = otherceilingplanes.Size(); + + if (oldcnt<=sector) + { + otherceilingplanes.Resize(sector+1); + for(int i=oldcnt;i<=sector;i++) otherceilingplanes[i]=NULL; + } + node->next = otherceilingplanes[sector]; + otherceilingplanes[sector] = node; +} + + +//========================================================================== +// +// Collects all sectors that might need a fake ceiling +// +//========================================================================== +void FDrawInfo::AddUpperMissingTexture(side_t * side, subsector_t *sub, fixed_t backheight) +{ + if (!side->segs[0]->backsector) return; + + totalms.Clock(); + for(int i=0; inumsegs; i++) + { + seg_t *seg = side->segs[i]; + + // we need find the seg belonging to the passed subsector + if (seg->Subsector == sub) + { + MissingTextureInfo mti = {}; + MissingSegInfo msi; + + + if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) + { + totalms.Unclock(); + return; + } + + for(unsigned int i=0;isegs[0]->backsector; + if (!backsec) return; + if (backsec->transdoor) + { + // Transparent door hacks alter the backsector's floor height so we should not + // process the missing texture for them. + if (backsec->transdoorheight == backsec->GetPlaneTexZ(sector_t::floor)) return; + } + + totalms.Clock(); + // we need to check all segs of this sidedef + for(int i=0; inumsegs; i++) + { + seg_t *seg = side->segs[i]; + + // we need find the seg belonging to the passed subsector + if (seg->Subsector == sub) + { + MissingTextureInfo mti = {}; + MissingSegInfo msi; + + subsector_t * sub = seg->Subsector; + + if (sub->render_sector != sub->sector || seg->frontsector != sub->sector) + { + totalms.Unclock(); + return; + } + + // Ignore FF_FIX's because they are designed to abuse missing textures + if (seg->backsector->e->XFloor.ffloors.Size() && (seg->backsector->e->XFloor.ffloors[0]->flags&(FF_FIX|FF_SEETHROUGH)) == FF_FIX) + { + totalms.Unclock(); + return; + } + + for(unsigned int i=0;i MissingLowerTextures[i].planez) + { + MissingLowerTextures[i].planez = backheight; + MissingLowerTextures[i].seg = seg; + } + + msi.MTI_Index = i; + msi.seg=seg; + MissingLowerSegs.Push(msi); + totalms.Unclock(); + return; + } + } + mti.seg=seg; + mti.sub = sub; + mti.planez=backheight; + msi.MTI_Index = MissingLowerTextures.Push(mti); + msi.seg=seg; + MissingLowerSegs.Push(msi); + } + } + totalms.Unclock(); +} + + +//========================================================================== +// +// +// +//========================================================================== +bool FDrawInfo::DoOneSectorUpper(subsector_t * subsec, fixed_t planez) +{ + // Is there a one-sided wall in this sector? + // Do this first to avoid unnecessary recursion + for(DWORD i=0; i< subsec->numlines; i++) + { + if (subsec->firstline[i].backsector == NULL) return false; + if (subsec->firstline[i].PartnerSeg == NULL) return false; + } + + for(DWORD i=0; i< subsec->numlines; i++) + { + seg_t * seg = subsec->firstline +i; + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // already checked? + if (backsub->validcount == validcount) continue; + backsub->validcount=validcount; + + if (seg->frontsector != seg->backsector && seg->linedef) + { + // Note: if this is a real line between sectors + // we can be sure that render_sector is the real sector! + + sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true); + + // Don't bother with slopes + if (sec->ceilingplane.a!=0 || sec->ceilingplane.b!=0) return false; + + // Is the neighboring ceiling lower than the desired height? + if (sec->GetPlaneTexZ(sector_t::ceiling)GetPlaneTexZ(sector_t::ceiling)==planez) + { + // If there's a texture abort + FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::top)]; + if (!tex || tex->UseType==FTexture::TEX_Null) continue; + else return false; + } + } + if (!DoOneSectorUpper(backsub, planez)) return false; + } + // all checked ok. This subsector is part of the current fake plane + + HandledSubsectors.Push(subsec); + return 1; +} + +//========================================================================== +// +// +// +//========================================================================== +bool FDrawInfo::DoOneSectorLower(subsector_t * subsec, fixed_t planez) +{ + // Is there a one-sided wall in this subsector? + // Do this first to avoid unnecessary recursion + for(DWORD i=0; i< subsec->numlines; i++) + { + if (subsec->firstline[i].backsector == NULL) return false; + if (subsec->firstline[i].PartnerSeg == NULL) return false; + } + + for(DWORD i=0; i< subsec->numlines; i++) + { + seg_t * seg = subsec->firstline + i; + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // already checked? + if (backsub->validcount == validcount) continue; + backsub->validcount=validcount; + + if (seg->frontsector != seg->backsector && seg->linedef) + { + // Note: if this is a real line between sectors + // we can be sure that render_sector is the real sector! + + sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true); + + // Don't bother with slopes + if (sec->floorplane.a!=0 || sec->floorplane.b!=0) return false; + + // Is the neighboring floor higher than the desired height? + if (sec->GetPlaneTexZ(sector_t::floor)>planez) + { + // todo: check for missing textures. + return false; + } + + // This is an exact height match which means we don't have to do any further checks for this sector + if (sec->GetPlaneTexZ(sector_t::floor)==planez) + { + // If there's a texture abort + FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::bottom)]; + if (!tex || tex->UseType==FTexture::TEX_Null) continue; + else return false; + } + } + if (!DoOneSectorLower(backsub, planez)) return false; + } + // all checked ok. This sector is part of the current fake plane + + HandledSubsectors.Push(subsec); + return 1; +} + + +//========================================================================== +// +// +// +//========================================================================== +bool FDrawInfo::DoFakeBridge(subsector_t * subsec, fixed_t planez) +{ + // Is there a one-sided wall in this sector? + // Do this first to avoid unnecessary recursion + for(DWORD i=0; i< subsec->numlines; i++) + { + if (subsec->firstline[i].backsector == NULL) return false; + if (subsec->firstline[i].PartnerSeg == NULL) return false; + } + + for(DWORD i=0; i< subsec->numlines; i++) + { + seg_t * seg = subsec->firstline + i; + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // already checked? + if (backsub->validcount == validcount) continue; + backsub->validcount=validcount; + + if (seg->frontsector != seg->backsector && seg->linedef) + { + // Note: if this is a real line between sectors + // we can be sure that render_sector is the real sector! + + sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true); + + // Don't bother with slopes + if (sec->floorplane.a!=0 || sec->floorplane.b!=0) return false; + + // Is the neighboring floor higher than the desired height? + if (sec->GetPlaneTexZ(sector_t::floor)GetPlaneTexZ(sector_t::floor)==planez) continue; + } + if (!DoFakeBridge(backsub, planez)) return false; + } + // all checked ok. This sector is part of the current fake plane + + HandledSubsectors.Push(subsec); + return 1; +} + +//========================================================================== +// +// +// +//========================================================================== +bool FDrawInfo::DoFakeCeilingBridge(subsector_t * subsec, fixed_t planez) +{ + // Is there a one-sided wall in this sector? + // Do this first to avoid unnecessary recursion + for(DWORD i=0; i< subsec->numlines; i++) + { + if (subsec->firstline[i].backsector == NULL) return false; + if (subsec->firstline[i].PartnerSeg == NULL) return false; + } + + for(DWORD i=0; i< subsec->numlines; i++) + { + seg_t * seg = subsec->firstline + i; + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // already checked? + if (backsub->validcount == validcount) continue; + backsub->validcount=validcount; + + if (seg->frontsector != seg->backsector && seg->linedef) + { + // Note: if this is a real line between sectors + // we can be sure that render_sector is the real sector! + + sector_t * sec = gl_FakeFlat(seg->backsector, &fakesec, true); + + // Don't bother with slopes + if (sec->ceilingplane.a!=0 || sec->ceilingplane.b!=0) return false; + + // Is the neighboring ceiling higher than the desired height? + if (sec->GetPlaneTexZ(sector_t::ceiling)>planez) + { + // todo: check for missing textures. + return false; + } + + // This is an exact height match which means we don't have to do any further checks for this sector + // No texture checks though! + if (sec->GetPlaneTexZ(sector_t::ceiling)==planez) continue; + } + if (!DoFakeCeilingBridge(backsub, planez)) return false; + } + // all checked ok. This sector is part of the current fake plane + + HandledSubsectors.Push(subsec); + return 1; +} + + +//========================================================================== +// +// Draws the fake planes +// +//========================================================================== +void FDrawInfo::HandleMissingTextures() +{ + sector_t fake; + totalms.Clock(); + totalupper=MissingUpperTextures.Size(); + totallower=MissingLowerTextures.Size(); + + for(unsigned int i=0;i viewz) + { + // close the hole only if all neighboring sectors are an exact height match + // Otherwise just fill in the missing textures. + MissingUpperTextures[i].sub->validcount=validcount; + if (DoOneSectorUpper(MissingUpperTextures[i].sub, MissingUpperTextures[i].planez)) + { + sector_t * sec = MissingUpperTextures[i].seg->backsector; + // The mere fact that this seg has been added to the list means that the back sector + // will be rendered so we can safely assume that it is already in the render list + + for(unsigned int j=0;jsub = HandledSubsectors[j]; + + AddOtherCeilingPlane(sec->sectornum, node); + } + + if (HandledSubsectors.Size()!=1) + { + // mark all subsectors in the missing list that got processed by this + for(unsigned int j=0;jPartnerSeg) continue; + subsector_t *backsub = MissingUpperTextures[i].seg->PartnerSeg->Subsector; + if (!backsub) continue; + validcount++; + HandledSubsectors.Clear(); + + { + // It isn't a hole. Now check whether it might be a fake bridge + sector_t * fakesector = gl_FakeFlat(MissingUpperTextures[i].seg->frontsector, &fake, false); + fixed_t planez = fakesector->GetPlaneTexZ(sector_t::ceiling); + + backsub->validcount=validcount; + if (DoFakeCeilingBridge(backsub, planez)) + { + // The mere fact that this seg has been added to the list means that the back sector + // will be rendered so we can safely assume that it is already in the render list + + for(unsigned int j=0;jsub = HandledSubsectors[j]; + AddOtherCeilingPlane(fakesector->sectornum, node); + } + } + continue; + } + } + + for(unsigned int i=0;ivalidcount=validcount; + if (DoOneSectorLower(MissingLowerTextures[i].sub, MissingLowerTextures[i].planez)) + { + sector_t * sec = MissingLowerTextures[i].seg->backsector; + // The mere fact that this seg has been added to the list means that the back sector + // will be rendered so we can safely assume that it is already in the render list + + for(unsigned int j=0;jsub = HandledSubsectors[j]; + AddOtherFloorPlane(sec->sectornum, node); + } + + if (HandledSubsectors.Size()!=1) + { + // mark all subsectors in the missing list that got processed by this + for(unsigned int j=0;jPartnerSeg) continue; + subsector_t *backsub = MissingLowerTextures[i].seg->PartnerSeg->Subsector; + if (!backsub) continue; + validcount++; + HandledSubsectors.Clear(); + + { + // It isn't a hole. Now check whether it might be a fake bridge + sector_t * fakesector = gl_FakeFlat(MissingLowerTextures[i].seg->frontsector, &fake, false); + fixed_t planez = fakesector->GetPlaneTexZ(sector_t::floor); + + backsub->validcount=validcount; + if (DoFakeBridge(backsub, planez)) + { + // The mere fact that this seg has been added to the list means that the back sector + // will be rendered so we can safely assume that it is already in the render list + + for(unsigned int j=0;jsub = HandledSubsectors[j]; + AddOtherFloorPlane(fakesector->sectornum, node); + } + } + continue; + } + } + + totalms.Unclock(); + showtotalms=totalms; + totalms.Reset(); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::DrawUnhandledMissingTextures() +{ + validcount++; + for(int i=MissingUpperSegs.Size()-1; i>=0; i--) + { + int index = MissingUpperSegs[i].MTI_Index; + if (index>=0 && MissingUpperTextures[index].seg==NULL) continue; + + seg_t * seg = MissingUpperSegs[i].seg; + + // already done! + if (seg->linedef->validcount==validcount) continue; // already done + seg->linedef->validcount=validcount; + if (seg->frontsector->GetPlaneTexZ(sector_t::ceiling) < viewz) continue; // out of sight + //if (seg->frontsector->ceilingpic==skyflatnum) continue; + + // FIXME: The check for degenerate subsectors should be more precise + if (seg->PartnerSeg && (seg->PartnerSeg->Subsector->flags & SSECF_DEGENERATE)) continue; + if (seg->backsector->transdoor) continue; + if (seg->backsector->GetTexture(sector_t::ceiling)==skyflatnum) continue; + if (seg->backsector->portals[sector_t::ceiling] != NULL) continue; + + if (!glset.notexturefill) FloodUpperGap(seg); + } + + validcount++; + for(int i=MissingLowerSegs.Size()-1; i>=0; i--) + { + int index = MissingLowerSegs[i].MTI_Index; + if (index>=0 && MissingLowerTextures[index].seg==NULL) continue; + + seg_t * seg = MissingLowerSegs[i].seg; + + // already done! + if (seg->linedef->validcount==validcount) continue; // already done + seg->linedef->validcount=validcount; + if (!(sectorrenderflags[seg->backsector->sectornum] & SSRF_RENDERFLOOR)) continue; + if (seg->frontsector->GetPlaneTexZ(sector_t::floor) > viewz) continue; // out of sight + if (seg->backsector->transdoor) continue; + if (seg->backsector->GetTexture(sector_t::floor)==skyflatnum) continue; + if (seg->backsector->portals[sector_t::floor] != NULL) continue; + + if (!glset.notexturefill) FloodLowerGap(seg); + } + MissingUpperTextures.Clear(); + MissingLowerTextures.Clear(); + MissingUpperSegs.Clear(); + MissingLowerSegs.Clear(); + +} + +void AppendMissingTextureStats(FString &out) +{ + out.AppendFormat("Missing textures: %d upper, %d lower, %.3f ms\n", + totalupper, totallower, showtotalms.TimeMS()); +} + +ADD_STAT(missingtextures) +{ + FString out; + AppendMissingTextureStats(out); + return out; +} + + +//========================================================================== +// +// Multi-sector deep water hacks +// +//========================================================================== + +void FDrawInfo::AddHackedSubsector(subsector_t * sub) +{ + if (!(level.maptype == MAPTYPE_HEXEN)) + { + SubsectorHackInfo sh={sub, 0}; + SubsectorHacks.Push (sh); + } +} + +//========================================================================== +// +// Finds a subsector whose plane can be used for rendering +// +//========================================================================== + +bool FDrawInfo::CheckAnchorFloor(subsector_t * sub) +{ + // This subsector has a one sided wall and can be used. + if (sub->hacked==3) return true; + if (sub->flags & SSECF_DEGENERATE) return false; + + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (!seg->PartnerSeg) return true; + + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // Find a linedef with a different visplane on the other side. + if (!(backsub->flags & SSECF_DEGENERATE) && seg->linedef && + (sub->render_sector != backsub->render_sector && sub->sector != backsub->sector)) + { + // I'm ignoring slopes, scaling and rotation here. The likelihood of ZDoom maps + // using such crap hacks is simply too small + if (sub->render_sector->GetTexture(sector_t::floor)==backsub->render_sector->GetTexture(sector_t::floor) && + sub->render_sector->GetPlaneTexZ(sector_t::floor)==backsub->render_sector->GetPlaneTexZ(sector_t::floor) && + sub->render_sector->GetFloorLight() == backsub->render_sector->GetFloorLight()) + { + continue; + } + // This means we found an adjoining subsector that clearly would go into another + // visplane. That means that this subsector can be used as an anchor. + return true; + } + } + return false; +} + +//========================================================================== +// +// Collect connected subsectors that have to be rendered with the same plane +// +//========================================================================== +static bool inview; +static subsector_t * viewsubsector; +static TArray lowersegs; + +bool FDrawInfo::CollectSubsectorsFloor(subsector_t * sub, sector_t * anchor) +{ + + // mark it checked + sub->validcount=validcount; + + + // We must collect any subsector that either is connected to this one with a miniseg + // or has the same visplane. + // We must not collect any subsector that has the anchor's visplane! + if (!(sub->flags & SSECF_DEGENERATE)) + { + // Is not being rendered so don't bother. + if (!(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return true; + + if (sub->render_sector->GetTexture(sector_t::floor) != anchor->GetTexture(sector_t::floor) || + sub->render_sector->GetPlaneTexZ(sector_t::floor)!=anchor->GetPlaneTexZ(sector_t::floor) || + sub->render_sector->GetFloorLight() != anchor->GetFloorLight()) + { + if (sub==viewsubsector && viewzGetPlaneTexZ(sector_t::floor)) inview=true; + HandledSubsectors.Push (sub); + } + } + + // We can assume that all segs in this subsector are connected to a subsector that has + // to be checked as well + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // could be an anchor itself. + if (!CheckAnchorFloor (backsub)) // must not be an anchor itself! + { + if (backsub->validcount!=validcount) + { + if (!CollectSubsectorsFloor (backsub, anchor)) return false; + } + } + else if (sub->render_sector == backsub->render_sector) + { + // Any anchor not within the original anchor's visplane terminates the processing. + if (sub->render_sector->GetTexture(sector_t::floor)!=anchor->GetTexture(sector_t::floor) || + sub->render_sector->GetPlaneTexZ(sector_t::floor)!=anchor->GetPlaneTexZ(sector_t::floor) || + sub->render_sector->GetFloorLight() != anchor->GetFloorLight()) + { + return false; + } + } + if (!seg->linedef || (seg->frontsector==seg->backsector && sub->render_sector!=backsub->render_sector)) + lowersegs.Push(seg); + } + } + return true; +} + +//========================================================================== +// +// Finds a subsector whose plane can be used for rendering +// +//========================================================================== + +bool FDrawInfo::CheckAnchorCeiling(subsector_t * sub) +{ + // This subsector has a one sided wall and can be used. + if (sub->hacked==3) return true; + if (sub->flags & SSECF_DEGENERATE) return false; + + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (!seg->PartnerSeg) return true; + + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // Find a linedef with a different visplane on the other side. + if (!(backsub->flags & SSECF_DEGENERATE) && seg->linedef && + (sub->render_sector != backsub->render_sector && sub->sector != backsub->sector)) + { + // I'm ignoring slopes, scaling and rotation here. The likelihood of ZDoom maps + // using such crap hacks is simply too small + if (sub->render_sector->GetTexture(sector_t::ceiling)==backsub->render_sector->GetTexture(sector_t::ceiling) && + sub->render_sector->GetPlaneTexZ(sector_t::ceiling)==backsub->render_sector->GetPlaneTexZ(sector_t::ceiling) && + sub->render_sector->GetCeilingLight() == backsub->render_sector->GetCeilingLight()) + { + continue; + } + // This means we found an adjoining subsector that clearly would go into another + // visplane. That means that this subsector can be used as an anchor. + return true; + } + } + return false; +} + +//========================================================================== +// +// Collect connected subsectors that have to be rendered with the same plane +// +//========================================================================== + +bool FDrawInfo::CollectSubsectorsCeiling(subsector_t * sub, sector_t * anchor) +{ + // mark it checked + sub->validcount=validcount; + + + // We must collect any subsector that either is connected to this one with a miniseg + // or has the same visplane. + // We must not collect any subsector that has the anchor's visplane! + if (!(sub->flags & SSECF_DEGENERATE)) + { + // Is not being rendererd so don't bother. + if (!(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return true; + + if (sub->render_sector->GetTexture(sector_t::ceiling)!=anchor->GetTexture(sector_t::ceiling) || + sub->render_sector->GetPlaneTexZ(sector_t::ceiling)!=anchor->GetPlaneTexZ(sector_t::ceiling) || + sub->render_sector->GetCeilingLight() != anchor->GetCeilingLight()) + { + HandledSubsectors.Push (sub); + } + } + + // We can assume that all segs in this subsector are connected to a subsector that has + // to be checked as well + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + // could be an anchor itself. + if (!CheckAnchorCeiling (backsub)) // must not be an anchor itself! + { + if (backsub->validcount!=validcount) + { + if (!CollectSubsectorsCeiling (backsub, anchor)) return false; + } + } + else if (sub->render_sector == backsub->render_sector) + { + // Any anchor not within the original anchor's visplane terminates the processing. + if (sub->render_sector->GetTexture(sector_t::ceiling)!=anchor->GetTexture(sector_t::ceiling) || + sub->render_sector->GetPlaneTexZ(sector_t::ceiling)!=anchor->GetPlaneTexZ(sector_t::ceiling) || + sub->render_sector->GetCeilingLight() != anchor->GetCeilingLight()) + { + return false; + } + } + } + } + return true; +} + +//========================================================================== +// +// Process the subsectors that have been marked as hacked +// +//========================================================================== + +void FDrawInfo::HandleHackedSubsectors() +{ + lowershcount=uppershcount=0; + totalssms.Reset(); + totalssms.Clock(); + + viewsubsector = R_PointInSubsector(viewx, viewy); + + // Each subsector may only be processed once in this loop! + validcount++; + for(unsigned int i=0;ivalidcount!=validcount && CheckAnchorFloor(sub)) + { + // Now collect everything that is connected with this subsector. + HandledSubsectors.Clear(); + inview=false; + lowersegs.Clear(); + if (CollectSubsectorsFloor(sub, sub->render_sector)) + { + for(unsigned int j=0;jsub = HandledSubsectors[j]; + AddOtherFloorPlane(sub->render_sector->sectornum, node); + } + if (inview) for(unsigned int j=0;jProcessLowerMiniseg (seg, seg->Subsector->render_sector, seg->PartnerSeg->Subsector->render_sector); + } + lowershcount+=HandledSubsectors.Size(); + } + } + } + + // Each subsector may only be processed once in this loop! + validcount++; + for(unsigned int i=0;ivalidcount!=validcount && CheckAnchorCeiling(sub)) + { + // Now collect everything that is connected with this subsector. + HandledSubsectors.Clear(); + if (CollectSubsectorsCeiling(sub, sub->render_sector)) + { + for(unsigned int j=0;jsub = HandledSubsectors[j]; + AddOtherCeilingPlane(sub->render_sector->sectornum, node); + } + uppershcount+=HandledSubsectors.Size(); + } + } + } + + + SubsectorHacks.Clear(); + totalssms.Unclock(); +} + +ADD_STAT(sectorhacks) +{ + FString out; + out.Format("sectorhacks = %.3f ms, %d upper, %d lower\n", totalssms.TimeMS(), uppershcount, lowershcount); + return out; +} + + +//========================================================================== +// +// This merges visplanes that lie inside a sector stack together +// to avoid rendering these unneeded flats +// +//========================================================================== + +void FDrawInfo::AddFloorStack(sector_t * sec) +{ + FloorStacks.Push(sec); +} + +void FDrawInfo::AddCeilingStack(sector_t * sec) +{ + CeilingStacks.Push(sec); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::CollectSectorStacksCeiling(subsector_t * sub, sector_t * anchor) +{ + // mark it checked + sub->validcount=validcount; + + // Has a sector stack or skybox itself! + if (sub->render_sector->portals[sector_t::ceiling] != NULL) return; + + // Don't bother processing unrendered subsectors + if (sub->numlines>2 && !(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return; + + // Must be the exact same visplane + sector_t * me = gl_FakeFlat(sub->render_sector, &fakesec, false); + if (me->GetTexture(sector_t::ceiling) != anchor->GetTexture(sector_t::ceiling) || + me->ceilingplane != anchor->ceilingplane || + me->GetCeilingLight() != anchor->GetCeilingLight() || + me->ColorMap != anchor->ColorMap || + me->GetXOffset(sector_t::ceiling) != anchor->GetXOffset(sector_t::ceiling) || + me->GetYOffset(sector_t::ceiling) != anchor->GetYOffset(sector_t::ceiling) || + me->GetXScale(sector_t::ceiling) != anchor->GetXScale(sector_t::ceiling) || + me->GetYScale(sector_t::ceiling) != anchor->GetYScale(sector_t::ceiling) || + me->GetAngle(sector_t::ceiling) != anchor->GetAngle(sector_t::ceiling)) + { + // different visplane so it can't belong to this stack + return; + } + + HandledSubsectors.Push (sub); + + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + if (backsub->validcount!=validcount) CollectSectorStacksCeiling (backsub, anchor); + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::CollectSectorStacksFloor(subsector_t * sub, sector_t * anchor) +{ + // mark it checked + sub->validcount=validcount; + + // Has a sector stack or skybox itself! + if (sub->render_sector->portals[sector_t::floor] != NULL) return; + + // Don't bother processing unrendered subsectors + if (sub->numlines>2 && !(ss_renderflags[DWORD(sub-subsectors)]&SSRF_PROCESSED)) return; + + // Must be the exact same visplane + sector_t * me = gl_FakeFlat(sub->render_sector, &fakesec, false); + if (me->GetTexture(sector_t::floor) != anchor->GetTexture(sector_t::floor) || + me->floorplane != anchor->floorplane || + me->GetFloorLight() != anchor->GetFloorLight() || + me->ColorMap != anchor->ColorMap || + me->GetXOffset(sector_t::floor) != anchor->GetXOffset(sector_t::floor) || + me->GetYOffset(sector_t::floor) != anchor->GetYOffset(sector_t::floor) || + me->GetXScale(sector_t::floor) != anchor->GetXScale(sector_t::floor) || + me->GetYScale(sector_t::floor) != anchor->GetYScale(sector_t::floor) || + me->GetAngle(sector_t::floor) != anchor->GetAngle(sector_t::floor)) + { + // different visplane so it can't belong to this stack + return; + } + + HandledSubsectors.Push (sub); + + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + if (backsub->validcount!=validcount) CollectSectorStacksFloor (backsub, anchor); + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FDrawInfo::ProcessSectorStacks() +{ + unsigned int i; + sector_t fake; + + validcount++; + for (i=0;iportals[sector_t::ceiling]; + if (portal != NULL) for(int k=0;ksubsectorcount;k++) + { + subsector_t * sub = sec->subsectors[k]; + if (ss_renderflags[sub-subsectors] & SSRF_PROCESSED) + { + HandledSubsectors.Clear(); + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + if (backsub->validcount!=validcount) CollectSectorStacksCeiling (backsub, sec); + } + } + for(unsigned int j=0;jportalcoverage[sector_t::ceiling].subsectors == NULL) + { + gl_BuildPortalCoverage(&sub->portalcoverage[sector_t::ceiling], sub, portal); + } + + portal->GetGLPortal()->AddSubsector(sub); + + if (sec->GetAlpha(sector_t::ceiling) != 0 && sec->GetTexture(sector_t::ceiling) != skyflatnum) + { + gl_subsectorrendernode * node = SSR_List.GetNew(); + node->sub = sub; + AddOtherCeilingPlane(sec->sectornum, node); + } + } + } + } + } + + validcount++; + for (i=0;iportals[sector_t::floor]; + if (portal != NULL) for(int k=0;ksubsectorcount;k++) + { + subsector_t * sub = sec->subsectors[k]; + if (ss_renderflags[sub-subsectors] & SSRF_PROCESSED) + { + HandledSubsectors.Clear(); + for(DWORD j=0;jnumlines;j++) + { + seg_t * seg = sub->firstline + j; + if (seg->PartnerSeg) + { + subsector_t * backsub = seg->PartnerSeg->Subsector; + + if (backsub->validcount!=validcount) CollectSectorStacksFloor (backsub, sec); + } + } + + for(unsigned int j=0;jportalcoverage[sector_t::floor].subsectors == NULL) + { + gl_BuildPortalCoverage(&sub->portalcoverage[sector_t::floor], sub, portal); + } + + GLSectorStackPortal *glportal = portal->GetGLPortal(); + glportal->AddSubsector(sub); + + if (sec->GetAlpha(sector_t::floor) != 0 && sec->GetTexture(sector_t::floor) != skyflatnum) + { + gl_subsectorrendernode * node = SSR_List.GetNew(); + node->sub = sub; + AddOtherFloorPlane(sec->sectornum, node); + } + } + } + } + } + + FloorStacks.Clear(); + CeilingStacks.Clear(); +} + diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp new file mode 100644 index 000000000..7a961d2cd --- /dev/null +++ b/src/gl/scene/gl_scene.cpp @@ -0,0 +1,1232 @@ +/* +** gl_scene.cpp +** manages the rendering of the player's view +** +**--------------------------------------------------------------------------- +** Copyright 2004-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "gi.h" +#include "m_png.h" +#include "m_random.h" +#include "st_stuff.h" +#include "dobject.h" +#include "doomstat.h" +#include "g_level.h" +#include "r_data/r_interpolate.h" +#include "r_utility.h" +#include "d_player.h" +#include "p_effect.h" +#include "sbar.h" +#include "po_man.h" +#include "r_utility.h" +#include "a_hexenglobal.h" +#include "p_local.h" +#include "gl/gl_functions.h" + +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/models/gl_models.h" +#include "gl/scene/gl_clipper.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/stereo3d/gl_stereo3d.h" +#include "gl/stereo3d/scoped_view_shifter.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_convert.h" +#include "gl/utility/gl_templates.h" + +//========================================================================== +// +// CVARs +// +//========================================================================== +CVAR(Bool, gl_texture, true, 0) +CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) + +EXTERN_CVAR (Int, screenblocks) +EXTERN_CVAR (Bool, cl_capfps) +EXTERN_CVAR (Bool, r_deathcamera) + + +extern int viewpitch; + +DWORD gl_fixedcolormap; +area_t in_area; +TArray currentmapsection; + +void gl_ParseDefs(); + +//----------------------------------------------------------------------------- +// +// R_FrustumAngle +// +//----------------------------------------------------------------------------- +angle_t FGLRenderer::FrustumAngle() +{ + float tilt= fabs(mAngles.Pitch); + + // If the pitch is larger than this you can look all around at a FOV of 90° + if (tilt>46.0f) return 0xffffffff; + + // ok, this is a gross hack that barely works... + // but at least it doesn't overestimate too much... + double floatangle=2.0+(45.0+((tilt/1.9)))*mCurrentFoV*48.0/BaseRatioSizes[WidescreenRatio][3]/90.0; + angle_t a1 = FLOAT_TO_ANGLE(floatangle); + if (a1>=ANGLE_180) return 0xffffffff; + return a1; +} + +//----------------------------------------------------------------------------- +// +// Sets the area the camera is in +// +//----------------------------------------------------------------------------- +void FGLRenderer::SetViewArea() +{ + // The render_sector is better suited to represent the current position in GL + viewsector = R_PointInSubsector(viewx, viewy)->render_sector; + + // keep the view within the render sector's floor and ceiling + fixed_t theZ = viewsector->ceilingplane.ZatPoint (viewx, viewy) - 4*FRACUNIT; + if (viewz > theZ) + { + viewz = theZ; + } + + theZ = viewsector->floorplane.ZatPoint (viewx, viewy) + 4*FRACUNIT; + if (viewz < theZ) + { + viewz = theZ; + } + + // Get the heightsec state from the render sector, not the current one! + if (viewsector->heightsec && !(viewsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) + { + in_area = viewz<=viewsector->heightsec->floorplane.ZatPoint(viewx,viewy) ? area_below : + (viewz>viewsector->heightsec->ceilingplane.ZatPoint(viewx,viewy) && + !(viewsector->heightsec->MoreFlags&SECF_FAKEFLOORONLY)) ? area_above:area_normal; + } + else + { + in_area=area_default; // depends on exposed lower sectors + } +} + +//----------------------------------------------------------------------------- +// +// resets the 3D viewport +// +//----------------------------------------------------------------------------- + +void FGLRenderer::ResetViewport() +{ + int trueheight = static_cast(screen)->GetTrueHeight(); // ugh... + glViewport(0, (trueheight-screen->GetHeight())/2, screen->GetWidth(), screen->GetHeight()); +} + +//----------------------------------------------------------------------------- +// +// sets 3D viewport and initial state +// +//----------------------------------------------------------------------------- + +void FGLRenderer::SetViewport(GL_IRECT *bounds) +{ + if (!bounds) + { + int height, width; + + // Special handling so the view with a visible status bar displays properly + + if (screenblocks >= 10) + { + height = SCREENHEIGHT; + width = SCREENWIDTH; + } + else + { + height = (screenblocks*SCREENHEIGHT/10) & ~7; + width = (screenblocks*SCREENWIDTH/10); + } + + int trueheight = static_cast(screen)->GetTrueHeight(); // ugh... + int bars = (trueheight-screen->GetHeight())/2; + + int vw = viewwidth; + int vh = viewheight; + glViewport(viewwindowx, trueheight-bars-(height+viewwindowy-((height-vh)/2)), vw, height); + glScissor(viewwindowx, trueheight-bars-(vh+viewwindowy), vw, vh); + } + else + { + glViewport(bounds->left, bounds->top, bounds->width, bounds->height); + glScissor(bounds->left, bounds->top, bounds->width, bounds->height); + } + glEnable(GL_SCISSOR_TEST); + + #ifdef _DEBUG + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + #else + glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + #endif + + glEnable(GL_MULTISAMPLE); + glEnable(GL_DEPTH_TEST); + glEnable(GL_STENCIL_TEST); + glStencilFunc(GL_ALWAYS,0,~0); // default stencil + glStencilOp(GL_KEEP,GL_KEEP,GL_REPLACE); +} + +//----------------------------------------------------------------------------- +// +// Setup the camera position +// +//----------------------------------------------------------------------------- + +void FGLRenderer::SetViewAngle(angle_t viewangle) +{ + float fviewangle=(float)(viewangle>>ANGLETOFINESHIFT)*360.0f/FINEANGLES; + + mAngles.Yaw = 270.0f-fviewangle; + mViewVector = FVector2(cos(DEG2RAD(fviewangle)), sin(DEG2RAD(fviewangle))); + + R_SetViewAngle(); +} + + +//----------------------------------------------------------------------------- +// +// SetProjection +// sets projection matrix +// +//----------------------------------------------------------------------------- + +void FGLRenderer::SetProjection(float fov, float ratio, float fovratio) +{ + + float fovy = 2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovratio)); + gl_RenderState.mProjectionMatrix.perspective(fovy, ratio, 5.f, 65536.f); + gl_RenderState.Set2DMode(false); +} + +// raw matrix input from stereo 3d modes +void FGLRenderer::SetProjection(VSMatrix matrix) +{ + gl_RenderState.mProjectionMatrix.loadIdentity(); + gl_RenderState.mProjectionMatrix.multMatrix(matrix); + gl_RenderState.Set2DMode(false); +} + +//----------------------------------------------------------------------------- +// +// Setup the modelview matrix +// +//----------------------------------------------------------------------------- + +void FGLRenderer::SetViewMatrix(fixed_t viewx, fixed_t viewy, fixed_t viewz, bool mirror, bool planemirror) +{ + float mult = mirror? -1:1; + float planemult = planemirror? -glset.pixelstretch : glset.pixelstretch; + + gl_RenderState.mViewMatrix.loadIdentity(); + gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Roll, 0.0f, 0.0f, 1.0f); + gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch, 1.0f, 0.0f, 0.0f); + gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw, 0.0f, mult, 0.0f); + gl_RenderState.mViewMatrix.translate(FIXED2FLOAT(viewx) * mult, -FIXED2FLOAT(viewz) * planemult , -FIXED2FLOAT(viewy)); + gl_RenderState.mViewMatrix.scale(-mult, planemult, 1); +} + + +//----------------------------------------------------------------------------- +// +// SetupView +// Setup the view rotation matrix for the given viewpoint +// +//----------------------------------------------------------------------------- +void FGLRenderer::SetupView(fixed_t viewx, fixed_t viewy, fixed_t viewz, angle_t viewangle, bool mirror, bool planemirror) +{ + SetViewAngle(viewangle); + SetViewMatrix(viewx, viewy, viewz, mirror, planemirror); + gl_RenderState.ApplyMatrices(); +} + +//----------------------------------------------------------------------------- +// +// CreateScene +// +// creates the draw lists for the current scene +// +//----------------------------------------------------------------------------- + +void FGLRenderer::CreateScene() +{ + // reset the portal manager + GLPortal::StartFrame(); + PO_LinkToSubsectors(); + + ProcessAll.Clock(); + + // clip the scene and fill the drawlists + for(unsigned i=0;iglportal = NULL; + gl_spriteindex=0; + Bsp.Clock(); + gl_RenderBSPNode (nodes + numnodes - 1); + Bsp.Unclock(); + + // And now the crappy hacks that have to be done to avoid rendering anomalies: + + gl_drawinfo->HandleMissingTextures(); // Missing upper/lower textures + gl_drawinfo->HandleHackedSubsectors(); // open sector hacks for deep water + gl_drawinfo->ProcessSectorStacks(); // merge visplanes of sector stacks + + ProcessAll.Unclock(); + +} + +//----------------------------------------------------------------------------- +// +// RenderScene +// +// Draws the current draw lists for the non GLSL renderer +// +//----------------------------------------------------------------------------- + +void FGLRenderer::RenderScene(int recursion) +{ + RenderAll.Clock(); + + glDepthMask(true); + if (!gl_no_skyclear) GLPortal::RenderFirstSkyPortal(recursion); + + gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); + + gl_RenderState.EnableFog(true); + gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); + + if (gl_sort_textures) + { + gl_drawinfo->drawlists[GLDL_PLAINWALLS].SortWalls(); + gl_drawinfo->drawlists[GLDL_PLAINFLATS].SortFlats(); + gl_drawinfo->drawlists[GLDL_MASKEDWALLS].SortWalls(); + gl_drawinfo->drawlists[GLDL_MASKEDFLATS].SortFlats(); + gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].SortWalls(); + } + + // if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front, + // so that we don't have to do repeated map/unmap calls on the buffer. + if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && !(gl.flags & RFL_BUFFER_STORAGE)) + { + GLRenderer->mLights->Begin(); + gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_LIGHTSONLY); + gl_drawinfo->drawlists[GLDL_TRANSLUCENT].Draw(GLPASS_LIGHTSONLY, true); + GLRenderer->mLights->Finish(); + } + + // Part 1: solid geometry. This is set up so that there are no transparent parts + glDepthFunc(GL_LESS); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + glDisable(GL_POLYGON_OFFSET_FILL); + + int pass; + + if (mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_BUFFER_STORAGE)) + { + pass = GLPASS_ALL; + } + else + { + pass = GLPASS_PLAIN; + } + + gl_RenderState.EnableTexture(gl_texture); + gl_RenderState.EnableBrightmap(true); + gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawWalls(pass); + gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(pass); + + + // Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show + if (!gl_texture) + { + gl_RenderState.EnableTexture(true); + gl_RenderState.SetTextureMode(TM_MASK); + } + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + gl_drawinfo->drawlists[GLDL_MASKEDWALLS].DrawWalls(pass); + gl_drawinfo->drawlists[GLDL_MASKEDFLATS].DrawFlats(pass); + + // Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use. + if (gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].Size() > 0) + { + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + gl_drawinfo->drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(pass); + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); + } + + gl_drawinfo->drawlists[GLDL_MODELS].Draw(pass); + + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + // Part 4: Draw decals (not a real pass) + glDepthFunc(GL_LEQUAL); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + glDepthMask(false); + + // this is the only geometry type on which decals can possibly appear + gl_drawinfo->drawlists[GLDL_PLAINWALLS].DrawDecals(); + + gl_RenderState.SetTextureMode(TM_MODULATE); + + glDepthMask(true); + + + // Push bleeding floor/ceiling textures back a little in the z-buffer + // so they don't interfere with overlapping mid textures. + glPolygonOffset(1.0f, 128.0f); + + // Part 5: flood all the gaps with the back sector's flat texture + // This will always be drawn like GLDL_PLAIN, depending on the fog settings + + glDepthMask(false); // don't write to Z-buffer! + gl_RenderState.EnableFog(true); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); + gl_drawinfo->DrawUnhandledMissingTextures(); + glDepthMask(true); + + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); + RenderAll.Unclock(); + +} + +//----------------------------------------------------------------------------- +// +// RenderTranslucent +// +// Draws the current draw lists for the non GLSL renderer +// +//----------------------------------------------------------------------------- + +void FGLRenderer::RenderTranslucent() +{ + RenderAll.Clock(); + + glDepthMask(false); + gl_RenderState.SetCameraPos(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz)); + + // final pass: translucent stuff + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + gl_RenderState.EnableBrightmap(true); + gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].Draw(GLPASS_TRANSLUCENT); + gl_drawinfo->drawlists[GLDL_TRANSLUCENT].DrawSorted(); + gl_RenderState.EnableBrightmap(false); + + glDepthMask(true); + + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); + RenderAll.Unclock(); +} + + +//----------------------------------------------------------------------------- +// +// gl_drawscene - this function renders the scene from the current +// viewpoint, including mirrors and skyboxes and other portals +// It is assumed that the GLPortal::EndFrame returns with the +// stencil, z-buffer and the projection matrix intact! +// +//----------------------------------------------------------------------------- +EXTERN_CVAR(Bool, gl_draw_sync) + +void FGLRenderer::DrawScene(bool toscreen) +{ + static int recursion=0; + + CreateScene(); + GLRenderer->mCurrentPortal = NULL; // this must be reset before any portal recursion takes place. + + // Up to this point in the main draw call no rendering is performed so we can wait + // with swapping the render buffer until now. + if (!gl_draw_sync && toscreen) + { + All.Unclock(); + static_cast(screen)->Swap(); + All.Clock(); + } + RenderScene(recursion); + + // Handle all portals after rendering the opaque objects but before + // doing all translucent stuff + recursion++; + GLPortal::EndFrame(); + recursion--; + RenderTranslucent(); +} + + +static void FillScreen() +{ + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, 0, 0, 0, 0); + ptr++; + ptr->Set(0, (float)SCREENHEIGHT, 0, 0, 0); + ptr++; + ptr->Set((float)SCREENWIDTH, 0, 0, 0, 0); + ptr++; + ptr->Set((float)SCREENWIDTH, (float)SCREENHEIGHT, 0, 0, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); +} + +//========================================================================== +// +// Draws a blend over the entire view +// +//========================================================================== +void FGLRenderer::DrawBlend(sector_t * viewsector) +{ + float blend[4]={0,0,0,0}; + PalEntry blendv=0; + float extra_red; + float extra_green; + float extra_blue; + player_t *player = NULL; + + if (players[consoleplayer].camera != NULL) + { + player=players[consoleplayer].camera->player; + } + + // don't draw sector based blends when an invulnerability colormap is active + if (!gl_fixedcolormap) + { + if (!viewsector->e->XFloor.ffloors.Size()) + { + if (viewsector->heightsec && !(viewsector->MoreFlags&SECF_IGNOREHEIGHTSEC)) + { + switch (in_area) + { + default: + case area_normal: blendv = viewsector->heightsec->midmap; break; + case area_above: blendv = viewsector->heightsec->topmap; break; + case area_below: blendv = viewsector->heightsec->bottommap; break; + } + } + } + else + { + TArray & lightlist = viewsector->e->XFloor.lightlist; + + for (unsigned int i = 0; i < lightlist.Size(); i++) + { + fixed_t lightbottom; + if (i < lightlist.Size() - 1) + lightbottom = lightlist[i + 1].plane.ZatPoint(viewx, viewy); + else + lightbottom = viewsector->floorplane.ZatPoint(viewx, viewy); + + if (lightbottom < viewz && (!lightlist[i].caster || !(lightlist[i].caster->flags&FF_FADEWALLS))) + { + // 3d floor 'fog' is rendered as a blending value + blendv = lightlist[i].blend; + // If this is the same as the sector's it doesn't apply! + if (blendv == viewsector->ColorMap->Fade) blendv = 0; + // a little hack to make this work for Legacy maps. + if (blendv.a == 0 && blendv != 0) blendv.a = 128; + break; + } + } + } + + if (blendv.a == 0) + { + blendv = R_BlendForColormap(blendv); + if (blendv.a == 255) + { + // The calculated average is too dark so brighten it according to the palettes's overall brightness + int maxcol = MAX(MAX(framebuffer->palette_brightness, blendv.r), MAX(blendv.g, blendv.b)); + blendv.r = blendv.r * 255 / maxcol; + blendv.g = blendv.g * 255 / maxcol; + blendv.b = blendv.b * 255 / maxcol; + } + } + + if (blendv.a == 255) + { + + extra_red = blendv.r / 255.0f; + extra_green = blendv.g / 255.0f; + extra_blue = blendv.b / 255.0f; + + // If this is a multiplicative blend do it separately and add the additive ones on top of it. + blendv = 0; + + // black multiplicative blends are ignored + if (extra_red || extra_green || extra_blue) + { + gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); + gl_RenderState.SetColor(extra_red, extra_green, extra_blue, 1.0f); + FillScreen(); + } + } + else if (blendv.a) + { + V_AddBlend(blendv.r / 255.f, blendv.g / 255.f, blendv.b / 255.f, blendv.a / 255.0f, blend); + } + } + + // This mostly duplicates the code in shared_sbar.cpp + // When I was writing this the original was called too late so that I + // couldn't get the blend in time. However, since then I made some changes + // here that would get lost if I switched back so I won't do it. + + if (player) + { + V_AddPlayerBlend(player, blend, 0.5, 175); + } + + if (players[consoleplayer].camera != NULL) + { + // except for fadeto effects + player_t *player = (players[consoleplayer].camera->player != NULL) ? players[consoleplayer].camera->player : &players[consoleplayer]; + V_AddBlend (player->BlendR, player->BlendG, player->BlendB, player->BlendA, blend); + } + + if (blend[3]>0.0f) + { + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.SetColor(blend[0], blend[1], blend[2], blend[3]); + FillScreen(); + } +} + + +//----------------------------------------------------------------------------- +// +// Draws player sprites and color blend +// +//----------------------------------------------------------------------------- + + +void FGLRenderer::EndDrawScene(sector_t * viewsector) +{ + gl_RenderState.EnableFog(false); + + // [BB] HUD models need to be rendered here. Make sure that + // DrawPlayerSprites is only called once. Either to draw + // HUD models or to draw the weapon sprites. + const bool renderHUDModel = gl_IsHUDModelForPlayerAvailable( players[consoleplayer].camera->player ); + if ( renderHUDModel ) + { + // [BB] The HUD model should be drawn over everything else already drawn. + glClear(GL_DEPTH_BUFFER_BIT); + DrawPlayerSprites (viewsector, true); + } + + glDisable(GL_STENCIL_TEST); + + framebuffer->Begin2D(false); + + ResetViewport(); + // [BB] Only draw the sprites if we didn't render a HUD model before. + if ( renderHUDModel == false ) + { + DrawPlayerSprites (viewsector, false); + } + gl_RenderState.SetFixedColormap(CM_DEFAULT); + gl_RenderState.SetSoftLightLevel(-1); + DrawTargeterSprites(); + DrawBlend(viewsector); + + // Restore standard rendering state + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.ResetColor(); + gl_RenderState.EnableTexture(true); + glDisable(GL_SCISSOR_TEST); +} + + +//----------------------------------------------------------------------------- +// +// R_RenderView - renders one view - either the screen or a camera texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::ProcessScene(bool toscreen) +{ + FDrawInfo::StartDrawInfo(); + iter_dlightf = iter_dlight = draw_dlight = draw_dlightf = 0; + GLPortal::BeginScene(); + + int mapsection = R_PointInSubsector(viewx, viewy)->mapsection; + memset(¤tmapsection[0], 0, currentmapsection.Size()); + currentmapsection[mapsection>>3] |= 1 << (mapsection & 7); + DrawScene(toscreen); + FDrawInfo::EndDrawInfo(); + +} + +//----------------------------------------------------------------------------- +// +// gl_SetFixedColormap +// +//----------------------------------------------------------------------------- + +void FGLRenderer::SetFixedColormap (player_t *player) +{ + gl_fixedcolormap=CM_DEFAULT; + + // check for special colormaps + player_t * cplayer = player->camera->player; + if (cplayer) + { + if (cplayer->extralight == INT_MIN) + { + gl_fixedcolormap=CM_FIRSTSPECIALCOLORMAP + INVERSECOLORMAP; + extralight=0; + } + else if (cplayer->fixedcolormap != NOFIXEDCOLORMAP) + { + gl_fixedcolormap = CM_FIRSTSPECIALCOLORMAP + cplayer->fixedcolormap; + } + else if (cplayer->fixedlightlevel != -1) + { + for(AInventory * in = cplayer->mo->Inventory; in; in = in->Inventory) + { + PalEntry color = in->GetBlend (); + + // Need special handling for light amplifiers + if (in->IsKindOf(RUNTIME_CLASS(APowerTorch))) + { + gl_fixedcolormap = cplayer->fixedlightlevel + CM_TORCH; + } + else if (in->IsKindOf(RUNTIME_CLASS(APowerLightAmp))) + { + gl_fixedcolormap = CM_LITE; + } + } + } + } + gl_RenderState.SetFixedColormap(gl_fixedcolormap); +} + +//----------------------------------------------------------------------------- +// +// Renders one viewpoint in a scene +// +//----------------------------------------------------------------------------- + +sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, float fov, float ratio, float fovratio, bool mainview, bool toscreen) +{ + sector_t * retval; + R_SetupFrame (camera); + SetViewArea(); + + // We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1. + double radPitch = bam2rad(viewpitch); + if (radPitch > PI) radPitch -= 2 * PI; + radPitch = clamp(radPitch, -PI / 2, PI / 2); + + double angx = cos(radPitch); + double angy = sin(radPitch) * glset.pixelstretch; + double alen = sqrt(angx*angx + angy*angy); + + mAngles.Pitch = (float)RAD2DEG(asin(angy / alen)); + mAngles.Roll = (float)(camera->roll>>ANGLETOFINESHIFT)*360.0f/FINEANGLES; + + // Scroll the sky + mSky1Pos = (float)fmod(gl_frameMS * level.skyspeed1, 1024.f) * 90.f/256.f; + mSky2Pos = (float)fmod(gl_frameMS * level.skyspeed2, 1024.f) * 90.f/256.f; + + + + if (camera->player && camera->player-players==consoleplayer && + ((camera->player->cheats & CF_CHASECAM) || (r_deathcamera && camera->health <= 0)) && camera==camera->player->mo) + { + mViewActor=NULL; + } + else + { + mViewActor=camera; + } + + // 'viewsector' will not survive the rendering so it cannot be used anymore below. + retval = viewsector; + + // Render (potentially) multiple views for stereo 3d + float viewShift[3]; + const s3d::Stereo3DMode& stereo3dMode = s3d::Stereo3DMode::getCurrentMode(); + stereo3dMode.SetUp(); + for (int eye_ix = 0; eye_ix < stereo3dMode.eye_count(); ++eye_ix) + { + const s3d::EyePose * eye = stereo3dMode.getEyePose(eye_ix); + eye->SetUp(); + // TODO: stereo specific viewport - needed when implementing side-by-side modes etc. + SetViewport(bounds); + mCurrentFoV = fov; + // Stereo mode specific perspective projection + SetProjection( eye->GetProjection(fov, ratio, fovratio) ); + // SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper + SetViewAngle(viewangle); + // Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz + eye->GetViewShift(GLRenderer->mAngles.Yaw, viewShift); + s3d::ScopedViewShifter viewShifter(viewShift); + SetViewMatrix(viewx, viewy, viewz, false, false); + gl_RenderState.ApplyMatrices(); + + clipper.Clear(); + angle_t a1 = FrustumAngle(); + clipper.SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1); + + ProcessScene(toscreen); + if (mainview) EndDrawScene(retval); // do not call this for camera textures. + eye->TearDown(); + } + stereo3dMode.TearDown(); + + gl_frameCount++; // This counter must be increased right before the interpolations are restored. + interpolator.RestoreInterpolations (); + return retval; +} + + +//----------------------------------------------------------------------------- +// +// renders the view +// +//----------------------------------------------------------------------------- + +void FGLRenderer::RenderView (player_t* player) +{ + OpenGLFrameBuffer* GLTarget = static_cast(screen); + AActor *&LastCamera = GLTarget->LastCamera; + + checkBenchActive(); + if (player->camera != LastCamera) + { + // If the camera changed don't interpolate + // Otherwise there will be some not so nice effects. + R_ResetViewInterpolation(); + LastCamera=player->camera; + } + + gl_RenderState.SetVertexBuffer(mVBO); + GLRenderer->mVBO->Reset(); + + // reset statistics counters + ResetProfilingData(); + + // Get this before everything else + if (cl_capfps || r_NoInterpolate) r_TicFrac = FRACUNIT; + else r_TicFrac = I_GetTimeFrac (&r_FrameTime); + gl_frameMS = I_MSTime(); + + P_FindParticleSubsectors (); + + GLRenderer->mLights->Clear(); + + // prepare all camera textures that have been used in the last frame + FCanvasTextureInfo::UpdateAll(); + + + // I stopped using BaseRatioSizes here because the information there wasn't well presented. + // 4:3 16:9 16:10 17:10 5:4 + static float ratios[]={1.333333f, 1.777777f, 1.6f, 1.7f, 1.25f}; + + // now render the main view + float fovratio; + float ratio = ratios[WidescreenRatio]; + if (!(WidescreenRatio&4)) + { + fovratio = 1.333333f; + } + else + { + fovratio = ratio; + } + + SetFixedColormap (player); + + // Check if there's some lights. If not some code can be skipped. + TThinkerIterator it(STAT_DLIGHT); + GLRenderer->mLightCount = ((it.Next()) != NULL); + + sector_t * viewsector = RenderViewpoint(player->camera, NULL, FieldOfView * 360.0f / FINEANGLES, ratio, fovratio, true, true); + + All.Unclock(); +} + +//=========================================================================== +// +// Render the view to a savegame picture +// +//=========================================================================== + +void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int height) +{ + GL_IRECT bounds; + + bounds.left=0; + bounds.top=0; + bounds.width=width; + bounds.height=height; + glFlush(); + SetFixedColormap(player); + gl_RenderState.SetVertexBuffer(mVBO); + GLRenderer->mVBO->Reset(); + GLRenderer->mLights->Clear(); + + // Check if there's some lights. If not some code can be skipped. + TThinkerIterator it(STAT_DLIGHT); + GLRenderer->mLightCount = ((it.Next()) != NULL); + + sector_t *viewsector = RenderViewpoint(players[consoleplayer].camera, &bounds, + FieldOfView * 360.0f / FINEANGLES, 1.6f, 1.6f, true, false); + glDisable(GL_STENCIL_TEST); + gl_RenderState.SetFixedColormap(CM_DEFAULT); + gl_RenderState.SetSoftLightLevel(-1); + screen->Begin2D(false); + DrawBlend(viewsector); + glFlush(); + + byte * scr = (byte *)M_Malloc(width * height * 3); + glReadPixels(0,0,width, height,GL_RGB,GL_UNSIGNED_BYTE,scr); + M_CreatePNG (file, scr + ((height-1) * width * 3), NULL, SS_RGB, width, height, -width*3); + M_Free(scr); +} + + +//=========================================================================== +// +// +// +//=========================================================================== + +struct FGLInterface : public FRenderer +{ + bool UsesColormap() const; + void PrecacheTexture(FTexture *tex, int cache); + void RenderView(player_t *player); + void WriteSavePic (player_t *player, FILE *file, int width, int height); + void StateChanged(AActor *actor); + void StartSerialize(FArchive &arc); + void EndSerialize(FArchive &arc); + void RenderTextureView (FCanvasTexture *self, AActor *viewpoint, int fov); + sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, bool back); + void SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog); + void PreprocessLevel(); + void CleanLevelData(); + bool RequireGLNodes(); + + int GetMaxViewPitch(bool down); + void ClearBuffer(int color); + void Init(); +}; + +//=========================================================================== +// +// The GL renderer has no use for colormaps so let's +// not create them and save us some time. +// +//=========================================================================== + +bool FGLInterface::UsesColormap() const +{ + return false; +} + +//========================================================================== +// +// DFrameBuffer :: PrecacheTexture +// +//========================================================================== + +void FGLInterface::PrecacheTexture(FTexture *tex, int cache) +{ + if (tex != NULL) + { + if (cache) + { + tex->PrecacheGL(cache); + } + else + { + tex->UncacheGL(); + } + } +} + +//========================================================================== +// +// DFrameBuffer :: StateChanged +// +//========================================================================== + +void FGLInterface::StateChanged(AActor *actor) +{ + gl_SetActorLights(actor); +} + +//=========================================================================== +// +// notify the renderer that serialization of the curent level is about to start/end +// +//=========================================================================== + +void FGLInterface::StartSerialize(FArchive &arc) +{ + gl_DeleteAllAttachedLights(); +} + +void gl_SerializeGlobals(FArchive &arc) +{ + arc << fogdensity << outsidefogdensity << skyfog; +} + +void FGLInterface::EndSerialize(FArchive &arc) +{ + gl_RecreateAllAttachedLights(); + if (arc.IsLoading()) gl_InitPortals(); +} + +//=========================================================================== +// +// Get max. view angle (renderer specific information so it goes here now) +// +//=========================================================================== + +EXTERN_CVAR(Float, maxviewpitch) + +int FGLInterface::GetMaxViewPitch(bool down) +{ + return int(maxviewpitch); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLInterface::ClearBuffer(int color) +{ + PalEntry pe = GPalette.BaseColors[color]; + glClearColor(pe.r/255.f, pe.g/255.f, pe.b/255.f, 1.f); + glClear(GL_COLOR_BUFFER_BIT); +} + +//=========================================================================== +// +// Render the view to a savegame picture +// +//=========================================================================== + +void FGLInterface::WriteSavePic (player_t *player, FILE *file, int width, int height) +{ + GLRenderer->WriteSavePic(player, file, width, height); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLInterface::RenderView(player_t *player) +{ + GLRenderer->RenderView(player); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLInterface::Init() +{ + gl_ParseDefs(); + gl_InitData(); +} + +//=========================================================================== +// +// Camera texture rendering +// +//=========================================================================== +CVAR(Bool, gl_usefb, false , CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +extern TexFilter_s TexFilter[]; + +void FGLInterface::RenderTextureView (FCanvasTexture *tex, AActor *Viewpoint, int FOV) +{ + FMaterial * gltex = FMaterial::ValidateTexture(tex, false); + + int width = gltex->TextureWidth(); + int height = gltex->TextureHeight(); + + gl_fixedcolormap=CM_DEFAULT; + gl_RenderState.SetFixedColormap(CM_DEFAULT); + + bool usefb = gl_usefb || width > screen->GetWidth() || height > screen->GetHeight(); + if (!usefb) + { + glFlush(); + } + else + { +#if defined(_WIN32) && (defined(_MSC_VER) || defined(__INTEL_COMPILER)) + __try +#endif + { + GLRenderer->StartOffscreen(); + gltex->BindToFrameBuffer(); + } +#if defined(_WIN32) && (defined(_MSC_VER) || defined(__INTEL_COMPILER)) + __except(1) + { + usefb = false; + gl_usefb = false; + GLRenderer->EndOffscreen(); + glFlush(); + } +#endif + } + + GL_IRECT bounds; + bounds.left=bounds.top=0; + bounds.width=FHardwareTexture::GetTexDimension(gltex->GetWidth()); + bounds.height=FHardwareTexture::GetTexDimension(gltex->GetHeight()); + + GLRenderer->RenderViewpoint(Viewpoint, &bounds, FOV, (float)width/height, (float)width/height, false, false); + + if (!usefb) + { + glFlush(); + gl_RenderState.SetMaterial(gltex, 0, 0, -1, false); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bounds.width, bounds.height); + } + else + { + GLRenderer->EndOffscreen(); + } + + tex->SetUpdated(); +} + +//========================================================================== +// +// +// +//========================================================================== + +sector_t *FGLInterface::FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, bool back) +{ + if (floorlightlevel != NULL) + { + *floorlightlevel = sec->GetFloorLight (); + } + if (ceilinglightlevel != NULL) + { + *ceilinglightlevel = sec->GetCeilingLight (); + } + return gl_FakeFlat(sec, tempsec, back); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLInterface::SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog) +{ + gl_SetFogParams(_fogdensity, _outsidefogcolor, _outsidefogdensity, _skyfog); +} + +void FGLInterface::PreprocessLevel() +{ + gl_PreprocessLevel(); +} + +void FGLInterface::CleanLevelData() +{ + gl_CleanLevelData(); +} + +bool FGLInterface::RequireGLNodes() +{ + return true; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FRenderer *gl_CreateInterface() +{ + return new FGLInterface; +} + + diff --git a/src/gl/scene/gl_sky.cpp b/src/gl/scene/gl_sky.cpp new file mode 100644 index 000000000..38dbfca49 --- /dev/null +++ b/src/gl/scene/gl_sky.cpp @@ -0,0 +1,352 @@ +/* +** gl_sky.cpp +** Sky preparation code. +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "a_sharedglobal.h" +#include "g_level.h" +#include "r_sky.h" +#include "r_state.h" +#include "r_utility.h" +#include "doomdata.h" +#include "gl/gl_functions.h" + +#include "gl/data/gl_data.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_convert.h" + +CVAR(Bool,gl_noskyboxes, false, 0) +extern int skyfog; + +enum +{ + NoSkyDraw = 89 +}; + + +//========================================================================== +// +// Calculate sky texture +// +//========================================================================== +void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) +{ + FPortal *portal = sector->portals[plane]; + if (portal != NULL) + { + if (GLPortal::instack[1-plane]) return; + type=RENDERWALL_SECTORSTACK; + this->portal = portal; + } + else if (sector->GetTexture(plane)==skyflatnum) + { + GLSkyInfo skyinfo; + ASkyViewpoint * skyboxx = sector->GetSkyBox(plane); + + // JUSTHIT is used as an indicator that a skybox is in use. + // This is to avoid recursion + + if (!gl_noskyboxes && skyboxx && GLRenderer->mViewActor!=skyboxx && !(skyboxx->flags&MF_JUSTHIT)) + { + type=RENDERWALL_SKYBOX; + skybox=skyboxx; + } + else + { + int sky1 = sector->sky; + memset(&skyinfo, 0, sizeof(skyinfo)); + if ((sky1 & PL_SKYFLAT) && (sky1 & (PL_SKYFLAT-1))) + { + const line_t *l = &lines[(sky1&(PL_SKYFLAT-1))-1]; + const side_t *s = l->sidedef[0]; + int pos; + + if (level.flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid()) + { + pos = side_t::bottom; + } + else + { + pos = side_t::top; + } + + FTextureID texno = s->GetTexture(pos); + skyinfo.texture[0] = FMaterial::ValidateTexture(texno, false, true); + if (!skyinfo.texture[0] || skyinfo.texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; + skyinfo.skytexno1 = texno; + skyinfo.x_offset[0] = ANGLE_TO_FLOAT(s->GetTextureXOffset(pos)); + skyinfo.y_offset = FIXED2FLOAT(s->GetTextureYOffset(pos)); + skyinfo.mirrored = !l->args[2]; + } + else + { + normalsky: + if (level.flags&LEVEL_DOUBLESKY) + { + skyinfo.texture[1]=FMaterial::ValidateTexture(sky1texture, false, true); + skyinfo.x_offset[1] = GLRenderer->mSky1Pos; + skyinfo.doublesky = true; + } + + if ((level.flags&LEVEL_SWAPSKIES || (sky1==PL_SKYFLAT) || (level.flags&LEVEL_DOUBLESKY)) && + sky2texture!=sky1texture) // If both skies are equal use the scroll offset of the first! + { + skyinfo.texture[0]=FMaterial::ValidateTexture(sky2texture, false, true); + skyinfo.skytexno1=sky2texture; + skyinfo.sky2 = true; + skyinfo.x_offset[0] = GLRenderer->mSky2Pos; + } + else + { + skyinfo.texture[0]=FMaterial::ValidateTexture(sky1texture, false, true); + skyinfo.skytexno1=sky1texture; + skyinfo.x_offset[0] = GLRenderer->mSky1Pos; + } + } + if (skyfog>0) + { + skyinfo.fadecolor=Colormap.FadeColor; + skyinfo.fadecolor.a=0; + } + else skyinfo.fadecolor=0; + + type=RENDERWALL_SKY; + sky=UniqueSkies.Get(&skyinfo); + } + } + else if (allowreflect && sector->GetReflect(plane) > 0) + { + if ((plane == sector_t::ceiling && viewz > sector->ceilingplane.d) || + (plane == sector_t::floor && viewz < -sector->floorplane.d)) return; + type=RENDERWALL_PLANEMIRROR; + planemirror = plane == sector_t::ceiling? §or->ceilingplane : §or->floorplane; + } + else return; + PutWall(0); +} + + +//========================================================================== +// +// Skies on one sided walls +// +//========================================================================== + +void GLWall::SkyNormal(sector_t * fs,vertex_t * v1,vertex_t * v2) +{ + ztop[0]=ztop[1]=32768.0f; + zbottom[0]=zceil[0]; + zbottom[1]=zceil[1]; + SkyPlane(fs, sector_t::ceiling, true); + + ztop[0]=zfloor[0]; + ztop[1]=zfloor[1]; + zbottom[0]=zbottom[1]=-32768.0f; + SkyPlane(fs, sector_t::floor, true); +} + +//========================================================================== +// +// Upper Skies on two sided walls +// +//========================================================================== + +void GLWall::SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2) +{ + if (fs->GetTexture(sector_t::ceiling)==skyflatnum) + { + if ((bs->special&0xff) == NoSkyDraw) return; + if (bs->GetTexture(sector_t::ceiling)==skyflatnum) + { + // if the back sector is closed the sky must be drawn! + if (bs->ceilingplane.ZatPoint(v1) > bs->floorplane.ZatPoint(v1) || + bs->ceilingplane.ZatPoint(v2) > bs->floorplane.ZatPoint(v2) || bs->transdoor) + return; + + // one more check for some ugly transparent door hacks + if (bs->floorplane.a==0 && bs->floorplane.b==0 && fs->floorplane.a==0 && fs->floorplane.b==0) + { + if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+FRACUNIT) + { + FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom)); + if (!tex || tex->UseType==FTexture::TEX_Null) return; + + // very, very, very ugly special case (See Icarus MAP14) + // It is VERY important that this is only done for a floor height difference of 1 + // or it will cause glitches elsewhere. + tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); + if (tex != NULL && !(seg->linedef->flags & ML_DONTPEGTOP) && + seg->sidedef->GetTextureYOffset(side_t::mid) > 0) + { + ztop[0]=ztop[1]=32768.0f; + zbottom[0]=zbottom[1]= + FIXED2FLOAT(bs->ceilingplane.ZatPoint(v2) + seg->sidedef->GetTextureYOffset(side_t::mid)); + SkyPlane(fs, sector_t::ceiling, false); + return; + } + } + } + } + + ztop[0]=ztop[1]=32768.0f; + + FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::top)); + if (bs->GetTexture(sector_t::ceiling) != skyflatnum) + + { + zbottom[0]=zceil[0]; + zbottom[1]=zceil[1]; + } + else + { + zbottom[0]=FIXED2FLOAT(bs->ceilingplane.ZatPoint(v1)); + zbottom[1]=FIXED2FLOAT(bs->ceilingplane.ZatPoint(v2)); + flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment! + } + } + else + { + FPortal *pfront = fs->portals[sector_t::ceiling]; + FPortal *pback = bs->portals[sector_t::ceiling]; + float frontreflect = fs->GetReflect(sector_t::ceiling); + if (frontreflect > 0) + { + float backreflect = bs->GetReflect(sector_t::ceiling); + if (backreflect > 0 && bs->ceilingplane.d == fs->ceilingplane.d) + { + // Don't add intra-portal line to the portal. + return; + } + } + else if (pfront == NULL || pfront == pback) + { + return; + } + + // stacked sectors + fixed_t fsc1=fs->ceilingplane.ZatPoint(v1); + fixed_t fsc2=fs->ceilingplane.ZatPoint(v2); + + ztop[0]=ztop[1]=32768.0f; + zbottom[0]=FIXED2FLOAT(fsc1); + zbottom[1]=FIXED2FLOAT(fsc2); + } + + SkyPlane(fs, sector_t::ceiling, true); +} + + +//========================================================================== +// +// Lower Skies on two sided walls +// +//========================================================================== + +void GLWall::SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2) +{ + if (fs->GetTexture(sector_t::floor)==skyflatnum) + { + if ((bs->special&0xff) == NoSkyDraw) return; + FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom)); + + // For lower skies the normal logic only applies to walls with no lower texture! + if (tex->UseType==FTexture::TEX_Null) + { + if (bs->GetTexture(sector_t::floor)==skyflatnum) + { + // if the back sector is closed the sky must be drawn! + if (bs->ceilingplane.ZatPoint(v1) > bs->floorplane.ZatPoint(v1) || + bs->ceilingplane.ZatPoint(v2) > bs->floorplane.ZatPoint(v2)) + return; + + } + else + { + // Special hack for Vrack2b + if (bs->floorplane.ZatPoint(FIXED2FLOAT(viewx), FIXED2FLOAT(viewy)) > FIXED2FLOAT(viewz)) return; + } + } + zbottom[0]=zbottom[1]=-32768.0f; + + if ((tex && tex->UseType!=FTexture::TEX_Null) || bs->GetTexture(sector_t::floor)!=skyflatnum) + { + ztop[0]=zfloor[0]; + ztop[1]=zfloor[1]; + } + else + { + ztop[0]=FIXED2FLOAT(bs->floorplane.ZatPoint(v1)); + ztop[1]=FIXED2FLOAT(bs->floorplane.ZatPoint(v2)); + flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment! + } + } + else + { + FPortal *pfront = fs->portals[sector_t::floor]; + FPortal *pback = bs->portals[sector_t::floor]; + float frontreflect = fs->GetReflect(sector_t::floor); + if (frontreflect > 0) + { + float backreflect = bs->GetReflect(sector_t::floor); + if (backreflect > 0 && bs->floorplane.d == fs->floorplane.d) + { + // Don't add intra-portal line to the portal. + return; + } + } + else if (pfront == NULL || pfront == pback) + { + return; + } + + // stacked sectors + fixed_t fsc1=fs->floorplane.ZatPoint(v1); + fixed_t fsc2=fs->floorplane.ZatPoint(v2); + + zbottom[0]=zbottom[1]=-32768.0f; + ztop[0]=FIXED2FLOAT(fsc1); + ztop[1]=FIXED2FLOAT(fsc2); + } + + SkyPlane(fs, sector_t::floor, true); +} + diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp new file mode 100644 index 000000000..59b0f634d --- /dev/null +++ b/src/gl/scene/gl_skydome.cpp @@ -0,0 +1,539 @@ +/* +** gl_sky.cpp +** +** Draws the sky. Loosely based on the JDoom sky and the ZDoomGL 0.66.2 sky. +** +**--------------------------------------------------------------------------- +** Copyright 2003 Tim Stump +** Copyright 2005 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. +** 4. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "doomtype.h" +#include "g_level.h" +#include "sc_man.h" +#include "w_wad.h" +#include "r_state.h" +//#include "gl/gl_intern.h" + +#include "gl/system/gl_interface.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_bitmap.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_skyboxtexture.h" +#include "gl/textures/gl_material.h" + + +//----------------------------------------------------------------------------- +// +// Shamelessly lifted from Doomsday (written by Jaakko Keränen) +// also shamelessly lifted from ZDoomGL! ;) +// +//----------------------------------------------------------------------------- + +CVAR(Float, skyoffset, 0, 0) // for testing + +extern int skyfog; + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +FSkyVertexBuffer::FSkyVertexBuffer() +{ + CreateDome(); + + glBindVertexArray(vao_id); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSkyVertex), &VSO->u); + glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSkyVertex), &VSO->color); + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); + glEnableVertexAttribArray(VATTR_COLOR); + glBindVertexArray(0); + +} + +FSkyVertexBuffer::~FSkyVertexBuffer() +{ +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyVertexBuffer::SkyVertex(int r, int c, bool yflip) +{ + static const angle_t maxSideAngle = ANGLE_180 / 3; + static const fixed_t scale = 10000 << FRACBITS; + + angle_t topAngle= (angle_t)(c / (float)mColumns * ANGLE_MAX); + angle_t sideAngle = maxSideAngle * (mRows - r) / mRows; + fixed_t height = finesine[sideAngle>>ANGLETOFINESHIFT]; + fixed_t realRadius = FixedMul(scale, finecosine[sideAngle>>ANGLETOFINESHIFT]); + fixed_t x = FixedMul(realRadius, finecosine[topAngle>>ANGLETOFINESHIFT]); + fixed_t y = (!yflip) ? FixedMul(scale, height) : FixedMul(scale, height) * -1; + fixed_t z = FixedMul(realRadius, finesine[topAngle>>ANGLETOFINESHIFT]); + + FSkyVertex vert; + + vert.color = r == 0 ? 0xffffff : 0xffffffff; + + // And the texture coordinates. + if(!yflip) // Flipped Y is for the lower hemisphere. + { + vert.u = (-c / (float)mColumns) ; + vert.v = (r / (float)mRows); + } + else + { + vert.u = (-c / (float)mColumns); + vert.v = 1.0f + ((mRows - r) / (float)mRows); + } + + if (r != 4) y+=FRACUNIT*300; + // And finally the vertex. + vert.x =-FIXED2FLOAT(x); // Doom mirrors the sky vertically! + vert.y = FIXED2FLOAT(y) - 1.f; + vert.z = FIXED2FLOAT(z); + + mVertices.Push(vert); +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyVertexBuffer::CreateSkyHemisphere(int hemi) +{ + int r, c; + bool yflip = !!(hemi & SKYHEMI_LOWER); + + mPrimStart.Push(mVertices.Size()); + + for (c = 0; c < mColumns; c++) + { + SkyVertex(1, c, yflip); + } + + // The total number of triangles per hemisphere can be calculated + // as follows: rows * columns * 2 + 2 (for the top cap). + for (r = 0; r < mRows; r++) + { + mPrimStart.Push(mVertices.Size()); + for (c = 0; c <= mColumns; c++) + { + SkyVertex(r + yflip, c, yflip); + SkyVertex(r + 1 - yflip, c, yflip); + } + } +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyVertexBuffer::CreateDome() +{ + // the first thing we put into the buffer is the fog layer object which is just 4 triangles around the viewpoint. + + mVertices.Reserve(12); + mVertices[0].Set( 1.0f, 1.0f, -1.0f); + mVertices[1].Set( 1.0f, -1.0f, -1.0f); + mVertices[2].Set(-1.0f, 0.0f, -1.0f); + + mVertices[3].Set( 1.0f, 1.0f, -1.0f); + mVertices[4].Set( 1.0f, -1.0f, -1.0f); + mVertices[5].Set( 0.0f, 0.0f, 1.0f); + + mVertices[6].Set(-1.0f, 0.0f, -1.0f); + mVertices[7].Set( 1.0f, 1.0f, -1.0f); + mVertices[8].Set( 0.0f, 0.0f, 1.0f); + + mVertices[9].Set(1.0f, -1.0f, -1.0f); + mVertices[10].Set(-1.0f, 0.0f, -1.0f); + mVertices[11].Set( 0.0f, 0.0f, 1.0f); + + mColumns = 128; + mRows = 4; + CreateSkyHemisphere(SKYHEMI_UPPER); + CreateSkyHemisphere(SKYHEMI_LOWER); + mPrimStart.Push(mVertices.Size()); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, mVertices.Size() * sizeof(FSkyVertex), &mVertices[0], GL_STATIC_DRAW); +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +inline void FSkyVertexBuffer::RenderRow(int prim, int row) +{ + glDrawArrays(prim, mPrimStart[row], mPrimStart[row + 1] - mPrimStart[row]); +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyVertexBuffer::RenderDome(FMaterial *tex, int mode) +{ + int rc = mRows + 1; + + // The caps only get drawn for the main layer but not for the overlay. + if (mode == SKYMODE_MAINLAYER && tex != NULL) + { + PalEntry pe = tex->tex->GetSkyCapColor(false); + gl_RenderState.SetObjectColor(pe); + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(); + RenderRow(GL_TRIANGLE_FAN, 0); + + pe = tex->tex->GetSkyCapColor(true); + gl_RenderState.SetObjectColor(pe); + gl_RenderState.Apply(); + RenderRow(GL_TRIANGLE_FAN, rc); + gl_RenderState.EnableTexture(true); + } + gl_RenderState.SetObjectColor(0xffffffff); + gl_RenderState.Apply(); + for (int i = 1; i <= mRows; i++) + { + RenderRow(GL_TRIANGLE_STRIP, i); + RenderRow(GL_TRIANGLE_STRIP, rc + i); + } +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void RenderDome(FMaterial * tex, float x_offset, float y_offset, bool mirror, int mode) +{ + int texh = 0; + int texw = 0; + + // 57 world units roughly represent one sky texel for the glTranslate call. + const float skyoffsetfactor = 57; + + if (tex) + { + gl_RenderState.SetMaterial(tex, CLAMP_NONE, 0, -1, false); + texw = tex->TextureWidth(); + texh = tex->TextureHeight(); + gl_RenderState.EnableModelMatrix(true); + + gl_RenderState.mModelMatrix.loadIdentity(); + gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, 0.f, 1.f, 0.f); + + float xscale = 1024.f / float(texw); + float yscale = 1.f; + if (texh < 128) + { + // smaller sky textures must be tiled. We restrict it to 128 sky pixels, though + gl_RenderState.mModelMatrix.translate(0.f, -1250.f, 0.f); + gl_RenderState.mModelMatrix.scale(1.f, 128/230.f, 1.f); + yscale = 128 / texh; // intentionally left as integer. + } + else if (texh < 200) + { + gl_RenderState.mModelMatrix.translate(0.f, -1250.f, 0.f); + gl_RenderState.mModelMatrix.scale(1.f, texh/230.f, 1.f); + } + else if (texh <= 240) + { + gl_RenderState.mModelMatrix.translate(0.f, (200 - texh + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); + gl_RenderState.mModelMatrix.scale(1.f, 1.f + ((texh-200.f)/200.f) * 1.17f, 1.f); + } + else + { + gl_RenderState.mModelMatrix.translate(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f); + gl_RenderState.mModelMatrix.scale(1.f, 1.2f * 1.17f, 1.f); + yscale = 240.f / texh; + } + gl_RenderState.EnableTextureMatrix(true); + gl_RenderState.mTextureMatrix.loadIdentity(); + gl_RenderState.mTextureMatrix.scale(mirror? -xscale : xscale, yscale, 1.f); + gl_RenderState.mTextureMatrix.translate(1.f, y_offset / texh, 1.f); + } + + GLRenderer->mSkyVBO->RenderDome(tex, mode); + gl_RenderState.EnableTextureMatrix(false); + gl_RenderState.EnableModelMatrix(false); +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +static void RenderBox(FTextureID texno, FMaterial * gltex, float x_offset, bool sky2) +{ + FSkyBox * sb = static_cast(gltex->tex); + int faces; + FMaterial * tex; + + gl_RenderState.EnableModelMatrix(true); + gl_RenderState.mModelMatrix.loadIdentity(); + + if (!sky2) + gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, glset.skyrotatevector.X, glset.skyrotatevector.Z, glset.skyrotatevector.Y); + else + gl_RenderState.mModelMatrix.rotate(-180.0f+x_offset, glset.skyrotatevector2.X, glset.skyrotatevector2.Z, glset.skyrotatevector2.Y); + + FFlatVertex *ptr; + if (sb->faces[5]) + { + faces=4; + + // north + tex = FMaterial::ValidateTexture(sb->faces[0], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(128.f, 128.f, -128.f, 0, 0); + ptr++; + ptr->Set(-128.f, 128.f, -128.f, 1, 0); + ptr++; + ptr->Set(128.f, -128.f, -128.f, 0, 1); + ptr++; + ptr->Set(-128.f, -128.f, -128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + // east + tex = FMaterial::ValidateTexture(sb->faces[1], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(-128.f, 128.f, -128.f, 0, 0); + ptr++; + ptr->Set(-128.f, 128.f, 128.f, 1, 0); + ptr++; + ptr->Set(-128.f, -128.f, -128.f, 0, 1); + ptr++; + ptr->Set(-128.f, -128.f, 128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + // south + tex = FMaterial::ValidateTexture(sb->faces[2], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(-128.f, 128.f, 128.f, 0, 0); + ptr++; + ptr->Set(128.f, 128.f, 128.f, 1, 0); + ptr++; + ptr->Set(-128.f, -128.f, 128.f, 0, 1); + ptr++; + ptr->Set(128.f, -128.f, 128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + // west + tex = FMaterial::ValidateTexture(sb->faces[3], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(128.f, 128.f, 128.f, 0, 0); + ptr++; + ptr->Set(128.f, 128.f, -128.f, 1, 0); + ptr++; + ptr->Set(128.f, -128.f, 128.f, 0, 1); + ptr++; + ptr->Set(128.f, -128.f, -128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + else + { + faces=1; + tex = FMaterial::ValidateTexture(sb->faces[0], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(128.f, 128.f, -128.f, 0, 0); + ptr++; + ptr->Set(128.f, -128.f, -128.f, 0, 1); + ptr++; + ptr->Set(-128.f, 128.f, -128.f, 0.25f, 0); + ptr++; + ptr->Set(-128.f, -128.f, -128.f, 0.25f, 1); + ptr++; + ptr->Set(-128.f, 128.f, 128.f, 0.5f, 0); + ptr++; + ptr->Set(-128.f, -128.f, 128.f, 0.5f, 1); + ptr++; + ptr->Set(128.f, 128.f, 128.f, 0.75f, 0); + ptr++; + ptr->Set(128.f, -128.f, 128.f, 0.75f, 1); + ptr++; + ptr->Set(128.f, 128.f, -128.f, 1, 0); + ptr++; + ptr->Set(128.f, -128.f, -128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + + // top + tex = FMaterial::ValidateTexture(sb->faces[faces], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(128.f, 128.f, -128.f, 0, sb->fliptop); + ptr++; + ptr->Set(-128.f, 128.f, -128.f, 1, sb->fliptop); + ptr++; + ptr->Set(128.f, 128.f, 128.f, 0, !sb->fliptop); + ptr++; + ptr->Set(-128.f, 128.f, 128.f, 1, !sb->fliptop); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + // bottom + tex = FMaterial::ValidateTexture(sb->faces[faces+1], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(128.f, -128.f, -128.f, 0, 0); + ptr++; + ptr->Set(-128.f, -128.f, -128.f, 1, 0); + ptr++; + ptr->Set(128.f, -128.f, 128.f, 0, 1); + ptr++; + ptr->Set(-128.f, -128.f, 128.f, 1, 1); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + gl_RenderState.EnableModelMatrix(false); +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- +void GLSkyPortal::DrawContents() +{ + bool drawBoth = false; + + // We have no use for Doom lighting special handling here, so disable it for this function. + int oldlightmode = glset.lightmode; + if (glset.lightmode == 8) + { + glset.lightmode = 2; + gl_RenderState.SetSoftLightLevel(-1); + } + + + gl_RenderState.ResetColor(); + gl_RenderState.EnableFog(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + bool oldClamp = gl_RenderState.SetDepthClamp(true); + + gl_MatrixStack.Push(gl_RenderState.mViewMatrix); + GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + + if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) + { + RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2); + } + else + { + gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); + if (origin->texture[0]==origin->texture[1] && origin->doublesky) origin->doublesky=false; + + if (origin->texture[0]) + { + gl_RenderState.SetTextureMode(TM_OPAQUE); + RenderDome(origin->texture[0], origin->x_offset[0], origin->y_offset, origin->mirrored, FSkyVertexBuffer::SKYMODE_MAINLAYER); + gl_RenderState.SetTextureMode(TM_MODULATE); + } + + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.05f); + + if (origin->doublesky && origin->texture[1]) + { + RenderDome(origin->texture[1], origin->x_offset[1], origin->y_offset, false, FSkyVertexBuffer::SKYMODE_SECONDLAYER); + } + + if (skyfog>0 && gl_fixedcolormap == CM_DEFAULT && (origin->fadecolor & 0xffffff) != 0) + { + PalEntry FadeColor = origin->fadecolor; + FadeColor.a = clamp(skyfog, 0, 255); + + gl_RenderState.EnableTexture(false); + gl_RenderState.SetObjectColor(FadeColor); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLES, 0, 12); + gl_RenderState.EnableTexture(true); + gl_RenderState.SetObjectColor(0xffffffff); + } + gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); + } + gl_MatrixStack.Pop(gl_RenderState.mViewMatrix); + gl_RenderState.ApplyMatrices(); + glset.lightmode = oldlightmode; + gl_RenderState.SetDepthClamp(oldClamp); +} + diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp new file mode 100644 index 000000000..e8d919a28 --- /dev/null +++ b/src/gl/scene/gl_sprite.cpp @@ -0,0 +1,975 @@ +/* +** gl_sprite.cpp +** Sprite/Particle rendering +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "p_local.h" +#include "p_effect.h" +#include "g_level.h" +#include "doomstat.h" +#include "gl/gl_functions.h" +#include "r_defs.h" +#include "r_sky.h" +#include "r_utility.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/models/gl_models.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/data/gl_vertexbuffer.h" + +CVAR(Bool, gl_usecolorblending, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CVAR(Bool, gl_spritebrightfog, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CVAR(Bool, gl_sprite_blend, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CVAR(Int, gl_spriteclip, 1, CVAR_ARCHIVE) +CVAR(Float, gl_sclipthreshold, 10.0, CVAR_ARCHIVE) +CVAR(Float, gl_sclipfactor, 1.8, CVAR_ARCHIVE) +CVAR(Int, gl_particles_style, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // 0 = square, 1 = round, 2 = smooth +CVAR(Int, gl_billboard_mode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Bool, gl_billboard_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CVAR(Int, gl_enhanced_nv_stealth, 3, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +CUSTOM_CVAR(Int, gl_fuzztype, 0, CVAR_ARCHIVE) +{ + if (self < 0 || self > 7) self = 0; +} + +extern bool r_showviewer; +EXTERN_CVAR (Float, transsouls) + +extern TArray sprites; +extern TArray SpriteFrames; +extern TArray BloodTranslationColors; + +enum HWRenderStyle +{ + STYLEHW_Normal, // default + STYLEHW_Solid, // drawn solid (needs special treatment for sprites) + STYLEHW_NoAlphaTest, // disable alpha test +}; + + +void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending) +{ + int tm, sb, db, be; + + gl_GetRenderStyle(style, drawopaque, allowcolorblending, &tm, &sb, &db, &be); + gl_RenderState.BlendEquation(be); + gl_RenderState.BlendFunc(sb, db); + gl_RenderState.SetTextureMode(tm); +} + +CVAR(Bool, gl_nolayer, false, 0) + +//========================================================================== +// +// +// +//========================================================================== +void GLSprite::Draw(int pass) +{ + if (pass == GLPASS_DECALS || pass == GLPASS_LIGHTSONLY) return; + + + + bool additivefog = false; + bool foglayer = false; + int rel = fullbright? 0 : getExtraLight(); + + if (pass==GLPASS_TRANSLUCENT) + { + // The translucent pass requires special setup for the various modes. + + // for special render styles brightmaps would not look good - especially for subtractive. + if (RenderStyle.BlendOp != STYLEOP_Add) + { + gl_RenderState.EnableBrightmap(false); + } + + gl_SetRenderStyle(RenderStyle, false, + // The rest of the needed checks are done inside gl_SetRenderStyle + trans > 1.f - FLT_EPSILON && gl_usecolorblending && gl_fixedcolormap == CM_DEFAULT && actor && + fullbright && gltexture && !gltexture->GetTransparent()); + + if (hw_styleflags == STYLEHW_NoAlphaTest) + { + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + } + else + { + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); + } + + if (RenderStyle.BlendOp == STYLEOP_Shadow) + { + float fuzzalpha=0.44f; + float minalpha=0.1f; + + // fog + fuzz don't work well without some fiddling with the alpha value! + if (!gl_isBlack(Colormap.FadeColor)) + { + float xcamera=FIXED2FLOAT(viewx); + float ycamera=FIXED2FLOAT(viewy); + + float dist=Dist2(xcamera,ycamera, x,y); + + if (!Colormap.FadeColor.a) Colormap.FadeColor.a=clamp(255-lightlevel,60,255); + + // this value was determined by trial and error and is scale dependent! + float factor=0.05f+exp(-Colormap.FadeColor.a*dist/62500.f); + fuzzalpha*=factor; + minalpha*=factor; + } + + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); + gl_RenderState.SetColor(0.2f,0.2f,0.2f,fuzzalpha, Colormap.desaturation); + additivefog = true; + } + else if (RenderStyle.BlendOp == STYLEOP_Add && RenderStyle.DestAlpha == STYLEALPHA_One) + { + additivefog = true; + } + } + if (RenderStyle.BlendOp!=STYLEOP_Shadow) + { + if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && !fullbright) + { + gl_SetDynSpriteLight(gl_light_sprites ? actor : NULL, gl_light_particles ? particle : NULL); + } + gl_SetColor(lightlevel, rel, Colormap, trans); + } + gl_RenderState.SetObjectColor(ThingColor); + + if (gl_isBlack(Colormap.FadeColor)) foglevel=lightlevel; + + if (RenderStyle.Flags & STYLEF_FadeToBlack) + { + Colormap.FadeColor=0; + additivefog = true; + } + + if (RenderStyle.BlendOp == STYLEOP_RevSub || RenderStyle.BlendOp == STYLEOP_Sub) + { + if (!modelframe) + { + // non-black fog with subtractive style needs special treatment + if (!gl_isBlack(Colormap.FadeColor)) + { + foglayer = true; + // Due to the two-layer approach we need to force an alpha test that lets everything pass + gl_RenderState.AlphaFunc(GL_GREATER, 0); + } + } + else RenderStyle.BlendOp = STYLEOP_Fuzz; // subtractive with models is not going to work. + } + + if (!foglayer) gl_SetFog(foglevel, rel, &Colormap, additivefog); + else + { + gl_RenderState.EnableFog(false); + gl_RenderState.SetFog(0, 0); + } + + if (gltexture) gl_RenderState.SetMaterial(gltexture, CLAMP_XY, translation, OverrideShader, !!(RenderStyle.Flags & STYLEF_RedIsAlpha)); + else if (!modelframe) gl_RenderState.EnableTexture(false); + + if (!modelframe) + { + // [BB] Billboard stuff + const bool drawWithXYBillboard = ( (particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD) + //&& GLRenderer->mViewActor != NULL + && (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD ))) ); + gl_RenderState.Apply(); + + Vector v1; + Vector v2; + Vector v3; + Vector v4; + + if (drawWithXYBillboard) + { + // Rotate the sprite about the vector starting at the center of the sprite + // triangle strip and with direction orthogonal to where the player is looking + // in the x/y plane. + float xcenter = (x1 + x2)*0.5; + float ycenter = (y1 + y2)*0.5; + float zcenter = (z1 + z2)*0.5; + float angleRad = DEG2RAD(270. - float(GLRenderer->mAngles.Yaw)); + + Matrix3x4 mat; + mat.MakeIdentity(); + mat.Translate(xcenter, zcenter, ycenter); + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch); + mat.Translate(-xcenter, -zcenter, -ycenter); + v1 = mat * Vector(x1, z1, y1); + v2 = mat * Vector(x2, z1, y2); + v3 = mat * Vector(x1, z2, y1); + v4 = mat * Vector(x2, z2, y2); + } + else + { + v1 = Vector(x1, z1, y1); + v2 = Vector(x2, z1, y2); + v3 = Vector(x1, z2, y1); + v4 = Vector(x2, z2, y2); + } + + FFlatVertex *ptr; + unsigned int offset, count; + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(v1[0], v1[1], v1[2], ul, vt); + ptr++; + ptr->Set(v2[0], v2[1], v2[2], ur, vt); + ptr++; + ptr->Set(v3[0], v3[1], v3[2], ul, vb); + ptr++; + ptr->Set(v4[0], v4[1], v4[2], ur, vb); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); + + if (foglayer) + { + // If we get here we know that we have colored fog and no fixed colormap. + gl_SetFog(foglevel, rel, &Colormap, additivefog); + gl_RenderState.SetFixedColormap(CM_FOGLAYER); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.Apply(); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); + gl_RenderState.SetFixedColormap(CM_DEFAULT); + } + } + else + { + gl_RenderModel(this); + } + + if (pass==GLPASS_TRANSLUCENT) + { + gl_RenderState.EnableBrightmap(true); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.SetTextureMode(TM_MODULATE); + } + + gl_RenderState.SetObjectColor(0xffffffff); + gl_RenderState.EnableTexture(true); + gl_RenderState.SetDynLight(0,0,0); +} + + +//========================================================================== +// +// +// +//========================================================================== +inline void GLSprite::PutSprite(bool translucent) +{ + int list; + // [BB] Allow models to be drawn in the GLDL_TRANSLUCENT pass. + if (translucent || !modelframe) + { + list = GLDL_TRANSLUCENT; + } + else + { + list = GLDL_MODELS; + } + gl_drawinfo->drawlists[list].AddSprite(this); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLSprite::SplitSprite(sector_t * frontsector, bool translucent) +{ + GLSprite copySprite; + fixed_t lightbottom; + float maplightbottom; + unsigned int i; + bool put=false; + TArray & lightlist=frontsector->e->XFloor.lightlist; + + for(i=0;ix,actor->y); + else lightbottom=frontsector->floorplane.ZatPoint(actor->x,actor->y); + + maplightbottom=FIXED2FLOAT(lightbottom); + if (maplightbottom & lightlist=actor->Sector->e->XFloor.lightlist; + + for(i=0;ix,actor->y); + else lightbottom=sector->floorplane.ZatPoint(actor->x,actor->y); + + //maplighttop=FIXED2FLOAT(lightlist[i].height); + maplightbottom=FIXED2FLOAT(lightbottom); + if (maplightbottomplayer || thing->flags3&MF3_ISMONSTER || + thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE || + !(thing->flags&MF_CORPSE))) || (gl_spriteclip == 3 && (smarterclip = true)) || gl_spriteclip > 1) + { + float btm = 1000000.0f; + float top = -1000000.0f; + extsector_t::xfloor &x = thing->Sector->e->XFloor; + + if (x.ffloors.Size()) + { + for (unsigned int i = 0; i < x.ffloors.Size(); i++) + { + F3DFloor * ff = x.ffloors[i]; + fixed_t floorh = ff->top.plane->ZatPoint(thingx, thingy); + fixed_t ceilingh = ff->bottom.plane->ZatPoint(thingx, thingy); + if (floorh == thing->floorz) + { + btm = FIXED2FLOAT(floorh); + } + if (ceilingh == thing->ceilingz) + { + top = FIXED2FLOAT(ceilingh); + } + if (btm != 1000000.0f && top != -1000000.0f) + { + break; + } + } + } + else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) + { + if (thing->flags2&MF2_ONMOBJ && thing->floorz == + thing->Sector->heightsec->floorplane.ZatPoint(thingx, thingy)) + { + btm = FIXED2FLOAT(thing->floorz); + top = FIXED2FLOAT(thing->ceilingz); + } + } + if (btm == 1000000.0f) + btm = FIXED2FLOAT(thing->Sector->floorplane.ZatPoint(thingx, thingy) - thing->floorclip); + if (top == -1000000.0f) + top = FIXED2FLOAT(thing->Sector->ceilingplane.ZatPoint(thingx, thingy)); + + // +/-1 to account for the one pixel empty frame around the sprite. + float diffb = (z2+1) - btm; + float difft = (z1-1) - top; + if (diffb >= 0 /*|| !gl_sprite_clip_to_floor*/) diffb = 0; + // Adjust sprites clipping into ceiling and adjust clipping adjustment for tall graphics + if (smarterclip) + { + // Reduce slightly clipping adjustment of corpses + if (thing->flags & MF_CORPSE || spriteheight > fabs(diffb)) + { + float ratio = clamp((fabs(diffb) * (float)gl_sclipfactor / (spriteheight + 1)), 0.5, 1.0); + diffb *= ratio; + } + if (!diffb) + { + if (difft <= 0) difft = 0; + if (difft >= (float)gl_sclipthreshold) + { + // dumb copy of the above. + if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || difft > (float)gl_sclipthreshold) + { + difft = 0; + } + } + if (spriteheight > fabs(difft)) + { + float ratio = clamp((fabs(difft) * (float)gl_sclipfactor / (spriteheight + 1)), 0.5, 1.0); + difft *= ratio; + } + z2 -= difft; + z1 -= difft; + } + } + if (diffb <= (0 - (float)gl_sclipthreshold)) // such a large displacement can't be correct! + { + // for living monsters standing on the floor allow a little more. + if (!(thing->flags3&MF3_ISMONSTER) || (thing->flags&MF_NOGRAVITY) || (thing->flags&MF_CORPSE) || diffb < (-1.8*(float)gl_sclipthreshold)) + { + diffb = 0; + } + } + z2 -= diffb; + z1 -= diffb; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void GLSprite::Process(AActor* thing,sector_t * sector) +{ + sector_t rs; + sector_t * rendersector; + // don't draw the thing that's used as camera (for viewshifts during quakes!) + if (thing==GLRenderer->mViewActor) return; + + // Don't waste time projecting sprites that are definitely not visible. + if (thing == NULL || thing->sprite == 0 || !thing->IsVisibleToPlayer()) + { + return; + } + + int spritenum = thing->sprite; + fixed_t spritescaleX = thing->scaleX; + fixed_t spritescaleY = thing->scaleY; + if (thing->player != NULL) + { + P_CheckPlayerSprite(thing, spritenum, spritescaleX, spritescaleY); + } + + if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->alpha)) + { + if (!(thing->flags & MF_STEALTH) || !gl_fixedcolormap || !gl_enhanced_nightvision) + return; + } + + // If this thing is in a map section that's not in view it can't possibly be visible + if (!(currentmapsection[thing->subsector->mapsection>>3] & (1 << (thing->subsector->mapsection & 7)))) return; + + // [RH] Interpolate the sprite's position to make it look smooth + fixed_t thingx = thing->PrevX + FixedMul (r_TicFrac, thing->x - thing->PrevX); + fixed_t thingy = thing->PrevY + FixedMul (r_TicFrac, thing->y - thing->PrevY); + fixed_t thingz = thing->PrevZ + FixedMul (r_TicFrac, thing->z - thing->PrevZ); + + // Too close to the camera. This doesn't look good if it is a sprite. + if (P_AproxDistance(thingx-viewx, thingy-viewy)<2*FRACUNIT) + { + // exclude vertically moving objects from this check. + if (!(thing->velx==0 && thing->vely==0 && thing->velz!=0)) + { + if (!gl_FindModelFrame(RUNTIME_TYPE(thing), spritenum, thing->frame, false)) + { + return; + } + } + } + + // don't draw first frame of a player missile + if (thing->flags&MF_MISSILE && thing->target==GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) + { + if (P_AproxDistance(thingx-viewx, thingy-viewy) < thing->Speed ) return; + } + + if (GLRenderer->mCurrentPortal) + { + int clipres = GLRenderer->mCurrentPortal->ClipPoint(thingx, thingy); + if (clipres == GLPortal::PClip_InFront) return; + } + + player_t *player=&players[consoleplayer]; + FloatRect r; + + if (sector->sectornum!=thing->Sector->sectornum) + { + rendersector=gl_FakeFlat(thing->Sector, &rs, false); + } + else + { + rendersector=sector; + } + + + x = FIXED2FLOAT(thingx); + z = FIXED2FLOAT(thingz-thing->floorclip); + y = FIXED2FLOAT(thingy); + + // [RH] Make floatbobbing a renderer-only effect. + if (thing->flags2 & MF2_FLOATBOB) + { + float fz = FIXED2FLOAT(thing->GetBobOffset(r_TicFrac)); + z += fz; + } + + modelframe = gl_FindModelFrame(RUNTIME_TYPE(thing), spritenum, thing->frame, !!(thing->flags & MF_DROPPED)); + if (!modelframe) + { + angle_t ang = R_PointToAngle(thingx, thingy); + + bool mirror; + FTextureID patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, ang - thing->angle, &mirror); + if (!patch.isValid()) return; + int type = thing->renderflags & RF_SPRITETYPEMASK; + gltexture = FMaterial::ValidateTexture(patch, (type == RF_FACESPRITE), false); + if (!gltexture) return; + + vt = gltexture->GetSpriteVT(); + vb = gltexture->GetSpriteVB(); + gltexture->GetSpriteRect(&r); + if (mirror) + { + r.left = -r.width - r.left; // mirror the sprite's x-offset + ul = gltexture->GetSpriteUL(); + ur = gltexture->GetSpriteUR(); + } + else + { + ul = gltexture->GetSpriteUR(); + ur = gltexture->GetSpriteUL(); + } + + r.Scale(FIXED2FLOAT(spritescaleX), FIXED2FLOAT(spritescaleY)); + + float rightfac = -r.left; + float leftfac = rightfac - r.width; + + z1 = z - r.top; + z2 = z1 - r.height; + + float spriteheight = FIXED2FLOAT(spritescaleY) * r.height; + + // Tests show that this doesn't look good for many decorations and corpses + if (spriteheight > 0 && gl_spriteclip > 0 && (thing->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE) + { + PerformSpriteClipAdjustment(thing, thingx, thingy, spriteheight); + } + + float viewvecX; + float viewvecY; + switch (thing->renderflags & RF_SPRITETYPEMASK) + { + case RF_FACESPRITE: + viewvecX = GLRenderer->mViewVector.X; + viewvecY = GLRenderer->mViewVector.Y; + + x1 = x - viewvecY*leftfac; + x2 = x - viewvecY*rightfac; + y1 = y + viewvecX*leftfac; + y2 = y + viewvecX*rightfac; + break; + + case RF_WALLSPRITE: + viewvecX = FIXED2FLOAT(finecosine[thing->angle >> ANGLETOFINESHIFT]); + viewvecY = FIXED2FLOAT(finesine[thing->angle >> ANGLETOFINESHIFT]); + + x1 = x + viewvecY*leftfac; + x2 = x + viewvecY*rightfac; + y1 = y - viewvecX*leftfac; + y2 = y - viewvecX*rightfac; + break; + } + } + else + { + x1 = x2 = x; + y1 = y2 = y; + z1 = z2 = z; + gltexture=NULL; + } + + depth = DMulScale20 (thing->x-viewx, viewtancos, thing->y-viewy, viewtansin); + + // light calculation + + bool enhancedvision=false; + + // allow disabling of the fullbright flag by a brightmap definition + // (e.g. to do the gun flashes of Doom's zombies correctly. + fullbright = (thing->flags5 & MF5_BRIGHT) || + ((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->tex->gl_info.bDisableFullbright)); + + lightlevel=fullbright? 255 : + gl_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? + rendersector->GetCeilingLight() : rendersector->GetFloorLight()); + foglevel = (BYTE)clamp(rendersector->lightlevel, 0, 255); + + lightlevel = (byte)gl_CheckSpriteGlow(rendersector, lightlevel, thingx, thingy, thingz); + + ThingColor = (thing->RenderStyle.Flags & STYLEF_ColorIsFixed) ? thing->fillcolor : 0xffffff; + ThingColor.a = 255; + RenderStyle = thing->RenderStyle; + + // colormap stuff is a little more complicated here... + if (gl_fixedcolormap) + { + if ((gl_enhanced_nv_stealth > 0 && gl_fixedcolormap == CM_LITE) // Infrared powerup only + || (gl_enhanced_nv_stealth == 2 && gl_fixedcolormap >= CM_TORCH)// Also torches + || (gl_enhanced_nv_stealth == 3)) // Any fixed colormap + enhancedvision=true; + + Colormap.Clear(); + + if (gl_fixedcolormap==CM_LITE) + { + if (gl_enhanced_nightvision && + (thing->IsKindOf(RUNTIME_CLASS(AInventory)) || thing->flags3&MF3_ISMONSTER || thing->flags&MF_MISSILE || thing->flags&MF_CORPSE)) + { + RenderStyle.Flags |= STYLEF_InvertSource; + } + } + } + else + { + Colormap=rendersector->ColorMap; + if (fullbright) + { + if (rendersector == §ors[rendersector->sectornum] || in_area != area_below) + // under water areas keep their color for fullbright objects + { + // Only make the light white but keep everything else (fog, desaturation and Boom colormap.) + Colormap.LightColor.r= + Colormap.LightColor.g= + Colormap.LightColor.b=0xff; + } + else + { + Colormap.LightColor.r = (3*Colormap.LightColor.r + 0xff)/4; + Colormap.LightColor.g = (3*Colormap.LightColor.g + 0xff)/4; + Colormap.LightColor.b = (3*Colormap.LightColor.b + 0xff)/4; + } + } + else if (glset.nocoloredspritelighting) + { + Colormap.Decolorize(); + } + } + + translation=thing->Translation; + + OverrideShader = -1; + trans = FIXED2FLOAT(thing->alpha); + hw_styleflags = STYLEHW_Normal; + + if (RenderStyle.BlendOp >= STYLEOP_Fuzz && RenderStyle.BlendOp <= STYLEOP_FuzzOrRevSub) + { + RenderStyle.CheckFuzz(); + if (RenderStyle.BlendOp == STYLEOP_Fuzz) + { + if (gl_fuzztype != 0) + { + // Todo: implement shader selection here + RenderStyle = LegacyRenderStyles[STYLE_Translucent]; + OverrideShader = gl_fuzztype + 4; + trans = 0.99f; // trans may not be 1 here + hw_styleflags |= STYLEHW_NoAlphaTest; + } + else + { + RenderStyle.BlendOp = STYLEOP_Shadow; + } + } + } + + if (RenderStyle.Flags & STYLEF_TransSoulsAlpha) + { + trans = transsouls; + } + else if (RenderStyle.Flags & STYLEF_Alpha1) + { + trans = 1.f; + } + + if (trans >= 1.f-FLT_EPSILON && RenderStyle.BlendOp != STYLEOP_Shadow && ( + (RenderStyle.SrcAlpha == STYLEALPHA_One && RenderStyle.DestAlpha == STYLEALPHA_Zero) || + (RenderStyle.SrcAlpha == STYLEALPHA_Src && RenderStyle.DestAlpha == STYLEALPHA_InvSrc) + )) + { + // This is a non-translucent sprite (i.e. STYLE_Normal or equivalent) + trans=1.f; + + + if (!gl_sprite_blend || modelframe) + { + RenderStyle.SrcAlpha = STYLEALPHA_One; + RenderStyle.DestAlpha = STYLEALPHA_Zero; + hw_styleflags = STYLEHW_Solid; + } + else + { + RenderStyle.SrcAlpha = STYLEALPHA_Src; + RenderStyle.DestAlpha = STYLEALPHA_InvSrc; + } + + + } + if ((gltexture && gltexture->GetTransparent()) || (RenderStyle.Flags & STYLEF_RedIsAlpha)) + { + if (hw_styleflags == STYLEHW_Solid) + { + RenderStyle.SrcAlpha = STYLEALPHA_Src; + RenderStyle.DestAlpha = STYLEALPHA_InvSrc; + } + hw_styleflags = STYLEHW_NoAlphaTest; + } + + if (enhancedvision && gl_enhanced_nightvision) + { + if (RenderStyle.BlendOp == STYLEOP_Shadow) + { + // enhanced vision makes them more visible! + trans=0.5f; + FRenderStyle rs = RenderStyle; + RenderStyle = STYLE_Translucent; + RenderStyle.Flags = rs.Flags; // Flags must be preserved, at this point it can only be STYLEF_InvertSource + } + else if (thing->flags & MF_STEALTH) + { + // enhanced vision overcomes stealth! + if (trans < 0.5f) trans = 0.5f; + } + } + + if (trans==0.0f) return; + + // end of light calculation + + actor=thing; + index = GLRenderer->gl_spriteindex++; + particle=NULL; + + const bool drawWithXYBillboard = ( !(actor->renderflags & RF_FORCEYBILLBOARD) + && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FACESPRITE + && players[consoleplayer].camera + && (gl_billboard_mode == 1 || actor->renderflags & RF_FORCEXYBILLBOARD ) ); + + + if (drawWithXYBillboard || modelframe) + { + if (!gl_fixedcolormap && !fullbright) SetSpriteColor(actor->Sector, actor->y + (actor->height>>1)); + PutSprite(hw_styleflags != STYLEHW_Solid); + } + else if (thing->Sector->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap || fullbright) + { + PutSprite(hw_styleflags != STYLEHW_Solid); + } + else + { + SplitSprite(thing->Sector, hw_styleflags != STYLEHW_Solid); + } + rendered_sprites++; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int shade, int fakeside) +{ + if (GLRenderer->mCurrentPortal) + { + int clipres = GLRenderer->mCurrentPortal->ClipPoint(particle->x, particle->y); + if (clipres == GLPortal::PClip_InFront) return; + } + + player_t *player=&players[consoleplayer]; + + if (particle->trans==0) return; + + lightlevel = gl_ClampLight(sector->GetTexture(sector_t::ceiling) == skyflatnum ? + sector->GetCeilingLight() : sector->GetFloorLight()); + foglevel = sector->lightlevel; + + if (gl_fixedcolormap) + { + Colormap.Clear(); + } + else if (!particle->bright) + { + TArray & lightlist=sector->e->XFloor.lightlist; + int lightbottom; + + Colormap = sector->ColorMap; + for(unsigned int i=0;ix,particle->y); + else lightbottom = sector->floorplane.ZatPoint(particle->x,particle->y); + + if (lightbottom < particle->y) + { + lightlevel = *lightlist[i].p_lightlevel; + Colormap.LightColor = (lightlist[i].extra_colormap)->Color; + break; + } + } + } + else + { + lightlevel = 255; + Colormap = sector->ColorMap; + Colormap.ClearColor(); + } + + trans=particle->trans/255.0f; + RenderStyle = STYLE_Translucent; + OverrideShader = 0; + + ThingColor = particle->color; + ThingColor.a = 255; + + modelframe=NULL; + gltexture=NULL; + + // [BB] Load the texture for round or smooth particles + if (gl_particles_style) + { + FTexture *lump = NULL; + if (gl_particles_style == 1) + { + lump = GLRenderer->glpart2; + } + else if (gl_particles_style == 2) + { + lump = GLRenderer->glpart; + } + + if (lump != NULL) + { + gltexture = FMaterial::ValidateTexture(lump, true); + translation = 0; + + ul = gltexture->GetUL(); + ur = gltexture->GetUR(); + vt = gltexture->GetVT(); + vb = gltexture->GetVB(); + FloatRect r; + gltexture->GetSpriteRect(&r); + } + } + + x= FIXED2FLOAT(particle->x); + y= FIXED2FLOAT(particle->y); + z= FIXED2FLOAT(particle->z); + + float scalefac=particle->size/4.0f; + // [BB] The smooth particles are smaller than the other ones. Compensate for this here. + if (gl_particles_style==2) + scalefac *= 1.7; + + float viewvecX = GLRenderer->mViewVector.X; + float viewvecY = GLRenderer->mViewVector.Y; + + x1=x+viewvecY*scalefac; + x2=x-viewvecY*scalefac; + y1=y-viewvecX*scalefac; + y2=y+viewvecX*scalefac; + z1=z-scalefac; + z2=z+scalefac; + + depth = DMulScale20 (particle->x-viewx, viewtancos, particle->y-viewy, viewtansin); + + actor=NULL; + this->particle=particle; + + // [BB] Translucent particles have to be rendered without the alpha test. + if (gl_particles_style != 2 && trans>=1.0f-FLT_EPSILON) hw_styleflags = STYLEHW_Solid; + else hw_styleflags = STYLEHW_NoAlphaTest; + + PutSprite(hw_styleflags != STYLEHW_Solid); + rendered_sprites++; +} + + + diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp new file mode 100644 index 000000000..97f326844 --- /dev/null +++ b/src/gl/scene/gl_spritelight.cpp @@ -0,0 +1,126 @@ +/* +** gl_light.cpp +** Light level / fog management / dynamic lights +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "c_dispatch.h" +#include "p_local.h" +#include "p_effect.h" +#include "vectors.h" +#include "gl/gl_functions.h" +#include "g_level.h" + +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" + + +//========================================================================== +// +// Sets a single light value from all dynamic lights affecting the specified location +// +//========================================================================== + +void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_t * subsec) +{ + ADynamicLight *light; + float frac, lr, lg, lb; + float radius; + float out[3] = { 0.0f, 0.0f, 0.0f }; + + // Go through both light lists + FLightNode * node = subsec->lighthead; + while (node) + { + light=node->lightsource; + //if (!light->owned || light->target == NULL || light->target->IsVisibleToPlayer()) + { + if (!(light->flags2&MF2_DORMANT) && + (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) + { + float dist = FVector3(FIXED2FLOAT(x - light->x), FIXED2FLOAT(y - light->y), FIXED2FLOAT(z - light->z)).Length(); + radius = light->GetRadius() * gl_lights_size; + + if (dist < radius) + { + frac = 1.0f - (dist / radius); + + if (frac > 0) + { + lr = light->GetRed() / 255.0f * gl_lights_intensity; + lg = light->GetGreen() / 255.0f * gl_lights_intensity; + lb = light->GetBlue() / 255.0f * gl_lights_intensity; + if (light->IsSubtractive()) + { + float bright = FVector3(lr, lg, lb).Length(); + FVector3 lightColor(lr, lg, lb); + lr = (bright - lr) * -1; + lg = (bright - lg) * -1; + lb = (bright - lb) * -1; + } + + out[0] += lr * frac; + out[1] += lg * frac; + out[2] += lb * frac; + } + } + } + } + node = node->nextLight; + } + gl_RenderState.SetDynLight(out[0], out[1], out[2]); +} + +void gl_SetDynSpriteLight(AActor *thing, particle_t *particle) +{ + if (thing != NULL) + { + gl_SetDynSpriteLight(thing, thing->x, thing->y, thing->z + (thing->height >> 1), thing->subsector); + } + else if (particle != NULL) + { + gl_SetDynSpriteLight(NULL, particle->x, particle->y, particle->z, particle->subsector); + } +} diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp new file mode 100644 index 000000000..c0f21adce --- /dev/null +++ b/src/gl/scene/gl_vertex.cpp @@ -0,0 +1,197 @@ +/* +** gl_vertex.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2006 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "gl/gl_functions.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_templates.h" + +EXTERN_CVAR(Bool, gl_seamless) + +//========================================================================== +// +// Split upper edge of wall +// +//========================================================================== + +void GLWall::SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr) +{ + if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; + + side_t *sidedef = seg->sidedef; + float polyw = glseg.fracright - glseg.fracleft; + float facu = (tcs[2].u - tcs[1].u) / polyw; + float facv = (tcs[2].v - tcs[1].v) / polyw; + float fact = (ztop[1] - ztop[0]) / polyw; + float facc = (zceil[1] - zceil[0]) / polyw; + float facf = (zfloor[1] - zfloor[0]) / polyw; + + for (int i = 0; i < sidedef->numsegs - 1; i++) + { + seg_t *cseg = sidedef->segs[i]; + float sidefrac = cseg->sidefrac; + if (sidefrac <= glseg.fracleft) continue; + if (sidefrac >= glseg.fracright) return; + + float fracfac = sidefrac - glseg.fracleft; + + ptr->x = cseg->v2->fx; + ptr->y = cseg->v2->fy; + ptr->z = ztop[0] + fact * fracfac; + ptr->u = tcs[1].u + facu * fracfac; + ptr->v = tcs[1].v + facv * fracfac; + ptr++; + } +} + +//========================================================================== +// +// Split upper edge of wall +// +//========================================================================== + +void GLWall::SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr) +{ + if (seg == NULL || seg->sidedef == NULL || (seg->sidedef->Flags & WALLF_POLYOBJ) || seg->sidedef->numsegs == 1) return; + + side_t *sidedef = seg->sidedef; + float polyw = glseg.fracright - glseg.fracleft; + float facu = (tcs[3].u - tcs[0].u) / polyw; + float facv = (tcs[3].v - tcs[0].v) / polyw; + float facb = (zbottom[1] - zbottom[0]) / polyw; + float facc = (zceil[1] - zceil[0]) / polyw; + float facf = (zfloor[1] - zfloor[0]) / polyw; + + for (int i = sidedef->numsegs - 2; i >= 0; i--) + { + seg_t *cseg = sidedef->segs[i]; + float sidefrac = cseg->sidefrac; + if (sidefrac >= glseg.fracright) continue; + if (sidefrac <= glseg.fracleft) return; + + float fracfac = sidefrac - glseg.fracleft; + + ptr->x = cseg->v2->fx; + ptr->y = cseg->v2->fy; + ptr->z = zbottom[0] + facb * fracfac; + ptr->u = tcs[0].u + facu * fracfac; + ptr->v = tcs[0].v + facv * fracfac; + ptr++; + } +} + +//========================================================================== +// +// Split left edge of wall +// +//========================================================================== + +void GLWall::SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr) +{ + if (vertexes[0] == NULL) return; + + vertex_t * vi = vertexes[0]; + + if (vi->numheights) + { + int i = 0; + + float polyh1 = ztop[0] - zbottom[0]; + float factv1 = polyh1 ? (tcs[1].v - tcs[0].v) / polyh1 : 0; + float factu1 = polyh1 ? (tcs[1].u - tcs[0].u) / polyh1 : 0; + + while (inumheights && vi->heightlist[i] <= zbottom[0]) i++; + while (inumheights && vi->heightlist[i] < ztop[0]) + { + ptr->x = glseg.x1; + ptr->y = glseg.y1; + ptr->z = vi->heightlist[i]; + ptr->u = factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u; + ptr->v = factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v; + ptr++; + i++; + } + } +} + +//========================================================================== +// +// Split right edge of wall +// +//========================================================================== + +void GLWall::SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr) +{ + if (vertexes[1] == NULL) return; + + vertex_t * vi = vertexes[1]; + + if (vi->numheights) + { + int i = vi->numheights - 1; + + float polyh2 = ztop[1] - zbottom[1]; + float factv2 = polyh2 ? (tcs[2].v - tcs[3].v) / polyh2 : 0; + float factu2 = polyh2 ? (tcs[2].u - tcs[3].u) / polyh2 : 0; + + while (i>0 && vi->heightlist[i] >= ztop[1]) i--; + while (i>0 && vi->heightlist[i] > zbottom[1]) + { + ptr->x = glseg.x2; + ptr->y = glseg.y2; + ptr->z = vi->heightlist[i]; + ptr->u = factu2*(vi->heightlist[i] - ztop[1]) + tcs[2].u; + ptr->v = factv2*(vi->heightlist[i] - ztop[1]) + tcs[2].v; + ptr++; + i--; + } + } +} + diff --git a/src/gl/scene/gl_wall.h b/src/gl/scene/gl_wall.h new file mode 100644 index 000000000..47ac06c46 --- /dev/null +++ b/src/gl/scene/gl_wall.h @@ -0,0 +1,361 @@ +#ifndef __GL_WALL_H +#define __GL_WALL_H +//========================================================================== +// +// One wall segment in the draw list +// +//========================================================================== +#include "r_defs.h" +#include "textures/textures.h" +#include "gl/renderer/gl_colormap.h" + +struct GLHorizonInfo; +struct F3DFloor; +struct model_t; +struct FSpriteModelFrame; +struct particle_t; +class ADynamicLight; +class FMaterial; +struct GLDrawList; +struct GLSkyInfo; +struct FTexCoordInfo; +struct FPortal; +struct FFlatVertex; + + +enum WallTypes +{ + RENDERWALL_NONE, + RENDERWALL_TOP, + RENDERWALL_M1S, + RENDERWALL_M2S, + RENDERWALL_BOTTOM, + RENDERWALL_SKY, + RENDERWALL_FOGBOUNDARY, + RENDERWALL_HORIZON, + RENDERWALL_SKYBOX, + RENDERWALL_SECTORSTACK, + RENDERWALL_PLANEMIRROR, + RENDERWALL_MIRROR, + RENDERWALL_MIRRORSURFACE, + RENDERWALL_M2SNF, + RENDERWALL_COLOR, + RENDERWALL_FFBLOCK, + RENDERWALL_COLORLAYER, + // Insert new types at the end! +}; + +struct GLSeg +{ + float x1,x2; + float y1,y2; + float fracleft, fracright; // fractional offset of the 2 vertices on the linedef +}; + +struct texcoord +{ + float u,v; +}; + +//========================================================================== +// +// One sector plane, still in fixed point +// +//========================================================================== + +struct GLSectorPlane +{ + FTextureID texture; + secplane_t plane; + fixed_t texheight; + fixed_t xoffs, yoffs; + fixed_t xscale, yscale; + angle_t angle; + + void GetFromSector(sector_t * sec, int ceiling) + { + xoffs = sec->GetXOffset(ceiling); + yoffs = sec->GetYOffset(ceiling); + xscale = sec->GetXScale(ceiling); + yscale = sec->GetYScale(ceiling); + angle = sec->GetAngle(ceiling); + texture = sec->GetTexture(ceiling); + plane = sec->GetSecPlane(ceiling); + texheight = (ceiling == sector_t::ceiling)? plane.d : -plane.d; + } +}; + + + +class GLWall +{ +public: + + enum + { + //GLWF_CLAMPX=1, use GLT_* for these! + //GLWF_CLAMPY=2, + GLWF_SKYHACK=4, + GLWF_GLOW=8, // illuminated by glowing flats + GLWF_NOSPLITUPPER=16, + GLWF_NOSPLITLOWER=32, + GLWF_NOSPLIT=64, + }; + + enum + { + RWF_BLANK = 0, + RWF_TEXTURED = 1, // actually not being used anymore because with buffers it's even less efficient not writing the texture coordinates - but leave it here + RWF_GLOW = 2, + RWF_NOSPLIT = 4, + RWF_NORENDER = 8, + }; + + + friend struct GLDrawList; + friend class GLPortal; + + GLSeg glseg; + vertex_t * vertexes[2]; // required for polygon splitting + float ztop[2],zbottom[2]; + texcoord uplft, uprgt, lolft, lorgt; + float alpha; + FMaterial *gltexture; + + FColormap Colormap; + ERenderStyle RenderStyle; + + fixed_t viewdistance; + + int lightlevel; + BYTE type; + BYTE flags; + short rellight; + + float topglowcolor[4]; + float bottomglowcolor[4]; + + int dynlightindex; + + union + { + // it's either one of them but never more! + AActor * skybox; // for skyboxes + GLSkyInfo * sky; // for normal sky + GLHorizonInfo * horizon; // for horizon information + FPortal * portal; // stacked sector portals + secplane_t * planemirror; // for plane mirrors + }; + + + FTextureID topflat,bottomflat; + secplane_t topplane, bottomplane; // we need to save these to pass them to the shader for calculating glows. + + // these are not the same as ytop and ybottom!!! + float zceil[2]; + float zfloor[2]; + +public: + seg_t * seg; // this gives the easiest access to all other structs involved + subsector_t * sub; // For polyobjects +private: + + void CheckGlowing(); + void PutWall(bool translucent); + void CheckTexturePosition(); + + void SetupLights(); + bool PrepareLight(texcoord * tcs, ADynamicLight * light); + void RenderWall(int textured, unsigned int *store = NULL); + + void FloodPlane(int pass); + + void SkyPlane(sector_t *sector, int plane, bool allowmirror); + void SkyNormal(sector_t * fs,vertex_t * v1,vertex_t * v2); + void SkyTop(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); + void SkyBottom(seg_t * seg,sector_t * fs,sector_t * bs,vertex_t * v1,vertex_t * v2); + + void Put3DWall(lightlist_t * lightlist, bool translucent); + void SplitWall(sector_t * frontsector, bool translucent); + void LightPass(); + void SetHorizon(vertex_t * ul, vertex_t * ur, vertex_t * ll, vertex_t * lr); + bool DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2); + + bool SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float ceilingrefheight, + int topleft,int topright, int bottomleft,int bottomright, int texoffset); + + void DoTexture(int type,seg_t * seg,int peg, + int ceilingrefheight,int floorrefheight, + int CeilingHeightstart,int CeilingHeightend, + int FloorHeightstart,int FloorHeightend, + int v_offset); + + void DoMidTexture(seg_t * seg, bool drawfogboundary, + sector_t * front, sector_t * back, + sector_t * realfront, sector_t * realback, + fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, + fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2); + + void GetPlanePos(F3DFloor::planeref *planeref, int &left, int &right); + + void BuildFFBlock(seg_t * seg, F3DFloor * rover, + fixed_t ff_topleft, fixed_t ff_topright, + fixed_t ff_bottomleft, fixed_t ff_bottomright); + void InverseFloors(seg_t * seg, sector_t * frontsector, + fixed_t topleft, fixed_t topright, + fixed_t bottomleft, fixed_t bottomright); + void ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector, + fixed_t topleft, fixed_t topright, + fixed_t bottomleft, fixed_t bottomright); + void DoFFloorBlocks(seg_t * seg, sector_t * frontsector, sector_t * backsector, + fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, + fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2); + + void DrawDecal(DBaseDecal *actor); + void DoDrawDecals(); + + void RenderFogBoundary(); + void RenderMirrorSurface(); + void RenderTranslucentWall(); + + void SplitLeftEdge(texcoord * tcs, FFlatVertex *&ptr); + void SplitRightEdge(texcoord * tcs, FFlatVertex *&ptr); + void SplitUpperEdge(texcoord * tcs, FFlatVertex *&ptr); + void SplitLowerEdge(texcoord * tcs, FFlatVertex *&ptr); + +public: + + void Process(seg_t *seg, sector_t *frontsector, sector_t *backsector); + void ProcessLowerMiniseg(seg_t *seg, sector_t *frontsector, sector_t *backsector); + void Draw(int pass); + + float PointOnSide(float x,float y) + { + return -((y-glseg.y1)*(glseg.x2-glseg.x1)-(x-glseg.x1)*(glseg.y2-glseg.y1)); + } + + // Lines start-end and fdiv must intersect. + double CalcIntersectionVertex(GLWall * w2) + { + float ax = glseg.x1, ay=glseg.y1; + float bx = glseg.x2, by=glseg.y2; + float cx = w2->glseg.x1, cy=w2->glseg.y1; + float dx = w2->glseg.x2, dy=w2->glseg.y2; + return ((ay-cy)*(dx-cx)-(ax-cx)*(dy-cy)) / ((bx-ax)*(dy-cy)-(by-ay)*(dx-cx)); + } + +}; + +//========================================================================== +// +// One flat plane in the draw list +// +//========================================================================== + +class GLFlat +{ +public: + friend struct GLDrawList; + + sector_t * sector; + subsector_t * sub; // only used for translucent planes + float dz; // z offset for rendering hacks + float z; // the z position of the flat (only valid for non-sloped planes) + FMaterial *gltexture; + + FColormap Colormap; // light and fog + ERenderStyle renderstyle; + + float alpha; + GLSectorPlane plane; + int lightlevel; + bool stack; + bool foggy; + bool ceiling; + BYTE renderflags; + int vboindex; + int vboheight; + + int dynlightindex; + + void SetupSubsectorLights(int pass, subsector_t * sub, int *dli = NULL); + void DrawSubsector(subsector_t * sub); + void DrawSubsectorLights(subsector_t * sub, int pass); + void DrawSubsectors(int pass, bool processlights, bool istrans); + void ProcessLights(bool istrans); + + void PutFlat(bool fog = false); + void Process(sector_t * model, int whichplane, bool notexture); + void SetFrom3DFloor(F3DFloor *rover, bool top, bool underside); + void ProcessSector(sector_t * frontsector); + void Draw(int pass, bool trans); +}; + + +//========================================================================== +// +// One sprite in the draw list +// +//========================================================================== + + +class GLSprite +{ +public: + friend struct GLDrawList; + friend void Mod_RenderModel(GLSprite * spr, model_t * mdl, int framenumber); + + BYTE lightlevel; + BYTE foglevel; + BYTE hw_styleflags; + bool fullbright; + PalEntry ThingColor; // thing's own color + FColormap Colormap; + FSpriteModelFrame * modelframe; + FRenderStyle RenderStyle; + int OverrideShader; + + int translation; + int index; + int depth; + + float x,y,z; // needed for sorting! + + float ul,ur; + float vt,vb; + float x1,y1,z1; + float x2,y2,z2; + + FMaterial *gltexture; + float trans; + AActor * actor; + particle_t * particle; + + void SplitSprite(sector_t * frontsector, bool translucent); + void SetLowerParam(); + void PerformSpriteClipAdjustment(AActor *thing, fixed_t thingx, fixed_t thingy, float spriteheight); + +public: + + void Draw(int pass); + void PutSprite(bool translucent); + void Process(AActor* thing,sector_t * sector); + void ProcessParticle (particle_t *particle, sector_t *sector);//, int shade, int fakeside) + void SetThingColor(PalEntry); + void SetSpriteColor(sector_t *sector, fixed_t y); + + // Lines start-end and fdiv must intersect. + double CalcIntersectionVertex(GLWall * w2); +}; + +inline float Dist2(float x1,float y1,float x2,float y2) +{ + return sqrtf((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); +} + +// Light + color + +void gl_SetDynSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subsector_t *subsec); +void gl_SetDynSpriteLight(AActor *actor, particle_t *particle); + +#endif diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp new file mode 100644 index 000000000..a906c47aa --- /dev/null +++ b/src/gl/scene/gl_walls.cpp @@ -0,0 +1,1790 @@ +/* +** gl_wall.cpp +** Wall rendering preparation +** +**--------------------------------------------------------------------------- +** Copyright 2000-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "p_local.h" +#include "p_lnspec.h" +#include "a_sharedglobal.h" +#include "g_level.h" +#include "templates.h" +#include "vectors.h" +#include "r_defs.h" +#include "r_sky.h" + +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_geometric.h" +#include "gl/utility/gl_templates.h" +#include "gl/shaders/gl_shader.h" + + +//========================================================================== +// +// Checks whether a wall should glow +// +//========================================================================== +void GLWall::CheckGlowing() +{ + bottomglowcolor[3] = topglowcolor[3] = 0; + if (!gl_isFullbright(Colormap.LightColor, lightlevel)) + { + FTexture *tex = TexMan[topflat]; + if (tex != NULL && tex->isGlowing()) + { + flags |= GLWall::GLWF_GLOW; + tex->GetGlowColor(topglowcolor); + topglowcolor[3] = tex->gl_info.GlowHeight; + } + + tex = TexMan[bottomflat]; + if (tex != NULL && tex->isGlowing()) + { + flags |= GLWall::GLWF_GLOW; + tex->GetGlowColor(bottomglowcolor); + bottomglowcolor[3] = tex->gl_info.GlowHeight; + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::PutWall(bool translucent) +{ + GLPortal * portal; + int list; + + static char passflag[]={ + 0, //RENDERWALL_NONE, + 1, //RENDERWALL_TOP, // unmasked + 1, //RENDERWALL_M1S, // unmasked + 2, //RENDERWALL_M2S, // depends on render and texture settings + 1, //RENDERWALL_BOTTOM, // unmasked + 4, //RENDERWALL_SKYDOME, // special + 3, //RENDERWALL_FOGBOUNDARY, // translucent + 4, //RENDERWALL_HORIZON, // special + 4, //RENDERWALL_SKYBOX, // special + 4, //RENDERWALL_SECTORSTACK, // special + 4, //RENDERWALL_PLANEMIRROR, // special + 4, //RENDERWALL_MIRROR, // special + 1, //RENDERWALL_MIRRORSURFACE, // only created here from RENDERWALL_MIRROR + 2, //RENDERWALL_M2SNF, // depends on render and texture settings, no fog, used on mid texture lines with a fog boundary. + 3, //RENDERWALL_COLOR, // translucent + 2, //RENDERWALL_FFBLOCK // depends on render and texture settings + 4, //RENDERWALL_COLORLAYER // color layer needs special handling + }; + + if (gltexture && gltexture->GetTransparent() && passflag[type] == 2) + { + translucent = true; + } + + if (gl_fixedcolormap) + { + // light planes don't get drawn with fullbright rendering + if (!gltexture && passflag[type]!=4) return; + + Colormap.Clear(); + } + + CheckGlowing(); + + if (translucent) // translucent walls + { + viewdistance = P_AproxDistance( ((seg->linedef->v1->x+seg->linedef->v2->x)>>1) - viewx, + ((seg->linedef->v1->y+seg->linedef->v2->y)>>1) - viewy); + gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); + } + else if (passflag[type]!=4) // non-translucent walls + { + + bool masked; + + masked = passflag[type]==1? false : (gltexture && gltexture->isMasked()); + + if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S)) + { + list = GLDL_MASKEDWALLSOFS; + } + else + { + list = masked ? GLDL_MASKEDWALLS : GLDL_PLAINWALLS; + } + gl_drawinfo->drawlists[list].AddWall(this); + + } + else switch (type) + { + case RENDERWALL_COLORLAYER: + gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].AddWall(this); + break; + + // portals don't go into the draw list. + // Instead they are added to the portal manager + case RENDERWALL_HORIZON: + horizon=UniqueHorizons.Get(horizon); + portal=GLPortal::FindPortal(horizon); + if (!portal) portal=new GLHorizonPortal(horizon); + portal->AddLine(this); + break; + + case RENDERWALL_SKYBOX: + portal=GLPortal::FindPortal(skybox); + if (!portal) portal=new GLSkyboxPortal(skybox); + portal->AddLine(this); + break; + + case RENDERWALL_SECTORSTACK: + portal = this->portal->GetGLPortal(); + portal->AddLine(this); + break; + + case RENDERWALL_PLANEMIRROR: + if (GLPortal::PlaneMirrorMode * planemirror->c <=0) + { + //@sync-portal + planemirror=UniquePlaneMirrors.Get(planemirror); + portal=GLPortal::FindPortal(planemirror); + if (!portal) portal=new GLPlaneMirrorPortal(planemirror); + portal->AddLine(this); + } + break; + + case RENDERWALL_MIRROR: + portal=GLPortal::FindPortal(seg->linedef); + if (!portal) portal=new GLMirrorPortal(seg->linedef); + portal->AddLine(this); + if (gl_mirror_envmap) + { + // draw a reflective layer over the mirror + type=RENDERWALL_MIRRORSURFACE; + gl_drawinfo->drawlists[GLDL_TRANSLUCENTBORDER].AddWall(this); + } + break; + + case RENDERWALL_SKY: + portal=GLPortal::FindPortal(sky); + if (!portal) portal=new GLSkyPortal(sky); + portal->AddLine(this); + break; + } +} + +//========================================================================== +// +// Sets 3D-floor lighting info +// +//========================================================================== + +void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) +{ + bool fadewall = (!translucent && lightlist->caster && (lightlist->caster->flags&FF_FADEWALLS) && + !gl_isBlack((lightlist->extra_colormap)->Fade)) && gl_isBlack(Colormap.FadeColor); + + // only modify the light level if it doesn't originate from the seg's frontsector. This is to account for light transferring effects + if (lightlist->p_lightlevel != &seg->sidedef->sector->lightlevel) + { + lightlevel = gl_ClampLight(*lightlist->p_lightlevel); + } + // relative light won't get changed here. It is constant across the entire wall. + + Colormap.CopyLightColor(lightlist->extra_colormap); + if (fadewall) lightlevel=255; + PutWall(translucent); + + if (fadewall) + { + FMaterial *tex = gltexture; + type = RENDERWALL_COLORLAYER; + gltexture = NULL; + Colormap.LightColor = (lightlist->extra_colormap)->Fade; + alpha = (255-(*lightlist->p_lightlevel))/255.f*1.f; + if (alpha>0.f) PutWall(true); + + type = RENDERWALL_FFBLOCK; + alpha = 1.0; + gltexture = tex; + } +} + +//========================================================================== +// +// Splits a wall vertically if a 3D-floor +// creates different lighting across the wall +// +//========================================================================== + +void GLWall::SplitWall(sector_t * frontsector, bool translucent) +{ + GLWall copyWall1,copyWall2; + float maplightbottomleft; + float maplightbottomright; + unsigned int i; + int origlight = lightlevel; + TArray & lightlist=frontsector->e->XFloor.lightlist; + + if (glseg.x1==glseg.x2 && glseg.y1==glseg.y2) + { + return; + } + ::SplitWall.Clock(); + +#ifdef _DEBUG + if (seg->linedef-lines==1) + { + int a = 0; + } +#endif + + if (lightlist.Size()>1) + { + for(i=0;i=ztop[0] && maplightbottomright>=ztop[1]) + { + continue; + } + + // check for an intersection with the upper plane + if ((maplightbottomleftztop[1]) || + (maplightbottomleft>ztop[0] && maplightbottomright(fabsf(glseg.x2-glseg.x1), fabsf(glseg.y2-glseg.y2)); + + float dch=ztop[1]-ztop[0]; + float dfh=maplightbottomright-maplightbottomleft; + float coeff= (ztop[0]-maplightbottomleft)/(dfh-dch); + + // check for inaccuracies - let's be a little generous here! + if (coeff*clen<.1f) + { + maplightbottomleft=ztop[0]; + } + else if (coeff*clen>clen-.1f) + { + maplightbottomright=ztop[1]; + } + else + { + // split the wall in 2 at the intersection and recursively split both halves + copyWall1=copyWall2=*this; + + copyWall1.glseg.x2 = copyWall2.glseg.x1 = glseg.x1 + coeff * (glseg.x2-glseg.x1); + copyWall1.glseg.y2 = copyWall2.glseg.y1 = glseg.y1 + coeff * (glseg.y2-glseg.y1); + copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1]-ztop[0]); + copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1]-zbottom[0]); + copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright-glseg.fracleft); + copyWall1.uprgt.u = copyWall2.uplft.u = uplft.u + coeff * (uprgt.u-uplft.u); + copyWall1.uprgt.v = copyWall2.uplft.v = uplft.v + coeff * (uprgt.v-uplft.v); + copyWall1.lorgt.u = copyWall2.lolft.u = lolft.u + coeff * (lorgt.u-lolft.u); + copyWall1.lorgt.v = copyWall2.lolft.v = lolft.v + coeff * (lorgt.v-lolft.v); + + ::SplitWall.Unclock(); + + copyWall1.SplitWall(frontsector, translucent); + copyWall2.SplitWall(frontsector, translucent); + return; + } + } + + // check for an intersection with the lower plane + if ((maplightbottomleftzbottom[1]) || + (maplightbottomleft>zbottom[0] && maplightbottomright(fabsf(glseg.x2-glseg.x1), fabsf(glseg.y2-glseg.y2)); + + float dch=zbottom[1]-zbottom[0]; + float dfh=maplightbottomright-maplightbottomleft; + float coeff= (zbottom[0]-maplightbottomleft)/(dfh-dch); + + // check for inaccuracies - let's be a little generous here because there's + // some conversions between floats and fixed_t's involved + if (coeff*clen<.1f) + { + maplightbottomleft=zbottom[0]; + } + else if (coeff*clen>clen-.1f) + { + maplightbottomright=zbottom[1]; + } + else + { + // split the wall in 2 at the intersection and recursively split both halves + copyWall1=copyWall2=*this; + + copyWall1.glseg.x2 = copyWall2.glseg.x1 = glseg.x1 + coeff * (glseg.x2-glseg.x1); + copyWall1.glseg.y2 = copyWall2.glseg.y1 = glseg.y1 + coeff * (glseg.y2-glseg.y1); + copyWall1.ztop[1] = copyWall2.ztop[0] = ztop[0] + coeff * (ztop[1]-ztop[0]); + copyWall1.zbottom[1] = copyWall2.zbottom[0] = zbottom[0] + coeff * (zbottom[1]-zbottom[0]); + copyWall1.glseg.fracright = copyWall2.glseg.fracleft = glseg.fracleft + coeff * (glseg.fracright-glseg.fracleft); + copyWall1.uprgt.u = copyWall2.uplft.u = uplft.u + coeff * (uprgt.u-uplft.u); + copyWall1.uprgt.v = copyWall2.uplft.v = uplft.v + coeff * (uprgt.v-uplft.v); + copyWall1.lorgt.u = copyWall2.lolft.u = lolft.u + coeff * (lorgt.u-lolft.u); + copyWall1.lorgt.v = copyWall2.lolft.v = lolft.v + coeff * (lorgt.v-lolft.v); + + ::SplitWall.Unclock(); + + copyWall1.SplitWall(frontsector, translucent); + copyWall2.SplitWall(frontsector, translucent); + return; + } + } + + // 3D floor is completely within this light + if (maplightbottomleft<=zbottom[0] && maplightbottomright<=zbottom[1]) + { + // These values must not be destroyed! + int ll=lightlevel; + FColormap lc=Colormap; + + if (i > 0) Put3DWall(&lightlist[i], translucent); + else PutWall(translucent); // uppermost section does not alter light at all. + + lightlevel=ll; + Colormap=lc; + + ::SplitWall.Unclock(); + + return; + } + + if (maplightbottomleft<=ztop[0] && maplightbottomright<=ztop[1] && + (maplightbottomleft!=ztop[0] || maplightbottomright!=ztop[1])) + { + copyWall1=*this; + + copyWall1.flags |= GLWF_NOSPLITLOWER; + flags |= GLWF_NOSPLITUPPER; + ztop[0]=copyWall1.zbottom[0]=maplightbottomleft; + ztop[1]=copyWall1.zbottom[1]=maplightbottomright; + uplft.v=copyWall1.lolft.v=copyWall1.uplft.v+ + (maplightbottomleft-copyWall1.ztop[0])*(copyWall1.lolft.v-copyWall1.uplft.v)/(zbottom[0]-copyWall1.ztop[0]); + uprgt.v=copyWall1.lorgt.v=copyWall1.uprgt.v+ + (maplightbottomright-copyWall1.ztop[1])*(copyWall1.lorgt.v-copyWall1.uprgt.v)/(zbottom[1]-copyWall1.ztop[1]); + copyWall1.Put3DWall(&lightlist[i], translucent); + } + if (ztop[0]==zbottom[0] && ztop[1]==zbottom[1]) + { + ::SplitWall.Unclock(); + return; + } + } + } + + // These values must not be destroyed! + int ll=lightlevel; + FColormap lc=Colormap; + + Put3DWall(&lightlist[lightlist.Size()-1], translucent); + + lightlevel=ll; + Colormap=lc; + flags &= ~GLWF_NOSPLITUPPER; + ::SplitWall.Unclock(); +} + + +//========================================================================== +// +// +// +//========================================================================== +bool GLWall::DoHorizon(seg_t * seg,sector_t * fs, vertex_t * v1,vertex_t * v2) +{ + GLHorizonInfo hi; + lightlist_t * light; + + // ZDoom doesn't support slopes in a horizon sector so I won't either! + ztop[1] = ztop[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::ceiling)); + zbottom[1] = zbottom[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::floor)); + + if (viewz < fs->GetPlaneTexZ(sector_t::ceiling)) + { + if (viewz > fs->GetPlaneTexZ(sector_t::floor)) + zbottom[1] = zbottom[0] = FIXED2FLOAT(viewz); + + if (fs->GetTexture(sector_t::ceiling) == skyflatnum) + { + SkyPlane(fs, sector_t::ceiling, false); + } + else + { + type = RENDERWALL_HORIZON; + hi.plane.GetFromSector(fs, true); + hi.lightlevel = gl_ClampLight(fs->GetCeilingLight()); + hi.colormap = fs->ColorMap; + + if (fs->e->XFloor.ffloors.Size()) + { + light = P_GetPlaneLight(fs, &fs->ceilingplane, true); + + if(!(fs->GetFlags(sector_t::ceiling)&PLANEF_ABSLIGHTING)) hi.lightlevel = gl_ClampLight(*light->p_lightlevel); + hi.colormap.LightColor = (light->extra_colormap)->Color; + } + + if (gl_fixedcolormap) hi.colormap.Clear(); + horizon = &hi; + PutWall(0); + } + ztop[1] = ztop[0] = zbottom[0]; + } + + if (viewz > fs->GetPlaneTexZ(sector_t::floor)) + { + zbottom[1] = zbottom[0] = FIXED2FLOAT(fs->GetPlaneTexZ(sector_t::floor)); + if (fs->GetTexture(sector_t::floor) == skyflatnum) + { + SkyPlane(fs, sector_t::floor, false); + } + else + { + type = RENDERWALL_HORIZON; + hi.plane.GetFromSector(fs, false); + hi.lightlevel = gl_ClampLight(fs->GetFloorLight()); + hi.colormap = fs->ColorMap; + + if (fs->e->XFloor.ffloors.Size()) + { + light = P_GetPlaneLight(fs, &fs->floorplane, false); + + if(!(fs->GetFlags(sector_t::floor)&PLANEF_ABSLIGHTING)) hi.lightlevel = gl_ClampLight(*light->p_lightlevel); + hi.colormap.LightColor = (light->extra_colormap)->Color; + } + + if (gl_fixedcolormap) hi.colormap.Clear(); + horizon = &hi; + PutWall(0); + } + } + return true; +} + +//========================================================================== +// +// +// +//========================================================================== +bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float texturetop, + int topleft,int topright, int bottomleft,int bottomright, int t_ofs) +{ + // + // + // set up texture coordinate stuff + // + // + float l_ul; + float texlength; + + if (gltexture) + { + float length = seg->sidedef? seg->sidedef->TexelLength: Dist2(glseg.x1, glseg.y1, glseg.x2, glseg.y2); + + l_ul=tci->FloatToTexU(FIXED2FLOAT(tci->TextureOffset(t_ofs))); + texlength = tci->FloatToTexU(length); + } + else + { + tci=NULL; + l_ul=0; + texlength=0; + } + + + // + // + // set up coordinates for the left side of the polygon + // + // check left side for intersections + if (topleft>=bottomleft) + { + // normal case + ztop[0]=FIXED2FLOAT(topleft); + zbottom[0]=FIXED2FLOAT(bottomleft); + + if (tci) + { + uplft.v=tci->FloatToTexV(-ztop[0] + texturetop); + lolft.v=tci->FloatToTexV(-zbottom[0] + texturetop); + } + } + else + { + // ceiling below floor - clip to the visible part of the wall + fixed_t dch=topright-topleft; + fixed_t dfh=bottomright-bottomleft; + fixed_t coeff=FixedDiv(bottomleft-topleft, dch-dfh); + + fixed_t inter_y=topleft+FixedMul(coeff,dch); + + float inter_x= FIXED2FLOAT(coeff); + + glseg.x1 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1); + glseg.y1 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1); + glseg.fracleft = inter_x; + + zbottom[0]=ztop[0]=FIXED2FLOAT(inter_y); + + if (tci) + { + lolft.v=uplft.v=tci->FloatToTexV(-ztop[0] + texturetop); + } + } + + // + // + // set up coordinates for the right side of the polygon + // + // check left side for intersections + if (topright >= bottomright) + { + // normal case + ztop[1]=FIXED2FLOAT(topright); + zbottom[1]=FIXED2FLOAT(bottomright); + + if (tci) + { + uprgt.v=tci->FloatToTexV(-ztop[1] + texturetop); + lorgt.v=tci->FloatToTexV(-zbottom[1] + texturetop); + } + } + else + { + // ceiling below floor - clip to the visible part of the wall + fixed_t dch=topright-topleft; + fixed_t dfh=bottomright-bottomleft; + fixed_t coeff=FixedDiv(bottomleft-topleft, dch-dfh); + + fixed_t inter_y=topleft+FixedMul(coeff,dch); + + float inter_x= FIXED2FLOAT(coeff); + + glseg.x2 = glseg.x1 + inter_x * (glseg.x2 - glseg.x1); + glseg.y2 = glseg.y1 + inter_x * (glseg.y2 - glseg.y1); + glseg.fracright = inter_x; + + zbottom[1]=ztop[1]=FIXED2FLOAT(inter_y); + if (tci) + { + lorgt.v=uprgt.v=tci->FloatToTexV(-ztop[1] + texturetop); + } + } + + uplft.u = lolft.u = l_ul + texlength * glseg.fracleft; + uprgt.u = lorgt.u = l_ul + texlength * glseg.fracright; + + if (gltexture != NULL) + { + bool normalize = false; + if (gltexture->tex->bHasCanvas) normalize = true; + else if (flags & GLT_CLAMPY) + { + // for negative scales we can get negative coordinates here. + normalize = (uplft.v > lolft.v || uprgt.v > lorgt.v); + } + if (normalize) + { + // we have to shift the y-coordinate from [-1..0] to [0..1] when using texture clamping with a negative scale + uplft.v+=1.f; + uprgt.v+=1.f; + lolft.v+=1.f; + lorgt.v+=1.f; + } + } + + return true; +} + +//========================================================================== +// +// Do some tweaks with the texture coordinates to reduce visual glitches +// +//========================================================================== + +void GLWall::CheckTexturePosition() +{ + float sub; + + if (gltexture->tex->bHasCanvas) return; + + // clamp texture coordinates to a reasonable range. + // Extremely large values can cause visual problems + if (uplft.v < uprgt.v) + { + sub = float(xs_FloorToInt(uplft.v)); + } + else + { + sub = float(xs_FloorToInt(uprgt.v)); + } + uplft.v -= sub; + uprgt.v -= sub; + lolft.v -= sub; + lorgt.v -= sub; + + if ((uplft.v == 0.f && uprgt.v == 0.f && lolft.v <= 1.f && lorgt.v <= 1.f) || + (uplft.v >= 0.f && uprgt.v >= 0.f && lolft.v == 1.f && lorgt.v == 1.f)) + { + flags|=GLT_CLAMPY; + } +} + +//========================================================================== +// +// Handle one sided walls, upper and lower texture +// +//========================================================================== +void GLWall::DoTexture(int _type,seg_t * seg, int peg, + int ceilingrefheight,int floorrefheight, + int topleft,int topright, + int bottomleft,int bottomright, + int v_offset) +{ + if (topleft<=bottomleft && topright<=bottomright) return; + + // The Vertex values can be destroyed in this function and must be restored aferward! + GLSeg glsave=glseg; + int lh=ceilingrefheight-floorrefheight; + int texpos; + + switch (_type) + { + case RENDERWALL_TOP: + texpos = side_t::top; + break; + case RENDERWALL_BOTTOM: + texpos = side_t::bottom; + break; + default: + texpos = side_t::mid; + break; + } + + FTexCoordInfo tci; + + gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(texpos), seg->sidedef->GetTextureYScale(texpos)); + + type = (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S && gl_mirrors) ? RENDERWALL_MIRROR : _type; + + float floatceilingref = FIXED2FLOAT(ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos))); + if (peg) floatceilingref += tci.mRenderHeight - FIXED2FLOAT(lh + v_offset); + + if (!SetWallCoordinates(seg, &tci, floatceilingref, topleft, topright, bottomleft, bottomright, + seg->sidedef->GetTextureXOffset(texpos))) return; + + CheckTexturePosition(); + + // Add this wall to the render list + sector_t * sec = sub? sub->sector : seg->frontsector; + + if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(false); + else SplitWall(sec, false); + + glseg=glsave; + flags&=~GLT_CLAMPY; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, + sector_t * front, sector_t * back, + sector_t * realfront, sector_t * realback, + fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, + fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2) + +{ + FTexCoordInfo tci; + fixed_t topleft,bottomleft,topright,bottomright; + GLSeg glsave=glseg; + fixed_t texturetop, texturebottom; + bool wrap = (seg->linedef->flags&ML_WRAP_MIDTEX) || (seg->sidedef->Flags&WALLF_WRAP_MIDTEX); + + // + // + // Get the base coordinates for the texture + // + // + if (gltexture) + { + // Align the texture to the ORIGINAL sector's height!! + // At this point slopes don't matter because they don't affect the texture's z-position + + gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::mid), seg->sidedef->GetTextureYScale(side_t::mid)); + fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); + if ( (seg->linedef->flags & ML_DONTPEGBOTTOM) >0) + { + texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor),realback->GetPlaneTexZ(sector_t::floor))+rowoffset; + texturetop=texturebottom+(tci.mRenderHeight << FRACBITS); + } + else + { + texturetop = MIN(realfront->GetPlaneTexZ(sector_t::ceiling),realback->GetPlaneTexZ(sector_t::ceiling))+rowoffset; + texturebottom=texturetop-(tci.mRenderHeight << FRACBITS); + } + } + else texturetop=texturebottom=0; + + // + // + // Depending on missing textures and possible plane intersections + // decide which planes to use for the polygon + // + // + if (realfront!=realback || drawfogboundary || wrap || realfront->GetHeightSec()) + { + // + // + // Set up the top + // + // + FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::top)); + if (!tex || tex->UseType==FTexture::TEX_Null) + { + if (front->GetTexture(sector_t::ceiling) == skyflatnum && + back->GetTexture(sector_t::ceiling) == skyflatnum) + { + // intra-sky lines do not clip the texture at all if there's no upper texture + topleft = topright = texturetop; + } + else + { + // texture is missing - use the higher plane + topleft = MAX(bch1,fch1); + topright = MAX(bch2,fch2); + } + } + else if ((bch1>fch1 || bch2>fch2) && + (seg->frontsector->GetTexture(sector_t::ceiling)!=skyflatnum || seg->backsector->GetTexture(sector_t::ceiling)==skyflatnum)) + // (!((bch1<=fch1 && bch2<=fch2) || (bch1>=fch1 && bch2>=fch2))) + { + // Use the higher plane and let the geometry clip the extruding part + topleft = bch1; + topright = bch2; + } + else + { + // But not if there can be visual artifacts. + topleft = MIN(bch1,fch1); + topright = MIN(bch2,fch2); + } + + // + // + // Set up the bottom + // + // + tex = TexMan(seg->sidedef->GetTexture(side_t::bottom)); + if (!tex || tex->UseType==FTexture::TEX_Null) + { + // texture is missing - use the lower plane + bottomleft = MIN(bfh1,ffh1); + bottomright = MIN(bfh2,ffh2); + } + else if (bfh1=ffh1 && bfh2>=ffh2))) + { + // the floor planes intersect. Use the backsector's floor for drawing so that + // drawing the front sector's plane clips the polygon automatically. + bottomleft = bfh1; + bottomright = bfh2; + } + else + { + // normal case - use the higher plane + bottomleft = MAX(bfh1,ffh1); + bottomright = MAX(bfh2,ffh2); + } + + // + // + // if we don't need a fog sheet let's clip away some unnecessary parts of the polygon + // + // + if (!drawfogboundary && !wrap) + { + if (texturetopbottomleft && texturebottom>bottomright) bottomleft=bottomright=texturebottom; + } + } + else + { + // + // + // if both sides of the line are in the same sector and the sector + // doesn't have a Transfer_Heights special don't clip to the planes + // Clipping to the planes is not necessary and can even produce + // unwanted side effects. + // + // + topleft=topright=texturetop; + bottomleft=bottomright=texturebottom; + } + + // nothing visible - skip the rest + if (topleft<=bottomleft && topright<=bottomright) return; + + + // + // + // set up texture coordinate stuff + // + // + fixed_t t_ofs = seg->sidedef->GetTextureXOffset(side_t::mid); + + if (gltexture) + { + // First adjust the texture offset so that the left edge of the linedef is inside the range [0..1]. + fixed_t texwidth = tci.TextureAdjustWidth()<>FRACBITS)+seg->sidedef->TexelLength; + + if ((textureoffset == 0 && righttex <= tci.mRenderWidth) || + (textureoffset >= 0 && righttex == tci.mRenderWidth)) + { + flags |= GLT_CLAMPX; + } + else + { + flags&=~GLT_CLAMPX; + } + if (!wrap) + { + flags|=GLT_CLAMPY; + } + } + SetWallCoordinates(seg, &tci, FIXED2FLOAT(texturetop), topleft, topright, bottomleft, bottomright, t_ofs); + + // + // + // draw fog sheet if required + // + // + if (drawfogboundary) + { + flags |= GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER; + type=RENDERWALL_FOGBOUNDARY; + PutWall(true); + if (!gltexture) + { + flags &= ~(GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER); + return; + } + type=RENDERWALL_M2SNF; + } + else type=RENDERWALL_M2S; + + // + // + // set up alpha blending + // + // + if (seg->linedef->Alpha)// && seg->linedef->special!=Line_Fogsheet) + { + bool translucent = false; + + switch (seg->linedef->flags& ML_ADDTRANS)//TRANSBITS) + { + case 0: + RenderStyle=STYLE_Translucent; + alpha=FIXED2FLOAT(seg->linedef->Alpha); + translucent = seg->linedef->Alpha < FRACUNIT || (gltexture && gltexture->GetTransparent()); + break; + + case ML_ADDTRANS: + RenderStyle=STYLE_Add; + alpha=FIXED2FLOAT(seg->linedef->Alpha); + translucent=true; + break; + } + + // + // + // for textures with large empty areas only the visible parts are drawn. + // If these textures come too close to the camera they severely affect performance + // if stacked closely together + // Recognizing vertical gaps is rather simple and well worth the effort. + // + // + FloatRect *splitrect; + int v = gltexture->GetAreas(&splitrect); + if (seg->frontsector == seg->backsector) flags |= GLWF_NOSPLIT; // we don't need to do vertex splits if a line has both sides in the same sector + if (v>0 && !drawfogboundary && !(seg->linedef->flags&ML_WRAP_MIDTEX)) + { + // split the poly! + GLWall split; + int i,t=0; + float v_factor=(zbottom[0]-ztop[0])/(lolft.v-uplft.v); + // only split the vertical area of the polygon that does not contain slopes. + float splittopv = MAX(uplft.v, uprgt.v); + float splitbotv = MIN(lolft.v, lorgt.v); + + // this is split vertically into sections. + for(i=0;i=splitbotv) break; + + float splitbot=splitrect[i].top+splitrect[i].height; + + // the current segment is above the top line of the splittable area + if (splitbot<=splittopv) continue; + + split=*this; + + // the top line of the current segment is inside the splittable area + // use the splitrect's top as top of this segment + // if not use the top of the remaining polygon + if (splitrect[i].top>splittopv) + { + split.ztop[0]=split.ztop[1]= ztop[0]+v_factor*(splitrect[i].top-uplft.v); + split.uplft.v=split.uprgt.v=splitrect[i].top; + } + // the bottom line of the current segment is inside the splittable area + // use the splitrect's bottom as bottom of this segment + // if not use the bottom of the remaining polygon + if (splitbot<=splitbotv) + { + split.zbottom[0]=split.zbottom[1]=ztop[0]+v_factor*(splitbot-uplft.v); + split.lolft.v=split.lorgt.v=splitbot; + } + // + // + // Draw the stuff + // + // + if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) split.PutWall(translucent); + else split.SplitWall(realfront, translucent); + + t=1; + } + render_texsplit+=t; + } + else + { + // + // + // Draw the stuff without splitting + // + // + if (realfront->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(translucent); + else SplitWall(realfront, translucent); + } + alpha=1.0f; + } + // restore some values that have been altered in this function + glseg=glsave; + flags&=~(GLT_CLAMPX|GLT_CLAMPY|GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER); +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::BuildFFBlock(seg_t * seg, F3DFloor * rover, + fixed_t ff_topleft, fixed_t ff_topright, + fixed_t ff_bottomleft, fixed_t ff_bottomright) +{ + side_t * mastersd = rover->master->sidedef[0]; + float to; + lightlist_t * light; + bool translucent; + int savelight=lightlevel; + FColormap savecolor=Colormap; + float ul; + float texlength; + FTexCoordInfo tci; + + if (rover->flags&FF_FOG) + { + if (!gl_fixedcolormap) + { + // this may not yet be done + light=P_GetPlaneLight(rover->target, rover->top.plane,true); + Colormap.Clear(); + Colormap.LightColor=(light->extra_colormap)->Fade; + // the fog plane defines the light level, not the front sector + lightlevel = gl_ClampLight(*light->p_lightlevel); + gltexture=NULL; + type=RENDERWALL_FFBLOCK; + } + else return; + } + else + { + + if (rover->flags&FF_UPPERTEXTURE) + { + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true); + if (!gltexture) return; + gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::top), seg->sidedef->GetTextureYScale(side_t::top)); + } + else if (rover->flags&FF_LOWERTEXTURE) + { + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true); + if (!gltexture) return; + gltexture->GetTexCoordInfo(&tci, seg->sidedef->GetTextureXScale(side_t::bottom), seg->sidedef->GetTextureYScale(side_t::bottom)); + } + else + { + gltexture = FMaterial::ValidateTexture(mastersd->GetTexture(side_t::mid), false, true); + if (!gltexture) return; + gltexture->GetTexCoordInfo(&tci, mastersd->GetTextureXScale(side_t::mid), mastersd->GetTextureYScale(side_t::mid)); + } + + to=FIXED2FLOAT((rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))? + 0 : tci.TextureOffset(mastersd->GetTextureXOffset(side_t::mid))); + + ul=tci.FloatToTexU(to + FIXED2FLOAT(tci.TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid)))); + + texlength = tci.FloatToTexU(seg->sidedef->TexelLength); + + uplft.u = lolft.u = ul + texlength * glseg.fracleft; + uprgt.u = lorgt.u = ul + texlength * glseg.fracright; + + fixed_t rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); + to= (rover->flags&(FF_UPPERTEXTURE|FF_LOWERTEXTURE))? + 0.f : FIXED2FLOAT(tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid))); + + to += FIXED2FLOAT(rowoffset); + + uplft.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_topleft)); + uprgt.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_topright)); + lolft.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_bottomleft)); + lorgt.v=tci.FloatToTexV(to + FIXED2FLOAT(*rover->top.texheight-ff_bottomright)); + type=RENDERWALL_FFBLOCK; + CheckTexturePosition(); + } + + ztop[0]=FIXED2FLOAT(ff_topleft); + ztop[1]=FIXED2FLOAT(ff_topright); + zbottom[0]=FIXED2FLOAT(ff_bottomleft);//-0.001f; + zbottom[1]=FIXED2FLOAT(ff_bottomright); + + if (rover->flags&(FF_TRANSLUCENT|FF_ADDITIVETRANS|FF_FOG)) + { + alpha=rover->alpha/255.0f; + RenderStyle = (rover->flags&FF_ADDITIVETRANS)? STYLE_Add : STYLE_Translucent; + translucent=true; + type=gltexture? RENDERWALL_M2S:RENDERWALL_COLOR; + } + else + { + alpha=1.0f; + RenderStyle=STYLE_Normal; + translucent=false; + } + + sector_t * sec = sub? sub->sector : seg->frontsector; + + if (sec->e->XFloor.lightlist.Size()==0 || gl_fixedcolormap) PutWall(translucent); + else SplitWall(sec, translucent); + + alpha=1.0f; + lightlevel = savelight; + Colormap = savecolor; + flags&=~GLT_CLAMPY; +} + + +//========================================================================== +// +// +// +//========================================================================== + +__forceinline void GLWall::GetPlanePos(F3DFloor::planeref *planeref, int &left, int &right) +{ + if (planeref->plane->a | planeref->plane->b) + { + left=planeref->plane->ZatPoint(vertexes[0]); + right=planeref->plane->ZatPoint(vertexes[1]); + } + else if(planeref->isceiling == sector_t::ceiling) + { + left = right = planeref->plane->d; + } + else + { + left = right = -planeref->plane->d; + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector, + fixed_t topleft, fixed_t topright, + fixed_t bottomleft, fixed_t bottomright) +{ + TArray & frontffloors=frontsector->e->XFloor.ffloors; + + for(unsigned int i=0;iflags&FF_EXISTS)) continue; + if (!(rover->flags&FF_RENDERSIDES)) continue; + if (!(rover->flags&(FF_INVERTSIDES|FF_ALLSIDES))) continue; + + fixed_t ff_topleft; + fixed_t ff_topright; + fixed_t ff_bottomleft; + fixed_t ff_bottomright; + + GetPlanePos(&rover->top, ff_topleft, ff_topright); + GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright); + + // above ceiling + if (ff_bottomleft>topleft && ff_bottomright>topright) continue; + + if (ff_topleft>topleft && ff_topright>topright) + { + // the new section overlaps with the previous one - clip it! + ff_topleft=topleft; + ff_topright=topright; + } + if (ff_bottomleft & frontffloors=frontsector->e->XFloor.ffloors; + + int flags = ffloor->flags & (FF_SWIMMABLE|FF_TRANSLUCENT); + + for(unsigned int i=0;iflags&FF_EXISTS)) continue; + if (!(rover->flags&FF_RENDERSIDES)) continue; + if ((rover->flags&(FF_SWIMMABLE|FF_TRANSLUCENT))!=flags) continue; + + fixed_t ff_topleft; + fixed_t ff_topright; + fixed_t ff_bottomleft; + fixed_t ff_bottomright; + + GetPlanePos(&rover->top, ff_topleft, ff_topright); + + // we are completely below the bottom so unless there are some + // (unsupported) intersections there won't be any more floors that + // could clip this one. + if (ff_topleftbottom, ff_bottomleft, ff_bottomright); + // above top line? + if (ff_bottomleft>topleft && ff_bottomright>topright) continue; + + // overlapping the top line + if (ff_topleft>=topleft && ff_topright>=topright) + { + // overlapping with the entire range + if (ff_bottomleft<=bottomleft && ff_bottomright<=bottomright) return; + else if (ff_bottomleft>bottomleft && ff_bottomright>bottomright) + { + topleft=ff_bottomleft; + topright=ff_bottomright; + } + else + { + // an intersecting case. + // proper handling requires splitting but + // I don't need this right now. + } + } + else if (ff_topleft<=topleft && ff_topright<=topright) + { + BuildFFBlock(seg, ffloor, topleft, topright, ff_topleft, ff_topright); + if (ff_bottomleft<=bottomleft && ff_bottomright<=bottomright) return; + topleft=ff_bottomleft; + topright=ff_bottomright; + } + else + { + // an intersecting case. + // proper handling requires splitting but + // I don't need this right now. + } + } + +done: + // if the program reaches here there is one block left to draw + BuildFFBlock(seg, ffloor, topleft, topright, bottomleft, bottomright); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::DoFFloorBlocks(seg_t * seg,sector_t * frontsector,sector_t * backsector, + fixed_t fch1, fixed_t fch2, fixed_t ffh1, fixed_t ffh2, + fixed_t bch1, fixed_t bch2, fixed_t bfh1, fixed_t bfh2) + +{ + TArray & backffloors=backsector->e->XFloor.ffloors; + fixed_t topleft, topright, bottomleft, bottomright; + bool renderedsomething=false; + + // if the ceilings intersect use the backsector's height because this sector's ceiling will + // obstruct the redundant parts. + + if (fch1bfh1 && ffh2>bfh2) + { + bottomleft=ffh1; + bottomright=ffh2; + } + else + { + bottomleft=bfh1; + bottomright=bfh2; + } + + for(unsigned int i=0;iflags&FF_EXISTS)) continue; + if (!(rover->flags&FF_RENDERSIDES) || (rover->flags&FF_INVERTSIDES)) continue; + + fixed_t ff_topleft; + fixed_t ff_topright; + fixed_t ff_bottomleft; + fixed_t ff_bottomright; + + GetPlanePos(&rover->top, ff_topleft, ff_topright); + GetPlanePos(&rover->bottom, ff_bottomleft, ff_bottomright); + + // completely above ceiling + if (ff_bottomleft>topleft && ff_bottomright>topright && !renderedsomething) continue; + + if (ff_topleft>topleft && ff_topright>topright) + { + // the new section overlaps with the previous one - clip it! + ff_topleft=topleft; + ff_topright=topright; + } + + // do all inverse floors above the current one it there is a gap between the + // last 3D floor and this one. + if (topleft>ff_topleft && topright>ff_topright) + InverseFloors(seg, frontsector, topleft, topright, ff_topleft, ff_topright); + + // if translucent or liquid clip away adjoining parts of the same type of FFloors on the other side + if (rover->flags&(FF_SWIMMABLE|FF_TRANSLUCENT)) + ClipFFloors(seg, rover, frontsector, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright); + else + BuildFFBlock(seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright); + + topleft=ff_bottomleft; + topright=ff_bottomright; + renderedsomething=true; + if (topleft<=bottomleft && topright<=bottomright) return; + } + + // draw all inverse floors below the lowest one + if (frontsector->e->XFloor.ffloors.Size() > 0) + { + if (topleft>bottomleft || topright>bottomright) + InverseFloors(seg, frontsector, topleft, topright, bottomleft, bottomright); + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector) +{ + vertex_t * v1, *v2; + fixed_t fch1; + fixed_t ffh1; + fixed_t fch2; + fixed_t ffh2; + sector_t * realfront; + sector_t * realback; + sector_t * segfront; + sector_t * segback; + +#ifdef _DEBUG + if (seg->linedef-lines==904) + { + int a = 0; + } +#endif + + // note: we always have a valid sidedef and linedef reference when getting here. + + this->seg = seg; + + if ((seg->sidedef->Flags & WALLF_POLYOBJ) && seg->backsector) + { + // Textures on 2-sided polyobjects are aligned to the actual seg's sectors + segfront = realfront = seg->frontsector; + segback = realback = seg->backsector; + } + else + { + // Need these for aligning the textures + realfront = §ors[frontsector->sectornum]; + realback = backsector ? §ors[backsector->sectornum] : NULL; + segfront = frontsector; + segback = backsector; + } + + if (seg->sidedef == seg->linedef->sidedef[0]) + { + v1 = seg->linedef->v1; + v2 = seg->linedef->v2; + } + else + { + v1 = seg->linedef->v2; + v2 = seg->linedef->v1; + } + + if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + glseg.fracleft = 0; + glseg.fracright = 1; + if (gl_seamless) + { + if (v1->dirty) gl_RecalcVertexHeights(v1); + if (v2->dirty) gl_RecalcVertexHeights(v2); + } + } + else // polyobjects must be rendered per seg. + { + if (abs(v1->x - v2->x) > abs(v1->y - v2->y)) + { + glseg.fracleft = float(seg->v1->x - v1->x) / float(v2->x - v1->x); + glseg.fracright = float(seg->v2->x - v1->x) / float(v2->x - v1->x); + } + else + { + glseg.fracleft = float(seg->v1->y - v1->y) / float(v2->y - v1->y); + glseg.fracright = float(seg->v2->y - v1->y) / float(v2->y - v1->y); + } + v1 = seg->v1; + v2 = seg->v2; + } + + + vertexes[0] = v1; + vertexes[1] = v2; + + glseg.x1 = FIXED2FLOAT(v1->x); + glseg.y1 = FIXED2FLOAT(v1->y); + glseg.x2 = FIXED2FLOAT(v2->x); + glseg.y2 = FIXED2FLOAT(v2->y); + Colormap = frontsector->ColorMap; + flags = 0; + dynlightindex = UINT_MAX; + + int rel = 0; + int orglightlevel = gl_ClampLight(frontsector->lightlevel); + bool foggy = (!gl_isBlack(Colormap.FadeColor) || level.flags&LEVEL_HASFADETABLE); // fog disables fake contrast + lightlevel = gl_ClampLight(seg->sidedef->GetLightLevel(foggy, orglightlevel, false, &rel)); + if (orglightlevel >= 253) // with the software renderer fake contrast won't be visible above this. + { + rellight = 0; + } + else if (lightlevel - rel > 256) // the brighter part of fake contrast will be clamped so also clamp the darker part by the same amount for better looks + { + rellight = 256 - lightlevel + rel; + } + else + { + rellight = rel; + } + + alpha = 1.0f; + RenderStyle = STYLE_Normal; + gltexture = NULL; + + topflat = frontsector->GetTexture(sector_t::ceiling); // for glowing textures. These must be saved because + bottomflat = frontsector->GetTexture(sector_t::floor); // the sector passed here might be a temporary copy. + topplane = frontsector->ceilingplane; + bottomplane = frontsector->floorplane; + + // Save a little time (up to 0.3 ms per frame ;) ) + if (frontsector->floorplane.a | frontsector->floorplane.b) + { + ffh1 = segfront->floorplane.ZatPoint(v1); + ffh2 = segfront->floorplane.ZatPoint(v2); + zfloor[0] = FIXED2FLOAT(ffh1); + zfloor[1] = FIXED2FLOAT(ffh2); + } + else + { + ffh1 = ffh2 = -segfront->floorplane.d; + zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh2); + } + + if (segfront->ceilingplane.a | segfront->ceilingplane.b) + { + fch1 = segfront->ceilingplane.ZatPoint(v1); + fch2 = segfront->ceilingplane.ZatPoint(v2); + zceil[0] = FIXED2FLOAT(fch1); + zceil[1] = FIXED2FLOAT(fch2); + } + else + { + fch1 = fch2 = segfront->ceilingplane.d; + zceil[0] = zceil[1] = FIXED2FLOAT(fch2); + } + + + if (seg->linedef->special == Line_Horizon) + { + SkyNormal(frontsector, v1, v2); + DoHorizon(seg, frontsector, v1, v2); + return; + } + + //return; + // [GZ] 3D middle textures are necessarily two-sided, even if they lack the explicit two-sided flag + if (!backsector || !(seg->linedef->flags&(ML_TWOSIDED | ML_3DMIDTEX))) // one sided + { + // sector's sky + SkyNormal(frontsector, v1, v2); + + // normal texture + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::mid), false, true); + if (gltexture) + { + DoTexture(RENDERWALL_M1S, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, + realfront->GetPlaneTexZ(sector_t::ceiling), realfront->GetPlaneTexZ(sector_t::floor), // must come from the original! + fch1, fch2, ffh1, ffh2, 0); + } + } + else // two sided + { + + fixed_t bch1; + fixed_t bch2; + fixed_t bfh1; + fixed_t bfh2; + + if (segback->floorplane.a | segback->floorplane.b) + { + bfh1 = segback->floorplane.ZatPoint(v1); + bfh2 = segback->floorplane.ZatPoint(v2); + } + else + { + bfh1 = bfh2 = -segback->floorplane.d; + } + + if (segback->ceilingplane.a | segback->ceilingplane.b) + { + bch1 = segback->ceilingplane.ZatPoint(v1); + bch2 = segback->ceilingplane.ZatPoint(v2); + } + else + { + bch1 = bch2 = segback->ceilingplane.d; + } + + SkyTop(seg, frontsector, backsector, v1, v2); + SkyBottom(seg, frontsector, backsector, v1, v2); + + // upper texture + if (frontsector->GetTexture(sector_t::ceiling) != skyflatnum || backsector->GetTexture(sector_t::ceiling) != skyflatnum) + { + fixed_t bch1a = bch1, bch2a = bch2; + if (frontsector->GetTexture(sector_t::floor) != skyflatnum || backsector->GetTexture(sector_t::floor) != skyflatnum) + { + // the back sector's floor obstructs part of this wall + if (ffh1 > bch1 && ffh2 > bch2) + { + bch2a = ffh2; + bch1a = ffh1; + } + } + + if (bch1a < fch1 || bch2a < fch2) + { + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::top), false, true); + if (gltexture) + { + DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, + realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling), + fch1, fch2, bch1a, bch2a, 0); + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + if ((frontsector->ceilingplane.a | frontsector->ceilingplane.b | + backsector->ceilingplane.a | backsector->ceilingplane.b) && + frontsector->GetTexture(sector_t::ceiling) != skyflatnum && + backsector->GetTexture(sector_t::ceiling) != skyflatnum) + { + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::ceiling), false, true); + if (gltexture) + { + DoTexture(RENDERWALL_TOP, seg, (seg->linedef->flags & (ML_DONTPEGTOP)) == 0, + realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling), + fch1, fch2, bch1a, bch2a, 0); + } + } + else + { + // skip processing if the back is a malformed subsector + if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) + { + gl_drawinfo->AddUpperMissingTexture(seg->sidedef, sub, bch1a); + } + } + } + } + } + + + /* mid texture */ + bool drawfogboundary = gl_CheckFog(frontsector, backsector); + FTexture *tex = TexMan(seg->sidedef->GetTexture(side_t::mid)); + if (tex != NULL) + { + if (i_compatflags & COMPATF_MASKEDMIDTEX) + { + tex = tex->GetRawTexture(); + } + gltexture = FMaterial::ValidateTexture(tex, false); + } + else gltexture = NULL; + + if (gltexture || drawfogboundary) + { + DoMidTexture(seg, drawfogboundary, frontsector, backsector, realfront, realback, + fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); + } + + if (backsector->e->XFloor.ffloors.Size() || frontsector->e->XFloor.ffloors.Size()) + { + DoFFloorBlocks(seg, frontsector, backsector, fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); + } + + /* bottom texture */ + // the back sector's ceiling obstructs part of this wall (specially important for sky sectors) + if (fch1ffh1 || bfh2>ffh2) + { + gltexture = FMaterial::ValidateTexture(seg->sidedef->GetTexture(side_t::bottom), false, true); + if (gltexture) + { + DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, + realback->GetPlaneTexZ(sector_t::floor), realfront->GetPlaneTexZ(sector_t::floor), + bfh1, bfh2, ffh1, ffh2, + frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum ? + realfront->GetPlaneTexZ(sector_t::floor) - realback->GetPlaneTexZ(sector_t::ceiling) : + realfront->GetPlaneTexZ(sector_t::floor) - realfront->GetPlaneTexZ(sector_t::ceiling)); + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + if ((frontsector->floorplane.a | frontsector->floorplane.b | + backsector->floorplane.a | backsector->floorplane.b) && + frontsector->GetTexture(sector_t::floor) != skyflatnum && + backsector->GetTexture(sector_t::floor) != skyflatnum) + { + // render it anyway with the sector's floor texture. With a background sky + // there are ugly holes otherwise and slopes are simply not precise enough + // to mach in any case. + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true); + if (gltexture) + { + DoTexture(RENDERWALL_BOTTOM, seg, (seg->linedef->flags & ML_DONTPEGBOTTOM) > 0, + realback->GetPlaneTexZ(sector_t::floor), realfront->GetPlaneTexZ(sector_t::floor), + bfh1, bfh2, ffh1, ffh2, realfront->GetPlaneTexZ(sector_t::floor) - realfront->GetPlaneTexZ(sector_t::ceiling)); + } + } + else if (backsector->GetTexture(sector_t::floor) != skyflatnum) + { + // skip processing if the back is a malformed subsector + if (seg->PartnerSeg != NULL && !(seg->PartnerSeg->Subsector->hacked & 4)) + { + gl_drawinfo->AddLowerMissingTexture(seg->sidedef, sub, bfh1); + } + } + } + } + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector) +{ + if (frontsector->GetTexture(sector_t::floor) == skyflatnum) return; + + fixed_t ffh = frontsector->GetPlaneTexZ(sector_t::floor); + fixed_t bfh = backsector->GetPlaneTexZ(sector_t::floor); + if (bfh > ffh) + { + this->seg = seg; + this->sub = NULL; + + vertex_t * v1 = seg->v1; + vertex_t * v2 = seg->v2; + vertexes[0] = v1; + vertexes[1] = v2; + + glseg.x1 = FIXED2FLOAT(v1->x); + glseg.y1 = FIXED2FLOAT(v1->y); + glseg.x2 = FIXED2FLOAT(v2->x); + glseg.y2 = FIXED2FLOAT(v2->y); + glseg.fracleft = 0; + glseg.fracright = 1; + + flags = 0; + + // can't do fake contrast without a sidedef + lightlevel = gl_ClampLight(frontsector->lightlevel); + rellight = 0; + + alpha = 1.0f; + RenderStyle = STYLE_Normal; + Colormap = frontsector->ColorMap; + + topflat = frontsector->GetTexture(sector_t::ceiling); // for glowing textures + bottomflat = frontsector->GetTexture(sector_t::floor); + topplane = frontsector->ceilingplane; + bottomplane = frontsector->floorplane; + dynlightindex = UINT_MAX; + + zfloor[0] = zfloor[1] = FIXED2FLOAT(ffh); + + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true); + + if (gltexture) + { + FTexCoordInfo tci; + type = RENDERWALL_BOTTOM; + gltexture->GetTexCoordInfo(&tci, FRACUNIT, FRACUNIT); + SetWallCoordinates(seg, &tci, FIXED2FLOAT(bfh), bfh, bfh, ffh, ffh, 0); + PutWall(false); + } + } +} diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp new file mode 100644 index 000000000..5135a5947 --- /dev/null +++ b/src/gl/scene/gl_walls_draw.cpp @@ -0,0 +1,444 @@ +/* +** gl_walls_draw.cpp +** Wall rendering +** +**--------------------------------------------------------------------------- +** Copyright 2000-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "p_local.h" +#include "p_lnspec.h" +#include "a_sharedglobal.h" +#include "gl/gl_functions.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/dynlights/gl_lightbuffer.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/scene/gl_portal.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" + +EXTERN_CVAR(Bool, gl_seamless) + +//========================================================================== +// +// Collect lights for shader +// +//========================================================================== +FDynLightData lightdata; + + +void GLWall::SetupLights() +{ + // check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.) + switch (type) + { + case RENDERWALL_FOGBOUNDARY: + case RENDERWALL_MIRRORSURFACE: + case RENDERWALL_COLOR: + case RENDERWALL_COLORLAYER: + return; + } + + float vtx[]={glseg.x1,zbottom[0],glseg.y1, glseg.x1,ztop[0],glseg.y1, glseg.x2,ztop[1],glseg.y2, glseg.x2,zbottom[1],glseg.y2}; + Plane p; + + lightdata.Clear(); + p.Init(vtx,4); + + if (!p.ValidNormal()) + { + return; + } + FLightNode *node; + if (seg->sidedef == NULL) + { + node = NULL; + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + node = seg->sidedef->lighthead; + } + else if (sub) + { + // Polobject segs cannot be checked per sidedef so use the subsector instead. + node = sub->lighthead; + } + else node = NULL; + + // Iterate through all dynamic lights which touch this wall and render them + while (node) + { + if (!(node->lightsource->flags2&MF2_DORMANT)) + { + iter_dlight++; + + Vector fn, pos; + + float x = FIXED2FLOAT(node->lightsource->x); + float y = FIXED2FLOAT(node->lightsource->y); + float z = FIXED2FLOAT(node->lightsource->z); + float dist = fabsf(p.DistToPoint(x, z, y)); + float radius = (node->lightsource->GetRadius() * gl_lights_size); + float scale = 1.0f / ((2.f * radius) - dist); + + if (radius > 0.f && dist < radius) + { + Vector nearPt, up, right; + + pos.Set(x,z,y); + fn=p.Normal(); + fn.GetRightUp(right, up); + + Vector tmpVec = fn * dist; + nearPt = pos + tmpVec; + + Vector t1; + int outcnt[4]={0,0,0,0}; + texcoord tcs[4]; + + // do a quick check whether the light touches this polygon + for(int i=0;i<4;i++) + { + t1.Set(&vtx[i*3]); + Vector nearToVert = t1 - nearPt; + tcs[i].u = (nearToVert.Dot(right) * scale) + 0.5f; + tcs[i].v = (nearToVert.Dot(up) * scale) + 0.5f; + + if (tcs[i].u<0) outcnt[0]++; + if (tcs[i].u>1) outcnt[1]++; + if (tcs[i].v<0) outcnt[2]++; + if (tcs[i].v>1) outcnt[3]++; + + } + if (outcnt[0]!=4 && outcnt[1]!=4 && outcnt[2]!=4 && outcnt[3]!=4) + { + gl_GetLight(p, node->lightsource, true, false, lightdata); + } + } + } + node = node->nextLight; + } + + dynlightindex = GLRenderer->mLights->UploadLights(lightdata); +} + + +//========================================================================== +// +// General purpose wall rendering function +// everything goes through here +// +//========================================================================== + +void GLWall::RenderWall(int textured, unsigned int *store) +{ + static texcoord tcs[4]; // making this variable static saves us a relatively costly stack integrity check. + bool split = (gl_seamless && !(textured&RWF_NOSPLIT) && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT)); + + tcs[0]=lolft; + tcs[1]=uplft; + tcs[2]=uprgt; + tcs[3]=lorgt; + if ((flags&GLWF_GLOW) && (textured & RWF_GLOW)) + { + gl_RenderState.SetGlowPlanes(topplane, bottomplane); + gl_RenderState.SetGlowParams(topglowcolor, bottomglowcolor); + } + + if (!(textured & RWF_NORENDER)) + { + gl_RenderState.Apply(); + gl_RenderState.ApplyLightIndex(dynlightindex); + } + + // the rest of the code is identical for textured rendering and lights + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + unsigned int count, offset; + + ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[0].u, tcs[0].v); + ptr++; + if (split && glseg.fracleft == 0) SplitLeftEdge(tcs, ptr); + ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[1].u, tcs[1].v); + ptr++; + if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(tcs, ptr); + ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[2].u, tcs[2].v); + ptr++; + if (split && glseg.fracright == 1) SplitRightEdge(tcs, ptr); + ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[3].u, tcs[3].v); + ptr++; + if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(tcs, ptr); + count = GLRenderer->mVBO->GetCount(ptr, &offset); + if (!(textured & RWF_NORENDER)) + { + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, offset, count); + vertexcount += count; + } + if (store != NULL) + { + store[0] = offset; + store[1] = count; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void GLWall::RenderFogBoundary() +{ + if (gl_fogmode && gl_fixedcolormap == 0) + { + int rel = rellight + getExtraLight(); + gl_SetFog(lightlevel, rel, &Colormap, false); + gl_RenderState.SetEffect(EFF_FOGBOUNDARY); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + RenderWall(RWF_BLANK); + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); + gl_RenderState.SetEffect(EFF_NONE); + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::RenderMirrorSurface() +{ + if (GLRenderer->mirrortexture == NULL) return; + + // For the sphere map effect we need a normal of the mirror surface, + Vector v(glseg.y2-glseg.y1, 0 ,-glseg.x2+glseg.x1); + v.Normalize(); + + // we use texture coordinates and texture matrix to pass the normal stuff to the shader so that the default vertex buffer format can be used as is. + lolft.u = lorgt.u = uplft.u = uprgt.u = v.X(); + lolft.v = lorgt.v = uplft.v = uprgt.v = v.Z(); + + gl_RenderState.EnableTextureMatrix(true); + gl_RenderState.mTextureMatrix.computeNormalMatrix(gl_RenderState.mViewMatrix); + + // Use sphere mapping for this + gl_RenderState.SetEffect(EFF_SPHEREMAP); + + gl_SetColor(lightlevel, 0, Colormap ,0.1f); + gl_SetFog(lightlevel, 0, &Colormap, true); + gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); + gl_RenderState.AlphaFunc(GL_GREATER,0); + glDepthFunc(GL_LEQUAL); + + FMaterial * pat=FMaterial::ValidateTexture(GLRenderer->mirrortexture, false); + gl_RenderState.SetMaterial(pat, CLAMP_NONE, 0, -1, false); + + flags &= ~GLWF_GLOW; + RenderWall(RWF_BLANK); + + gl_RenderState.EnableTextureMatrix(false); + gl_RenderState.SetEffect(EFF_NONE); + + // Restore the defaults for the translucent pass + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); + glDepthFunc(GL_LESS); + + // This is drawn in the translucent pass which is done after the decal pass + // As a result the decals have to be drawn here. + if (seg->sidedef->AttachedDecals) + { + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + glDepthMask(false); + DoDrawDecals(); + glDepthMask(true); + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +void GLWall::RenderTranslucentWall() +{ + bool transparent = gltexture? gltexture->GetTransparent() : false; + + // currently the only modes possible are solid, additive or translucent + // and until that changes I won't fix this code for the new blending modes! + bool isadditive = RenderStyle == STYLE_Add; + + if (gl_fixedcolormap == CM_DEFAULT && gl_lights && (gl.flags & RFL_BUFFER_STORAGE)) + { + SetupLights(); + } + + if (!transparent) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); + + int extra; + if (gltexture) + { + gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); + gl_RenderState.SetMaterial(gltexture, flags & 3, 0, -1, false); + extra = getExtraLight(); + } + else + { + gl_RenderState.EnableTexture(false); + extra = 0; + } + int tmode = gl_RenderState.GetTextureMode(); + + gl_SetColor(lightlevel, extra, Colormap, fabsf(alpha)); + if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, extra, &Colormap, isadditive); + else + { + if (flags & GLT_CLAMPY) + { + if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); + } + gl_SetFog(255, 0, NULL, false); + } + + RenderWall(RWF_TEXTURED|RWF_NOSPLIT); + + // restore default settings + if (isadditive) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + if (!gltexture) + { + gl_RenderState.EnableTexture(true); + } + gl_RenderState.EnableGlow(false); + gl_RenderState.SetTextureMode(tmode); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::Draw(int pass) +{ + int rel; + int tmode; + +#ifdef _DEBUG + if (seg->linedef-lines==879) + { + int a = 0; + } +#endif + + + switch (pass) + { + case GLPASS_LIGHTSONLY: + SetupLights(); + break; + + case GLPASS_ALL: + SetupLights(); + // fall through + case GLPASS_PLAIN: + rel = rellight + getExtraLight(); + gl_SetColor(lightlevel, rel, Colormap,1.0f); + tmode = gl_RenderState.GetTextureMode(); + if (type!=RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, false); + else + { + if (flags & GLT_CLAMPY) + { + if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); + } + gl_SetFog(255, 0, NULL, false); + } + gl_RenderState.EnableGlow(!!(flags & GLWF_GLOW)); + gl_RenderState.SetMaterial(gltexture, flags & 3, false, -1, false); + RenderWall(RWF_TEXTURED|RWF_GLOW); + gl_RenderState.EnableGlow(false); + gl_RenderState.SetTextureMode(tmode); + break; + + case GLPASS_TRANSLUCENT: + + + switch (type) + { + case RENDERWALL_MIRRORSURFACE: + RenderMirrorSurface(); + break; + + case RENDERWALL_FOGBOUNDARY: + RenderFogBoundary(); + break; + + case RENDERWALL_COLORLAYER: + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + RenderTranslucentWall(); + glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(0, 0); + + default: + RenderTranslucentWall(); + break; + } + } +} diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp new file mode 100644 index 000000000..71b4a8fdc --- /dev/null +++ b/src/gl/scene/gl_weapon.cpp @@ -0,0 +1,437 @@ +/* +** gl_weapon.cpp +** Weapon sprite drawing +** +**--------------------------------------------------------------------------- +** Copyright 2002-2005 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "sbar.h" +#include "r_utility.h" +#include "v_video.h" +#include "doomstat.h" +#include "d_player.h" +#include "g_level.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/dynlights/gl_glow.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/models/gl_models.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" + +EXTERN_CVAR (Bool, r_drawplayersprites) +EXTERN_CVAR(Float, transsouls) +EXTERN_CVAR (Bool, st_scale) +EXTERN_CVAR(Int, gl_fuzztype) +EXTERN_CVAR (Bool, r_deathcamera) + + +//========================================================================== +// +// R_DrawPSprite +// +//========================================================================== + +void FGLRenderer::DrawPSprite (player_t * player,pspdef_t *psp,fixed_t sx, fixed_t sy, bool hudModelStep, int OverrideShader, bool alphatexture) +{ + float fU1,fV1; + float fU2,fV2; + float tx; + float x1,y1,x2,y2; + float scale; + float scalex; + float ftexturemid; + // 4:3 16:9 16:10 17:10 5:4 + static float xratio[] = {1.f, 3.f/4, 5.f/6, 40.f/51, 1.f}; + + // [BB] In the HUD model step we just render the model and break out. + if ( hudModelStep ) + { + gl_RenderHUDModel( psp, sx, sy); + return; + } + + // decide which patch to use + bool mirror; + FTextureID lump = gl_GetSpriteFrame(psp->sprite, psp->frame, 0, 0, &mirror); + if (!lump.isValid()) return; + + FMaterial * tex = FMaterial::ValidateTexture(lump, true, false); + if (!tex) return; + + gl_RenderState.SetMaterial(tex, CLAMP_XY_NOMIP, 0, OverrideShader, alphatexture); + + float vw = (float)viewwidth; + float vh = (float)viewheight; + + FloatRect r; + tex->GetSpriteRect(&r); + + // calculate edges of the shape + scalex = xratio[WidescreenRatio] * vw / 320; + + tx = FIXED2FLOAT(sx) - (160 - r.left); + x1 = tx * scalex + vw/2; + if (x1 > vw) return; // off the right side + x1 += viewwindowx; + + tx += r.width; + x2 = tx * scalex + vw / 2; + if (x2 < 0) return; // off the left side + x2 += viewwindowx; + + + // killough 12/98: fix psprite positioning problem + ftexturemid = 100.f - FIXED2FLOAT(sy) - r.top; + + AWeapon * wi=player->ReadyWeapon; + if (wi && wi->YAdjust) + { + float fYAd = FIXED2FLOAT(wi->YAdjust); + if (screenblocks >= 11) + { + ftexturemid -= fYAd; + } + else if (!st_scale) + { + ftexturemid -= FIXED2FLOAT(StatusBar->GetDisplacement ()) * fYAd; + } + } + + scale = (SCREENHEIGHT*vw) / (SCREENWIDTH * 200.0f); + y1 = viewwindowy + vh / 2 - (ftexturemid * scale); + y2 = y1 + (r.height * scale) + 1; + + if (!mirror) + { + fU1=tex->GetSpriteUL(); + fV1=tex->GetSpriteVT(); + fU2=tex->GetSpriteUR(); + fV2=tex->GetSpriteVB(); + } + else + { + fU2=tex->GetSpriteUL(); + fV1=tex->GetSpriteVT(); + fU1=tex->GetSpriteUR(); + fV2=tex->GetSpriteVB(); + } + + if (tex->GetTransparent() || OverrideShader != -1) + { + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + } + gl_RenderState.Apply(); + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(x1, y1, 0, fU1, fV1); + ptr++; + ptr->Set(x1, y2, 0, fU1, fV2); + ptr++; + ptr->Set(x2, y1, 0, fU2, fV1); + ptr++; + ptr->Set(x2, y2, 0, fU2, fV2); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); +} + +//========================================================================== +// +// R_DrawPlayerSprites +// +//========================================================================== + +EXTERN_CVAR(Bool, gl_brightfog) + +void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) +{ + bool statebright[2] = {false, false}; + unsigned int i; + pspdef_t *psp; + int lightlevel=0; + fixed_t ofsx, ofsy; + FColormap cm; + sector_t * fakesec, fs; + AActor * playermo=players[consoleplayer].camera; + player_t * player=playermo->player; + + // this is the same as the software renderer + if (!player || + !r_drawplayersprites || + !camera->player || + (player->cheats & CF_CHASECAM) || + (r_deathcamera && camera->health <= 0)) + return; + + P_BobWeapon (player, &player->psprites[ps_weapon], &ofsx, &ofsy); + + // check for fullbright + if (player->fixedcolormap==NOFIXEDCOLORMAP) + { + for (i = 0, psp = player->psprites; i <= ps_flash; i++, psp++) + { + if (psp->state != NULL) + { + bool disablefullbright = false; + FTextureID lump = gl_GetSpriteFrame(psp->sprite, psp->frame, 0, 0, NULL); + if (lump.isValid()) + { + FMaterial * tex=FMaterial::ValidateTexture(lump, false, false); + if (tex) + disablefullbright = tex->tex->gl_info.bDisableFullbright; + } + statebright[i] = !!psp->state->GetFullbright() && !disablefullbright; + } + } + } + + if (gl_fixedcolormap) + { + lightlevel=255; + cm.Clear(); + statebright[0] = statebright[1] = true; + fakesec = viewsector; + } + else + { + fakesec = gl_FakeFlat(viewsector, &fs, false); + + // calculate light level for weapon sprites + lightlevel = gl_ClampLight(fakesec->lightlevel); + if (glset.lightmode == 8) + { + lightlevel = gl_CalcLightLevel(lightlevel, getExtraLight(), true); + + // Korshun: the way based on max possible light level for sector like in software renderer. + float min_L = 36.0/31.0 - ((lightlevel/255.0) * (63.0/31.0)); // Lightlevel in range 0-63 + if (min_L < 0) + min_L = 0; + else if (min_L > 1.0) + min_L = 1.0; + + lightlevel = (1.0 - min_L) * 255; + } + lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->x, playermo->y, playermo->z); + + // calculate colormap for weapon sprites + if (viewsector->e->XFloor.ffloors.Size() && !glset.nocoloredspritelighting) + { + TArray & lightlist = viewsector->e->XFloor.lightlist; + for(i=0;ifloorplane.ZatPoint(viewx,viewy); + } + + if (lightbottomviewz) + { + cm = lightlist[i].extra_colormap; + lightlevel = *lightlist[i].p_lightlevel; + break; + } + } + } + else + { + cm=fakesec->ColorMap; + if (glset.nocoloredspritelighting) cm.ClearColor(); + } + } + + + // Korshun: fullbright fog in opengl, render weapon sprites fullbright (but don't cancel out the light color!) + if (glset.brightfog && ((level.flags&LEVEL_HASFADETABLE) || cm.FadeColor != 0)) + { + lightlevel = 255; + } + + PalEntry ThingColor = (playermo->RenderStyle.Flags & STYLEF_ColorIsFixed) ? playermo->fillcolor : 0xffffff; + ThingColor.a = 255; + + visstyle_t vis; + + vis.RenderStyle=playermo->RenderStyle; + vis.alpha=playermo->alpha; + vis.colormap = NULL; + if (playermo->Inventory) + { + playermo->Inventory->AlterWeaponSprite(&vis); + if (vis.colormap >= SpecialColormaps[0].Colormap && + vis.colormap < SpecialColormaps[SpecialColormaps.Size()].Colormap && + gl_fixedcolormap == CM_DEFAULT) + { + // this only happens for Strife's inverted weapon sprite + vis.RenderStyle.Flags |= STYLEF_InvertSource; + } + } + + // Set the render parameters + + int OverrideShader = -1; + float trans = 0.f; + if (vis.RenderStyle.BlendOp >= STYLEOP_Fuzz && vis.RenderStyle.BlendOp <= STYLEOP_FuzzOrRevSub) + { + vis.RenderStyle.CheckFuzz(); + if (vis.RenderStyle.BlendOp == STYLEOP_Fuzz) + { + if (gl_fuzztype != 0) + { + // Todo: implement shader selection here + vis.RenderStyle = LegacyRenderStyles[STYLE_Translucent]; + OverrideShader = gl_fuzztype + 4; + trans = 0.99f; // trans may not be 1 here + } + else + { + vis.RenderStyle.BlendOp = STYLEOP_Shadow; + } + } + statebright[0] = statebright[1] = false; + } + + gl_SetRenderStyle(vis.RenderStyle, false, false); + + if (vis.RenderStyle.Flags & STYLEF_TransSoulsAlpha) + { + trans = transsouls; + } + else if (vis.RenderStyle.Flags & STYLEF_Alpha1) + { + trans = 1.f; + } + else if (trans == 0.f) + { + trans = FIXED2FLOAT(vis.alpha); + } + + // now draw the different layers of the weapon + gl_RenderState.EnableBrightmap(true); + gl_RenderState.SetObjectColor(ThingColor); + if (statebright[0] || statebright[1]) + { + // brighten the weapon to reduce the difference between + // normal sprite and fullbright flash. + if (glset.lightmode != 8) lightlevel = (2*lightlevel+255)/3; + } + + // hack alert! Rather than changing everything in the underlying lighting code let's just temporarily change + // light mode here to draw the weapon sprite. + int oldlightmode = glset.lightmode; + if (glset.lightmode == 8) glset.lightmode = 2; + + for (i=0, psp=player->psprites; i<=ps_flash; i++,psp++) + { + if (psp->state) + { + FColormap cmc = cm; + if (statebright[i]) + { + if (fakesec == viewsector || in_area != area_below) + { + cmc.LightColor.r= + cmc.LightColor.g= + cmc.LightColor.b=0xff; + } + else + { + // under water areas keep most of their color for fullbright objects + cmc.LightColor.r = (3 * cmc.LightColor.r + 0xff) / 4; + cmc.LightColor.g = (3*cmc.LightColor.g + 0xff)/4; + cmc.LightColor.b = (3*cmc.LightColor.b + 0xff)/4; + } + } + // set the lighting parameters + if (vis.RenderStyle.BlendOp == STYLEOP_Shadow) + { + gl_RenderState.SetColor(0.2f, 0.2f, 0.2f, 0.33f, cmc.desaturation); + } + else + { + if (gl_lights && GLRenderer->mLightCount && !gl_fixedcolormap && gl_light_sprites) + { + gl_SetDynSpriteLight(playermo, NULL); + } + gl_SetColor(statebright[i] ? 255 : lightlevel, 0, cmc, trans, true); + } + DrawPSprite(player, psp, psp->sx + ofsx, psp->sy + ofsy, hudModelStep, OverrideShader, !!(vis.RenderStyle.Flags & STYLEF_RedIsAlpha)); + } + } + gl_RenderState.SetObjectColor(0xffffffff); + gl_RenderState.SetDynLight(0, 0, 0); + gl_RenderState.EnableBrightmap(false); + glset.lightmode = oldlightmode; +} + +//========================================================================== +// +// R_DrawPlayerSprites +// +//========================================================================== + +void FGLRenderer::DrawTargeterSprites() +{ + int i; + pspdef_t *psp; + AActor * playermo=players[consoleplayer].camera; + player_t * player=playermo->player; + + if(!player || playermo->renderflags&RF_INVISIBLE || !r_drawplayersprites || + mViewActor!=playermo) return; + + gl_RenderState.EnableBrightmap(false); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.AlphaFunc(GL_GEQUAL,gl_mask_sprite_threshold); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.ResetColor(); + gl_RenderState.SetTextureMode(TM_MODULATE); + + // The Targeter's sprites are always drawn normally. + for (i=ps_targetcenter, psp = &player->psprites[ps_targetcenter]; istate) DrawPSprite (player,psp,psp->sx, psp->sy, false, 0, false); +} \ No newline at end of file diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp new file mode 100644 index 000000000..2955cf7c8 --- /dev/null +++ b/src/gl/shaders/gl_shader.cpp @@ -0,0 +1,630 @@ +/* +** gl_shader.cpp +** +** GLSL shader handling +** +**--------------------------------------------------------------------------- +** Copyright 2004-2009 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "c_cvars.h" +#include "v_video.h" +#include "name.h" +#include "w_wad.h" +#include "i_system.h" +#include "doomerrors.h" +#include "v_palette.h" +#include "sc_man.h" +#include "cmdlib.h" + +#include "gl/system/gl_interface.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_matrix.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/system/gl_cvars.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_material.h" +#include "gl/dynlights/gl_lightbuffer.h" + +//========================================================================== +// +// +// +//========================================================================== + +bool FShader::Load(const char * name, const char * vert_prog_lump, const char * frag_prog_lump, const char * proc_prog_lump, const char * defines) +{ + static char buffer[10000]; + FString error; + + int i_lump = Wads.CheckNumForFullName("shaders/glsl/shaderdefs.i"); + if (i_lump == -1) I_Error("Unable to load 'shaders/glsl/shaderdefs.i'"); + FMemLump i_data = Wads.ReadLump(i_lump); + + int vp_lump = Wads.CheckNumForFullName(vert_prog_lump); + if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump); + FMemLump vp_data = Wads.ReadLump(vp_lump); + + int fp_lump = Wads.CheckNumForFullName(frag_prog_lump); + if (fp_lump == -1) I_Error("Unable to load '%s'", frag_prog_lump); + FMemLump fp_data = Wads.ReadLump(fp_lump); + + + +// +// The following code uses GetChars on the strings to get rid of terminating 0 characters. Do not remove or the code may break! +// + unsigned int lightbuffertype = GLRenderer->mLights->GetBufferType(); + unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize(); + + FString vp_comb; + + if (lightbuffertype == GL_UNIFORM_BUFFER) + { + if (gl.glslversion < 1.4f || gl.version < 3.1f) + { + vp_comb.Format("#version 130\n#extension GL_ARB_uniform_buffer_object : require\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + } + else + { + vp_comb.Format("#version 140\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); + } + } + else + { + vp_comb = "#version 400 core\n#extension GL_ARB_shader_storage_buffer_object : require\n#define SHADER_STORAGE_LIGHTS\n"; + } + + vp_comb << defines << i_data.GetString().GetChars(); + FString fp_comb = vp_comb; + + vp_comb << vp_data.GetString().GetChars() << "\n"; + fp_comb << fp_data.GetString().GetChars() << "\n"; + + if (proc_prog_lump != NULL) + { + if (*proc_prog_lump != '#') + { + int pp_lump = Wads.CheckNumForFullName(proc_prog_lump); + if (pp_lump == -1) I_Error("Unable to load '%s'", proc_prog_lump); + FMemLump pp_data = Wads.ReadLump(pp_lump); + + if (pp_data.GetString().IndexOf("ProcessTexel") < 0) + { + // this looks like an old custom hardware shader. + // We need to replace the ProcessTexel call to make it work. + + fp_comb.Substitute("vec4 frag = ProcessTexel();", "vec4 frag = Process(vec4(1.0));"); + } + fp_comb << pp_data.GetString().GetChars(); + fp_comb.Substitute("gl_TexCoord[0]", "vTexCoord"); // fix old custom shaders. + + if (pp_data.GetString().IndexOf("ProcessLight") < 0) + { + int pl_lump = Wads.CheckNumForFullName("shaders/glsl/func_defaultlight.fp"); + if (pl_lump == -1) I_Error("Unable to load '%s'", "shaders/glsl/func_defaultlight.fp"); + FMemLump pl_data = Wads.ReadLump(pl_lump); + fp_comb << "\n" << pl_data.GetString().GetChars(); + } + } + else + { + // Proc_prog_lump is not a lump name but the source itself (from generated shaders) + fp_comb << proc_prog_lump + 1; + } + } + + hVertProg = glCreateShader(GL_VERTEX_SHADER); + hFragProg = glCreateShader(GL_FRAGMENT_SHADER); + + + int vp_size = (int)vp_comb.Len(); + int fp_size = (int)fp_comb.Len(); + + const char *vp_ptr = vp_comb.GetChars(); + const char *fp_ptr = fp_comb.GetChars(); + + glShaderSource(hVertProg, 1, &vp_ptr, &vp_size); + glShaderSource(hFragProg, 1, &fp_ptr, &fp_size); + + glCompileShader(hVertProg); + glCompileShader(hFragProg); + + hShader = glCreateProgram(); + + glAttachShader(hShader, hVertProg); + glAttachShader(hShader, hFragProg); + + glBindAttribLocation(hShader, VATTR_VERTEX, "aPosition"); + glBindAttribLocation(hShader, VATTR_TEXCOORD, "aTexCoord"); + glBindAttribLocation(hShader, VATTR_COLOR, "aColor"); + glBindAttribLocation(hShader, VATTR_VERTEX2, "aVertex2"); + + glLinkProgram(hShader); + + glGetShaderInfoLog(hVertProg, 10000, NULL, buffer); + if (*buffer) + { + error << "Vertex shader:\n" << buffer << "\n"; + } + glGetShaderInfoLog(hFragProg, 10000, NULL, buffer); + if (*buffer) + { + error << "Fragment shader:\n" << buffer << "\n"; + } + + glGetProgramInfoLog(hShader, 10000, NULL, buffer); + if (*buffer) + { + error << "Linking:\n" << buffer << "\n"; + } + int linked; + glGetProgramiv(hShader, GL_LINK_STATUS, &linked); + if (linked == 0) + { + // only print message if there's an error. + I_Error("Init Shader '%s':\n%s\n", name, error.GetChars()); + } + + + muDesaturation.Init(hShader, "uDesaturationFactor"); + muFogEnabled.Init(hShader, "uFogEnabled"); + muTextureMode.Init(hShader, "uTextureMode"); + muCameraPos.Init(hShader, "uCameraPos"); + muLightParms.Init(hShader, "uLightAttr"); + muClipSplit.Init(hShader, "uClipSplit"); + muColormapStart.Init(hShader, "uFixedColormapStart"); + muColormapRange.Init(hShader, "uFixedColormapRange"); + muLightIndex.Init(hShader, "uLightIndex"); + muFogColor.Init(hShader, "uFogColor"); + muDynLightColor.Init(hShader, "uDynLightColor"); + muObjectColor.Init(hShader, "uObjectColor"); + muGlowBottomColor.Init(hShader, "uGlowBottomColor"); + muGlowTopColor.Init(hShader, "uGlowTopColor"); + muGlowBottomPlane.Init(hShader, "uGlowBottomPlane"); + muGlowTopPlane.Init(hShader, "uGlowTopPlane"); + muFixedColormap.Init(hShader, "uFixedColormap"); + muInterpolationFactor.Init(hShader, "uInterpolationFactor"); + muClipHeightTop.Init(hShader, "uClipHeightTop"); + muClipHeightBottom.Init(hShader, "uClipHeightBottom"); + muAlphaThreshold.Init(hShader, "uAlphaThreshold"); + muTimer.Init(hShader, "timer"); + + lights_index = glGetUniformLocation(hShader, "lights"); + fakevb_index = glGetUniformLocation(hShader, "fakeVB"); + projectionmatrix_index = glGetUniformLocation(hShader, "ProjectionMatrix"); + viewmatrix_index = glGetUniformLocation(hShader, "ViewMatrix"); + modelmatrix_index = glGetUniformLocation(hShader, "ModelMatrix"); + texturematrix_index = glGetUniformLocation(hShader, "TextureMatrix"); + + int tempindex = glGetUniformBlockIndex(hShader, "LightBufferUBO"); + if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, LIGHTBUF_BINDINGPOINT); + + glUseProgram(hShader); + + // set up other texture units (if needed by the shader) + for (int i = 2; i<16; i++) + { + char stringbuf[20]; + mysnprintf(stringbuf, 20, "texture%d", i); + tempindex = glGetUniformLocation(hShader, stringbuf); + if (tempindex > 0) glUniform1i(tempindex, i - 1); + } + + glUseProgram(0); + return !!linked; +} + +//========================================================================== +// +// +// +//========================================================================== + +FShader::~FShader() +{ + glDeleteProgram(hShader); + glDeleteShader(hVertProg); + glDeleteShader(hFragProg); +} + + +//========================================================================== +// +// +// +//========================================================================== + +bool FShader::Bind() +{ + GLRenderer->mShaderManager->SetActiveShader(this); + return true; +} + +//========================================================================== +// +// Since all shaders are REQUIRED, any error here needs to be fatal +// +//========================================================================== + +FShader *FShaderManager::Compile (const char *ShaderName, const char *ShaderPath, bool usediscard) +{ + FString defines; + // this can't be in the shader code due to ATI strangeness. + if (gl.MaxLights() == 128) defines += "#define MAXLIGHTS128\n"; + if (!usediscard) defines += "#define NO_ALPHATEST\n"; + + FShader *shader = NULL; + try + { + shader = new FShader(ShaderName); + if (!shader->Load(ShaderName, "shaders/glsl/main.vp", "shaders/glsl/main.fp", ShaderPath, defines.GetChars())) + { + I_FatalError("Unable to load shader %s\n", ShaderName); + } + } + catch(CRecoverableError &err) + { + if (shader != NULL) delete shader; + shader = NULL; + I_FatalError("Unable to load shader %s:\n%s\n", ShaderName, err.GetMessage()); + } + return shader; +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShader::ApplyMatrices(VSMatrix *proj, VSMatrix *view) +{ + Bind(); + glUniformMatrix4fv(projectionmatrix_index, 1, false, proj->get()); + glUniformMatrix4fv(viewmatrix_index, 1, false, view->get()); +} + + +//========================================================================== +// +// +// +//========================================================================== +struct FDefaultShader +{ + const char * ShaderName; + const char * gettexelfunc; +}; + +// Note: the FIRST_USER_SHADER constant in gl_shader.h needs +// to be updated whenever the size of this array is modified. +static const FDefaultShader defaultshaders[]= +{ + {"Default", "shaders/glsl/func_normal.fp"}, + {"Warp 1", "shaders/glsl/func_warp1.fp"}, + {"Warp 2", "shaders/glsl/func_warp2.fp"}, + {"Brightmap","shaders/glsl/func_brightmap.fp"}, + {"No Texture", "shaders/glsl/func_notexture.fp"}, + {"Basic Fuzz", "shaders/glsl/fuzz_standard.fp"}, + {"Smooth Fuzz", "shaders/glsl/fuzz_smooth.fp"}, + {"Swirly Fuzz", "shaders/glsl/fuzz_swirly.fp"}, + {"Translucent Fuzz", "shaders/glsl/fuzz_smoothtranslucent.fp"}, + {"Jagged Fuzz", "shaders/glsl/fuzz_jagged.fp"}, + {"Noise Fuzz", "shaders/glsl/fuzz_noise.fp"}, + {"Smooth Noise Fuzz", "shaders/glsl/fuzz_smoothnoise.fp"}, + {NULL,NULL} +}; + +static TArray usershaders; + +struct FEffectShader +{ + const char *ShaderName; + const char *vp; + const char *fp1; + const char *fp2; + const char *defines; +}; + +static const FEffectShader effectshaders[]= +{ + { "fogboundary", "shaders/glsl/main.vp", "shaders/glsl/fogboundary.fp", NULL, "#define NO_ALPHATEST\n" }, + { "spheremap", "shaders/glsl/main.vp", "shaders/glsl/main.fp", "shaders/glsl/func_normal.fp", "#define SPHEREMAP\n#define NO_ALPHATEST\n" }, + { "burn", "shaders/glsl/main.vp", "shaders/glsl/burn.fp", NULL, "#define SIMPLE\n#define NO_ALPHATEST\n" }, + { "stencil", "shaders/glsl/main.vp", "shaders/glsl/stencil.fp", NULL, "#define SIMPLE\n#define NO_ALPHATEST\n" }, +}; + + +//========================================================================== +// +// +// +//========================================================================== + +FShaderManager::FShaderManager() +{ + CompileShaders(); +} + +//========================================================================== +// +// +// +//========================================================================== + +FShaderManager::~FShaderManager() +{ + Clean(); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShaderManager::CompileShaders() +{ + mActiveShader = NULL; + + mTextureEffects.Clear(); + mTextureEffectsNAT.Clear(); + for (int i = 0; i < MAX_EFFECTS; i++) + { + mEffectShaders[i] = NULL; + } + + for(int i=0;defaultshaders[i].ShaderName != NULL;i++) + { + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, true); + mTextureEffects.Push(shc); + if (i <= 3) + { + FShader *shc = Compile(defaultshaders[i].ShaderName, defaultshaders[i].gettexelfunc, false); + mTextureEffectsNAT.Push(shc); + } + } + + for(unsigned i = 0; i < usershaders.Size(); i++) + { + FString name = ExtractFileBase(usershaders[i]); + FName sfn = name; + + FShader *shc = Compile(sfn, usershaders[i], true); + mTextureEffects.Push(shc); + } + + for(int i=0;iLoad(effectshaders[i].ShaderName, effectshaders[i].vp, effectshaders[i].fp1, + effectshaders[i].fp2, effectshaders[i].defines)) + { + delete eff; + } + else mEffectShaders[i] = eff; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShaderManager::Clean() +{ + glUseProgram(0); + mActiveShader = NULL; + + for (unsigned int i = 0; i < mTextureEffectsNAT.Size(); i++) + { + if (mTextureEffectsNAT[i] != NULL) delete mTextureEffectsNAT[i]; + } + for (unsigned int i = 0; i < mTextureEffects.Size(); i++) + { + if (mTextureEffects[i] != NULL) delete mTextureEffects[i]; + } + for (int i = 0; i < MAX_EFFECTS; i++) + { + if (mEffectShaders[i] != NULL) delete mEffectShaders[i]; + mEffectShaders[i] = NULL; + } + mTextureEffects.Clear(); + mTextureEffectsNAT.Clear(); +} + +//========================================================================== +// +// +// +//========================================================================== + +int FShaderManager::Find(const char * shn) +{ + FName sfn = shn; + + for(unsigned int i=0;imName == sfn) + { + return i; + } + } + return -1; +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShaderManager::SetActiveShader(FShader *sh) +{ + if (mActiveShader != sh) + { + glUseProgram(sh!= NULL? sh->GetHandle() : 0); + mActiveShader = sh; + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +FShader *FShaderManager::BindEffect(int effect) +{ + if (effect >= 0 && effect < MAX_EFFECTS && mEffectShaders[effect] != NULL) + { + mEffectShaders[effect]->Bind(); + return mEffectShaders[effect]; + } + return NULL; +} + + +//========================================================================== +// +// +// +//========================================================================== +EXTERN_CVAR(Int, gl_fuzztype) + +void FShaderManager::ApplyMatrices(VSMatrix *proj, VSMatrix *view) +{ + for (int i = 0; i < 4; i++) + { + mTextureEffects[i]->ApplyMatrices(proj, view); + mTextureEffectsNAT[i]->ApplyMatrices(proj, view); + } + mTextureEffects[4]->ApplyMatrices(proj, view); + if (gl_fuzztype != 0) + { + mTextureEffects[4+gl_fuzztype]->ApplyMatrices(proj, view); + } + for (unsigned i = 12; i < mTextureEffects.Size(); i++) + { + mTextureEffects[i]->ApplyMatrices(proj, view); + } + for (int i = 0; i < MAX_EFFECTS; i++) + { + mEffectShaders[i]->ApplyMatrices(proj, view); + } + if (mActiveShader != NULL) mActiveShader->Bind(); +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_DestroyUserShaders() +{ + // todo +} + +//========================================================================== +// +// Parses a shader definition +// +//========================================================================== + +void gl_ParseHardwareShader(FScanner &sc, int deflump) +{ + int type = FTexture::TEX_Any; + bool disable_fullbright=false; + bool thiswad = false; + bool iwad = false; + int maplump = -1; + FString maplumpname; + float speed = 1.f; + + sc.MustGetString(); + if (sc.Compare("texture")) type = FTexture::TEX_Wall; + else if (sc.Compare("flat")) type = FTexture::TEX_Flat; + else if (sc.Compare("sprite")) type = FTexture::TEX_Sprite; + else sc.UnGet(); + + sc.MustGetString(); + FTextureID no = TexMan.CheckForTexture(sc.String, type); + FTexture *tex = TexMan[no]; + + sc.MustGetToken('{'); + while (!sc.CheckToken('}')) + { + sc.MustGetString(); + if (sc.Compare("shader")) + { + sc.MustGetString(); + maplumpname = sc.String; + } + else if (sc.Compare("speed")) + { + sc.MustGetFloat(); + speed = float(sc.Float); + } + } + if (!tex) + { + return; + } + + if (maplumpname.IsNotEmpty()) + { + if (tex->bWarped != 0) + { + Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars()); + return; + } + tex->gl_info.shaderspeed = speed; + for(unsigned i=0;igl_info.shaderindex = i + FIRST_USER_SHADER; + return; + } + } + tex->gl_info.shaderindex = usershaders.Push(maplumpname) + FIRST_USER_SHADER; + } +} + diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h new file mode 100644 index 000000000..c5baceceb --- /dev/null +++ b/src/gl/shaders/gl_shader.h @@ -0,0 +1,330 @@ + +#ifndef __GL_SHADERS_H__ +#define __GL_SHADERS_H__ + +#include "gl/renderer/gl_renderstate.h" +#include "name.h" + +extern bool gl_shaderactive; + +enum +{ + VATTR_VERTEX = 0, + VATTR_TEXCOORD = 1, + VATTR_COLOR = 2, + VATTR_VERTEX2 = 3 +}; + + +//========================================================================== +// +// +//========================================================================== + +class FUniform1i +{ + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + } + + void Set(int newvalue) + { + glUniform1i(mIndex, newvalue); + } +}; + +class FBufferedUniform1i +{ + int mBuffer; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + mBuffer = 0; + } + + void Set(int newvalue) + { + if (newvalue != mBuffer) + { + mBuffer = newvalue; + glUniform1i(mIndex, newvalue); + } + } +}; + +class FBufferedUniform4i +{ + int mBuffer[4]; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + memset(mBuffer, 0, sizeof(mBuffer)); + } + + void Set(const int *newvalue) + { + if (memcmp(newvalue, mBuffer, sizeof(mBuffer))) + { + memcpy(mBuffer, newvalue, sizeof(mBuffer)); + glUniform4iv(mIndex, 1, newvalue); + } + } +}; + +class FBufferedUniform1f +{ + float mBuffer; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + mBuffer = 0; + } + + void Set(float newvalue) + { + if (newvalue != mBuffer) + { + mBuffer = newvalue; + glUniform1f(mIndex, newvalue); + } + } +}; + +class FBufferedUniform2f +{ + float mBuffer[2]; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + memset(mBuffer, 0, sizeof(mBuffer)); + } + + void Set(const float *newvalue) + { + if (memcmp(newvalue, mBuffer, sizeof(mBuffer))) + { + memcpy(mBuffer, newvalue, sizeof(mBuffer)); + glUniform2fv(mIndex, 1, newvalue); + } + } +}; + +class FBufferedUniform4f +{ + float mBuffer[4]; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + memset(mBuffer, 0, sizeof(mBuffer)); + } + + void Set(const float *newvalue) + { + if (memcmp(newvalue, mBuffer, sizeof(mBuffer))) + { + memcpy(mBuffer, newvalue, sizeof(mBuffer)); + glUniform4fv(mIndex, 1, newvalue); + } + } +}; + +class FUniform4f +{ + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + } + + void Set(const float *newvalue) + { + glUniform4fv(mIndex, 1, newvalue); + } + + void Set(float a, float b, float c, float d) + { + glUniform4f(mIndex, a, b, c, d); + } +}; + +class FBufferedUniformPE +{ + PalEntry mBuffer; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + mBuffer = 0; + } + + void Set(PalEntry newvalue) + { + if (newvalue != mBuffer) + { + mBuffer = newvalue; + glUniform4f(mIndex, newvalue.r/255.f, newvalue.g/255.f, newvalue.b/255.f, newvalue.a/255.f); + } + } +}; + + +class FShader +{ + friend class FShaderManager; + friend class FRenderState; + + unsigned int hShader; + unsigned int hVertProg; + unsigned int hFragProg; + FName mName; + + FBufferedUniform1f muDesaturation; + FBufferedUniform1i muFogEnabled; + FBufferedUniform1i muTextureMode; + FBufferedUniform4f muCameraPos; + FBufferedUniform4f muLightParms; + FBufferedUniform2f muClipSplit; + FUniform1i muFixedColormap; + FUniform4f muColormapStart; + FUniform4f muColormapRange; + FBufferedUniform1i muLightIndex; + FBufferedUniformPE muFogColor; + FBufferedUniform4f muDynLightColor; + FBufferedUniformPE muObjectColor; + FUniform4f muGlowBottomColor; + FUniform4f muGlowTopColor; + FUniform4f muGlowBottomPlane; + FUniform4f muGlowTopPlane; + FBufferedUniform1f muInterpolationFactor; + FBufferedUniform1f muClipHeightTop; + FBufferedUniform1f muClipHeightBottom; + FBufferedUniform1f muAlphaThreshold; + FBufferedUniform1f muTimer; + + int lights_index; + int projectionmatrix_index; + int viewmatrix_index; + int modelmatrix_index; + int texturematrix_index; +public: + int fakevb_index; +private: + int currentglowstate; + int currentfixedcolormap; + bool currentTextureMatrixState; + bool currentModelMatrixState; + +public: + FShader(const char *name) + : mName(name) + { + hShader = hVertProg = hFragProg = 0; + currentglowstate = 0; + currentfixedcolormap = 0; + currentTextureMatrixState = true; // by setting the matrix state to 'true' it is guaranteed to be set the first time the render state gets applied. + currentModelMatrixState = true; + } + + ~FShader(); + + bool Load(const char * name, const char * vert_prog_lump, const char * fragprog, const char * fragprog2, const char *defines); + + void SetColormapColor(float r, float g, float b, float r1, float g1, float b1); + void SetGlowParams(float *topcolors, float topheight, float *bottomcolors, float bottomheight); + void SetLightRange(int start, int end, int forceadd); + + bool Bind(); + unsigned int GetHandle() const { return hShader; } + + void ApplyMatrices(VSMatrix *proj, VSMatrix *view); + +}; + + +//========================================================================== +// +// The global shader manager +// +//========================================================================== +class FShaderManager +{ + TArray mTextureEffects; + TArray mTextureEffectsNAT; + FShader *mActiveShader; + FShader *mEffectShaders[MAX_EFFECTS]; + + void Clean(); + void CompileShaders(); + +public: + FShaderManager(); + ~FShaderManager(); + FShader *Compile(const char *ShaderName, const char *ShaderPath, bool usediscard); + int Find(const char *mame); + FShader *BindEffect(int effect); + void SetActiveShader(FShader *sh); + void ApplyMatrices(VSMatrix *proj, VSMatrix *view); + FShader *GetActiveShader() const + { + return mActiveShader; + } + + void ResetFixedColormap() + { + for (unsigned i = 0; i < mTextureEffects.Size(); i++) + { + mTextureEffects[i]->currentfixedcolormap = -1; + } + for (unsigned i = 0; i < mTextureEffectsNAT.Size(); i++) + { + mTextureEffectsNAT[i]->currentfixedcolormap = -1; + } + } + + FShader *Get(unsigned int eff, bool alphateston) + { + // indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom + if (!alphateston && eff <= 3) + { + return mTextureEffectsNAT[eff]; // Non-alphatest shaders are only created for default, warp1+2 and brightmap. The rest won't get used anyway + } + if (eff < mTextureEffects.Size()) + { + return mTextureEffects[eff]; + } + return NULL; + } +}; + +#define FIRST_USER_SHADER 12 + +enum +{ + LIGHTBUF_BINDINGPOINT = 1 +}; + +#endif + diff --git a/src/gl/shaders/gl_texshader.cpp b/src/gl/shaders/gl_texshader.cpp new file mode 100644 index 000000000..f91529909 --- /dev/null +++ b/src/gl/shaders/gl_texshader.cpp @@ -0,0 +1,698 @@ +/* +** gl_shaders.cpp +** Routines parsing/managing texture shaders. +** +**--------------------------------------------------------------------------- +** Copyright 2003 Timothy Stump +** Copyright 2009 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 "gl/system/gl_system.h" +#include "doomtype.h" +#include "c_cvars.h" +#include "sc_man.h" +#include "textures/textures.h" +#include "gl/shaders/gl_texshader.h" + +CVAR(Bool, gl_texture_useshaders, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + + +//========================================================================== +// +// +// +//========================================================================== + +FShaderLayer::FShaderLayer() +{ + animate = false; + emissive = false; + blendFuncSrc = GL_SRC_ALPHA; + blendFuncDst = GL_ONE_MINUS_SRC_ALPHA; + offsetX = 0.f; + offsetY = 0.f; + centerX = 0.0f; + centerY = 0.0f; + rotate = 0.f; + rotation = 0.f; + adjustX.SetParams(0.f, 0.f, 0.f); + adjustY.SetParams(0.f, 0.f, 0.f); + scaleX.SetParams(1.f, 1.f, 0.f); + scaleY.SetParams(1.f, 1.f, 0.f); + alpha.SetParams(1.f, 1.f, 0.f); + r.SetParams(1.f, 1.f, 0.f); + g.SetParams(1.f, 1.f, 0.f); + b.SetParams(1.f, 1.f, 0.f); + flags = 0; + layerMask = NULL; + texgen = SHADER_TexGen_None; + warp = false; + warpspeed = 0; +} + +//========================================================================== +// +// +// +//========================================================================== + +FShaderLayer::FShaderLayer(const FShaderLayer &layer) +{ + texture = layer.texture; + animate = layer.animate; + emissive = layer.emissive; + adjustX = layer.adjustX; + adjustY = layer.adjustY; + blendFuncSrc = layer.blendFuncSrc; + blendFuncDst = layer.blendFuncDst; + offsetX = layer.offsetX; + offsetY = layer.offsetY; + centerX = layer.centerX; + centerY = layer.centerX; + rotate = layer.rotate; + rotation = layer.rotation; + scaleX = layer.scaleX; + scaleY = layer.scaleY; + vectorX = layer.vectorX; + vectorY = layer.vectorY; + alpha = layer.alpha; + r = layer.r; + g = layer.g; + b = layer.b; + flags = layer.flags; + if (layer.layerMask) + { + layerMask = new FShaderLayer(*(layer.layerMask)); + } + else + { + layerMask = NULL; + } + texgen = layer.texgen; + warp = layer.warp; + warpspeed = layer.warpspeed; +} + +//========================================================================== +// +// +// +//========================================================================== + +FShaderLayer::~FShaderLayer() +{ + if (layerMask) + { + delete layerMask; + layerMask = NULL; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void FShaderLayer::Update(float diff) +{ + r.Update(diff); + g.Update(diff); + b.Update(diff); + alpha.Update(diff); + vectorY.Update(diff); + vectorX.Update(diff); + scaleX.Update(diff); + scaleY.Update(diff); + adjustX.Update(diff); + adjustY.Update(diff); + srcFactor.Update(diff); + dstFactor.Update(diff); + + offsetX += vectorX * diff; + if (offsetX >= 1.f) offsetX -= 1.f; + if (offsetX < 0.f) offsetX += 1.f; + + offsetY += vectorY * diff; + if (offsetY >= 1.f) offsetY -= 1.f; + if (offsetY < 0.f) offsetY += 1.f; + + rotation += rotate * diff; + if (rotation > 360.f) rotation -= 360.f; + if (rotation < 0.f) rotation += 360.f; + + if (layerMask != NULL) layerMask->Update(diff); +} + +//========================================================================== +// +// +// +//========================================================================== + +struct FParseKey +{ + const char *name; + int value; +}; + +static const FParseKey CycleTags[]= +{ + {"linear", CYCLE_Linear}, + {"sin", CYCLE_Sin}, + {"cos", CYCLE_Cos}, + {"sawtooth", CYCLE_SawTooth}, + {"square", CYCLE_Square}, + {NULL} +}; + +static const FParseKey BlendTags[]= +{ + {"GL_ZERO", GL_ZERO}, + {"GL_ONE", GL_ONE}, + + {"GL_DST_COLOR", GL_DST_COLOR}, + {"GL_ONE_MINUS_DST_COLOR", GL_ONE_MINUS_DST_COLOR}, + {"GL_DST_ALPHA", GL_DST_ALPHA}, + {"GL_ONE_MINUS_DST_ALPHA", GL_ONE_MINUS_DST_ALPHA}, + + {"GL_SRC_COLOR", GL_SRC_COLOR}, + {"GL_ONE_MINUS_SRC_COLOR", GL_ONE_MINUS_SRC_COLOR}, + {"GL_SRC_ALPHA", GL_SRC_ALPHA}, + {"GL_ONE_MINUS_SRC_ALPHA", GL_ONE_MINUS_SRC_ALPHA}, + + {"GL_SRC_ALPHA_SATURATE", GL_SRC_ALPHA_SATURATE}, + {NULL} +}; + + +//========================================================================== +// +// +// +//========================================================================== + +CycleType FShaderLayer::ParseCycleType(FScanner &sc) +{ + if (sc.GetString()) + { + int t = sc.MatchString(&CycleTags[0].name, sizeof(CycleTags[0])); + if (t > -1) return CycleType(CycleTags[t].value); + sc.UnGet(); + } + return CYCLE_Linear; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool FShaderLayer::ParseLayer(FScanner &sc) +{ + bool retval = true; + float start, end, cycle, r1, r2, g1, g2, b1, b2; + int type; + + if (sc.GetString()) + { + texture = TexMan.CheckForTexture(sc.String, FTexture::TEX_Wall); + if (!texture.isValid()) + { + sc.ScriptMessage("Unknown texture '%s'", sc.String); + retval = false; + } + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + if (sc.End) + { + sc.ScriptError("Unexpected end of file encountered"); + return false; + } + + if (sc.Compare("alpha")) + { + if (sc.CheckString("cycle")) + { + alpha.ShouldCycle(true); + alpha.SetCycleType(ParseCycleType(sc)); + + sc.GetFloat(); + start = sc.Float; + sc.GetFloat(); + end = sc.Float; + sc.GetFloat(); + cycle = sc.Float; + + alpha.SetParams(start, end, cycle); + } + else + { + sc.MustGetFloat(); + alpha.SetParams(float(sc.Float), float(sc.Float), 0.f); + } + } + else if (sc.Compare("srcfactor")) + { + if (sc.CheckString("cycle")) + { + srcFactor.ShouldCycle(true); + srcFactor.SetCycleType(ParseCycleType(sc)); + + sc.GetFloat(); + start = sc.Float; + sc.GetFloat(); + end = sc.Float; + sc.GetFloat(); + cycle = sc.Float; + + srcFactor.SetParams(start, end, cycle); + } + else + { + sc.MustGetFloat(); + srcFactor.SetParams(float(sc.Float), float(sc.Float), 0.f); + } + } + if (sc.Compare("destfactor")) + { + if (sc.CheckString("cycle")) + { + dstFactor.ShouldCycle(true); + dstFactor.SetCycleType(ParseCycleType(sc)); + + sc.GetFloat(); + start = sc.Float; + sc.GetFloat(); + end = sc.Float; + sc.GetFloat(); + cycle = sc.Float; + + dstFactor.SetParams(start, end, cycle); + } + else + { + sc.MustGetFloat(); + dstFactor.SetParams(float(sc.Float), float(sc.Float), 0.f); + } + } + else if (sc.Compare("animate")) + { + sc.GetString(); + animate = sc.Compare("true"); + } + else if (sc.Compare("blendfunc")) + { + sc.GetString(); + type = sc.MustMatchString(&BlendTags[0].name, sizeof(BlendTags[0])); + blendFuncSrc = type;// BlendTags[type].value; + + sc.GetString(); + type = sc.MustMatchString(&BlendTags[0].name, sizeof(BlendTags[0])); + blendFuncDst = type; //BlendTags[type].value; + } + else if (sc.Compare("color")) + { + if (sc.CheckString("cycle")) + { + CycleType type = ParseCycleType(sc); + r.ShouldCycle(true); + g.ShouldCycle(true); + b.ShouldCycle(true); + r.SetCycleType(type); + g.SetCycleType(type); + b.SetCycleType(type); + + sc.GetFloat(); + r1 = float(sc.Float); + sc.GetFloat(); + g1 = float(sc.Float); + sc.GetFloat(); + b1 = float(sc.Float); + + // get color2 + sc.GetFloat(); + r2 = float(sc.Float); + sc.GetFloat(); + g2 = float(sc.Float); + sc.GetFloat(); + b2 = float(sc.Float); + + // get cycle time + sc.GetFloat(); + cycle = sc.Float; + + r.SetParams(r1, r2, cycle); + g.SetParams(g1, g2, cycle); + b.SetParams(b1, b2, cycle); + } + else + { + sc.GetFloat(); + r1 = float(sc.Float); + sc.GetFloat(); + g1 = sc.Float; + sc.GetFloat(); + b1 = sc.Float; + + r.SetParams(r1, r1, 0.f); + g.SetParams(g1, g1, 0.f); + b.SetParams(b1, b1, 0.f); + } + } + else if (sc.Compare("center")) + { + sc.GetFloat(); + centerX = sc.Float; + sc.GetFloat(); + centerY = sc.Float; + } + else if (sc.Compare("emissive")) + { + sc.GetString(); + emissive = sc.Compare("true"); + } + else if (sc.Compare("offset")) + { + if (sc.CheckString("cycle")) + { + adjustX.ShouldCycle(true); + adjustY.ShouldCycle(true); + + sc.GetFloat(); + r1 = sc.Float; + sc.GetFloat(); + r2 = sc.Float; + + sc.GetFloat(); + g1 = sc.Float; + sc.GetFloat(); + g2 = sc.Float; + + sc.GetFloat(); + cycle = sc.Float; + + offsetX = r1; + offsetY = r2; + + adjustX.SetParams(0.f, g1 - r1, cycle); + adjustY.SetParams(0.f, g2 - r2, cycle); + } + else + { + sc.GetFloat(); + offsetX = sc.Float; + sc.GetFloat(); + offsetY = sc.Float; + } + } + else if (sc.Compare("offsetfunc")) + { + adjustX.SetCycleType(ParseCycleType(sc)); + adjustY.SetCycleType(ParseCycleType(sc)); + } + else if (sc.Compare("mask")) + { + if (layerMask != NULL) delete layerMask; + layerMask = new FShaderLayer; + layerMask->ParseLayer(sc); + } + else if (sc.Compare("rotate")) + { + sc.GetFloat(); + rotate = sc.Float; + } + else if (sc.Compare("rotation")) + { + sc.GetFloat(); + rotation = sc.Float; + } + else if (sc.Compare("scale")) + { + if (sc.CheckString("cycle")) + { + scaleX.ShouldCycle(true); + scaleY.ShouldCycle(true); + + sc.GetFloat(); + r1 = sc.Float; + sc.GetFloat(); + r2 = sc.Float; + + sc.GetFloat(); + g1 = sc.Float; + sc.GetFloat(); + g2 = sc.Float; + + sc.GetFloat(); + cycle = sc.Float; + + scaleX.SetParams(r1, g1, cycle); + scaleY.SetParams(r2, g2, cycle); + } + else + { + sc.GetFloat(); + scaleX.SetParams(sc.Float, sc.Float, 0.f); + sc.GetFloat(); + scaleY.SetParams(sc.Float, sc.Float, 0.f); + } + } + else if (sc.Compare("scalefunc")) + { + scaleX.SetCycleType(ParseCycleType(sc)); + scaleY.SetCycleType(ParseCycleType(sc)); + } + else if (sc.Compare("texgen")) + { + sc.MustGetString(); + if (sc.Compare("sphere")) + { + texgen = SHADER_TexGen_Sphere; + } + else + { + texgen = SHADER_TexGen_None; + } + } + else if (sc.Compare("vector")) + { + if (sc.CheckString("cycle")) + { + vectorX.ShouldCycle(true); + vectorY.ShouldCycle(true); + + sc.GetFloat(); + r1 = sc.Float; + sc.GetFloat(); + g1 = sc.Float; + sc.GetFloat(); + r2 = sc.Float; + sc.GetFloat(); + g2 = sc.Float; + sc.GetFloat(); + cycle = sc.Float; + + vectorX.SetParams(r1, r2, cycle); + vectorY.SetParams(g1, g2, cycle); + } + else + { + sc.GetFloat(); + vectorX.SetParams(sc.Float, sc.Float, 0.f); + sc.GetFloat(); + vectorY.SetParams(sc.Float, sc.Float, 0.f); + } + } + else if (sc.Compare("vectorfunc")) + { + vectorX.SetCycleType(ParseCycleType(sc)); + vectorY.SetCycleType(ParseCycleType(sc)); + } + else if (sc.Compare("warp")) + { + if (sc.CheckNumber()) + { + warp = sc.Number >= 0 && sc.Number <= 2? sc.Number : 0; + } + else + { + // compatibility with ZDoomGL + sc.MustGetString(); + warp = sc.Compare("true"); + } + } + else + { + sc.ScriptError("Unknown keyword '%s' in shader layer", sc.String); + } + } + } + return retval; +} + +//========================================================================== +// +// +// +//========================================================================== + +FTextureShader::FTextureShader() +{ + layers.Clear(); + lastUpdate = 0; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool FTextureShader::ParseShader(FScanner &sc, TArray &names) +{ + bool retval = true; + + if (sc.GetString()) + { + name = sc.String; + + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + if (sc.End) + { + sc.ScriptError("Unexpected end of file encountered"); + return false; + } + else if (sc.Compare("layer")) + { + FShaderLayer *lay = new FShaderLayer; + if (lay->ParseLayer(sc)) + { + if (layers.Size() < 8) + { + layers.Push(lay); + } + else + { + delete lay; + sc.ScriptMessage("Only 8 layers per texture allowed."); + } + } + else + { + delete lay; + retval = false; + } + } + else + { + sc.ScriptError("Unknown keyword '%s' in shader", sc.String); + } + } + } + return retval; +} + +//========================================================================== +// +// +// +//========================================================================== + +void FTextureShader::Update(int framems) +{ + float diff = (framems - lastUpdate) / 1000.f; + + if (lastUpdate != 0) // && !paused && !bglobal.freeze) + { + for (unsigned int i = 0; i < layers.Size(); i++) + { + layers[i]->Update(diff); + } + } + lastUpdate = framems; +} + +//========================================================================== +// +// +// +//========================================================================== + +void FTextureShader::FakeUpdate(int framems) +{ + lastUpdate = framems; +} + +//========================================================================== +// +// +// +//========================================================================== + +FString FTextureShader::CreateName() +{ + FString compose = "custom"; + for(unsigned i=0; iemissive, + layers[i]->blendFuncSrc, layers[i]->blendFuncDst, layers[i]->texgen, layers[i]->warp); + } + return compose; +} + +//========================================================================== +// +// +// +//========================================================================== + +FString FTextureShader::GenerateCode() +{ + static const char *funcnames[] = {"gettexel", "getwarp1", "getwarp2" }; + static const char *srcblend[] = { "vec4(0.0)", "src", "src*dest", "1.0-src*dest", "src*dest.a", "1.0-src*dest.a", + "src*src", "1.0-src*src", "src*src.a", "1.0-src*src", "vec4(src.rgb*src.a, 1)" }; + static const char *dstblend[] = { "vec4(0.0)", "dest", "dest*dest", "1.0-dest*dest", "dest*dest.a", "1.0-dest*dest.a", + "dest*src", "1.0-dest*src", "dest*src.a", "1.0-dest*src", "vec4(dest.rgb*src.a, 1)" }; + FString compose; + for(unsigned i=0; iwarp], i+1, i, i); + if (!layers[i]->emissive) compose.AppendFormat("src.rgb *= gl_Color.rgb;\n"); + compose.AppendFormat("dest = (%s)*srcfactor + (%s)*dstfactor;\n", + srcblend[layers[i]->blendFuncSrc], dstblend[layers[i]->blendFuncDst]); + } + return compose; +} + diff --git a/src/gl/shaders/gl_texshader.h b/src/gl/shaders/gl_texshader.h new file mode 100644 index 000000000..b3e90bf56 --- /dev/null +++ b/src/gl/shaders/gl_texshader.h @@ -0,0 +1,96 @@ + +#ifndef __GL_TEXSHADERS_H__ +#define __GL_TEXSHADERS_H__ + + +#include "tarray.h" +#include "zstring.h" +#include "gl/utility/gl_cycler.h" + + +enum +{ + SHADER_TexGen_None = 0, + SHADER_TexGen_Sphere, + NUM_TexGenTypes +}; + + +//========================================================================== +// +// +// +//========================================================================== + +class FShaderLayer +{ +public: + FShaderLayer(); + FShaderLayer(const FShaderLayer &layer); + ~FShaderLayer(); + void Update(float diff); + CycleType ParseCycleType(FScanner &sc); + bool ParseLayer(FScanner &sc); + + FTextureID texture; + int warpspeed; + unsigned char warp; + bool animate; + bool emissive; + unsigned char texgen; + float centerX, centerY; + float rotation; + float rotate; + float offsetX, offsetY; + FCycler adjustX, adjustY; + FCycler vectorX, vectorY; + FCycler scaleX, scaleY; + FCycler alpha; + FCycler r, g, b; + FCycler srcFactor, dstFactor; + unsigned int flags; + unsigned int blendFuncSrc, blendFuncDst; + FShaderLayer *layerMask; +}; + +//========================================================================== +// +// +// +//========================================================================== + +class FTextureShader +{ +public: + FTextureShader(); + bool ParseShader(FScanner &sc, TArray &names); + bool Available(); + bool Setup(float time); + void Update(int framems); + void FakeUpdate(int framems); + FString CreateName(); + FString GenerateCode(); + + FName name; + TDeletingArray layers; // layers for shader + unsigned int lastUpdate; +}; + + +/* +//extern TArray Shaders[NUM_ShaderClasses]; +//extern TArray ShaderLookup[NUM_ShaderClasses]; + +void GL_InitShaders(); +void GL_ReleaseShaders(); +void GL_UpdateShaders(); +void GL_FakeUpdateShaders(); +//void GL_UpdateShader(FShader *shader); +void GL_DrawShaders(); +//FShader *GL_ShaderForTexture(FTexture *tex); + +bool GL_ParseShader(); +*/ + + +#endif // __GL_TEXSHADERS_H__ diff --git a/src/gl/stereo3d/gl_anaglyph.cpp b/src/gl/stereo3d/gl_anaglyph.cpp new file mode 100644 index 000000000..4b3d4d00e --- /dev/null +++ b/src/gl/stereo3d/gl_anaglyph.cpp @@ -0,0 +1,64 @@ +/* +** gl_anaglyph.cpp +** Color mask based stereoscopic 3D modes for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** 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 "gl_anaglyph.h" + +namespace s3d { + +MaskAnaglyph::MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters) + : leftEye(leftColorMask, ipdMeters), rightEye(leftColorMask.inverse(), ipdMeters) +{ + eye_ptrs.Push(&leftEye); + eye_ptrs.Push(&rightEye); +} + + +/* static */ +const GreenMagenta& GreenMagenta::getInstance(FLOATTYPE ipd) +{ + static GreenMagenta instance(ipd); + return instance; +} + + +/* static */ +const RedCyan& RedCyan::getInstance(FLOATTYPE ipd) +{ + static RedCyan instance(ipd); + return instance; +} + + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_anaglyph.h b/src/gl/stereo3d/gl_anaglyph.h new file mode 100644 index 000000000..d60506dde --- /dev/null +++ b/src/gl/stereo3d/gl_anaglyph.h @@ -0,0 +1,124 @@ +/* +** gl_anaglyph.h +** Color mask based stereoscopic 3D modes for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** 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. +**--------------------------------------------------------------------------- +** +** +*/ + +#ifndef GL_ANAGLYPH_H_ +#define GL_ANAGLYPH_H_ + +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" +#include "gl/system/gl_system.h" +#include "gl/renderer/gl_renderstate.h" + + +namespace s3d { + + +class ColorMask +{ +public: + ColorMask(bool r, bool g, bool b) : r(r), g(g), b(b) {} + ColorMask inverse() const { return ColorMask(!r, !g, !b); } + + bool r; + bool g; + bool b; +}; + + +class AnaglyphLeftPose : public LeftEyePose +{ +public: + AnaglyphLeftPose(const ColorMask& colorMask, float ipd) : LeftEyePose(ipd), colorMask(colorMask) {} + virtual void SetUp() const { + gl_RenderState.SetColorMask(colorMask.r, colorMask.g, colorMask.b, true); + gl_RenderState.ApplyColorMask(); + } + virtual void TearDown() const { + gl_RenderState.ResetColorMask(); + gl_RenderState.ApplyColorMask(); + } +private: + ColorMask colorMask; +}; + +class AnaglyphRightPose : public RightEyePose +{ +public: + AnaglyphRightPose(const ColorMask& colorMask, float ipd) : RightEyePose(ipd), colorMask(colorMask) {} + virtual void SetUp() const { + gl_RenderState.SetColorMask(colorMask.r, colorMask.g, colorMask.b, true); + gl_RenderState.ApplyColorMask(); + } + virtual void TearDown() const { + gl_RenderState.ResetColorMask(); + gl_RenderState.ApplyColorMask(); + } +private: + ColorMask colorMask; +}; + +class MaskAnaglyph : public Stereo3DMode +{ +public: + MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters); +private: + AnaglyphLeftPose leftEye; + AnaglyphRightPose rightEye; +}; + + +class RedCyan : public MaskAnaglyph +{ +public: + static const RedCyan& getInstance(float ipd); + + RedCyan(float ipd) : MaskAnaglyph(ColorMask(true, false, false), ipd) {} +}; + +class GreenMagenta : public MaskAnaglyph +{ +public: + static const GreenMagenta& getInstance(float ipd); + + GreenMagenta(float ipd) : MaskAnaglyph(ColorMask(false, true, false), ipd) {} +}; + +// TODO matrix anaglyph + + +} /* namespace st3d */ + + +#endif /* GL_ANAGLYPH_H_ */ diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp new file mode 100644 index 000000000..ed16d9db5 --- /dev/null +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -0,0 +1,91 @@ +/* +** gl_stereo3d.cpp +** Stereoscopic 3D API +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** 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 "gl/stereo3d/gl_stereo3d.h" +#include "vectors.h" // RAD2DEG +#include "doomtype.h" // M_PI + +namespace s3d { + + +/* virtual */ +VSMatrix EyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const +{ + VSMatrix result; + + // Lifted from gl_scene.cpp FGLRenderer::SetProjection() + float fovy = (float)(2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio))); + result.perspective(fovy, aspectRatio, 5.f, 65536.f); + + return result; +} + +/* virtual */ +Viewport EyePose::GetViewport(const Viewport& fullViewport) const +{ + return fullViewport; +} + + +/* virtual */ +void EyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const +{ + // pass-through for Mono view + outViewShift[0] = 0; + outViewShift[1] = 0; + outViewShift[2] = 0; +} + + +Stereo3DMode::Stereo3DMode() +{ +} + +Stereo3DMode::~Stereo3DMode() +{ +} + +// Avoid static initialization order fiasco by declaring first Mode type (Mono) here in the +// same source file as Stereo3DMode::getCurrentMode() +// https://isocpp.org/wiki/faq/ctors#static-init-order + +/* static */ +const MonoView& MonoView::getInstance() +{ + static MonoView instance; + return instance; +} + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_stereo3d.h b/src/gl/stereo3d/gl_stereo3d.h new file mode 100644 index 000000000..48b6ef900 --- /dev/null +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -0,0 +1,113 @@ +/* +** gl_stereo3d.h +** Stereoscopic 3D API +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** 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. +**--------------------------------------------------------------------------- +** +** +*/ + +#ifndef GL_STEREO3D_H_ +#define GL_STEREO3D_H_ + +#include // needed for memcpy on linux, which is needed by VSMatrix copy ctor +#include "tarray.h" +#include "gl/data/gl_matrix.h" + + +/* stereoscopic 3D API */ +namespace s3d { + + +/* Subregion of current display window */ +class Viewport +{ +public: + int x, y; + int width, height; +}; + + +/* Viewpoint of one eye */ +class EyePose +{ +public: + EyePose() {} + virtual ~EyePose() {} + virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const; + virtual Viewport GetViewport(const Viewport& fullViewport) const; + virtual void GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const; + virtual void SetUp() const {}; + virtual void TearDown() const {}; +}; + + +/* Base class for stereoscopic 3D rendering modes */ +class Stereo3DMode +{ +public: + /* static methods for managing the selected stereoscopic view state */ + static const Stereo3DMode& getCurrentMode(); + + Stereo3DMode(); + virtual ~Stereo3DMode(); + virtual int eye_count() const { return eye_ptrs.Size(); } + virtual const EyePose * getEyePose(int ix) const { return eye_ptrs(ix); } + + /* hooks for setup and cleanup operations for each stereo mode */ + virtual void SetUp() const {}; + virtual void TearDown() const {}; + +protected: + TArray eye_ptrs; + +private: + static Stereo3DMode const * currentStereo3DMode; + static void setCurrentMode(const Stereo3DMode& mode); +}; + + +/** +* Ordinary non-3D rendering +*/ +class MonoView : public Stereo3DMode +{ +public: + static const MonoView& getInstance(); + +protected: + MonoView() { eye_ptrs.Push(¢ralEye); } + EyePose centralEye; +}; + + +} /* namespace st3d */ + + +#endif /* GL_STEREO3D_H_ */ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp new file mode 100644 index 000000000..56895bbc6 --- /dev/null +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -0,0 +1,92 @@ +/* +** gl_stereo_cvars.cpp +** Console variables related to stereoscopic 3D in GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** 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 "gl/stereo3d/gl_stereo3d.h" +#include "gl/stereo3d/gl_stereo_leftright.h" +#include "gl/stereo3d/gl_anaglyph.h" +#include "gl/system/gl_cvars.h" + +// Set up 3D-specific console variables: +CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG) + +// intraocular distance in meters +CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS + +// distance between viewer and the display screen +CVAR(Float, vr_screendist, 0.80f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS + +// default conversion between (vertical) DOOM units and meters +CVAR(Float, vr_hunits_per_meter, 41.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS + +// Manage changing of 3D modes: +namespace s3d { + +// Initialize static member +Stereo3DMode const * Stereo3DMode::currentStereo3DMode = 0; // "nullptr" not resolved on linux (presumably not C++11) + +/* static */ +void Stereo3DMode::setCurrentMode(const Stereo3DMode& mode) { + Stereo3DMode::currentStereo3DMode = &mode; +} + +/* static */ +const Stereo3DMode& Stereo3DMode::getCurrentMode() +{ + // NOTE: Ensure that these vr_mode values correspond to the ones in wadsrc/static/menudef.z + switch (vr_mode) + { + case 1: + setCurrentMode(GreenMagenta::getInstance(vr_ipd)); + break; + case 2: + setCurrentMode(RedCyan::getInstance(vr_ipd)); + break; + // TODO: missing indices 3, 4 for not-yet-implemented side-by-side modes, to match values from GZ3Doom + case 5: + setCurrentMode(LeftEyeView::getInstance(vr_ipd)); + break; + case 6: + setCurrentMode(RightEyeView::getInstance(vr_ipd)); + break; + case 0: + default: + setCurrentMode(MonoView::getInstance()); + break; + } + return *currentStereo3DMode; +} + +} /* namespace s3d */ + diff --git a/src/gl/stereo3d/gl_stereo_leftright.cpp b/src/gl/stereo3d/gl_stereo_leftright.cpp new file mode 100644 index 000000000..bf9fea09c --- /dev/null +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -0,0 +1,101 @@ +/* +** gl_stereo_leftright.cpp +** Offsets for left and right eye views +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** 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 "gl_stereo_leftright.h" +#include "vectors.h" // RAD2DEG +#include "doomtype.h" // M_PI +#include "gl/system/gl_cvars.h" +#include + +EXTERN_CVAR(Float, vr_screendist) +EXTERN_CVAR(Float, vr_hunits_per_meter) + +namespace s3d { + + +/* virtual */ +VSMatrix ShiftedEyePose::GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const +{ + double zNear = 5.0; + double zFar = 65536.0; + + // For stereo 3D, use asymmetric frustum shift in projection matrix + // Q: shouldn't shift vary with roll angle, at least for desktop display? + // A: No. (lab) roll is not measured on desktop display (yet) + double frustumShift = zNear * shift / vr_screendist; // meters cancel, leaving doom units + // double frustumShift = 0; // Turning off shift for debugging + double fH = zNear * tan(DEG2RAD(fov) / 2) / fovRatio; + double fW = fH * aspectRatio; + double left = -fW - frustumShift; + double right = fW - frustumShift; + double bottom = -fH; + double top = fH; + + VSMatrix result(1); + result.frustum(left, right, bottom, top, zNear, zFar); + return result; +} + + +/* virtual */ +void ShiftedEyePose::GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const +{ + FLOATTYPE dx = cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + FLOATTYPE dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + outViewShift[0] = dx; + outViewShift[1] = dy; + outViewShift[2] = 0; +} + + +/* static */ +const LeftEyeView& LeftEyeView::getInstance(FLOATTYPE ipd) +{ + static LeftEyeView instance(ipd); + instance.setIpd(ipd); + return instance; +} + + +/* static */ +const RightEyeView& RightEyeView::getInstance(FLOATTYPE ipd) +{ + static RightEyeView instance(ipd); + instance.setIpd(ipd); + return instance; +} + + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_stereo_leftright.h b/src/gl/stereo3d/gl_stereo_leftright.h new file mode 100644 index 000000000..6bca9de90 --- /dev/null +++ b/src/gl/stereo3d/gl_stereo_leftright.h @@ -0,0 +1,106 @@ +/* +** gl_stereo_leftright.h +** Offsets for left and right eye views +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** 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. +**--------------------------------------------------------------------------- +** +** +*/ + +#ifndef GL_STEREO_LEFTRIGHT_H_ +#define GL_STEREO_LEFTRIGHT_H_ + +#include "gl_stereo3d.h" + +namespace s3d { + + +class ShiftedEyePose : public EyePose +{ +public: + ShiftedEyePose(FLOATTYPE shift) : shift(shift) {}; + FLOATTYPE getShift() const { return shift; } + void setShift(FLOATTYPE shift) { this->shift = shift; } + virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const; + virtual void GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const; +protected: + FLOATTYPE shift; +}; + + +class LeftEyePose : public ShiftedEyePose +{ +public: + LeftEyePose(FLOATTYPE ipd) : ShiftedEyePose( FLOATTYPE(-0.5) * ipd) {} + FLOATTYPE getIpd() const { return FLOATTYPE(-2.0)*getShift(); } + void setIpd(FLOATTYPE ipd) { setShift(FLOATTYPE(-0.5)*ipd); } +}; + + +class RightEyePose : public ShiftedEyePose +{ +public: + RightEyePose(FLOATTYPE ipd) : ShiftedEyePose(FLOATTYPE(+0.5)*ipd) {} + FLOATTYPE getIpd() const { return FLOATTYPE(+2.0)*shift; } + void setIpd(FLOATTYPE ipd) { setShift(FLOATTYPE(+0.5)*ipd); } +}; + + +/** + * As if viewed through the left eye only + */ +class LeftEyeView : public Stereo3DMode +{ +public: + static const LeftEyeView& getInstance(FLOATTYPE ipd); + + LeftEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.Push(&eye); } + FLOATTYPE getIpd() const { return eye.getIpd(); } + void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); } +protected: + LeftEyePose eye; +}; + + +class RightEyeView : public Stereo3DMode +{ +public: + static const RightEyeView& getInstance(FLOATTYPE ipd); + + RightEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.Push(&eye); } + FLOATTYPE getIpd() const { return eye.getIpd(); } + void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); } +protected: + RightEyePose eye; +}; + + +} /* namespace s3d */ + +#endif /* GL_STEREO_LEFTRIGHT_H_ */ diff --git a/src/gl/stereo3d/scoped_color_mask.h b/src/gl/stereo3d/scoped_color_mask.h new file mode 100644 index 000000000..5c35752e5 --- /dev/null +++ b/src/gl/stereo3d/scoped_color_mask.h @@ -0,0 +1,62 @@ +/* +** scoped_color_mask.h +** Stack-scoped class for temporarily changing the OpenGL color mask setting. +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** 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. +**--------------------------------------------------------------------------- +** +** +*/ + +#ifndef GL_STEREO3D_SCOPED_COLOR_MASK_H_ +#define GL_STEREO3D_SCOPED_COLOR_MASK_H_ + +#include "gl/system/gl_system.h" + +/** +* Temporarily change color mask +*/ +class ScopedColorMask +{ +public: + ScopedColorMask(bool r, bool g, bool b, bool a) + { + gl_RenderState.GetColorMask(saved[0], saved[1], saved[2], saved[3]); + gl_RenderState.SetColorMask(r, g, b, a); + gl_RenderState.ApplyColorMask(); + } + ~ScopedColorMask() { + gl_RenderState.SetColorMask(saved[0], saved[1], saved[2], saved[3]); + gl_RenderState.ApplyColorMask(); + } +private: + bool saved[4]; +}; + + +#endif // GL_STEREO3D_SCOPED_COLOR_MASK_H_ diff --git a/src/gl/stereo3d/scoped_view_shifter.cpp b/src/gl/stereo3d/scoped_view_shifter.cpp new file mode 100644 index 000000000..4e70c596d --- /dev/null +++ b/src/gl/stereo3d/scoped_view_shifter.cpp @@ -0,0 +1,65 @@ +/* +** scoped_view_shifter.cpp +** Stack-scoped class for temporarily changing player viewpoint global variables viewx, viewy, viewz. +** Used for stereoscopic 3D. +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** 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 "scoped_view_shifter.h" +#include "r_utility.h" + +namespace s3d { + +ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in meters +{ + // save original values + cachedViewx = viewx; + cachedViewy = viewy; + cachedViewz = viewz; + // modify values + float fViewx = FIXED2FLOAT(viewx) - dxyz[0]; + float fViewy = FIXED2FLOAT(viewy) + dxyz[1]; + float fViewz = FIXED2FLOAT(viewz) + dxyz[2]; + viewx = FLOAT2FIXED(fViewx); + viewy = FLOAT2FIXED(fViewy); + viewz = FLOAT2FIXED(fViewz); +} + +ScopedViewShifter::~ScopedViewShifter() +{ + // restore original values + viewx = cachedViewx; + viewy = cachedViewy; + viewz = cachedViewz; +} + +} \ No newline at end of file diff --git a/src/gl/stereo3d/scoped_view_shifter.h b/src/gl/stereo3d/scoped_view_shifter.h new file mode 100644 index 000000000..d43e2b32a --- /dev/null +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -0,0 +1,61 @@ +/* +** scoped_view_shifter.h +** Stack-scoped class for temporarily changing player viewpoint global variables viewx, viewy, viewz. +** Used for stereoscopic 3D. +** +**--------------------------------------------------------------------------- +** Copyright 2015 Christopher Bruns +** 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. +**--------------------------------------------------------------------------- +** +** +*/ + +#ifndef GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_ +#define GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_ + +#include "basictypes.h" + +namespace s3d { + + /** + * Temporarily shift viewx, viewy, viewz + */ + class ScopedViewShifter + { + public: + ScopedViewShifter(float dxyz[3]); // in meters + ~ScopedViewShifter(); + + private: + fixed_t cachedViewx; + fixed_t cachedViewy; + fixed_t cachedViewz; + }; + +} /* namespace s3d */ + +#endif // GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_ diff --git a/src/gl/system/gl_cvars.h b/src/gl/system/gl_cvars.h new file mode 100644 index 000000000..cedeec06a --- /dev/null +++ b/src/gl/system/gl_cvars.h @@ -0,0 +1,44 @@ + + +#ifndef _GL_INTERN_H +#define _GL_INTERN_H + +#include "r_defs.h" +#include "c_cvars.h" + +#ifdef _MSC_VER +#pragma warning(disable:4244) +#endif + +EXTERN_CVAR(Bool,gl_enhanced_nightvision) +EXTERN_CVAR(Int, screenblocks); +EXTERN_CVAR(Bool, gl_texture) +EXTERN_CVAR(Int, gl_texture_filter) +EXTERN_CVAR(Float, gl_texture_filter_anisotropic) +EXTERN_CVAR(Int, gl_texture_format) +EXTERN_CVAR(Bool, gl_texture_usehires) +EXTERN_CVAR(Bool, gl_usefb) + +EXTERN_CVAR(Int, gl_weaponlight) + +EXTERN_CVAR (Bool, gl_lights); +EXTERN_CVAR (Bool, gl_attachedlights); +EXTERN_CVAR (Bool, gl_lights_checkside); +EXTERN_CVAR (Float, gl_lights_intensity); +EXTERN_CVAR (Float, gl_lights_size); +EXTERN_CVAR (Bool, gl_lights_additive); +EXTERN_CVAR (Bool, gl_light_sprites); +EXTERN_CVAR (Bool, gl_light_particles); + +EXTERN_CVAR(Int, gl_fogmode) +EXTERN_CVAR(Int, gl_lightmode) +EXTERN_CVAR(Bool,gl_mirror_envmap) + +EXTERN_CVAR(Bool,gl_mirrors) +EXTERN_CVAR(Bool,gl_mirror_envmap) +EXTERN_CVAR(Bool, gl_seamless) + +EXTERN_CVAR(Float, gl_mask_threshold) +EXTERN_CVAR(Float, gl_mask_sprite_threshold) + +#endif // _GL_INTERN_H diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp new file mode 100644 index 000000000..7a3fef1a3 --- /dev/null +++ b/src/gl/system/gl_framebuffer.cpp @@ -0,0 +1,541 @@ +/* +** gl_framebuffer.cpp +** Implementation of the non-hardware specific parts of the +** OpenGL frame buffer +** +**--------------------------------------------------------------------------- +** Copyright 2000-2007 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "files.h" +#include "m_swap.h" +#include "v_video.h" +#include "doomstat.h" +#include "m_png.h" +#include "m_crc32.h" +#include "vectors.h" +#include "v_palette.h" +#include "templates.h" +#include "farchive.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/data/gl_data.h" +#include "gl/textures/gl_hwtexture.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_translate.h" +#include "gl/textures/gl_skyboxtexture.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_templates.h" +#include "gl/gl_functions.h" + +IMPLEMENT_CLASS(OpenGLFrameBuffer) +EXTERN_CVAR (Float, vid_brightness) +EXTERN_CVAR (Float, vid_contrast) +EXTERN_CVAR (Bool, vid_vsync) + +CVAR(Bool, gl_aalines, false, CVAR_ARCHIVE) + +FGLRenderer *GLRenderer; + +void gl_LoadExtensions(); +void gl_PrintStartupLog(); +void gl_SetupMenu(); + +//========================================================================== +// +// +// +//========================================================================== + +OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : + Super(hMonitor, width, height, bits, refreshHz, fullscreen) +{ + GLRenderer = new FGLRenderer(this); + memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256); + UpdatePalette (); + ScreenshotBuffer = NULL; + LastCamera = NULL; + + InitializeState(); + gl_SetupMenu(); + gl_GenerateGlobalBrightmapFromColormap(); + DoSetGamma(); + needsetgamma = true; + swapped = false; + Accel2D = true; + SetVSync(vid_vsync); +} + +OpenGLFrameBuffer::~OpenGLFrameBuffer() +{ + delete GLRenderer; + GLRenderer = NULL; +} + +//========================================================================== +// +// Initializes the GL renderer +// +//========================================================================== + +void OpenGLFrameBuffer::InitializeState() +{ + static bool first=true; + + if (first) + { + ogl_LoadFunctions(); + } + + gl_LoadExtensions(); + Super::InitializeState(); + + if (first) + { + first=false; + // [BB] For some reason this crashes, if compiled with MinGW and optimization. Has to be investigated. +#ifdef _MSC_VER + gl_PrintStartupLog(); +#endif + + } + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glClearDepth(1.0f); + glDepthFunc(GL_LESS); + + glEnable(GL_DITHER); + glDisable(GL_CULL_FACE); + glDisable(GL_POLYGON_OFFSET_FILL); + glEnable(GL_POLYGON_OFFSET_LINE); + glEnable(GL_BLEND); + glEnable(GL_DEPTH_CLAMP); + glDisable(GL_DEPTH_TEST); + glEnable(GL_TEXTURE_2D); + glDisable(GL_LINE_SMOOTH); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + int trueH = GetTrueHeight(); + int h = GetHeight(); + glViewport(0, (trueH - h)/2, GetWidth(), GetHeight()); + + Begin2D(false); + GLRenderer->Initialize(); +} + +//========================================================================== +// +// Updates the screen +// +//========================================================================== + +// Testing only for now. +CVAR(Bool, gl_draw_sync, true, 0) //false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) + +void OpenGLFrameBuffer::Update() +{ + if (!CanUpdate()) + { + GLRenderer->Flush(); + return; + } + + Begin2D(false); + + DrawRateStuff(); + GLRenderer->Flush(); + + if (GetTrueHeight() != GetHeight()) + { + if (GLRenderer != NULL) + GLRenderer->ClearBorders(); + + Begin2D(false); + } + if (gl_draw_sync || !swapped) + { + Swap(); + } + swapped = false; + Unlock(); + CheckBench(); +} + + +//========================================================================== +// +// Swap the buffers +// +//========================================================================== + +void OpenGLFrameBuffer::Swap() +{ + Finish.Reset(); + Finish.Clock(); + glFinish(); + if (needsetgamma) + { + //DoSetGamma(); + needsetgamma = false; + } + SwapBuffers(); + Finish.Unclock(); + swapped = true; + FHardwareTexture::UnbindAll(); +} + +//=========================================================================== +// +// DoSetGamma +// +// (Unfortunately Windows has some safety precautions that block gamma ramps +// that are considered too extreme. As a result this doesn't work flawlessly) +// +//=========================================================================== + +void OpenGLFrameBuffer::DoSetGamma() +{ + WORD gammaTable[768]; + + if (m_supportsGamma) + { + // This formula is taken from Doomsday + float gamma = clamp(Gamma, 0.1f, 4.f); + float contrast = clamp(vid_contrast, 0.1f, 3.f); + float bright = clamp(vid_brightness, -0.8f, 0.8f); + + double invgamma = 1 / gamma; + double norm = pow(255., invgamma - 1); + + for (int i = 0; i < 256; i++) + { + double val = i * contrast - (contrast - 1) * 127; + if(gamma != 1) val = pow(val, invgamma) / norm; + val += bright * 128; + + gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (WORD)clamp(val*256, 0, 0xffff); + } + SetGammaTable(gammaTable); + } +} + +bool OpenGLFrameBuffer::SetGamma(float gamma) +{ + DoSetGamma(); + return true; +} + +bool OpenGLFrameBuffer::SetBrightness(float bright) +{ + DoSetGamma(); + return true; +} + +bool OpenGLFrameBuffer::SetContrast(float contrast) +{ + DoSetGamma(); + return true; +} + +//=========================================================================== +// +// +//=========================================================================== + +void OpenGLFrameBuffer::UpdatePalette() +{ + int rr=0,gg=0,bb=0; + for(int x=0;x<256;x++) + { + rr+=GPalette.BaseColors[x].r; + gg+=GPalette.BaseColors[x].g; + bb+=GPalette.BaseColors[x].b; + } + rr>>=8; + gg>>=8; + bb>>=8; + + palette_brightness = (rr*77 + gg*143 + bb*35)/255; +} + +void OpenGLFrameBuffer::GetFlashedPalette (PalEntry pal[256]) +{ + memcpy(pal, SourcePalette, 256*sizeof(PalEntry)); +} + +PalEntry *OpenGLFrameBuffer::GetPalette () +{ + return SourcePalette; +} + +bool OpenGLFrameBuffer::SetFlash(PalEntry rgb, int amount) +{ + Flash = PalEntry(amount, rgb.r, rgb.g, rgb.b); + return true; +} + +void OpenGLFrameBuffer::GetFlash(PalEntry &rgb, int &amount) +{ + rgb = Flash; + rgb.a = 0; + amount = Flash.a; +} + +int OpenGLFrameBuffer::GetPageCount() +{ + return 1; +} + + +void OpenGLFrameBuffer::GetHitlist(BYTE *hitlist) +{ + Super::GetHitlist(hitlist); + + // check skybox textures and mark the separate faces as used + for(int i=0;igl_info.bSkybox) + { + FSkyBox *sb = static_cast(tex); + for(int i=0;i<6;i++) + { + if (sb->faces[i]) + { + int index = sb->faces[i]->id.GetIndex(); + hitlist[index] |= FTextureManager::HIT_Flat; + } + } + } + } + } + + + // check model skins +} + +//========================================================================== +// +// DFrameBuffer :: CreatePalette +// +// Creates a native palette from a remap table, if supported. +// +//========================================================================== + +FNativePalette *OpenGLFrameBuffer::CreatePalette(FRemapTable *remap) +{ + return GLTranslationPalette::CreatePalette(remap); +} + +//========================================================================== +// +// +// +//========================================================================== +bool OpenGLFrameBuffer::Begin2D(bool) +{ + gl_RenderState.mViewMatrix.loadIdentity(); + gl_RenderState.mProjectionMatrix.ortho(0, GetWidth(), GetHeight(), 0, -1.0f, 1.0f); + gl_RenderState.ApplyMatrices(); + + glDisable(GL_DEPTH_TEST); + + // Korshun: ENABLE AUTOMAP ANTIALIASING!!! + if (gl_aalines) + glEnable(GL_LINE_SMOOTH); + else + { + glDisable(GL_MULTISAMPLE); + glDisable(GL_LINE_SMOOTH); + glLineWidth(1.0); + } + + if (GLRenderer != NULL) + GLRenderer->Begin2D(); + return true; +} + +//========================================================================== +// +// Draws a texture +// +//========================================================================== + +void STACK_ARGS OpenGLFrameBuffer::DrawTextureV(FTexture *img, double x0, double y0, uint32 tag, va_list tags) +{ + DrawParms parms; + + if (ParseDrawTextureTags(img, x0, y0, tag, tags, &parms, true)) + { + if (GLRenderer != NULL) GLRenderer->DrawTexture(img, parms); + } +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color) +{ + if (GLRenderer != NULL) + GLRenderer->DrawLine(x1, y1, x2, y2, palcolor, color); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::DrawPixel(int x1, int y1, int palcolor, uint32 color) +{ + if (GLRenderer != NULL) + GLRenderer->DrawPixel(x1, y1, palcolor, color); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::Dim(PalEntry) +{ + // Unlike in the software renderer the color is being ignored here because + // view blending only affects the actual view with the GL renderer. + Super::Dim(0); +} + +void OpenGLFrameBuffer::Dim(PalEntry color, float damount, int x1, int y1, int w, int h) +{ + if (GLRenderer != NULL) + GLRenderer->Dim(color, damount, x1, y1, w, h); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin) +{ + + if (GLRenderer != NULL) + GLRenderer->FlatFill(left, top, right, bottom, src, local_origin); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::Clear(int left, int top, int right, int bottom, int palcolor, uint32 color) +{ + if (GLRenderer != NULL) + GLRenderer->Clear(left, top, right, bottom, palcolor, color); +} + +//========================================================================== +// +// D3DFB :: FillSimplePoly +// +// Here, "simple" means that a simple triangle fan can draw it. +// +//========================================================================== + +void OpenGLFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + angle_t rotation, FDynamicColormap *colormap, int lightlevel) +{ + if (GLRenderer != NULL) + { + GLRenderer->FillSimplePoly(texture, points, npoints, originx, originy, scalex, scaley, + rotation, colormap, lightlevel); + } +} + + +//=========================================================================== +// +// Takes a screenshot +// +//=========================================================================== + +void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type) +{ + int w = SCREENWIDTH; + int h = SCREENHEIGHT; + + ReleaseScreenshotBuffer(); + ScreenshotBuffer = new BYTE[w * h * 3]; + + glPixelStorei(GL_PACK_ALIGNMENT, 1); + glReadPixels(0,(GetTrueHeight() - GetHeight()) / 2,w,h,GL_RGB,GL_UNSIGNED_BYTE,ScreenshotBuffer); + glPixelStorei(GL_PACK_ALIGNMENT, 4); + pitch = -w*3; + color_type = SS_RGB; + buffer = ScreenshotBuffer + w * 3 * (h - 1); +} + +//=========================================================================== +// +// Releases the screenshot buffer. +// +//=========================================================================== + +void OpenGLFrameBuffer::ReleaseScreenshotBuffer() +{ + if (ScreenshotBuffer != NULL) delete [] ScreenshotBuffer; + ScreenshotBuffer = NULL; +} + + +void OpenGLFrameBuffer::GameRestart() +{ + memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256); + UpdatePalette (); + ScreenshotBuffer = NULL; + LastCamera = NULL; + gl_GenerateGlobalBrightmapFromColormap(); +} + diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h new file mode 100644 index 000000000..c2a4fc277 --- /dev/null +++ b/src/gl/system/gl_framebuffer.h @@ -0,0 +1,117 @@ +#ifndef __GL_FRAMEBUFFER +#define __GL_FRAMEBUFFER + +#ifdef _WIN32 +#include "win32iface.h" +#include "win32gliface.h" +#endif + +class FHardwareTexture; + +extern long gl_frameMS; +extern long gl_frameCount; +#ifdef _WIN32 +class OpenGLFrameBuffer : public Win32GLFrameBuffer +{ + typedef Win32GLFrameBuffer Super; + DECLARE_CLASS(OpenGLFrameBuffer, Win32GLFrameBuffer) +#else +#include "sdlglvideo.h" +class OpenGLFrameBuffer : public SDLGLFB +{ +// typedef SDLGLFB Super; //[C]commented, DECLARE_CLASS defines this in linux + DECLARE_CLASS(OpenGLFrameBuffer, SDLGLFB) +#endif + + +public: + + explicit OpenGLFrameBuffer() {} + OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) ; + ~OpenGLFrameBuffer(); + + void InitializeState(); + void Update(); + + // Color correction + bool SetGamma (float gamma); + bool SetBrightness(float bright); + bool SetContrast(float contrast); + void DoSetGamma(); + + void UpdatePalette(); + void GetFlashedPalette (PalEntry pal[256]); + PalEntry *GetPalette (); + bool SetFlash(PalEntry rgb, int amount); + void GetFlash(PalEntry &rgb, int &amount); + int GetPageCount(); + bool Begin2D(bool copy3d); + void GetHitlist(BYTE *hitlist); + void GameRestart(); + + // Retrieves a buffer containing image data for a screenshot. + // Hint: Pitch can be negative for upside-down images, in which case buffer + // points to the last row in the buffer, which will be the first row output. + virtual void GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type); + + // Releases the screenshot buffer. + virtual void ReleaseScreenshotBuffer(); + + // 2D drawing + void STACK_ARGS DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags); + void DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color); + void DrawPixel(int x1, int y1, int palcolor, uint32 color); + void Clear(int left, int top, int right, int bottom, int palcolor, uint32 color); + void Dim(PalEntry color=0); + void Dim (PalEntry color, float damount, int x1, int y1, int w, int h); + void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin=false); + + void FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + angle_t rotation, FDynamicColormap *colormap, int lightlevel); + + FNativePalette *CreatePalette(FRemapTable *remap); + + bool WipeStartScreen(int type); + void WipeEndScreen(); + bool WipeDo(int ticks); + void WipeCleanup(); + void Swap(); + bool Is8BitMode() { return false; } + + +private: + PalEntry Flash; + + // Texture creation info + int cm; + int translation; + bool iscomplex; + bool needsetgamma; + bool swapped; + + PalEntry SourcePalette[256]; + BYTE *ScreenshotBuffer; + + class Wiper + { + public: + virtual ~Wiper(); + virtual bool Run(int ticks, OpenGLFrameBuffer *fb) = 0; + }; + + class Wiper_Melt; friend class Wiper_Melt; + class Wiper_Burn; friend class Wiper_Burn; + class Wiper_Crossfade; friend class Wiper_Crossfade; + + Wiper *ScreenWipe; + FHardwareTexture *wipestartscreen; + FHardwareTexture *wipeendscreen; + +public: + AActor * LastCamera; + int palette_brightness; +}; + + +#endif //__GL_FRAMEBUFFER diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp new file mode 100644 index 000000000..2e7d0f1e0 --- /dev/null +++ b/src/gl/system/gl_interface.cpp @@ -0,0 +1,211 @@ +/* +** r_opengl.cpp +** +** OpenGL system interface +** +**--------------------------------------------------------------------------- +** Copyright 2005 Tim Stump +** Copyright 2005-2013 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. +** 4. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "tarray.h" +#include "doomtype.h" +#include "m_argv.h" +#include "zstring.h" +#include "version.h" +#include "i_system.h" +#include "v_text.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" + +static TArray m_Extensions; + +RenderContext gl; + +int occlusion_type=0; + +//========================================================================== +// +// +// +//========================================================================== + +static void CollectExtensions() +{ + const char *extension; + + int max = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &max); + + for(int i = 0; i < max; i++) + { + extension = (const char*)glGetStringi(GL_EXTENSIONS, i); + m_Extensions.Push(FString(extension)); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +static bool CheckExtension(const char *ext) +{ + for (unsigned int i = 0; i < m_Extensions.Size(); ++i) + { + if (m_Extensions[i].CompareNoCase(ext) == 0) return true; + } + + return false; +} + + + +//========================================================================== +// +// +// +//========================================================================== + +static void InitContext() +{ + gl.flags=0; +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_LoadExtensions() +{ + InitContext(); + CollectExtensions(); + + const char *version = Args->CheckValue("-glversion"); + if (version == NULL) version = (const char*)glGetString(GL_VERSION); + else Printf("Emulating OpenGL v %s\n", version); + + // Don't even start if it's lower than 3.0 + if (strcmp(version, "3.0") < 0) + { + I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 3.0 is required to run " GAMENAME ".\n"); + } + + // add 0.01 to account for roundoff errors making the number a tad smaller than the actual version + gl.version = strtod(version, NULL) + 0.01f; + gl.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL) + 0.01f; + + gl.vendorstring = (char*)glGetString(GL_VENDOR); + + if (gl.version < 3.3f && !CheckExtension("GL_ARB_sampler_objects")) + { + I_FatalError("'GL_ARB_sampler_objects' extension not found. Please update your graphics driver."); + } + if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; + if (CheckExtension("GL_EXT_texture_compression_s3tc")) gl.flags|=RFL_TEXTURE_COMPRESSION_S3TC; + if (!Args->CheckParm("-gl3")) + { + // don't use GL 4.x features when running in GL 3 emulation mode. + if (CheckExtension("GL_ARB_buffer_storage")) + { + // work around a problem with older AMD drivers: Their implementation of shader storage buffer objects is piss-poor and does not match uniform buffers even closely. + // Recent drivers, GL 4.4 don't have this problem, these can easily be recognized by also supporting the GL_ARB_buffer_storage extension. + if (CheckExtension("GL_ARB_shader_storage_buffer_object")) + { + // Shader storage buffer objects are broken on current Intel drivers. + if (strstr(gl.vendorstring, "Intel") == NULL) + { + gl.flags |= RFL_SHADER_STORAGE_BUFFER; + } + } + gl.flags |= RFL_BUFFER_STORAGE; + } + } + + int v; + glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); + gl.maxuniforms = v; + glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); + gl.maxuniformblock = v; + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); + gl.uniformblockalignment = v; + + glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl.max_texturesize); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_PrintStartupLog() +{ + int v = 0; + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &v); + + Printf ("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); + Printf ("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); + Printf ("GL_VERSION: %s (%s profile)\n", glGetString(GL_VERSION), (v & GL_CONTEXT_CORE_PROFILE_BIT)? "Core" : "Compatibility"); + Printf ("GL_SHADING_LANGUAGE_VERSION: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); + Printf ("GL_EXTENSIONS:"); + for (unsigned i = 0; i < m_Extensions.Size(); i++) + { + Printf(" %s", m_Extensions[i].GetChars()); + } + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &v); + Printf("\nMax. texture size: %d\n", v); + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &v); + Printf ("Max. texture units: %d\n", v); + glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &v); + Printf ("Max. fragment uniforms: %d\n", v); + glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &v); + Printf ("Max. vertex uniforms: %d\n", v); + glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &v); + Printf ("Max. uniform block size: %d\n", v); + glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &v); + Printf ("Uniform block alignment: %d\n", v); + + glGetIntegerv(GL_MAX_VARYING_FLOATS, &v); + Printf ("Max. varying: %d\n", v); + glGetIntegerv(GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS, &v); + Printf("Max. combined shader storage blocks: %d\n", v); + glGetIntegerv(GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS, &v); + Printf("Max. vertex shader storage blocks: %d\n", v); + + +} + diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h new file mode 100644 index 000000000..6f2fb2bfc --- /dev/null +++ b/src/gl/system/gl_interface.h @@ -0,0 +1,46 @@ +#ifndef R_RENDER +#define R_RENDER + +#include "basictypes.h" + +enum RenderFlags +{ + // [BB] Added texture compression flags. + RFL_TEXTURE_COMPRESSION=1, + RFL_TEXTURE_COMPRESSION_S3TC=2, + + RFL_SHADER_STORAGE_BUFFER = 4, + RFL_BUFFER_STORAGE = 8 +}; + +enum TexMode +{ + TM_MODULATE = 0, // (r, g, b, a) + TM_MASK, // (1, 1, 1, a) + TM_OPAQUE, // (r, g, b, 1) + TM_INVERSE, // (1-r, 1-g, 1-b, a) + TM_REDTOALPHA, // (1, 1, 1, r) + TM_CLAMPY, // (r, g, b, (t >= 0.0 && t <= 1.0)? a:0) +}; + +struct RenderContext +{ + unsigned int flags; + unsigned int maxuniforms; + unsigned int maxuniformblock; + unsigned int uniformblockalignment; + float version; + float glslversion; + int max_texturesize; + char * vendorstring; + + int MaxLights() const + { + return maxuniforms>=2048? 128:64; + } +}; + +extern RenderContext gl; + +#endif + diff --git a/src/gl/system/gl_load.c b/src/gl/system/gl_load.c new file mode 100644 index 000000000..282395016 --- /dev/null +++ b/src/gl/system/gl_load.c @@ -0,0 +1,1346 @@ +#include +#include +#include +#include "gl_load.h" + +#if defined(__APPLE__) +#include + +static void* AppleGLGetProcAddress (const GLubyte *name) +{ + static const struct mach_header* image = NULL; + NSSymbol symbol; + char* symbolName; + if (NULL == image) + { + image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR); + } + /* prepend a '_' for the Unix C symbol mangling convention */ + symbolName = malloc(strlen((const char*)name) + 2); + strcpy(symbolName+1, (const char*)name); + symbolName[0] = '_'; + symbol = NULL; + /* if (NSIsSymbolNameDefined(symbolName)) + symbol = NSLookupAndBindSymbol(symbolName); */ + symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL; + free(symbolName); + return symbol ? NSAddressOfSymbol(symbol) : NULL; +} +#endif /* __APPLE__ */ + +#if defined(__sgi) || defined (__sun) +#include +#include + +static void* SunGetProcAddress (const GLubyte* name) +{ + static void* h = NULL; + static void* gpa; + + if (h == NULL) + { + if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL; + gpa = dlsym(h, "glXGetProcAddress"); + } + + if (gpa != NULL) + return ((void*(*)(const GLubyte*))gpa)(name); + else + return dlsym(h, (const char*)name); +} +#endif /* __sgi || __sun */ + +#if defined(_WIN32) + +#ifdef _MSC_VER +// disable inlining here because it creates an incredible amount of bloat here. +#pragma inline_depth(0) +#pragma warning(disable: 4055) +#pragma warning(disable: 4054) +#endif + +static int TestPointer(const PROC pTest) +{ + ptrdiff_t iTest; + if(!pTest) return 0; + iTest = (ptrdiff_t)pTest; + + if(iTest == 1 || iTest == 2 || iTest == 3 || iTest == -1) return 0; + + return 1; +} + +static PROC WinGetProcAddress(const char *name) +{ + HMODULE glMod = NULL; + PROC pFunc = wglGetProcAddress((LPCSTR)name); + if(TestPointer(pFunc)) + { + return pFunc; + } + glMod = GetModuleHandleA("OpenGL32.dll"); + return (PROC)GetProcAddress(glMod, (LPCSTR)name); +} + +#define IntGetProcAddress(name) WinGetProcAddress(name) +#else + #if defined(__APPLE__) + #define IntGetProcAddress(name) AppleGLGetProcAddress(name) + #else + #if defined(__sgi) || defined(__sun) + #define IntGetProcAddress(name) SunGetProcAddress(name) + #else /* GLX */ + #include + + #define IntGetProcAddress(name) (*glXGetProcAddressARB)((const GLubyte*)name) + #endif + #endif +#endif + +int ogl_ext_ARB_texture_compression = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_compression_s3tc = ogl_LOAD_FAILED; +int ogl_ext_ARB_buffer_storage = ogl_LOAD_FAILED; +int ogl_ext_ARB_shader_storage_buffer_object = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; + +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1DARB)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2DARB)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3DARB)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImageARB)(GLenum, GLint, GLvoid *) = NULL; + +static int Load_ARB_texture_compression() +{ + int numFailed = 0; + _ptrc_glCompressedTexImage1DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage1DARB"); + if(!_ptrc_glCompressedTexImage1DARB) numFailed++; + _ptrc_glCompressedTexImage2DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage2DARB"); + if(!_ptrc_glCompressedTexImage2DARB) numFailed++; + _ptrc_glCompressedTexImage3DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage3DARB"); + if(!_ptrc_glCompressedTexImage3DARB) numFailed++; + _ptrc_glCompressedTexSubImage1DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage1DARB"); + if(!_ptrc_glCompressedTexSubImage1DARB) numFailed++; + _ptrc_glCompressedTexSubImage2DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage2DARB"); + if(!_ptrc_glCompressedTexSubImage2DARB) numFailed++; + _ptrc_glCompressedTexSubImage3DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage3DARB"); + if(!_ptrc_glCompressedTexSubImage3DARB) numFailed++; + _ptrc_glGetCompressedTexImageARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLvoid *))IntGetProcAddress("glGetCompressedTexImageARB"); + if(!_ptrc_glGetCompressedTexImageARB) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum, GLsizeiptr, const void *, GLbitfield) = NULL; + +static int Load_ARB_buffer_storage() +{ + int numFailed = 0; + _ptrc_glBufferStorage = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const void *, GLbitfield))IntGetProcAddress("glBufferStorage"); + if(!_ptrc_glBufferStorage) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint, GLuint, GLuint) = NULL; + +static int Load_ARB_shader_storage_buffer_object() +{ + int numFailed = 0; + _ptrc_glShaderStorageBlockBinding = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glShaderStorageBlockBinding"); + if(!_ptrc_glShaderStorageBlockBinding) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnd)() = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFinish)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFlush)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *) = NULL; +const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum, GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum, GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum, GLenum, GLvoid **) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum, GLintptr, GLsizeiptr, GLvoid *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint, GLenum, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum, GLenum, GLint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint) = NULL; +void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum, GLenum) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint, GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)() = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei, const GLenum *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint, GLenum, GLint *) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint, GLint, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint, GLint, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint, GLenum, GLvoid **) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint, GLenum, GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint, GLenum, GLint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint, GLsizei, const GLchar *const*, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint, GLsizei, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint, GLsizei, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint, GLsizei, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint, GLsizei, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint, GLsizei, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint, GLsizei, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint, GLsizei, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint, GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint, GLsizei, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint, GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint, const GLbyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint, const GLubyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint, const GLushort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint, const GLbyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint, const GLdouble *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint, GLshort, GLshort, GLshort, GLshort) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint, const GLubyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint, const GLushort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint, GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum, GLint, GLfloat, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum, GLint, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum, GLint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum, GLint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)() = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum, GLenum, GLenum, GLuint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum, GLuint, GLboolean *) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum, GLuint, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *) = NULL; +const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum, GLenum, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint, GLint, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum, GLuint) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint) = NULL; +void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum, GLenum, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar *const*, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint, GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint, GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint, GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint, GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint, GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint, GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint, const GLbyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint, const GLshort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint, const GLubyte *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint, const GLushort *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint, GLsizei, const GLchar *const*, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum, GLenum, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint, GLuint, GLuint) = NULL; + +GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync, GLbitfield, GLuint64) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint) = NULL; +GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum, GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum, GLenum, GLuint, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum, GLuint, GLint64 *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum, GLint64 *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum, GLuint, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint, GLbitfield) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync, GLbitfield, GLuint64) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint, GLuint, GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei, GLuint *) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint, const GLchar *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint, GLenum, GLint64 *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint, GLenum, GLuint64 *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint, GLenum, GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint, GLenum, GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint, GLenum, GLint *) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint, GLenum) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint, GLenum, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint, GLenum, GLfloat) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint, GLenum, const GLfloat *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint, GLenum, GLint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint, GLenum, const GLint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint, GLenum, GLboolean, GLuint) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint, GLenum, GLboolean, const GLuint *) = NULL; + +static int Load_Version_3_3() +{ + int numFailed = 0; + _ptrc_glBegin = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBegin"); + if(!_ptrc_glBegin) numFailed++; + _ptrc_glEnd = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEnd"); + if(!_ptrc_glEnd) numFailed++; + _ptrc_glBlendFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glBlendFunc"); + if(!_ptrc_glBlendFunc) numFailed++; + _ptrc_glClear = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress("glClear"); + if(!_ptrc_glClear) numFailed++; + _ptrc_glClearColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glClearColor"); + if(!_ptrc_glClearColor) numFailed++; + _ptrc_glClearDepth = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glClearDepth"); + if(!_ptrc_glClearDepth) numFailed++; + _ptrc_glClearStencil = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glClearStencil"); + if(!_ptrc_glClearStencil) numFailed++; + _ptrc_glColorMask = (void (CODEGEN_FUNCPTR *)(GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress("glColorMask"); + if(!_ptrc_glColorMask) numFailed++; + _ptrc_glCullFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCullFace"); + if(!_ptrc_glCullFace) numFailed++; + _ptrc_glDepthFunc = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glDepthFunc"); + if(!_ptrc_glDepthFunc) numFailed++; + _ptrc_glDepthMask = (void (CODEGEN_FUNCPTR *)(GLboolean))IntGetProcAddress("glDepthMask"); + if(!_ptrc_glDepthMask) numFailed++; + _ptrc_glDepthRange = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glDepthRange"); + if(!_ptrc_glDepthRange) numFailed++; + _ptrc_glDisable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glDisable"); + if(!_ptrc_glDisable) numFailed++; + _ptrc_glDrawBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glDrawBuffer"); + if(!_ptrc_glDrawBuffer) numFailed++; + _ptrc_glEnable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glEnable"); + if(!_ptrc_glEnable) numFailed++; + _ptrc_glFinish = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glFinish"); + if(!_ptrc_glFinish) numFailed++; + _ptrc_glFlush = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glFlush"); + if(!_ptrc_glFlush) numFailed++; + _ptrc_glFrontFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glFrontFace"); + if(!_ptrc_glFrontFace) numFailed++; + _ptrc_glGetBooleanv = (void (CODEGEN_FUNCPTR *)(GLenum, GLboolean *))IntGetProcAddress("glGetBooleanv"); + if(!_ptrc_glGetBooleanv) numFailed++; + _ptrc_glGetDoublev = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble *))IntGetProcAddress("glGetDoublev"); + if(!_ptrc_glGetDoublev) numFailed++; + _ptrc_glGetError = (GLenum (CODEGEN_FUNCPTR *)())IntGetProcAddress("glGetError"); + if(!_ptrc_glGetError) numFailed++; + _ptrc_glGetFloatv = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat *))IntGetProcAddress("glGetFloatv"); + if(!_ptrc_glGetFloatv) numFailed++; + _ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress("glGetIntegerv"); + if(!_ptrc_glGetIntegerv) numFailed++; + _ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetString"); + if(!_ptrc_glGetString) numFailed++; + _ptrc_glGetTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLenum, GLvoid *))IntGetProcAddress("glGetTexImage"); + if(!_ptrc_glGetTexImage) numFailed++; + _ptrc_glGetTexLevelParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLfloat *))IntGetProcAddress("glGetTexLevelParameterfv"); + if(!_ptrc_glGetTexLevelParameterfv) numFailed++; + _ptrc_glGetTexLevelParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint *))IntGetProcAddress("glGetTexLevelParameteriv"); + if(!_ptrc_glGetTexLevelParameteriv) numFailed++; + _ptrc_glGetTexParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetTexParameterfv"); + if(!_ptrc_glGetTexParameterfv) numFailed++; + _ptrc_glGetTexParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetTexParameteriv"); + if(!_ptrc_glGetTexParameteriv) numFailed++; + _ptrc_glHint = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glHint"); + if(!_ptrc_glHint) numFailed++; + _ptrc_glIsEnabled = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glIsEnabled"); + if(!_ptrc_glIsEnabled) numFailed++; + _ptrc_glLineWidth = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glLineWidth"); + if(!_ptrc_glLineWidth) numFailed++; + _ptrc_glLogicOp = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glLogicOp"); + if(!_ptrc_glLogicOp) numFailed++; + _ptrc_glPixelStoref = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glPixelStoref"); + if(!_ptrc_glPixelStoref) numFailed++; + _ptrc_glPixelStorei = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glPixelStorei"); + if(!_ptrc_glPixelStorei) numFailed++; + _ptrc_glPointSize = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glPointSize"); + if(!_ptrc_glPointSize) numFailed++; + _ptrc_glPolygonMode = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glPolygonMode"); + if(!_ptrc_glPolygonMode) numFailed++; + _ptrc_glReadBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glReadBuffer"); + if(!_ptrc_glReadBuffer) numFailed++; + _ptrc_glReadPixels = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *))IntGetProcAddress("glReadPixels"); + if(!_ptrc_glReadPixels) numFailed++; + _ptrc_glScissor = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glScissor"); + if(!_ptrc_glScissor) numFailed++; + _ptrc_glStencilFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLuint))IntGetProcAddress("glStencilFunc"); + if(!_ptrc_glStencilFunc) numFailed++; + _ptrc_glStencilMask = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glStencilMask"); + if(!_ptrc_glStencilMask) numFailed++; + _ptrc_glStencilOp = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum))IntGetProcAddress("glStencilOp"); + if(!_ptrc_glStencilOp) numFailed++; + _ptrc_glTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexImage1D"); + if(!_ptrc_glTexImage1D) numFailed++; + _ptrc_glTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexImage2D"); + if(!_ptrc_glTexImage2D) numFailed++; + _ptrc_glTexParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress("glTexParameterf"); + if(!_ptrc_glTexParameterf) numFailed++; + _ptrc_glTexParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress("glTexParameterfv"); + if(!_ptrc_glTexParameterfv) numFailed++; + _ptrc_glTexParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress("glTexParameteri"); + if(!_ptrc_glTexParameteri) numFailed++; + _ptrc_glTexParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glTexParameteriv"); + if(!_ptrc_glTexParameteriv) numFailed++; + _ptrc_glViewport = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glViewport"); + if(!_ptrc_glViewport) numFailed++; + _ptrc_glBindTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindTexture"); + if(!_ptrc_glBindTexture) numFailed++; + _ptrc_glCopyTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint))IntGetProcAddress("glCopyTexImage1D"); + if(!_ptrc_glCopyTexImage1D) numFailed++; + _ptrc_glCopyTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint))IntGetProcAddress("glCopyTexImage2D"); + if(!_ptrc_glCopyTexImage2D) numFailed++; + _ptrc_glCopyTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei))IntGetProcAddress("glCopyTexSubImage1D"); + if(!_ptrc_glCopyTexSubImage1D) numFailed++; + _ptrc_glCopyTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glCopyTexSubImage2D"); + if(!_ptrc_glCopyTexSubImage2D) numFailed++; + _ptrc_glDeleteTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteTextures"); + if(!_ptrc_glDeleteTextures) numFailed++; + _ptrc_glDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei))IntGetProcAddress("glDrawArrays"); + if(!_ptrc_glDrawArrays) numFailed++; + _ptrc_glDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *))IntGetProcAddress("glDrawElements"); + if(!_ptrc_glDrawElements) numFailed++; + _ptrc_glGenTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenTextures"); + if(!_ptrc_glGenTextures) numFailed++; + _ptrc_glIsTexture = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsTexture"); + if(!_ptrc_glIsTexture) numFailed++; + _ptrc_glPolygonOffset = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glPolygonOffset"); + if(!_ptrc_glPolygonOffset) numFailed++; + _ptrc_glTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexSubImage1D"); + if(!_ptrc_glTexSubImage1D) numFailed++; + _ptrc_glTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexSubImage2D"); + if(!_ptrc_glTexSubImage2D) numFailed++; + _ptrc_glBlendColor = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glBlendColor"); + if(!_ptrc_glBlendColor) numFailed++; + _ptrc_glBlendEquation = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBlendEquation"); + if(!_ptrc_glBlendEquation) numFailed++; + _ptrc_glCopyTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glCopyTexSubImage3D"); + if(!_ptrc_glCopyTexSubImage3D) numFailed++; + _ptrc_glDrawRangeElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))IntGetProcAddress("glDrawRangeElements"); + if(!_ptrc_glDrawRangeElements) numFailed++; + _ptrc_glTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexImage3D"); + if(!_ptrc_glTexImage3D) numFailed++; + _ptrc_glTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *))IntGetProcAddress("glTexSubImage3D"); + if(!_ptrc_glTexSubImage3D) numFailed++; + _ptrc_glActiveTexture = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glActiveTexture"); + if(!_ptrc_glActiveTexture) numFailed++; + _ptrc_glCompressedTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage1D"); + if(!_ptrc_glCompressedTexImage1D) numFailed++; + _ptrc_glCompressedTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage2D"); + if(!_ptrc_glCompressedTexImage2D) numFailed++; + _ptrc_glCompressedTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexImage3D"); + if(!_ptrc_glCompressedTexImage3D) numFailed++; + _ptrc_glCompressedTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage1D"); + if(!_ptrc_glCompressedTexSubImage1D) numFailed++; + _ptrc_glCompressedTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage2D"); + if(!_ptrc_glCompressedTexSubImage2D) numFailed++; + _ptrc_glCompressedTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glCompressedTexSubImage3D"); + if(!_ptrc_glCompressedTexSubImage3D) numFailed++; + _ptrc_glGetCompressedTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLvoid *))IntGetProcAddress("glGetCompressedTexImage"); + if(!_ptrc_glGetCompressedTexImage) numFailed++; + _ptrc_glSampleCoverage = (void (CODEGEN_FUNCPTR *)(GLfloat, GLboolean))IntGetProcAddress("glSampleCoverage"); + if(!_ptrc_glSampleCoverage) numFailed++; + _ptrc_glBlendFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress("glBlendFuncSeparate"); + if(!_ptrc_glBlendFuncSeparate) numFailed++; + _ptrc_glMultiDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *, const GLsizei *, GLsizei))IntGetProcAddress("glMultiDrawArrays"); + if(!_ptrc_glMultiDrawArrays) numFailed++; + _ptrc_glMultiDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei))IntGetProcAddress("glMultiDrawElements"); + if(!_ptrc_glMultiDrawElements) numFailed++; + _ptrc_glPointParameterf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glPointParameterf"); + if(!_ptrc_glPointParameterf) numFailed++; + _ptrc_glPointParameterfv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glPointParameterfv"); + if(!_ptrc_glPointParameterfv) numFailed++; + _ptrc_glPointParameteri = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glPointParameteri"); + if(!_ptrc_glPointParameteri) numFailed++; + _ptrc_glPointParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glPointParameteriv"); + if(!_ptrc_glPointParameteriv) numFailed++; + _ptrc_glBeginQuery = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBeginQuery"); + if(!_ptrc_glBeginQuery) numFailed++; + _ptrc_glBindBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindBuffer"); + if(!_ptrc_glBindBuffer) numFailed++; + _ptrc_glBufferData = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizeiptr, const GLvoid *, GLenum))IntGetProcAddress("glBufferData"); + if(!_ptrc_glBufferData) numFailed++; + _ptrc_glBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, const GLvoid *))IntGetProcAddress("glBufferSubData"); + if(!_ptrc_glBufferSubData) numFailed++; + _ptrc_glDeleteBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteBuffers"); + if(!_ptrc_glDeleteBuffers) numFailed++; + _ptrc_glDeleteQueries = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteQueries"); + if(!_ptrc_glDeleteQueries) numFailed++; + _ptrc_glEndQuery = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glEndQuery"); + if(!_ptrc_glEndQuery) numFailed++; + _ptrc_glGenBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenBuffers"); + if(!_ptrc_glGenBuffers) numFailed++; + _ptrc_glGenQueries = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenQueries"); + if(!_ptrc_glGenQueries) numFailed++; + _ptrc_glGetBufferParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetBufferParameteriv"); + if(!_ptrc_glGetBufferParameteriv) numFailed++; + _ptrc_glGetBufferPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLvoid **))IntGetProcAddress("glGetBufferPointerv"); + if(!_ptrc_glGetBufferPointerv) numFailed++; + _ptrc_glGetBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, GLvoid *))IntGetProcAddress("glGetBufferSubData"); + if(!_ptrc_glGetBufferSubData) numFailed++; + _ptrc_glGetQueryObjectiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetQueryObjectiv"); + if(!_ptrc_glGetQueryObjectiv) numFailed++; + _ptrc_glGetQueryObjectuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress("glGetQueryObjectuiv"); + if(!_ptrc_glGetQueryObjectuiv) numFailed++; + _ptrc_glGetQueryiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetQueryiv"); + if(!_ptrc_glGetQueryiv) numFailed++; + _ptrc_glIsBuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsBuffer"); + if(!_ptrc_glIsBuffer) numFailed++; + _ptrc_glIsQuery = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsQuery"); + if(!_ptrc_glIsQuery) numFailed++; + _ptrc_glMapBuffer = (void * (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glMapBuffer"); + if(!_ptrc_glMapBuffer) numFailed++; + _ptrc_glUnmapBuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glUnmapBuffer"); + if(!_ptrc_glUnmapBuffer) numFailed++; + _ptrc_glAttachShader = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress("glAttachShader"); + if(!_ptrc_glAttachShader) numFailed++; + _ptrc_glBindAttribLocation = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, const GLchar *))IntGetProcAddress("glBindAttribLocation"); + if(!_ptrc_glBindAttribLocation) numFailed++; + _ptrc_glBlendEquationSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glBlendEquationSeparate"); + if(!_ptrc_glBlendEquationSeparate) numFailed++; + _ptrc_glCompileShader = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glCompileShader"); + if(!_ptrc_glCompileShader) numFailed++; + _ptrc_glCreateProgram = (GLuint (CODEGEN_FUNCPTR *)())IntGetProcAddress("glCreateProgram"); + if(!_ptrc_glCreateProgram) numFailed++; + _ptrc_glCreateShader = (GLuint (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCreateShader"); + if(!_ptrc_glCreateShader) numFailed++; + _ptrc_glDeleteProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glDeleteProgram"); + if(!_ptrc_glDeleteProgram) numFailed++; + _ptrc_glDeleteShader = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glDeleteShader"); + if(!_ptrc_glDeleteShader) numFailed++; + _ptrc_glDetachShader = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress("glDetachShader"); + if(!_ptrc_glDetachShader) numFailed++; + _ptrc_glDisableVertexAttribArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glDisableVertexAttribArray"); + if(!_ptrc_glDisableVertexAttribArray) numFailed++; + _ptrc_glDrawBuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLenum *))IntGetProcAddress("glDrawBuffers"); + if(!_ptrc_glDrawBuffers) numFailed++; + _ptrc_glEnableVertexAttribArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glEnableVertexAttribArray"); + if(!_ptrc_glEnableVertexAttribArray) numFailed++; + _ptrc_glGetActiveAttrib = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *))IntGetProcAddress("glGetActiveAttrib"); + if(!_ptrc_glGetActiveAttrib) numFailed++; + _ptrc_glGetActiveUniform = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *))IntGetProcAddress("glGetActiveUniform"); + if(!_ptrc_glGetActiveUniform) numFailed++; + _ptrc_glGetAttachedShaders = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLuint *))IntGetProcAddress("glGetAttachedShaders"); + if(!_ptrc_glGetAttachedShaders) numFailed++; + _ptrc_glGetAttribLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress("glGetAttribLocation"); + if(!_ptrc_glGetAttribLocation) numFailed++; + _ptrc_glGetProgramInfoLog = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetProgramInfoLog"); + if(!_ptrc_glGetProgramInfoLog) numFailed++; + _ptrc_glGetProgramiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetProgramiv"); + if(!_ptrc_glGetProgramiv) numFailed++; + _ptrc_glGetShaderInfoLog = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetShaderInfoLog"); + if(!_ptrc_glGetShaderInfoLog) numFailed++; + _ptrc_glGetShaderSource = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetShaderSource"); + if(!_ptrc_glGetShaderSource) numFailed++; + _ptrc_glGetShaderiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetShaderiv"); + if(!_ptrc_glGetShaderiv) numFailed++; + _ptrc_glGetUniformLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress("glGetUniformLocation"); + if(!_ptrc_glGetUniformLocation) numFailed++; + _ptrc_glGetUniformfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLfloat *))IntGetProcAddress("glGetUniformfv"); + if(!_ptrc_glGetUniformfv) numFailed++; + _ptrc_glGetUniformiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint *))IntGetProcAddress("glGetUniformiv"); + if(!_ptrc_glGetUniformiv) numFailed++; + _ptrc_glGetVertexAttribPointerv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLvoid **))IntGetProcAddress("glGetVertexAttribPointerv"); + if(!_ptrc_glGetVertexAttribPointerv) numFailed++; + _ptrc_glGetVertexAttribdv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLdouble *))IntGetProcAddress("glGetVertexAttribdv"); + if(!_ptrc_glGetVertexAttribdv) numFailed++; + _ptrc_glGetVertexAttribfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat *))IntGetProcAddress("glGetVertexAttribfv"); + if(!_ptrc_glGetVertexAttribfv) numFailed++; + _ptrc_glGetVertexAttribiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetVertexAttribiv"); + if(!_ptrc_glGetVertexAttribiv) numFailed++; + _ptrc_glIsProgram = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsProgram"); + if(!_ptrc_glIsProgram) numFailed++; + _ptrc_glIsShader = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsShader"); + if(!_ptrc_glIsShader) numFailed++; + _ptrc_glLinkProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glLinkProgram"); + if(!_ptrc_glLinkProgram) numFailed++; + _ptrc_glShaderSource = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, const GLint *))IntGetProcAddress("glShaderSource"); + if(!_ptrc_glShaderSource) numFailed++; + _ptrc_glStencilFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint, GLuint))IntGetProcAddress("glStencilFuncSeparate"); + if(!_ptrc_glStencilFuncSeparate) numFailed++; + _ptrc_glStencilMaskSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glStencilMaskSeparate"); + if(!_ptrc_glStencilMaskSeparate) numFailed++; + _ptrc_glStencilOpSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress("glStencilOpSeparate"); + if(!_ptrc_glStencilOpSeparate) numFailed++; + _ptrc_glUniform1f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat))IntGetProcAddress("glUniform1f"); + if(!_ptrc_glUniform1f) numFailed++; + _ptrc_glUniform1fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform1fv"); + if(!_ptrc_glUniform1fv) numFailed++; + _ptrc_glUniform1i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glUniform1i"); + if(!_ptrc_glUniform1i) numFailed++; + _ptrc_glUniform1iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform1iv"); + if(!_ptrc_glUniform1iv) numFailed++; + _ptrc_glUniform2f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat))IntGetProcAddress("glUniform2f"); + if(!_ptrc_glUniform2f) numFailed++; + _ptrc_glUniform2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform2fv"); + if(!_ptrc_glUniform2fv) numFailed++; + _ptrc_glUniform2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glUniform2i"); + if(!_ptrc_glUniform2i) numFailed++; + _ptrc_glUniform2iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform2iv"); + if(!_ptrc_glUniform2iv) numFailed++; + _ptrc_glUniform3f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glUniform3f"); + if(!_ptrc_glUniform3f) numFailed++; + _ptrc_glUniform3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform3fv"); + if(!_ptrc_glUniform3fv) numFailed++; + _ptrc_glUniform3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glUniform3i"); + if(!_ptrc_glUniform3i) numFailed++; + _ptrc_glUniform3iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform3iv"); + if(!_ptrc_glUniform3iv) numFailed++; + _ptrc_glUniform4f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glUniform4f"); + if(!_ptrc_glUniform4f) numFailed++; + _ptrc_glUniform4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLfloat *))IntGetProcAddress("glUniform4fv"); + if(!_ptrc_glUniform4fv) numFailed++; + _ptrc_glUniform4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint))IntGetProcAddress("glUniform4i"); + if(!_ptrc_glUniform4i) numFailed++; + _ptrc_glUniform4iv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLint *))IntGetProcAddress("glUniform4iv"); + if(!_ptrc_glUniform4iv) numFailed++; + _ptrc_glUniformMatrix2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix2fv"); + if(!_ptrc_glUniformMatrix2fv) numFailed++; + _ptrc_glUniformMatrix3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix3fv"); + if(!_ptrc_glUniformMatrix3fv) numFailed++; + _ptrc_glUniformMatrix4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix4fv"); + if(!_ptrc_glUniformMatrix4fv) numFailed++; + _ptrc_glUseProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glUseProgram"); + if(!_ptrc_glUseProgram) numFailed++; + _ptrc_glValidateProgram = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glValidateProgram"); + if(!_ptrc_glValidateProgram) numFailed++; + _ptrc_glVertexAttrib1d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble))IntGetProcAddress("glVertexAttrib1d"); + if(!_ptrc_glVertexAttrib1d) numFailed++; + _ptrc_glVertexAttrib1dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress("glVertexAttrib1dv"); + if(!_ptrc_glVertexAttrib1dv) numFailed++; + _ptrc_glVertexAttrib1f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat))IntGetProcAddress("glVertexAttrib1f"); + if(!_ptrc_glVertexAttrib1f) numFailed++; + _ptrc_glVertexAttrib1fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress("glVertexAttrib1fv"); + if(!_ptrc_glVertexAttrib1fv) numFailed++; + _ptrc_glVertexAttrib1s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort))IntGetProcAddress("glVertexAttrib1s"); + if(!_ptrc_glVertexAttrib1s) numFailed++; + _ptrc_glVertexAttrib1sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttrib1sv"); + if(!_ptrc_glVertexAttrib1sv) numFailed++; + _ptrc_glVertexAttrib2d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble))IntGetProcAddress("glVertexAttrib2d"); + if(!_ptrc_glVertexAttrib2d) numFailed++; + _ptrc_glVertexAttrib2dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress("glVertexAttrib2dv"); + if(!_ptrc_glVertexAttrib2dv) numFailed++; + _ptrc_glVertexAttrib2f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat))IntGetProcAddress("glVertexAttrib2f"); + if(!_ptrc_glVertexAttrib2f) numFailed++; + _ptrc_glVertexAttrib2fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress("glVertexAttrib2fv"); + if(!_ptrc_glVertexAttrib2fv) numFailed++; + _ptrc_glVertexAttrib2s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort))IntGetProcAddress("glVertexAttrib2s"); + if(!_ptrc_glVertexAttrib2s) numFailed++; + _ptrc_glVertexAttrib2sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttrib2sv"); + if(!_ptrc_glVertexAttrib2sv) numFailed++; + _ptrc_glVertexAttrib3d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glVertexAttrib3d"); + if(!_ptrc_glVertexAttrib3d) numFailed++; + _ptrc_glVertexAttrib3dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress("glVertexAttrib3dv"); + if(!_ptrc_glVertexAttrib3dv) numFailed++; + _ptrc_glVertexAttrib3f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glVertexAttrib3f"); + if(!_ptrc_glVertexAttrib3f) numFailed++; + _ptrc_glVertexAttrib3fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress("glVertexAttrib3fv"); + if(!_ptrc_glVertexAttrib3fv) numFailed++; + _ptrc_glVertexAttrib3s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort))IntGetProcAddress("glVertexAttrib3s"); + if(!_ptrc_glVertexAttrib3s) numFailed++; + _ptrc_glVertexAttrib3sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttrib3sv"); + if(!_ptrc_glVertexAttrib3sv) numFailed++; + _ptrc_glVertexAttrib4Nbv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress("glVertexAttrib4Nbv"); + if(!_ptrc_glVertexAttrib4Nbv) numFailed++; + _ptrc_glVertexAttrib4Niv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttrib4Niv"); + if(!_ptrc_glVertexAttrib4Niv) numFailed++; + _ptrc_glVertexAttrib4Nsv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttrib4Nsv"); + if(!_ptrc_glVertexAttrib4Nsv) numFailed++; + _ptrc_glVertexAttrib4Nub = (void (CODEGEN_FUNCPTR *)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte))IntGetProcAddress("glVertexAttrib4Nub"); + if(!_ptrc_glVertexAttrib4Nub) numFailed++; + _ptrc_glVertexAttrib4Nubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress("glVertexAttrib4Nubv"); + if(!_ptrc_glVertexAttrib4Nubv) numFailed++; + _ptrc_glVertexAttrib4Nuiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttrib4Nuiv"); + if(!_ptrc_glVertexAttrib4Nuiv) numFailed++; + _ptrc_glVertexAttrib4Nusv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress("glVertexAttrib4Nusv"); + if(!_ptrc_glVertexAttrib4Nusv) numFailed++; + _ptrc_glVertexAttrib4bv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress("glVertexAttrib4bv"); + if(!_ptrc_glVertexAttrib4bv) numFailed++; + _ptrc_glVertexAttrib4d = (void (CODEGEN_FUNCPTR *)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glVertexAttrib4d"); + if(!_ptrc_glVertexAttrib4d) numFailed++; + _ptrc_glVertexAttrib4dv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLdouble *))IntGetProcAddress("glVertexAttrib4dv"); + if(!_ptrc_glVertexAttrib4dv) numFailed++; + _ptrc_glVertexAttrib4f = (void (CODEGEN_FUNCPTR *)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glVertexAttrib4f"); + if(!_ptrc_glVertexAttrib4f) numFailed++; + _ptrc_glVertexAttrib4fv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLfloat *))IntGetProcAddress("glVertexAttrib4fv"); + if(!_ptrc_glVertexAttrib4fv) numFailed++; + _ptrc_glVertexAttrib4iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttrib4iv"); + if(!_ptrc_glVertexAttrib4iv) numFailed++; + _ptrc_glVertexAttrib4s = (void (CODEGEN_FUNCPTR *)(GLuint, GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glVertexAttrib4s"); + if(!_ptrc_glVertexAttrib4s) numFailed++; + _ptrc_glVertexAttrib4sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttrib4sv"); + if(!_ptrc_glVertexAttrib4sv) numFailed++; + _ptrc_glVertexAttrib4ubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress("glVertexAttrib4ubv"); + if(!_ptrc_glVertexAttrib4ubv) numFailed++; + _ptrc_glVertexAttrib4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttrib4uiv"); + if(!_ptrc_glVertexAttrib4uiv) numFailed++; + _ptrc_glVertexAttrib4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress("glVertexAttrib4usv"); + if(!_ptrc_glVertexAttrib4usv) numFailed++; + _ptrc_glVertexAttribPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *))IntGetProcAddress("glVertexAttribPointer"); + if(!_ptrc_glVertexAttribPointer) numFailed++; + _ptrc_glUniformMatrix2x3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix2x3fv"); + if(!_ptrc_glUniformMatrix2x3fv) numFailed++; + _ptrc_glUniformMatrix2x4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix2x4fv"); + if(!_ptrc_glUniformMatrix2x4fv) numFailed++; + _ptrc_glUniformMatrix3x2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix3x2fv"); + if(!_ptrc_glUniformMatrix3x2fv) numFailed++; + _ptrc_glUniformMatrix3x4fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix3x4fv"); + if(!_ptrc_glUniformMatrix3x4fv) numFailed++; + _ptrc_glUniformMatrix4x2fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix4x2fv"); + if(!_ptrc_glUniformMatrix4x2fv) numFailed++; + _ptrc_glUniformMatrix4x3fv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, GLboolean, const GLfloat *))IntGetProcAddress("glUniformMatrix4x3fv"); + if(!_ptrc_glUniformMatrix4x3fv) numFailed++; + _ptrc_glBeginConditionalRender = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress("glBeginConditionalRender"); + if(!_ptrc_glBeginConditionalRender) numFailed++; + _ptrc_glBeginTransformFeedback = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBeginTransformFeedback"); + if(!_ptrc_glBeginTransformFeedback) numFailed++; + _ptrc_glBindBufferBase = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint))IntGetProcAddress("glBindBufferBase"); + if(!_ptrc_glBindBufferBase) numFailed++; + _ptrc_glBindBufferRange = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr))IntGetProcAddress("glBindBufferRange"); + if(!_ptrc_glBindBufferRange) numFailed++; + _ptrc_glBindFragDataLocation = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, const GLchar *))IntGetProcAddress("glBindFragDataLocation"); + if(!_ptrc_glBindFragDataLocation) numFailed++; + _ptrc_glBindFramebuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindFramebuffer"); + if(!_ptrc_glBindFramebuffer) numFailed++; + _ptrc_glBindRenderbuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindRenderbuffer"); + if(!_ptrc_glBindRenderbuffer) numFailed++; + _ptrc_glBindVertexArray = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glBindVertexArray"); + if(!_ptrc_glBindVertexArray) numFailed++; + _ptrc_glBlitFramebuffer = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum))IntGetProcAddress("glBlitFramebuffer"); + if(!_ptrc_glBlitFramebuffer) numFailed++; + _ptrc_glCheckFramebufferStatus = (GLenum (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCheckFramebufferStatus"); + if(!_ptrc_glCheckFramebufferStatus) numFailed++; + _ptrc_glClampColor = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glClampColor"); + if(!_ptrc_glClampColor) numFailed++; + _ptrc_glClearBufferfi = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLfloat, GLint))IntGetProcAddress("glClearBufferfi"); + if(!_ptrc_glClearBufferfi) numFailed++; + _ptrc_glClearBufferfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLfloat *))IntGetProcAddress("glClearBufferfv"); + if(!_ptrc_glClearBufferfv) numFailed++; + _ptrc_glClearBufferiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLint *))IntGetProcAddress("glClearBufferiv"); + if(!_ptrc_glClearBufferiv) numFailed++; + _ptrc_glClearBufferuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, const GLuint *))IntGetProcAddress("glClearBufferuiv"); + if(!_ptrc_glClearBufferuiv) numFailed++; + _ptrc_glColorMaski = (void (CODEGEN_FUNCPTR *)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress("glColorMaski"); + if(!_ptrc_glColorMaski) numFailed++; + _ptrc_glDeleteFramebuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteFramebuffers"); + if(!_ptrc_glDeleteFramebuffers) numFailed++; + _ptrc_glDeleteRenderbuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteRenderbuffers"); + if(!_ptrc_glDeleteRenderbuffers) numFailed++; + _ptrc_glDeleteVertexArrays = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteVertexArrays"); + if(!_ptrc_glDeleteVertexArrays) numFailed++; + _ptrc_glDisablei = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glDisablei"); + if(!_ptrc_glDisablei) numFailed++; + _ptrc_glEnablei = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glEnablei"); + if(!_ptrc_glEnablei) numFailed++; + _ptrc_glEndConditionalRender = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEndConditionalRender"); + if(!_ptrc_glEndConditionalRender) numFailed++; + _ptrc_glEndTransformFeedback = (void (CODEGEN_FUNCPTR *)())IntGetProcAddress("glEndTransformFeedback"); + if(!_ptrc_glEndTransformFeedback) numFailed++; + _ptrc_glFlushMappedBufferRange = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr))IntGetProcAddress("glFlushMappedBufferRange"); + if(!_ptrc_glFlushMappedBufferRange) numFailed++; + _ptrc_glFramebufferRenderbuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint))IntGetProcAddress("glFramebufferRenderbuffer"); + if(!_ptrc_glFramebufferRenderbuffer) numFailed++; + _ptrc_glFramebufferTexture1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture1D"); + if(!_ptrc_glFramebufferTexture1D) numFailed++; + _ptrc_glFramebufferTexture2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture2D"); + if(!_ptrc_glFramebufferTexture2D) numFailed++; + _ptrc_glFramebufferTexture3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress("glFramebufferTexture3D"); + if(!_ptrc_glFramebufferTexture3D) numFailed++; + _ptrc_glFramebufferTextureLayer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress("glFramebufferTextureLayer"); + if(!_ptrc_glFramebufferTextureLayer) numFailed++; + _ptrc_glGenFramebuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenFramebuffers"); + if(!_ptrc_glGenFramebuffers) numFailed++; + _ptrc_glGenRenderbuffers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenRenderbuffers"); + if(!_ptrc_glGenRenderbuffers) numFailed++; + _ptrc_glGenVertexArrays = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenVertexArrays"); + if(!_ptrc_glGenVertexArrays) numFailed++; + _ptrc_glGenerateMipmap = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGenerateMipmap"); + if(!_ptrc_glGenerateMipmap) numFailed++; + _ptrc_glGetBooleani_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLboolean *))IntGetProcAddress("glGetBooleani_v"); + if(!_ptrc_glGetBooleani_v) numFailed++; + _ptrc_glGetFragDataLocation = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress("glGetFragDataLocation"); + if(!_ptrc_glGetFragDataLocation) numFailed++; + _ptrc_glGetFramebufferAttachmentParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLint *))IntGetProcAddress("glGetFramebufferAttachmentParameteriv"); + if(!_ptrc_glGetFramebufferAttachmentParameteriv) numFailed++; + _ptrc_glGetIntegeri_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLint *))IntGetProcAddress("glGetIntegeri_v"); + if(!_ptrc_glGetIntegeri_v) numFailed++; + _ptrc_glGetRenderbufferParameteriv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetRenderbufferParameteriv"); + if(!_ptrc_glGetRenderbufferParameteriv) numFailed++; + _ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi"); + if(!_ptrc_glGetStringi) numFailed++; + _ptrc_glGetTexParameterIiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetTexParameterIiv"); + if(!_ptrc_glGetTexParameterIiv) numFailed++; + _ptrc_glGetTexParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint *))IntGetProcAddress("glGetTexParameterIuiv"); + if(!_ptrc_glGetTexParameterIuiv) numFailed++; + _ptrc_glGetTransformFeedbackVarying = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *))IntGetProcAddress("glGetTransformFeedbackVarying"); + if(!_ptrc_glGetTransformFeedbackVarying) numFailed++; + _ptrc_glGetUniformuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLuint *))IntGetProcAddress("glGetUniformuiv"); + if(!_ptrc_glGetUniformuiv) numFailed++; + _ptrc_glGetVertexAttribIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetVertexAttribIiv"); + if(!_ptrc_glGetVertexAttribIiv) numFailed++; + _ptrc_glGetVertexAttribIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress("glGetVertexAttribIuiv"); + if(!_ptrc_glGetVertexAttribIuiv) numFailed++; + _ptrc_glIsEnabledi = (GLboolean (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glIsEnabledi"); + if(!_ptrc_glIsEnabledi) numFailed++; + _ptrc_glIsFramebuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsFramebuffer"); + if(!_ptrc_glIsFramebuffer) numFailed++; + _ptrc_glIsRenderbuffer = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsRenderbuffer"); + if(!_ptrc_glIsRenderbuffer) numFailed++; + _ptrc_glIsVertexArray = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsVertexArray"); + if(!_ptrc_glIsVertexArray) numFailed++; + _ptrc_glMapBufferRange = (void * (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, GLbitfield))IntGetProcAddress("glMapBufferRange"); + if(!_ptrc_glMapBufferRange) numFailed++; + _ptrc_glRenderbufferStorage = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLsizei, GLsizei))IntGetProcAddress("glRenderbufferStorage"); + if(!_ptrc_glRenderbufferStorage) numFailed++; + _ptrc_glRenderbufferStorageMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))IntGetProcAddress("glRenderbufferStorageMultisample"); + if(!_ptrc_glRenderbufferStorageMultisample) numFailed++; + _ptrc_glTexParameterIiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glTexParameterIiv"); + if(!_ptrc_glTexParameterIiv) numFailed++; + _ptrc_glTexParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLuint *))IntGetProcAddress("glTexParameterIuiv"); + if(!_ptrc_glTexParameterIuiv) numFailed++; + _ptrc_glTransformFeedbackVaryings = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, GLenum))IntGetProcAddress("glTransformFeedbackVaryings"); + if(!_ptrc_glTransformFeedbackVaryings) numFailed++; + _ptrc_glUniform1ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint))IntGetProcAddress("glUniform1ui"); + if(!_ptrc_glUniform1ui) numFailed++; + _ptrc_glUniform1uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress("glUniform1uiv"); + if(!_ptrc_glUniform1uiv) numFailed++; + _ptrc_glUniform2ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint))IntGetProcAddress("glUniform2ui"); + if(!_ptrc_glUniform2ui) numFailed++; + _ptrc_glUniform2uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress("glUniform2uiv"); + if(!_ptrc_glUniform2uiv) numFailed++; + _ptrc_glUniform3ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint, GLuint))IntGetProcAddress("glUniform3ui"); + if(!_ptrc_glUniform3ui) numFailed++; + _ptrc_glUniform3uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress("glUniform3uiv"); + if(!_ptrc_glUniform3uiv) numFailed++; + _ptrc_glUniform4ui = (void (CODEGEN_FUNCPTR *)(GLint, GLuint, GLuint, GLuint, GLuint))IntGetProcAddress("glUniform4ui"); + if(!_ptrc_glUniform4ui) numFailed++; + _ptrc_glUniform4uiv = (void (CODEGEN_FUNCPTR *)(GLint, GLsizei, const GLuint *))IntGetProcAddress("glUniform4uiv"); + if(!_ptrc_glUniform4uiv) numFailed++; + _ptrc_glVertexAttribI1i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint))IntGetProcAddress("glVertexAttribI1i"); + if(!_ptrc_glVertexAttribI1i) numFailed++; + _ptrc_glVertexAttribI1iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttribI1iv"); + if(!_ptrc_glVertexAttribI1iv) numFailed++; + _ptrc_glVertexAttribI1ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress("glVertexAttribI1ui"); + if(!_ptrc_glVertexAttribI1ui) numFailed++; + _ptrc_glVertexAttribI1uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttribI1uiv"); + if(!_ptrc_glVertexAttribI1uiv) numFailed++; + _ptrc_glVertexAttribI2i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint))IntGetProcAddress("glVertexAttribI2i"); + if(!_ptrc_glVertexAttribI2i) numFailed++; + _ptrc_glVertexAttribI2iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttribI2iv"); + if(!_ptrc_glVertexAttribI2iv) numFailed++; + _ptrc_glVertexAttribI2ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glVertexAttribI2ui"); + if(!_ptrc_glVertexAttribI2ui) numFailed++; + _ptrc_glVertexAttribI2uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttribI2uiv"); + if(!_ptrc_glVertexAttribI2uiv) numFailed++; + _ptrc_glVertexAttribI3i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint))IntGetProcAddress("glVertexAttribI3i"); + if(!_ptrc_glVertexAttribI3i) numFailed++; + _ptrc_glVertexAttribI3iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttribI3iv"); + if(!_ptrc_glVertexAttribI3iv) numFailed++; + _ptrc_glVertexAttribI3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint))IntGetProcAddress("glVertexAttribI3ui"); + if(!_ptrc_glVertexAttribI3ui) numFailed++; + _ptrc_glVertexAttribI3uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttribI3uiv"); + if(!_ptrc_glVertexAttribI3uiv) numFailed++; + _ptrc_glVertexAttribI4bv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLbyte *))IntGetProcAddress("glVertexAttribI4bv"); + if(!_ptrc_glVertexAttribI4bv) numFailed++; + _ptrc_glVertexAttribI4i = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint, GLint))IntGetProcAddress("glVertexAttribI4i"); + if(!_ptrc_glVertexAttribI4i) numFailed++; + _ptrc_glVertexAttribI4iv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLint *))IntGetProcAddress("glVertexAttribI4iv"); + if(!_ptrc_glVertexAttribI4iv) numFailed++; + _ptrc_glVertexAttribI4sv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLshort *))IntGetProcAddress("glVertexAttribI4sv"); + if(!_ptrc_glVertexAttribI4sv) numFailed++; + _ptrc_glVertexAttribI4ubv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLubyte *))IntGetProcAddress("glVertexAttribI4ubv"); + if(!_ptrc_glVertexAttribI4ubv) numFailed++; + _ptrc_glVertexAttribI4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint, GLuint))IntGetProcAddress("glVertexAttribI4ui"); + if(!_ptrc_glVertexAttribI4ui) numFailed++; + _ptrc_glVertexAttribI4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLuint *))IntGetProcAddress("glVertexAttribI4uiv"); + if(!_ptrc_glVertexAttribI4uiv) numFailed++; + _ptrc_glVertexAttribI4usv = (void (CODEGEN_FUNCPTR *)(GLuint, const GLushort *))IntGetProcAddress("glVertexAttribI4usv"); + if(!_ptrc_glVertexAttribI4usv) numFailed++; + _ptrc_glVertexAttribIPointer = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLenum, GLsizei, const GLvoid *))IntGetProcAddress("glVertexAttribIPointer"); + if(!_ptrc_glVertexAttribIPointer) numFailed++; + _ptrc_glCopyBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr))IntGetProcAddress("glCopyBufferSubData"); + if(!_ptrc_glCopyBufferSubData) numFailed++; + _ptrc_glDrawArraysInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei, GLsizei))IntGetProcAddress("glDrawArraysInstanced"); + if(!_ptrc_glDrawArraysInstanced) numFailed++; + _ptrc_glDrawElementsInstanced = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei))IntGetProcAddress("glDrawElementsInstanced"); + if(!_ptrc_glDrawElementsInstanced) numFailed++; + _ptrc_glGetActiveUniformBlockName = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetActiveUniformBlockName"); + if(!_ptrc_glGetActiveUniformBlockName) numFailed++; + _ptrc_glGetActiveUniformBlockiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLenum, GLint *))IntGetProcAddress("glGetActiveUniformBlockiv"); + if(!_ptrc_glGetActiveUniformBlockiv) numFailed++; + _ptrc_glGetActiveUniformName = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetActiveUniformName"); + if(!_ptrc_glGetActiveUniformName) numFailed++; + _ptrc_glGetActiveUniformsiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLuint *, GLenum, GLint *))IntGetProcAddress("glGetActiveUniformsiv"); + if(!_ptrc_glGetActiveUniformsiv) numFailed++; + _ptrc_glGetUniformBlockIndex = (GLuint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress("glGetUniformBlockIndex"); + if(!_ptrc_glGetUniformBlockIndex) numFailed++; + _ptrc_glGetUniformIndices = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei, const GLchar *const*, GLuint *))IntGetProcAddress("glGetUniformIndices"); + if(!_ptrc_glGetUniformIndices) numFailed++; + _ptrc_glPrimitiveRestartIndex = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glPrimitiveRestartIndex"); + if(!_ptrc_glPrimitiveRestartIndex) numFailed++; + _ptrc_glTexBuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint))IntGetProcAddress("glTexBuffer"); + if(!_ptrc_glTexBuffer) numFailed++; + _ptrc_glUniformBlockBinding = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glUniformBlockBinding"); + if(!_ptrc_glUniformBlockBinding) numFailed++; + _ptrc_glClientWaitSync = (GLenum (CODEGEN_FUNCPTR *)(GLsync, GLbitfield, GLuint64))IntGetProcAddress("glClientWaitSync"); + if(!_ptrc_glClientWaitSync) numFailed++; + _ptrc_glDeleteSync = (void (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress("glDeleteSync"); + if(!_ptrc_glDeleteSync) numFailed++; + _ptrc_glDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLint))IntGetProcAddress("glDrawElementsBaseVertex"); + if(!_ptrc_glDrawElementsBaseVertex) numFailed++; + _ptrc_glDrawElementsInstancedBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint))IntGetProcAddress("glDrawElementsInstancedBaseVertex"); + if(!_ptrc_glDrawElementsInstancedBaseVertex) numFailed++; + _ptrc_glDrawRangeElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint))IntGetProcAddress("glDrawRangeElementsBaseVertex"); + if(!_ptrc_glDrawRangeElementsBaseVertex) numFailed++; + _ptrc_glFenceSync = (GLsync (CODEGEN_FUNCPTR *)(GLenum, GLbitfield))IntGetProcAddress("glFenceSync"); + if(!_ptrc_glFenceSync) numFailed++; + _ptrc_glFramebufferTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture"); + if(!_ptrc_glFramebufferTexture) numFailed++; + _ptrc_glGetBufferParameteri64v = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint64 *))IntGetProcAddress("glGetBufferParameteri64v"); + if(!_ptrc_glGetBufferParameteri64v) numFailed++; + _ptrc_glGetInteger64i_v = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLint64 *))IntGetProcAddress("glGetInteger64i_v"); + if(!_ptrc_glGetInteger64i_v) numFailed++; + _ptrc_glGetInteger64v = (void (CODEGEN_FUNCPTR *)(GLenum, GLint64 *))IntGetProcAddress("glGetInteger64v"); + if(!_ptrc_glGetInteger64v) numFailed++; + _ptrc_glGetMultisamplefv = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLfloat *))IntGetProcAddress("glGetMultisamplefv"); + if(!_ptrc_glGetMultisamplefv) numFailed++; + _ptrc_glGetSynciv = (void (CODEGEN_FUNCPTR *)(GLsync, GLenum, GLsizei, GLsizei *, GLint *))IntGetProcAddress("glGetSynciv"); + if(!_ptrc_glGetSynciv) numFailed++; + _ptrc_glIsSync = (GLboolean (CODEGEN_FUNCPTR *)(GLsync))IntGetProcAddress("glIsSync"); + if(!_ptrc_glIsSync) numFailed++; + _ptrc_glMultiDrawElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *))IntGetProcAddress("glMultiDrawElementsBaseVertex"); + if(!_ptrc_glMultiDrawElementsBaseVertex) numFailed++; + _ptrc_glProvokingVertex = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glProvokingVertex"); + if(!_ptrc_glProvokingVertex) numFailed++; + _ptrc_glSampleMaski = (void (CODEGEN_FUNCPTR *)(GLuint, GLbitfield))IntGetProcAddress("glSampleMaski"); + if(!_ptrc_glSampleMaski) numFailed++; + _ptrc_glTexImage2DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean))IntGetProcAddress("glTexImage2DMultisample"); + if(!_ptrc_glTexImage2DMultisample) numFailed++; + _ptrc_glTexImage3DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean))IntGetProcAddress("glTexImage3DMultisample"); + if(!_ptrc_glTexImage3DMultisample) numFailed++; + _ptrc_glWaitSync = (void (CODEGEN_FUNCPTR *)(GLsync, GLbitfield, GLuint64))IntGetProcAddress("glWaitSync"); + if(!_ptrc_glWaitSync) numFailed++; + _ptrc_glBindFragDataLocationIndexed = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, const GLchar *))IntGetProcAddress("glBindFragDataLocationIndexed"); + if(!_ptrc_glBindFragDataLocationIndexed) numFailed++; + _ptrc_glBindSampler = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress("glBindSampler"); + if(!_ptrc_glBindSampler) numFailed++; + _ptrc_glDeleteSamplers = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteSamplers"); + if(!_ptrc_glDeleteSamplers) numFailed++; + _ptrc_glGenSamplers = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenSamplers"); + if(!_ptrc_glGenSamplers) numFailed++; + _ptrc_glGetFragDataIndex = (GLint (CODEGEN_FUNCPTR *)(GLuint, const GLchar *))IntGetProcAddress("glGetFragDataIndex"); + if(!_ptrc_glGetFragDataIndex) numFailed++; + _ptrc_glGetQueryObjecti64v = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint64 *))IntGetProcAddress("glGetQueryObjecti64v"); + if(!_ptrc_glGetQueryObjecti64v) numFailed++; + _ptrc_glGetQueryObjectui64v = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint64 *))IntGetProcAddress("glGetQueryObjectui64v"); + if(!_ptrc_glGetQueryObjectui64v) numFailed++; + _ptrc_glGetSamplerParameterIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetSamplerParameterIiv"); + if(!_ptrc_glGetSamplerParameterIiv) numFailed++; + _ptrc_glGetSamplerParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLuint *))IntGetProcAddress("glGetSamplerParameterIuiv"); + if(!_ptrc_glGetSamplerParameterIuiv) numFailed++; + _ptrc_glGetSamplerParameterfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat *))IntGetProcAddress("glGetSamplerParameterfv"); + if(!_ptrc_glGetSamplerParameterfv) numFailed++; + _ptrc_glGetSamplerParameteriv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint *))IntGetProcAddress("glGetSamplerParameteriv"); + if(!_ptrc_glGetSamplerParameteriv) numFailed++; + _ptrc_glIsSampler = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsSampler"); + if(!_ptrc_glIsSampler) numFailed++; + _ptrc_glQueryCounter = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress("glQueryCounter"); + if(!_ptrc_glQueryCounter) numFailed++; + _ptrc_glSamplerParameterIiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLint *))IntGetProcAddress("glSamplerParameterIiv"); + if(!_ptrc_glSamplerParameterIiv) numFailed++; + _ptrc_glSamplerParameterIuiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLuint *))IntGetProcAddress("glSamplerParameterIuiv"); + if(!_ptrc_glSamplerParameterIuiv) numFailed++; + _ptrc_glSamplerParameterf = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLfloat))IntGetProcAddress("glSamplerParameterf"); + if(!_ptrc_glSamplerParameterf) numFailed++; + _ptrc_glSamplerParameterfv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLfloat *))IntGetProcAddress("glSamplerParameterfv"); + if(!_ptrc_glSamplerParameterfv) numFailed++; + _ptrc_glSamplerParameteri = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLint))IntGetProcAddress("glSamplerParameteri"); + if(!_ptrc_glSamplerParameteri) numFailed++; + _ptrc_glSamplerParameteriv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, const GLint *))IntGetProcAddress("glSamplerParameteriv"); + if(!_ptrc_glSamplerParameteriv) numFailed++; + _ptrc_glVertexAttribDivisor = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint))IntGetProcAddress("glVertexAttribDivisor"); + if(!_ptrc_glVertexAttribDivisor) numFailed++; + _ptrc_glVertexAttribP1ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress("glVertexAttribP1ui"); + if(!_ptrc_glVertexAttribP1ui) numFailed++; + _ptrc_glVertexAttribP1uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress("glVertexAttribP1uiv"); + if(!_ptrc_glVertexAttribP1uiv) numFailed++; + _ptrc_glVertexAttribP2ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress("glVertexAttribP2ui"); + if(!_ptrc_glVertexAttribP2ui) numFailed++; + _ptrc_glVertexAttribP2uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress("glVertexAttribP2uiv"); + if(!_ptrc_glVertexAttribP2uiv) numFailed++; + _ptrc_glVertexAttribP3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress("glVertexAttribP3ui"); + if(!_ptrc_glVertexAttribP3ui) numFailed++; + _ptrc_glVertexAttribP3uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress("glVertexAttribP3uiv"); + if(!_ptrc_glVertexAttribP3uiv) numFailed++; + _ptrc_glVertexAttribP4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, GLuint))IntGetProcAddress("glVertexAttribP4ui"); + if(!_ptrc_glVertexAttribP4ui) numFailed++; + _ptrc_glVertexAttribP4uiv = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum, GLboolean, const GLuint *))IntGetProcAddress("glVertexAttribP4uiv"); + if(!_ptrc_glVertexAttribP4uiv) numFailed++; + return numFailed; +} + +typedef int (*PFN_LOADFUNCPOINTERS)(); +typedef struct ogl_StrToExtMap_s +{ + char *extensionName; + int *extensionVariable; + PFN_LOADFUNCPOINTERS LoadExtension; +} ogl_StrToExtMap; + +static ogl_StrToExtMap ExtensionMap[6] = { + {"GL_ARB_texture_compression", &ogl_ext_ARB_texture_compression, Load_ARB_texture_compression}, + {"GL_EXT_texture_compression_s3tc", &ogl_ext_EXT_texture_compression_s3tc, NULL}, + {"GL_ARB_buffer_storage", &ogl_ext_ARB_buffer_storage, Load_ARB_buffer_storage}, + {"GL_ARB_shader_storage_buffer_object", &ogl_ext_ARB_shader_storage_buffer_object, Load_ARB_shader_storage_buffer_object}, + {"GL_EXT_texture_sRGB", &ogl_ext_EXT_texture_sRGB, NULL}, + {"GL_EXT_texture_filter_anisotropic", &ogl_ext_EXT_texture_filter_anisotropic, NULL}, +}; + +static int g_extensionMapSize = 6; + +static ogl_StrToExtMap *FindExtEntry(const char *extensionName) +{ + int loop; + ogl_StrToExtMap *currLoc = ExtensionMap; + for(loop = 0; loop < g_extensionMapSize; ++loop, ++currLoc) + { + if(strcmp(extensionName, currLoc->extensionName) == 0) + return currLoc; + } + + return NULL; +} + +static void ClearExtensionVars() +{ + ogl_ext_ARB_texture_compression = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_compression_s3tc = ogl_LOAD_FAILED; + ogl_ext_ARB_buffer_storage = ogl_LOAD_FAILED; + ogl_ext_ARB_shader_storage_buffer_object = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; +} + + +static void LoadExtByName(const char *extensionName) +{ + ogl_StrToExtMap *entry = NULL; + entry = FindExtEntry(extensionName); + if(entry) + { + if(entry->LoadExtension) + { + int numFailed = entry->LoadExtension(); + if(numFailed == 0) + { + *(entry->extensionVariable) = ogl_LOAD_SUCCEEDED; + } + else + { + *(entry->extensionVariable) = ogl_LOAD_SUCCEEDED + numFailed; + } + } + else + { + *(entry->extensionVariable) = ogl_LOAD_SUCCEEDED; + } + } +} + + +static void ProcExtsFromExtList() +{ + GLint iLoop; + GLint iNumExtensions = 0; + _ptrc_glGetIntegerv(GL_NUM_EXTENSIONS, &iNumExtensions); + + for(iLoop = 0; iLoop < iNumExtensions; iLoop++) + { + const char *strExtensionName = (const char *)_ptrc_glGetStringi(GL_EXTENSIONS, iLoop); + LoadExtByName(strExtensionName); + } +} + +int ogl_LoadFunctions() +{ + int numFailed = 0; + ClearExtensionVars(); + + _ptrc_glGetIntegerv = (void (CODEGEN_FUNCPTR *)(GLenum, GLint *))IntGetProcAddress("glGetIntegerv"); + if(!_ptrc_glGetIntegerv) return ogl_LOAD_FAILED; + _ptrc_glGetStringi = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glGetStringi"); + if(!_ptrc_glGetStringi) return ogl_LOAD_FAILED; + + ProcExtsFromExtList(); + numFailed = Load_Version_3_3(); + + if(numFailed == 0) + return ogl_LOAD_SUCCEEDED; + else + return ogl_LOAD_SUCCEEDED + numFailed; +} + +static int g_major_version = 0; +static int g_minor_version = 0; + +static void GetGLVersion() +{ + glGetIntegerv(GL_MAJOR_VERSION, &g_major_version); + glGetIntegerv(GL_MINOR_VERSION, &g_minor_version); +} + +int ogl_GetMajorVersion() +{ + if(g_major_version == 0) + GetGLVersion(); + return g_major_version; +} + +int ogl_GetMinorVersion() +{ + if(g_major_version == 0) //Yes, check the major version to get the minor one. + GetGLVersion(); + return g_minor_version; +} + +int ogl_IsVersionGEQ(int majorVersion, int minorVersion) +{ + if(g_major_version == 0) + GetGLVersion(); + + if(majorVersion > g_major_version) return 1; + if(majorVersion < g_major_version) return 0; + if(minorVersion >= g_minor_version) return 1; + return 0; +} + diff --git a/src/gl/system/gl_load.h b/src/gl/system/gl_load.h new file mode 100644 index 000000000..307f3893a --- /dev/null +++ b/src/gl/system/gl_load.h @@ -0,0 +1,1793 @@ +#ifndef POINTER_C_GENERATED_HEADER_OPENGL_H +#define POINTER_C_GENERATED_HEADER_OPENGL_H + +#if defined(__glew_h__) || defined(__GLEW_H__) +#error Attempt to include auto-generated header after including glew.h +#endif +#if defined(__gl_h_) || defined(__GL_H__) +#error Attempt to include auto-generated header after including gl.h +#endif +#if defined(__glext_h_) || defined(__GLEXT_H_) +#error Attempt to include auto-generated header after including glext.h +#endif +#if defined(__gltypes_h_) +#error Attempt to include auto-generated header after gltypes.h +#endif +#if defined(__gl_ATI_h_) +#error Attempt to include auto-generated header after including glATI.h +#endif + +#define __glew_h__ +#define __GLEW_H__ +#define __gl_h_ +#define __GL_H__ +#define __glext_h_ +#define __GLEXT_H_ +#define __gltypes_h_ +#define __gl_ATI_h_ + +#ifndef APIENTRY + #if defined(__MINGW32__) + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN 1 + #endif + #ifndef NOMINMAX + #define NOMINMAX + #endif + #include + #elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) + #ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN 1 + #endif + #ifndef NOMINMAX + #define NOMINMAX + #endif + #include + #else + #define APIENTRY + #endif +#endif /*APIENTRY*/ + +#ifndef CODEGEN_FUNCPTR + #define CODEGEN_REMOVE_FUNCPTR + #if defined(_WIN32) + #define CODEGEN_FUNCPTR APIENTRY + #else + #define CODEGEN_FUNCPTR + #endif +#endif /*CODEGEN_FUNCPTR*/ + +#ifndef GLAPI + #define GLAPI extern +#endif + + +#ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS +#define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS + + +#endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/ + + +#include +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif + typedef unsigned int GLenum; + typedef unsigned char GLboolean; + typedef unsigned int GLbitfield; + typedef void GLvoid; + typedef signed char GLbyte; + typedef short GLshort; + typedef int GLint; + typedef unsigned char GLubyte; + typedef unsigned short GLushort; + typedef unsigned int GLuint; + typedef int GLsizei; + typedef float GLfloat; + typedef float GLclampf; + typedef double GLdouble; + typedef double GLclampd; + typedef char GLchar; + typedef char GLcharARB; + #ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif + typedef unsigned short GLhalfARB; + typedef unsigned short GLhalf; + typedef GLint GLfixed; + typedef ptrdiff_t GLintptr; + typedef ptrdiff_t GLsizeiptr; + typedef int64_t GLint64; + typedef uint64_t GLuint64; + typedef ptrdiff_t GLintptrARB; + typedef ptrdiff_t GLsizeiptrARB; + typedef int64_t GLint64EXT; + typedef uint64_t GLuint64EXT; + typedef struct __GLsync *GLsync; + struct _cl_context; + struct _cl_event; + typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); + typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); + typedef unsigned short GLhalfNV; + typedef GLintptr GLvdpauSurfaceNV; + +#ifdef __cplusplus +extern "C" { +#endif /*__cplusplus*/ + +extern int ogl_ext_ARB_texture_compression; +extern int ogl_ext_EXT_texture_compression_s3tc; +extern int ogl_ext_ARB_buffer_storage; +extern int ogl_ext_ARB_shader_storage_buffer_object; +extern int ogl_ext_EXT_texture_sRGB; +extern int ogl_ext_EXT_texture_filter_anisotropic; + +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF + +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 + +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 + +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 + +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB_EXT 0x8C40 + +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE + +#define GL_ALPHA 0x1906 +#define GL_ALWAYS 0x0207 +#define GL_AND 0x1501 +#define GL_AND_INVERTED 0x1504 +#define GL_AND_REVERSE 0x1502 +#define GL_BACK 0x0405 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_BLEND 0x0BE2 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLUE 0x1905 +#define GL_BYTE 0x1400 +#define GL_CCW 0x0901 +#define GL_CLEAR 0x1500 +#define GL_COLOR 0x1800 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_COPY 0x1503 +#define GL_COPY_INVERTED 0x150C +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_CW 0x0900 +#define GL_DECR 0x1E03 +#define GL_DEPTH 0x1801 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DITHER 0x0BD0 +#define GL_DONT_CARE 0x1100 +#define GL_DOUBLE 0x140A +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_DST_ALPHA 0x0304 +#define GL_DST_COLOR 0x0306 +#define GL_EQUAL 0x0202 +#define GL_EQUIV 0x1509 +#define GL_EXTENSIONS 0x1F03 +#define GL_FALSE 0 +#define GL_FASTEST 0x1101 +#define GL_FILL 0x1B02 +#define GL_FLOAT 0x1406 +#define GL_FRONT 0x0404 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_FRONT_FACE 0x0B46 +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_GEQUAL 0x0206 +#define GL_GREATER 0x0204 +#define GL_GREEN 0x1904 +#define GL_INCR 0x1E02 +#define GL_INT 0x1404 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_OPERATION 0x0502 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVERT 0x150A +#define GL_KEEP 0x1E00 +#define GL_LEFT 0x0406 +#define GL_LEQUAL 0x0203 +#define GL_LESS 0x0201 +#define GL_LINE 0x1B01 +#define GL_LINEAR 0x2601 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_LINE_STRIP 0x0003 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_NAND 0x150E +#define GL_NEAREST 0x2600 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_NEVER 0x0200 +#define GL_NICEST 0x1102 +#define GL_NONE 0 +#define GL_NOOP 0x1505 +#define GL_NOR 0x1508 +#define GL_NOTEQUAL 0x0205 +#define GL_NO_ERROR 0 +#define GL_ONE 1 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_OR 0x1507 +#define GL_OR_INVERTED 0x150D +#define GL_OR_REVERSE 0x150B +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_POINT 0x1B00 +#define GL_POINTS 0x0000 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_QUADS 0x0007 +#define GL_R3_G3_B2 0x2A10 +#define GL_READ_BUFFER 0x0C02 +#define GL_RED 0x1903 +#define GL_RENDERER 0x1F01 +#define GL_REPEAT 0x2901 +#define GL_REPLACE 0x1E01 +#define GL_RGB 0x1907 +#define GL_RGB10 0x8052 +#define GL_RGB10_A2 0x8059 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB5_A1 0x8057 +#define GL_RGB8 0x8051 +#define GL_RGBA 0x1908 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGBA8 0x8058 +#define GL_RIGHT 0x0407 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_SET 0x150F +#define GL_SHORT 0x1402 +#define GL_SRC_ALPHA 0x0302 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_SRC_COLOR 0x0300 +#define GL_STENCIL 0x1802 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_INDEX 0x1901 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STEREO 0x0C33 +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRUE 1 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_UNSIGNED_INT 0x1405 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_VENDOR 0x1F00 +#define GL_VERSION 0x1F02 +#define GL_VIEWPORT 0x0BA2 +#define GL_XOR 0x1506 +#define GL_ZERO 0 + +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_TEXTURE_3D 0x806F +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 + +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_MULTISAMPLE 0x809D +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 + +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_DECR_WRAP 0x8508 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_INCR_WRAP 0x8507 +#define GL_MAX 0x8008 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_MIN 0x8007 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_LOD_BIAS 0x8501 + +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_CURRENT_QUERY 0x8865 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_READ_ONLY 0x88B8 +#define GL_READ_WRITE 0x88BA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_STATIC_COPY 0x88E6 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STREAM_COPY 0x88E2 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_WRITE_ONLY 0x88B9 + +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_DELETE_STATUS 0x8B80 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_LINK_STATUS 0x8B82 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_TYPE 0x8B4F +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_SHADER 0x8B31 + +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_SRGB_ALPHA 0x8C42 + +#define GL_BGRA_INTEGER 0x8D9B +#define GL_BGR_INTEGER 0x8D9A +#define GL_BLUE_INTEGER 0x8D96 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_RG 0x8226 +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_CONTEXT_FLAGS 0x821E +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_FIXED_ONLY 0x891D +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_FRAMEBUFFER 0x8D40 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_GREEN_INTEGER 0x8D95 +#define GL_HALF_FLOAT 0x140B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_MAJOR_VERSION 0x821B +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +/*Copied GL_MAP_READ_BIT From: ARB_buffer_storage*/ +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +/*Copied GL_MAP_WRITE_BIT From: ARB_buffer_storage*/ +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_MINOR_VERSION 0x821C +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_NUM_EXTENSIONS 0x821D +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_WAIT 0x8E13 +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_R16 0x822A +#define GL_R16F 0x822D +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32F 0x822E +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_R8 0x8229 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RED_INTEGER 0x8D94 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RG 0x8227 +#define GL_RG16 0x822C +#define GL_RG16F 0x822F +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32F 0x8230 +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_RG8 0x822B +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RGB16F 0x881B +#define GL_RGB16I 0x8D89 +#define GL_RGB16UI 0x8D77 +#define GL_RGB32F 0x8815 +#define GL_RGB32I 0x8D83 +#define GL_RGB32UI 0x8D71 +#define GL_RGB8I 0x8D8F +#define GL_RGB8UI 0x8D7D +#define GL_RGB9_E5 0x8C3D +#define GL_RGBA16F 0x881A +#define GL_RGBA16I 0x8D88 +#define GL_RGBA16UI 0x8D76 +#define GL_RGBA32F 0x8814 +#define GL_RGBA32I 0x8D82 +#define GL_RGBA32UI 0x8D70 +#define GL_RGBA8I 0x8D8E +#define GL_RGBA8UI 0x8D7C +#define GL_RGBA_INTEGER 0x8D99 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RG_INTEGER 0x8228 +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD + +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_INVALID_INDEX 0xFFFFFFFF +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_R16_SNORM 0x8F98 +#define GL_R8_SNORM 0x8F94 +#define GL_RG16_SNORM 0x8F99 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA16_SNORM 0x8F9B +#define GL_RGBA8_SNORM 0x8F97 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 + +#define GL_ALREADY_SIGNALED 0x911A +#define GL_CONDITION_SATISFIED 0x911C +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_OBJECT_TYPE 0x9112 +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SIGNALED 0x9119 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_SYNC_STATUS 0x9114 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_UNSIGNALED 0x9118 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_WAIT_FAILED 0x911D + +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_INT_2_10_10_10_REV 0x8D9F +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_RGB10_A2UI 0x906F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_SRC1_COLOR 0x88F9 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIMESTAMP 0x8E28 +#define GL_TIME_ELAPSED 0x88BF +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage1DARB _ptrc_glCompressedTexImage1DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage2DARB _ptrc_glCompressedTexImage2DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3DARB)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage3DARB _ptrc_glCompressedTexImage3DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1DARB)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage1DARB _ptrc_glCompressedTexSubImage1DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2DARB)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage2DARB _ptrc_glCompressedTexSubImage2DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3DARB)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage3DARB _ptrc_glCompressedTexSubImage3DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImageARB)(GLenum, GLint, GLvoid *); +#define glGetCompressedTexImageARB _ptrc_glGetCompressedTexImageARB +#endif /*GL_ARB_texture_compression*/ + + +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum, GLsizeiptr, const void *, GLbitfield); +#define glBufferStorage _ptrc_glBufferStorage +#endif /*GL_ARB_buffer_storage*/ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glShaderStorageBlockBinding)(GLuint, GLuint, GLuint); +#define glShaderStorageBlockBinding _ptrc_glShaderStorageBlockBinding +#endif /*GL_ARB_shader_storage_buffer_object*/ + + +extern void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum); +#define glBegin _ptrc_glBegin +extern void (CODEGEN_FUNCPTR *_ptrc_glEnd)(); +#define glEnd _ptrc_glEnd + + +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum, GLenum); +#define glBlendFunc _ptrc_glBlendFunc +extern void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield); +#define glClear _ptrc_glClear +extern void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat, GLfloat, GLfloat, GLfloat); +#define glClearColor _ptrc_glClearColor +extern void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble); +#define glClearDepth _ptrc_glClearDepth +extern void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint); +#define glClearStencil _ptrc_glClearStencil +extern void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean, GLboolean, GLboolean, GLboolean); +#define glColorMask _ptrc_glColorMask +extern void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum); +#define glCullFace _ptrc_glCullFace +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum); +#define glDepthFunc _ptrc_glDepthFunc +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean); +#define glDepthMask _ptrc_glDepthMask +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble, GLdouble); +#define glDepthRange _ptrc_glDepthRange +extern void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum); +#define glDisable _ptrc_glDisable +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum); +#define glDrawBuffer _ptrc_glDrawBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum); +#define glEnable _ptrc_glEnable +extern void (CODEGEN_FUNCPTR *_ptrc_glFinish)(); +#define glFinish _ptrc_glFinish +extern void (CODEGEN_FUNCPTR *_ptrc_glFlush)(); +#define glFlush _ptrc_glFlush +extern void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum); +#define glFrontFace _ptrc_glFrontFace +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum, GLboolean *); +#define glGetBooleanv _ptrc_glGetBooleanv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum, GLdouble *); +#define glGetDoublev _ptrc_glGetDoublev +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)(); +#define glGetError _ptrc_glGetError +extern void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum, GLfloat *); +#define glGetFloatv _ptrc_glGetFloatv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum, GLint *); +#define glGetIntegerv _ptrc_glGetIntegerv +extern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum); +#define glGetString _ptrc_glGetString +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *); +#define glGetTexImage _ptrc_glGetTexImage +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum, GLint, GLenum, GLfloat *); +#define glGetTexLevelParameterfv _ptrc_glGetTexLevelParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *); +#define glGetTexLevelParameteriv _ptrc_glGetTexLevelParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum, GLenum, GLfloat *); +#define glGetTexParameterfv _ptrc_glGetTexParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum, GLenum, GLint *); +#define glGetTexParameteriv _ptrc_glGetTexParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum, GLenum); +#define glHint _ptrc_glHint +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum); +#define glIsEnabled _ptrc_glIsEnabled +extern void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat); +#define glLineWidth _ptrc_glLineWidth +extern void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum); +#define glLogicOp _ptrc_glLogicOp +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum, GLfloat); +#define glPixelStoref _ptrc_glPixelStoref +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum, GLint); +#define glPixelStorei _ptrc_glPixelStorei +extern void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat); +#define glPointSize _ptrc_glPointSize +extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum, GLenum); +#define glPolygonMode _ptrc_glPolygonMode +extern void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum); +#define glReadBuffer _ptrc_glReadBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *); +#define glReadPixels _ptrc_glReadPixels +extern void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint, GLint, GLsizei, GLsizei); +#define glScissor _ptrc_glScissor +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum, GLint, GLuint); +#define glStencilFunc _ptrc_glStencilFunc +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint); +#define glStencilMask _ptrc_glStencilMask +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum, GLenum, GLenum); +#define glStencilOp _ptrc_glStencilOp +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +#define glTexImage1D _ptrc_glTexImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +#define glTexImage2D _ptrc_glTexImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum, GLenum, GLfloat); +#define glTexParameterf _ptrc_glTexParameterf +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum, GLenum, const GLfloat *); +#define glTexParameterfv _ptrc_glTexParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum, GLenum, GLint); +#define glTexParameteri _ptrc_glTexParameteri +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum, GLenum, const GLint *); +#define glTexParameteriv _ptrc_glTexParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint, GLint, GLsizei, GLsizei); +#define glViewport _ptrc_glViewport + +extern void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum, GLuint); +#define glBindTexture _ptrc_glBindTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +#define glCopyTexImage1D _ptrc_glCopyTexImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +#define glCopyTexImage2D _ptrc_glCopyTexImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum, GLint, GLint, GLint, GLint, GLsizei); +#define glCopyTexSubImage1D _ptrc_glCopyTexSubImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#define glCopyTexSubImage2D _ptrc_glCopyTexSubImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei, const GLuint *); +#define glDeleteTextures _ptrc_glDeleteTextures +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum, GLint, GLsizei); +#define glDrawArrays _ptrc_glDrawArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum, GLsizei, GLenum, const GLvoid *); +#define glDrawElements _ptrc_glDrawElements +extern void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei, GLuint *); +#define glGenTextures _ptrc_glGenTextures +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint); +#define glIsTexture _ptrc_glIsTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat, GLfloat); +#define glPolygonOffset _ptrc_glPolygonOffset +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +#define glTexSubImage1D _ptrc_glTexSubImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#define glTexSubImage2D _ptrc_glTexSubImage2D + +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat, GLfloat, GLfloat, GLfloat); +#define glBlendColor _ptrc_glBlendColor +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum); +#define glBlendEquation _ptrc_glBlendEquation +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#define glCopyTexSubImage3D _ptrc_glCopyTexSubImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +#define glDrawRangeElements _ptrc_glDrawRangeElements +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +#define glTexImage3D _ptrc_glTexImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#define glTexSubImage3D _ptrc_glTexSubImage3D + +extern void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum); +#define glActiveTexture _ptrc_glActiveTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage1D _ptrc_glCompressedTexImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage2D _ptrc_glCompressedTexImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +#define glCompressedTexImage3D _ptrc_glCompressedTexImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage1D _ptrc_glCompressedTexSubImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage2D _ptrc_glCompressedTexSubImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +#define glCompressedTexSubImage3D _ptrc_glCompressedTexSubImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum, GLint, GLvoid *); +#define glGetCompressedTexImage _ptrc_glGetCompressedTexImage +extern void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat, GLboolean); +#define glSampleCoverage _ptrc_glSampleCoverage + +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum); +#define glBlendFuncSeparate _ptrc_glBlendFuncSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum, const GLint *, const GLsizei *, GLsizei); +#define glMultiDrawArrays _ptrc_glMultiDrawArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei); +#define glMultiDrawElements _ptrc_glMultiDrawElements +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum, GLfloat); +#define glPointParameterf _ptrc_glPointParameterf +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum, const GLfloat *); +#define glPointParameterfv _ptrc_glPointParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum, GLint); +#define glPointParameteri _ptrc_glPointParameteri +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum, const GLint *); +#define glPointParameteriv _ptrc_glPointParameteriv + +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum, GLuint); +#define glBeginQuery _ptrc_glBeginQuery +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum, GLuint); +#define glBindBuffer _ptrc_glBindBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum, GLsizeiptr, const GLvoid *, GLenum); +#define glBufferData _ptrc_glBufferData +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid *); +#define glBufferSubData _ptrc_glBufferSubData +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei, const GLuint *); +#define glDeleteBuffers _ptrc_glDeleteBuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei, const GLuint *); +#define glDeleteQueries _ptrc_glDeleteQueries +extern void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum); +#define glEndQuery _ptrc_glEndQuery +extern void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei, GLuint *); +#define glGenBuffers _ptrc_glGenBuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei, GLuint *); +#define glGenQueries _ptrc_glGenQueries +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum, GLenum, GLint *); +#define glGetBufferParameteriv _ptrc_glGetBufferParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum, GLenum, GLvoid **); +#define glGetBufferPointerv _ptrc_glGetBufferPointerv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum, GLintptr, GLsizeiptr, GLvoid *); +#define glGetBufferSubData _ptrc_glGetBufferSubData +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint, GLenum, GLint *); +#define glGetQueryObjectiv _ptrc_glGetQueryObjectiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint, GLenum, GLuint *); +#define glGetQueryObjectuiv _ptrc_glGetQueryObjectuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum, GLenum, GLint *); +#define glGetQueryiv _ptrc_glGetQueryiv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint); +#define glIsBuffer _ptrc_glIsBuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint); +#define glIsQuery _ptrc_glIsQuery +extern void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum, GLenum); +#define glMapBuffer _ptrc_glMapBuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum); +#define glUnmapBuffer _ptrc_glUnmapBuffer + +extern void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint, GLuint); +#define glAttachShader _ptrc_glAttachShader +extern void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint, GLuint, const GLchar *); +#define glBindAttribLocation _ptrc_glBindAttribLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum, GLenum); +#define glBlendEquationSeparate _ptrc_glBlendEquationSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint); +#define glCompileShader _ptrc_glCompileShader +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)(); +#define glCreateProgram _ptrc_glCreateProgram +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum); +#define glCreateShader _ptrc_glCreateShader +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint); +#define glDeleteProgram _ptrc_glDeleteProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint); +#define glDeleteShader _ptrc_glDeleteShader +extern void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint, GLuint); +#define glDetachShader _ptrc_glDetachShader +extern void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint); +#define glDisableVertexAttribArray _ptrc_glDisableVertexAttribArray +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei, const GLenum *); +#define glDrawBuffers _ptrc_glDrawBuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint); +#define glEnableVertexAttribArray _ptrc_glEnableVertexAttribArray +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +#define glGetActiveAttrib _ptrc_glGetActiveAttrib +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +#define glGetActiveUniform _ptrc_glGetActiveUniform +extern void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint, GLsizei, GLsizei *, GLuint *); +#define glGetAttachedShaders _ptrc_glGetAttachedShaders +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint, const GLchar *); +#define glGetAttribLocation _ptrc_glGetAttribLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); +#define glGetProgramInfoLog _ptrc_glGetProgramInfoLog +extern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint, GLenum, GLint *); +#define glGetProgramiv _ptrc_glGetProgramiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint, GLsizei, GLsizei *, GLchar *); +#define glGetShaderInfoLog _ptrc_glGetShaderInfoLog +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint, GLsizei, GLsizei *, GLchar *); +#define glGetShaderSource _ptrc_glGetShaderSource +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint, GLenum, GLint *); +#define glGetShaderiv _ptrc_glGetShaderiv +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint, const GLchar *); +#define glGetUniformLocation _ptrc_glGetUniformLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint, GLint, GLfloat *); +#define glGetUniformfv _ptrc_glGetUniformfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint, GLint, GLint *); +#define glGetUniformiv _ptrc_glGetUniformiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint, GLenum, GLvoid **); +#define glGetVertexAttribPointerv _ptrc_glGetVertexAttribPointerv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint, GLenum, GLdouble *); +#define glGetVertexAttribdv _ptrc_glGetVertexAttribdv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint, GLenum, GLfloat *); +#define glGetVertexAttribfv _ptrc_glGetVertexAttribfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint, GLenum, GLint *); +#define glGetVertexAttribiv _ptrc_glGetVertexAttribiv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint); +#define glIsProgram _ptrc_glIsProgram +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint); +#define glIsShader _ptrc_glIsShader +extern void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint); +#define glLinkProgram _ptrc_glLinkProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint, GLsizei, const GLchar *const*, const GLint *); +#define glShaderSource _ptrc_glShaderSource +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint); +#define glStencilFuncSeparate _ptrc_glStencilFuncSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum, GLuint); +#define glStencilMaskSeparate _ptrc_glStencilMaskSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum); +#define glStencilOpSeparate _ptrc_glStencilOpSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint, GLfloat); +#define glUniform1f _ptrc_glUniform1f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint, GLsizei, const GLfloat *); +#define glUniform1fv _ptrc_glUniform1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint, GLint); +#define glUniform1i _ptrc_glUniform1i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint, GLsizei, const GLint *); +#define glUniform1iv _ptrc_glUniform1iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint, GLfloat, GLfloat); +#define glUniform2f _ptrc_glUniform2f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint, GLsizei, const GLfloat *); +#define glUniform2fv _ptrc_glUniform2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint, GLint, GLint); +#define glUniform2i _ptrc_glUniform2i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint, GLsizei, const GLint *); +#define glUniform2iv _ptrc_glUniform2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint, GLfloat, GLfloat, GLfloat); +#define glUniform3f _ptrc_glUniform3f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint, GLsizei, const GLfloat *); +#define glUniform3fv _ptrc_glUniform3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint, GLint, GLint, GLint); +#define glUniform3i _ptrc_glUniform3i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint, GLsizei, const GLint *); +#define glUniform3iv _ptrc_glUniform3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); +#define glUniform4f _ptrc_glUniform4f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint, GLsizei, const GLfloat *); +#define glUniform4fv _ptrc_glUniform4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint, GLint, GLint, GLint, GLint); +#define glUniform4i _ptrc_glUniform4i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint, GLsizei, const GLint *); +#define glUniform4iv _ptrc_glUniform4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix2fv _ptrc_glUniformMatrix2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix3fv _ptrc_glUniformMatrix3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix4fv _ptrc_glUniformMatrix4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint); +#define glUseProgram _ptrc_glUseProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint); +#define glValidateProgram _ptrc_glValidateProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint, GLdouble); +#define glVertexAttrib1d _ptrc_glVertexAttrib1d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint, const GLdouble *); +#define glVertexAttrib1dv _ptrc_glVertexAttrib1dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint, GLfloat); +#define glVertexAttrib1f _ptrc_glVertexAttrib1f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint, const GLfloat *); +#define glVertexAttrib1fv _ptrc_glVertexAttrib1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint, GLshort); +#define glVertexAttrib1s _ptrc_glVertexAttrib1s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint, const GLshort *); +#define glVertexAttrib1sv _ptrc_glVertexAttrib1sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint, GLdouble, GLdouble); +#define glVertexAttrib2d _ptrc_glVertexAttrib2d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint, const GLdouble *); +#define glVertexAttrib2dv _ptrc_glVertexAttrib2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint, GLfloat, GLfloat); +#define glVertexAttrib2f _ptrc_glVertexAttrib2f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint, const GLfloat *); +#define glVertexAttrib2fv _ptrc_glVertexAttrib2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint, GLshort, GLshort); +#define glVertexAttrib2s _ptrc_glVertexAttrib2s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint, const GLshort *); +#define glVertexAttrib2sv _ptrc_glVertexAttrib2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint, GLdouble, GLdouble, GLdouble); +#define glVertexAttrib3d _ptrc_glVertexAttrib3d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint, const GLdouble *); +#define glVertexAttrib3dv _ptrc_glVertexAttrib3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat); +#define glVertexAttrib3f _ptrc_glVertexAttrib3f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint, const GLfloat *); +#define glVertexAttrib3fv _ptrc_glVertexAttrib3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint, GLshort, GLshort, GLshort); +#define glVertexAttrib3s _ptrc_glVertexAttrib3s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint, const GLshort *); +#define glVertexAttrib3sv _ptrc_glVertexAttrib3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint, const GLbyte *); +#define glVertexAttrib4Nbv _ptrc_glVertexAttrib4Nbv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint, const GLint *); +#define glVertexAttrib4Niv _ptrc_glVertexAttrib4Niv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint, const GLshort *); +#define glVertexAttrib4Nsv _ptrc_glVertexAttrib4Nsv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +#define glVertexAttrib4Nub _ptrc_glVertexAttrib4Nub +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint, const GLubyte *); +#define glVertexAttrib4Nubv _ptrc_glVertexAttrib4Nubv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint, const GLuint *); +#define glVertexAttrib4Nuiv _ptrc_glVertexAttrib4Nuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint, const GLushort *); +#define glVertexAttrib4Nusv _ptrc_glVertexAttrib4Nusv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint, const GLbyte *); +#define glVertexAttrib4bv _ptrc_glVertexAttrib4bv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +#define glVertexAttrib4d _ptrc_glVertexAttrib4d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint, const GLdouble *); +#define glVertexAttrib4dv _ptrc_glVertexAttrib4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +#define glVertexAttrib4f _ptrc_glVertexAttrib4f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint, const GLfloat *); +#define glVertexAttrib4fv _ptrc_glVertexAttrib4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint, const GLint *); +#define glVertexAttrib4iv _ptrc_glVertexAttrib4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint, GLshort, GLshort, GLshort, GLshort); +#define glVertexAttrib4s _ptrc_glVertexAttrib4s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint, const GLshort *); +#define glVertexAttrib4sv _ptrc_glVertexAttrib4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint, const GLubyte *); +#define glVertexAttrib4ubv _ptrc_glVertexAttrib4ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint, const GLuint *); +#define glVertexAttrib4uiv _ptrc_glVertexAttrib4uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint, const GLushort *); +#define glVertexAttrib4usv _ptrc_glVertexAttrib4usv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +#define glVertexAttribPointer _ptrc_glVertexAttribPointer + +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix2x3fv _ptrc_glUniformMatrix2x3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix2x4fv _ptrc_glUniformMatrix2x4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix3x2fv _ptrc_glUniformMatrix3x2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix3x4fv _ptrc_glUniformMatrix3x4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix4x2fv _ptrc_glUniformMatrix4x2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint, GLsizei, GLboolean, const GLfloat *); +#define glUniformMatrix4x3fv _ptrc_glUniformMatrix4x3fv + +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint, GLenum); +#define glBeginConditionalRender _ptrc_glBeginConditionalRender +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum); +#define glBeginTransformFeedback _ptrc_glBeginTransformFeedback +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum, GLuint, GLuint); +#define glBindBufferBase _ptrc_glBindBufferBase +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); +#define glBindBufferRange _ptrc_glBindBufferRange +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint, GLuint, const GLchar *); +#define glBindFragDataLocation _ptrc_glBindFragDataLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum, GLuint); +#define glBindFramebuffer _ptrc_glBindFramebuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum, GLuint); +#define glBindRenderbuffer _ptrc_glBindRenderbuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint); +#define glBindVertexArray _ptrc_glBindVertexArray +extern void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); +#define glBlitFramebuffer _ptrc_glBlitFramebuffer +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum); +#define glCheckFramebufferStatus _ptrc_glCheckFramebufferStatus +extern void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum, GLenum); +#define glClampColor _ptrc_glClampColor +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum, GLint, GLfloat, GLint); +#define glClearBufferfi _ptrc_glClearBufferfi +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum, GLint, const GLfloat *); +#define glClearBufferfv _ptrc_glClearBufferfv +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum, GLint, const GLint *); +#define glClearBufferiv _ptrc_glClearBufferiv +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum, GLint, const GLuint *); +#define glClearBufferuiv _ptrc_glClearBufferuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint, GLboolean, GLboolean, GLboolean, GLboolean); +#define glColorMaski _ptrc_glColorMaski +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei, const GLuint *); +#define glDeleteFramebuffers _ptrc_glDeleteFramebuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei, const GLuint *); +#define glDeleteRenderbuffers _ptrc_glDeleteRenderbuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei, const GLuint *); +#define glDeleteVertexArrays _ptrc_glDeleteVertexArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum, GLuint); +#define glDisablei _ptrc_glDisablei +extern void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum, GLuint); +#define glEnablei _ptrc_glEnablei +extern void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)(); +#define glEndConditionalRender _ptrc_glEndConditionalRender +extern void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)(); +#define glEndTransformFeedback _ptrc_glEndTransformFeedback +extern void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum, GLintptr, GLsizeiptr); +#define glFlushMappedBufferRange _ptrc_glFlushMappedBufferRange +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint); +#define glFramebufferRenderbuffer _ptrc_glFramebufferRenderbuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum, GLenum, GLenum, GLuint, GLint); +#define glFramebufferTexture1D _ptrc_glFramebufferTexture1D +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint); +#define glFramebufferTexture2D _ptrc_glFramebufferTexture2D +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum, GLenum, GLenum, GLuint, GLint, GLint); +#define glFramebufferTexture3D _ptrc_glFramebufferTexture3D +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum, GLenum, GLuint, GLint, GLint); +#define glFramebufferTextureLayer _ptrc_glFramebufferTextureLayer +extern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei, GLuint *); +#define glGenFramebuffers _ptrc_glGenFramebuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei, GLuint *); +#define glGenRenderbuffers _ptrc_glGenRenderbuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei, GLuint *); +#define glGenVertexArrays _ptrc_glGenVertexArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum); +#define glGenerateMipmap _ptrc_glGenerateMipmap +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum, GLuint, GLboolean *); +#define glGetBooleani_v _ptrc_glGetBooleani_v +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint, const GLchar *); +#define glGetFragDataLocation _ptrc_glGetFragDataLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint *); +#define glGetFramebufferAttachmentParameteriv _ptrc_glGetFramebufferAttachmentParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum, GLuint, GLint *); +#define glGetIntegeri_v _ptrc_glGetIntegeri_v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum, GLenum, GLint *); +#define glGetRenderbufferParameteriv _ptrc_glGetRenderbufferParameteriv +extern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum, GLuint); +#define glGetStringi _ptrc_glGetStringi +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum, GLenum, GLint *); +#define glGetTexParameterIiv _ptrc_glGetTexParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum, GLenum, GLuint *); +#define glGetTexParameterIuiv _ptrc_glGetTexParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *); +#define glGetTransformFeedbackVarying _ptrc_glGetTransformFeedbackVarying +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint, GLint, GLuint *); +#define glGetUniformuiv _ptrc_glGetUniformuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint, GLenum, GLint *); +#define glGetVertexAttribIiv _ptrc_glGetVertexAttribIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint, GLenum, GLuint *); +#define glGetVertexAttribIuiv _ptrc_glGetVertexAttribIuiv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum, GLuint); +#define glIsEnabledi _ptrc_glIsEnabledi +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint); +#define glIsFramebuffer _ptrc_glIsFramebuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint); +#define glIsRenderbuffer _ptrc_glIsRenderbuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint); +#define glIsVertexArray _ptrc_glIsVertexArray +extern void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum, GLintptr, GLsizeiptr, GLbitfield); +#define glMapBufferRange _ptrc_glMapBufferRange +extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei); +#define glRenderbufferStorage _ptrc_glRenderbufferStorage +extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum, GLsizei, GLenum, GLsizei, GLsizei); +#define glRenderbufferStorageMultisample _ptrc_glRenderbufferStorageMultisample +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum, GLenum, const GLint *); +#define glTexParameterIiv _ptrc_glTexParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum, GLenum, const GLuint *); +#define glTexParameterIuiv _ptrc_glTexParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint, GLsizei, const GLchar *const*, GLenum); +#define glTransformFeedbackVaryings _ptrc_glTransformFeedbackVaryings +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint, GLuint); +#define glUniform1ui _ptrc_glUniform1ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint, GLsizei, const GLuint *); +#define glUniform1uiv _ptrc_glUniform1uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint, GLuint, GLuint); +#define glUniform2ui _ptrc_glUniform2ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint, GLsizei, const GLuint *); +#define glUniform2uiv _ptrc_glUniform2uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint, GLuint, GLuint, GLuint); +#define glUniform3ui _ptrc_glUniform3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint, GLsizei, const GLuint *); +#define glUniform3uiv _ptrc_glUniform3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint, GLuint, GLuint, GLuint, GLuint); +#define glUniform4ui _ptrc_glUniform4ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint, GLsizei, const GLuint *); +#define glUniform4uiv _ptrc_glUniform4uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint, GLint); +#define glVertexAttribI1i _ptrc_glVertexAttribI1i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint, const GLint *); +#define glVertexAttribI1iv _ptrc_glVertexAttribI1iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint, GLuint); +#define glVertexAttribI1ui _ptrc_glVertexAttribI1ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint, const GLuint *); +#define glVertexAttribI1uiv _ptrc_glVertexAttribI1uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint, GLint, GLint); +#define glVertexAttribI2i _ptrc_glVertexAttribI2i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint, const GLint *); +#define glVertexAttribI2iv _ptrc_glVertexAttribI2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint, GLuint, GLuint); +#define glVertexAttribI2ui _ptrc_glVertexAttribI2ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint, const GLuint *); +#define glVertexAttribI2uiv _ptrc_glVertexAttribI2uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint, GLint, GLint, GLint); +#define glVertexAttribI3i _ptrc_glVertexAttribI3i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint, const GLint *); +#define glVertexAttribI3iv _ptrc_glVertexAttribI3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint, GLuint, GLuint, GLuint); +#define glVertexAttribI3ui _ptrc_glVertexAttribI3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint, const GLuint *); +#define glVertexAttribI3uiv _ptrc_glVertexAttribI3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint, const GLbyte *); +#define glVertexAttribI4bv _ptrc_glVertexAttribI4bv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint, GLint, GLint, GLint, GLint); +#define glVertexAttribI4i _ptrc_glVertexAttribI4i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint, const GLint *); +#define glVertexAttribI4iv _ptrc_glVertexAttribI4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint, const GLshort *); +#define glVertexAttribI4sv _ptrc_glVertexAttribI4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint, const GLubyte *); +#define glVertexAttribI4ubv _ptrc_glVertexAttribI4ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint, GLuint, GLuint, GLuint, GLuint); +#define glVertexAttribI4ui _ptrc_glVertexAttribI4ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint, const GLuint *); +#define glVertexAttribI4uiv _ptrc_glVertexAttribI4uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint, const GLushort *); +#define glVertexAttribI4usv _ptrc_glVertexAttribI4usv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint, GLint, GLenum, GLsizei, const GLvoid *); +#define glVertexAttribIPointer _ptrc_glVertexAttribIPointer + +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum, GLenum, GLintptr, GLintptr, GLsizeiptr); +#define glCopyBufferSubData _ptrc_glCopyBufferSubData +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum, GLint, GLsizei, GLsizei); +#define glDrawArraysInstanced _ptrc_glDrawArraysInstanced +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei); +#define glDrawElementsInstanced _ptrc_glDrawElementsInstanced +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *); +#define glGetActiveUniformBlockName _ptrc_glGetActiveUniformBlockName +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint, GLuint, GLenum, GLint *); +#define glGetActiveUniformBlockiv _ptrc_glGetActiveUniformBlockiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint, GLuint, GLsizei, GLsizei *, GLchar *); +#define glGetActiveUniformName _ptrc_glGetActiveUniformName +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint, GLsizei, const GLuint *, GLenum, GLint *); +#define glGetActiveUniformsiv _ptrc_glGetActiveUniformsiv +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint, const GLchar *); +#define glGetUniformBlockIndex _ptrc_glGetUniformBlockIndex +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint, GLsizei, const GLchar *const*, GLuint *); +#define glGetUniformIndices _ptrc_glGetUniformIndices +extern void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint); +#define glPrimitiveRestartIndex _ptrc_glPrimitiveRestartIndex +extern void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum, GLenum, GLuint); +#define glTexBuffer _ptrc_glTexBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint, GLuint, GLuint); +#define glUniformBlockBinding _ptrc_glUniformBlockBinding + +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync, GLbitfield, GLuint64); +#define glClientWaitSync _ptrc_glClientWaitSync +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync); +#define glDeleteSync _ptrc_glDeleteSync +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLint); +#define glDrawElementsBaseVertex _ptrc_glDrawElementsBaseVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint); +#define glDrawElementsInstancedBaseVertex _ptrc_glDrawElementsInstancedBaseVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint); +#define glDrawRangeElementsBaseVertex _ptrc_glDrawRangeElementsBaseVertex +extern GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum, GLbitfield); +#define glFenceSync _ptrc_glFenceSync +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum, GLenum, GLuint, GLint); +#define glFramebufferTexture _ptrc_glFramebufferTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum, GLenum, GLint64 *); +#define glGetBufferParameteri64v _ptrc_glGetBufferParameteri64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum, GLuint, GLint64 *); +#define glGetInteger64i_v _ptrc_glGetInteger64i_v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum, GLint64 *); +#define glGetInteger64v _ptrc_glGetInteger64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum, GLuint, GLfloat *); +#define glGetMultisamplefv _ptrc_glGetMultisamplefv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync, GLenum, GLsizei, GLsizei *, GLint *); +#define glGetSynciv _ptrc_glGetSynciv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync); +#define glIsSync _ptrc_glIsSync +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum, const GLsizei *, GLenum, const GLvoid *const*, GLsizei, const GLint *); +#define glMultiDrawElementsBaseVertex _ptrc_glMultiDrawElementsBaseVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum); +#define glProvokingVertex _ptrc_glProvokingVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint, GLbitfield); +#define glSampleMaski _ptrc_glSampleMaski +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean); +#define glTexImage2DMultisample _ptrc_glTexImage2DMultisample +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean); +#define glTexImage3DMultisample _ptrc_glTexImage3DMultisample +extern void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync, GLbitfield, GLuint64); +#define glWaitSync _ptrc_glWaitSync + +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint, GLuint, GLuint, const GLchar *); +#define glBindFragDataLocationIndexed _ptrc_glBindFragDataLocationIndexed +extern void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint, GLuint); +#define glBindSampler _ptrc_glBindSampler +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei, const GLuint *); +#define glDeleteSamplers _ptrc_glDeleteSamplers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei, GLuint *); +#define glGenSamplers _ptrc_glGenSamplers +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint, const GLchar *); +#define glGetFragDataIndex _ptrc_glGetFragDataIndex +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint, GLenum, GLint64 *); +#define glGetQueryObjecti64v _ptrc_glGetQueryObjecti64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint, GLenum, GLuint64 *); +#define glGetQueryObjectui64v _ptrc_glGetQueryObjectui64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint, GLenum, GLint *); +#define glGetSamplerParameterIiv _ptrc_glGetSamplerParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint, GLenum, GLuint *); +#define glGetSamplerParameterIuiv _ptrc_glGetSamplerParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint, GLenum, GLfloat *); +#define glGetSamplerParameterfv _ptrc_glGetSamplerParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint, GLenum, GLint *); +#define glGetSamplerParameteriv _ptrc_glGetSamplerParameteriv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint); +#define glIsSampler _ptrc_glIsSampler +extern void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint, GLenum); +#define glQueryCounter _ptrc_glQueryCounter +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint, GLenum, const GLint *); +#define glSamplerParameterIiv _ptrc_glSamplerParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint, GLenum, const GLuint *); +#define glSamplerParameterIuiv _ptrc_glSamplerParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint, GLenum, GLfloat); +#define glSamplerParameterf _ptrc_glSamplerParameterf +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint, GLenum, const GLfloat *); +#define glSamplerParameterfv _ptrc_glSamplerParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint, GLenum, GLint); +#define glSamplerParameteri _ptrc_glSamplerParameteri +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint, GLenum, const GLint *); +#define glSamplerParameteriv _ptrc_glSamplerParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint, GLuint); +#define glVertexAttribDivisor _ptrc_glVertexAttribDivisor +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint, GLenum, GLboolean, GLuint); +#define glVertexAttribP1ui _ptrc_glVertexAttribP1ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint, GLenum, GLboolean, const GLuint *); +#define glVertexAttribP1uiv _ptrc_glVertexAttribP1uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint, GLenum, GLboolean, GLuint); +#define glVertexAttribP2ui _ptrc_glVertexAttribP2ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint, GLenum, GLboolean, const GLuint *); +#define glVertexAttribP2uiv _ptrc_glVertexAttribP2uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint, GLenum, GLboolean, GLuint); +#define glVertexAttribP3ui _ptrc_glVertexAttribP3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint, GLenum, GLboolean, const GLuint *); +#define glVertexAttribP3uiv _ptrc_glVertexAttribP3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint, GLenum, GLboolean, GLuint); +#define glVertexAttribP4ui _ptrc_glVertexAttribP4ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint, GLenum, GLboolean, const GLuint *); +#define glVertexAttribP4uiv _ptrc_glVertexAttribP4uiv + +enum ogl_LoadStatus +{ + ogl_LOAD_FAILED = 0, + ogl_LOAD_SUCCEEDED = 1, +}; + +int ogl_LoadFunctions(); + +int ogl_GetMinorVersion(); +int ogl_GetMajorVersion(); +int ogl_IsVersionGEQ(int majorVersion, int minorVersion); + +#ifdef __cplusplus +} +#endif /*__cplusplus*/ + +#endif //POINTER_C_GENERATED_HEADER_OPENGL_H diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp new file mode 100644 index 000000000..d4688cfd1 --- /dev/null +++ b/src/gl/system/gl_menu.cpp @@ -0,0 +1,74 @@ + + +#include "gl/system/gl_system.h" +#include "c_cvars.h" +#include "c_dispatch.h" +#include "v_video.h" +#include "version.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "menu/menu.h" + + + +// OpenGL stuff moved here +// GL related CVARs +CVAR(Bool, gl_portals, true, 0) +CVAR(Bool, gl_noquery, false, 0) +CVAR(Bool,gl_mirrors,true,0) // This is for debugging only! +CVAR(Bool,gl_mirror_envmap, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) +CVAR(Bool, gl_seamless, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) + +CUSTOM_CVAR(Int, r_mirror_recursions,4,CVAR_GLOBALCONFIG|CVAR_ARCHIVE) +{ + if (self<0) self=0; + if (self>10) self=10; +} +bool gl_plane_reflection_i; // This is needed in a header that cannot include the CVAR stuff... +CUSTOM_CVAR(Bool, gl_plane_reflection, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) +{ + gl_plane_reflection_i = self; +} + +CUSTOM_CVAR(Bool, gl_render_precise, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + gl_seamless=self; +} + +CUSTOM_CVAR (Float, vid_brightness, 0.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (screen != NULL) + { + screen->SetGamma(Gamma); //Brightness (self); + } +} + +CUSTOM_CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (screen != NULL) + { + screen->SetGamma(Gamma); //SetContrast (self); + } +} + + +// Do some tinkering with the menus so that certain options only appear +// when they are actually valid. +void gl_SetupMenu() +{ +#ifndef HAVE_MMX + FOptionValues **opt = OptionValues.CheckKey("HqResizeModes"); + if (opt != NULL) + { + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + { + // Delete HQnX resize modes for non MSVC targets + if ((*opt)->mValues[i].Value >= 7.0) + { + (*opt)->mValues.Delete(i); + } + } + } +#endif +} diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h new file mode 100644 index 000000000..ed52ab7ef --- /dev/null +++ b/src/gl/system/gl_system.h @@ -0,0 +1,121 @@ +#ifndef __GL_PCH_H +#define __GL_PCH_H +#ifdef _WIN32 +//#define __RPCNDR_H__ // this header causes problems! +//#define __wtypes_h__ +#define WIN32_LEAN_AND_MEAN +#define _WIN32_WINDOWS 0x410 +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 // Support the mouse wheel and session notification. +#define _WIN32_IE 0x0500 +#endif +#define DIRECTINPUT_VERSION 0x800 +#define DIRECTDRAW_VERSION 0x0300 + +#define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! + +#ifdef _MSC_VER +#pragma warning(disable : 4995) // MIPS +#endif + +#include +#include +#include +#ifndef __WINE__ +#include +#endif +#include +//#include +//#include +//#include +//#include +#endif + +#undef DWORD +#ifndef CALLBACK +#define CALLBACK +#endif +#include +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#if !defined(__APPLE__) && !defined(__FreeBSD__) +#include +#endif +#include + +#ifdef _MSC_VER +#define F_OK 0 /* Check for file existence */ +#define W_OK 2 /* Check for write permission */ +#define R_OK 4 /* Check for read permission */ +#include +#else +#include +#endif +#include +#include +#include + +//GL headers +#include "gl_load.h" + +#if defined(__APPLE__) + #include +#endif + +#ifdef _WIN32 +#define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! +//#include "gl/api/wglext.h" +#ifndef __WINE__ +#undef DWORD +#endif +#else +typedef unsigned char byte; +typedef float FLOAT; +template +inline T max( T a, T b) { return (((a)>(b)) ? (a) : (b)); } +#define __cdecl +#define _access(a,b) access(a,b) +#endif +#ifndef _WIN32 +#include +#endif + + +#ifdef LoadMenu +#undef LoadMenu +#endif +#ifdef DrawText +#undef DrawText +#endif +#ifdef GetCharWidth +#undef GetCharWidth +#endif + +#undef S_NORMAL +#undef OPAQUE + + +#ifdef _MSC_VER +#pragma warning(disable : 4244) // MIPS +#pragma warning(disable : 4136) // X86 +#pragma warning(disable : 4051) // ALPHA + +#pragma warning(disable : 4018) // signed/unsigned mismatch +#pragma warning(disable : 4305) // truncate from double to float +#endif + +#ifdef WIN32 +#undef WIN32 +#endif +#endif //__GL_PCH_H diff --git a/src/gl/system/gl_threads.cpp b/src/gl/system/gl_threads.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp new file mode 100644 index 000000000..30a996816 --- /dev/null +++ b/src/gl/system/gl_wipe.cpp @@ -0,0 +1,529 @@ +/* +** gl_wipe.cpp +** Screen wipe stuff +** (This uses immediate mode and the fixed function pipeline +** even if the new renderer is active) +** +**--------------------------------------------------------------------------- +** Copyright 2008 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "files.h" +#include "f_wipe.h" +#include "m_random.h" +#include "w_wad.h" +#include "v_palette.h" +#include "templates.h" +#include "vectors.h" + +#include "gl/system/gl_interface.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_translate.h" +#include "gl/textures/gl_material.h" +#include "gl/textures/gl_samplers.h" +#include "gl/utility/gl_templates.h" +#include "gl/data/gl_vertexbuffer.h" + +#ifndef _WIN32 +struct POINT { + SDWORD x; + SDWORD y; +}; +struct RECT { + SDWORD left; + SDWORD top; + SDWORD right; + SDWORD bottom; +}; +#endif + +//=========================================================================== +// +// Screen wipes +// +//=========================================================================== + +// TYPES ------------------------------------------------------------------- + +class OpenGLFrameBuffer::Wiper_Crossfade : public OpenGLFrameBuffer::Wiper +{ +public: + Wiper_Crossfade(); + bool Run(int ticks, OpenGLFrameBuffer *fb); + +private: + int Clock; +}; + +class OpenGLFrameBuffer::Wiper_Melt : public OpenGLFrameBuffer::Wiper +{ +public: + Wiper_Melt(); + bool Run(int ticks, OpenGLFrameBuffer *fb); + +private: + static const int WIDTH = 320, HEIGHT = 200; + int y[WIDTH]; +}; + +class OpenGLFrameBuffer::Wiper_Burn : public OpenGLFrameBuffer::Wiper +{ +public: + Wiper_Burn(); + ~Wiper_Burn(); + bool Run(int ticks, OpenGLFrameBuffer *fb); + +private: + static const int WIDTH = 64, HEIGHT = 64; + BYTE BurnArray[WIDTH * (HEIGHT + 5)]; + FHardwareTexture *BurnTexture; + int Density; + int BurnTime; +}; + +//========================================================================== +// +// OpenGLFrameBuffer :: WipeStartScreen +// +// Called before the current screen has started rendering. This needs to +// save what was drawn the previous frame so that it can be animated into +// what gets drawn this frame. +// +//========================================================================== + +bool OpenGLFrameBuffer::WipeStartScreen(int type) +{ + switch (type) + { + case wipe_Burn: + ScreenWipe = new Wiper_Burn; + break; + + case wipe_Fade: + ScreenWipe = new Wiper_Crossfade; + break; + + case wipe_Melt: + ScreenWipe = new Wiper_Melt; + break; + + default: + return false; + } + + wipestartscreen = new FHardwareTexture(Width, Height, true); + wipestartscreen->CreateTexture(NULL, Width, Height, 0, false, 0); + GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER); + GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE); + glFinish(); + wipestartscreen->Bind(0, false, false); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + return true; +} + +//========================================================================== +// +// OpenGLFrameBuffer :: WipeEndScreen +// +// The screen we want to animate to has just been drawn. +// +//========================================================================== + +void OpenGLFrameBuffer::WipeEndScreen() +{ + wipeendscreen = new FHardwareTexture(Width, Height, true); + wipeendscreen->CreateTexture(NULL, Width, Height, 0, false, 0); + GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER); + glFinish(); + wipeendscreen->Bind(0, false, false); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, Width, Height); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + Unlock(); +} + +//========================================================================== +// +// OpenGLFrameBuffer :: WipeDo +// +// Perform the actual wipe animation. The number of tics since the last +// time this function was called is passed in. Returns true when the wipe +// is over. The first time this function has been called, the screen is +// still locked from before and EndScene() still has not been called. +// Successive times need to call BeginScene(). +// +//========================================================================== + +bool OpenGLFrameBuffer::WipeDo(int ticks) +{ + // Sanity checks. + if (wipestartscreen == NULL || wipeendscreen == NULL) + { + return true; + } + + Lock(true); + + gl_RenderState.EnableTexture(true); + gl_RenderState.EnableFog(false); + glDisable(GL_DEPTH_TEST); + glDepthMask(false); + + bool done = ScreenWipe->Run(ticks, this); + glDepthMask(true); + //DrawLetterbox(); + return done; +} + +//========================================================================== +// +// OpenGLFrameBuffer :: WipeCleanup +// +// Release any resources that were specifically created for the wipe. +// +//========================================================================== + +void OpenGLFrameBuffer::WipeCleanup() +{ + if (ScreenWipe != NULL) + { + delete ScreenWipe; + ScreenWipe = NULL; + } + if (wipestartscreen != NULL) + { + delete wipestartscreen; + wipestartscreen = NULL; + } + if (wipeendscreen != NULL) + { + delete wipeendscreen; + wipeendscreen = NULL; + } + FMaterial::ClearLastTexture(); +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper Constructor +// +//========================================================================== + +OpenGLFrameBuffer::Wiper::~Wiper() +{ +} + +// WIPE: CROSSFADE --------------------------------------------------------- + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Crossfade Constructor +// +//========================================================================== + +OpenGLFrameBuffer::Wiper_Crossfade::Wiper_Crossfade() +: Clock(0) +{ +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Crossfade :: Run +// +// Fades the old screen into the new one over 32 ticks. +// +//========================================================================== + +bool OpenGLFrameBuffer::Wiper_Crossfade::Run(int ticks, OpenGLFrameBuffer *fb) +{ + Clock += ticks; + + float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); + float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); + + gl_RenderState.SetTextureMode(TM_OPAQUE); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.ResetColor(); + gl_RenderState.Apply(); + fb->wipestartscreen->Bind(0, 0, false); + + FFlatVertex *ptr; + unsigned int offset, count; + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, 0, 0, 0, vb); + ptr++; + ptr->Set(0, fb->Height, 0, 0, 0); + ptr++; + ptr->Set(fb->Width, 0, 0, ur, vb); + ptr++; + ptr->Set(fb->Width, fb->Height, 0, ur, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); + + fb->wipeendscreen->Bind(0, 0, false); + gl_RenderState.SetColorAlpha(0xffffff, clamp(Clock/32.f, 0.f, 1.f)); + gl_RenderState.Apply(); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); + gl_RenderState.SetTextureMode(TM_MODULATE); + + return Clock >= 32; +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Melt Constructor +// +//========================================================================== + +OpenGLFrameBuffer::Wiper_Melt::Wiper_Melt() +{ + int i, r; + + // setup initial column positions + // (y<0 => not ready to scroll yet) + y[0] = -(M_Random() & 15); + for (i = 1; i < WIDTH; ++i) + { + r = (M_Random()%3) - 1; + y[i] = clamp(y[i-1] + r, -15, 0); + } +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Melt :: Run +// +// Fades the old screen into the new one over 32 ticks. +// +//========================================================================== + +bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) +{ + float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); + float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); + + // Draw the new screen on the bottom. + gl_RenderState.SetTextureMode(TM_OPAQUE); + gl_RenderState.ResetColor(); + gl_RenderState.Apply(); + fb->wipeendscreen->Bind(0, 0, false); + FFlatVertex *ptr; + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, 0, 0, 0, vb); + ptr++; + ptr->Set(0, fb->Height, 0, 0, 0); + ptr++; + ptr->Set(fb->Width, 0, 0, ur, vb); + ptr++; + ptr->Set(fb->Width, fb->Height, 0, ur, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + + int i, dy; + bool done = false; + + fb->wipestartscreen->Bind(0, 0, false); + // Copy the old screen in vertical strips on top of the new one. + while (ticks--) + { + done = true; + for (i = 0; i < WIDTH; i++) + { + if (y[i] < 0) + { + y[i]++; + done = false; + } + else if (y[i] < HEIGHT) + { + dy = (y[i] < 16) ? y[i]+1 : 8; + y[i] = MIN(y[i] + dy, HEIGHT); + done = false; + } + if (ticks == 0) + { + // Only draw for the final tick. + // No need for optimization. Wipes won't ever be drawn with anything else. + RECT rect; + POINT dpt; + + dpt.x = i * fb->Width / WIDTH; + dpt.y = MAX(0, y[i] * fb->Height / HEIGHT); + rect.left = dpt.x; + rect.top = 0; + rect.right = (i + 1) * fb->Width / WIDTH; + rect.bottom = fb->Height - dpt.y; + if (rect.bottom > rect.top) + { + float tw = (float)FHardwareTexture::GetTexDimension(fb->Width); + float th = (float)FHardwareTexture::GetTexDimension(fb->Height); + rect.bottom = fb->Height - rect.bottom; + rect.top = fb->Height - rect.top; + + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(rect.left, rect.bottom, 0, rect.left / tw, rect.top / th); + ptr++; + ptr->Set(rect.left, rect.top, 0, rect.left / tw, rect.bottom / th); + ptr++; + ptr->Set(rect.right, rect.bottom, 0, rect.right / tw, rect.top / th); + ptr++; + ptr->Set(rect.right, rect.top, 0, rect.right / tw, rect.bottom / th); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP); + } + } + } + } + gl_RenderState.SetTextureMode(TM_MODULATE); + return done; +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Burn Constructor +// +//========================================================================== + +OpenGLFrameBuffer::Wiper_Burn::Wiper_Burn() +{ + Density = 4; + BurnTime = 0; + memset(BurnArray, 0, sizeof(BurnArray)); + BurnTexture = NULL; +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Burn Destructor +// +//========================================================================== + +OpenGLFrameBuffer::Wiper_Burn::~Wiper_Burn() +{ + if (BurnTexture != NULL) + { + delete BurnTexture; + BurnTexture = NULL; + } +} + +//========================================================================== +// +// OpenGLFrameBuffer :: Wiper_Burn :: Run +// +//========================================================================== + +bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) +{ + bool done; + + BurnTime += ticks; + ticks *= 2; + + // Make the fire burn + done = false; + while (!done && ticks--) + { + Density = wipe_CalcBurn(BurnArray, WIDTH, HEIGHT, Density); + done = (Density < 0); + } + + if (BurnTexture != NULL) delete BurnTexture; + BurnTexture = new FHardwareTexture(WIDTH, HEIGHT, true); + + // Update the burn texture with the new burn data + BYTE rgb_buffer[WIDTH*HEIGHT*4]; + + const BYTE *src = BurnArray; + DWORD *dest = (DWORD *)rgb_buffer; + for (int y = HEIGHT; y != 0; --y) + { + for (int x = WIDTH; x != 0; --x) + { + BYTE s = clamp((*src++)*2, 0, 255); + *dest++ = MAKEARGB(s,255,255,255); + } + } + + float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); + float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); + + + // Put the initial screen back to the buffer. + gl_RenderState.SetTextureMode(TM_OPAQUE); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.ResetColor(); + gl_RenderState.Apply(); + fb->wipestartscreen->Bind(0, 0, false); + FFlatVertex *ptr; + unsigned int offset, count; + ptr = GLRenderer->mVBO->GetBuffer(); + ptr->Set(0, 0, 0, 0, vb); + ptr++; + ptr->Set(0, fb->Height, 0, 0, 0); + ptr++; + ptr->Set(fb->Width, 0, 0, ur, vb); + ptr++; + ptr->Set(fb->Width, fb->Height, 0, ur, 0); + ptr++; + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP, &offset, &count); + + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.SetEffect(EFF_BURN); + gl_RenderState.ResetColor(); + gl_RenderState.Apply(); + + // Burn the new screen on top of it. + fb->wipeendscreen->Bind(0, 0, false); + + BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, 1, true, 0); + + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, offset, count); + gl_RenderState.SetEffect(EFF_NONE); + + // The fire may not always stabilize, so the wipe is forced to end + // after an arbitrary maximum time. + return done || (BurnTime > 40); +} diff --git a/src/gl/textures/gl_bitmap.cpp b/src/gl/textures/gl_bitmap.cpp new file mode 100644 index 000000000..a2319f67c --- /dev/null +++ b/src/gl/textures/gl_bitmap.cpp @@ -0,0 +1,156 @@ +/* +** gl_bitmap.cpp +** Bitmap class for texture composition +** +**--------------------------------------------------------------------------- +** Copyright 2004-2009 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** 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 "v_palette.h" +#include "templates.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/textures/gl_translate.h" +#include "gl/textures/gl_bitmap.h" +#include "gl/system/gl_interface.h" + +//=========================================================================== +// +// multi-format pixel copy with colormap application +// requires one of the previously defined conversion classes to work +// +//=========================================================================== +template +void iCopyColors(unsigned char * pout, const unsigned char * pin, int count, int step) +{ + int i; + + for(i=0;i, + iCopyColors, + iCopyColors, + iCopyColors, + iCopyColors, + iCopyColors, + iCopyColors, + iCopyColors, + iCopyColors +}; + +//=========================================================================== +// +// True Color texture copy function +// This excludes all the cases that force downconversion to the +// base palette because they wouldn't be used anyway. +// +//=========================================================================== +void FGLBitmap::CopyPixelDataRGB(int originx, int originy, + const BYTE * patch, int srcwidth, int srcheight, int step_x, int step_y, + int rotate, int ct, FCopyInfo *inf) +{ + if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate)) + { + BYTE *buffer = GetPixels() + 4*originx + Pitch*originy; + for (int y=0;y 0) + { + PalEntry *ptrans = GLTranslationPalette::GetPalette(translation); + if (ptrans) + { + for (i = 0; i < 256; i++) + { + penew[i] = (ptrans[i] & 0xffffff) | (palette[i] & 0xff000000); + } + } + } + else + { + memcpy(penew, palette, 256*sizeof(PalEntry)); + } + + // convert the image according to the translated palette. + for (y=0;y +#else +#include +#endif + +#include "w_wad.h" +#include "m_png.h" +#include "sbar.h" +#include "gi.h" +#include "cmdlib.h" +#include "sc_man.h" +#include "doomstat.h" +#include "d_main.h" +#include "zstring.h" + +#ifndef _WIN32 +#define _access(a,b) access(a,b) +#endif + +static int Doom2Wad = -1; + +// quick'n dirty hack. Should be enough here... +static void SetDoom2Wad() +{ + if (Doom2Wad == -1) + { + FString iwad = Wads.GetWadFullName(1); + iwad.ToLower(); + if (iwad.IndexOf("plutonia") >= 0) Doom2Wad = 1; + else if (iwad.IndexOf("tnt") >= 0) Doom2Wad = 2; + else Doom2Wad = 0; + } +} +//========================================================================== +// +// Checks for the presence of a hires texture replacement in a Doomsday style PK3 +// +//========================================================================== +int CheckDDPK3(FTexture *tex) +{ + static const char * doom1texpath[]= { + "data/jdoom/textures/doom/%s.%s", "data/jdoom/textures/doom-ult/%s.%s", "data/jdoom/textures/doom1/%s.%s", "data/jdoom/textures/%s.%s", NULL }; + + static const char * doom2texpath[]= { + "data/jdoom/textures/doom2/%s.%s", "data/jdoom/textures/%s.%s", NULL }; + + static const char * pluttexpath[]= { + "data/jdoom/textures/doom2-plut/%s.%s", "data/jdoom/textures/plutonia/%s.%s", "data/jdoom/textures/%s.%s", NULL }; + + static const char * tnttexpath[]= { + "data/jdoom/textures/doom2-tnt/%s.%s", "data/jdoom/textures/tnt/%s.%s", "data/jdoom/textures/%s.%s", NULL }; + + static const char * heretictexpath[]= { + "data/jheretic/textures/%s.%s", NULL }; + + static const char * hexentexpath[]= { + "data/jhexen/textures/%s.%s", NULL }; + + static const char * strifetexpath[]= { + "data/jstrife/textures/%s.%s", NULL }; + + static const char * chextexpath[]= { + "data/jchex/textures/%s.%s", NULL }; + + static const char * doomflatpath[]= { + "data/jdoom/flats/%s.%s", NULL }; + + static const char * hereticflatpath[]= { + "data/jheretic/flats/%s.%s", NULL }; + + static const char * hexenflatpath[]= { + "data/jhexen/flats/%s.%s", NULL }; + + static const char * strifeflatpath[]= { + "data/jstrife/flats/%s.%s", NULL }; + + static const char * chexflatpath[]= { + "data/jchex/flats/%s.%s", NULL }; + + + FString checkName; + const char ** checklist; + BYTE useType=tex->UseType; + + if (useType==FTexture::TEX_SkinSprite || useType==FTexture::TEX_Decal || useType==FTexture::TEX_FontChar) + { + return -3; + } + + bool ispatch = (useType==FTexture::TEX_MiscPatch || useType==FTexture::TEX_Sprite) ; + + // for patches this doesn't work yet + if (ispatch) return -3; + + if (!gameinfo.ConfigName.CompareNoCase("Doom")) + { + if (!(gameinfo.flags & GI_MAPxx)) + { + checklist = useType==FTexture::TEX_Flat? doomflatpath : doom1texpath; + } + else + { + SetDoom2Wad(); + if (Doom2Wad == 1) + checklist = useType==FTexture::TEX_Flat? doomflatpath : pluttexpath; + else if (Doom2Wad == 2) + checklist = useType==FTexture::TEX_Flat? doomflatpath : tnttexpath; + else + checklist = useType==FTexture::TEX_Flat? doomflatpath : doom2texpath; + } + } + else if (!gameinfo.ConfigName.CompareNoCase("Heretic")) + { + checklist = useType==FTexture::TEX_Flat? hereticflatpath : heretictexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Hexen")) + { + checklist = useType==FTexture::TEX_Flat? hexenflatpath : hexentexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Strife")) + { + checklist = useType==FTexture::TEX_Flat? strifeflatpath : strifetexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Chex")) + { + checklist = useType==FTexture::TEX_Flat? chexflatpath : chextexpath; + } + else + return -3; + + while (*checklist) + { + static const char * extensions[] = { "PNG", "JPG", "TGA", "PCX", NULL }; + + for (const char ** extp=extensions; *extp; extp++) + { + checkName.Format(*checklist, tex->Name.GetChars(), *extp); + int lumpnum = Wads.CheckNumForFullName(checkName); + if (lumpnum >= 0) return lumpnum; + } + checklist++; + } + return -3; +} + + +//========================================================================== +// +// Checks for the presence of a hires texture replacement +// +//========================================================================== +int CheckExternalFile(FTexture *tex, bool & hascolorkey) +{ + static const char * doom1texpath[]= { + "%stextures/doom/doom1/%s.%s", "%stextures/doom/doom1/%s-ck.%s", + "%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * doom2texpath[]= { + "%stextures/doom/doom2/%s.%s", "%stextures/doom/doom2/%s-ck.%s", + "%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * pluttexpath[]= { + "%stextures/doom/plut/%s.%s", "%stextures/doom/plut/%s-ck.%s", + "%stextures/doom/doom2-plut/%s.%s", "%stextures/doom/doom2-plut/%s-ck.%s", + "%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * tnttexpath[]= { + "%stextures/doom/tnt/%s.%s", "%stextures/doom/tnt/%s-ck.%s", + "%stextures/doom/doom2-tnt/%s.%s", "%stextures/doom/doom2-tnt/%s-ck.%s", + "%stextures/doom/%s.%s", "%stextures/doom/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * heretictexpath[]= { + "%stextures/heretic/%s.%s", "%stextures/heretic/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * hexentexpath[]= { + "%stextures/hexen/%s.%s", "%stextures/hexen/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * strifetexpath[]= { + "%stextures/strife/%s.%s", "%stextures/strife/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * chextexpath[]= { + "%stextures/chex/%s.%s", "%stextures/chex/%s-ck.%s", "%stextures/%s.%s", "%stextures/%s-ck.%s", NULL + }; + + static const char * doom1flatpath[]= { + "%sflats/doom/doom1/%s.%s", "%stextures/doom/doom1/flat-%s.%s", + "%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * doom2flatpath[]= { + "%sflats/doom/doom2/%s.%s", "%stextures/doom/doom2/flat-%s.%s", + "%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * plutflatpath[]= { + "%sflats/doom/plut/%s.%s", "%stextures/doom/plut/flat-%s.%s", + "%sflats/doom/doom2-plut/%s.%s", "%stextures/doom/doom2-plut/flat-%s.%s", + "%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * tntflatpath[]= { + "%sflats/doom/tnt/%s.%s", "%stextures/doom/tnt/flat-%s.%s", + "%sflats/doom/doom2-tnt/%s.%s", "%stextures/doom/doom2-tnt/flat-%s.%s", + "%sflats/doom/%s.%s", "%stextures/doom/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * hereticflatpath[]= { + "%sflats/heretic/%s.%s", "%stextures/heretic/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * hexenflatpath[]= { + "%sflats/hexen/%s.%s", "%stextures/hexen/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * strifeflatpath[]= { + "%sflats/strife/%s.%s", "%stextures/strife/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * chexflatpath[]= { + "%sflats/chex/%s.%s", "%stextures/chex/flat-%s.%s", "%sflats/%s.%s", "%stextures/flat-%s.%s", NULL + }; + + static const char * doom1patchpath[]= { + "%spatches/doom/doom1/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * doom2patchpath[]= { + "%spatches/doom/doom2/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * plutpatchpath[]= { + "%spatches/doom/plut/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * tntpatchpath[]= { + "%spatches/doom/tnt/%s.%s", "%spatches/doom/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * hereticpatchpath[]= { + "%spatches/heretic/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * hexenpatchpath[]= { + "%spatches/hexen/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * strifepatchpath[]= { + "%spatches/strife/%s.%s", "%spatches/%s.%s", NULL + }; + + static const char * chexpatchpath[]= { + "%spatches/chex/%s.%s", "%spatches/%s.%s", NULL + }; + + FString checkName; + const char ** checklist; + BYTE useType=tex->UseType; + + if (useType==FTexture::TEX_SkinSprite || useType==FTexture::TEX_Decal || useType==FTexture::TEX_FontChar) + { + return -3; + } + + bool ispatch = (useType==FTexture::TEX_MiscPatch || useType==FTexture::TEX_Sprite) ; + + // for patches this doesn't work yet + if (ispatch) return -3; + + if (!gameinfo.ConfigName.CompareNoCase("Doom")) + { + if (!(gameinfo.flags & GI_MAPxx)) + { + checklist = ispatch ? doom1patchpath : useType==FTexture::TEX_Flat? doom1flatpath : doom1texpath; + } + else + { + SetDoom2Wad(); + if (Doom2Wad == 1) + checklist = ispatch ? plutpatchpath : useType==FTexture::TEX_Flat? plutflatpath : pluttexpath; + else if (Doom2Wad == 2) + checklist = ispatch ? tntpatchpath : useType==FTexture::TEX_Flat? tntflatpath : tnttexpath; + else + checklist = ispatch ? doom2patchpath : useType==FTexture::TEX_Flat? doom2flatpath : doom2texpath; + } + } + else if (!gameinfo.ConfigName.CompareNoCase("Heretic")) + { + checklist = ispatch ? hereticpatchpath : useType==FTexture::TEX_Flat? hereticflatpath : heretictexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Hexen")) + { + checklist = ispatch ? hexenpatchpath : useType==FTexture::TEX_Flat? hexenflatpath : hexentexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Strife")) + { + checklist = ispatch ?strifepatchpath : useType==FTexture::TEX_Flat? strifeflatpath : strifetexpath; + } + else if (!gameinfo.ConfigName.CompareNoCase("Chex")) + { + checklist = ispatch ?chexpatchpath : useType==FTexture::TEX_Flat? chexflatpath : chextexpath; + } + else + return -3; + + while (*checklist) + { + static const char * extensions[] = { "PNG", "JPG", "TGA", "PCX", NULL }; + + for (const char ** extp=extensions; *extp; extp++) + { + checkName.Format(*checklist, progdir.GetChars(), tex->Name.GetChars(), *extp); + if (_access(checkName, 0) == 0) + { + hascolorkey = !!strstr(checkName, "-ck."); + return Wads.AddExternalFile(checkName); + } + } + checklist++; + } + return -3; +} + + diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp new file mode 100644 index 000000000..261f66e6a --- /dev/null +++ b/src/gl/textures/gl_hqresize.cpp @@ -0,0 +1,320 @@ +/* +** gl_hqresize.cpp +** Contains high quality upsampling functions. +** So far Scale2x/3x/4x as described in http://scale2x.sourceforge.net/ +** are implemented. +** +**--------------------------------------------------------------------------- +** Copyright 2008 Benjamin Berkels +** 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 "gl/system/gl_system.h" +#include "gl/system/gl_interface.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/textures/gl_texture.h" +#include "c_cvars.h" +#include "gl/hqnx/hqx.h" +#ifdef HAVE_MMX +#include "gl/hqnx_asm/hqnx_asm.h" +#endif + +CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ +#ifdef HAVE_MMX + if (self < 0 || self > 9) +#else + if (self < 0 || self > 6) +#endif + self = 0; + GLRenderer->FlushTextures(); +} + +CUSTOM_CVAR(Int, gl_texture_hqresize_maxinputsize, 512, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self > 1024) self = 1024; + GLRenderer->FlushTextures(); +} + +CUSTOM_CVAR(Int, gl_texture_hqresize_targets, 7, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + GLRenderer->FlushTextures(); +} + +CVAR (Flag, gl_texture_hqresize_textures, gl_texture_hqresize_targets, 1); +CVAR (Flag, gl_texture_hqresize_sprites, gl_texture_hqresize_targets, 2); +CVAR (Flag, gl_texture_hqresize_fonts, gl_texture_hqresize_targets, 4); + + +static void scale2x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) +{ + const int width = 2* inWidth; + const int height = 2 * inHeight; + + for ( int i = 0; i < inWidth; ++i ) + { + const int iMinus = (i > 0) ? (i-1) : 0; + const int iPlus = (i < inWidth - 1 ) ? (i+1) : i; + for ( int j = 0; j < inHeight; ++j ) + { + const int jMinus = (j > 0) ? (j-1) : 0; + const int jPlus = (j < inHeight - 1 ) ? (j+1) : j; + const uint32 A = inputBuffer[ iMinus +inWidth*jMinus]; + const uint32 B = inputBuffer[ iMinus +inWidth*j ]; + const uint32 C = inputBuffer[ iMinus +inWidth*jPlus]; + const uint32 D = inputBuffer[ i +inWidth*jMinus]; + const uint32 E = inputBuffer[ i +inWidth*j ]; + const uint32 F = inputBuffer[ i +inWidth*jPlus]; + const uint32 G = inputBuffer[ iPlus +inWidth*jMinus]; + const uint32 H = inputBuffer[ iPlus +inWidth*j ]; + const uint32 I = inputBuffer[ iPlus +inWidth*jPlus]; + if (B != H && D != F) { + outputBuffer[2*i + width*2*j ] = D == B ? D : E; + outputBuffer[2*i + width*(2*j+1)] = B == F ? F : E; + outputBuffer[2*i+1 + width*2*j ] = D == H ? D : E; + outputBuffer[2*i+1 + width*(2*j+1)] = H == F ? F : E; + } else { + outputBuffer[2*i + width*2*j ] = E; + outputBuffer[2*i + width*(2*j+1)] = E; + outputBuffer[2*i+1 + width*2*j ] = E; + outputBuffer[2*i+1 + width*(2*j+1)] = E; + } + } + } +} + +static void scale3x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) +{ + const int width = 3* inWidth; + const int height = 3 * inHeight; + + for ( int i = 0; i < inWidth; ++i ) + { + const int iMinus = (i > 0) ? (i-1) : 0; + const int iPlus = (i < inWidth - 1 ) ? (i+1) : i; + for ( int j = 0; j < inHeight; ++j ) + { + const int jMinus = (j > 0) ? (j-1) : 0; + const int jPlus = (j < inHeight - 1 ) ? (j+1) : j; + const uint32 A = inputBuffer[ iMinus +inWidth*jMinus]; + const uint32 B = inputBuffer[ iMinus +inWidth*j ]; + const uint32 C = inputBuffer[ iMinus +inWidth*jPlus]; + const uint32 D = inputBuffer[ i +inWidth*jMinus]; + const uint32 E = inputBuffer[ i +inWidth*j ]; + const uint32 F = inputBuffer[ i +inWidth*jPlus]; + const uint32 G = inputBuffer[ iPlus +inWidth*jMinus]; + const uint32 H = inputBuffer[ iPlus +inWidth*j ]; + const uint32 I = inputBuffer[ iPlus +inWidth*jPlus]; + if (B != H && D != F) { + outputBuffer[3*i + width*3*j ] = D == B ? D : E; + outputBuffer[3*i + width*(3*j+1)] = (D == B && E != C) || (B == F && E != A) ? B : E; + outputBuffer[3*i + width*(3*j+2)] = B == F ? F : E; + outputBuffer[3*i+1 + width*3*j ] = (D == B && E != G) || (D == H && E != A) ? D : E; + outputBuffer[3*i+1 + width*(3*j+1)] = E; + outputBuffer[3*i+1 + width*(3*j+2)] = (B == F && E != I) || (H == F && E != C) ? F : E; + outputBuffer[3*i+2 + width*3*j ] = D == H ? D : E; + outputBuffer[3*i+2 + width*(3*j+1)] = (D == H && E != I) || (H == F && E != G) ? H : E; + outputBuffer[3*i+2 + width*(3*j+2)] = H == F ? F : E; + } else { + outputBuffer[3*i + width*3*j ] = E; + outputBuffer[3*i + width*(3*j+1)] = E; + outputBuffer[3*i + width*(3*j+2)] = E; + outputBuffer[3*i+1 + width*3*j ] = E; + outputBuffer[3*i+1 + width*(3*j+1)] = E; + outputBuffer[3*i+1 + width*(3*j+2)] = E; + outputBuffer[3*i+2 + width*3*j ] = E; + outputBuffer[3*i+2 + width*(3*j+1)] = E; + outputBuffer[3*i+2 + width*(3*j+2)] = E; + } + } + } +} + +static void scale4x ( uint32* inputBuffer, uint32* outputBuffer, int inWidth, int inHeight ) +{ + int width = 2* inWidth; + int height = 2 * inHeight; + uint32 * buffer2x = new uint32[width*height]; + + scale2x ( reinterpret_cast ( inputBuffer ), reinterpret_cast ( buffer2x ), inWidth, inHeight ); + width *= 2; + height *= 2; + scale2x ( reinterpret_cast ( buffer2x ), reinterpret_cast ( outputBuffer ), 2*inWidth, 2*inHeight ); + delete[] buffer2x; +} + + +static unsigned char *scaleNxHelper( void (*scaleNxFunction) ( uint32* , uint32* , int , int), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + outWidth = N * inWidth; + outHeight = N *inHeight; + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + + scaleNxFunction ( reinterpret_cast ( inputBuffer ), reinterpret_cast ( newBuffer ), inWidth, inHeight ); + delete[] inputBuffer; + return newBuffer; +} + +#ifdef HAVE_MMX +static unsigned char *hqNxAsmHelper( void (*hqNxFunction) ( int*, unsigned char*, int, int, int ), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + outWidth = N * inWidth; + outHeight = N *inHeight; + + static int initdone = false; + + if (!initdone) + { + HQnX_asm::InitLUTs(); + initdone = true; + } + + HQnX_asm::CImage cImageIn; + cImageIn.SetImage(inputBuffer, inWidth, inHeight, 32); + cImageIn.Convert32To17(); + + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + hqNxFunction( reinterpret_cast(cImageIn.m_pBitmap), newBuffer, cImageIn.m_Xres, cImageIn.m_Yres, outWidth*4 ); + delete[] inputBuffer; + return newBuffer; +} +#endif + +static unsigned char *hqNxHelper( void (*hqNxFunction) ( unsigned*, unsigned*, int, int ), + const int N, + unsigned char *inputBuffer, + const int inWidth, + const int inHeight, + int &outWidth, + int &outHeight ) +{ + static int initdone = false; + + if (!initdone) + { + hqxInit(); + initdone = true; + } + outWidth = N * inWidth; + outHeight = N *inHeight; + + unsigned char * newBuffer = new unsigned char[outWidth*outHeight*4]; + hqNxFunction( reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), inWidth, inHeight ); + delete[] inputBuffer; + return newBuffer; +} + + +//=========================================================================== +// +// [BB] Upsamples the texture in inputBuffer, frees inputBuffer and returns +// the upsampled buffer. +// +//=========================================================================== +unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha ) +{ + // [BB] Make sure that outWidth and outHeight denote the size of + // the returned buffer even if we don't upsample the input buffer. + outWidth = inWidth; + outHeight = inHeight; + + // [BB] Don't resample if the width or height of the input texture is bigger than gl_texture_hqresize_maxinputsize. + if ( ( inWidth > gl_texture_hqresize_maxinputsize ) || ( inHeight > gl_texture_hqresize_maxinputsize ) ) + return inputBuffer; + + // [BB] Don't try to upsample textures based off FCanvasTexture. + if ( inputTexture->bHasCanvas ) + return inputBuffer; + + switch (inputTexture->UseType) + { + case FTexture::TEX_Sprite: + case FTexture::TEX_SkinSprite: + if (!(gl_texture_hqresize_targets & 2)) return inputBuffer; + break; + + case FTexture::TEX_FontChar: + if (!(gl_texture_hqresize_targets & 4)) return inputBuffer; + break; + + default: + if (!(gl_texture_hqresize_targets & 1)) return inputBuffer; + break; + } + + if (inputBuffer) + { + outWidth = inWidth; + outHeight = inHeight; + int type = gl_texture_hqresize; +#ifdef HAVE_MMX + // ASM-hqNx does not preserve the alpha channel so fall back to C-version for such textures + if (!hasAlpha && type > 3 && type <= 6) + { + type += 3; + } +#endif + + switch (type) + { + case 1: + return scaleNxHelper( &scale2x, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 2: + return scaleNxHelper( &scale3x, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 3: + return scaleNxHelper( &scale4x, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 4: + return hqNxHelper( &hq2x_32, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 5: + return hqNxHelper( &hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 6: + return hqNxHelper( &hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); +#ifdef HAVE_MMX + case 7: + return hqNxAsmHelper( &HQnX_asm::hq2x_32, 2, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 8: + return hqNxAsmHelper( &HQnX_asm::hq3x_32, 3, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + case 9: + return hqNxAsmHelper( &HQnX_asm::hq4x_32, 4, inputBuffer, inWidth, inHeight, outWidth, outHeight ); +#endif + } + } + return inputBuffer; +} diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp new file mode 100644 index 000000000..c855ef285 --- /dev/null +++ b/src/gl/textures/gl_hwtexture.cpp @@ -0,0 +1,429 @@ +/* +** gltexture.cpp +** Low level OpenGL texture handling. These classes are also +** containers for the various translations a texture can have. +** +**--------------------------------------------------------------------------- +** Copyright 2004-2014 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "gl/system/gl_system.h" +#include "templates.h" +#include "m_crc32.h" +#include "c_cvars.h" +#include "c_dispatch.h" +#include "v_palette.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/textures/gl_material.h" + + +extern TexFilter_s TexFilter[]; +extern int TexFormat[]; + + +//=========================================================================== +// +// Static texture data +// +//=========================================================================== +unsigned int FHardwareTexture::lastbound[FHardwareTexture::MAX_TEXTURES]; + +//=========================================================================== +// +// STATIC - Gets the maximum size of hardware textures +// +//=========================================================================== +int FHardwareTexture::GetTexDimension(int value) +{ + if (value > gl.max_texturesize) return gl.max_texturesize; + return value; +} + + +//=========================================================================== +// +// 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& 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(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1); + precalc.boxEnd = clamp(MAX(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1); + } +} + +void FHardwareTexture::Resize(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 vPrecalcs(height); + TArray hPrecalcs(width); + + ResampleBoxPrecalc(vPrecalcs, texheight); + ResampleBoxPrecalc(hPrecalcs, texwidth); + + 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 * texwidth + 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; + } + } +} + + + +//=========================================================================== +// +// Loads the texture image into the hardware +// +// NOTE: For some strange reason I was unable to find the source buffer +// should be one line higher than the actual texture. I got extremely +// strange crashes deep inside the GL driver when I didn't do it! +// +//=========================================================================== + +unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation) +{ + int rh,rw; + int texformat=TexFormat[gl_texture_format]; + bool deletebuffer=false; + + if (forcenocompression) + { + texformat = GL_RGBA8; + } + TranslatedTexture * glTex=GetTexID(translation); + if (glTex->glTexID==0) glGenTextures(1,&glTex->glTexID); + if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); + glBindTexture(GL_TEXTURE_2D, glTex->glTexID); + lastbound[texunit] = glTex->glTexID; + + if (!buffer) + { + w=texwidth; + h=abs(texheight); + rw = GetTexDimension (w); + rh = GetTexDimension (h); + + // The texture must at least be initialized if no data is present. + glTex->mipmapped = false; + buffer=(unsigned char *)calloc(4,rw * (rh+1)); + deletebuffer=true; + //texheight=-h; + } + else + { + rw = GetTexDimension (w); + rh = GetTexDimension (h); + + if (rw < w || rh < h) + { + // The texture is larger than what the hardware can handle so scale it down. + unsigned char * scaledbuffer=(unsigned char *)calloc(4,rw * (rh+1)); + if (scaledbuffer) + { + Resize(rw, rh, buffer, scaledbuffer); + deletebuffer=true; + buffer=scaledbuffer; + } + } + } + glTexImage2D(GL_TEXTURE_2D, 0, texformat, rw, rh, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + if (deletebuffer) free(buffer); + + if (mipmap && TexFilter[gl_texture_filter].mipmapping) + { + glGenerateMipmap(GL_TEXTURE_2D); + glTex->mipmapped = true; + } + + if (texunit != 0) glActiveTexture(GL_TEXTURE0); + return glTex->glTexID; +} + + +//=========================================================================== +// +// Creates a texture +// +//=========================================================================== +FHardwareTexture::FHardwareTexture(int _width, int _height, bool nocompression) +{ + forcenocompression = nocompression; + texwidth=_width; + texheight=_height; + + glDefTex.glTexID = 0; + glDefTex.translation = 0; + glDefTex.mipmapped = false; + glDepthID = 0; +} + + +//=========================================================================== +// +// Deletes a texture id and unbinds it from the texture units +// +//=========================================================================== +void FHardwareTexture::TranslatedTexture::Delete() +{ + if (glTexID != 0) + { + for(int i = 0; i < MAX_TEXTURES; i++) + { + if (lastbound[i] == glTexID) + { + lastbound[i] = 0; + } + } + glDeleteTextures(1, &glTexID); + glTexID = 0; + mipmapped = false; + } +} + +//=========================================================================== +// +// Frees all associated resources +// +//=========================================================================== +void FHardwareTexture::Clean(bool all) +{ + int cm_arraysize = CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size(); + + if (all) + { + glDefTex.Delete(); + } + for(unsigned int i=0;iglTexID != 0) + { + if (lastbound[texunit] == pTex->glTexID) return pTex->glTexID; + lastbound[texunit] = pTex->glTexID; + if (texunit != 0) glActiveTexture(GL_TEXTURE0 + texunit); + glBindTexture(GL_TEXTURE_2D, pTex->glTexID); + // Check if we need mipmaps on a texture that was creted without them. + if (needmipmap && !pTex->mipmapped && TexFilter[gl_texture_filter].mipmapping) + { + glGenerateMipmap(GL_TEXTURE_2D); + pTex->mipmapped = true; + } + if (texunit != 0) glActiveTexture(GL_TEXTURE0); + return pTex->glTexID; + } + return 0; +} + + +void FHardwareTexture::Unbind(int texunit) +{ + if (lastbound[texunit] != 0) + { + if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); + glBindTexture(GL_TEXTURE_2D, 0); + if (texunit != 0) glActiveTexture(GL_TEXTURE0); + lastbound[texunit] = 0; + } +} + +void FHardwareTexture::UnbindAll() +{ + for(int texunit = 0; texunit < 16; texunit++) + { + Unbind(texunit); + } + FMaterial::ClearLastTexture(); +} + +//=========================================================================== +// +// Creates a depth buffer for this texture +// +//=========================================================================== + +int FHardwareTexture::GetDepthBuffer() +{ + if (glDepthID == 0) + { + glGenRenderbuffers(1, &glDepthID); + glBindRenderbuffer(GL_RENDERBUFFER, glDepthID); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, + GetTexDimension(texwidth), GetTexDimension(texheight)); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + } + return glDepthID; +} + + +//=========================================================================== +// +// Binds this texture's surfaces to the current framrbuffer +// +//=========================================================================== + +void FHardwareTexture::BindToFrameBuffer() +{ + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glDefTex.glTexID, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); +} + diff --git a/src/gl/textures/gl_hwtexture.h b/src/gl/textures/gl_hwtexture.h new file mode 100644 index 000000000..7fa0f0580 --- /dev/null +++ b/src/gl/textures/gl_hwtexture.h @@ -0,0 +1,84 @@ + +#ifndef __GLTEXTURE_H +#define __GLTEXTURE_H + +#ifdef LoadImage +#undef LoadImage +#endif + +#define SHADED_TEXTURE -1 +#define DIRECT_PALETTE -2 + +#include "tarray.h" + +class FCanvasTexture; +class AActor; + +// For error catching while changing parameters. +enum EInvalid +{ + Invalid = 0 +}; + +enum +{ + GLT_CLAMPX=1, + GLT_CLAMPY=2 +}; + +class FHardwareTexture +{ +public: + enum + { + MAX_TEXTURES = 16 + }; + +private: + struct TranslatedTexture + { + unsigned int glTexID; + int translation; + bool mipmapped; + + void Delete(); + }; + +public: + + static unsigned int lastbound[MAX_TEXTURES]; + static int lastactivetexture; + static int max_texturesize; + + static int GetTexDimension(int value); + +private: + + short texwidth, texheight; + bool forcenocompression; + + TranslatedTexture glDefTex; + TArray glTex_Translated; + unsigned int glDepthID; // only used by camera textures + + TranslatedTexture * GetTexID(int translation); + + int GetDepthBuffer(); + void Resize(int width, int height, unsigned char *src_data, unsigned char *dst_data); + +public: + FHardwareTexture(int w, int h, bool nocompress); + ~FHardwareTexture(); + + static void Unbind(int texunit); + static void UnbindAll(); + + void BindToFrameBuffer(); + + unsigned int Bind(int texunit, int translation, bool needmipmap); + unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation); + + void Clean(bool all); +}; + +#endif diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp new file mode 100644 index 000000000..a359191e1 --- /dev/null +++ b/src/gl/textures/gl_material.cpp @@ -0,0 +1,851 @@ +/* +** gl_material.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2004-2009 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** 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 "gl/system/gl_system.h" +#include "w_wad.h" +#include "m_png.h" +#include "sbar.h" +#include "gi.h" +#include "cmdlib.h" +#include "c_dispatch.h" +#include "stats.h" +#include "r_utility.h" +#include "templates.h" +#include "sc_man.h" +#include "colormatcher.h" + +//#include "gl/gl_intern.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/data/gl_data.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_translate.h" +#include "gl/textures/gl_bitmap.h" +#include "gl/textures/gl_material.h" +#include "gl/textures/gl_samplers.h" +#include "gl/shaders/gl_shader.h" + +EXTERN_CVAR(Bool, gl_render_precise) +EXTERN_CVAR(Int, gl_lightmode) +EXTERN_CVAR(Bool, gl_precache) +EXTERN_CVAR(Bool, gl_texture_usehires) + +//=========================================================================== +// +// The GL texture maintenance class +// +//=========================================================================== + +//=========================================================================== +// +// Constructor +// +//=========================================================================== +FGLTexture::FGLTexture(FTexture * tx, bool expandpatches) +{ + assert(tx->gl_info.SystemTexture[expandpatches] == NULL); + tex = tx; + + mHwTexture = NULL; + HiresLump = -1; + hirestexture = NULL; + bHasColorkey = false; + bIsTransparent = -1; + bExpandFlag = expandpatches; + tex->gl_info.SystemTexture[expandpatches] = this; +} + +//=========================================================================== +// +// Destructor +// +//=========================================================================== + +FGLTexture::~FGLTexture() +{ + Clean(true); + if (hirestexture) delete hirestexture; +} + +//========================================================================== +// +// Checks for the presence of a hires texture replacement and loads it +// +//========================================================================== +unsigned char *FGLTexture::LoadHiresTexture(FTexture *tex, int *width, int *height) +{ + if (bExpandFlag) return NULL; // doesn't work for expanded textures + + if (HiresLump==-1) + { + bHasColorkey = false; + HiresLump = CheckDDPK3(tex); + if (HiresLump < 0) HiresLump = CheckExternalFile(tex, bHasColorkey); + + if (HiresLump >=0) + { + hirestexture = FTexture::CreateTexture(HiresLump, FTexture::TEX_Any); + } + } + if (hirestexture != NULL) + { + int w=hirestexture->GetWidth(); + int h=hirestexture->GetHeight(); + + unsigned char * buffer=new unsigned char[w*(h+1)*4]; + memset(buffer, 0, w * (h+1) * 4); + + FGLBitmap bmp(buffer, w*4, w, h); + + int trans = hirestexture->CopyTrueColorPixels(&bmp, 0, 0); + hirestexture->CheckTrans(buffer, w*h, trans); + bIsTransparent = hirestexture->gl_info.mIsTransparent; + + if (bHasColorkey) + { + // This is a crappy Doomsday color keyed image + // We have to remove the key manually. :( + DWORD * dwdata=(DWORD*)buffer; + for (int i=(w*h);i>0;i--) + { + if (dwdata[i]==0xffffff00 || dwdata[i]==0xffff00ff) dwdata[i]=0; + } + } + *width = w; + *height = h; + return buffer; + } + return NULL; +} + +//=========================================================================== +// +// Deletes all allocated resources +// +//=========================================================================== + +void FGLTexture::Clean(bool all) +{ + if (mHwTexture) + { + if (!all) mHwTexture->Clean(false); + else + { + delete mHwTexture; + mHwTexture = NULL; + } + } +} + + +//=========================================================================== +// +// Initializes the buffer for the texture data +// +//=========================================================================== + +unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded) +{ + unsigned char * buffer; + int W, H; + + + // Textures that are already scaled in the texture lump will not get replaced + // by hires textures + if (gl_texture_usehires && hirescheck != NULL) + { + buffer = LoadHiresTexture (hirescheck, &w, &h); + if (buffer) + { + return buffer; + } + } + + int exx = bExpandFlag && createexpanded; + + W = w = tex->GetWidth() + 2 * exx; + H = h = tex->GetHeight() + 2 * exx; + + + buffer=new unsigned char[W*(H+1)*4]; + memset(buffer, 0, W * (H+1) * 4); + + FGLBitmap bmp(buffer, W*4, W, H); + bmp.SetTranslationInfo(translation); + + if (tex->bComplex) + { + FBitmap imgCreate; + + // The texture contains special processing so it must be composited using the + // base bitmap class and then be converted as a whole. + if (imgCreate.Create(W, H)) + { + memset(imgCreate.GetPixels(), 0, W * H * 4); + int trans = tex->CopyTrueColorPixels(&imgCreate, exx, exx); + bmp.CopyPixelDataRGB(0, 0, imgCreate.GetPixels(), W, H, 4, W * 4, 0, CF_BGRA); + tex->CheckTrans(buffer, W*H, trans); + bIsTransparent = tex->gl_info.mIsTransparent; + } + } + else if (translation<=0) + { + int trans = tex->CopyTrueColorPixels(&bmp, exx, exx); + tex->CheckTrans(buffer, W*H, trans); + bIsTransparent = tex->gl_info.mIsTransparent; + } + else + { + // When using translations everything must be mapped to the base palette. + // Since FTexture's method is doing exactly that by calling GetPixels let's use that here + // to do all the dirty work for us. ;) + tex->FTexture::CopyTrueColorPixels(&bmp, exx, exx); + bIsTransparent = 0; + } + + // if we just want the texture for some checks there's no need for upsampling. + if (!createexpanded) return buffer; + + // [BB] The hqnx upsampling (not the scaleN one) destroys partial transparency, don't upsamle textures using it. + // [BB] Potentially upsample the buffer. + return gl_CreateUpsampledTextureBuffer ( tex, buffer, W, H, w, h, !!bIsTransparent); +} + + +//=========================================================================== +// +// Create hardware texture for world use +// +//=========================================================================== + +FHardwareTexture *FGLTexture::CreateHwTexture() +{ + if (tex->UseType==FTexture::TEX_Null) return NULL; // Cannot register a NULL texture + if (mHwTexture == NULL) + { + mHwTexture = new FHardwareTexture(tex->GetWidth() + bExpandFlag*2, tex->GetHeight() + bExpandFlag*2, tex->gl_info.bNoCompress); + } + return mHwTexture; +} + +//=========================================================================== +// +// Binds a texture to the renderer +// +//=========================================================================== + +const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int translation, FTexture *hirescheck) +{ + int usebright = false; + + if (translation <= 0) translation = -translation; + else translation = GLTranslationPalette::GetInternalTranslation(translation); + + bool needmipmap = (clampmode <= CLAMP_XY); + + FHardwareTexture *hwtex = CreateHwTexture(); + + if (hwtex) + { + // Texture has become invalid + if ((!tex->bHasCanvas && !tex->bWarped) && tex->CheckModified()) + { + Clean(true); + hwtex = CreateHwTexture(); + } + + // Bind it to the system. + if (!hwtex->Bind(texunit, translation, needmipmap)) + { + + int w=0, h=0; + + // Create this texture + unsigned char * buffer = NULL; + + if (!tex->bHasCanvas) + { + buffer = CreateTexBuffer(translation, w, h, hirescheck); + tex->ProcessData(buffer, w, h, false); + } + if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation)) + { + // could not create texture + delete[] buffer; + return NULL; + } + delete[] buffer; + } + + if (tex->bHasCanvas) static_cast(tex)->NeedUpdate(); + GLRenderer->mSamplerManager->Bind(texunit, clampmode); + return hwtex; + } + return NULL; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +fixed_t FTexCoordInfo::RowOffset(fixed_t rowoffset) const +{ + if (mTempScaleY == FRACUNIT) + { + if (mScaleY==FRACUNIT || mWorldPanning) return rowoffset; + else return FixedDiv(rowoffset, mScaleY); + } + else + { + if (mWorldPanning) return FixedDiv(rowoffset, mTempScaleY); + else return FixedDiv(rowoffset, mScaleY); + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +fixed_t FTexCoordInfo::TextureOffset(fixed_t textureoffset) const +{ + if (mTempScaleX == FRACUNIT) + { + if (mScaleX==FRACUNIT || mWorldPanning) return textureoffset; + else return FixedDiv(textureoffset, mScaleX); + } + else + { + if (mWorldPanning) return FixedDiv(textureoffset, mTempScaleX); + else return FixedDiv(textureoffset, mScaleX); + } +} + +//=========================================================================== +// +// Returns the size for which texture offset coordinates are used. +// +//=========================================================================== + +fixed_t FTexCoordInfo::TextureAdjustWidth() const +{ + if (mWorldPanning) + { + if (mTempScaleX == FRACUNIT) return mRenderWidth; + else return FixedDiv(mWidth, mTempScaleX); + } + else return mWidth; +} + + + +//=========================================================================== +// +// +// +//=========================================================================== +FGLTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand) +{ + if (tex && tex->UseType!=FTexture::TEX_Null) + { + FGLTexture *gltex = tex->gl_info.SystemTexture[expand]; + if (gltex == NULL) + { + gltex = new FGLTexture(tex, expand); + } + return gltex; + } + return NULL; +} + +//=========================================================================== +// +// Constructor +// +//=========================================================================== +TArray FMaterial::mMaterials; +int FMaterial::mMaxBound; + +FMaterial::FMaterial(FTexture * tx, bool expanded) +{ + mShaderIndex = 0; + tex = tx; + + // TODO: apply custom shader object here + /* if (tx->CustomShaderDefinition) + { + } + else + */ + if (tx->bWarped) + { + mShaderIndex = tx->bWarped; + tx->gl_info.shaderspeed = static_cast(tx)->GetSpeed(); + } + else if (tx->bHasCanvas) + { + } + else + { + if (tx->gl_info.shaderindex >= FIRST_USER_SHADER) + { + mShaderIndex = tx->gl_info.shaderindex; + } + else + { + tx->CreateDefaultBrightmap(); + if (tx->gl_info.Brightmap != NULL) + { + ValidateSysTexture(tx->gl_info.Brightmap, expanded); + FTextureLayer layer = {tx->gl_info.Brightmap, false}; + mTextureLayers.Push(layer); + mShaderIndex = 3; + } + } + } + mBaseLayer = ValidateSysTexture(tx, expanded); + + + mWidth = tx->GetWidth(); + mHeight = tx->GetHeight(); + mLeftOffset = tx->LeftOffset; + mTopOffset = tx->TopOffset; + mRenderWidth = tx->GetScaledWidth(); + mRenderHeight = tx->GetScaledHeight(); + mSpriteU[0] = mSpriteV[0] = 0.f; + mSpriteU[1] = mSpriteV[1] = 1.f; + + FTexture *basetex = tx->GetRedirect(false); + // allow the redirect only if the textute is not expanded or the scale matches. + if (!expanded || (tx->xScale == basetex->xScale && tx->yScale == basetex->yScale)) + { + mBaseLayer = ValidateSysTexture(basetex, expanded); + } + + float fxScale = FIXED2FLOAT(tx->xScale); + float fyScale = FIXED2FLOAT(tx->yScale); + + // mSpriteRect is for positioning the sprite in the scene. + mSpriteRect.left = -mLeftOffset / fxScale; + mSpriteRect.top = -mTopOffset / fyScale; + mSpriteRect.width = mWidth / fxScale; + mSpriteRect.height = mHeight / fyScale; + + if (expanded) + { + // a little adjustment to make sprites look better with texture filtering: + // create a 1 pixel wide empty frame around them. + int trim[4]; + bool trimmed = TrimBorders(trim); // get the trim size before adding the empty frame + + int oldwidth = mWidth; + int oldheight = mHeight; + + mWidth+=2; + mHeight+=2; + mLeftOffset+=1; + mTopOffset+=1; + mRenderWidth = mRenderWidth * mWidth / oldwidth; + mRenderHeight = mRenderHeight * mHeight / oldheight; + + // Reposition the sprite with the frame considered + mSpriteRect.left = -mLeftOffset / fxScale; + mSpriteRect.top = -mTopOffset / fyScale; + mSpriteRect.width = mWidth / fxScale; + mSpriteRect.height = mHeight / fyScale; + + if (trimmed) + { + mSpriteRect.left += trim[0] / fxScale; + mSpriteRect.top += trim[1] / fyScale; + + mSpriteRect.width -= (oldwidth - trim[2]) / fxScale; + mSpriteRect.height -= (oldheight - trim[3]) / fyScale; + + mSpriteU[0] = trim[0] / (float)mWidth; + mSpriteV[0] = trim[1] / (float)mHeight; + mSpriteU[1] -= (oldwidth - trim[0] - trim[2]) / (float)mWidth; + mSpriteV[1] -= (oldheight - trim[1] - trim[3]) / (float)mHeight; + } + } + + mTextureLayers.ShrinkToFit(); + mMaxBound = -1; + mMaterials.Push(this); + tx->gl_info.Material[expanded] = this; + if (tx->bHasCanvas) tx->gl_info.mIsTransparent = 0; + mExpanded = expanded; +} + +//=========================================================================== +// +// Destructor +// +//=========================================================================== + +FMaterial::~FMaterial() +{ + for(unsigned i=0;i= size) + { + // completely empty + rect[0] = 0; + rect[1] = 0; + rect[2] = 1; + rect[3] = 1; + delete [] buffer; + return true; + } + + for(last = size-1; last >= first; last--) + { + if (buffer[last*4+3] != 0) break; + } + + rect[1] = first / w; + rect[3] = 1 + last/w - rect[1]; + + rect[0] = 0; + rect[2] = w; + + unsigned char *bufferoff = buffer + (rect[1] * w * 4); + h = rect[3]; + + for(int x = 0; x < w; x++) + { + for(int y = 0; y < h; y++) + { + if (bufferoff[(x+y*w)*4+3] != 0) goto outl; + } + rect[0]++; + } +outl: + rect[2] -= rect[0]; + + for(int x = w-1; rect[2] > 1; x--) + { + for(int y = 0; y < h; y++) + { + if (bufferoff[(x+y*w)*4+3] != 0) + { + delete [] buffer; + return true; + } + } + rect[2]--; + } + delete [] buffer; + return true; +} + + +//=========================================================================== +// +// Binds a texture to the renderer +// +//=========================================================================== + +static FMaterial *last; +static int lastclamp; +static int lasttrans; + + +void FMaterial::Bind(int clampmode, int translation) +{ + // avoid rebinding the same texture multiple times. + if (this == last && lastclamp == clampmode && translation == lasttrans) return; + last = this; + lastclamp = clampmode; + lasttrans = translation; + + int usebright = false; + int maxbound = 0; + bool allowhires = tex->xScale == FRACUNIT && tex->yScale == FRACUNIT && clampmode <= CLAMP_XY && !mExpanded; + + if (tex->bHasCanvas) clampmode = CLAMP_CAMTEX; + else if (tex->bWarped && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE; + + const FHardwareTexture *gltexture = mBaseLayer->Bind(0, clampmode, translation, allowhires? tex:NULL); + if (gltexture != NULL) + { + for(unsigned i=0;iid; + layer = TexMan(id); + ValidateSysTexture(layer, mExpanded); + } + else + { + layer = mTextureLayers[i].texture; + } + layer->gl_info.SystemTexture[mExpanded]->Bind(i+1, clampmode, 0, NULL); + maxbound = i+1; + } + } + // unbind everything from the last texture that's still active + for(int i=maxbound+1; i<=mMaxBound;i++) + { + FHardwareTexture::Unbind(i); + mMaxBound = maxbound; + } +} + + +//=========================================================================== +// +// +// +//=========================================================================== +void FMaterial::Precache() +{ + Bind(0, 0); +} + +//=========================================================================== +// +// Retrieve texture coordinate info for per-wall scaling +// +//=========================================================================== + +void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const +{ + if (x == FRACUNIT) + { + tci->mRenderWidth = mRenderWidth; + tci->mScaleX = tex->xScale; + tci->mTempScaleX = FRACUNIT; + } + else + { + fixed_t scale_x = FixedMul(x, tex->xScale); + int foo = (mWidth << 17) / scale_x; + tci->mRenderWidth = (foo >> 1) + (foo & 1); + tci->mScaleX = scale_x; + tci->mTempScaleX = x; + } + + if (y == FRACUNIT) + { + tci->mRenderHeight = mRenderHeight; + tci->mScaleY = tex->yScale; + tci->mTempScaleY = FRACUNIT; + } + else + { + fixed_t scale_y = FixedMul(y, tex->yScale); + int foo = (mHeight << 17) / scale_y; + tci->mRenderHeight = (foo >> 1) + (foo & 1); + tci->mScaleY = scale_y; + tci->mTempScaleY = y; + } + if (tex->bHasCanvas) + { + tci->mScaleY = -tci->mScaleY; + tci->mRenderHeight = -tci->mRenderHeight; + } + tci->mWorldPanning = tex->bWorldPanning; + tci->mWidth = mWidth; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +int FMaterial::GetAreas(FloatRect **pAreas) const +{ + if (mShaderIndex == 0) // texture splitting can only be done if there's no attached effects + { + FTexture *tex = mBaseLayer->tex; + *pAreas = tex->gl_info.areas; + return tex->gl_info.areacount; + } + else + { + return 0; + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FMaterial::BindToFrameBuffer() +{ + if (mBaseLayer->mHwTexture == NULL) + { + // must create the hardware texture first + mBaseLayer->Bind(0, 0, 0, NULL); + FHardwareTexture::Unbind(0); + ClearLastTexture(); + } + mBaseLayer->mHwTexture->BindToFrameBuffer(); +} + +//========================================================================== +// +// Gets a texture from the texture manager and checks its validity for +// GL rendering. +// +//========================================================================== + +FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand) +{ +again: + if (tex && tex->UseType!=FTexture::TEX_Null) + { + if (tex->gl_info.bNoExpand) expand = false; + + FMaterial *gltex = tex->gl_info.Material[expand]; + if (gltex == NULL) + { + if (expand) + { + if (tex->bWarped || tex->bHasCanvas || tex->gl_info.shaderindex >= FIRST_USER_SHADER) + { + tex->gl_info.bNoExpand = true; + goto again; + } + if (tex->gl_info.Brightmap != NULL && + (tex->GetWidth() != tex->gl_info.Brightmap->GetWidth() || + tex->GetHeight() != tex->gl_info.Brightmap->GetHeight()) + ) + { + // do not expand if the brightmap's size differs. + tex->gl_info.bNoExpand = true; + goto again; + } + } + gltex = new FMaterial(tex, expand); + } + return gltex; + } + return NULL; +} + +FMaterial * FMaterial::ValidateTexture(FTextureID no, bool expand, bool translate) +{ + return ValidateTexture(translate? TexMan(no) : TexMan[no], expand); +} + + +//========================================================================== +// +// Flushes all hardware dependent data +// +//========================================================================== + +void FMaterial::FlushAll() +{ + for(int i=mMaterials.Size()-1;i>=0;i--) + { + mMaterials[i]->Clean(true); + } + // This is for shader layers. All shader layers must be managed by the texture manager + // so this will catch everything. + for(int i=TexMan.NumTextures()-1;i>=0;i--) + { + for (int j = 0; j < 2; j++) + { + FGLTexture *gltex = TexMan.ByIndex(i)->gl_info.SystemTexture[j]; + if (gltex != NULL) gltex->Clean(true); + } + } +} + +void FMaterial::ClearLastTexture() +{ + last = NULL; +} diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h new file mode 100644 index 000000000..61fdd6e46 --- /dev/null +++ b/src/gl/textures/gl_material.h @@ -0,0 +1,260 @@ + +#ifndef __GL_TEXTURE_H +#define __GL_TEXTURE_H + +#include "m_fixed.h" +#include "textures/textures.h" +#include "gl/textures/gl_hwtexture.h" +#include "gl/renderer/gl_colormap.h" +#include "i_system.h" + +EXTERN_CVAR(Bool, gl_precache) + +struct FRemapTable; +class FTextureShader; + +enum +{ + CLAMP_NONE = 0, + CLAMP_X = 1, + CLAMP_Y = 2, + CLAMP_XY = 3, + CLAMP_XY_NOMIP = 4, + CLAMP_NOFILTER = 5, + CLAMP_CAMTEX = 6, +}; + + + +struct FTexCoordInfo +{ + int mRenderWidth; + int mRenderHeight; + int mWidth; + fixed_t mScaleX; + fixed_t mScaleY; + fixed_t mTempScaleX; + fixed_t mTempScaleY; + bool mWorldPanning; + + float FloatToTexU(float v) const { return v / mRenderWidth; } + float FloatToTexV(float v) const { return v / mRenderHeight; } + fixed_t RowOffset(fixed_t ofs) const; + fixed_t TextureOffset(fixed_t ofs) const; + fixed_t TextureAdjustWidth() const; +}; + +//=========================================================================== +// +// this is the texture maintenance class for OpenGL. +// +//=========================================================================== +class FMaterial; + + +class FGLTexture +{ + friend class FMaterial; +public: + FTexture * tex; + FTexture * hirestexture; + char bIsTransparent; + int HiresLump; + +private: + FHardwareTexture *mHwTexture; + + bool bHasColorkey; // only for hires + bool bExpandFlag; + + unsigned char * LoadHiresTexture(FTexture *hirescheck, int *width, int *height); + + FHardwareTexture *CreateHwTexture(); + + const FHardwareTexture *Bind(int texunit, int clamp, int translation, FTexture *hirescheck); + +public: + FGLTexture(FTexture * tx, bool expandpatches); + ~FGLTexture(); + + unsigned char * CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded = true); + + void Clean(bool all); + int Dump(int i); + +}; + +//=========================================================================== +// +// this is the material class for OpenGL. +// +//=========================================================================== + +class FMaterial +{ + friend class FRenderState; + + struct FTextureLayer + { + FTexture *texture; + bool animated; + }; + + static TArray mMaterials; + static int mMaxBound; + + FGLTexture *mBaseLayer; + TArray mTextureLayers; + int mShaderIndex; + + short mLeftOffset; + short mTopOffset; + short mWidth; + short mHeight; + short mRenderWidth; + short mRenderHeight; + bool mExpanded; + + float mSpriteU[2], mSpriteV[2]; + FloatRect mSpriteRect; + + FGLTexture * ValidateSysTexture(FTexture * tex, bool expand); + bool TrimBorders(int *rect); + +public: + FTexture *tex; + + FMaterial(FTexture *tex, bool forceexpand); + ~FMaterial(); + void Precache(); + bool isMasked() const + { + return !!mBaseLayer->tex->bMasked; + } + + int GetLayers() const + { + return mTextureLayers.Size() + 1; + } + + void Bind(int clamp, int translation); + + unsigned char * CreateTexBuffer(int translation, int & w, int & h, bool allowhires=true, bool createexpanded = true) const + { + return mBaseLayer->CreateTexBuffer(translation, w, h, allowhires? tex : NULL, createexpanded); + } + + void Clean(bool f) + { + mBaseLayer->Clean(f); + } + + void BindToFrameBuffer(); + // Patch drawing utilities + + void GetSpriteRect(FloatRect * r) const + { + *r = mSpriteRect; + } + + void GetTexCoordInfo(FTexCoordInfo *tci, fixed_t x, fixed_t y) const; + + // This is scaled size in integer units as needed by walls and flats + int TextureHeight() const { return mRenderHeight; } + int TextureWidth() const { return mRenderWidth; } + + int GetAreas(FloatRect **pAreas) const; + + int GetWidth() const + { + return mWidth; + } + + int GetHeight() const + { + return mHeight; + } + + int GetLeftOffset() const + { + return mLeftOffset; + } + + int GetTopOffset() const + { + return mTopOffset; + } + + int GetScaledLeftOffset() const + { + return DivScale16(mLeftOffset, tex->xScale); + } + + int GetScaledTopOffset() const + { + return DivScale16(mTopOffset, tex->yScale); + } + + float GetScaledLeftOffsetFloat() const + { + return mLeftOffset / FIXED2FLOAT(tex->xScale); + } + + float GetScaledTopOffsetFloat() const + { + return mTopOffset/ FIXED2FLOAT(tex->yScale); + } + + // This is scaled size in floating point as needed by sprites + float GetScaledWidthFloat() const + { + return mWidth / FIXED2FLOAT(tex->xScale); + } + + float GetScaledHeightFloat() const + { + return mHeight / FIXED2FLOAT(tex->yScale); + } + + // Get right/bottom UV coordinates for patch drawing + float GetUL() const { return 0; } + float GetVT() const { return 0; } + float GetUR() const { return 1; } + float GetVB() const { return 1; } + float GetU(float upix) const { return upix/(float)mWidth; } + float GetV(float vpix) const { return vpix/(float)mHeight; } + + float GetSpriteUL() const { return mSpriteU[0]; } + float GetSpriteVT() const { return mSpriteV[0]; } + float GetSpriteUR() const { return mSpriteU[1]; } + float GetSpriteVB() const { return mSpriteV[1]; } + + + + bool GetTransparent() const + { + if (mBaseLayer->bIsTransparent == -1) + { + if (!mBaseLayer->tex->bHasCanvas) + { + int w, h; + unsigned char *buffer = CreateTexBuffer(0, w, h); + delete [] buffer; + } + else + { + mBaseLayer->bIsTransparent = 0; + } + } + return !!mBaseLayer->bIsTransparent; + } + + static void DeleteAll(); + static void FlushAll(); + static FMaterial *ValidateTexture(FTexture * tex, bool expand); + static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans); + static void ClearLastTexture(); + +}; + +#endif diff --git a/src/gl/textures/gl_samplers.cpp b/src/gl/textures/gl_samplers.cpp new file mode 100644 index 000000000..3851d6c71 --- /dev/null +++ b/src/gl/textures/gl_samplers.cpp @@ -0,0 +1,112 @@ +/* +** gl_samplers.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2014 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** 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 "gl/system/gl_system.h" +#include "templates.h" +#include "c_cvars.h" +#include "c_dispatch.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderer.h" +#include "gl_samplers.h" + +extern TexFilter_s TexFilter[]; + + +FSamplerManager::FSamplerManager() +{ + glGenSamplers(7, mSamplers); + SetTextureFilterMode(); + glSamplerParameteri(mSamplers[5], GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glSamplerParameteri(mSamplers[5], GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glSamplerParameterf(mSamplers[5], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + glSamplerParameterf(mSamplers[4], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + glSamplerParameterf(mSamplers[6], GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.f); + + glSamplerParameteri(mSamplers[1], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[2], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + +} + +FSamplerManager::~FSamplerManager() +{ + UnbindAll(); + glDeleteSamplers(7, mSamplers); +} + +void FSamplerManager::UnbindAll() +{ + for (int i = 0; i < FHardwareTexture::MAX_TEXTURES; i++) + { + mLastBound[i] = 0; + glBindSampler(i, 0); + } +} + +void FSamplerManager::Bind(int texunit, int num) +{ + unsigned int samp = mSamplers[num]; + //if (samp != mLastBound[texunit]) + { + glBindSampler(texunit, samp); + mLastBound[texunit] = samp; + } +} + + +void FSamplerManager::SetTextureFilterMode() +{ + UnbindAll(); + + for (int i = 0; i < 4; i++) + { + glSamplerParameteri(mSamplers[i], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glSamplerParameteri(mSamplers[i], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameterf(mSamplers[i], GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + glSamplerParameteri(mSamplers[4], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameteri(mSamplers[4], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameteri(mSamplers[6], GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glSamplerParameteri(mSamplers[6], GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); +} + + diff --git a/src/gl/textures/gl_samplers.h b/src/gl/textures/gl_samplers.h new file mode 100644 index 000000000..26589b4ad --- /dev/null +++ b/src/gl/textures/gl_samplers.h @@ -0,0 +1,28 @@ +#ifndef __GL_SAMPLERS_H +#define __GL_SAMPLERS_H + +#include "gl_hwtexture.h" + +class FSamplerManager +{ + // We need 6 different samplers: 4 for the different clamping modes, + // one for 2D-textures and one for voxel textures + unsigned int mSamplers[7]; + unsigned int mLastBound[FHardwareTexture::MAX_TEXTURES]; + + void UnbindAll(); + +public: + + FSamplerManager(); + ~FSamplerManager(); + + void Bind(int texunit, int num); + void SetTextureFilterMode(); + + +}; + + +#endif + diff --git a/src/gl/textures/gl_skyboxtexture.cpp b/src/gl/textures/gl_skyboxtexture.cpp new file mode 100644 index 000000000..c86556ea9 --- /dev/null +++ b/src/gl/textures/gl_skyboxtexture.cpp @@ -0,0 +1,216 @@ +/* +** gl_skyboxtexture.cpp +** +**--------------------------------------------------------------------------- +** Copyright 2004-2009 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** 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 "sc_man.h" +#include "w_wad.h" +#include "textures/textures.h" +#include "gl/textures/gl_skyboxtexture.h" + + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +FSkyBox::FSkyBox() +{ + faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5]=NULL; + UseType=TEX_Override; + gl_info.bSkybox = true; + fliptop = false; +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +FSkyBox::~FSkyBox() +{ + // The faces are only referenced but not owned so don't delete them. +} + +//----------------------------------------------------------------------------- +// +// If something attempts to use this as a texture just pass the information of the first face. +// +//----------------------------------------------------------------------------- + +const BYTE *FSkyBox::GetColumn (unsigned int column, const Span **spans_out) +{ + if (faces[0]) return faces[0]->GetColumn(column, spans_out); + return NULL; +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +const BYTE *FSkyBox::GetPixels () +{ + if (faces[0]) return faces[0]->GetPixels(); + return NULL; +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +int FSkyBox::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +{ + if (faces[0]) return faces[0]->CopyTrueColorPixels(bmp, x, y, rotate, inf); + return 0; +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +bool FSkyBox::UseBasePalette() +{ + return false; // not really but here it's not important. +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyBox::Unload () +{ + //for(int i=0;i<6;i++) if (faces[i]) faces[i]->Unload(); +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void gl_ParseSkybox(FScanner &sc) +{ + int facecount=0; + + sc.MustGetString(); + + FSkyBox * sb = new FSkyBox; + sb->Name = sc.String; + sb->Name.ToUpper(); + if (sc.CheckString("fliptop")) + { + sb->fliptop = true; + } + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + sc.MustGetString(); + if (facecount<6) + { + sb->faces[facecount] = TexMan[TexMan.GetTexture(sc.String, FTexture::TEX_Wall, FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_Overridable)]; + } + facecount++; + } + if (facecount != 3 && facecount != 6) + { + sc.ScriptError("%s: Skybox definition requires either 3 or 6 faces", sb->Name.GetChars()); + } + sb->SetSize(); + TexMan.AddTexture(sb); +} + +//----------------------------------------------------------------------------- +// +// gl_ParseVavoomSkybox +// +//----------------------------------------------------------------------------- + +void gl_ParseVavoomSkybox() +{ + int lump = Wads.CheckNumForName("SKYBOXES"); + + if (lump < 0) return; + + FScanner sc(lump); + while (sc.GetString()) + { + int facecount=0; + int maplump = -1; + FSkyBox * sb = new FSkyBox; + sb->Name = sc.String; + sb->Name.ToUpper(); + sb->fliptop = true; + sc.MustGetStringName("{"); + while (!sc.CheckString("}")) + { + if (facecount<6) + { + sc.MustGetStringName("{"); + sc.MustGetStringName("map"); + sc.MustGetString(); + + maplump = Wads.CheckNumForFullName(sc.String, true); + + FTexture *tex = TexMan.FindTexture(sc.String, FTexture::TEX_Wall, FTextureManager::TEXMAN_TryAny); + if (tex != NULL) + { + Printf("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->Name.GetChars()); + } + sb->faces[facecount] = tex; + sc.MustGetStringName("}"); + } + facecount++; + } + if (facecount != 6) + { + sc.ScriptError("%s: Skybox definition requires 6 faces", sb->Name.GetChars()); + } + sb->SetSize(); + TexMan.AddTexture(sb); + } +} + diff --git a/src/gl/textures/gl_skyboxtexture.h b/src/gl/textures/gl_skyboxtexture.h new file mode 100644 index 000000000..28a052be9 --- /dev/null +++ b/src/gl/textures/gl_skyboxtexture.h @@ -0,0 +1,44 @@ + + +//----------------------------------------------------------------------------- +// +// This is not a real texture but will be added to the texture manager +// so that it can be handled like any other sky. +// +//----------------------------------------------------------------------------- + +class FSkyBox : public FTexture +{ +public: + + FTexture * faces[6]; + bool fliptop; + + FSkyBox(); + ~FSkyBox(); + const BYTE *GetColumn (unsigned int column, const Span **spans_out); + const BYTE *GetPixels (); + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf); + bool UseBasePalette(); + void Unload (); + + void SetSize() + { + if (faces[0]) + { + Width=faces[0]->GetWidth(); + Height=faces[0]->GetHeight(); + CalcBitSize(); + } + } + + bool Is3Face() const + { + return faces[5]==NULL; + } + + bool IsFlipped() const + { + return fliptop; + } +}; diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp new file mode 100644 index 000000000..414f631a4 --- /dev/null +++ b/src/gl/textures/gl_texture.cpp @@ -0,0 +1,839 @@ +/* +** Global texture data +** +**--------------------------------------------------------------------------- +** Copyright 2004-2009 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** +** 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 "gl/system/gl_system.h" +#include "c_cvars.h" +#include "w_wad.h" +#include "templates.h" +#include "colormatcher.h" +#include "r_data/r_translate.h" +#include "c_dispatch.h" +#ifdef _WIN32 +#include "win32gliface.h" +#endif +#include "v_palette.h" +#include "sc_man.h" + +#include "gl/system/gl_interface.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/textures/gl_texture.h" +#include "gl/textures/gl_material.h" +#include "gl/textures/gl_samplers.h" + +//========================================================================== +// +// Texture CVARs +// +//========================================================================== +CUSTOM_CVAR(Float,gl_texture_filter_anisotropic,8.0f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +{ + if (GLRenderer != NULL && GLRenderer->mSamplerManager != NULL) GLRenderer->mSamplerManager->SetTextureFilterMode(); +} + +CCMD(gl_flush) +{ + if (GLRenderer != NULL) GLRenderer->FlushTextures(); +} + +CUSTOM_CVAR(Int, gl_texture_filter, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +{ + if (self < 0 || self > 5) self=4; + if (GLRenderer != NULL && GLRenderer->mSamplerManager != NULL) GLRenderer->mSamplerManager->SetTextureFilterMode(); +} + +CUSTOM_CVAR(Int, gl_texture_format, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +{ + // [BB] The number of available texture modes depends on the GPU capabilities. + // RFL_TEXTURE_COMPRESSION gives us one additional mode and RFL_TEXTURE_COMPRESSION_S3TC + // another three. + int numOfAvailableTextureFormat = 4; + if ( gl.flags & RFL_TEXTURE_COMPRESSION && gl.flags & RFL_TEXTURE_COMPRESSION_S3TC ) + numOfAvailableTextureFormat = 8; + else if ( gl.flags & RFL_TEXTURE_COMPRESSION ) + numOfAvailableTextureFormat = 5; + if (self < 0 || self > numOfAvailableTextureFormat-1) self=0; + GLRenderer->FlushTextures(); +} + +CUSTOM_CVAR(Bool, gl_texture_usehires, true, CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + if (GLRenderer != NULL) GLRenderer->FlushTextures(); +} + +CVAR(Bool, gl_precache, false, CVAR_ARCHIVE) + +CVAR(Bool, gl_trimsprites, true, CVAR_ARCHIVE); + +TexFilter_s TexFilter[]={ + {GL_NEAREST, GL_NEAREST, false}, + {GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST, true}, + {GL_LINEAR, GL_LINEAR, false}, + {GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR, true}, + {GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, true}, + {GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST, true}, +}; + +int TexFormat[]={ + GL_RGBA8, + GL_RGB5_A1, + GL_RGBA4, + GL_RGBA2, + // [BB] Added compressed texture formats. + GL_COMPRESSED_RGBA_ARB, + GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, + GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, + GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, +}; + + + +bool HasGlobalBrightmap; +FRemapTable GlobalBrightmap; + +//=========================================================================== +// +// Examines the colormap to see if some of the colors have to be +// considered fullbright all the time. +// +//=========================================================================== + +void gl_GenerateGlobalBrightmapFromColormap() +{ + HasGlobalBrightmap = false; + int lump = Wads.CheckNumForName("COLORMAP"); + if (lump == -1) lump = Wads.CheckNumForName("COLORMAP", ns_colormaps); + if (lump == -1) return; + FMemLump cmap = Wads.ReadLump(lump); + FMemLump palette = Wads.ReadLump("PLAYPAL"); + const unsigned char *cmapdata = (const unsigned char *)cmap.GetMem(); + const unsigned char *paldata = (const unsigned char *)palette.GetMem(); + + const int black = 0; + const int white = ColorMatcher.Pick(255,255,255); + + + GlobalBrightmap.MakeIdentity(); + memset(GlobalBrightmap.Remap, white, 256); + for(int i=0;i<256;i++) GlobalBrightmap.Palette[i]=PalEntry(255,255,255,255); + for(int j=0;j<32;j++) + { + for(int i=0;i<256;i++) + { + // the palette comparison should be for ==0 but that gives false positives with Heretic + // and Hexen. + if (cmapdata[i+j*256]!=i || (paldata[3*i]<10 && paldata[3*i+1]<10 && paldata[3*i+2]<10)) + { + GlobalBrightmap.Remap[i]=black; + GlobalBrightmap.Palette[i] = PalEntry(255, 0, 0, 0); + } + } + } + for(int i=0;i<256;i++) + { + HasGlobalBrightmap |= GlobalBrightmap.Remap[i] == white; + if (GlobalBrightmap.Remap[i] == white) DPrintf("Marked color %d as fullbright\n",i); + } +} + +//=========================================================================== +// +// averageColor +// input is RGBA8 pixel format. +// The resulting RGB color can be scaled uniformly so that the highest +// component becomes one. +// +//=========================================================================== +PalEntry averageColor(const DWORD *data, int size, fixed_t maxout_factor) +{ + int i; + unsigned int r, g, b; + + + + // First clear them. + r = g = b = 0; + if (size==0) + { + return PalEntry(255,255,255); + } + for(i = 0; i < size; i++) + { + r += BPART(data[i]); + g += GPART(data[i]); + b += RPART(data[i]); + } + + r = r/size; + g = g/size; + b = b/size; + + int maxv=MAX(MAX(r,g),b); + + if(maxv && maxout_factor) + { + maxout_factor = FixedMul(maxout_factor, 255); + r = Scale(r, maxout_factor, maxv); + g = Scale(g, maxout_factor, maxv); + b = Scale(b, maxout_factor, maxv); + } + return PalEntry(255,r,g,b); +} + + + +//========================================================================== +// +// GL status data for a texture +// +//========================================================================== + +FTexture::MiscGLInfo::MiscGLInfo() throw() +{ + bGlowing = false; + GlowColor = 0; + GlowHeight = 128; + bSkybox = false; + FloorSkyColor = 0; + CeilingSkyColor = 0; + bFullbright = false; + bSkyColorDone = false; + bBrightmapChecked = false; + bDisableFullbright = false; + bNoFilter = false; + bNoCompress = false; + bNoExpand = false; + areas = NULL; + areacount = 0; + mIsTransparent = -1; + shaderspeed = 1.f; + shaderindex = 0; + precacheTime = 0; + + Material[1] = Material[0] = NULL; + SystemTexture[1] = SystemTexture[0] = NULL; + Brightmap = NULL; +} + +FTexture::MiscGLInfo::~MiscGLInfo() +{ + for (int i = 0; i < 2; i++) + { + if (Material[i] != NULL) delete Material[i]; + Material[i] = NULL; + + if (SystemTexture[i] != NULL) delete SystemTexture[i]; + SystemTexture[i] = NULL; + } + + // this is just a reference to another texture in the texture manager. + Brightmap = NULL; + + if (areas != NULL) delete [] areas; + areas = NULL; +} + +//=========================================================================== +// +// Checks if the texture has a default brightmap and creates it if so +// +//=========================================================================== +void FTexture::CreateDefaultBrightmap() +{ + if (!gl_info.bBrightmapChecked) + { + // Check for brightmaps + if (UseBasePalette() && HasGlobalBrightmap && + UseType != TEX_Decal && UseType != TEX_MiscPatch && UseType != TEX_FontChar && + gl_info.Brightmap == NULL && bWarped == 0 + ) + { + // May have one - let's check when we use this texture + const BYTE *texbuf = GetPixels(); + const int white = ColorMatcher.Pick(255,255,255); + + int size = GetWidth() * GetHeight(); + for(int i=0;iPrecache(); + } + if (cache & FTextureManager::HIT_Sprite) + { + FMaterial * gltex = FMaterial::ValidateTexture(this, true); + if (gltex) gltex->Precache(); + } + gl_info.precacheTime = TexMan.precacheTime; + } +} + +//========================================================================== +// +// Precaches a GL texture +// +//========================================================================== + +void FTexture::UncacheGL() +{ + if (gl_info.precacheTime != TexMan.precacheTime) + { + if (gl_info.Material[0]) gl_info.Material[0]->Clean(true); + if (gl_info.Material[1]) gl_info.Material[1]->Clean(true); + gl_info.precacheTime = 0; + } +} + +//========================================================================== +// +// Calculates glow color for a texture +// +//========================================================================== + +void FTexture::GetGlowColor(float *data) +{ + if (gl_info.bGlowing && gl_info.GlowColor == 0) + { + int w, h; + unsigned char *buffer = GLRenderer->GetTextureBuffer(this, w, h); + + if (buffer) + { + gl_info.GlowColor = averageColor((DWORD *) buffer, w*h, 6*FRACUNIT/10); + delete[] buffer; + } + + // Black glow equals nothing so switch glowing off + if (gl_info.GlowColor == 0) gl_info.bGlowing = false; + } + data[0]=gl_info.GlowColor.r/255.0f; + data[1]=gl_info.GlowColor.g/255.0f; + data[2]=gl_info.GlowColor.b/255.0f; +} + +//=========================================================================== +// +// Gets the average color of a texture for use as a sky cap color +// +//=========================================================================== + +PalEntry FTexture::GetSkyCapColor(bool bottom) +{ + PalEntry col; + int w; + int h; + + if (!gl_info.bSkyColorDone) + { + gl_info.bSkyColorDone = true; + + unsigned char *buffer = GLRenderer->GetTextureBuffer(this, w, h); + + if (buffer) + { + gl_info.CeilingSkyColor = averageColor((DWORD *) buffer, w * MIN(30, h), 0); + if (h>30) + { + gl_info.FloorSkyColor = averageColor(((DWORD *) buffer)+(h-30)*w, w * 30, 0); + } + else gl_info.FloorSkyColor = gl_info.CeilingSkyColor; + delete[] buffer; + } + } + return bottom? gl_info.FloorSkyColor : gl_info.CeilingSkyColor; +} + +//=========================================================================== +// +// Finds gaps in the texture which can be skipped by the renderer +// This was mainly added to speed up one area in E4M6 of 007LTSD +// +//=========================================================================== + +bool FTexture::FindHoles(const unsigned char * buffer, int w, int h) +{ + const unsigned char * li; + int y,x; + int startdraw,lendraw; + int gaps[5][2]; + int gapc=0; + + + // already done! + if (gl_info.areacount) return false; + if (UseType == TEX_Flat) return false; // flats don't have transparent parts + gl_info.areacount=-1; //whatever happens next, it shouldn't be done twice! + + // large textures are excluded for performance reasons + if (h>512) return false; + + startdraw=-1; + lendraw=0; + for(y=0;y>24; + + if (alpha != 0xff && alpha != 0) + { + gl_info.mIsTransparent = 1; + return; + } + } + } + gl_info.mIsTransparent = 0; + } +} + + +//=========================================================================== +// +// smooth the edges of transparent fields in the texture +// +//=========================================================================== + +#ifdef WORDS_BIGENDIAN +#define MSB 0 +#define SOME_MASK 0xffffff00 +#else +#define MSB 3 +#define SOME_MASK 0x00ffffff +#endif + +#define CHKPIX(ofs) (l1[(ofs)*4+MSB]==255 ? (( ((DWORD*)l1)[0] = ((DWORD*)l1)[ofs]&SOME_MASK), trans=true ) : false) + +bool FTexture::SmoothEdges(unsigned char * buffer,int w, int h) +{ + int x,y; + bool trans=buffer[MSB]==0; // If I set this to false here the code won't detect textures + // that only contain transparent pixels. + unsigned char * l1; + + if (h<=1 || w<=1) return false; // makes (a) no sense and (b) doesn't work with this code! + + l1=buffer; + + + if (l1[MSB]==0 && !CHKPIX(1)) CHKPIX(w); + l1+=4; + for(x=1;xbNoDecals; + Rotations = source->Rotations; + UseType = source->UseType; + bMasked = false; + id.SetInvalid(); + SourceLump = -1; +} + +FBrightmapTexture::~FBrightmapTexture () +{ +} + +const BYTE *FBrightmapTexture::GetColumn (unsigned int column, const Span **spans_out) +{ + // not needed + return NULL; +} + +const BYTE *FBrightmapTexture::GetPixels () +{ + // not needed + return NULL; +} + +void FBrightmapTexture::Unload () +{ +} + +int FBrightmapTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) +{ + SourcePic->CopyTrueColorTranslated(bmp, x, y, rotate, &GlobalBrightmap); + return 0; +} + + +//========================================================================== +// +// Parses a brightmap definition +// +//========================================================================== + +void gl_ParseBrightmap(FScanner &sc, int deflump) +{ + int type = FTexture::TEX_Any; + bool disable_fullbright=false; + bool thiswad = false; + bool iwad = false; + FTexture *bmtex = NULL; + + sc.MustGetString(); + if (sc.Compare("texture")) type = FTexture::TEX_Wall; + else if (sc.Compare("flat")) type = FTexture::TEX_Flat; + else if (sc.Compare("sprite")) type = FTexture::TEX_Sprite; + else sc.UnGet(); + + sc.MustGetString(); + FTextureID no = TexMan.CheckForTexture(sc.String, type); + FTexture *tex = TexMan[no]; + + sc.MustGetToken('{'); + while (!sc.CheckToken('}')) + { + sc.MustGetString(); + if (sc.Compare("disablefullbright")) + { + // This can also be used without a brightness map to disable + // fullbright in rotations that only use brightness maps on + // other angles. + disable_fullbright = true; + } + else if (sc.Compare("thiswad")) + { + // only affects textures defined in the WAD containing the definition file. + thiswad = true; + } + else if (sc.Compare ("iwad")) + { + // only affects textures defined in the IWAD. + iwad = true; + } + else if (sc.Compare ("map")) + { + sc.MustGetString(); + + if (bmtex != NULL) + { + Printf("Multiple brightmap definitions in texture %s\n", tex? tex->Name.GetChars() : "(null)"); + } + + bmtex = TexMan.FindTexture(sc.String, FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny); + + if (bmtex == NULL) + Printf("Brightmap '%s' not found in texture '%s'\n", sc.String, tex? tex->Name.GetChars() : "(null)"); + } + } + if (!tex) + { + return; + } + if (thiswad || iwad) + { + bool useme = false; + int lumpnum = tex->GetSourceLump(); + + if (lumpnum != -1) + { + if (iwad && Wads.GetLumpFile(lumpnum) <= FWadCollection::IWAD_FILENUM) useme = true; + if (thiswad && Wads.GetLumpFile(lumpnum) == deflump) useme = true; + } + if (!useme) return; + } + + if (bmtex != NULL) + { + if (tex->bWarped != 0) + { + Printf("Cannot combine warping with brightmap on texture '%s'\n", tex->Name.GetChars()); + return; + } + + bmtex->bMasked = false; + tex->gl_info.Brightmap = bmtex; + } + tex->gl_info.bDisableFullbright = disable_fullbright; +} + +//========================================================================== +// +// Parses a GLBoom+ detail texture definition +// +// Syntax is this: +// detail +// { +// (walls | flats) [default_detail_name [width [height [offset_x [offset_y]]]]] +// { +// texture_name [detail_name [width [height [offset_x [offset_y]]]]] +// } +// } +// This merely parses the block and returns no error if valid. The feature +// is not actually implemented, so nothing else happens. +//========================================================================== + +void gl_ParseDetailTexture(FScanner &sc) +{ + while (!sc.CheckToken('}')) + { + sc.MustGetString(); + if (sc.Compare("walls") || sc.Compare("flats")) + { + if (!sc.CheckToken('{')) + { + sc.MustGetString(); // Default detail texture + if (sc.CheckFloat()) // Width + if (sc.CheckFloat()) // Height + if (sc.CheckFloat()) // OffsX + if (sc.CheckFloat()) // OffsY + { + // Nothing + } + } + else sc.UnGet(); + sc.MustGetToken('{'); + while (!sc.CheckToken('}')) + { + sc.MustGetString(); // Texture + if (sc.GetString()) // Detail texture + { + if (sc.CheckFloat()) // Width + if (sc.CheckFloat()) // Height + if (sc.CheckFloat()) // OffsX + if (sc.CheckFloat()) // OffsY + { + // Nothing + } + } + else sc.UnGet(); + } + } + } +} + + +//========================================================================== +// +// Prints some texture info +// +//========================================================================== + +CCMD(textureinfo) +{ + int cntt = 0; + for (int i = 0; i < TexMan.NumTextures(); i++) + { + FTexture *tex = TexMan.ByIndex(i); + if (tex->gl_info.SystemTexture[0] || tex->gl_info.SystemTexture[1] || tex->gl_info.Material[0] || tex->gl_info.Material[1]) + { + int lump = tex->GetSourceLump(); + Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name.GetChars(), i, lump, Wads.GetLumpFullName(lump)); + if (tex->gl_info.Material[0]) + { + Printf(PRINT_LOG, "in use (normal)\n"); + } + else if (tex->gl_info.SystemTexture[0]) + { + Printf(PRINT_LOG, "referenced (normal)\n"); + } + if (tex->gl_info.Material[1]) + { + Printf(PRINT_LOG, "in use (expanded)\n"); + } + else if (tex->gl_info.SystemTexture[1]) + { + Printf(PRINT_LOG, "referenced (normal)\n"); + } + cntt++; + } + } + Printf(PRINT_LOG, "%d system textures\n", cntt); +} + diff --git a/src/gl/textures/gl_texture.h b/src/gl/textures/gl_texture.h new file mode 100644 index 000000000..a70ccebc5 --- /dev/null +++ b/src/gl/textures/gl_texture.h @@ -0,0 +1,71 @@ +/* +** gl_hqresize.h +** Contains high quality upsampling functions. +** +**--------------------------------------------------------------------------- +** Copyright 2008 Benjamin Berkels +** 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. +**--------------------------------------------------------------------------- +** +*/ + +#ifndef __GL_HQRESIZE_H__ +#define __GL_HQRESIZE_H__ + +#include "r_defs.h" + +class FBrightmapTexture : public FTexture +{ +public: + FBrightmapTexture (FTexture *source); + ~FBrightmapTexture (); + + const BYTE *GetColumn (unsigned int column, const Span **spans_out); + const BYTE *GetPixels (); + void Unload (); + + int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf); + bool UseBasePalette() { return false; } + +protected: + FTexture *SourcePic; + //BYTE *Pixels; + //Span **Spans; +}; + + +void gl_GenerateGlobalBrightmapFromColormap(); +PalEntry averageColor(const DWORD *data, int size, fixed_t maxout); + + + +unsigned char *gl_CreateUpsampledTextureBuffer ( const FTexture *inputTexture, unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha ); +int CheckDDPK3(FTexture *tex); +int CheckExternalFile(FTexture *tex, bool & hascolorkey); +PalEntry averageColor(const DWORD *data, int size, fixed_t maxout); + +#endif // __GL_HQRESIZE_H__ + diff --git a/src/gl/textures/gl_translate.cpp b/src/gl/textures/gl_translate.cpp new file mode 100644 index 000000000..f9a46dba8 --- /dev/null +++ b/src/gl/textures/gl_translate.cpp @@ -0,0 +1,88 @@ +/* +** gl_translate.cpp +** GL-related translation stuff +** +**--------------------------------------------------------------------------- +** Copyright 2007 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. +** 4. When not used as part of GZDoom or a GZDoom derivative, this code will be +** covered by the terms of the GNU Lesser General Public License as published +** by the Free Software Foundation; either version 2.1 of the License, or (at +** your option) any later version. +** 5. Full disclosure of the entire project's source code, except for third +** party libraries is mandatory. (NOTE: This clause is non-negotiable!) +** +** 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 "r_data/r_translate.h" +#include "gl/textures/gl_translate.h" +#include "m_crc32.h" + +TArray GLTranslationPalette::AllPalettes; + + +GLTranslationPalette *GLTranslationPalette::CreatePalette(FRemapTable *remap) +{ + GLTranslationPalette *p = new GLTranslationPalette(remap); + p->Update(); + return p; +} + +bool GLTranslationPalette::Update() +{ + PalData pd; + + memset(pd.pe, 0, sizeof(pd.pe)); + memcpy(pd.pe, remap->Palette, remap->NumEntries * sizeof(*remap->Palette)); + pd.crc32 = CalcCRC32((BYTE*)pd.pe, sizeof(pd.pe)); + for(unsigned int i=0;i< AllPalettes.Size(); i++) + { + if (pd.crc32 == AllPalettes[i].crc32) + { + if (!memcmp(pd.pe, AllPalettes[i].pe, sizeof(pd.pe))) + { + Index = 1+i; + return true; + } + } + } + Index = 1+AllPalettes.Push(pd); + return true; +} + +int GLTranslationPalette::GetInternalTranslation(int trans) +{ + if (trans <= 0) return 0; + + FRemapTable *remap = TranslationToTable(trans); + if (remap == NULL || remap->Inactive) return 0; + + GLTranslationPalette *tpal = static_cast(remap->GetNative()); + if (tpal == NULL) return 0; + return tpal->GetIndex(); +} diff --git a/src/gl/textures/gl_translate.h b/src/gl/textures/gl_translate.h new file mode 100644 index 000000000..07ede1a22 --- /dev/null +++ b/src/gl/textures/gl_translate.h @@ -0,0 +1,42 @@ +#ifndef __GL_TRANSLATE__ +#define __GL_TRANSLATE__ + +#include "doomtype.h" +#include "v_video.h" + +enum +{ + TRANSLATION_ICE = -1, + TRANSLATION_INTENSITY = -2, + TRANSLATION_SHADE = -3, +}; + + +class GLTranslationPalette : public FNativePalette +{ + struct PalData + { + int crc32; + PalEntry pe[256]; + }; + static TArray AllPalettes; + + int Index; + FRemapTable *remap; + + GLTranslationPalette(FRemapTable *r) { remap=r; Index=-1; } + +public: + + static GLTranslationPalette *CreatePalette(FRemapTable *remap); + static int GetInternalTranslation(int trans); + static PalEntry *GetPalette(unsigned int index) + { + return index > 0 && index <= AllPalettes.Size()? AllPalettes[index-1].pe : NULL; + } + bool Update(); + int GetIndex() const { return Index; } +}; + + +#endif diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp new file mode 100644 index 000000000..48c21dde2 --- /dev/null +++ b/src/gl/utility/gl_clock.cpp @@ -0,0 +1,233 @@ +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include + +#define USE_WINDOWS_DWORD +#endif + +#include "i_system.h" +#include "g_level.h" +#include "c_console.h" +#include "c_dispatch.h" +#include "r_utility.h" +#include "v_video.h" +#include "gl/utility/gl_clock.h" +#include "gl/utility/gl_convert.h" + + +glcycle_t RenderWall,SetupWall,ClipWall,SplitWall; +glcycle_t RenderFlat,SetupFlat; +glcycle_t RenderSprite,SetupSprite; +glcycle_t All, Finish, PortalAll, Bsp; +glcycle_t ProcessAll; +glcycle_t RenderAll; +glcycle_t Dirty; +glcycle_t drawcalls; +int vertexcount, flatvertices, flatprimitives; + +int rendered_lines,rendered_flats,rendered_sprites,render_vertexsplit,render_texsplit,rendered_decals, rendered_portals; +int iter_dlightf, iter_dlight, draw_dlight, draw_dlightf; + +double gl_SecondsPerCycle = 1e-8; +double gl_MillisecPerCycle = 1e-5; // 100 MHz + +// For GL timing the performance counter is far too costly so we still need RDTSC +// even though it may not be perfect. + +void gl_CalculateCPUSpeed () +{ + #ifdef WIN32 + LARGE_INTEGER freq; + + QueryPerformanceFrequency (&freq); + + if (freq.QuadPart != 0) + { + LARGE_INTEGER count1, count2; + unsigned minDiff; + long long ClockCalibration = 0; + + // Count cycles for at least 55 milliseconds. + // The performance counter is very low resolution compared to CPU + // speeds today, so the longer we count, the more accurate our estimate. + // On the other hand, we don't want to count too long, because we don't + // want the user to notice us spend time here, since most users will + // probably never use the performance statistics. + minDiff = freq.LowPart * 11 / 200; + + // Minimize the chance of task switching during the testing by going very + // high priority. This is another reason to avoid timing for too long. + SetPriorityClass (GetCurrentProcess (), REALTIME_PRIORITY_CLASS); + SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_TIME_CRITICAL); + ClockCalibration = __rdtsc(); + QueryPerformanceCounter (&count1); + do + { + QueryPerformanceCounter (&count2); + } while ((DWORD)((unsigned __int64)count2.QuadPart - (unsigned __int64)count1.QuadPart) < minDiff); + ClockCalibration = __rdtsc() - ClockCalibration; + QueryPerformanceCounter (&count2); + SetPriorityClass (GetCurrentProcess (), NORMAL_PRIORITY_CLASS); + SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_NORMAL); + + double CyclesPerSecond = (double)ClockCalibration * + (double)freq.QuadPart / + (double)((__int64)count2.QuadPart - (__int64)count1.QuadPart); + gl_SecondsPerCycle = 1.0 / CyclesPerSecond; + gl_MillisecPerCycle = 1000.0 / CyclesPerSecond; + } + #endif +} + + +void ResetProfilingData() +{ + All.Reset(); + All.Clock(); + Bsp.Reset(); + PortalAll.Reset(); + RenderAll.Reset(); + ProcessAll.Reset(); + RenderWall.Reset(); + SetupWall.Reset(); + SplitWall.Reset(); + ClipWall.Reset(); + RenderFlat.Reset(); + SetupFlat.Reset(); + RenderSprite.Reset(); + SetupSprite.Reset(); + drawcalls.Reset(); + + flatvertices=flatprimitives=vertexcount=0; + render_texsplit=render_vertexsplit=rendered_lines=rendered_flats=rendered_sprites=rendered_decals=rendered_portals = 0; +} + +//----------------------------------------------------------------------------- +// +// Rendering statistics +// +//----------------------------------------------------------------------------- + +static void AppendRenderTimes(FString &str) +{ + double setupwall = SetupWall.TimeMS() - SplitWall.TimeMS(); + double clipwall = ClipWall.TimeMS() - SetupWall.TimeMS(); + double bsp = Bsp.TimeMS() - ClipWall.TimeMS() - SetupFlat.TimeMS() - SetupSprite.TimeMS(); + + str.AppendFormat("W: Render=%2.3f, Split = %2.3f, Setup=%2.3f, Clip=%2.3f\n" + "F: Render=%2.3f, Setup=%2.3f\n" + "S: Render=%2.3f, Setup=%2.3f\n" + "All=%2.3f, Render=%2.3f, Setup=%2.3f, BSP = %2.3f, Portal=%2.3f, Drawcalls=%2.3f, Finish=%2.3f\n", + RenderWall.TimeMS(), SplitWall.TimeMS(), setupwall, clipwall, RenderFlat.TimeMS(), SetupFlat.TimeMS(), + RenderSprite.TimeMS(), SetupSprite.TimeMS(), All.TimeMS() + Finish.TimeMS(), RenderAll.TimeMS(), + ProcessAll.TimeMS(), bsp, PortalAll.TimeMS(), drawcalls.TimeMS(), Finish.TimeMS()); +} + +static void AppendRenderStats(FString &out) +{ + out.AppendFormat("Walls: %d (%d splits, %d t-splits, %d vertices)\n" + "Flats: %d (%d primitives, %d vertices)\n" + "Sprites: %d, Decals=%d, Portals: %d\n", + rendered_lines, render_vertexsplit, render_texsplit, vertexcount, rendered_flats, flatprimitives, flatvertices, rendered_sprites,rendered_decals, rendered_portals ); +} + +static void AppendLightStats(FString &out) +{ + out.AppendFormat("DLight - Walls: %d processed, %d rendered - Flats: %d processed, %d rendered\n", + iter_dlight, draw_dlight, iter_dlightf, draw_dlightf ); +} + +ADD_STAT(rendertimes) +{ + static FString buff; + static int lasttime=0; + int t=I_FPSTime(); + if (t-lasttime>1000) + { + buff.Truncate(0); + AppendRenderTimes(buff); + lasttime=t; + } + return buff; +} + +ADD_STAT(renderstats) +{ + FString out; + AppendRenderStats(out); + return out; +} + +ADD_STAT(lightstats) +{ + FString out; + AppendLightStats(out); + return out; +} + +void AppendMissingTextureStats(FString &out); + + +static int printstats; +static bool switchfps; +static unsigned int waitstart; +EXTERN_CVAR(Bool, vid_fps) + +void CheckBench() +{ + if (printstats && ConsoleState == c_up) + { + // if we started the FPS counter ourselves or ran from the console + // we need to wait for it to stabilize before using it. + if (waitstart > 0 && I_MSTime() < waitstart + 5000) return; + + FString compose; + + compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n", + level.MapName.GetChars(), level.LevelName.GetChars(), FIXED2FLOAT(viewx), FIXED2FLOAT(viewy), FIXED2FLOAT(viewz), + ANGLE_TO_FLOAT(viewangle), ANGLE_TO_FLOAT(viewpitch)); + + AppendRenderStats(compose); + AppendRenderTimes(compose); + AppendLightStats(compose); + AppendMissingTextureStats(compose); + compose.AppendFormat("%d fps\n\n", screen->GetLastFPS()); + + FILE *f = fopen("benchmarks.txt", "at"); + if (f != NULL) + { + fputs(compose.GetChars(), f); + fclose(f); + } + Printf("Benchmark info saved\n"); + if (switchfps) vid_fps = false; + printstats = false; + } +} + +CCMD(bench) +{ + printstats = true; + if (vid_fps == 0) + { + vid_fps = 1; + waitstart = I_MSTime(); + switchfps = true; + } + else + { + if (ConsoleState == c_up) waitstart = I_MSTime(); + switchfps = false; + } + C_HideConsole (); +} + +bool gl_benching = false; + +void checkBenchActive() +{ + FStat *stat = FStat::FindStat("rendertimes"); + gl_benching = ((stat != NULL && stat->isActive()) || printstats); +} + diff --git a/src/gl/utility/gl_clock.h b/src/gl/utility/gl_clock.h new file mode 100644 index 000000000..46a01d1e4 --- /dev/null +++ b/src/gl/utility/gl_clock.h @@ -0,0 +1,125 @@ +#ifndef __GL_CLOCK_H +#define __GL_CLOCK_H + +#include "stats.h" +#include "x86.h" +#include "m_fixed.h" + +extern bool gl_benching; + +#ifdef _MSC_VER + +extern double gl_SecondsPerCycle; +extern double gl_MillisecPerCycle; + +__forceinline long long GetClockCycle () +{ +#if _M_X64 + return __rdtsc(); +#else + return CPU.bRDTSC ? __rdtsc() : 0; +#endif +} + +#elif defined(__GNUG__) && defined(__i386__) + +extern double gl_SecondsPerCycle; +extern double gl_MillisecPerCycle; + +inline long long GetClockCycle() +{ + if (CPU.bRDTSC) + { + long long res; + asm volatile ("rdtsc" : "=A" (res)); + return res; + } + else + { + return 0; + } +} + +#else + +extern double gl_SecondsPerCycle; +extern double gl_MillisecPerCycle; + +inline long long GetClockCycle () +{ + return 0; +} +#endif + +#if defined (__APPLE__) + +typedef cycle_t glcycle_t; + +#else // !__APPLE__ + +class glcycle_t +{ +public: + glcycle_t &operator= (const glcycle_t &o) + { + Counter = o.Counter; + return *this; + } + + void Reset() + { + Counter = 0; + } + + __forceinline void Clock() + { + // Not using QueryPerformanceCounter directly, so we don't need + // to pull in the Windows headers for every single file that + // wants to do some profiling. + long long time = (gl_benching? GetClockCycle() : 0); + Counter -= time; + } + + __forceinline void Unclock() + { + long long time = (gl_benching? GetClockCycle() : 0); + Counter += time; + } + + double Time() + { + return double(Counter) * gl_SecondsPerCycle; + } + + double TimeMS() + { + return double(Counter) * gl_MillisecPerCycle; + } + +private: + long long Counter; +}; + +#endif // __APPLE__ + +extern glcycle_t RenderWall,SetupWall,ClipWall,SplitWall; +extern glcycle_t RenderFlat,SetupFlat; +extern glcycle_t RenderSprite,SetupSprite; +extern glcycle_t All, Finish, PortalAll, Bsp; +extern glcycle_t ProcessAll; +extern glcycle_t RenderAll; +extern glcycle_t Dirty; +extern glcycle_t drawcalls; + +extern int iter_dlightf, iter_dlight, draw_dlight, draw_dlightf; +extern int rendered_lines,rendered_flats,rendered_sprites,rendered_decals,render_vertexsplit,render_texsplit; +extern int rendered_portals; + +extern int vertexcount, flatvertices, flatprimitives; + +void ResetProfilingData(); +void CheckBench(); +void checkBenchActive(); + + +#endif \ No newline at end of file diff --git a/src/gl/utility/gl_convert.h b/src/gl/utility/gl_convert.h new file mode 100644 index 000000000..7f99412fa --- /dev/null +++ b/src/gl/utility/gl_convert.h @@ -0,0 +1,9 @@ + +#ifndef __GLC_CONVERT +#define __GLC_CONVERT + +#include "m_fixed.h" +#define ANGLE_TO_FLOAT(ang) ((float)((ang) * 180. / ANGLE_180)) +#define FLOAT_TO_ANGLE(ang) xs_RoundToUInt((ang) / 180. * ANGLE_180) + +#endif \ No newline at end of file diff --git a/src/gl/utility/gl_cycler.cpp b/src/gl/utility/gl_cycler.cpp new file mode 100644 index 000000000..a12cb4851 --- /dev/null +++ b/src/gl/utility/gl_cycler.cpp @@ -0,0 +1,155 @@ +/* +** gl_cycler.cpp +** Implements the cycler for dynamic lights and texture shaders. +** +**--------------------------------------------------------------------------- +** Copyright 2003 Timothy Stump +** Copyright 2006 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 +#include "gl/utility/gl_cycler.h" + +//========================================================================== +// +// +// +//========================================================================== + +void FCycler::Serialize(FArchive & arc) +{ + arc << m_start << m_end << m_current + << m_time << m_cycle << m_increment << m_shouldCycle + << m_cycleType; +} + +//========================================================================== +// +// +// +//========================================================================== + +FCycler::FCycler() +{ + m_cycle = 0.f; + m_cycleType = CYCLE_Linear; + m_shouldCycle = false; + m_start = m_current = 0.f; + m_end = 0.f; + m_increment = true; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void FCycler::SetParams(float start, float end, float cycle) +{ + m_cycle = cycle; + m_time = 0.f; + m_start = m_current = start; + m_end = end; + m_increment = true; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void FCycler::Update(float diff) +{ + float mult, angle; + float step = m_end - m_start; + + if (!m_shouldCycle) + { + return; + } + + m_time += diff; + if (m_time >= m_cycle) + { + m_time = m_cycle; + } + + mult = m_time / m_cycle; + + switch (m_cycleType) + { + case CYCLE_Linear: + if (m_increment) + { + m_current = m_start + (step * mult); + } + else + { + m_current = m_end - (step * mult); + } + break; + case CYCLE_Sin: + angle = float(M_PI * 2.f * mult); + mult = sinf(angle); + mult = (mult + 1.f) / 2.f; + m_current = m_start + (step * mult); + break; + case CYCLE_Cos: + angle = float(M_PI * 2.f * mult); + mult = cosf(angle); + mult = (mult + 1.f) / 2.f; + m_current = m_start + (step * mult); + break; + case CYCLE_SawTooth: + m_current = m_start + (step * mult); + break; + case CYCLE_Square: + if (m_increment) + { + m_current = m_start; + } + else + { + m_current = m_end; + } + break; + } + + if (m_time == m_cycle) + { + m_time = 0.f; + m_increment = !m_increment; + } +} + + diff --git a/src/gl/utility/gl_cycler.h b/src/gl/utility/gl_cycler.h new file mode 100644 index 000000000..8a6b55581 --- /dev/null +++ b/src/gl/utility/gl_cycler.h @@ -0,0 +1,52 @@ +#ifndef __GL_CYCLER_H +#define __GL_CYCLER_H + +#include "farchive.h" + +typedef enum +{ + CYCLE_Linear, + CYCLE_Sin, + CYCLE_Cos, + CYCLE_SawTooth, + CYCLE_Square +} CycleType; + +inline FArchive &operator<< (FArchive &arc, CycleType &type) +{ + BYTE val = (BYTE)type; + arc << val; + type = (CycleType)val; + return arc; +} + + +class FCycler +{ +public: + FCycler(); + void Update(float diff); + void SetParams(float start, float end, float cycle); + void ShouldCycle(bool sc) { m_shouldCycle = sc; } + void SetCycleType(CycleType ct) { m_cycleType = ct; } + float GetVal() { return m_current; } + + inline operator float () const { return m_current; } + + void Serialize(FArchive & arc); +protected: + float m_start, m_end, m_current; + float m_time, m_cycle; + bool m_increment, m_shouldCycle; + + CycleType m_cycleType; +}; + +inline FArchive &operator<< (FArchive &arc, FCycler &type) +{ + type.Serialize(arc); + return arc; +} + + +#endif diff --git a/src/gl/utility/gl_geometric.cpp b/src/gl/utility/gl_geometric.cpp new file mode 100644 index 000000000..5e3f93ba8 --- /dev/null +++ b/src/gl/utility/gl_geometric.cpp @@ -0,0 +1,258 @@ + + +#include +#include +#include "gl/utility/gl_geometric.h" + +static Vector axis[3] = +{ + Vector(1.0f, 0.0f, 0.0f), + Vector(0.0f, 1.0f, 0.0f), + Vector(0.0f, 0.0f, 1.0f) +}; + + + +Vector Vector::Cross(Vector &v) +{ + float x, y, z; + Vector cp; + + x = Y() * v.Z() - Z() * v.Y(); + y = Z() * v.X() - X() * v.Z(); + z = X() * v.Y() - Y() * v.X(); + + cp.Set(x, y, z); + + return cp; +} + + +Vector Vector::operator- (Vector &v) +{ + float x, y, z; + Vector vec; + + x = X() - v.X(); + y = Y() - v.Y(); + z = Z() - v.Z(); + + vec.Set(x, y, z); + + return vec; +} + + +Vector Vector::operator+ (Vector &v) +{ + float x, y, z; + Vector vec; + + x = X() + v.X(); + y = Y() + v.Y(); + z = Z() + v.Z(); + + vec.Set(x, y, z); + + return vec; +} + + +Vector Vector::operator* (float f) +{ + Vector vec(X(), Y(), Z()); + + vec.Scale(f); + + return vec; +} + + +Vector Vector::operator/ (float f) +{ + Vector vec(X(), Y(), Z()); + + vec.Scale(1.f / f); + + return vec; +} + + +bool Vector::operator== (Vector &v) +{ + return X() == v.X() && Y() == v.Y() && Z() == v.Z(); +} + + +void Vector::GetRightUp(Vector &right, Vector &up) +{ + Vector n(X(), Y(), Z()); + Vector fn(fabsf(n.X()), fabsf(n.Y()), fabsf(n.Z())); + int major = 0; + + if (fn[1] > fn[major]) major = 1; + if (fn[2] > fn[major]) major = 2; + + // build right vector by hand + if (fabsf(fn[0]-1.0f) < FLT_EPSILON || fabsf(fn[1]-1.0f) < FLT_EPSILON || fabsf(fn[2]-1.0f) < FLT_EPSILON) + { + if (major == 0 && n[0] > 0.f) + { + right.Set(0.f, 0.f, -1.f); + } + else if (major == 0) + { + right.Set(0.f, 0.f, 1.f); + } + + if (major == 1 || (major == 2 && n[2] > 0.f)) + { + right.Set(1.f, 0.f, 0.f); + } + + if (major == 2 && n[2] < 0.0f) + { + right.Set(-1.f, 0.f, 0.f); + } + } + else + { + right = axis[major].Cross(n); + } + + up = n.Cross(right); + right.Normalize(); + up.Normalize(); +} + + +void Vector::Scale(float scale) +{ + float x, y, z; + + x = X() * scale; + y = Y() * scale; + z = Z() * scale; + + Set(x, y, z); +} + + +Vector Vector::ProjectVector(Vector &a) +{ + Vector res, b; + + b.Set(X(), Y(), Z()); + res.Set(a.X(), a.Y(), a.Z()); + + res.Scale(a.Dot(b) / a.Dot(a)); + + return res; +} + + +Vector Vector::ProjectPlane(Vector &right, Vector &up) +{ + Vector src(X(), Y(), Z()); + Vector t1, t2; + + t1 = src.ProjectVector(right); + t2 = src.ProjectVector(up); + + return t1 + t2; +} + + + + + + +void Plane::Init(float *v1, float *v2, float *v3) +{ + Vector vec1, vec2, vec3; + + vec1.Set(v1); + vec2.Set(v2); + vec3.Set(v3); + +#ifdef _MSC_VER + m_normal = (vec2 - vec1).Cross(vec3 - vec1); +#else + Vector tmpVec = vec3 - vec1; + m_normal = (vec2 - vec1).Cross(tmpVec); +#endif + m_normal.Normalize(); + m_d = vec3.Dot(m_normal) * -1.f; +} + + +#define FNOTEQUAL(a, b) (fabsf(a - b) > 0.001f) +void Plane::Init(float *verts, int numVerts) +{ + float *v[3], *t; + int i, curVert; + + if (numVerts < 3) return; + + curVert = 1; + v[0] = verts + 0; + for (i = 1; i < numVerts; i++) + { + t = verts + (i * 3); + if (FNOTEQUAL(t[0], v[curVert - 1][0]) || FNOTEQUAL(t[1], v[curVert - 1][1]) || FNOTEQUAL(t[2], v[curVert - 1][2])) + { + v[curVert] = t; + curVert++; + } + if (curVert == 3) break; + } + + if (curVert != 3) + { + // degenerate triangle, no valid normal + return; + } + + Init(v[0], v[1], v[2]); +} + + +void Plane::Init(float a, float b, float c, float d) +{ + m_normal.Set(a, b, c); + m_d = d / m_normal.Length(); + m_normal.Normalize(); +} + + +void Plane::Set(secplane_t &plane) +{ + float a, b, c, d; + + a = FIXED2FLOAT(plane.a); + b = FIXED2FLOAT(plane.b); + c = FIXED2FLOAT(plane.c); + d = FIXED2FLOAT(plane.d); + + m_normal.Set(a, c, b); + //m_normal.Normalize(); the vector is already normalized + m_d = d; +} + + +float Plane::DistToPoint(float x, float y, float z) +{ + Vector p; + + p.Set(x, y, z); + + return m_normal.Dot(p) + m_d; +} + + +bool Plane::PointOnSide(float x, float y, float z) +{ + return DistToPoint(x, y, z) < 0.f; +} + + diff --git a/src/gl/utility/gl_geometric.h b/src/gl/utility/gl_geometric.h new file mode 100644 index 000000000..6868dab21 --- /dev/null +++ b/src/gl/utility/gl_geometric.h @@ -0,0 +1,251 @@ +#ifndef __GL_GEOM +#define __GL_GEOM + +#include "math.h" +#include "r_defs.h" + +class Vector +{ +public: + Vector() + { + SetX(0.f); + SetY(1.f); + SetZ(0.f); + m_length = 1.f; + } + + Vector(float x, float y, float z) + { + SetX(x); + SetY(y); + SetZ(z); + m_length=-1.0f; + } + + Vector(float *v) + { + SetX(v[0]); + SetY(v[1]); + SetZ(v[2]); + m_length=-1.0f; + } + + Vector(vertex_t * v) + { + SetX(v->fx); + SetY(v->fy); + SetZ(0); + } + + void Normalize() + { + float l = 1.f / Length(); + + SetX(X() * l); + SetY(Y() * l); + SetZ(Z() * l); + m_length=1.0f; + } + + void UpdateLength() + { + m_length = sqrtf((X() * X()) + (Y() * Y()) + (Z() * Z())); + } + + void Set(float *v) + { + SetX(v[0]); + SetY(v[1]); + SetZ(v[2]); + m_length=-1.0f; + } + + void Set(float x, float y, float z) + { + SetX(x); + SetY(y); + SetZ(z); + m_length=-1.0f; + } + + float Length() + { + if (m_length<0.0f) UpdateLength(); + return m_length; + } + + float Dist(Vector &v) + { + Vector t(X() - v.X(), Y() - v.Y(), Z() - v.Z()); + + return t.Length(); + } + + float Dot(Vector &v) + { + return (X() * v.X()) + (Y() * v.Y()) + (Z() * v.Z()); + } + + Vector Cross(Vector &v); + Vector operator- (Vector &v); + Vector operator+ (Vector &v); + Vector operator* (float f); + Vector operator/ (float f); + bool operator== (Vector &v); + bool operator!= (Vector &v) { return !((*this) == v); } + + void GetRightUp(Vector &up, Vector &right); + float operator[] (int index) const { return m_vec[index]; } + float &operator[] (int index) { return m_vec[index]; } + float X() const { return m_vec[0]; } + float Y() const { return m_vec[1]; } + float Z() const { return m_vec[2]; } + void SetX(float x) { m_vec[0] = x; } + void SetY(float y) { m_vec[1] = y; } + void SetZ(float z) { m_vec[2] = z; } + void Scale(float scale); + + Vector ProjectVector(Vector &a); + Vector ProjectPlane(Vector &right, Vector &up); +protected: + float m_vec[3]; + float m_length; +}; + + +class Plane +{ +public: + Plane() + { + m_normal.Set(0.f, 1.f, 0.f); + m_d = 0.f; + } + void Init(float *v1, float *v2, float *v3); + void Init(float a, float b, float c, float d); + void Init(float *verts, int numVerts); + void Set(secplane_t &plane); + float DistToPoint(float x, float y, float z); + bool PointOnSide(float x, float y, float z); + bool PointOnSide(Vector &v) { return PointOnSide(v.X(), v.Y(), v.Z()); } + bool ValidNormal() { return m_normal.Length() == 1.f; } + + float A() { return m_normal.X(); } + float B() { return m_normal.Y(); } + float C() { return m_normal.Z(); } + float D() { return m_d; } + + const Vector &Normal() const { return m_normal; } +protected: + Vector m_normal; + float m_d; +}; + +class Matrix3x4 // used like a 4x4 matrix with the last row always being (0,0,0,1) +{ + float m[3][4]; + +public: + + void MakeIdentity() + { + memset(m, 0, sizeof(m)); + m[0][0] = m[1][1] = m[2][2] = 1.f; + } + + void Translate(float x, float y, float z) + { + m[0][3] = m[0][0]*x + m[0][1]*y + m[0][2]*z + m[0][3]; + m[1][3] = m[1][0]*x + m[1][1]*y + m[1][2]*z + m[1][3]; + m[2][3] = m[2][0]*x + m[2][1]*y + m[2][2]*z + m[2][3]; + } + + void Scale(float x, float y, float z) + { + m[0][0] *=x; + m[1][0] *=x; + m[2][0] *=x; + + m[0][1] *=y; + m[1][1] *=y; + m[2][1] *=y; + + m[0][2] *=z; + m[1][2] *=z; + m[2][2] *=z; + } + + void Rotate(float ax, float ay, float az, float angle) + { + Matrix3x4 m1; + + Vector axis(ax, ay, az); + axis.Normalize(); + double c = cos(angle * M_PI/180.), s = sin(angle * M_PI/180.), t = 1 - c; + double sx = s*axis.X(), sy = s*axis.Y(), sz = s*axis.Z(); + double tx, ty, txx, tyy, u, v; + + tx = t*axis.X(); + m1.m[0][0] = float( (txx=tx*axis.X()) + c ); + m1.m[0][1] = float( (u=tx*axis.Y()) - sz); + m1.m[0][2] = float( (v=tx*axis.Z()) + sy); + + ty = t*axis.Y(); + m1.m[1][0] = float( u + sz); + m1.m[1][1] = float( (tyy=ty*axis.Y()) + c ); + m1.m[1][2] = float( (u=ty*axis.Z()) - sx); + + m1.m[2][0] = float( v - sy); + m1.m[2][1] = float( u + sx); + m1.m[2][2] = float( (t-txx-tyy) + c ); + + m1.m[0][3] = 0.f; + m1.m[1][3] = 0.f; + m1.m[2][3] = 0.f; + + *this = (*this) * m1; + } + + Matrix3x4 operator *(const Matrix3x4 &other) + { + Matrix3x4 result; + + result.m[0][0] = m[0][0]*other.m[0][0] + m[0][1]*other.m[1][0] + m[0][2]*other.m[2][0]; + result.m[0][1] = m[0][0]*other.m[0][1] + m[0][1]*other.m[1][1] + m[0][2]*other.m[2][1]; + result.m[0][2] = m[0][0]*other.m[0][2] + m[0][1]*other.m[1][2] + m[0][2]*other.m[2][2]; + result.m[0][3] = m[0][0]*other.m[0][3] + m[0][1]*other.m[1][3] + m[0][2]*other.m[2][3] + m[0][3]; + + result.m[1][0] = m[1][0]*other.m[0][0] + m[1][1]*other.m[1][0] + m[1][2]*other.m[2][0]; + result.m[1][1] = m[1][0]*other.m[0][1] + m[1][1]*other.m[1][1] + m[1][2]*other.m[2][1]; + result.m[1][2] = m[1][0]*other.m[0][2] + m[1][1]*other.m[1][2] + m[1][2]*other.m[2][2]; + result.m[1][3] = m[1][0]*other.m[0][3] + m[1][1]*other.m[1][3] + m[1][2]*other.m[2][3] + m[1][3]; + + result.m[2][0] = m[2][0]*other.m[0][0] + m[2][1]*other.m[1][0] + m[2][2]*other.m[2][0]; + result.m[2][1] = m[2][0]*other.m[0][1] + m[2][1]*other.m[1][1] + m[2][2]*other.m[2][1]; + result.m[2][2] = m[2][0]*other.m[0][2] + m[2][1]*other.m[1][2] + m[2][2]*other.m[2][2]; + result.m[2][3] = m[2][0]*other.m[0][3] + m[2][1]*other.m[1][3] + m[2][2]*other.m[2][3] + m[2][3]; + + return result; + } + + Vector operator *(const Vector &vec) + { + Vector result; + + result.SetX(vec.X()*m[0][0] + vec.Y()*m[0][1] + vec.Z()*m[0][2] + m[0][3]); + result.SetY(vec.X()*m[1][0] + vec.Y()*m[1][1] + vec.Z()*m[1][2] + m[1][3]); + result.SetZ(vec.X()*m[2][0] + vec.Y()*m[2][1] + vec.Z()*m[2][2] + m[2][3]); + return result; + } + + void MultiplyVector(float *f3 , float *f3o) + { + float x = f3[0] * m[0][0] + f3[1] * m[0][1] + f3[2] * m[0][2] + m[0][3]; + float y = f3[0] * m[1][0] + f3[1] * m[1][1] + f3[2] * m[1][2] + m[1][3]; + float z = f3[0] * m[2][0] + f3[1] * m[2][1] + f3[2] * m[2][2] + m[2][3]; + f3o[2] = z; f3o[1] = y; f3o[0] = x; + } +}; + +#endif diff --git a/src/gl/utility/gl_templates.h b/src/gl/utility/gl_templates.h new file mode 100644 index 000000000..1ebef1f48 --- /dev/null +++ b/src/gl/utility/gl_templates.h @@ -0,0 +1,82 @@ +#ifndef __GL_BASIC +#define __GL_BASIC + +#include +#include "stats.h" + + +// Disabled because it doesn't work and only accumulates large portions of blocked heap +// without providing any relevant performance boost. +template struct FreeList +{ + //T * freelist; + + T * GetNew() + { + /* + if (freelist) + { + T * n=freelist; + freelist=*((T**)n); + return new ((void*)n) T; + } + */ + return new T; + } + + void Release(T * node) + { + /* + node->~T(); + *((T**)node) = freelist; + freelist=node; + */ + delete node; + } + + ~FreeList() + { + /* + while (freelist!=NULL) + { + T * n = freelist; + freelist=*((T**)n); + delete n; + } + */ + } +}; + +template class UniqueList +{ + TArray Array; + FreeList TheFreeList; + +public: + + T * Get(T * t) + { + for(unsigned i=0;iargs[0]; - sector_t * sec = line->frontsector, * ss; + int tag = line->args[0]; + sector_t * sec = line->frontsector, *ss; - FSectorTagIterator it(tag); - while ((s = it.Next()) >= 0) + FSectorTagIterator itr(tag); + while ((s = itr.Next()) >= 0) { - ss=§ors[s]; + ss = §ors[s]; - if (param==0) + if (param == 0) { - flags=FF_EXISTS|FF_RENDERALL|FF_SOLID|FF_INVERTSECTOR; + flags = FF_EXISTS | FF_RENDERALL | FF_SOLID | FF_INVERTSECTOR; alpha = 255; - for (i=0;ilinecount;i++) + for (i = 0; i < sec->linecount; i++) { - line_t * l=sec->lines[i]; + line_t * l = sec->lines[i]; - if (l->special==Sector_SetContents && l->frontsector==sec) + if (l->special == Sector_SetContents && l->frontsector == sec) { - alpha=clamp(l->args[1], 0, 100); + alpha = clamp(l->args[1], 0, 100); if (l->args[2] & 1) flags &= ~FF_SOLID; if (l->args[2] & 2) flags |= FF_SEETHROUGH; if (l->args[2] & 4) flags |= FF_SHOOTTHROUGH; if (l->args[2] & 8) flags |= FF_ADDITIVETRANS; - if (alpha!=100) flags|=FF_TRANSLUCENT;//|FF_BOTHPLANES|FF_ALLSIDES; - if (l->args[0]) + if (alpha != 100) flags |= FF_TRANSLUCENT;//|FF_BOTHPLANES|FF_ALLSIDES; + if (l->args[0]) { // Yes, Vavoom's 3D-floor definitions suck! // The content list changed in r1783 of Vavoom to be unified // among all its supported games, so it has now ten different // values instead of just five. - static DWORD vavoomcolors[]={VC_EMPTY, + static DWORD vavoomcolors[] = { VC_EMPTY, VC_WATER, VC_LAVA, VC_NUKAGE, VC_SLIME, VC_HELLSLIME, - VC_BLOOD, VC_SLUDGE, VC_HAZARD, VC_BOOMWATER}; - flags|=FF_SWIMMABLE|FF_BOTHPLANES|FF_ALLSIDES|FF_FLOOD; + VC_BLOOD, VC_SLUDGE, VC_HAZARD, VC_BOOMWATER }; + flags |= FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_FLOOD; - l->frontsector->ColorMap = - GetSpecialLights (l->frontsector->ColorMap->Color, - vavoomcolors[l->args[0]], - l->frontsector->ColorMap->Desaturate); + l->frontsector->ColorMap = + GetSpecialLights(l->frontsector->ColorMap->Color, + vavoomcolors[l->args[0]], + l->frontsector->ColorMap->Desaturate); } - alpha=(alpha*255)/100; + alpha = (alpha * 255) / 100; break; } } } - else if (param==4) + else if (param == 4) { - flags=FF_EXISTS|FF_RENDERPLANES|FF_INVERTPLANES|FF_NOSHADE|FF_FIX; - alpha=255; + flags = FF_EXISTS | FF_RENDERPLANES | FF_INVERTPLANES | FF_NOSHADE | FF_FIX; + if (param2 & 1) flags |= FF_SEETHROUGH; // marker for allowing missing texture checks + alpha = 255; } - else + else { - static const int defflags[]= {0, - FF_SOLID, - FF_SWIMMABLE|FF_BOTHPLANES|FF_ALLSIDES|FF_SHOOTTHROUGH|FF_SEETHROUGH, - FF_SHOOTTHROUGH|FF_SEETHROUGH, + static const int defflags[] = { 0, + FF_SOLID, + FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_SHOOTTHROUGH | FF_SEETHROUGH, + FF_SHOOTTHROUGH | FF_SEETHROUGH, }; - flags = defflags[param&3] | FF_EXISTS|FF_RENDERALL; + flags = defflags[param & 3] | FF_EXISTS | FF_RENDERALL; - if (param&4) flags |= FF_ALLSIDES|FF_BOTHPLANES; - if (param&16) flags ^= FF_SEETHROUGH; - if (param&32) flags ^= FF_SHOOTTHROUGH; + if (param & 4) flags |= FF_ALLSIDES | FF_BOTHPLANES; + if (param & 16) flags ^= FF_SEETHROUGH; + if (param & 32) flags ^= FF_SHOOTTHROUGH; - if (param2&1) flags |= FF_NOSHADE; - if (param2&2) flags |= FF_DOUBLESHADOW; - if (param2&4) flags |= FF_FOG; - if (param2&8) flags |= FF_THINFLOOR; - if (param2&16) flags |= FF_UPPERTEXTURE; - if (param2&32) flags |= FF_LOWERTEXTURE; - if (param2&64) flags |= FF_ADDITIVETRANS|FF_TRANSLUCENT; + if (param2 & 1) flags |= FF_NOSHADE; + if (param2 & 2) flags |= FF_DOUBLESHADOW; + if (param2 & 4) flags |= FF_FOG; + if (param2 & 8) flags |= FF_THINFLOOR; + if (param2 & 16) flags |= FF_UPPERTEXTURE; + if (param2 & 32) flags |= FF_LOWERTEXTURE; + if (param2 & 64) flags |= FF_ADDITIVETRANS | FF_TRANSLUCENT; // if flooding is used the floor must be non-solid and is automatically made shootthrough and seethrough - if ((param2&128) && !(flags & FF_SOLID)) flags |= FF_FLOOD|FF_SEETHROUGH|FF_SHOOTTHROUGH; - if (param2&512) flags |= FF_FADEWALLS; + if ((param2 & 128) && !(flags & FF_SOLID)) flags |= FF_FLOOD | FF_SEETHROUGH | FF_SHOOTTHROUGH; + if (param2 & 512) flags |= FF_FADEWALLS; FTextureID tex = line->sidedef[0]->GetTexture(side_t::top); - if (!tex.Exists() && alpha<255) + if (!tex.Exists() && alpha < 255) { alpha = -tex.GetIndex(); } alpha = clamp(alpha, 0, 255); - if (alpha==0) flags&=~(FF_RENDERALL|FF_BOTHPLANES|FF_ALLSIDES); - else if (alpha!=255) flags|=FF_TRANSLUCENT; - + if (alpha == 0) flags &= ~(FF_RENDERALL | FF_BOTHPLANES | FF_ALLSIDES); + else if (alpha != 255) flags |= FF_TRANSLUCENT; + } P_Add3DFloor(ss, sec, line, flags, alpha); } // To be 100% safe this should be done even if the alpha by texture value isn't used. - if (!line->sidedef[0]->GetTexture(side_t::top).isValid()) + if (!line->sidedef[0]->GetTexture(side_t::top).isValid()) line->sidedef[0]->SetTexture(side_t::top, FNullTextureID()); return 1; } @@ -588,6 +591,7 @@ void P_Recalculate3DFloors(sector_t * sector) lightlist[0].extra_colormap = sector->ColorMap; lightlist[0].blend = 0; lightlist[0].flags = 0; + lightlist[0].fromsector = true; maxheight = sector->CenterCeiling(); minheight = sector->CenterFloor(); @@ -609,6 +613,7 @@ void P_Recalculate3DFloors(sector_t * sector) newlight.extra_colormap = rover->GetColormap(); newlight.blend = rover->GetBlend(); newlight.flags = rover->flags; + newlight.fromsector = false; lightlist.Push(newlight); } else if (i==0) @@ -623,6 +628,7 @@ void P_Recalculate3DFloors(sector_t * sector) lightlist[0].extra_colormap = rover->GetColormap(); lightlist[0].blend = rover->GetBlend(); lightlist[0].flags = rover->flags; + lightlist[0].fromsector = false; } } if (rover->flags&FF_DOUBLESHADOW) @@ -647,6 +653,7 @@ void P_Recalculate3DFloors(sector_t * sector) newlight.blend = 0; } newlight.flags = rover->flags; + newlight.fromsector = false; lightlist.Push(newlight); } } diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index 8abd23f03..7f18418a7 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -119,6 +119,7 @@ struct lightlist_t int flags; F3DFloor* lightsource; F3DFloor* caster; + bool fromsector; }; diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index db14aeb90..7a09b2ee8 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -450,6 +450,9 @@ void P_SerializeWorld (FArchive &arc) << desaturate; sec->ColorMap = GetSpecialLights (color, fade, desaturate); } + // begin of GZDoom additions + arc << sec->reflect[sector_t::ceiling] << sec->reflect[sector_t::floor]; + // end of GZDoom additions } // do lines diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 75d663266..83c855de5 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -1,77 +1,110 @@ -/* -** hardware.cpp -** Somewhat OS-independant interface to the screen, mouse, keyboard, and stick -** -**--------------------------------------------------------------------------- -** Copyright 1998-2006 Randy Heit -** 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 -#include -#include - -#include "hardware.h" -#include "i_video.h" -#include "i_system.h" -#include "c_console.h" -#include "c_cvars.h" -#include "c_dispatch.h" -#include "sdlvideo.h" -#include "v_text.h" -#include "doomstat.h" -#include "m_argv.h" -#include "r_renderer.h" -#include "r_swrenderer.h" - -EXTERN_CVAR (Bool, ticker) -EXTERN_CVAR (Bool, fullscreen) -EXTERN_CVAR (Float, vid_winscale) - -IVideo *Video; - -void I_ShutdownGraphics () -{ - if (screen) - { - DFrameBuffer *s = screen; - screen = NULL; - s->ObjectFlags |= OF_YesReallyDelete; - delete s; - } - if (Video) - delete Video, Video = NULL; +/* +** hardware.cpp +** Somewhat OS-independant interface to the screen, mouse, keyboard, and stick +** +**--------------------------------------------------------------------------- +** Copyright 1998-2006 Randy Heit +** 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 +#include +#include + +#include "version.h" +#include "hardware.h" +#include "i_video.h" +#include "i_system.h" +#include "c_console.h" +#include "c_cvars.h" +#include "c_dispatch.h" +#include "sdlvideo.h" +#include "v_text.h" +#include "doomstat.h" +#include "m_argv.h" +#include "sdlglvideo.h" +#include "r_renderer.h" +#include "r_swrenderer.h" + +EXTERN_CVAR (Bool, ticker) +EXTERN_CVAR (Bool, fullscreen) +EXTERN_CVAR (Float, vid_winscale) + +IVideo *Video; + +extern int NewWidth, NewHeight, NewBits, DisplayBits; +bool V_DoModeSetup (int width, int height, int bits); +void I_RestartRenderer(); + +int currentrenderer; + +// [ZDoomGL] +CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + // 0: Software renderer + // 1: OpenGL renderer + + if (self != currentrenderer) + { + switch (self) + { + case 0: + Printf("Switching to software renderer...\n"); + break; + case 1: + Printf("Switching to OpenGL renderer...\n"); + break; + default: + Printf("Unknown renderer (%d). Falling back to software renderer...\n", (int) vid_renderer); + self = 0; // make sure to actually switch to the software renderer + break; + } + Printf("You must restart " GAMENAME " to switch the renderer\n"); + } +} + +void I_ShutdownGraphics () +{ + if (screen) + { + DFrameBuffer *s = screen; + screen = NULL; + s->ObjectFlags |= OF_YesReallyDelete; + delete s; + } + if (Video) + delete Video, Video = NULL; SDL_QuitSubSystem (SDL_INIT_VIDEO); -} - -void I_InitGraphics () -{ +} + +void I_InitGraphics () +{ if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0) { I_FatalError ("Could not initialize SDL video:\n%s\n", SDL_GetError()); @@ -80,261 +113,266 @@ void I_InitGraphics () Printf("Using video driver %s\n", SDL_GetCurrentVideoDriver()); - UCVarValue val; - - val.Bool = !!Args->CheckParm ("-devparm"); - ticker.SetGenericRepDefault (val, CVAR_Bool); - - Video = new SDLVideo (0); - if (Video == NULL) - I_FatalError ("Failed to initialize display"); - - atterm (I_ShutdownGraphics); - - Video->SetWindowedScale (vid_winscale); -} - -static void I_DeleteRenderer() -{ - if (Renderer != NULL) delete Renderer; -} - -void I_CreateRenderer() -{ - if (Renderer == NULL) - { - Renderer = new FSoftwareRenderer; - atterm(I_DeleteRenderer); - } -} - - -/** Remaining code is common to Win32 and Linux **/ - -// VIDEO WRAPPERS --------------------------------------------------------- - -DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old) -{ - bool fs = false; - switch (Video->GetDisplayType ()) - { - case DISPLAY_WindowOnly: - fs = false; - break; - case DISPLAY_FullscreenOnly: - fs = true; - break; - case DISPLAY_Both: - fs = fullscreen; - break; - } - DFrameBuffer *res = Video->CreateFrameBuffer (width, height, fs, old); - - /* Right now, CreateFrameBuffer cannot return NULL - if (res == NULL) - { - I_FatalError ("Mode %dx%d is unavailable\n", width, height); - } - */ - return res; -} - -bool I_CheckResolution (int width, int height, int bits) -{ - int twidth, theight; - - Video->StartModeIterator (bits, screen ? screen->IsFullscreen() : fullscreen); - while (Video->NextMode (&twidth, &theight, NULL)) - { - if (width == twidth && height == theight) - return true; - } - return false; -} - -void I_ClosestResolution (int *width, int *height, int bits) -{ - int twidth, theight; - int cwidth = 0, cheight = 0; - int iteration; - DWORD closest = 4294967295u; - - for (iteration = 0; iteration < 2; iteration++) - { - Video->StartModeIterator (bits, screen ? screen->IsFullscreen() : fullscreen); - while (Video->NextMode (&twidth, &theight, NULL)) - { - if (twidth == *width && theight == *height) - return; - - if (iteration == 0 && (twidth < *width || theight < *height)) - continue; - - DWORD dist = (twidth - *width) * (twidth - *width) - + (theight - *height) * (theight - *height); - - if (dist < closest) - { - closest = dist; - cwidth = twidth; - cheight = theight; - } - } - if (closest != 4294967295u) - { - *width = cwidth; - *height = cheight; - return; - } - } -} - -//========================================================================== -// -// SetFPSLimit -// -// Initializes an event timer to fire at a rate of /sec. The video -// update will wait for this timer to trigger before updating. -// -// Pass 0 as the limit for unlimited. -// Pass a negative value for the limit to use the value of vid_maxfps. -// -//========================================================================== - -EXTERN_CVAR(Int, vid_maxfps); -EXTERN_CVAR(Bool, cl_capfps); - -#ifndef __APPLE__ -Semaphore FPSLimitSemaphore; - -static void FPSLimitNotify(sigval val) -{ - SEMAPHORE_SIGNAL(FPSLimitSemaphore) -} - -void I_SetFPSLimit(int limit) -{ - static sigevent FPSLimitEvent; - static timer_t FPSLimitTimer; - static bool FPSLimitTimerEnabled = false; - static bool EventSetup = false; - if(!EventSetup) - { - EventSetup = true; - FPSLimitEvent.sigev_notify = SIGEV_THREAD; - FPSLimitEvent.sigev_signo = 0; - FPSLimitEvent.sigev_value.sival_int = 0; - FPSLimitEvent.sigev_notify_function = FPSLimitNotify; - FPSLimitEvent.sigev_notify_attributes = NULL; - - SEMAPHORE_INIT(FPSLimitSemaphore, 0, 0) - } - - if (limit < 0) - { - limit = vid_maxfps; - } - // Kill any leftover timer. - if (FPSLimitTimerEnabled) - { - timer_delete(FPSLimitTimer); - FPSLimitTimerEnabled = false; - } - if (limit == 0) - { // no limit - DPrintf("FPS timer disabled\n"); - } - else - { - FPSLimitTimerEnabled = true; - if(timer_create(CLOCK_REALTIME, &FPSLimitEvent, &FPSLimitTimer) == -1) - Printf("Failed to create FPS limitter event\n"); - itimerspec period = { {0, 0}, {0, 0} }; - period.it_value.tv_nsec = period.it_interval.tv_nsec = 1000000000 / limit; - if(timer_settime(FPSLimitTimer, 0, &period, NULL) == -1) - Printf("Failed to set FPS limitter timer\n"); - DPrintf("FPS timer set to %u ms\n", (unsigned int) period.it_interval.tv_nsec / 1000000); - } -} -#else -// So Apple doesn't support POSIX timers and I can't find a good substitute short of -// having Objective-C Cocoa events or something like that. -void I_SetFPSLimit(int limit) -{ -} -#endif - -CUSTOM_CVAR (Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) -{ - if (vid_maxfps < TICRATE && vid_maxfps != 0) - { - vid_maxfps = TICRATE; - } - else if (vid_maxfps > 1000) - { - vid_maxfps = 1000; - } - else if (cl_capfps == 0) - { - I_SetFPSLimit(vid_maxfps); - } -} - -extern int NewWidth, NewHeight, NewBits, DisplayBits; - -CUSTOM_CVAR (Bool, fullscreen, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -{ - NewWidth = screen->GetWidth(); - NewHeight = screen->GetHeight(); - NewBits = DisplayBits; - setmodeneeded = true; -} - -CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -{ - if (self < 1.f) - { - self = 1.f; - } - else if (Video) - { - Video->SetWindowedScale (self); - NewWidth = screen->GetWidth(); - NewHeight = screen->GetHeight(); - NewBits = DisplayBits; - setmodeneeded = true; - } -} - -CCMD (vid_listmodes) -{ - static const char *ratios[5] = { "", " - 16:9", " - 16:10", "", " - 5:4" }; - int width, height, bits; - bool letterbox; - - if (Video == NULL) - { - return; - } - for (bits = 1; bits <= 32; bits++) - { - Video->StartModeIterator (bits, screen->IsFullscreen()); - while (Video->NextMode (&width, &height, &letterbox)) - { - bool thisMode = (width == DisplayWidth && height == DisplayHeight && bits == DisplayBits); - int ratio = CheckRatio (width, height); - Printf (thisMode ? PRINT_BOLD : PRINT_HIGH, - "%s%4d x%5d x%3d%s%s\n", - thisMode || !(ratio & 3) ? "" : TEXTCOLOR_GOLD, - width, height, bits, - ratios[ratio], - thisMode || !letterbox ? "" : TEXTCOLOR_BROWN " LB" - ); - } - } -} - -CCMD (vid_currentmode) -{ - Printf ("%dx%dx%d\n", DisplayWidth, DisplayHeight, DisplayBits); -} + UCVarValue val; + + val.Bool = !!Args->CheckParm ("-devparm"); + ticker.SetGenericRepDefault (val, CVAR_Bool); + + //currentrenderer = vid_renderer; + if (currentrenderer==1) Video = new SDLGLVideo(0); + else Video = new SDLVideo (0); + + if (Video == NULL) + I_FatalError ("Failed to initialize display"); + + atterm (I_ShutdownGraphics); + + Video->SetWindowedScale (vid_winscale); +} + +static void I_DeleteRenderer() +{ + if (Renderer != NULL) delete Renderer; +} + +void I_CreateRenderer() +{ + currentrenderer = vid_renderer; + if (Renderer == NULL) + { + if (currentrenderer==1) Renderer = gl_CreateInterface(); + else Renderer = new FSoftwareRenderer; + atterm(I_DeleteRenderer); + } +} + + +/** Remaining code is common to Win32 and Linux **/ + +// VIDEO WRAPPERS --------------------------------------------------------- + +DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old) +{ + bool fs = false; + switch (Video->GetDisplayType ()) + { + case DISPLAY_WindowOnly: + fs = false; + break; + case DISPLAY_FullscreenOnly: + fs = true; + break; + case DISPLAY_Both: + fs = fullscreen; + break; + } + DFrameBuffer *res = Video->CreateFrameBuffer (width, height, fs, old); + + /* Right now, CreateFrameBuffer cannot return NULL + if (res == NULL) + { + I_FatalError ("Mode %dx%d is unavailable\n", width, height); + } + */ + return res; +} + +bool I_CheckResolution (int width, int height, int bits) +{ + int twidth, theight; + + Video->StartModeIterator (bits, screen ? screen->IsFullscreen() : fullscreen); + while (Video->NextMode (&twidth, &theight, NULL)) + { + if (width == twidth && height == theight) + return true; + } + return false; +} + +void I_ClosestResolution (int *width, int *height, int bits) +{ + int twidth, theight; + int cwidth = 0, cheight = 0; + int iteration; + DWORD closest = 4294967295u; + + for (iteration = 0; iteration < 2; iteration++) + { + Video->StartModeIterator (bits, screen ? screen->IsFullscreen() : fullscreen); + while (Video->NextMode (&twidth, &theight, NULL)) + { + if (twidth == *width && theight == *height) + return; + + if (iteration == 0 && (twidth < *width || theight < *height)) + continue; + + DWORD dist = (twidth - *width) * (twidth - *width) + + (theight - *height) * (theight - *height); + + if (dist < closest) + { + closest = dist; + cwidth = twidth; + cheight = theight; + } + } + if (closest != 4294967295u) + { + *width = cwidth; + *height = cheight; + return; + } + } +} + +//========================================================================== +// +// SetFPSLimit +// +// Initializes an event timer to fire at a rate of /sec. The video +// update will wait for this timer to trigger before updating. +// +// Pass 0 as the limit for unlimited. +// Pass a negative value for the limit to use the value of vid_maxfps. +// +//========================================================================== + +EXTERN_CVAR(Int, vid_maxfps); +EXTERN_CVAR(Bool, cl_capfps); + +#ifndef __APPLE__ +Semaphore FPSLimitSemaphore; + +static void FPSLimitNotify(sigval val) +{ + SEMAPHORE_SIGNAL(FPSLimitSemaphore) +} + +void I_SetFPSLimit(int limit) +{ + static sigevent FPSLimitEvent; + static timer_t FPSLimitTimer; + static bool FPSLimitTimerEnabled = false; + static bool EventSetup = false; + if(!EventSetup) + { + EventSetup = true; + FPSLimitEvent.sigev_notify = SIGEV_THREAD; + FPSLimitEvent.sigev_signo = 0; + FPSLimitEvent.sigev_value.sival_int = 0; + FPSLimitEvent.sigev_notify_function = FPSLimitNotify; + FPSLimitEvent.sigev_notify_attributes = NULL; + + SEMAPHORE_INIT(FPSLimitSemaphore, 0, 0) + } + + if (limit < 0) + { + limit = vid_maxfps; + } + // Kill any leftover timer. + if (FPSLimitTimerEnabled) + { + timer_delete(FPSLimitTimer); + FPSLimitTimerEnabled = false; + } + if (limit == 0) + { // no limit + DPrintf("FPS timer disabled\n"); + } + else + { + FPSLimitTimerEnabled = true; + if(timer_create(CLOCK_REALTIME, &FPSLimitEvent, &FPSLimitTimer) == -1) + Printf("Failed to create FPS limitter event\n"); + itimerspec period = { {0, 0}, {0, 0} }; + period.it_value.tv_nsec = period.it_interval.tv_nsec = 1000000000 / limit; + if(timer_settime(FPSLimitTimer, 0, &period, NULL) == -1) + Printf("Failed to set FPS limitter timer\n"); + DPrintf("FPS timer set to %u ms\n", (unsigned int) period.it_interval.tv_nsec / 1000000); + } +} +#else +// So Apple doesn't support POSIX timers and I can't find a good substitute short of +// having Objective-C Cocoa events or something like that. +void I_SetFPSLimit(int limit) +{ +} +#endif + +CUSTOM_CVAR (Int, vid_maxfps, 200, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) +{ + if (vid_maxfps < TICRATE && vid_maxfps != 0) + { + vid_maxfps = TICRATE; + } + else if (vid_maxfps > 1000) + { + vid_maxfps = 1000; + } + else if (cl_capfps == 0) + { + I_SetFPSLimit(vid_maxfps); + } +} + +extern int NewWidth, NewHeight, NewBits, DisplayBits; + +CUSTOM_CVAR (Bool, fullscreen, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + NewWidth = screen->GetWidth(); + NewHeight = screen->GetHeight(); + NewBits = DisplayBits; + setmodeneeded = true; +} + +CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (self < 1.f) + { + self = 1.f; + } + else if (Video) + { + Video->SetWindowedScale (self); + NewWidth = screen->GetWidth(); + NewHeight = screen->GetHeight(); + NewBits = DisplayBits; + setmodeneeded = true; + } +} + +CCMD (vid_listmodes) +{ + static const char *ratios[5] = { "", " - 16:9", " - 16:10", "", " - 5:4" }; + int width, height, bits; + bool letterbox; + + if (Video == NULL) + { + return; + } + for (bits = 1; bits <= 32; bits++) + { + Video->StartModeIterator (bits, screen->IsFullscreen()); + while (Video->NextMode (&width, &height, &letterbox)) + { + bool thisMode = (width == DisplayWidth && height == DisplayHeight && bits == DisplayBits); + int ratio = CheckRatio (width, height); + Printf (thisMode ? PRINT_BOLD : PRINT_HIGH, + "%s%4d x%5d x%3d%s%s\n", + thisMode || !(ratio & 3) ? "" : TEXTCOLOR_GOLD, + width, height, bits, + ratios[ratio], + thisMode || !letterbox ? "" : TEXTCOLOR_BROWN " LB" + ); + } + } +} + +CCMD (vid_currentmode) +{ + Printf ("%dx%dx%d\n", DisplayWidth, DisplayHeight, DisplayBits); +} diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp new file mode 100644 index 000000000..54506b813 --- /dev/null +++ b/src/posix/sdl/sdlglvideo.cpp @@ -0,0 +1,449 @@ + +// HEADER FILES ------------------------------------------------------------ + +#include "doomtype.h" + +#include "templates.h" +#include "i_system.h" +#include "i_video.h" +#include "v_video.h" +#include "v_pfx.h" +#include "stats.h" +#include "version.h" +#include "c_console.h" + +#include "sdlglvideo.h" +#include "gl/system/gl_system.h" +#include "r_defs.h" +#include "gl/gl_functions.h" +//#include "gl/gl_intern.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/shaders/gl_shader.h" +#include "gl/utility/gl_templates.h" +#include "gl/textures/gl_material.h" +#include "gl/system/gl_cvars.h" + +// MACROS ------------------------------------------------------------------ + +// TYPES ------------------------------------------------------------------- + +IMPLEMENT_ABSTRACT_CLASS(SDLGLFB) + +struct MiniModeInfo +{ + WORD Width, Height; +}; + +// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- + +// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- + +// EXTERNAL DATA DECLARATIONS ---------------------------------------------- + +extern IVideo *Video; +// extern int vid_renderer; + +EXTERN_CVAR (Float, Gamma) +EXTERN_CVAR (Int, vid_adapter) +EXTERN_CVAR (Int, vid_displaybits) +EXTERN_CVAR (Int, vid_renderer) + + +// PUBLIC DATA DEFINITIONS ------------------------------------------------- + +CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL ) +{ + Printf("This won't take effect until " GAMENAME " is restarted.\n"); +} + +// PRIVATE DATA DEFINITIONS ------------------------------------------------ + +// Dummy screen sizes to pass when windowed +static MiniModeInfo WinModes[] = +{ + { 320, 200 }, + { 320, 240 }, + { 400, 225 }, // 16:9 + { 400, 300 }, + { 480, 270 }, // 16:9 + { 480, 360 }, + { 512, 288 }, // 16:9 + { 512, 384 }, + { 640, 360 }, // 16:9 + { 640, 400 }, + { 640, 480 }, + { 720, 480 }, // 16:10 + { 720, 540 }, + { 800, 450 }, // 16:9 + { 800, 480 }, + { 800, 500 }, // 16:10 + { 800, 600 }, + { 848, 480 }, // 16:9 + { 960, 600 }, // 16:10 + { 960, 720 }, + { 1024, 576 }, // 16:9 + { 1024, 600 }, // 17:10 + { 1024, 640 }, // 16:10 + { 1024, 768 }, + { 1088, 612 }, // 16:9 + { 1152, 648 }, // 16:9 + { 1152, 720 }, // 16:10 + { 1152, 864 }, + { 1280, 720 }, // 16:9 + { 1280, 854 }, + { 1280, 800 }, // 16:10 + { 1280, 960 }, + { 1280, 1024 }, // 5:4 + { 1360, 768 }, // 16:9 + { 1366, 768 }, + { 1400, 787 }, // 16:9 + { 1400, 875 }, // 16:10 + { 1400, 1050 }, + { 1440, 900 }, + { 1440, 960 }, + { 1440, 1080 }, + { 1600, 900 }, // 16:9 + { 1600, 1000 }, // 16:10 + { 1600, 1200 }, + { 1920, 1080 }, + { 1920, 1200 }, + { 2048, 1536 }, + { 2560, 1440 }, + { 2560, 1600 }, + { 2560, 2048 }, + { 2880, 1800 }, + { 3200, 1800 }, + { 3840, 2160 }, + { 3840, 2400 }, + { 4096, 2160 }, + { 5120, 2880 } +}; + +// CODE -------------------------------------------------------------------- + +SDLGLVideo::SDLGLVideo (int parm) +{ + IteratorBits = 0; + if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { + fprintf( stderr, "Video initialization failed: %s\n", + SDL_GetError( ) ); + } +#ifndef _WIN32 + // mouse cursor is visible by default on linux systems, we disable it by default + SDL_ShowCursor (0); +#endif +} + +SDLGLVideo::~SDLGLVideo () +{ + if (GLRenderer != NULL) GLRenderer->FlushTextures(); +} + +void SDLGLVideo::StartModeIterator (int bits, bool fs) +{ + IteratorMode = 0; + IteratorBits = bits; +} + +bool SDLGLVideo::NextMode (int *width, int *height, bool *letterbox) +{ + if (IteratorBits != 8) + return false; + + if ((unsigned)IteratorMode < sizeof(WinModes)/sizeof(WinModes[0])) + { + *width = WinModes[IteratorMode].Width; + *height = WinModes[IteratorMode].Height; + ++IteratorMode; + return true; + } + return false; +} + +DFrameBuffer *SDLGLVideo::CreateFrameBuffer (int width, int height, bool fullscreen, DFrameBuffer *old) +{ + static int retry = 0; + static int owidth, oheight; + + PalEntry flashColor; +// int flashAmount; + + if (old != NULL) + { // Reuse the old framebuffer if its attributes are the same + SDLGLFB *fb = static_cast (old); + if (fb->Width == width && + fb->Height == height) + { + bool fsnow = (SDL_GetWindowFlags (fb->Screen) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0; + + if (fsnow != fullscreen) + { + SDL_SetWindowFullscreen (fb->Screen, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); + } + return old; + } +// old->GetFlash (flashColor, flashAmount); + delete old; + } + else + { + flashColor = 0; +// flashAmount = 0; + } + + SDLGLFB *fb = new OpenGLFrameBuffer (0, width, height, 32, 60, fullscreen); + retry = 0; + + // If we could not create the framebuffer, try again with slightly + // different parameters in this order: + // 1. Try with the closest size + // 2. Try in the opposite screen mode with the original size + // 3. Try in the opposite screen mode with the closest size + // This is a somewhat confusing mass of recursion here. + + while (fb == NULL || !fb->IsValid ()) + { + if (fb != NULL) + { + delete fb; + } + + switch (retry) + { + case 0: + owidth = width; + oheight = height; + case 2: + // Try a different resolution. Hopefully that will work. + I_ClosestResolution (&width, &height, 8); + break; + + case 1: + // Try changing fullscreen mode. Maybe that will work. + width = owidth; + height = oheight; + fullscreen = !fullscreen; + break; + + default: + // I give up! + I_FatalError ("Could not create new screen (%d x %d)", owidth, oheight); + + fprintf( stderr, "!!! [SDLGLVideo::CreateFrameBuffer] Got beyond I_FatalError !!!" ); + return NULL; //[C] actually this shouldn't be reached; probably should be replaced with an ASSERT + } + + ++retry; + fb = static_cast(CreateFrameBuffer (width, height, fullscreen, NULL)); + } + +// fb->SetFlash (flashColor, flashAmount); + return fb; +} + +void SDLGLVideo::SetWindowedScale (float scale) +{ +} + +bool SDLGLVideo::SetResolution (int width, int height, int bits) +{ + // FIXME: Is it possible to do this without completely destroying the old + // interface? +#ifndef NO_GL + + if (GLRenderer != NULL) GLRenderer->FlushTextures(); + I_ShutdownGraphics(); + + Video = new SDLGLVideo(0); + if (Video == NULL) I_FatalError ("Failed to initialize display"); + +#if (defined(WINDOWS)) || defined(WIN32) + bits=32; +#else + bits=24; +#endif + + V_DoModeSetup(width, height, bits); +#endif + return true; // We must return true because the old video context no longer exists. +} + +//========================================================================== +// +// +// +//========================================================================== + +bool SDLGLVideo::SetupPixelFormat(bool allowsoftware, int multisample) +{ + SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); + SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8 ); + SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + if (multisample > 0) { + SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); + SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, multisample ); + } + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool SDLGLVideo::InitHardware (bool allowsoftware, int multisample) +{ + if (!SetupPixelFormat(allowsoftware, multisample)) + { + Printf ("R_OPENGL: Reverting to software mode...\n"); + return false; + } + return true; +} + + +// FrameBuffer implementation ----------------------------------------------- + +SDLGLFB::SDLGLFB (void *, int width, int height, int, int, bool fullscreen) + : DFrameBuffer (width, height) +{ + static int localmultisample=-1; + + if (localmultisample<0) localmultisample=gl_vid_multisample; + + int i; + + m_Lock=0; + + UpdatePending = false; + + if (!static_cast(Video)->InitHardware(false, localmultisample)) + { + vid_renderer = 0; + return; + } + + FString caption; + caption.Format(GAMESIG " %s (%s)", GetVersionString(), GetGitTime()); + Screen = SDL_CreateWindow (caption, + SDL_WINDOWPOS_UNDEFINED_DISPLAY(vid_adapter), SDL_WINDOWPOS_UNDEFINED_DISPLAY(vid_adapter), + width, height, (fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)|SDL_WINDOW_OPENGL); + + if (Screen == NULL) + return; + + GLContext = SDL_GL_CreateContext(Screen); + if (GLContext == NULL) + return; + + m_supportsGamma = -1 != SDL_GetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]); +} + +SDLGLFB::~SDLGLFB () +{ + if (Screen) + { + if (m_supportsGamma) + { + SDL_SetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]); + } + + if (GLContext) + { + SDL_GL_DeleteContext(GLContext); + } + + SDL_DestroyWindow(Screen); + } +} + + + + +void SDLGLFB::InitializeState() +{ +} + +bool SDLGLFB::CanUpdate () +{ + if (m_Lock != 1) + { + if (m_Lock > 0) + { + UpdatePending = true; + --m_Lock; + } + return false; + } + return true; +} + +void SDLGLFB::SetGammaTable(WORD *tbl) +{ + SDL_SetWindowGammaRamp(Screen, &tbl[0], &tbl[256], &tbl[512]); +} + +bool SDLGLFB::Lock(bool buffered) +{ + m_Lock++; + Buffer = MemBuffer; + return true; +} + +bool SDLGLFB::Lock () +{ + return Lock(false); +} + +void SDLGLFB::Unlock () +{ + if (UpdatePending && m_Lock == 1) + { + Update (); + } + else if (--m_Lock <= 0) + { + m_Lock = 0; + } +} + +bool SDLGLFB::IsLocked () +{ + return m_Lock>0;// true; +} + +bool SDLGLFB::IsFullscreen () +{ + return (SDL_GetWindowFlags (Screen) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0; +} + + +bool SDLGLFB::IsValid () +{ + return DFrameBuffer::IsValid() && Screen != NULL; +} + +void SDLGLFB::SetVSync( bool vsync ) +{ +#if defined (__APPLE__) + const GLint value = vsync ? 1 : 0; + CGLSetParameter( CGLGetCurrentContext(), kCGLCPSwapInterval, &value ); +#endif +} + +void SDLGLFB::NewRefreshRate () +{ +} + +void SDLGLFB::SwapBuffers() +{ + SDL_GL_SwapWindow (Screen); +} + diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h new file mode 100644 index 000000000..19e6a5ff5 --- /dev/null +++ b/src/posix/sdl/sdlglvideo.h @@ -0,0 +1,83 @@ +#ifndef __SDLGLVIDEO_H__ +#define __SDLGLVIDEO_H__ + +#include "hardware.h" +#include "v_video.h" +#include +#include "gl/system/gl_system.h" + +EXTERN_CVAR (Float, dimamount) +EXTERN_CVAR (Color, dimcolor) + +struct FRenderer; +FRenderer *gl_CreateInterface(); + +class SDLGLVideo : public IVideo +{ + public: + SDLGLVideo (int parm); + ~SDLGLVideo (); + + EDisplayType GetDisplayType () { return DISPLAY_Both; } + void SetWindowedScale (float scale); + + DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); + + void StartModeIterator (int bits, bool fs); + bool NextMode (int *width, int *height, bool *letterbox); + bool SetResolution (int width, int height, int bits); + + bool SetupPixelFormat(bool allowsoftware, int multisample); + bool InitHardware (bool allowsoftware, int multisample); + +private: + int IteratorMode; + int IteratorBits; +}; +class SDLGLFB : public DFrameBuffer +{ + DECLARE_CLASS(SDLGLFB, DFrameBuffer) +public: + // this must have the same parameters as the Windows version, even if they are not used! + SDLGLFB (void *hMonitor, int width, int height, int, int, bool fullscreen); + ~SDLGLFB (); + + void ForceBuffering (bool force); + bool Lock(bool buffered); + bool Lock (); + void Unlock(); + bool IsLocked (); + + bool IsValid (); + bool IsFullscreen (); + + virtual void SetVSync( bool vsync ); + void SwapBuffers(); + + void NewRefreshRate (); + + friend class SDLGLVideo; + +//[C] + int GetTrueHeight() { return GetHeight();} + +protected: + bool CanUpdate(); + void SetGammaTable(WORD *tbl); + void InitializeState(); + + SDLGLFB () {} + BYTE GammaTable[3][256]; + bool UpdatePending; + + SDL_Window *Screen; + + SDL_GLContext GLContext; + + void UpdateColors (); + + int m_Lock; + Uint16 m_origGamma[3][256]; + bool m_supportsGamma; +}; +#endif diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index 3ca3b557c..29f54c39b 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -451,12 +451,12 @@ void DSectorPlaneInterpolation::Restore() if (!ceiling) { sector->floorplane.d = bakheight; - sector->SetPlaneTexZ(sector_t::floor, baktexz); + sector->SetPlaneTexZ(sector_t::floor, baktexz, true); } else { sector->ceilingplane.d = bakheight; - sector->SetPlaneTexZ(sector_t::ceiling, baktexz); + sector->SetPlaneTexZ(sector_t::ceiling, baktexz, true); } P_RecalculateAttached3DFloors(sector); } @@ -487,7 +487,7 @@ void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio) baktexz = sector->GetPlaneTexZ(pos); *pheight = oldheight + FixedMul(bakheight - oldheight, smoothratio); - sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio)); + sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio), true); P_RecalculateAttached3DFloors(sector); } diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index d11388e6e..8d867f25f 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -824,6 +824,15 @@ void R_InitTranslationTables () remap->Remap[i] = IcePaletteRemap[v]; remap->Palette[i] = PalEntry(255, IcePalette[v][0], IcePalette[v][1], IcePalette[v][2]); } + + // The alphatexture translation. Since alphatextures use the red channel this is just a standard grayscale mapping. + PushIdentityTable(TRANSLATION_Standard); + remap = translationtables[TRANSLATION_Standard][8]; + for (i = 0; i < 256; i++) + { + remap->Remap[i] = i; + remap->Palette[i] = PalEntry(255, i, i, i); + } } //---------------------------------------------------------------------------- diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index ebf4699da..ccf808a2f 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -15,6 +15,8 @@ #include "r_data/voxels.h" #include "textures/textures.h" +void gl_InitModels(); + // variables used to look up // and range check thing_t sprites patches TArray sprites; @@ -986,6 +988,8 @@ void R_InitSprites () // [RH] Sort the skins, but leave base as skin 0 //qsort (&skins[PlayerClasses.Size ()], numskins-PlayerClasses.Size (), sizeof(FPlayerSkin), skinsorter); + + gl_InitModels(); } void R_DeinitSpriteData() diff --git a/src/r_defs.h b/src/r_defs.h index c05fdf2fc..55176a1c1 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -35,6 +35,9 @@ // to handle sound origins in sectors. // SECTORS do store MObjs anyway. #include "actor.h" +struct FLightNode; +struct FGLSection; +struct seg_t; #include "dthinker.h" @@ -81,15 +84,43 @@ struct vertex_t { fixed_t x, y; + float fx, fy; // Floating point coordinates of this vertex (excluding polyoblect translation!) + angle_t viewangle; // precalculated angle for clipping + int angletime; // recalculation time for view angle + bool dirty; // something has changed and needs to be recalculated + int numheights; + int numsectors; + sector_t ** sectors; + float * heightlist; + + vertex_t() + { + x = y = 0; + fx = fy = 0; + angletime = 0; + viewangle = 0; + dirty = true; + numheights = numsectors = 0; + sectors = NULL; + heightlist = NULL; + } + bool operator== (const vertex_t &other) { return x == other.x && y == other.y; } + bool operator!= (const vertex_t &other) + { + return x != other.x || y != other.y; + } + void clear() { x = y = 0; } + + angle_t GetClipAngle(); }; // Forward of LineDefs, for Sectors. @@ -325,6 +356,12 @@ FArchive &operator<< (FArchive &arc, secplane_t &plane); #include "p_3dfloors.h" +struct subsector_t; +struct sector_t; +struct side_t; +extern bool gl_plane_reflection_i; +struct FPortal; + // Ceiling/floor flags enum { @@ -428,6 +465,8 @@ struct extsector_t TArray lightlist; // 3D light list TArray attached; // 3D floors attached to this sector } XFloor; + + TArray vertices; void Serialize(FArchive &arc); }; @@ -644,14 +683,28 @@ struct sector_t return planes[pos].TexZ; } - void SetPlaneTexZ(int pos, fixed_t val) + void SetVerticesDirty() + { + for (unsigned i = 0; i < e->vertices.Size(); i++) e->vertices[i]->dirty = true; + } + + void SetAllVerticesDirty() + { + SetVerticesDirty(); + for (unsigned i = 0; i < e->FakeFloor.Sectors.Size(); i++) e->FakeFloor.Sectors[i]->SetVerticesDirty(); + for (unsigned i = 0; i < e->XFloor.attached.Size(); i++) e->XFloor.attached[i]->SetVerticesDirty(); + } + + void SetPlaneTexZ(int pos, fixed_t val, bool dirtify = false) // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code. { planes[pos].TexZ = val; + if (dirtify) SetAllVerticesDirty(); } void ChangePlaneTexZ(int pos, fixed_t val) { planes[pos].TexZ += val; + SetAllVerticesDirty(); } static inline short ClampLight(int level) @@ -801,6 +854,36 @@ struct sector_t int sectornum; // for comparing sector copies extsector_t * e; // This stores data that requires construction/destruction. Such data must not be copied by R_FakeFlat. + + // GL only stuff starts here + float reflect[2]; + + bool transdoor; // For transparent door hacks + fixed_t transdoorheight; // for transparent door hacks + int subsectorcount; // list of subsectors + subsector_t ** subsectors; + FPortal * portals[2]; // floor and ceiling portals + FLightNode * lighthead; + + enum + { + vbo_fakefloor = floor+2, + vbo_fakeceiling = ceiling+2, + }; + + int vboindex[4]; // VBO indices of the 4 planes this sector uses during rendering + fixed_t vboheight[2]; // Last calculated height for the 2 planes of this actual sector + int vbocount[2]; // Total count of vertices belonging to this sector's planes + + float GetReflect(int pos) { return gl_plane_reflection_i? reflect[pos] : 0; } + bool VBOHeightcheck(int pos) const { return vboheight[pos] == GetPlaneTexZ(pos); } + + enum + { + INVALIDATE_PLANES = 1, + INVALIDATE_OTHER = 2 + }; + }; FArchive &operator<< (FArchive &arc, sector_t::splane &p); @@ -955,6 +1038,13 @@ struct side_t vertex_t *V1() const; vertex_t *V2() const; + + //For GL + FLightNode * lighthead; // all blended lights that may affect this wall + + seg_t **segs; // all segs belonging to this sidedef in ascending order. Used for precise rendering + int numsegs; + }; FArchive &operator<< (FArchive &arc, side_t::part &p); @@ -1019,6 +1109,11 @@ struct seg_t // Sector references. Could be retrieved from linedef, too. sector_t* frontsector; sector_t* backsector; // NULL for one-sided lines + + seg_t* PartnerSeg; + subsector_t* Subsector; + + float sidefrac; // relative position of seg's ending vertex on owning sidedef }; struct glsegextra_t @@ -1027,6 +1122,9 @@ struct glsegextra_t subsector_t *Subsector; }; +extern seg_t *segs; + + // // A SubSector. // References a Sector. @@ -1041,6 +1139,12 @@ enum SSECF_POLYORG = 4, }; +struct FPortalCoverage +{ + DWORD * subsectors; + int sscount; +}; + struct subsector_t { sector_t *sector; @@ -1052,6 +1156,13 @@ struct subsector_t int flags; void BuildPolyBSP(); + // subsector related GL data + FLightNode * lighthead; // Light nodes (blended and additive) + int validcount; + short mapsection; + char hacked; // 1: is part of a render hack + // 2: has one-sided walls + FPortalCoverage portalcoverage[2]; }; diff --git a/src/stats.h b/src/stats.h index ed493188b..24ab24cdf 100644 --- a/src/stats.h +++ b/src/stats.h @@ -267,6 +267,10 @@ public: virtual FString GetStats () = 0; void ToggleStat (); + bool isActive() const + { + return m_Active; + } static void PrintStat (); static FStat *FindStat (const char *name); diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 4fc82ac0d..0612fa792 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -1239,6 +1239,8 @@ void FTextureManager::PrecacheLevel (void) if (demoplayback) return; + precacheTime = I_FPSTime(); + hitlist = new BYTE[cnt]; memset (hitlist, 0, cnt); diff --git a/src/textures/textures.h b/src/textures/textures.h index cb3680ead..6a75dfed3 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -3,6 +3,27 @@ #include "doomtype.h" +struct FloatRect +{ + float left,top; + float width,height; + + + void Offset(float xofs,float yofs) + { + left+=xofs; + top+=yofs; + } + void Scale(float xfac,float yfac) + { + left*=xfac; + width*=xfac; + top*=yfac; + height*=yfac; + } +}; + + class FBitmap; struct FRemapTable; struct FCopyInfo; @@ -13,6 +34,8 @@ class FArchive; // Texture IDs class FTextureManager; class FTerrainTypeArray; +class FGLTexture; +class FMaterial; class FTextureID { @@ -291,6 +314,9 @@ protected: CopySize(other); bNoDecals = other->bNoDecals; Rotations = other->Rotations; + gl_info = other->gl_info; + gl_info.Brightmap = NULL; + gl_info.areas = NULL; } public: @@ -300,8 +326,51 @@ public: static void FlipNonSquareBlockRemap (BYTE *blockto, const BYTE *blockfrom, int x, int y, int srcpitch, const BYTE *remap); friend class D3DTex; -}; +public: + + struct MiscGLInfo + { + FMaterial *Material[2]; + FGLTexture *SystemTexture[2]; + FTexture *Brightmap; + PalEntry GlowColor; + PalEntry FloorSkyColor; + PalEntry CeilingSkyColor; + int GlowHeight; + FloatRect *areas; + int areacount; + int shaderindex; + unsigned int precacheTime; + float shaderspeed; + int mIsTransparent:2; + bool bGlowing:1; // Texture glows + bool bFullbright:1; // always draw fullbright + bool bSkybox:1; // This is a skybox + bool bSkyColorDone:1; // Fill color for sky + char bBrightmapChecked:1; // Set to 1 if brightmap has been checked + bool bDisableFullbright:1; // This texture will not be displayed as fullbright sprite + bool bNoFilter:1; + bool bNoCompress:1; + bool bNoExpand:1; + + MiscGLInfo() throw (); + ~MiscGLInfo(); + }; + MiscGLInfo gl_info; + + virtual void PrecacheGL(int cache); + virtual void UncacheGL(); + void GetGlowColor(float *data); + PalEntry GetSkyCapColor(bool bottom); + bool isGlowing() { return gl_info.bGlowing; } + bool isFullbright() { return gl_info.bFullbright; } + void CreateDefaultBrightmap(); + bool FindHoles(const unsigned char * buffer, int w, int h); + static bool SmoothEdges(unsigned char * buffer,int w, int h); + void CheckTrans(unsigned char * buffer, int size, int trans); + bool ProcessData(unsigned char * buffer, int w, int h, bool ispatch); +}; // Texture manager class FTextureManager @@ -421,6 +490,8 @@ public: FSwitchDef *FindSwitch (FTextureID texture); FDoorAnimation *FindAnimatedDoor (FTextureID picnum); + unsigned int precacheTime; + private: // texture counting diff --git a/src/version.h b/src/version.h index 6a0eb9c4b..1ebc9ac5d 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "2.8pre" +#define VERSIONSTR "2.1pre" // The version as seen in the Windows resource -#define RC_FILEVERSION 2,7,9999,0 -#define RC_PRODUCTVERSION 2,7,9999,0 -#define RC_PRODUCTVERSION2 "2.8pre" +#define RC_FILEVERSION 2,0,9999,0 +#define RC_PRODUCTVERSION 2,0,9999,0 +#define RC_PRODUCTVERSION2 "2.1pre" // Version identifier for network games. // Bump it every time you do a release unless you're certain you @@ -82,15 +82,17 @@ const char *GetVersionString(); #define SAVEVERSTRINGIFY(x) SAVEVERSTRINGIFY2(x) #define SAVESIG "ZDOOMSAVE" SAVEVERSTRINGIFY(SAVEVER) +#define DYNLIGHT + // This is so that derivates can use the same savegame versions without worrying about engine compatibility -#define GAMESIG "ZDOOM" -#define BASEWAD "zdoom.pk3" +#define GAMESIG "GZDOOM" +#define BASEWAD "gzdoom.pk3" // More stuff that needs to be different for derivatives. -#define GAMENAME "ZDoom" -#define GAMENAMELOWERCASE "zdoom" -#define FORUM_URL "http://forum.zdoom.org" -#define BUGS_FORUM_URL "http://forum.zdoom.org/index.php?c=3" +#define GAMENAME "GZDoom" +#define GAMENAMELOWERCASE "gzdoom" +#define FORUM_URL "http://forum.drdteam.org" +#define BUGS_FORUM_URL "http://forum.drdteam.org/viewforum.php?f=24" #if defined(__APPLE__) || defined(_WIN32) #define GAME_DIR GAMENAME diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 1641df365..8120de501 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -3091,8 +3091,8 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, return; } - cosrot = cos(rot); - sinrot = sin(rot); + cosrot = (float)cos(rot); + sinrot = (float)sin(rot); CheckQuadBatch(npoints - 2, npoints); quad = &QuadExtra[QuadBatchPos]; diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index 6b3f40f1c..2c3fbdea4 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -62,6 +62,45 @@ bool ForceWindowed; IVideo *Video; +// do not include GL headers here, only declare the necessary functions. +IVideo *gl_CreateVideo(); +FRenderer *gl_CreateInterface(); + +void I_RestartRenderer(); +int currentrenderer = -1; +bool changerenderer; + +// [ZDoomGL] +CUSTOM_CVAR (Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + // 0: Software renderer + // 1: OpenGL renderer + + if (self != currentrenderer) + { + switch (self) + { + case 0: + Printf("Switching to software renderer...\n"); + break; + case 1: + Printf("Switching to OpenGL renderer...\n"); + break; + default: + Printf("Unknown renderer (%d). Falling back to software renderer...\n", *vid_renderer); + self = 0; // make sure to actually switch to the software renderer + break; + } + //changerenderer = true; + Printf("You must restart " GAMENAME " to switch the renderer\n"); + } +} + +CCMD (vid_restart) +{ +} + + void I_ShutdownGraphics () { if (screen) @@ -94,15 +133,18 @@ void I_InitGraphics () // not receive a WM_ACTIVATEAPP message, so both games think they // are the active app. Huh? } - val.Bool = !!Args->CheckParm ("-devparm"); ticker.SetGenericRepDefault (val, CVAR_Bool); - Video = new Win32Video (0); + + //currentrenderer = vid_renderer; + if (currentrenderer==1) Video = gl_CreateVideo(); + else Video = new Win32Video (0); + if (Video == NULL) I_FatalError ("Failed to initialize display"); - + atterm (I_ShutdownGraphics); - + Video->SetWindowedScale (vid_winscale); } @@ -113,9 +155,11 @@ static void I_DeleteRenderer() void I_CreateRenderer() { + currentrenderer = vid_renderer; if (Renderer == NULL) { - Renderer = new FSoftwareRenderer; + if (currentrenderer==1) Renderer = gl_CreateInterface(); + else Renderer = new FSoftwareRenderer; atterm(I_DeleteRenderer); } } @@ -148,12 +192,12 @@ DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old) } DFrameBuffer *res = Video->CreateFrameBuffer (width, height, fs, old); - /* Right now, CreateFrameBuffer cannot return NULL + //* Right now, CreateFrameBuffer cannot return NULL if (res == NULL) { I_FatalError ("Mode %dx%d is unavailable\n", width, height); } - */ + //*/ return res; } @@ -332,7 +376,7 @@ CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) NewWidth = screen->GetWidth(); NewHeight = screen->GetHeight(); NewBits = DisplayBits; - setmodeneeded = true; + //setmodeneeded = true; // This CVAR doesn't do anything and only causes problems! } } diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index 133337af5..cb21c3728 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -1,1761 +1,1761 @@ -/* -** i_system.cpp -** Timers, pre-console output, IWAD selection, and misc system routines. -** -**--------------------------------------------------------------------------- -** Copyright 1998-2009 Randy Heit -** 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. -**--------------------------------------------------------------------------- -** -*/ - -// HEADER FILES ------------------------------------------------------------ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#include - -#define USE_WINDOWS_DWORD -#include "hardware.h" -#include "doomerrors.h" -#include - -#include "doomtype.h" -#include "version.h" -#include "doomdef.h" -#include "cmdlib.h" -#include "m_argv.h" -#include "m_misc.h" -#include "i_video.h" -#include "i_sound.h" -#include "i_music.h" -#include "resource.h" -#include "x86.h" -#include "stats.h" - -#include "d_main.h" -#include "d_net.h" -#include "g_game.h" -#include "i_input.h" -#include "i_system.h" -#include "c_dispatch.h" -#include "templates.h" -#include "gameconfigfile.h" -#include "v_font.h" -#include "g_level.h" -#include "doomstat.h" -#include "v_palette.h" -#include "stats.h" -#include "textures/bitmap.h" -#include "textures/textures.h" - -// MACROS ------------------------------------------------------------------ - -#ifdef _MSC_VER -// Turn off "conversion from 'LONG_PTR' to 'LONG', possible loss of data" -// generated by SetClassLongPtr(). -#pragma warning(disable:4244) -#endif - -// TYPES ------------------------------------------------------------------- - -// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- - -extern void CheckCPUID(CPUInfo *cpu); -extern void LayoutMainWindow(HWND hWnd, HWND pane); - -// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- - -// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- - -static void CalculateCPUSpeed(); -static void I_SelectTimer(); - -static int I_GetTimePolled(bool saveMS); -static int I_WaitForTicPolled(int prevtic); -static void I_FreezeTimePolled(bool frozen); -static int I_GetTimeEventDriven(bool saveMS); -static int I_WaitForTicEvent(int prevtic); -static void I_FreezeTimeEventDriven(bool frozen); -static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2); - -static HCURSOR CreateCompatibleCursor(FTexture *cursorpic); -static HCURSOR CreateAlphaCursor(FTexture *cursorpic); -static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP color_mask); -static void DestroyCustomCursor(); - -// EXTERNAL DATA DECLARATIONS ---------------------------------------------- - -EXTERN_CVAR(String, language); -EXTERN_CVAR (Bool, queryiwad); - -extern HWND Window, ConWindow, GameTitleWindow; -extern HANDLE StdOut; -extern bool FancyStdOut; -extern HINSTANCE g_hInst; -extern FILE *Logfile; -extern bool NativeMouse; -extern bool ConWindowHidden; - -// PUBLIC DATA DEFINITIONS ------------------------------------------------- - -CVAR (String, queryiwad_key, "shift", CVAR_GLOBALCONFIG|CVAR_ARCHIVE); -CVAR (Bool, con_debugoutput, false, 0); - -double PerfToSec, PerfToMillisec; -UINT TimerPeriod; -UINT TimerEventID; -UINT MillisecondsPerTic; -HANDLE NewTicArrived; -uint32 LanguageIDs[4]; - -int (*I_GetTime) (bool saveMS); -int (*I_WaitForTic) (int); -void (*I_FreezeTime) (bool frozen); - -os_t OSPlatform; -bool gameisdead; - -// PRIVATE DATA DEFINITIONS ------------------------------------------------ - -static ticcmd_t emptycmd; -static bool HasExited; - -static DWORD basetime = 0; -// These are for the polled timer. -static DWORD TicStart; -static DWORD TicNext; -static int TicFrozen; - -// These are for the event-driven timer. -static int tics; -static DWORD ted_start, ted_next; - -static WadStuff *WadList; -static int NumWads; -static int DefaultWad; - -static HCURSOR CustomCursor; - -// CODE -------------------------------------------------------------------- - -//========================================================================== -// -// I_Tactile -// -// Doom calls it when you take damage, so presumably it could be converted -// to something compatible with force feedback. -// -//========================================================================== - -void I_Tactile(int on, int off, int total) -{ - // UNUSED. - on = off = total = 0; -} - -//========================================================================== -// -// I_BaseTiccmd -// -// Returns an empty ticcmd. I have no idea why this should be system- -// specific. -// -//========================================================================== - -ticcmd_t *I_BaseTiccmd() -{ - return &emptycmd; -} - -// Stubs that select the timer to use and then call into it ---------------- - -//========================================================================== -// -// I_GetTimeSelect -// -//========================================================================== - -static int I_GetTimeSelect(bool saveMS) -{ - I_SelectTimer(); - return I_GetTime(saveMS); -} - -//========================================================================== -// -// I_WaitForTicSelect -// -//========================================================================== - -static int I_WaitForTicSelect(int prevtic) -{ - I_SelectTimer(); - return I_WaitForTic(prevtic); -} - -//========================================================================== -// -// I_SelectTimer -// -// Tries to create a timer event for efficent CPU use when the FPS is -// capped. Failing that, it sets things up for a polling timer instead. -// -//========================================================================== - -static void I_SelectTimer() -{ - assert(basetime == 0); - - // Use a timer event if possible. - NewTicArrived = CreateEvent(NULL, FALSE, FALSE, NULL); - if (NewTicArrived) - { - UINT delay; - const char *cmdDelay; - - cmdDelay = Args->CheckValue("-timerdelay"); - delay = 0; - if (cmdDelay != 0) - { - delay = atoi(cmdDelay); - } - if (delay == 0) - { - delay = 1000/TICRATE; - } - MillisecondsPerTic = delay; - TimerEventID = timeSetEvent(delay, 0, TimerTicked, 0, TIME_PERIODIC); - } - // Get the current time as the basetime. - basetime = timeGetTime(); - // Set timer functions. - if (TimerEventID != 0) - { - I_GetTime = I_GetTimeEventDriven; - I_WaitForTic = I_WaitForTicEvent; - I_FreezeTime = I_FreezeTimeEventDriven; - } - else - { - I_GetTime = I_GetTimePolled; - I_WaitForTic = I_WaitForTicPolled; - I_FreezeTime = I_FreezeTimePolled; - } -} - -//========================================================================== -// -// I_MSTime -// -// Returns the current time in milliseconds, where 0 is the first call -// to I_GetTime or I_WaitForTic. -// -//========================================================================== - -unsigned int I_MSTime() -{ - assert(basetime != 0); - return timeGetTime() - basetime; -} - -//========================================================================== -// -// I_FPSTime -// -// Returns the current system time in milliseconds. This is used by the FPS -// meter of DFrameBuffer::DrawRateStuff(). Since the screen can display -// before the play simulation is ready to begin, this needs to be -// separate from I_MSTime(). -// -//========================================================================== - -unsigned int I_FPSTime() -{ - return timeGetTime(); -} - -//========================================================================== -// -// I_GetTimePolled -// -// Returns the current time in tics. If saveMS is true, then calls to -// I_GetTimeFrac() will use this tic as 0 and the next tic as 1. -// -//========================================================================== - -static int I_GetTimePolled(bool saveMS) -{ - DWORD tm; - - if (TicFrozen != 0) - { - return TicFrozen; - } - - tm = timeGetTime(); - if (basetime == 0) - { - basetime = tm; - } - if (saveMS) - { - TicStart = tm; - TicNext = (tm * TICRATE / 1000 + 1) * 1000 / TICRATE; - } - - return ((tm-basetime)*TICRATE)/1000; -} - -//========================================================================== -// -// I_WaitForTicPolled -// -// Busy waits until the current tic is greater than prevtic. Time must not -// be frozen. -// -//========================================================================== - -static int I_WaitForTicPolled(int prevtic) -{ - int time; - - assert(TicFrozen == 0); - while ((time = I_GetTimePolled(false)) <= prevtic) - { } - - return time; -} - -//========================================================================== -// -// I_FreezeTimePolled -// -// Freeze/unfreeze the timer. -// -//========================================================================== - -static void I_FreezeTimePolled(bool frozen) -{ - if (frozen) - { - assert(TicFrozen == 0); - TicFrozen = I_GetTimePolled(false); - } - else - { - assert(TicFrozen != 0); - int froze = TicFrozen; - TicFrozen = 0; - int now = I_GetTimePolled(false); - basetime += (now - froze) * 1000 / TICRATE; - } -} - -//========================================================================== -// -// I_GetTimeEventDriven -// -// Returns the current tick counter. This is incremented asynchronously as -// the timer event fires. -// -//========================================================================== - -static int I_GetTimeEventDriven(bool saveMS) -{ - if (saveMS) - { - TicStart = ted_start; - TicNext = ted_next; - } - return tics; -} - -//========================================================================== -// -// I_WaitForTicEvent -// -// Waits on the timer event as long as the current tic is not later than -// prevtic. -// -//========================================================================== - -static int I_WaitForTicEvent(int prevtic) -{ - assert(!TicFrozen); - while (prevtic >= tics) - { - WaitForSingleObject(NewTicArrived, 1000/TICRATE); - } - return tics; -} - -//========================================================================== -// -// I_FreezeTimeEventDriven -// -// Freeze/unfreeze the ticker. -// -//========================================================================== - -static void I_FreezeTimeEventDriven(bool frozen) -{ - TicFrozen = frozen; -} - -//========================================================================== -// -// TimerTicked -// -// Advance the tick count and signal the NewTicArrived event. -// -//========================================================================== - -static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2) -{ - if (!TicFrozen) - { - tics++; - } - ted_start = timeGetTime (); - ted_next = ted_start + MillisecondsPerTic; - SetEvent(NewTicArrived); -} - -//========================================================================== -// -// I_GetTimeFrac -// -// Returns the fractional amount of a tic passed since the most recently -// saved tic. -// -//========================================================================== - -fixed_t I_GetTimeFrac(uint32 *ms) -{ - DWORD now = timeGetTime(); - if (ms != NULL) - { - *ms = TicNext; - } - DWORD step = TicNext - TicStart; - if (step == 0) - { - return FRACUNIT; - } - else - { - fixed_t frac = clamp ((now - TicStart)*FRACUNIT/step, 0, FRACUNIT); - return frac; - } -} - -//========================================================================== -// -// I_WaitVBL -// -// I_WaitVBL is never used to actually synchronize to the vertical blank. -// Instead, it's used for delay purposes. Doom used a 70 Hz display mode, -// so that's what we use to determine how long to wait for. -// -//========================================================================== - -void I_WaitVBL(int count) -{ - Sleep(1000 * count / 70); -} - -//========================================================================== -// -// I_DetectOS -// -// Determine which version of Windows the game is running on. -// -//========================================================================== - -void I_DetectOS(void) -{ - OSVERSIONINFOEX info; - const char *osname; - - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - if (!GetVersionEx((OSVERSIONINFO *)&info)) - { - // Retry with the older OSVERSIONINFO structure. - info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx((OSVERSIONINFO *)&info); - } - - switch (info.dwPlatformId) - { - case VER_PLATFORM_WIN32_WINDOWS: - OSPlatform = os_Win95; - if (info.dwMinorVersion < 10) - { - osname = "95"; - } - else if (info.dwMinorVersion < 90) - { - osname = "98"; - } - else - { - osname = "Me"; - } - break; - - case VER_PLATFORM_WIN32_NT: - OSPlatform = info.dwMajorVersion < 5 ? os_WinNT4 : os_Win2k; - osname = "NT"; - if (info.dwMajorVersion == 5) - { - if (info.dwMinorVersion == 0) - { - osname = "2000"; - } - if (info.dwMinorVersion == 1) - { - osname = "XP"; - } - else if (info.dwMinorVersion == 2) - { - osname = "Server 2003"; - } - } - else if (info.dwMajorVersion == 6) - { - if (info.dwMinorVersion == 0) - { - osname = (info.wProductType == VER_NT_WORKSTATION) ? "Vista" : "Server 2008"; - } - else if (info.dwMinorVersion == 1) - { - osname = (info.wProductType == VER_NT_WORKSTATION) ? "7" : "Server 2008 R2"; - } - else if (info.dwMinorVersion == 2) - { - // Starting with Windows 8.1, you need to specify in your manifest - // the highest version of Windows you support, which will also be the - // highest version of Windows this function returns. - osname = (info.wProductType == VER_NT_WORKSTATION) ? "8" : "Server 2012"; - } - else if (info.dwMinorVersion == 3) - { - osname = (info.wProductType == VER_NT_WORKSTATION) ? "8.1" : "Server 2012 R2"; - } - else if (info.dwMinorVersion == 4) - { - osname = (info.wProductType == VER_NT_WORKSTATION) ? "10 (or higher)" : "Server 10 (or higher)"; - } - } - break; - - default: - OSPlatform = os_unknown; - osname = "Unknown OS"; - break; - } - - if (OSPlatform == os_Win95) - { - Printf ("OS: Windows %s %lu.%lu.%lu %s\n", - osname, - info.dwMajorVersion, info.dwMinorVersion, - info.dwBuildNumber & 0xffff, info.szCSDVersion); - } - else - { - Printf ("OS: Windows %s (NT %lu.%lu) Build %lu\n %s\n", - osname, - info.dwMajorVersion, info.dwMinorVersion, - info.dwBuildNumber, info.szCSDVersion); - } - - if (OSPlatform == os_unknown) - { - Printf ("(Assuming Windows 2000)\n"); - OSPlatform = os_Win2k; - } -} - -//========================================================================== -// -// SubsetLanguageIDs -// -// Helper function for SetLanguageIDs. -// -//========================================================================== - -static void SubsetLanguageIDs(LCID id, LCTYPE type, int idx) -{ - char buf[8]; - LCID langid; - char *idp; - - if (!GetLocaleInfo(id, type, buf, 8)) - return; - langid = MAKELCID(strtoul(buf, NULL, 16), SORT_DEFAULT); - if (!GetLocaleInfo(langid, LOCALE_SABBREVLANGNAME, buf, 8)) - return; - idp = (char *)(&LanguageIDs[idx]); - memset (idp, 0, 4); - idp[0] = tolower(buf[0]); - idp[1] = tolower(buf[1]); - idp[2] = tolower(buf[2]); - idp[3] = 0; -} - -//========================================================================== -// -// SetLanguageIDs -// -//========================================================================== - -void SetLanguageIDs() -{ - size_t langlen = strlen(language); - - if (langlen < 2 || langlen > 3) - { - memset(LanguageIDs, 0, sizeof(LanguageIDs)); - SubsetLanguageIDs(LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, 0); - SubsetLanguageIDs(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 1); - SubsetLanguageIDs(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, 2); - SubsetLanguageIDs(LOCALE_SYSTEM_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 3); - } - else - { - DWORD lang = 0; - - ((BYTE *)&lang)[0] = (language)[0]; - ((BYTE *)&lang)[1] = (language)[1]; - ((BYTE *)&lang)[2] = (language)[2]; - LanguageIDs[0] = lang; - LanguageIDs[1] = lang; - LanguageIDs[2] = lang; - LanguageIDs[3] = lang; - } -} - -//========================================================================== -// -// CalculateCPUSpeed -// -// Make a decent guess at how much time elapses between TSC steps. This can -// vary over runtime depending on power management settings, so should not -// be used anywhere that truely accurate timing actually matters. -// -//========================================================================== - -void CalculateCPUSpeed() -{ - LARGE_INTEGER freq; - - QueryPerformanceFrequency (&freq); - - if (freq.QuadPart != 0 && CPU.bRDTSC) - { - LARGE_INTEGER count1, count2; - cycle_t ClockCalibration; - DWORD min_diff; - - ClockCalibration.Reset(); - - // Count cycles for at least 55 milliseconds. - // The performance counter may be very low resolution compared to CPU - // speeds today, so the longer we count, the more accurate our estimate. - // On the other hand, we don't want to count too long, because we don't - // want the user to notice us spend time here, since most users will - // probably never use the performance statistics. - min_diff = freq.LowPart * 11 / 200; - - // Minimize the chance of task switching during the testing by going very - // high priority. This is another reason to avoid timing for too long. - SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); - - // Make sure we start timing on a counter boundary. - QueryPerformanceCounter(&count1); - do { QueryPerformanceCounter(&count2); } while (count1.QuadPart == count2.QuadPart); - - // Do the timing loop. - ClockCalibration.Clock(); - do { QueryPerformanceCounter(&count1); } while ((count1.QuadPart - count2.QuadPart) < min_diff); - ClockCalibration.Unclock(); - - SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); - - PerfToSec = double(count1.QuadPart - count2.QuadPart) / (double(ClockCalibration.GetRawCounter()) * freq.QuadPart); - PerfToMillisec = PerfToSec * 1000.0; - } - - Printf ("CPU Speed: %.0f MHz\n", 0.001 / PerfToMillisec); -} - -//========================================================================== -// -// I_Init -// -//========================================================================== - -void I_Init() -{ - CheckCPUID(&CPU); - CalculateCPUSpeed(); - DumpCPUInfo(&CPU); - - I_GetTime = I_GetTimeSelect; - I_WaitForTic = I_WaitForTicSelect; - - atterm (I_ShutdownSound); - I_InitSound (); -} - -//========================================================================== -// -// I_Quit -// -//========================================================================== - -void I_Quit() -{ - HasExited = true; /* Prevent infinitely recursive exits -- killough */ - - if (TimerEventID != 0) - { - timeKillEvent(TimerEventID); - } - if (NewTicArrived != NULL) - { - CloseHandle(NewTicArrived); - } - timeEndPeriod(TimerPeriod); - if (demorecording) - { - G_CheckDemoStatus(); - } - - C_DeinitConsole(); -} - - -//========================================================================== -// -// I_FatalError -// -// Throw an error that will end the game. -// -//========================================================================== - -void STACK_ARGS I_FatalError(const char *error, ...) -{ - static BOOL alreadyThrown = false; - gameisdead = true; - - if (!alreadyThrown) // ignore all but the first message -- killough - { - alreadyThrown = true; - char errortext[MAX_ERRORTEXT]; - va_list argptr; - va_start(argptr, error); - myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr); - va_end(argptr); - - // Record error to log (if logging) - if (Logfile) - { - fprintf(Logfile, "\n**** DIED WITH FATAL ERROR:\n%s\n", errortext); - fflush(Logfile); - } - - throw CFatalError(errortext); - } - - if (!HasExited) // If it hasn't exited yet, exit now -- killough - { - HasExited = 1; // Prevent infinitely recursive exits -- killough - exit(-1); - } -} - -//========================================================================== -// -// I_Error -// -// Throw an error that will send us to the console if we are far enough -// along in the startup process. -// -//========================================================================== - -void STACK_ARGS I_Error(const char *error, ...) -{ - va_list argptr; - char errortext[MAX_ERRORTEXT]; - - va_start(argptr, error); - myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr); - va_end(argptr); - - throw CRecoverableError(errortext); -} - -//========================================================================== -// -// ToEditControl -// -// Converts string to Unicode and inserts it into the control. -// -//========================================================================== - -void ToEditControl(HWND edit, const char *buf, wchar_t *wbuf, int bpos) -{ - // Let's just do this ourself. It's not hard, and we can compensate for - // special console characters at the same time. -#if 0 - MultiByteToWideChar(1252 /* Western */, 0, buf, bpos, wbuf, countof(wbuf)); - wbuf[bpos] = 0; -#else - static wchar_t notlatin1[32] = // code points 0x80-0x9F - { - 0x20AC, // Euro sign - 0x0081, // Undefined - 0x201A, // Single low-9 quotation mark - 0x0192, // Latin small letter f with hook - 0x201E, // Double low-9 quotation mark - 0x2026, // Horizontal ellipsis - 0x2020, // Dagger - 0x2021, // Double dagger - 0x02C6, // Modifier letter circumflex accent - 0x2030, // Per mille sign - 0x0160, // Latin capital letter S with caron - 0x2039, // Single left-pointing angle quotation mark - 0x0152, // Latin capital ligature OE - 0x008D, // Undefined - 0x017D, // Latin capital letter Z with caron - 0x008F, // Undefined - 0x0090, // Undefined - 0x2018, // Left single quotation mark - 0x2019, // Right single quotation mark - 0x201C, // Left double quotation mark - 0x201D, // Right double quotation mark - 0x2022, // Bullet - 0x2013, // En dash - 0x2014, // Em dash - 0x02DC, // Small tilde - 0x2122, // Trade mark sign - 0x0161, // Latin small letter s with caron - 0x203A, // Single right-pointing angle quotation mark - 0x0153, // Latin small ligature oe - 0x009D, // Undefined - 0x017E, // Latin small letter z with caron - 0x0178 // Latin capital letter Y with diaeresis - }; - for (int i = 0; i <= bpos; ++i) - { - wchar_t code = (BYTE)buf[i]; - if (code >= 0x1D && code <= 0x1F) - { // The bar characters, most commonly used to indicate map changes - code = 0x2550; // Box Drawings Double Horizontal - } - else if (code >= 0x80 && code <= 0x9F) - { - code = notlatin1[code - 0x80]; - } - wbuf[i] = code; - } -#endif - SendMessageW(edit, EM_REPLACESEL, FALSE, (LPARAM)wbuf); -} - -//========================================================================== -// -// I_PrintStr -// -// Send output to the list box shown during startup (and hidden during -// gameplay). -// -//========================================================================== - -static void DoPrintStr(const char *cp, HWND edit, HANDLE StdOut) -{ - if (edit == NULL && StdOut == NULL) - return; - - char buf[256]; - wchar_t wbuf[countof(buf)]; - int bpos = 0; - CHARRANGE selection; - CHARRANGE endselection; - LONG lines_before = 0, lines_after; - CHARFORMAT format; - - if (edit != NULL) - { - // Store the current selection and set it to the end so we can append text. - SendMessage(edit, EM_EXGETSEL, 0, (LPARAM)&selection); - endselection.cpMax = endselection.cpMin = GetWindowTextLength(edit); - SendMessage(edit, EM_EXSETSEL, 0, (LPARAM)&endselection); - - // GetWindowTextLength and EM_EXSETSEL can disagree on where the end of - // the text is. Find out what EM_EXSETSEL thought it was and use that later. - SendMessage(edit, EM_EXGETSEL, 0, (LPARAM)&endselection); - - // Remember how many lines there were before we added text. - lines_before = (LONG)SendMessage(edit, EM_GETLINECOUNT, 0, 0); - } - - while (*cp != 0) - { - // 28 is the escape code for a color change. - if ((*cp == 28 && bpos != 0) || bpos == 255) - { - buf[bpos] = 0; - if (edit != NULL) - { - ToEditControl(edit, buf, wbuf, bpos); - } - if (StdOut != NULL) - { - DWORD bytes_written; - WriteFile(StdOut, buf, bpos, &bytes_written, NULL); - } - bpos = 0; - } - if (*cp != 28) - { - buf[bpos++] = *cp++; - } - else - { - const BYTE *color_id = (const BYTE *)cp + 1; - EColorRange range = V_ParseFontColor(color_id, CR_UNTRANSLATED, CR_YELLOW); - cp = (const char *)color_id; - - if (range != CR_UNDEFINED) - { - // Change the color of future text added to the control. - PalEntry color = V_LogColorFromColorRange(range); - if (StdOut != NULL && FancyStdOut) - { - // Unfortunately, we are pretty limited here: There are only - // eight basic colors, and each comes in a dark and a bright - // variety. - float h, s, v, r, g, b; - WORD attrib = 0; - - RGBtoHSV(color.r / 255.f, color.g / 255.f, color.b / 255.f, &h, &s, &v); - if (s != 0) - { // color - HSVtoRGB(&r, &g, &b, h, 1, 1); - if (r == 1) attrib = FOREGROUND_RED; - if (g == 1) attrib |= FOREGROUND_GREEN; - if (b == 1) attrib |= FOREGROUND_BLUE; - if (v > 0.6) attrib |= FOREGROUND_INTENSITY; - } - else - { // gray - if (v < 0.33) attrib = FOREGROUND_INTENSITY; - else if (v < 0.90) attrib = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; - else attrib = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; - } - SetConsoleTextAttribute(StdOut, attrib); - } - if (edit != NULL) - { - // GDI uses BGR colors, but color is RGB, so swap the R and the B. - swapvalues(color.r, color.b); - // Change the color. - format.cbSize = sizeof(format); - format.dwMask = CFM_COLOR; - format.dwEffects = 0; - format.crTextColor = color; - SendMessage(edit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format); - } - } - } - } - if (bpos != 0) - { - buf[bpos] = 0; - if (edit != NULL) - { - ToEditControl(edit, buf, wbuf, bpos); - } - if (StdOut != NULL) - { - DWORD bytes_written; - WriteFile(StdOut, buf, bpos, &bytes_written, NULL); - } - } - - if (edit != NULL) - { - // If the old selection was at the end of the text, keep it at the end and - // scroll. Don't scroll if the selection is anywhere else. - if (selection.cpMin == endselection.cpMin && selection.cpMax == endselection.cpMax) - { - selection.cpMax = selection.cpMin = GetWindowTextLength (edit); - lines_after = (LONG)SendMessage(edit, EM_GETLINECOUNT, 0, 0); - if (lines_after > lines_before) - { - SendMessage(edit, EM_LINESCROLL, 0, lines_after - lines_before); - } - } - // Restore the previous selection. - SendMessage(edit, EM_EXSETSEL, 0, (LPARAM)&selection); - // Give the edit control a chance to redraw itself. - I_GetEvent(); - } - if (StdOut != NULL && FancyStdOut) - { // Set text back to gray, in case it was changed. - SetConsoleTextAttribute(StdOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); - } -} - -static TArray bufferedConsoleStuff; - -void I_PrintStr(const char *cp) -{ - if (con_debugoutput) - { - // Strip out any color escape sequences before writing to debug output - char * copy = new char[strlen(cp)+1]; - const char * srcp = cp; - char * dstp = copy; - - while (*srcp != 0) - { - if (*srcp!=0x1c && *srcp!=0x1d && *srcp!=0x1e && *srcp!=0x1f) - { - *dstp++=*srcp++; - } - else - { - if (srcp[1]!=0) srcp+=2; - else break; - } - } - *dstp=0; - - OutputDebugStringA(copy); - delete [] copy; - } - - if (ConWindowHidden) - { - bufferedConsoleStuff.Push(cp); - DoPrintStr(cp, NULL, StdOut); - } - else - { - DoPrintStr(cp, ConWindow, StdOut); - } -} - -void I_FlushBufferedConsoleStuff() -{ - for (unsigned i = 0; i < bufferedConsoleStuff.Size(); i++) - { - DoPrintStr(bufferedConsoleStuff[i], ConWindow, NULL); - } - bufferedConsoleStuff.Clear(); -} - -//========================================================================== -// -// SetQueryIWAD -// -// The user had the "Don't ask again" box checked when they closed the -// IWAD selection dialog. -// -//========================================================================== - -static void SetQueryIWad(HWND dialog) -{ - HWND checkbox = GetDlgItem(dialog, IDC_DONTASKIWAD); - int state = (int)SendMessage(checkbox, BM_GETCHECK, 0, 0); - bool query = (state != BST_CHECKED); - - if (!query && queryiwad) - { - MessageBox(dialog, - "You have chosen not to show this dialog box in the future.\n" - "If you wish to see it again, hold down SHIFT while starting " GAMENAME ".", - "Don't ask me this again", - MB_OK | MB_ICONINFORMATION); - } - - queryiwad = query; -} - -//========================================================================== -// -// IWADBoxCallback -// -// Dialog proc for the IWAD selector. -// -//========================================================================== - -BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - HWND ctrl; - int i; - - switch (message) - { - case WM_INITDIALOG: - // Add our program name to the window title - { - TCHAR label[256]; - FString newlabel; - - GetWindowText(hDlg, label, countof(label)); - newlabel.Format(GAMESIG " %s: %s", GetVersionString(), label); - SetWindowText(hDlg, newlabel.GetChars()); - } - // Populate the list with all the IWADs found - ctrl = GetDlgItem(hDlg, IDC_IWADLIST); - for (i = 0; i < NumWads; i++) - { - FString work; - const char *filepart = strrchr(WadList[i].Path, '/'); - if (filepart == NULL) - filepart = WadList[i].Path; - else - filepart++; - work.Format("%s (%s)", WadList[i].Name.GetChars(), filepart); - SendMessage(ctrl, LB_ADDSTRING, 0, (LPARAM)work.GetChars()); - SendMessage(ctrl, LB_SETITEMDATA, i, (LPARAM)i); - } - SendMessage(ctrl, LB_SETCURSEL, DefaultWad, 0); - SetFocus(ctrl); - // Set the state of the "Don't ask me again" checkbox - ctrl = GetDlgItem(hDlg, IDC_DONTASKIWAD); - SendMessage(ctrl, BM_SETCHECK, queryiwad ? BST_UNCHECKED : BST_CHECKED, 0); - // Make sure the dialog is in front. If SHIFT was pressed to force it visible, - // then the other window will normally be on top. - SetForegroundWindow(hDlg); - break; - - case WM_COMMAND: - if (LOWORD(wParam) == IDCANCEL) - { - EndDialog (hDlg, -1); - } - else if (LOWORD(wParam) == IDOK || - (LOWORD(wParam) == IDC_IWADLIST && HIWORD(wParam) == LBN_DBLCLK)) - { - SetQueryIWad(hDlg); - ctrl = GetDlgItem (hDlg, IDC_IWADLIST); - EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); - } - break; - } - return FALSE; -} - -//========================================================================== -// -// I_PickIWad -// -// Open a dialog to pick the IWAD, if there is more than one found. -// -//========================================================================== - -int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad) -{ - int vkey; - - if (stricmp(queryiwad_key, "shift") == 0) - { - vkey = VK_SHIFT; - } - else if (stricmp(queryiwad_key, "control") == 0 || stricmp (queryiwad_key, "ctrl") == 0) - { - vkey = VK_CONTROL; - } - else - { - vkey = 0; - } - if (showwin || (vkey != 0 && GetAsyncKeyState(vkey))) - { - WadList = wads; - NumWads = numwads; - DefaultWad = defaultiwad; - - return (int)DialogBox(g_hInst, MAKEINTRESOURCE(IDD_IWADDIALOG), - (HWND)Window, (DLGPROC)IWADBoxCallback); - } - return defaultiwad; -} - -//========================================================================== -// -// I_SetCursor -// -// Returns true if the cursor was successfully changed. -// -//========================================================================== - -bool I_SetCursor(FTexture *cursorpic) -{ - HCURSOR cursor; - - if (cursorpic != NULL && cursorpic->UseType != FTexture::TEX_Null && - (screen == NULL || !screen->Is8BitMode())) - { - // Must be no larger than 32x32. - if (cursorpic->GetWidth() > 32 || cursorpic->GetHeight() > 32) - { - return false; - } - - cursor = CreateAlphaCursor(cursorpic); - if (cursor == NULL) - { - cursor = CreateCompatibleCursor(cursorpic); - } - if (cursor == NULL) - { - return false; - } - // Replace the existing cursor with the new one. - DestroyCustomCursor(); - CustomCursor = cursor; - atterm(DestroyCustomCursor); - } - else - { - DestroyCustomCursor(); - cursor = LoadCursor(NULL, IDC_ARROW); - } - SetClassLongPtr(Window, GCLP_HCURSOR, (LONG_PTR)cursor); - if (NativeMouse) - { - POINT pt; - RECT client; - - // If the mouse pointer is within the window's client rect, set it now. - if (GetCursorPos(&pt) && GetClientRect(Window, &client) && - ClientToScreen(Window, (LPPOINT)&client.left) && - ClientToScreen(Window, (LPPOINT)&client.right)) - { - if (pt.x >= client.left && pt.x < client.right && - pt.y >= client.top && pt.y < client.bottom) - { - SetCursor(cursor); - } - } - } - return true; -} - -//========================================================================== -// -// CreateCompatibleCursor -// -// Creates a cursor with a 1-bit alpha channel. -// -//========================================================================== - -static HCURSOR CreateCompatibleCursor(FTexture *cursorpic) -{ - int picwidth = cursorpic->GetWidth(); - int picheight = cursorpic->GetHeight(); - - // Create bitmap masks for the cursor from the texture. - HDC dc = GetDC(NULL); - if (dc == NULL) - { - return false; - } - HDC and_mask_dc = CreateCompatibleDC(dc); - HDC xor_mask_dc = CreateCompatibleDC(dc); - HBITMAP and_mask = CreateCompatibleBitmap(dc, 32, 32); - HBITMAP xor_mask = CreateCompatibleBitmap(dc, 32, 32); - ReleaseDC(NULL, dc); - - SelectObject(and_mask_dc, and_mask); - SelectObject(xor_mask_dc, xor_mask); - - // Initialize with an invisible cursor. - SelectObject(and_mask_dc, GetStockObject(WHITE_PEN)); - SelectObject(and_mask_dc, GetStockObject(WHITE_BRUSH)); - Rectangle(and_mask_dc, 0, 0, 32, 32); - SelectObject(xor_mask_dc, GetStockObject(BLACK_PEN)); - SelectObject(xor_mask_dc, GetStockObject(BLACK_BRUSH)); - Rectangle(xor_mask_dc, 0, 0, 32, 32); - - FBitmap bmp; - const BYTE *pixels; - - bmp.Create(picwidth, picheight); - cursorpic->CopyTrueColorPixels(&bmp, 0, 0); - pixels = bmp.GetPixels(); - - // Copy color data from the source texture to the cursor bitmaps. - for (int y = 0; y < picheight; ++y) - { - for (int x = 0; x < picwidth; ++x) - { - const BYTE *bgra = &pixels[x*4 + y*bmp.GetPitch()]; - if (bgra[3] != 0) - { - SetPixelV(and_mask_dc, x, y, RGB(0,0,0)); - SetPixelV(xor_mask_dc, x, y, RGB(bgra[2], bgra[1], bgra[0])); - } - } - } - DeleteDC(and_mask_dc); - DeleteDC(xor_mask_dc); - - // Create the cursor from the bitmaps. - return CreateBitmapCursor(cursorpic->LeftOffset, cursorpic->TopOffset, and_mask, xor_mask); -} - -//========================================================================== -// -// CreateAlphaCursor -// -// Creates a cursor with a full alpha channel. -// -//========================================================================== - -static HCURSOR CreateAlphaCursor(FTexture *cursorpic) -{ - HDC dc; - BITMAPV5HEADER bi; - HBITMAP color, mono; - void *bits; - - memset(&bi, 0, sizeof(bi)); - bi.bV5Size = sizeof(bi); - bi.bV5Width = 32; - bi.bV5Height = 32; - bi.bV5Planes = 1; - bi.bV5BitCount = 32; - bi.bV5Compression = BI_BITFIELDS; - bi.bV5RedMask = 0x00FF0000; - bi.bV5GreenMask = 0x0000FF00; - bi.bV5BlueMask = 0x000000FF; - bi.bV5AlphaMask = 0xFF000000; - - dc = GetDC(NULL); - if (dc == NULL) - { - return NULL; - } - - // Create the DIB section with an alpha channel. - color = CreateDIBSection(dc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, &bits, NULL, 0); - ReleaseDC(NULL, dc); - - if (color == NULL) - { - return NULL; - } - - // Create an empty mask bitmap, since CreateIconIndirect requires this. - mono = CreateBitmap(32, 32, 1, 1, NULL); - if (mono == NULL) - { - DeleteObject(color); - return NULL; - } - - // Copy cursor to the color bitmap. Note that GDI bitmaps are upside down compared - // to normal conventions, so we create the FBitmap pointing at the last row and use - // a negative pitch so that CopyTrueColorPixels will use GDI's orientation. - FBitmap bmp((BYTE *)bits + 31*32*4, -32*4, 32, 32); - cursorpic->CopyTrueColorPixels(&bmp, 0, 0); - - return CreateBitmapCursor(cursorpic->LeftOffset, cursorpic->TopOffset, mono, color); -} - -//========================================================================== -// -// CreateBitmapCursor -// -// Create the cursor from the bitmaps. Deletes the bitmaps before returning. -// -//========================================================================== - -static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP color_mask) -{ - ICONINFO iconinfo = - { - FALSE, // fIcon - xhot, // xHotspot - yhot, // yHotspot - and_mask, // hbmMask - color_mask // hbmColor - }; - HCURSOR cursor = CreateIconIndirect(&iconinfo); - - // Delete the bitmaps. - DeleteObject(and_mask); - DeleteObject(color_mask); - - return cursor; -} - -//========================================================================== -// -// DestroyCustomCursor -// -//========================================================================== - -static void DestroyCustomCursor() -{ - if (CustomCursor != NULL) - { - DestroyCursor(CustomCursor); - CustomCursor = NULL; - } -} - -//========================================================================== -// -// I_WriteIniFailed -// -// Display a message when the config failed to save. -// -//========================================================================== - -bool I_WriteIniFailed() -{ - char *lpMsgBuf; - FString errortext; - - FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPSTR)&lpMsgBuf, - 0, - NULL - ); - errortext.Format ("The config file %s could not be written:\n%s", GameConfig->GetPathName(), lpMsgBuf); - LocalFree (lpMsgBuf); - return MessageBox(Window, errortext.GetChars(), GAMENAME " configuration not saved", MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDRETRY; -} - -//========================================================================== -// -// I_FindFirst -// -// Start a pattern matching sequence. -// -//========================================================================== - -void *I_FindFirst(const char *filespec, findstate_t *fileinfo) -{ - return FindFirstFileA(filespec, (LPWIN32_FIND_DATAA)fileinfo); -} - -//========================================================================== -// -// I_FindNext -// -// Return the next file in a pattern matching sequence. -// -//========================================================================== - -int I_FindNext(void *handle, findstate_t *fileinfo) -{ - return !FindNextFileA((HANDLE)handle, (LPWIN32_FIND_DATAA)fileinfo); -} - -//========================================================================== -// -// I_FindClose -// -// Finish a pattern matching sequence. -// -//========================================================================== - -int I_FindClose(void *handle) -{ - return FindClose((HANDLE)handle); -} - -//========================================================================== -// -// QueryPathKey -// -// Returns the value of a registry key into the output variable value. -// -//========================================================================== - -static bool QueryPathKey(HKEY key, const char *keypath, const char *valname, FString &value) -{ - HKEY pathkey; - DWORD pathtype; - DWORD pathlen; - LONG res; - - if(ERROR_SUCCESS == RegOpenKeyEx(key, keypath, 0, KEY_QUERY_VALUE, &pathkey)) - { - if (ERROR_SUCCESS == RegQueryValueEx(pathkey, valname, 0, &pathtype, NULL, &pathlen) && - pathtype == REG_SZ && pathlen != 0) - { - // Don't include terminating null in count - char *chars = value.LockNewBuffer(pathlen - 1); - res = RegQueryValueEx(pathkey, valname, 0, NULL, (LPBYTE)chars, &pathlen); - value.UnlockBuffer(); - if (res != ERROR_SUCCESS) - { - value = ""; - } - } - RegCloseKey(pathkey); - } - return value.IsNotEmpty(); -} - -//========================================================================== -// -// I_GetGogPaths -// -// Check the registry for GOG installation paths, so we can search for IWADs -// that were bought from GOG.com. This is a bit different from the Steam -// version because each game has its own independent installation path, no -// such thing as /SteamApps/common/. -// -//========================================================================== - -TArray I_GetGogPaths() -{ - TArray result; - FString path; - FString gamepath; - -#ifdef _WIN64 - FString gogregistrypath = "Software\\Wow6432Node\\GOG.com\\Games"; -#else - // If a 32-bit ZDoom runs on a 64-bit Windows, this will be transparently and - // automatically redirected to the Wow6432Node address instead, so this address - // should be safe to use in all cases. - FString gogregistrypath = "Software\\GOG.com\\Games"; -#endif - - // Look for Ultimate Doom - gamepath = gogregistrypath + "\\1435827232"; - if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) - { - result.Push(path); // directly in install folder - } - - // Look for Doom II - gamepath = gogregistrypath + "\\1435848814"; - if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) - { - result.Push(path + "/doom2"); // in a subdirectory - // If direct support for the Master Levels is ever added, they are in path + /master/wads - } - - // Look for Final Doom - gamepath = gogregistrypath + "\\1435848742"; - if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) - { - // in subdirectories - result.Push(path + "/TNT"); - result.Push(path + "/Plutonia"); - } - - return result; -} - -//========================================================================== -// -// I_GetSteamPath -// -// Check the registry for the path to Steam, so that we can search for -// IWADs that were bought with Steam. -// -//========================================================================== - -TArray I_GetSteamPath() -{ - TArray result; - static const char *const steam_dirs[] = - { - "doom 2/base", - "final doom/base", - "heretic shadow of the serpent riders/base", - "hexen/base", - "hexen deathkings of the dark citadel/base", - "ultimate doom/base", - "DOOM 3 BFG Edition/base/wads", - "Strife" - }; - - FString path; - - if (!QueryPathKey(HKEY_CURRENT_USER, "Software\\Valve\\Steam", "SteamPath", path)) - { - if (!QueryPathKey(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", "InstallPath", path)) - return result; - } - path += "/SteamApps/common/"; - - for(unsigned int i = 0; i < countof(steam_dirs); ++i) - { - result.Push(path + steam_dirs[i]); - } - - return result; -} - -//========================================================================== -// -// I_MakeRNGSeed -// -// Returns a 32-bit random seed, preferably one with lots of entropy. -// -//========================================================================== - -unsigned int I_MakeRNGSeed() -{ - unsigned int seed; - - // If RtlGenRandom is available, use that to avoid increasing the - // working set by pulling in all of the crytographic API. - HMODULE advapi = GetModuleHandle("advapi32.dll"); - if (advapi != NULL) - { - BOOLEAN (APIENTRY *RtlGenRandom)(void *, ULONG) = - (BOOLEAN (APIENTRY *)(void *, ULONG))GetProcAddress(advapi, "SystemFunction036"); - if (RtlGenRandom != NULL) - { - if (RtlGenRandom(&seed, sizeof(seed))) - { - return seed; - } - } - } - - // Use the full crytographic API to produce a seed. If that fails, - // time() is used as a fallback. - HCRYPTPROV prov; - - if (!CryptAcquireContext(&prov, NULL, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) - { - return (unsigned int)time(NULL); - } - if (!CryptGenRandom(prov, sizeof(seed), (BYTE *)&seed)) - { - seed = (unsigned int)time(NULL); - } - CryptReleaseContext(prov, 0); - return seed; -} - -//========================================================================== -// -// I_GetLongPathName -// -// Returns the long version of the path, or the original if there isn't -// anything worth changing. -// -//========================================================================== - -FString I_GetLongPathName(FString shortpath) -{ - static TOptWin32Proc - GetLongPathNameA("kernel32.dll", "GetLongPathNameA"); - - // Doesn't exist on NT4 - if (GetLongPathName == NULL) - return shortpath; - - DWORD buffsize = GetLongPathNameA.Call(shortpath.GetChars(), NULL, 0); - if (buffsize == 0) - { // nothing to change (it doesn't exist, maybe?) - return shortpath; - } - TCHAR *buff = new TCHAR[buffsize]; - DWORD buffsize2 = GetLongPathNameA.Call(shortpath.GetChars(), buff, buffsize); - if (buffsize2 >= buffsize) - { // Failure! Just return the short path - delete[] buff; - return shortpath; - } - FString longpath(buff, buffsize2); - delete[] buff; - return longpath; -} - -#if _MSC_VER == 1900 && defined(_USING_V110_SDK71_) -//========================================================================== -// -// VS14Stat -// -// Work around an issue where stat doesn't work with v140_xp. This was -// supposedly fixed, but as of Update 1 continues to not function on XP. -// -//========================================================================== - -#include - -int VS14Stat(const char *path, struct _stat64i32 *buffer) -{ - WIN32_FILE_ATTRIBUTE_DATA data; - if(!GetFileAttributesEx(path, GetFileExInfoStandard, &data)) - return -1; - - buffer->st_ino = 0; - buffer->st_mode = ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? S_IFDIR : S_IFREG)| - ((data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? S_IREAD : S_IREAD|S_IWRITE); - buffer->st_dev = buffer->st_rdev = 0; - buffer->st_nlink = 1; - buffer->st_uid = 0; - buffer->st_gid = 0; - buffer->st_size = data.nFileSizeLow; - buffer->st_atime = (*(QWORD*)&data.ftLastAccessTime) / 10000000 - 11644473600LL; - buffer->st_mtime = (*(QWORD*)&data.ftLastWriteTime) / 10000000 - 11644473600LL; - buffer->st_ctime = (*(QWORD*)&data.ftCreationTime) / 10000000 - 11644473600LL; - return 0; -} -#endif +/* +** i_system.cpp +** Timers, pre-console output, IWAD selection, and misc system routines. +** +**--------------------------------------------------------------------------- +** Copyright 1998-2009 Randy Heit +** 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. +**--------------------------------------------------------------------------- +** +*/ + +// HEADER FILES ------------------------------------------------------------ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include + +#define USE_WINDOWS_DWORD +#include "hardware.h" +#include "doomerrors.h" +#include + +#include "doomtype.h" +#include "version.h" +#include "doomdef.h" +#include "cmdlib.h" +#include "m_argv.h" +#include "m_misc.h" +#include "i_video.h" +#include "i_sound.h" +#include "i_music.h" +#include "resource.h" +#include "x86.h" +#include "stats.h" + +#include "d_main.h" +#include "d_net.h" +#include "g_game.h" +#include "i_input.h" +#include "i_system.h" +#include "c_dispatch.h" +#include "templates.h" +#include "gameconfigfile.h" +#include "v_font.h" +#include "g_level.h" +#include "doomstat.h" +#include "v_palette.h" +#include "stats.h" +#include "textures/bitmap.h" +#include "textures/textures.h" + +// MACROS ------------------------------------------------------------------ + +#ifdef _MSC_VER +// Turn off "conversion from 'LONG_PTR' to 'LONG', possible loss of data" +// generated by SetClassLongPtr(). +#pragma warning(disable:4244) +#endif + +// TYPES ------------------------------------------------------------------- + +// EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- + +extern void CheckCPUID(CPUInfo *cpu); +extern void LayoutMainWindow(HWND hWnd, HWND pane); + +// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- + +// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- + +static void CalculateCPUSpeed(); +static void I_SelectTimer(); + +static int I_GetTimePolled(bool saveMS); +static int I_WaitForTicPolled(int prevtic); +static void I_FreezeTimePolled(bool frozen); +static int I_GetTimeEventDriven(bool saveMS); +static int I_WaitForTicEvent(int prevtic); +static void I_FreezeTimeEventDriven(bool frozen); +static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2); + +static HCURSOR CreateCompatibleCursor(FTexture *cursorpic); +static HCURSOR CreateAlphaCursor(FTexture *cursorpic); +static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP color_mask); +static void DestroyCustomCursor(); + +// EXTERNAL DATA DECLARATIONS ---------------------------------------------- + +EXTERN_CVAR(String, language); +EXTERN_CVAR (Bool, queryiwad); + +extern HWND Window, ConWindow, GameTitleWindow; +extern HANDLE StdOut; +extern bool FancyStdOut; +extern HINSTANCE g_hInst; +extern FILE *Logfile; +extern bool NativeMouse; +extern bool ConWindowHidden; + +// PUBLIC DATA DEFINITIONS ------------------------------------------------- + +CVAR (String, queryiwad_key, "shift", CVAR_GLOBALCONFIG|CVAR_ARCHIVE); +CVAR (Bool, con_debugoutput, false, 0); + +double PerfToSec, PerfToMillisec; +UINT TimerPeriod; +UINT TimerEventID; +UINT MillisecondsPerTic; +HANDLE NewTicArrived; +uint32 LanguageIDs[4]; + +int (*I_GetTime) (bool saveMS); +int (*I_WaitForTic) (int); +void (*I_FreezeTime) (bool frozen); + +os_t OSPlatform; +bool gameisdead; + +// PRIVATE DATA DEFINITIONS ------------------------------------------------ + +static ticcmd_t emptycmd; +static bool HasExited; + +static DWORD basetime = 0; +// These are for the polled timer. +static DWORD TicStart; +static DWORD TicNext; +static int TicFrozen; + +// These are for the event-driven timer. +static int tics; +static DWORD ted_start, ted_next; + +static WadStuff *WadList; +static int NumWads; +static int DefaultWad; + +static HCURSOR CustomCursor; + +// CODE -------------------------------------------------------------------- + +//========================================================================== +// +// I_Tactile +// +// Doom calls it when you take damage, so presumably it could be converted +// to something compatible with force feedback. +// +//========================================================================== + +void I_Tactile(int on, int off, int total) +{ + // UNUSED. + on = off = total = 0; +} + +//========================================================================== +// +// I_BaseTiccmd +// +// Returns an empty ticcmd. I have no idea why this should be system- +// specific. +// +//========================================================================== + +ticcmd_t *I_BaseTiccmd() +{ + return &emptycmd; +} + +// Stubs that select the timer to use and then call into it ---------------- + +//========================================================================== +// +// I_GetTimeSelect +// +//========================================================================== + +static int I_GetTimeSelect(bool saveMS) +{ + I_SelectTimer(); + return I_GetTime(saveMS); +} + +//========================================================================== +// +// I_WaitForTicSelect +// +//========================================================================== + +static int I_WaitForTicSelect(int prevtic) +{ + I_SelectTimer(); + return I_WaitForTic(prevtic); +} + +//========================================================================== +// +// I_SelectTimer +// +// Tries to create a timer event for efficent CPU use when the FPS is +// capped. Failing that, it sets things up for a polling timer instead. +// +//========================================================================== + +static void I_SelectTimer() +{ + assert(basetime == 0); + + // Use a timer event if possible. + NewTicArrived = CreateEvent(NULL, FALSE, FALSE, NULL); + if (NewTicArrived) + { + UINT delay; + const char *cmdDelay; + + cmdDelay = Args->CheckValue("-timerdelay"); + delay = 0; + if (cmdDelay != 0) + { + delay = atoi(cmdDelay); + } + if (delay == 0) + { + delay = 1000/TICRATE; + } + MillisecondsPerTic = delay; + TimerEventID = timeSetEvent(delay, 0, TimerTicked, 0, TIME_PERIODIC); + } + // Get the current time as the basetime. + basetime = timeGetTime(); + // Set timer functions. + if (TimerEventID != 0) + { + I_GetTime = I_GetTimeEventDriven; + I_WaitForTic = I_WaitForTicEvent; + I_FreezeTime = I_FreezeTimeEventDriven; + } + else + { + I_GetTime = I_GetTimePolled; + I_WaitForTic = I_WaitForTicPolled; + I_FreezeTime = I_FreezeTimePolled; + } +} + +//========================================================================== +// +// I_MSTime +// +// Returns the current time in milliseconds, where 0 is the first call +// to I_GetTime or I_WaitForTic. +// +//========================================================================== + +unsigned int I_MSTime() +{ + assert(basetime != 0); + return timeGetTime() - basetime; +} + +//========================================================================== +// +// I_FPSTime +// +// Returns the current system time in milliseconds. This is used by the FPS +// meter of DFrameBuffer::DrawRateStuff(). Since the screen can display +// before the play simulation is ready to begin, this needs to be +// separate from I_MSTime(). +// +//========================================================================== + +unsigned int I_FPSTime() +{ + return timeGetTime(); +} + +//========================================================================== +// +// I_GetTimePolled +// +// Returns the current time in tics. If saveMS is true, then calls to +// I_GetTimeFrac() will use this tic as 0 and the next tic as 1. +// +//========================================================================== + +static int I_GetTimePolled(bool saveMS) +{ + DWORD tm; + + if (TicFrozen != 0) + { + return TicFrozen; + } + + tm = timeGetTime(); + if (basetime == 0) + { + basetime = tm; + } + if (saveMS) + { + TicStart = tm; + TicNext = (tm * TICRATE / 1000 + 1) * 1000 / TICRATE; + } + + return ((tm-basetime)*TICRATE)/1000; +} + +//========================================================================== +// +// I_WaitForTicPolled +// +// Busy waits until the current tic is greater than prevtic. Time must not +// be frozen. +// +//========================================================================== + +static int I_WaitForTicPolled(int prevtic) +{ + int time; + + assert(TicFrozen == 0); + while ((time = I_GetTimePolled(false)) <= prevtic) + { } + + return time; +} + +//========================================================================== +// +// I_FreezeTimePolled +// +// Freeze/unfreeze the timer. +// +//========================================================================== + +static void I_FreezeTimePolled(bool frozen) +{ + if (frozen) + { + assert(TicFrozen == 0); + TicFrozen = I_GetTimePolled(false); + } + else + { + assert(TicFrozen != 0); + int froze = TicFrozen; + TicFrozen = 0; + int now = I_GetTimePolled(false); + basetime += (now - froze) * 1000 / TICRATE; + } +} + +//========================================================================== +// +// I_GetTimeEventDriven +// +// Returns the current tick counter. This is incremented asynchronously as +// the timer event fires. +// +//========================================================================== + +static int I_GetTimeEventDriven(bool saveMS) +{ + if (saveMS) + { + TicStart = ted_start; + TicNext = ted_next; + } + return tics; +} + +//========================================================================== +// +// I_WaitForTicEvent +// +// Waits on the timer event as long as the current tic is not later than +// prevtic. +// +//========================================================================== + +static int I_WaitForTicEvent(int prevtic) +{ + assert(!TicFrozen); + while (prevtic >= tics) + { + WaitForSingleObject(NewTicArrived, 1000/TICRATE); + } + return tics; +} + +//========================================================================== +// +// I_FreezeTimeEventDriven +// +// Freeze/unfreeze the ticker. +// +//========================================================================== + +static void I_FreezeTimeEventDriven(bool frozen) +{ + TicFrozen = frozen; +} + +//========================================================================== +// +// TimerTicked +// +// Advance the tick count and signal the NewTicArrived event. +// +//========================================================================== + +static void CALLBACK TimerTicked(UINT id, UINT msg, DWORD_PTR user, DWORD_PTR dw1, DWORD_PTR dw2) +{ + if (!TicFrozen) + { + tics++; + } + ted_start = timeGetTime (); + ted_next = ted_start + MillisecondsPerTic; + SetEvent(NewTicArrived); +} + +//========================================================================== +// +// I_GetTimeFrac +// +// Returns the fractional amount of a tic passed since the most recently +// saved tic. +// +//========================================================================== + +fixed_t I_GetTimeFrac(uint32 *ms) +{ + DWORD now = timeGetTime(); + if (ms != NULL) + { + *ms = TicNext; + } + DWORD step = TicNext - TicStart; + if (step == 0) + { + return FRACUNIT; + } + else + { + fixed_t frac = clamp ((now - TicStart)*FRACUNIT/step, 0, FRACUNIT); + return frac; + } +} + +//========================================================================== +// +// I_WaitVBL +// +// I_WaitVBL is never used to actually synchronize to the vertical blank. +// Instead, it's used for delay purposes. Doom used a 70 Hz display mode, +// so that's what we use to determine how long to wait for. +// +//========================================================================== + +void I_WaitVBL(int count) +{ + Sleep(1000 * count / 70); +} + +//========================================================================== +// +// I_DetectOS +// +// Determine which version of Windows the game is running on. +// +//========================================================================== + +void I_DetectOS(void) +{ + OSVERSIONINFOEX info; + const char *osname; + + info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + if (!GetVersionEx((OSVERSIONINFO *)&info)) + { + // Retry with the older OSVERSIONINFO structure. + info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx((OSVERSIONINFO *)&info); + } + + switch (info.dwPlatformId) + { + case VER_PLATFORM_WIN32_WINDOWS: + OSPlatform = os_Win95; + if (info.dwMinorVersion < 10) + { + osname = "95"; + } + else if (info.dwMinorVersion < 90) + { + osname = "98"; + } + else + { + osname = "Me"; + } + break; + + case VER_PLATFORM_WIN32_NT: + OSPlatform = info.dwMajorVersion < 5 ? os_WinNT4 : os_Win2k; + osname = "NT"; + if (info.dwMajorVersion == 5) + { + if (info.dwMinorVersion == 0) + { + osname = "2000"; + } + if (info.dwMinorVersion == 1) + { + osname = "XP"; + } + else if (info.dwMinorVersion == 2) + { + osname = "Server 2003"; + } + } + else if (info.dwMajorVersion == 6) + { + if (info.dwMinorVersion == 0) + { + osname = (info.wProductType == VER_NT_WORKSTATION) ? "Vista" : "Server 2008"; + } + else if (info.dwMinorVersion == 1) + { + osname = (info.wProductType == VER_NT_WORKSTATION) ? "7" : "Server 2008 R2"; + } + else if (info.dwMinorVersion == 2) + { + // Starting with Windows 8.1, you need to specify in your manifest + // the highest version of Windows you support, which will also be the + // highest version of Windows this function returns. + osname = (info.wProductType == VER_NT_WORKSTATION) ? "8" : "Server 2012"; + } + else if (info.dwMinorVersion == 3) + { + osname = (info.wProductType == VER_NT_WORKSTATION) ? "8.1" : "Server 2012 R2"; + } + else if (info.dwMinorVersion == 4) + { + osname = (info.wProductType == VER_NT_WORKSTATION) ? "10 (or higher)" : "Server 10 (or higher)"; + } + } + break; + + default: + OSPlatform = os_unknown; + osname = "Unknown OS"; + break; + } + + if (OSPlatform == os_Win95) + { + Printf ("OS: Windows %s %lu.%lu.%lu %s\n", + osname, + info.dwMajorVersion, info.dwMinorVersion, + info.dwBuildNumber & 0xffff, info.szCSDVersion); + } + else + { + Printf ("OS: Windows %s (NT %lu.%lu) Build %lu\n %s\n", + osname, + info.dwMajorVersion, info.dwMinorVersion, + info.dwBuildNumber, info.szCSDVersion); + } + + if (OSPlatform == os_unknown) + { + Printf ("(Assuming Windows 2000)\n"); + OSPlatform = os_Win2k; + } +} + +//========================================================================== +// +// SubsetLanguageIDs +// +// Helper function for SetLanguageIDs. +// +//========================================================================== + +static void SubsetLanguageIDs(LCID id, LCTYPE type, int idx) +{ + char buf[8]; + LCID langid; + char *idp; + + if (!GetLocaleInfo(id, type, buf, 8)) + return; + langid = MAKELCID(strtoul(buf, NULL, 16), SORT_DEFAULT); + if (!GetLocaleInfo(langid, LOCALE_SABBREVLANGNAME, buf, 8)) + return; + idp = (char *)(&LanguageIDs[idx]); + memset (idp, 0, 4); + idp[0] = tolower(buf[0]); + idp[1] = tolower(buf[1]); + idp[2] = tolower(buf[2]); + idp[3] = 0; +} + +//========================================================================== +// +// SetLanguageIDs +// +//========================================================================== + +void SetLanguageIDs() +{ + size_t langlen = strlen(language); + + if (langlen < 2 || langlen > 3) + { + memset(LanguageIDs, 0, sizeof(LanguageIDs)); + SubsetLanguageIDs(LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, 0); + SubsetLanguageIDs(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 1); + SubsetLanguageIDs(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, 2); + SubsetLanguageIDs(LOCALE_SYSTEM_DEFAULT, LOCALE_IDEFAULTLANGUAGE, 3); + } + else + { + DWORD lang = 0; + + ((BYTE *)&lang)[0] = (language)[0]; + ((BYTE *)&lang)[1] = (language)[1]; + ((BYTE *)&lang)[2] = (language)[2]; + LanguageIDs[0] = lang; + LanguageIDs[1] = lang; + LanguageIDs[2] = lang; + LanguageIDs[3] = lang; + } +} + +//========================================================================== +// +// CalculateCPUSpeed +// +// Make a decent guess at how much time elapses between TSC steps. This can +// vary over runtime depending on power management settings, so should not +// be used anywhere that truely accurate timing actually matters. +// +//========================================================================== + +void CalculateCPUSpeed() +{ + LARGE_INTEGER freq; + + QueryPerformanceFrequency (&freq); + + if (freq.QuadPart != 0 && CPU.bRDTSC) + { + LARGE_INTEGER count1, count2; + cycle_t ClockCalibration; + DWORD min_diff; + + ClockCalibration.Reset(); + + // Count cycles for at least 55 milliseconds. + // The performance counter may be very low resolution compared to CPU + // speeds today, so the longer we count, the more accurate our estimate. + // On the other hand, we don't want to count too long, because we don't + // want the user to notice us spend time here, since most users will + // probably never use the performance statistics. + min_diff = freq.LowPart * 11 / 200; + + // Minimize the chance of task switching during the testing by going very + // high priority. This is another reason to avoid timing for too long. + SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS); + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); + + // Make sure we start timing on a counter boundary. + QueryPerformanceCounter(&count1); + do { QueryPerformanceCounter(&count2); } while (count1.QuadPart == count2.QuadPart); + + // Do the timing loop. + ClockCalibration.Clock(); + do { QueryPerformanceCounter(&count1); } while ((count1.QuadPart - count2.QuadPart) < min_diff); + ClockCalibration.Unclock(); + + SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); + + PerfToSec = double(count1.QuadPart - count2.QuadPart) / (double(ClockCalibration.GetRawCounter()) * freq.QuadPart); + PerfToMillisec = PerfToSec * 1000.0; + } + + Printf ("CPU Speed: %.0f MHz\n", 0.001 / PerfToMillisec); +} + +//========================================================================== +// +// I_Init +// +//========================================================================== + +void I_Init() +{ + CheckCPUID(&CPU); + CalculateCPUSpeed(); + DumpCPUInfo(&CPU); + + I_GetTime = I_GetTimeSelect; + I_WaitForTic = I_WaitForTicSelect; + + atterm (I_ShutdownSound); + I_InitSound (); +} + +//========================================================================== +// +// I_Quit +// +//========================================================================== + +void I_Quit() +{ + HasExited = true; /* Prevent infinitely recursive exits -- killough */ + + if (TimerEventID != 0) + { + timeKillEvent(TimerEventID); + } + if (NewTicArrived != NULL) + { + CloseHandle(NewTicArrived); + } + timeEndPeriod(TimerPeriod); + if (demorecording) + { + G_CheckDemoStatus(); + } + + C_DeinitConsole(); +} + + +//========================================================================== +// +// I_FatalError +// +// Throw an error that will end the game. +// +//========================================================================== + +void STACK_ARGS I_FatalError(const char *error, ...) +{ + static BOOL alreadyThrown = false; + gameisdead = true; + + if (!alreadyThrown) // ignore all but the first message -- killough + { + alreadyThrown = true; + char errortext[MAX_ERRORTEXT]; + va_list argptr; + va_start(argptr, error); + myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr); + va_end(argptr); + + // Record error to log (if logging) + if (Logfile) + { + fprintf(Logfile, "\n**** DIED WITH FATAL ERROR:\n%s\n", errortext); + fflush(Logfile); + } + + throw CFatalError(errortext); + } + + if (!HasExited) // If it hasn't exited yet, exit now -- killough + { + HasExited = 1; // Prevent infinitely recursive exits -- killough + exit(-1); + } +} + +//========================================================================== +// +// I_Error +// +// Throw an error that will send us to the console if we are far enough +// along in the startup process. +// +//========================================================================== + +void STACK_ARGS I_Error(const char *error, ...) +{ + va_list argptr; + char errortext[MAX_ERRORTEXT]; + + va_start(argptr, error); + myvsnprintf(errortext, MAX_ERRORTEXT, error, argptr); + va_end(argptr); + + throw CRecoverableError(errortext); +} + +//========================================================================== +// +// ToEditControl +// +// Converts string to Unicode and inserts it into the control. +// +//========================================================================== + +void ToEditControl(HWND edit, const char *buf, wchar_t *wbuf, int bpos) +{ + // Let's just do this ourself. It's not hard, and we can compensate for + // special console characters at the same time. +#if 0 + MultiByteToWideChar(1252 /* Western */, 0, buf, bpos, wbuf, countof(wbuf)); + wbuf[bpos] = 0; +#else + static wchar_t notlatin1[32] = // code points 0x80-0x9F + { + 0x20AC, // Euro sign + 0x0081, // Undefined + 0x201A, // Single low-9 quotation mark + 0x0192, // Latin small letter f with hook + 0x201E, // Double low-9 quotation mark + 0x2026, // Horizontal ellipsis + 0x2020, // Dagger + 0x2021, // Double dagger + 0x02C6, // Modifier letter circumflex accent + 0x2030, // Per mille sign + 0x0160, // Latin capital letter S with caron + 0x2039, // Single left-pointing angle quotation mark + 0x0152, // Latin capital ligature OE + 0x008D, // Undefined + 0x017D, // Latin capital letter Z with caron + 0x008F, // Undefined + 0x0090, // Undefined + 0x2018, // Left single quotation mark + 0x2019, // Right single quotation mark + 0x201C, // Left double quotation mark + 0x201D, // Right double quotation mark + 0x2022, // Bullet + 0x2013, // En dash + 0x2014, // Em dash + 0x02DC, // Small tilde + 0x2122, // Trade mark sign + 0x0161, // Latin small letter s with caron + 0x203A, // Single right-pointing angle quotation mark + 0x0153, // Latin small ligature oe + 0x009D, // Undefined + 0x017E, // Latin small letter z with caron + 0x0178 // Latin capital letter Y with diaeresis + }; + for (int i = 0; i <= bpos; ++i) + { + wchar_t code = (BYTE)buf[i]; + if (code >= 0x1D && code <= 0x1F) + { // The bar characters, most commonly used to indicate map changes + code = 0x2550; // Box Drawings Double Horizontal + } + else if (code >= 0x80 && code <= 0x9F) + { + code = notlatin1[code - 0x80]; + } + wbuf[i] = code; + } +#endif + SendMessageW(edit, EM_REPLACESEL, FALSE, (LPARAM)wbuf); +} + +//========================================================================== +// +// I_PrintStr +// +// Send output to the list box shown during startup (and hidden during +// gameplay). +// +//========================================================================== + +static void DoPrintStr(const char *cp, HWND edit, HANDLE StdOut) +{ + if (edit == NULL && StdOut == NULL) + return; + + char buf[256]; + wchar_t wbuf[countof(buf)]; + int bpos = 0; + CHARRANGE selection; + CHARRANGE endselection; + LONG lines_before = 0, lines_after; + CHARFORMAT format; + + if (edit != NULL) + { + // Store the current selection and set it to the end so we can append text. + SendMessage(edit, EM_EXGETSEL, 0, (LPARAM)&selection); + endselection.cpMax = endselection.cpMin = GetWindowTextLength(edit); + SendMessage(edit, EM_EXSETSEL, 0, (LPARAM)&endselection); + + // GetWindowTextLength and EM_EXSETSEL can disagree on where the end of + // the text is. Find out what EM_EXSETSEL thought it was and use that later. + SendMessage(edit, EM_EXGETSEL, 0, (LPARAM)&endselection); + + // Remember how many lines there were before we added text. + lines_before = (LONG)SendMessage(edit, EM_GETLINECOUNT, 0, 0); + } + + while (*cp != 0) + { + // 28 is the escape code for a color change. + if ((*cp == 28 && bpos != 0) || bpos == 255) + { + buf[bpos] = 0; + if (edit != NULL) + { + ToEditControl(edit, buf, wbuf, bpos); + } + if (StdOut != NULL) + { + DWORD bytes_written; + WriteFile(StdOut, buf, bpos, &bytes_written, NULL); + } + bpos = 0; + } + if (*cp != 28) + { + buf[bpos++] = *cp++; + } + else + { + const BYTE *color_id = (const BYTE *)cp + 1; + EColorRange range = V_ParseFontColor(color_id, CR_UNTRANSLATED, CR_YELLOW); + cp = (const char *)color_id; + + if (range != CR_UNDEFINED) + { + // Change the color of future text added to the control. + PalEntry color = V_LogColorFromColorRange(range); + if (StdOut != NULL && FancyStdOut) + { + // Unfortunately, we are pretty limited here: There are only + // eight basic colors, and each comes in a dark and a bright + // variety. + float h, s, v, r, g, b; + WORD attrib = 0; + + RGBtoHSV(color.r / 255.f, color.g / 255.f, color.b / 255.f, &h, &s, &v); + if (s != 0) + { // color + HSVtoRGB(&r, &g, &b, h, 1, 1); + if (r == 1) attrib = FOREGROUND_RED; + if (g == 1) attrib |= FOREGROUND_GREEN; + if (b == 1) attrib |= FOREGROUND_BLUE; + if (v > 0.6) attrib |= FOREGROUND_INTENSITY; + } + else + { // gray + if (v < 0.33) attrib = FOREGROUND_INTENSITY; + else if (v < 0.90) attrib = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; + else attrib = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY; + } + SetConsoleTextAttribute(StdOut, attrib); + } + if (edit != NULL) + { + // GDI uses BGR colors, but color is RGB, so swap the R and the B. + swapvalues(color.r, color.b); + // Change the color. + format.cbSize = sizeof(format); + format.dwMask = CFM_COLOR; + format.dwEffects = 0; + format.crTextColor = color; + SendMessage(edit, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&format); + } + } + } + } + if (bpos != 0) + { + buf[bpos] = 0; + if (edit != NULL) + { + ToEditControl(edit, buf, wbuf, bpos); + } + if (StdOut != NULL) + { + DWORD bytes_written; + WriteFile(StdOut, buf, bpos, &bytes_written, NULL); + } + } + + if (edit != NULL) + { + // If the old selection was at the end of the text, keep it at the end and + // scroll. Don't scroll if the selection is anywhere else. + if (selection.cpMin == endselection.cpMin && selection.cpMax == endselection.cpMax) + { + selection.cpMax = selection.cpMin = GetWindowTextLength (edit); + lines_after = (LONG)SendMessage(edit, EM_GETLINECOUNT, 0, 0); + if (lines_after > lines_before) + { + SendMessage(edit, EM_LINESCROLL, 0, lines_after - lines_before); + } + } + // Restore the previous selection. + SendMessage(edit, EM_EXSETSEL, 0, (LPARAM)&selection); + // Give the edit control a chance to redraw itself. + I_GetEvent(); + } + if (StdOut != NULL && FancyStdOut) + { // Set text back to gray, in case it was changed. + SetConsoleTextAttribute(StdOut, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + } +} + +static TArray bufferedConsoleStuff; + +void I_PrintStr(const char *cp) +{ + if (con_debugoutput) + { + // Strip out any color escape sequences before writing to debug output + char * copy = new char[strlen(cp)+1]; + const char * srcp = cp; + char * dstp = copy; + + while (*srcp != 0) + { + if (*srcp!=0x1c && *srcp!=0x1d && *srcp!=0x1e && *srcp!=0x1f) + { + *dstp++=*srcp++; + } + else + { + if (srcp[1]!=0) srcp+=2; + else break; + } + } + *dstp=0; + + OutputDebugStringA(copy); + delete [] copy; + } + + if (ConWindowHidden) + { + bufferedConsoleStuff.Push(cp); + DoPrintStr(cp, NULL, StdOut); + } + else + { + DoPrintStr(cp, ConWindow, StdOut); + } +} + +void I_FlushBufferedConsoleStuff() +{ + for (unsigned i = 0; i < bufferedConsoleStuff.Size(); i++) + { + DoPrintStr(bufferedConsoleStuff[i], ConWindow, NULL); + } + bufferedConsoleStuff.Clear(); +} + +//========================================================================== +// +// SetQueryIWAD +// +// The user had the "Don't ask again" box checked when they closed the +// IWAD selection dialog. +// +//========================================================================== + +static void SetQueryIWad(HWND dialog) +{ + HWND checkbox = GetDlgItem(dialog, IDC_DONTASKIWAD); + int state = (int)SendMessage(checkbox, BM_GETCHECK, 0, 0); + bool query = (state != BST_CHECKED); + + if (!query && queryiwad) + { + MessageBox(dialog, + "You have chosen not to show this dialog box in the future.\n" + "If you wish to see it again, hold down SHIFT while starting " GAMENAME ".", + "Don't ask me this again", + MB_OK | MB_ICONINFORMATION); + } + + queryiwad = query; +} + +//========================================================================== +// +// IWADBoxCallback +// +// Dialog proc for the IWAD selector. +// +//========================================================================== + +BOOL CALLBACK IWADBoxCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + HWND ctrl; + int i; + + switch (message) + { + case WM_INITDIALOG: + // Add our program name to the window title + { + TCHAR label[256]; + FString newlabel; + + GetWindowText(hDlg, label, countof(label)); + newlabel.Format(GAMESIG " %s: %s", GetVersionString(), label); + SetWindowText(hDlg, newlabel.GetChars()); + } + // Populate the list with all the IWADs found + ctrl = GetDlgItem(hDlg, IDC_IWADLIST); + for (i = 0; i < NumWads; i++) + { + FString work; + const char *filepart = strrchr(WadList[i].Path, '/'); + if (filepart == NULL) + filepart = WadList[i].Path; + else + filepart++; + work.Format("%s (%s)", WadList[i].Name.GetChars(), filepart); + SendMessage(ctrl, LB_ADDSTRING, 0, (LPARAM)work.GetChars()); + SendMessage(ctrl, LB_SETITEMDATA, i, (LPARAM)i); + } + SendMessage(ctrl, LB_SETCURSEL, DefaultWad, 0); + SetFocus(ctrl); + // Set the state of the "Don't ask me again" checkbox + ctrl = GetDlgItem(hDlg, IDC_DONTASKIWAD); + SendMessage(ctrl, BM_SETCHECK, queryiwad ? BST_UNCHECKED : BST_CHECKED, 0); + // Make sure the dialog is in front. If SHIFT was pressed to force it visible, + // then the other window will normally be on top. + SetForegroundWindow(hDlg); + break; + + case WM_COMMAND: + if (LOWORD(wParam) == IDCANCEL) + { + EndDialog (hDlg, -1); + } + else if (LOWORD(wParam) == IDOK || + (LOWORD(wParam) == IDC_IWADLIST && HIWORD(wParam) == LBN_DBLCLK)) + { + SetQueryIWad(hDlg); + ctrl = GetDlgItem (hDlg, IDC_IWADLIST); + EndDialog(hDlg, SendMessage (ctrl, LB_GETCURSEL, 0, 0)); + } + break; + } + return FALSE; +} + +//========================================================================== +// +// I_PickIWad +// +// Open a dialog to pick the IWAD, if there is more than one found. +// +//========================================================================== + +int I_PickIWad(WadStuff *wads, int numwads, bool showwin, int defaultiwad) +{ + int vkey; + + if (stricmp(queryiwad_key, "shift") == 0) + { + vkey = VK_SHIFT; + } + else if (stricmp(queryiwad_key, "control") == 0 || stricmp (queryiwad_key, "ctrl") == 0) + { + vkey = VK_CONTROL; + } + else + { + vkey = 0; + } + if (showwin || (vkey != 0 && GetAsyncKeyState(vkey))) + { + WadList = wads; + NumWads = numwads; + DefaultWad = defaultiwad; + + return (int)DialogBox(g_hInst, MAKEINTRESOURCE(IDD_IWADDIALOG), + (HWND)Window, (DLGPROC)IWADBoxCallback); + } + return defaultiwad; +} + +//========================================================================== +// +// I_SetCursor +// +// Returns true if the cursor was successfully changed. +// +//========================================================================== + +bool I_SetCursor(FTexture *cursorpic) +{ + HCURSOR cursor; + + if (cursorpic != NULL && cursorpic->UseType != FTexture::TEX_Null && + (screen == NULL || !screen->Is8BitMode())) + { + // Must be no larger than 32x32. + if (cursorpic->GetWidth() > 32 || cursorpic->GetHeight() > 32) + { + return false; + } + + cursor = CreateAlphaCursor(cursorpic); + if (cursor == NULL) + { + cursor = CreateCompatibleCursor(cursorpic); + } + if (cursor == NULL) + { + return false; + } + // Replace the existing cursor with the new one. + DestroyCustomCursor(); + CustomCursor = cursor; + atterm(DestroyCustomCursor); + } + else + { + DestroyCustomCursor(); + cursor = LoadCursor(NULL, IDC_ARROW); + } + SetClassLongPtr(Window, GCLP_HCURSOR, (LONG_PTR)cursor); + if (NativeMouse) + { + POINT pt; + RECT client; + + // If the mouse pointer is within the window's client rect, set it now. + if (GetCursorPos(&pt) && GetClientRect(Window, &client) && + ClientToScreen(Window, (LPPOINT)&client.left) && + ClientToScreen(Window, (LPPOINT)&client.right)) + { + if (pt.x >= client.left && pt.x < client.right && + pt.y >= client.top && pt.y < client.bottom) + { + SetCursor(cursor); + } + } + } + return true; +} + +//========================================================================== +// +// CreateCompatibleCursor +// +// Creates a cursor with a 1-bit alpha channel. +// +//========================================================================== + +static HCURSOR CreateCompatibleCursor(FTexture *cursorpic) +{ + int picwidth = cursorpic->GetWidth(); + int picheight = cursorpic->GetHeight(); + + // Create bitmap masks for the cursor from the texture. + HDC dc = GetDC(NULL); + if (dc == NULL) + { + return false; + } + HDC and_mask_dc = CreateCompatibleDC(dc); + HDC xor_mask_dc = CreateCompatibleDC(dc); + HBITMAP and_mask = CreateCompatibleBitmap(dc, 32, 32); + HBITMAP xor_mask = CreateCompatibleBitmap(dc, 32, 32); + ReleaseDC(NULL, dc); + + SelectObject(and_mask_dc, and_mask); + SelectObject(xor_mask_dc, xor_mask); + + // Initialize with an invisible cursor. + SelectObject(and_mask_dc, GetStockObject(WHITE_PEN)); + SelectObject(and_mask_dc, GetStockObject(WHITE_BRUSH)); + Rectangle(and_mask_dc, 0, 0, 32, 32); + SelectObject(xor_mask_dc, GetStockObject(BLACK_PEN)); + SelectObject(xor_mask_dc, GetStockObject(BLACK_BRUSH)); + Rectangle(xor_mask_dc, 0, 0, 32, 32); + + FBitmap bmp; + const BYTE *pixels; + + bmp.Create(picwidth, picheight); + cursorpic->CopyTrueColorPixels(&bmp, 0, 0); + pixels = bmp.GetPixels(); + + // Copy color data from the source texture to the cursor bitmaps. + for (int y = 0; y < picheight; ++y) + { + for (int x = 0; x < picwidth; ++x) + { + const BYTE *bgra = &pixels[x*4 + y*bmp.GetPitch()]; + if (bgra[3] != 0) + { + SetPixelV(and_mask_dc, x, y, RGB(0,0,0)); + SetPixelV(xor_mask_dc, x, y, RGB(bgra[2], bgra[1], bgra[0])); + } + } + } + DeleteDC(and_mask_dc); + DeleteDC(xor_mask_dc); + + // Create the cursor from the bitmaps. + return CreateBitmapCursor(cursorpic->LeftOffset, cursorpic->TopOffset, and_mask, xor_mask); +} + +//========================================================================== +// +// CreateAlphaCursor +// +// Creates a cursor with a full alpha channel. +// +//========================================================================== + +static HCURSOR CreateAlphaCursor(FTexture *cursorpic) +{ + HDC dc; + BITMAPV5HEADER bi; + HBITMAP color, mono; + void *bits; + + memset(&bi, 0, sizeof(bi)); + bi.bV5Size = sizeof(bi); + bi.bV5Width = 32; + bi.bV5Height = 32; + bi.bV5Planes = 1; + bi.bV5BitCount = 32; + bi.bV5Compression = BI_BITFIELDS; + bi.bV5RedMask = 0x00FF0000; + bi.bV5GreenMask = 0x0000FF00; + bi.bV5BlueMask = 0x000000FF; + bi.bV5AlphaMask = 0xFF000000; + + dc = GetDC(NULL); + if (dc == NULL) + { + return NULL; + } + + // Create the DIB section with an alpha channel. + color = CreateDIBSection(dc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, &bits, NULL, 0); + ReleaseDC(NULL, dc); + + if (color == NULL) + { + return NULL; + } + + // Create an empty mask bitmap, since CreateIconIndirect requires this. + mono = CreateBitmap(32, 32, 1, 1, NULL); + if (mono == NULL) + { + DeleteObject(color); + return NULL; + } + + // Copy cursor to the color bitmap. Note that GDI bitmaps are upside down compared + // to normal conventions, so we create the FBitmap pointing at the last row and use + // a negative pitch so that CopyTrueColorPixels will use GDI's orientation. + FBitmap bmp((BYTE *)bits + 31*32*4, -32*4, 32, 32); + cursorpic->CopyTrueColorPixels(&bmp, 0, 0); + + return CreateBitmapCursor(cursorpic->LeftOffset, cursorpic->TopOffset, mono, color); +} + +//========================================================================== +// +// CreateBitmapCursor +// +// Create the cursor from the bitmaps. Deletes the bitmaps before returning. +// +//========================================================================== + +static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP color_mask) +{ + ICONINFO iconinfo = + { + FALSE, // fIcon + xhot, // xHotspot + yhot, // yHotspot + and_mask, // hbmMask + color_mask // hbmColor + }; + HCURSOR cursor = CreateIconIndirect(&iconinfo); + + // Delete the bitmaps. + DeleteObject(and_mask); + DeleteObject(color_mask); + + return cursor; +} + +//========================================================================== +// +// DestroyCustomCursor +// +//========================================================================== + +static void DestroyCustomCursor() +{ + if (CustomCursor != NULL) + { + DestroyCursor(CustomCursor); + CustomCursor = NULL; + } +} + +//========================================================================== +// +// I_WriteIniFailed +// +// Display a message when the config failed to save. +// +//========================================================================== + +bool I_WriteIniFailed() +{ + char *lpMsgBuf; + FString errortext; + + FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPSTR)&lpMsgBuf, + 0, + NULL + ); + errortext.Format ("The config file %s could not be written:\n%s", GameConfig->GetPathName(), lpMsgBuf); + LocalFree (lpMsgBuf); + return MessageBox(Window, errortext.GetChars(), GAMENAME " configuration not saved", MB_ICONEXCLAMATION | MB_RETRYCANCEL) == IDRETRY; +} + +//========================================================================== +// +// I_FindFirst +// +// Start a pattern matching sequence. +// +//========================================================================== + +void *I_FindFirst(const char *filespec, findstate_t *fileinfo) +{ + return FindFirstFileA(filespec, (LPWIN32_FIND_DATAA)fileinfo); +} + +//========================================================================== +// +// I_FindNext +// +// Return the next file in a pattern matching sequence. +// +//========================================================================== + +int I_FindNext(void *handle, findstate_t *fileinfo) +{ + return !FindNextFileA((HANDLE)handle, (LPWIN32_FIND_DATAA)fileinfo); +} + +//========================================================================== +// +// I_FindClose +// +// Finish a pattern matching sequence. +// +//========================================================================== + +int I_FindClose(void *handle) +{ + return FindClose((HANDLE)handle); +} + +//========================================================================== +// +// QueryPathKey +// +// Returns the value of a registry key into the output variable value. +// +//========================================================================== + +static bool QueryPathKey(HKEY key, const char *keypath, const char *valname, FString &value) +{ + HKEY pathkey; + DWORD pathtype; + DWORD pathlen; + LONG res; + + if(ERROR_SUCCESS == RegOpenKeyEx(key, keypath, 0, KEY_QUERY_VALUE, &pathkey)) + { + if (ERROR_SUCCESS == RegQueryValueEx(pathkey, valname, 0, &pathtype, NULL, &pathlen) && + pathtype == REG_SZ && pathlen != 0) + { + // Don't include terminating null in count + char *chars = value.LockNewBuffer(pathlen - 1); + res = RegQueryValueEx(pathkey, valname, 0, NULL, (LPBYTE)chars, &pathlen); + value.UnlockBuffer(); + if (res != ERROR_SUCCESS) + { + value = ""; + } + } + RegCloseKey(pathkey); + } + return value.IsNotEmpty(); +} + +//========================================================================== +// +// I_GetGogPaths +// +// Check the registry for GOG installation paths, so we can search for IWADs +// that were bought from GOG.com. This is a bit different from the Steam +// version because each game has its own independent installation path, no +// such thing as /SteamApps/common/. +// +//========================================================================== + +TArray I_GetGogPaths() +{ + TArray result; + FString path; + FString gamepath; + +#ifdef _WIN64 + FString gogregistrypath = "Software\\Wow6432Node\\GOG.com\\Games"; +#else + // If a 32-bit ZDoom runs on a 64-bit Windows, this will be transparently and + // automatically redirected to the Wow6432Node address instead, so this address + // should be safe to use in all cases. + FString gogregistrypath = "Software\\GOG.com\\Games"; +#endif + + // Look for Ultimate Doom + gamepath = gogregistrypath + "\\1435827232"; + if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) + { + result.Push(path); // directly in install folder + } + + // Look for Doom II + gamepath = gogregistrypath + "\\1435848814"; + if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) + { + result.Push(path + "/doom2"); // in a subdirectory + // If direct support for the Master Levels is ever added, they are in path + /master/wads + } + + // Look for Final Doom + gamepath = gogregistrypath + "\\1435848742"; + if (QueryPathKey(HKEY_LOCAL_MACHINE, gamepath.GetChars(), "Path", path)) + { + // in subdirectories + result.Push(path + "/TNT"); + result.Push(path + "/Plutonia"); + } + + return result; +} + +//========================================================================== +// +// I_GetSteamPath +// +// Check the registry for the path to Steam, so that we can search for +// IWADs that were bought with Steam. +// +//========================================================================== + +TArray I_GetSteamPath() +{ + TArray result; + static const char *const steam_dirs[] = + { + "doom 2/base", + "final doom/base", + "heretic shadow of the serpent riders/base", + "hexen/base", + "hexen deathkings of the dark citadel/base", + "ultimate doom/base", + "DOOM 3 BFG Edition/base/wads", + "Strife" + }; + + FString path; + + if (!QueryPathKey(HKEY_CURRENT_USER, "Software\\Valve\\Steam", "SteamPath", path)) + { + if (!QueryPathKey(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", "InstallPath", path)) + return result; + } + path += "/SteamApps/common/"; + + for(unsigned int i = 0; i < countof(steam_dirs); ++i) + { + result.Push(path + steam_dirs[i]); + } + + return result; +} + +//========================================================================== +// +// I_MakeRNGSeed +// +// Returns a 32-bit random seed, preferably one with lots of entropy. +// +//========================================================================== + +unsigned int I_MakeRNGSeed() +{ + unsigned int seed; + + // If RtlGenRandom is available, use that to avoid increasing the + // working set by pulling in all of the crytographic API. + HMODULE advapi = GetModuleHandle("advapi32.dll"); + if (advapi != NULL) + { + BOOLEAN (APIENTRY *RtlGenRandom)(void *, ULONG) = + (BOOLEAN (APIENTRY *)(void *, ULONG))GetProcAddress(advapi, "SystemFunction036"); + if (RtlGenRandom != NULL) + { + if (RtlGenRandom(&seed, sizeof(seed))) + { + return seed; + } + } + } + + // Use the full crytographic API to produce a seed. If that fails, + // time() is used as a fallback. + HCRYPTPROV prov; + + if (!CryptAcquireContext(&prov, NULL, MS_DEF_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) + { + return (unsigned int)time(NULL); + } + if (!CryptGenRandom(prov, sizeof(seed), (BYTE *)&seed)) + { + seed = (unsigned int)time(NULL); + } + CryptReleaseContext(prov, 0); + return seed; +} + +//========================================================================== +// +// I_GetLongPathName +// +// Returns the long version of the path, or the original if there isn't +// anything worth changing. +// +//========================================================================== + +FString I_GetLongPathName(FString shortpath) +{ + static TOptWin32Proc + GetLongPathNameA("kernel32.dll", "GetLongPathNameA"); + + // Doesn't exist on NT4 + if (GetLongPathName == NULL) + return shortpath; + + DWORD buffsize = GetLongPathNameA.Call(shortpath.GetChars(), NULL, 0); + if (buffsize == 0) + { // nothing to change (it doesn't exist, maybe?) + return shortpath; + } + TCHAR *buff = new TCHAR[buffsize]; + DWORD buffsize2 = GetLongPathNameA.Call(shortpath.GetChars(), buff, buffsize); + if (buffsize2 >= buffsize) + { // Failure! Just return the short path + delete[] buff; + return shortpath; + } + FString longpath(buff, buffsize2); + delete[] buff; + return longpath; +} + +#if _MSC_VER == 1900 && defined(_USING_V110_SDK71_) +//========================================================================== +// +// VS14Stat +// +// Work around an issue where stat doesn't work with v140_xp. This was +// supposedly fixed, but as of Update 1 continues to not function on XP. +// +//========================================================================== + +#include + +int VS14Stat(const char *path, struct _stat64i32 *buffer) +{ + WIN32_FILE_ATTRIBUTE_DATA data; + if(!GetFileAttributesEx(path, GetFileExInfoStandard, &data)) + return -1; + + buffer->st_ino = 0; + buffer->st_mode = ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? S_IFDIR : S_IFREG)| + ((data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? S_IREAD : S_IREAD|S_IWRITE); + buffer->st_dev = buffer->st_rdev = 0; + buffer->st_nlink = 1; + buffer->st_uid = 0; + buffer->st_gid = 0; + buffer->st_size = data.nFileSizeLow; + buffer->st_atime = (*(QWORD*)&data.ftLastAccessTime) / 10000000 - 11644473600LL; + buffer->st_mtime = (*(QWORD*)&data.ftLastWriteTime) / 10000000 - 11644473600LL; + buffer->st_ctime = (*(QWORD*)&data.ftCreationTime) / 10000000 - 11644473600LL; + return 0; +} +#endif diff --git a/src/win32/wglext.h b/src/win32/wglext.h new file mode 100644 index 000000000..daba41091 --- /dev/null +++ b/src/win32/wglext.h @@ -0,0 +1,840 @@ +#ifndef __wglext_h_ +#define __wglext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013-2014 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision: 27684 $ on $Date: 2014-08-11 01:21:35 -0700 (Mon, 11 Aug 2014) $ +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#define WGL_WGLEXT_VERSION 20140810 + +/* Generated C header for: + * API: wgl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: wgl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef WGL_ARB_buffer_region +#define WGL_ARB_buffer_region 1 +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 +typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); +typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); +typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); +typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#ifdef WGL_WGLEXT_PROTOTYPES +HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); +VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); +BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); +BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#endif +#endif /* WGL_ARB_buffer_region */ + +#ifndef WGL_ARB_context_flush_control +#define WGL_ARB_context_flush_control 1 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#endif /* WGL_ARB_context_flush_control */ + +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); +#ifdef WGL_WGLEXT_PROTOTYPES +HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); +#endif +#endif /* WGL_ARB_create_context */ + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile 1 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#endif /* WGL_ARB_create_context_profile */ + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness 1 +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif /* WGL_ARB_create_context_robustness */ + +#ifndef WGL_ARB_extensions_string +#define WGL_ARB_extensions_string 1 +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +#ifdef WGL_WGLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringARB (HDC hdc); +#endif +#endif /* WGL_ARB_extensions_string */ + +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif /* WGL_ARB_framebuffer_sRGB */ + +#ifndef WGL_ARB_make_current_read +#define WGL_ARB_make_current_read 1 +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCARB (void); +#endif +#endif /* WGL_ARB_make_current_read */ + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif /* WGL_ARB_multisample */ + +#ifndef WGL_ARB_pbuffer +#define WGL_ARB_pbuffer 1 +DECLARE_HANDLE(HPBUFFERARB); +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 +typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); +int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); +BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_ARB_pbuffer */ + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif +#endif /* WGL_ARB_pixel_format */ + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif /* WGL_ARB_pixel_format_float */ + +#ifndef WGL_ARB_render_texture +#define WGL_ARB_render_texture 1 +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 +typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); +#endif +#endif /* WGL_ARB_render_texture */ + +#ifndef WGL_ARB_robustness_application_isolation +#define WGL_ARB_robustness_application_isolation 1 +#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 +#endif /* WGL_ARB_robustness_application_isolation */ + +#ifndef WGL_ARB_robustness_share_group_isolation +#define WGL_ARB_robustness_share_group_isolation 1 +#endif /* WGL_ARB_robustness_share_group_isolation */ + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 +#endif /* WGL_3DFX_multisample */ + +#ifndef WGL_3DL_stereo_control +#define WGL_3DL_stereo_control 1 +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 +typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); +#endif +#endif /* WGL_3DL_stereo_control */ + +#ifndef WGL_AMD_gpu_association +#define WGL_AMD_gpu_association 1 +#define WGL_GPU_VENDOR_AMD 0x1F00 +#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 +#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define WGL_GPU_RAM_AMD 0x21A3 +#define WGL_GPU_CLOCK_AMD 0x21A4 +#define WGL_GPU_NUM_PIPES_AMD 0x21A5 +#define WGL_GPU_NUM_SIMD_AMD 0x21A6 +#define WGL_GPU_NUM_RB_AMD 0x21A7 +#define WGL_GPU_NUM_SPI_AMD 0x21A8 +typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); +typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); +typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); +typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); +typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef WGL_WGLEXT_PROTOTYPES +UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); +INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); +UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); +HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); +HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); +BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); +BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); +HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); +VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* WGL_AMD_gpu_association */ + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#endif /* WGL_ATI_pixel_format_float */ + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_EXT_create_context_es2_profile 1 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es2_profile */ + +#ifndef WGL_EXT_create_context_es_profile +#define WGL_EXT_create_context_es_profile 1 +#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es_profile */ + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 +#define WGL_DEPTH_FLOAT_EXT 0x2040 +#endif /* WGL_EXT_depth_float */ + +#ifndef WGL_EXT_display_color_table +#define WGL_EXT_display_color_table 1 +typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); +typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +#ifdef WGL_WGLEXT_PROTOTYPES +GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); +GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); +GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); +VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); +#endif +#endif /* WGL_EXT_display_color_table */ + +#ifndef WGL_EXT_extensions_string +#define WGL_EXT_extensions_string 1 +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringEXT (void); +#endif +#endif /* WGL_EXT_extensions_string */ + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 +#endif /* WGL_EXT_framebuffer_sRGB */ + +#ifndef WGL_EXT_make_current_read +#define WGL_EXT_make_current_read 1 +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCEXT (void); +#endif +#endif /* WGL_EXT_make_current_read */ + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#endif /* WGL_EXT_multisample */ + +#ifndef WGL_EXT_pbuffer +#define WGL_EXT_pbuffer 1 +DECLARE_HANDLE(HPBUFFEREXT); +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 +typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); +int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); +BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_EXT_pbuffer */ + +#ifndef WGL_EXT_pixel_format +#define WGL_EXT_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#endif +#endif /* WGL_EXT_pixel_format */ + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 +#endif /* WGL_EXT_pixel_format_packed_float */ + +#ifndef WGL_EXT_swap_control +#define WGL_EXT_swap_control 1 +typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); +typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglSwapIntervalEXT (int interval); +int WINAPI wglGetSwapIntervalEXT (void); +#endif +#endif /* WGL_EXT_swap_control */ + +#ifndef WGL_EXT_swap_control_tear +#define WGL_EXT_swap_control_tear 1 +#endif /* WGL_EXT_swap_control_tear */ + +#ifndef WGL_I3D_digital_video_control +#define WGL_I3D_digital_video_control 1 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 +typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); +#endif +#endif /* WGL_I3D_digital_video_control */ + +#ifndef WGL_I3D_gamma +#define WGL_I3D_gamma 1 +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); +BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#endif +#endif /* WGL_I3D_gamma */ + +#ifndef WGL_I3D_genlock +#define WGL_I3D_genlock 1 +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C +typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); +typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); +typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnableGenlockI3D (HDC hDC); +BOOL WINAPI wglDisableGenlockI3D (HDC hDC); +BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); +BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); +BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); +BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); +BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); +BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); +BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); +BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); +BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); +BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif +#endif /* WGL_I3D_genlock */ + +#ifndef WGL_I3D_image_buffer +#define WGL_I3D_image_buffer 1 +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 +typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); +typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); +typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); +#ifdef WGL_WGLEXT_PROTOTYPES +LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); +BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); +BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); +#endif +#endif /* WGL_I3D_image_buffer */ + +#ifndef WGL_I3D_swap_frame_lock +#define WGL_I3D_swap_frame_lock 1 +typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnableFrameLockI3D (void); +BOOL WINAPI wglDisableFrameLockI3D (void); +BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); +BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); +#endif +#endif /* WGL_I3D_swap_frame_lock */ + +#ifndef WGL_I3D_swap_frame_usage +#define WGL_I3D_swap_frame_usage 1 +typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); +typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); +BOOL WINAPI wglBeginFrameTrackingI3D (void); +BOOL WINAPI wglEndFrameTrackingI3D (void); +BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif +#endif /* WGL_I3D_swap_frame_usage */ + +#ifndef WGL_NV_DX_interop +#define WGL_NV_DX_interop 1 +#define WGL_ACCESS_READ_ONLY_NV 0x00000000 +#define WGL_ACCESS_READ_WRITE_NV 0x00000001 +#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 +typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); +typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); +typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); +typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); +typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); +HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); +BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); +HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); +BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); +BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +#endif +#endif /* WGL_NV_DX_interop */ + +#ifndef WGL_NV_DX_interop2 +#define WGL_NV_DX_interop2 1 +#endif /* WGL_NV_DX_interop2 */ + +#ifndef WGL_NV_copy_image +#define WGL_NV_copy_image 1 +typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* WGL_NV_copy_image */ + +#ifndef WGL_NV_delay_before_swap +#define WGL_NV_delay_before_swap 1 +typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds); +#endif +#endif /* WGL_NV_delay_before_swap */ + +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 +#endif /* WGL_NV_float_buffer */ + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 +DECLARE_HANDLE(HGPUNV); +struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; +}; +typedef struct _GPU_DEVICE *PGPU_DEVICE; +#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 +typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); +typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); +typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); +BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); +BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +BOOL WINAPI wglDeleteDCNV (HDC hdc); +#endif +#endif /* WGL_NV_gpu_affinity */ + +#ifndef WGL_NV_multisample_coverage +#define WGL_NV_multisample_coverage 1 +#define WGL_COVERAGE_SAMPLES_NV 0x2042 +#define WGL_COLOR_SAMPLES_NV 0x20B9 +#endif /* WGL_NV_multisample_coverage */ + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); +#ifdef WGL_WGLEXT_PROTOTYPES +int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); +#endif +#endif /* WGL_NV_present_video */ + +#ifndef WGL_NV_render_depth_texture +#define WGL_NV_render_depth_texture 1 +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 +#endif /* WGL_NV_render_depth_texture */ + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_NV_render_texture_rectangle 1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 +#endif /* WGL_NV_render_texture_rectangle */ + +#ifndef WGL_NV_swap_group +#define WGL_NV_swap_group 1 +typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); +typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); +typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); +typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); +typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); +BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); +BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); +BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); +BOOL WINAPI wglResetFrameCountNV (HDC hDC); +#endif +#endif /* WGL_NV_swap_group */ + +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 +typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +#ifdef WGL_WGLEXT_PROTOTYPES +void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +void WINAPI wglFreeMemoryNV (void *pointer); +#endif +#endif /* WGL_NV_vertex_array_range */ + +#ifndef WGL_NV_video_capture +#define WGL_NV_video_capture 1 +DECLARE_HANDLE(HVIDEOINPUTDEVICENV); +#define WGL_UNIQUE_ID_NV 0x20CE +#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#endif +#endif /* WGL_NV_video_capture */ + +#ifndef WGL_NV_video_output +#define WGL_NV_video_output 1 +DECLARE_HANDLE(HPVIDEODEV); +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC +typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); +typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); +BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif +#endif /* WGL_NV_video_output */ + +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#ifdef WGL_WGLEXT_PROTOTYPES +BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); +INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif +#endif /* WGL_OML_sync_control */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp new file mode 100644 index 000000000..ca6800de8 --- /dev/null +++ b/src/win32/win32gliface.cpp @@ -0,0 +1,1141 @@ +//#include "gl/system/gl_system.h" + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include "wglext.h" + +#define USE_WINDOWS_DWORD +#include "win32iface.h" +#include "win32gliface.h" +//#include "gl/gl_intern.h" +#include "x86.h" +#include "templates.h" +#include "version.h" +#include "c_console.h" +#include "hardware.h" +#include "v_video.h" +#include "i_input.h" +#include "i_system.h" +#include "doomstat.h" +#include "v_text.h" +#include "m_argv.h" +#include "doomerrors.h" +//#include "gl_defs.h" + +#include "gl/renderer/gl_renderer.h" +#include "gl/system/gl_framebuffer.h" + +extern "C" { + _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; + __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; +} + +void gl_CalculateCPUSpeed(); +extern int NewWidth, NewHeight, NewBits, DisplayBits; + +// these get used before GLEW is initialized so we have to use separate pointers with different names +PFNWGLCHOOSEPIXELFORMATARBPROC myWglChoosePixelFormatARB; // = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); +PFNWGLCREATECONTEXTATTRIBSARBPROC myWglCreateContextAttribsARB; +PFNWGLSWAPINTERVALEXTPROC vsyncfunc; + + +CUSTOM_CVAR(Int, gl_vid_multisample, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL ) +{ + Printf("This won't take effect until " GAMENAME " is restarted.\n"); +} + +CVAR(Bool, gl_debug, false, 0) + +EXTERN_CVAR(Int, vid_refreshrate) + +//========================================================================== +// +// +// +//========================================================================== + +Win32GLVideo::Win32GLVideo(int parm) : m_Modes(NULL), m_IsFullscreen(false) +{ + #ifdef _WIN32 + if (CPU.bRDTSC) gl_CalculateCPUSpeed(); + #endif + I_SetWndProc(); + m_DisplayWidth = vid_defwidth; + m_DisplayHeight = vid_defheight; + m_DisplayBits = 32; + m_DisplayHz = 60; + + GetDisplayDeviceName(); + MakeModesList(); + SetPixelFormat(); + +} + +//========================================================================== +// +// +// +//========================================================================== + +Win32GLVideo::~Win32GLVideo() +{ + FreeModes(); + if (GLRenderer != NULL) GLRenderer->FlushTextures(); +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLVideo::SetWindowedScale(float scale) +{ +} + +//========================================================================== +// +// +// +//========================================================================== + +struct MonitorEnumState +{ + int curIdx; + HMONITOR hFoundMonitor; +}; + +static BOOL CALLBACK GetDisplayDeviceNameMonitorEnumProc(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData) +{ + MonitorEnumState *state = reinterpret_cast(dwData); + + MONITORINFOEX mi; + mi.cbSize = sizeof mi; + GetMonitorInfo(hMonitor, &mi); + + // This assumes the monitors are returned by EnumDisplayMonitors in the + // order they're found in the Direct3D9 adapters list. Fingers crossed... + if (state->curIdx == vid_adapter) + { + state->hFoundMonitor = hMonitor; + + // Don't stop enumeration; this makes EnumDisplayMonitors fail. I like + // proper fails. + } + + ++state->curIdx; + + return TRUE; +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLVideo::GetDisplayDeviceName() +{ + // If anything goes wrong, anything at all, everything uses the primary + // monitor. + m_DisplayDeviceName = 0; + m_hMonitor = 0; + + MonitorEnumState mes; + + mes.curIdx = 1; + mes.hFoundMonitor = 0; + + // Could also use EnumDisplayDevices, I guess. That might work. + if (EnumDisplayMonitors(0, 0, &GetDisplayDeviceNameMonitorEnumProc, LPARAM(&mes))) + { + if (mes.hFoundMonitor) + { + MONITORINFOEX mi; + + mi.cbSize = sizeof mi; + + if (GetMonitorInfo(mes.hFoundMonitor, &mi)) + { + strcpy(m_DisplayDeviceBuffer, mi.szDevice); + m_DisplayDeviceName = m_DisplayDeviceBuffer; + + m_hMonitor = mes.hFoundMonitor; + } + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLVideo::MakeModesList() +{ + ModeInfo *pMode, *nextmode; + DEVMODE dm; + int mode = 0; + + memset(&dm, 0, sizeof(DEVMODE)); + dm.dmSize = sizeof(DEVMODE); + + while (EnumDisplaySettings(m_DisplayDeviceName, mode, &dm)) + { + this->AddMode(dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmPelsHeight, dm.dmDisplayFrequency); + ++mode; + } + + for (pMode = m_Modes; pMode != NULL; pMode = nextmode) + { + nextmode = pMode->next; + if (pMode->realheight == pMode->height && pMode->height * 4/3 == pMode->width) + { + if (pMode->width >= 360) + { + AddMode (pMode->width, pMode->width * 9/16, pMode->bits, pMode->height, pMode->refreshHz); + } + if (pMode->width > 640) + { + AddMode (pMode->width, pMode->width * 10/16, pMode->bits, pMode->height, pMode->refreshHz); + } + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLVideo::StartModeIterator(int bits, bool fs) +{ + m_IteratorMode = m_Modes; + // I think it's better to ignore the game-side settings of bit depth. + // The GL renderer will always default to 32 bits because 16 bit modes cannot have a stencil buffer. + m_IteratorBits = 32; + m_IteratorFS = fs; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLVideo::NextMode(int *width, int *height, bool *letterbox) +{ + if (m_IteratorMode) + { + while (m_IteratorMode && m_IteratorMode->bits != m_IteratorBits) + { + m_IteratorMode = m_IteratorMode->next; + } + + if (m_IteratorMode) + { + *width = m_IteratorMode->width; + *height = m_IteratorMode->height; + if (letterbox != NULL) *letterbox = m_IteratorMode->realheight != m_IteratorMode->height; + m_IteratorMode = m_IteratorMode->next; + return true; + } + } + + return false; +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLVideo::AddMode(int x, int y, int bits, int baseHeight, int refreshHz) +{ + ModeInfo **probep = &m_Modes; + ModeInfo *probe = m_Modes; + + // This mode may have been already added to the list because it is + // enumerated multiple times at different refresh rates. If it's + // not present, add it to the right spot in the list; otherwise, do nothing. + // Modes are sorted first by width, then by height, then by depth. In each + // case the order is ascending. + if (bits < 32) return; + for (; probe != 0; probep = &probe->next, probe = probe->next) + { + if (probe->width != x) continue; + // Width is equal + if (probe->height != y) continue; + // Width is equal + if (probe->realheight != baseHeight) continue; + // Height is equal + if (probe->bits != bits) continue; + // Bits is equal + if (probe->refreshHz > refreshHz) return; + probe->refreshHz = refreshHz; + return; + } + + *probep = new ModeInfo (x, y, bits, baseHeight, refreshHz); + (*probep)->next = probe; +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLVideo::FreeModes() +{ + ModeInfo *mode = m_Modes; + + while (mode) + { + ModeInfo *tempmode = mode; + mode = mode->next; + delete tempmode; + } + + m_Modes = NULL; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLVideo::GoFullscreen(bool yes) +{ + m_IsFullscreen = yes; + + m_trueHeight = m_DisplayHeight; + + if (yes) + { + // If in windowed mode, any height is good. + for (ModeInfo *mode = m_Modes; mode != NULL; mode = mode->next) + { + if (mode->width == m_DisplayWidth && mode->height == m_DisplayHeight) + { + m_trueHeight = mode->realheight; + break; + } + } + } + + if (yes) + { + SetFullscreen(m_DisplayDeviceName, m_DisplayWidth, m_trueHeight, m_DisplayBits, m_DisplayHz); + } + else + { + SetFullscreen(m_DisplayDeviceName, 0,0,0,0); + } + return yes; +} + + +//========================================================================== +// +// +// +//========================================================================== + +DFrameBuffer *Win32GLVideo::CreateFrameBuffer(int width, int height, bool fs, DFrameBuffer *old) +{ + Win32GLFrameBuffer *fb; + + m_DisplayWidth = width; + m_DisplayHeight = height; + m_DisplayBits = 32; + m_DisplayHz = 60; + + if (vid_refreshrate == 0) + { + for (ModeInfo *mode = m_Modes; mode != NULL; mode = mode->next) + { + if (mode->width == m_DisplayWidth && mode->height == m_DisplayHeight && mode->bits == m_DisplayBits) + { + m_DisplayHz = MAX(m_DisplayHz, mode->refreshHz); + } + } + } + else + { + m_DisplayHz = vid_refreshrate; + } + + if (old != NULL) + { // Reuse the old framebuffer if its attributes are the same + fb = static_cast (old); + if (fb->m_Width == m_DisplayWidth && + fb->m_Height == m_DisplayHeight && + fb->m_Bits == m_DisplayBits && + fb->m_RefreshHz == m_DisplayHz && + fb->m_Fullscreen == fs) + { + return old; + } + //old->GetFlash(flashColor, flashAmount); + delete old; + } + fb = new OpenGLFrameBuffer(m_hMonitor, m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz, fs); + return fb; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLVideo::SetResolution (int width, int height, int bits) +{ + if (GLRenderer != NULL) GLRenderer->FlushTextures(); + I_ShutdownGraphics(); + + Video = new Win32GLVideo(0); + if (Video == NULL) I_FatalError ("Failed to initialize display"); + + bits=32; + + V_DoModeSetup(width, height, bits); + return true; // We must return true because the old video context no longer exists. +} + +//========================================================================== +// +// +// +//========================================================================== + +struct DumpAdaptersState +{ + unsigned index; + char *displayDeviceName; +}; + +static BOOL CALLBACK DumpAdaptersMonitorEnumProc(HMONITOR hMonitor, HDC, LPRECT, LPARAM dwData) +{ + DumpAdaptersState *state = reinterpret_cast(dwData); + + MONITORINFOEX mi; + mi.cbSize=sizeof mi; + + char moreinfo[64] = ""; + + bool active = true; + + if (GetMonitorInfo(hMonitor, &mi)) + { + bool primary = !!(mi.dwFlags & MONITORINFOF_PRIMARY); + + mysnprintf(moreinfo, countof(moreinfo), " [%ldx%ld @ (%ld,%ld)]%s", + mi.rcMonitor.right - mi.rcMonitor.left, + mi.rcMonitor.bottom - mi.rcMonitor.top, + mi.rcMonitor.left, mi.rcMonitor.top, + primary ? " (Primary)" : ""); + + if (!state->displayDeviceName && !primary) + active = false;//primary selected, but this ain't primary + else if (state->displayDeviceName && strcmp(state->displayDeviceName, mi.szDevice) != 0) + active = false;//this isn't the selected one + } + + Printf("%s%u. %s\n", + active ? TEXTCOLOR_BOLD : "", + state->index, + moreinfo); + + ++state->index; + + return TRUE; +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLVideo::DumpAdapters() +{ + DumpAdaptersState das; + + das.index = 1; + das.displayDeviceName = m_DisplayDeviceName; + + EnumDisplayMonitors(0, 0, DumpAdaptersMonitorEnumProc, LPARAM(&das)); +} + +//========================================================================== +// +// +// +//========================================================================== + +HWND Win32GLVideo::InitDummy() +{ + HMODULE g_hInst = GetModuleHandle(NULL); + HWND dummy; + //Create a rect structure for the size/position of the window + RECT windowRect; + windowRect.left = 0; + windowRect.right = 64; + windowRect.top = 0; + windowRect.bottom = 64; + + //Window class structure + WNDCLASS wc; + + //Fill in window class struct + wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wc.lpfnWndProc = (WNDPROC) DefWindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = g_hInst; + wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hbrBackground = NULL; + wc.lpszMenuName = NULL; + wc.lpszClassName = "GZDoomOpenGLDummyWindow"; + + //Register window class + if(!RegisterClass(&wc)) + { + return 0; + } + + //Set window style & extended style + DWORD style, exStyle; + exStyle = WS_EX_CLIENTEDGE; + style = WS_SYSMENU | WS_BORDER | WS_CAPTION;// | WS_VISIBLE; + + //Adjust the window size so that client area is the size requested + AdjustWindowRectEx(&windowRect, style, false, exStyle); + + //Create Window + if(!(dummy = CreateWindowEx(exStyle, + "GZDoomOpenGLDummyWindow", + "GZDOOM", + WS_CLIPSIBLINGS | WS_CLIPCHILDREN | style, + 0, 0, + windowRect.right-windowRect.left, + windowRect.bottom-windowRect.top, + NULL, NULL, + g_hInst, + NULL))) + { + UnregisterClass("GZDoomOpenGLDummyWindow", g_hInst); + return 0; + } + ShowWindow(dummy, SW_HIDE); + + return dummy; +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLVideo::ShutdownDummy(HWND dummy) +{ + DestroyWindow(dummy); + UnregisterClass("GZDoomOpenGLDummyWindow", GetModuleHandle(NULL)); +} + + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLVideo::SetPixelFormat() +{ + HDC hDC; + HGLRC hRC; + HWND dummy; + + PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 32, // color depth + 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, + 16, // z depth + 0, // stencil buffer + 0, + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + + int pixelFormat; + + // we have to create a dummy window to init stuff from or the full init stuff fails + dummy = InitDummy(); + + hDC = GetDC(dummy); + pixelFormat = ChoosePixelFormat(hDC, &pfd); + DescribePixelFormat(hDC, pixelFormat, sizeof(pfd), &pfd); + + ::SetPixelFormat(hDC, pixelFormat, &pfd); + + hRC = wglCreateContext(hDC); + wglMakeCurrent(hDC, hRC); + + myWglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); + myWglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB"); + // any extra stuff here? + + wglMakeCurrent(NULL, NULL); + wglDeleteContext(hRC); + ReleaseDC(dummy, hDC); + ShutdownDummy(dummy); + + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLVideo::SetupPixelFormat(int multisample) +{ + int colorDepth; + HDC deskDC; + int attributes[26]; + int pixelFormat; + unsigned int numFormats; + float attribsFloat[] = {0.0f, 0.0f}; + + deskDC = GetDC(GetDesktopWindow()); + colorDepth = GetDeviceCaps(deskDC, BITSPIXEL); + ReleaseDC(GetDesktopWindow(), deskDC); + + if (myWglChoosePixelFormatARB) + { + attributes[0] = WGL_RED_BITS_ARB; //bits + attributes[1] = 8; + attributes[2] = WGL_GREEN_BITS_ARB; //bits + attributes[3] = 8; + attributes[4] = WGL_BLUE_BITS_ARB; //bits + attributes[5] = 8; + attributes[6] = WGL_ALPHA_BITS_ARB; + attributes[7] = 8; + attributes[8] = WGL_DEPTH_BITS_ARB; + attributes[9] = 24; + attributes[10] = WGL_STENCIL_BITS_ARB; + attributes[11] = 8; + + attributes[12] = WGL_DRAW_TO_WINDOW_ARB; //required to be true + attributes[13] = true; + attributes[14] = WGL_SUPPORT_OPENGL_ARB; + attributes[15] = true; + attributes[16] = WGL_DOUBLE_BUFFER_ARB; + attributes[17] = true; + + attributes[18] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB + attributes[19] = WGL_FULL_ACCELERATION_ARB; + + if (multisample > 0) + { + attributes[20] = WGL_SAMPLE_BUFFERS_ARB; + attributes[21] = true; + attributes[22] = WGL_SAMPLES_ARB; + attributes[23] = multisample; + } + else + { + attributes[20] = 0; + attributes[21] = 0; + attributes[22] = 0; + attributes[23] = 0; + } + + attributes[24] = 0; + attributes[25] = 0; + + if (!myWglChoosePixelFormatARB(m_hDC, attributes, attribsFloat, 1, &pixelFormat, &numFormats)) + { + Printf("R_OPENGL: Couldn't choose pixel format. Retrying in compatibility mode\n"); + goto oldmethod; + } + + if (numFormats == 0) + { + Printf("R_OPENGL: No valid pixel formats found. Retrying in compatibility mode\n"); + goto oldmethod; + } + } + else + { + oldmethod: + // If wglChoosePixelFormatARB is not found we have to do it the old fashioned way. + static PIXELFORMATDESCRIPTOR pfd = { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 32, // color depth + 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, + 32, // z depth + 8, // stencil buffer + 0, + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + + pixelFormat = ChoosePixelFormat(m_hDC, &pfd); + DescribePixelFormat(m_hDC, pixelFormat, sizeof(pfd), &pfd); + + if (pfd.dwFlags & PFD_GENERIC_FORMAT) + { + I_Error("R_OPENGL: OpenGL driver not accelerated!"); + return false; + } + } + + if (!::SetPixelFormat(m_hDC, pixelFormat, NULL)) + { + I_Error("R_OPENGL: Couldn't set pixel format.\n"); + return false; + } + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +// since we cannot use the extension loader here, before it gets initialized, +// we have to define the extended GL stuff we need, ourselves here. +// The headers generated by GLLoadGen only work if the loader gets initialized. +typedef const GLubyte * (APIENTRY *PFNGLGETSTRINGIPROC)(GLenum, GLuint); +#define GL_NUM_EXTENSIONS 0x821D + +bool Win32GLVideo::checkCoreUsability() +{ + // if we explicitly want to disable 4.x features this must fail. + if (Args->CheckParm("-gl3")) return false; + + // GL 4.4 implies GL_ARB_buffer_storage + if (strcmp((char*)glGetString(GL_VERSION), "4.4") >= 0) return true; + + // at this point the extension loader has not been initialized so we have to retrieve glGetStringi ourselves. + PFNGLGETSTRINGIPROC myglGetStringi = (PFNGLGETSTRINGIPROC)wglGetProcAddress("glGetStringi"); + if (!myglGetStringi) return false; // this should not happen. + + const char *extension; + + int max = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &max); + + // step through all reported extensions and see if we got what we need... + for (int i = 0; i < max; i++) + { + extension = (const char*)myglGetStringi(GL_EXTENSIONS, i); + if (!strcmp(extension, "GL_ARB_buffer_storage")) return true; + } + return false; +} + +bool Win32GLVideo::InitHardware (HWND Window, int multisample) +{ + m_Window=Window; + m_hDC = GetDC(Window); + + if (!SetupPixelFormat(multisample)) + { + I_Error ("R_OPENGL: Unabl...\n"); + return false; + } + + for (int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; prof <= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; prof++) + { + m_hRC = NULL; + if (myWglCreateContextAttribsARB != NULL) + { + // let's try to get the best version possible. Some drivers only give us the version we request + // which breaks all version checks for feature support. The highest used features we use are from version 4.4, and 3.0 is a requirement. + static int versions[] = { 45, 44, 43, 42, 41, 40, 33, 32, 31, 30, -1 }; + + for (int i = 0; versions[i] > 0; i++) + { + int ctxAttribs[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, versions[i] / 10, + WGL_CONTEXT_MINOR_VERSION_ARB, versions[i] % 10, + WGL_CONTEXT_FLAGS_ARB, gl_debug ? WGL_CONTEXT_DEBUG_BIT_ARB : 0, + WGL_CONTEXT_PROFILE_MASK_ARB, prof, + 0 + }; + + m_hRC = myWglCreateContextAttribsARB(m_hDC, 0, ctxAttribs); + if (m_hRC != NULL) break; + } + } + + if (m_hRC == NULL && prof == WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) + { + I_Error ("R_OPENGL: Unable to create an OpenGL 3.x render context.\n"); + return false; + } + + if (m_hRC != NULL) + { + wglMakeCurrent(m_hDC, m_hRC); + + // we can only use core profile contexts if GL_ARB_buffer_storage is supported or GL version is >= 4.4 + if (prof == WGL_CONTEXT_CORE_PROFILE_BIT_ARB && !checkCoreUsability()) + { + wglMakeCurrent(0, 0); + wglDeleteContext(m_hRC); + } + else + { + return true; + } + } + } + // We get here if the driver doesn't support the modern context creation API which always means an old driver. + I_Error ("R_OPENGL: Unable to create an OpenGL 3.x render context.\n"); + return false; +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLVideo::Shutdown() +{ + if (m_hRC) + { + wglMakeCurrent(0, 0); + wglDeleteContext(m_hRC); + } + if (m_hDC) ReleaseDC(m_Window, m_hDC); +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLVideo::SetFullscreen(const char *devicename, int w, int h, int bits, int hz) +{ + DEVMODE dm; + + if (w==0) + { + ChangeDisplaySettingsEx(devicename, 0, 0, 0, 0); + } + else + { + dm.dmSize = sizeof(DEVMODE); + dm.dmSpecVersion = DM_SPECVERSION;//Somebody owes me... + dm.dmDriverExtra = 0;//...1 hour of my life back + dm.dmPelsWidth = w; + dm.dmPelsHeight = h; + dm.dmBitsPerPel = bits; + dm.dmDisplayFrequency = hz; + dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; + if (DISP_CHANGE_SUCCESSFUL != ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0)) + { + dm.dmFields &= ~DM_DISPLAYFREQUENCY; + return DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx(devicename, &dm, 0, CDS_FULLSCREEN, 0); + } + } + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +IMPLEMENT_ABSTRACT_CLASS(Win32GLFrameBuffer) + +//========================================================================== +// +// +// +//========================================================================== + +Win32GLFrameBuffer::Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : BaseWinFB(width, height) +{ + static int localmultisample=-1; + + if (localmultisample<0) localmultisample=gl_vid_multisample; + + m_Width = width; + m_Height = height; + m_Bits = bits; + m_RefreshHz = refreshHz; + m_Fullscreen = fullscreen; + m_Lock=0; + + RECT r; + LONG style, exStyle; + + static_cast(Video)->GoFullscreen(fullscreen); + + m_displayDeviceName = 0; + int monX = 0, monY = 0; + + if (hMonitor) + { + MONITORINFOEX mi; + mi.cbSize = sizeof mi; + + if (GetMonitorInfo(HMONITOR(hMonitor), &mi)) + { + strcpy(m_displayDeviceNameBuffer, mi.szDevice); + m_displayDeviceName = m_displayDeviceNameBuffer; + + monX = int(mi.rcMonitor.left); + monY = int(mi.rcMonitor.top); + } + } + + ShowWindow (Window, SW_SHOW); + GetWindowRect(Window, &r); + style = WS_VISIBLE | WS_CLIPSIBLINGS; + exStyle = 0; + + if (fullscreen) + style |= WS_POPUP; + else + { + style |= WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX; + exStyle |= WS_EX_WINDOWEDGE; + } + + SetWindowLong(Window, GWL_STYLE, style); + SetWindowLong(Window, GWL_EXSTYLE, exStyle); + SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + + if (fullscreen) + { + MoveWindow(Window, monX, monY, width, GetTrueHeight(), FALSE); + + // And now, seriously, it IS in the right place. Promise. + } + else + { + MoveWindow(Window, r.left, r.top, width + (GetSystemMetrics(SM_CXSIZEFRAME) * 2), height + (GetSystemMetrics(SM_CYSIZEFRAME) * 2) + GetSystemMetrics(SM_CYCAPTION), FALSE); + + I_RestoreWindowedPos(); + } + + if (!static_cast(Video)->InitHardware(Window, localmultisample)) + { + vid_renderer = 0; + return; + } + + vsyncfunc = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); + + HDC hDC = GetDC(Window); + m_supportsGamma = !!GetDeviceGammaRamp(hDC, (void *)m_origGamma); + ReleaseDC(Window, hDC); +} + +//========================================================================== +// +// +// +//========================================================================== + +Win32GLFrameBuffer::~Win32GLFrameBuffer() +{ + if (m_supportsGamma) + { + HDC hDC = GetDC(Window); + SetDeviceGammaRamp(hDC, (void *)m_origGamma); + ReleaseDC(Window, hDC); + } + I_SaveWindowedPos(); + + static_cast(Video)->SetFullscreen(m_displayDeviceName, 0,0,0,0); + + ShowWindow (Window, SW_SHOW); + SetWindowLong(Window, GWL_STYLE, WS_VISIBLE | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW); + SetWindowLong(Window, GWL_EXSTYLE, WS_EX_WINDOWEDGE); + SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); + I_GetEvent(); + + static_cast(Video)->Shutdown(); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLFrameBuffer::InitializeState() +{ +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLFrameBuffer::CanUpdate() +{ + if (!AppActive) return false; + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLFrameBuffer::SetGammaTable(WORD *tbl) +{ + HDC hDC = GetDC(Window); + SetDeviceGammaRamp(hDC, (void *)tbl); + ReleaseDC(Window, hDC); +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLFrameBuffer::Lock(bool buffered) +{ + m_Lock++; + Buffer = MemBuffer; + return true; +} + +bool Win32GLFrameBuffer::Lock () +{ + return Lock(false); +} + +void Win32GLFrameBuffer::Unlock () +{ + m_Lock--; +} + +bool Win32GLFrameBuffer::IsLocked () +{ + return m_Lock>0;// true; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLFrameBuffer::IsFullscreen() +{ + return m_Fullscreen; +} + +void Win32GLFrameBuffer::PaletteChanged() +{ +} + +int Win32GLFrameBuffer::QueryNewPalette() +{ + return 0; +} + +HRESULT Win32GLFrameBuffer::GetHR() +{ + return 0; +} + +void Win32GLFrameBuffer::Blank () +{ +} + +bool Win32GLFrameBuffer::PaintToWindow () +{ + return false; +} + +bool Win32GLFrameBuffer::CreateResources () +{ + return false; +} + +void Win32GLFrameBuffer::ReleaseResources () +{ +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLFrameBuffer::SetVSync (bool vsync) +{ + if (vsyncfunc != NULL) vsyncfunc(vsync); +} + +void Win32GLFrameBuffer::SwapBuffers() +{ + ::SwapBuffers(static_cast(Video)->m_hDC); +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLFrameBuffer::NewRefreshRate () +{ + if (m_Fullscreen) + { + setmodeneeded = true; + NewWidth = screen->GetWidth(); + NewHeight = screen->GetHeight(); + NewBits = DisplayBits; + } +} + + +IVideo *gl_CreateVideo() +{ + return new Win32GLVideo(0); +} \ No newline at end of file diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h new file mode 100644 index 000000000..4ef48ce18 --- /dev/null +++ b/src/win32/win32gliface.h @@ -0,0 +1,154 @@ +#ifndef __WIN32GLIFACE_H__ +#define __WIN32GLIFACE_H__ + +#include "hardware.h" +#include "win32iface.h" +#include "v_video.h" +#include "tarray.h" + +extern IVideo *Video; + + +extern BOOL AppActive; + +EXTERN_CVAR (Float, dimamount) +EXTERN_CVAR (Color, dimcolor) + +EXTERN_CVAR(Int, vid_defwidth); +EXTERN_CVAR(Int, vid_defheight); +EXTERN_CVAR(Int, vid_renderer); +EXTERN_CVAR(Int, vid_adapter); + +extern HINSTANCE g_hInst; +extern HWND Window; +extern IVideo *Video; + +struct FRenderer; +FRenderer *gl_CreateInterface(); + + +class Win32GLVideo : public IVideo +{ +public: + Win32GLVideo(int parm); + virtual ~Win32GLVideo(); + + EDisplayType GetDisplayType () { return DISPLAY_Both; } + void SetWindowedScale (float scale); + void StartModeIterator (int bits, bool fs); + bool NextMode (int *width, int *height, bool *letterbox); + bool GoFullscreen(bool yes); + DFrameBuffer *CreateFrameBuffer (int width, int height, bool fs, DFrameBuffer *old); + virtual bool SetResolution (int width, int height, int bits); + void DumpAdapters(); + bool InitHardware (HWND Window, int multisample); + void Shutdown(); + bool SetFullscreen(const char *devicename, int w, int h, int bits, int hz); + + HDC m_hDC; + +protected: + struct ModeInfo + { + ModeInfo (int inX, int inY, int inBits, int inRealY, int inRefresh) + : next (NULL), + width (inX), + height (inY), + bits (inBits), + refreshHz (inRefresh), + realheight (inRealY) + {} + ModeInfo *next; + int width, height, bits, refreshHz, realheight; + } *m_Modes; + + ModeInfo *m_IteratorMode; + int m_IteratorBits; + bool m_IteratorFS; + bool m_IsFullscreen; + int m_trueHeight; + int m_DisplayWidth, m_DisplayHeight, m_DisplayBits, m_DisplayHz; + HMODULE hmRender; + + char m_DisplayDeviceBuffer[CCHDEVICENAME]; + char *m_DisplayDeviceName; + HMONITOR m_hMonitor; + + HWND m_Window; + HGLRC m_hRC; + + HWND InitDummy(); + void ShutdownDummy(HWND dummy); + bool SetPixelFormat(); + bool SetupPixelFormat(int multisample); + + void GetDisplayDeviceName(); + void MakeModesList(); + void AddMode(int x, int y, int bits, int baseHeight, int refreshHz); + void FreeModes(); + bool checkCoreUsability(); +public: + int GetTrueHeight() { return m_trueHeight; } + +}; + + + +class Win32GLFrameBuffer : public BaseWinFB +{ + DECLARE_CLASS(Win32GLFrameBuffer, BaseWinFB) + +public: + Win32GLFrameBuffer() {} + // Actually, hMonitor is a HMONITOR, but it's passed as a void * as there + // look to be some cross-platform bits in the way. + Win32GLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen); + virtual ~Win32GLFrameBuffer(); + + + // unused but must be defined + virtual void Blank (); + virtual bool PaintToWindow (); + virtual HRESULT GetHR(); + + virtual bool CreateResources (); + virtual void ReleaseResources (); + + void SetVSync (bool vsync); + void SwapBuffers(); + void NewRefreshRate (); + + + int GetTrueHeight() { return static_cast(Video)->GetTrueHeight(); } + + bool Lock(bool buffered); + bool Lock (); + void Unlock(); + bool IsLocked (); + + + bool IsFullscreen(); + void PaletteChanged(); + int QueryNewPalette(); + + void InitializeState(); + +protected: + + bool CanUpdate(); + void SetGammaTable(WORD * tbl); + + float m_Gamma, m_Brightness, m_Contrast; + WORD m_origGamma[768]; + BOOL m_supportsGamma; + bool m_Fullscreen; + int m_Width, m_Height, m_Bits, m_RefreshHz; + int m_Lock; + char m_displayDeviceNameBuffer[CCHDEVICENAME]; + char *m_displayDeviceName; + + friend class Win32GLVideo; + +}; + +#endif //__WIN32GLIFACE_H__ diff --git a/src/win32/zdoom.rc b/src/win32/zdoom.rc index e28277e3a..5e2226c6d 100644 --- a/src/win32/zdoom.rc +++ b/src/win32/zdoom.rc @@ -72,13 +72,13 @@ BEGIN " BEGIN\r\n" " VALUE ""Comments"", ""Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg.""\r\n" " VALUE ""CompanyName"", "" ""\r\n" - " VALUE ""FileDescription"", ""ZDoom""\r\n" + " VALUE ""FileDescription"", ""GZDoom""\r\n" " VALUE ""FileVersion"", RC_FILEVERSION2\r\n" - " VALUE ""InternalName"", ""ZDoom""\r\n" + " VALUE ""InternalName"", ""GZDoom""\r\n" " VALUE ""LegalCopyright"", ""Copyright \\u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al.""\r\n" " VALUE ""LegalTrademarks"", ""DoomR is a Registered Trademark of id Software, Inc.""\r\n" - " VALUE ""OriginalFilename"", ""zdoom.exe""\r\n" - " VALUE ""ProductName"", ""ZDoom""\r\n" + " VALUE ""OriginalFilename"", ""gzdoom.exe""\r\n" + " VALUE ""ProductName"", ""GZDoom""\r\n" " VALUE ""ProductVersion"", RC_PRODUCTVERSION2\r\n" " END\r\n" " END\r\n" @@ -86,7 +86,7 @@ BEGIN " BEGIN\r\n" " VALUE ""Translation"", 0x409, 1200\r\n" " END\r\n" - "EN\0" + "END\r\n" END #endif // APSTUDIO_INVOKED @@ -464,7 +464,7 @@ IDB_DEADGUY BITMAP "deadguy.bmp" // Generated from the TEXTINCLUDE 3 resource. // #ifndef NO_MANIFEST - CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "zdoom.exe.manifest" +// CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "zdoom.exe.manifest" #endif ///////////////////////////////////////////////////////////////////////////// @@ -492,13 +492,13 @@ BEGIN BEGIN VALUE "Comments", "Thanks to id Software for creating DOOM and then releasing the source code. Thanks also to TeamTNT for creating BOOM, which ZDoom is partially based on. Includes code based on the Cajun Bot 0.97 by Martin Collberg." VALUE "CompanyName", " " - VALUE "FileDescription", "ZDoom" + VALUE "FileDescription", "GZDoom" VALUE "FileVersion", RC_FILEVERSION2 - VALUE "InternalName", "ZDoom" + VALUE "InternalName", "GZDoom" VALUE "LegalCopyright", "Copyright \u00A9 1993-1996 id Software, 1998-2010 Randy Heit, 2002-2010 Christoph Oelckers, et al." VALUE "LegalTrademarks", "DoomR is a Registered Trademark of id Software, Inc." - VALUE "OriginalFilename", "zdoom.exe" - VALUE "ProductName", "ZDoom" + VALUE "OriginalFilename", "gzdoom.exe" + VALUE "ProductName", "GZDoom" VALUE "ProductVersion", RC_PRODUCTVERSION2 END END diff --git a/tools/fixrtext/fixrtext.vcproj b/tools/fixrtext/fixrtext.vcproj index cc50b605b..33bfde6f0 100644 --- a/tools/fixrtext/fixrtext.vcproj +++ b/tools/fixrtext/fixrtext.vcproj @@ -1,11 +1,12 @@ - @@ -138,6 +138,8 @@ SubSystem="1" OptimizeReferences="2" EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="1" /> - diff --git a/tools/lemon/lemon.vcproj b/tools/lemon/lemon.vcproj index 9f46d4df9..d3205b967 100644 --- a/tools/lemon/lemon.vcproj +++ b/tools/lemon/lemon.vcproj @@ -1,11 +1,12 @@ - @@ -159,6 +159,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> - @@ -241,6 +240,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="1" /> - @@ -325,6 +323,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> - diff --git a/tools/re2c/re2c.vcproj b/tools/re2c/re2c.vcproj index c10906185..5d82bd460 100644 --- a/tools/re2c/re2c.vcproj +++ b/tools/re2c/re2c.vcproj @@ -1,11 +1,12 @@ - @@ -156,6 +156,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> - @@ -237,6 +236,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="1" /> - @@ -320,6 +318,8 @@ OptimizeReferences="2" EnableCOMDATFolding="2" OptimizeForWindows98="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> - diff --git a/tools/updaterevision/updaterevision.vcproj b/tools/updaterevision/updaterevision.vcproj index 0421cbb65..17675b681 100644 --- a/tools/updaterevision/updaterevision.vcproj +++ b/tools/updaterevision/updaterevision.vcproj @@ -1,11 +1,12 @@ - - - - - - - - - - - - - - - - - - - - - @@ -221,6 +144,8 @@ LinkIncremental="2" GenerateDebugInformation="true" SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="17" /> + + + + + + + + + + + + + + + + + + - @@ -349,7 +346,7 @@ /> - - - - 0.0) + { + float gray = (texel.r * 0.3 + texel.g * 0.56 + texel.b * 0.14); + return mix (texel, vec4(gray,gray,gray,texel.a), uDesaturationFactor); + } + else + { + return texel; + } +} + +//=========================================================================== +// +// This function is common for all (non-special-effect) fragment shaders +// +//=========================================================================== + +vec4 getTexel(vec2 st) +{ + vec4 texel = texture(tex, st); + + // + // Apply texture modes + // + switch (uTextureMode) + { + case 1: // TM_MASK + texel.rgb = vec3(1.0,1.0,1.0); + break; + + case 2: // TM_OPAQUE + texel.a = 1.0; + break; + + case 3: // TM_INVERSE + texel = vec4(1.0-texel.r, 1.0-texel.b, 1.0-texel.g, texel.a); + break; + + case 4: // TM_REDTOALPHA + texel = vec4(1.0, 1.0, 1.0, texel.r*texel.a); + break; + + case 5: // TM_CLAMPY + if (st.t < 0.0 || st.t > 1.0) + { + texel.a = 0.0; + } + break; + } + texel *= uObjectColor; + + return desaturate(texel); +} + +//=========================================================================== +// +// Doom lighting equation ripped from EDGE. +// Big thanks to EDGE developers for making the only port +// that actually replicates software renderer's lighting in OpenGL. +// Float version. +// Basically replace int with float and divide all constants by 31. +// +//=========================================================================== + +float R_DoomLightingEquation(float light, float dist) +{ + // Changing this constant gives results very similar to changing r_visibility. + // Default is 232, it seems to give exactly the same light bands as software renderer. + #define DOOMLIGHTFACTOR 232.0 + + /* L in the range 0 to 63 */ + float L = light * 63.0/31.0; + + float min_L = clamp(36.0/31.0 - L, 0.0, 1.0); + + // Fix objects getting totally black when close. + if (dist < 0.0001) + dist = 0.0001; + + float scale = 1.0 / dist; + float index = (59.0/31.0 - L) - (scale * DOOMLIGHTFACTOR/31.0 - DOOMLIGHTFACTOR/31.0); + + /* result is colormap index (0 bright .. 31 dark) */ + return clamp(index, min_L, 1.0); +} + +//=========================================================================== +// +// Calculate light +// +// It is important to note that the light color is not desaturated +// due to ZDoom's implementation weirdness. Everything that's added +// on top of it, e.g. dynamic lights and glows are, though, because +// the objects emitting these lights are also. +// +// This is making this a bit more complicated than it needs to +// because we can't just desaturate the final fragment color. +// +//=========================================================================== + +vec4 getLightColor(float fogdist, float fogfactor) +{ + vec4 color = vColor; + + if (uLightLevel >= 0.0) + { + float newlightlevel = 1.0 - R_DoomLightingEquation(uLightLevel, gl_FragCoord.z); + color.rgb *= newlightlevel; + } + else if (uFogEnabled > 0.0) + { + // brightening around the player for light mode 2 + if (fogdist < uLightDist) + { + color.rgb *= uLightFactor - (fogdist / uLightDist) * (uLightFactor - 1.0); + } + + // + // apply light diminishing through fog equation + // + color.rgb = mix(vec3(0.0, 0.0, 0.0), color.rgb, fogfactor); + } + + // + // handle glowing walls + // + if (uGlowTopColor.a > 0.0 && glowdist.x < uGlowTopColor.a) + { + color.rgb += desaturate(uGlowTopColor * (1.0 - glowdist.x / uGlowTopColor.a)).rgb; + } + if (uGlowBottomColor.a > 0.0 && glowdist.y < uGlowBottomColor.a) + { + color.rgb += desaturate(uGlowBottomColor * (1.0 - glowdist.y / uGlowBottomColor.a)).rgb; + } + color = min(color, 1.0); + + // + // apply brightmaps (or other light manipulation by custom shaders. + // + color = ProcessLight(color); + + // + // apply dynamic lights (except additive) + // + + vec4 dynlight = uDynLightColor; + + if (uLightIndex >= 0) + { + ivec4 lightRange = ivec4(lights[uLightIndex]) + ivec4(uLightIndex + 1); + if (lightRange.z > lightRange.x) + { + // + // modulated lights + // + for(int i=lightRange.x; i= 0) + { + ivec4 lightRange = ivec4(lights[uLightIndex]) + ivec4(uLightIndex + 1); + if (lightRange.w > lightRange.z) + { + vec4 addlight = vec4(0.0,0.0,0.0,0.0); + + // + // additive lights - these can be done after the alpha test. + // + for(int i=lightRange.z; i diff --git a/wadsrc_bm/CMakeLists.txt b/wadsrc_bm/CMakeLists.txt new file mode 100644 index 000000000..a76c5dc36 --- /dev/null +++ b/wadsrc_bm/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required( VERSION 2.4 ) + +add_pk3(brightmaps.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) diff --git a/wadsrc_bm/brightmaps.vcproj b/wadsrc_bm/brightmaps.vcproj new file mode 100644 index 000000000..eaf6a4729 --- /dev/null +++ b/wadsrc_bm/brightmaps.vcproj @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wadsrc_bm/static/brightmaps/doom/BON2B0.png b/wadsrc_bm/static/brightmaps/doom/BON2B0.png new file mode 100644 index 000000000..ef16358e5 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BON2B0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BON2C0.png b/wadsrc_bm/static/brightmaps/doom/BON2C0.png new file mode 100644 index 000000000..f55f93bf4 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BON2C0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BON2D0.png b/wadsrc_bm/static/brightmaps/doom/BON2D0.png new file mode 100644 index 000000000..a08679f6e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BON2D0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOS2A6C4.png b/wadsrc_bm/static/brightmaps/doom/BOS2A6C4.png new file mode 100644 index 000000000..9e866d11e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOS2A6C4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOS2A7C3.png b/wadsrc_bm/static/brightmaps/doom/BOS2A7C3.png new file mode 100644 index 000000000..2e0c7c592 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOS2A7C3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOS2A8C2.png b/wadsrc_bm/static/brightmaps/doom/BOS2A8C2.png new file mode 100644 index 000000000..f11facd1b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOS2A8C2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOS2B6D4.png b/wadsrc_bm/static/brightmaps/doom/BOS2B6D4.png new file mode 100644 index 000000000..8c3d09be2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOS2B6D4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOS2B7D3.png b/wadsrc_bm/static/brightmaps/doom/BOS2B7D3.png new file mode 100644 index 000000000..6d78193f5 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOS2B7D3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOS2B8D2.png b/wadsrc_bm/static/brightmaps/doom/BOS2B8D2.png new file mode 100644 index 000000000..9af1ca025 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOS2B8D2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSA1.png b/wadsrc_bm/static/brightmaps/doom/BOSSA1.png new file mode 100644 index 000000000..a0f08cbb5 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSA1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSA2A8.png b/wadsrc_bm/static/brightmaps/doom/BOSSA2A8.png new file mode 100644 index 000000000..2d07518de Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSA2A8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSA3A7.png b/wadsrc_bm/static/brightmaps/doom/BOSSA3A7.png new file mode 100644 index 000000000..7c48d51e7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSA3A7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSA4A6.png b/wadsrc_bm/static/brightmaps/doom/BOSSA4A6.png new file mode 100644 index 000000000..a76d9635c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSA4A6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSA5.png b/wadsrc_bm/static/brightmaps/doom/BOSSA5.png new file mode 100644 index 000000000..80dca3199 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSA5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSB1.png b/wadsrc_bm/static/brightmaps/doom/BOSSB1.png new file mode 100644 index 000000000..7ef1147cc Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSB1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSB2B8.png b/wadsrc_bm/static/brightmaps/doom/BOSSB2B8.png new file mode 100644 index 000000000..bb31928df Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSB2B8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSB3B7.png b/wadsrc_bm/static/brightmaps/doom/BOSSB3B7.png new file mode 100644 index 000000000..dd8da7d8a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSB3B7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSB4B6.png b/wadsrc_bm/static/brightmaps/doom/BOSSB4B6.png new file mode 100644 index 000000000..112b5186c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSB4B6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSB5.png b/wadsrc_bm/static/brightmaps/doom/BOSSB5.png new file mode 100644 index 000000000..1bc1154c3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSB5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSC1.png b/wadsrc_bm/static/brightmaps/doom/BOSSC1.png new file mode 100644 index 000000000..c1bb118fa Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSC1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSC2C8.png b/wadsrc_bm/static/brightmaps/doom/BOSSC2C8.png new file mode 100644 index 000000000..c9fee8d0d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSC2C8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSC3C7.png b/wadsrc_bm/static/brightmaps/doom/BOSSC3C7.png new file mode 100644 index 000000000..b93cacc81 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSC3C7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSC4C6.png b/wadsrc_bm/static/brightmaps/doom/BOSSC4C6.png new file mode 100644 index 000000000..6b3ff0cdf Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSC4C6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSC5.png b/wadsrc_bm/static/brightmaps/doom/BOSSC5.png new file mode 100644 index 000000000..0f1d38618 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSC5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSD1.png b/wadsrc_bm/static/brightmaps/doom/BOSSD1.png new file mode 100644 index 000000000..8ed579c9c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSD1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSD2D8.png b/wadsrc_bm/static/brightmaps/doom/BOSSD2D8.png new file mode 100644 index 000000000..afa335e0c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSD2D8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSD3D7.png b/wadsrc_bm/static/brightmaps/doom/BOSSD3D7.png new file mode 100644 index 000000000..7fafce06e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSD3D7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSD4D6.png b/wadsrc_bm/static/brightmaps/doom/BOSSD4D6.png new file mode 100644 index 000000000..296b5a80a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSD4D6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSD5.png b/wadsrc_bm/static/brightmaps/doom/BOSSD5.png new file mode 100644 index 000000000..0468e12e2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSD5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE1.png b/wadsrc_bm/static/brightmaps/doom/BOSSE1.png new file mode 100644 index 000000000..cc3c407c6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSE1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE2.png b/wadsrc_bm/static/brightmaps/doom/BOSSE2.png new file mode 100644 index 000000000..31837cc6c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSE2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE3.png b/wadsrc_bm/static/brightmaps/doom/BOSSE3.png new file mode 100644 index 000000000..6dde651c7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSE3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE4.png b/wadsrc_bm/static/brightmaps/doom/BOSSE4.png new file mode 100644 index 000000000..8ffaed4bd Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSE4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE5.png b/wadsrc_bm/static/brightmaps/doom/BOSSE5.png new file mode 100644 index 000000000..e5bca33a3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSE5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE6.png b/wadsrc_bm/static/brightmaps/doom/BOSSE6.png new file mode 100644 index 000000000..fd6b669da Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSE6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE7.png b/wadsrc_bm/static/brightmaps/doom/BOSSE7.png new file mode 100644 index 000000000..4a9e0a653 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSE7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSE8.png b/wadsrc_bm/static/brightmaps/doom/BOSSE8.png new file mode 100644 index 000000000..d8be17d60 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSE8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF1.png b/wadsrc_bm/static/brightmaps/doom/BOSSF1.png new file mode 100644 index 000000000..7667a456a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSF1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF2.png b/wadsrc_bm/static/brightmaps/doom/BOSSF2.png new file mode 100644 index 000000000..1884c9cb9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSF2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF3.png b/wadsrc_bm/static/brightmaps/doom/BOSSF3.png new file mode 100644 index 000000000..f6b72649a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSF3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF4.png b/wadsrc_bm/static/brightmaps/doom/BOSSF4.png new file mode 100644 index 000000000..10c4a6e4b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSF4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF5.png b/wadsrc_bm/static/brightmaps/doom/BOSSF5.png new file mode 100644 index 000000000..8719121f8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSF5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF6.png b/wadsrc_bm/static/brightmaps/doom/BOSSF6.png new file mode 100644 index 000000000..7bc73a47e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSF6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF7.png b/wadsrc_bm/static/brightmaps/doom/BOSSF7.png new file mode 100644 index 000000000..71826d440 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSF7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSF8.png b/wadsrc_bm/static/brightmaps/doom/BOSSF8.png new file mode 100644 index 000000000..70af4c02b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSF8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG1.png b/wadsrc_bm/static/brightmaps/doom/BOSSG1.png new file mode 100644 index 000000000..f3ee59a1c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSG1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG2.png b/wadsrc_bm/static/brightmaps/doom/BOSSG2.png new file mode 100644 index 000000000..fc735a9cb Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSG2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG3.png b/wadsrc_bm/static/brightmaps/doom/BOSSG3.png new file mode 100644 index 000000000..8d74f0cdf Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSG3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG4.png b/wadsrc_bm/static/brightmaps/doom/BOSSG4.png new file mode 100644 index 000000000..4cb2a3f96 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSG4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG5.png b/wadsrc_bm/static/brightmaps/doom/BOSSG5.png new file mode 100644 index 000000000..cc9150430 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSG5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG6.png b/wadsrc_bm/static/brightmaps/doom/BOSSG6.png new file mode 100644 index 000000000..df682c071 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSG6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG7.png b/wadsrc_bm/static/brightmaps/doom/BOSSG7.png new file mode 100644 index 000000000..90010e2df Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSG7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSG8.png b/wadsrc_bm/static/brightmaps/doom/BOSSG8.png new file mode 100644 index 000000000..d2a412042 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSG8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH1.png b/wadsrc_bm/static/brightmaps/doom/BOSSH1.png new file mode 100644 index 000000000..bd4fbfe56 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSH1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH2.png b/wadsrc_bm/static/brightmaps/doom/BOSSH2.png new file mode 100644 index 000000000..dc93c8f70 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSH2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH3.png b/wadsrc_bm/static/brightmaps/doom/BOSSH3.png new file mode 100644 index 000000000..b94e1bb1a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSH3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH4.png b/wadsrc_bm/static/brightmaps/doom/BOSSH4.png new file mode 100644 index 000000000..ce03a828f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSH4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH5.png b/wadsrc_bm/static/brightmaps/doom/BOSSH5.png new file mode 100644 index 000000000..d3765c7c6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSH5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH6.png b/wadsrc_bm/static/brightmaps/doom/BOSSH6.png new file mode 100644 index 000000000..13939f984 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSH6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH7.png b/wadsrc_bm/static/brightmaps/doom/BOSSH7.png new file mode 100644 index 000000000..4061dc2e9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSH7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSH8.png b/wadsrc_bm/static/brightmaps/doom/BOSSH8.png new file mode 100644 index 000000000..55e98eaf0 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSH8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSI0.png b/wadsrc_bm/static/brightmaps/doom/BOSSI0.png new file mode 100644 index 000000000..8626bba21 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSI0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSJ0.png b/wadsrc_bm/static/brightmaps/doom/BOSSJ0.png new file mode 100644 index 000000000..0fd48d816 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSJ0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSK0.png b/wadsrc_bm/static/brightmaps/doom/BOSSK0.png new file mode 100644 index 000000000..0a4809b98 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSK0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSL0.png b/wadsrc_bm/static/brightmaps/doom/BOSSL0.png new file mode 100644 index 000000000..1950c21ff Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSL0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BOSSM0.png b/wadsrc_bm/static/brightmaps/doom/BOSSM0.png new file mode 100644 index 000000000..73f7971c9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BOSSM0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIG1.png b/wadsrc_bm/static/brightmaps/doom/BSPIG1.png new file mode 100644 index 000000000..034ec03d8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BSPIG1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIG2G8.png b/wadsrc_bm/static/brightmaps/doom/BSPIG2G8.png new file mode 100644 index 000000000..937b8b1cb Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BSPIG2G8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIH1.png b/wadsrc_bm/static/brightmaps/doom/BSPIH1.png new file mode 100644 index 000000000..4e3625aa2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BSPIH1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIH2H8.png b/wadsrc_bm/static/brightmaps/doom/BSPIH2H8.png new file mode 100644 index 000000000..6e270f2c8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BSPIH2H8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIH3H7.png b/wadsrc_bm/static/brightmaps/doom/BSPIH3H7.png new file mode 100644 index 000000000..4ff61708f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BSPIH3H7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIH4H6.png b/wadsrc_bm/static/brightmaps/doom/BSPIH4H6.png new file mode 100644 index 000000000..1813d9689 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BSPIH4H6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/BSPIH5.png b/wadsrc_bm/static/brightmaps/doom/BSPIH5.png new file mode 100644 index 000000000..a3c97ea8c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/BSPIH5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CELLA0.png b/wadsrc_bm/static/brightmaps/doom/CELLA0.png new file mode 100644 index 000000000..f06e3d3d7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CELLA0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CELPA0.png b/wadsrc_bm/static/brightmaps/doom/CELPA0.png new file mode 100644 index 000000000..5b6486c8b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CELPA0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE1.png b/wadsrc_bm/static/brightmaps/doom/CPOSE1.png new file mode 100644 index 000000000..437c2a463 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSE1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE2.png b/wadsrc_bm/static/brightmaps/doom/CPOSE2.png new file mode 100644 index 000000000..9597368cf Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSE2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE3.png b/wadsrc_bm/static/brightmaps/doom/CPOSE3.png new file mode 100644 index 000000000..c443441c1 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSE3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE5.png b/wadsrc_bm/static/brightmaps/doom/CPOSE5.png new file mode 100644 index 000000000..a01147e6e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSE5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE6.png b/wadsrc_bm/static/brightmaps/doom/CPOSE6.png new file mode 100644 index 000000000..61eda1af7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSE6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE7.png b/wadsrc_bm/static/brightmaps/doom/CPOSE7.png new file mode 100644 index 000000000..587d4f62f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSE7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSE8.png b/wadsrc_bm/static/brightmaps/doom/CPOSE8.png new file mode 100644 index 000000000..692601735 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSE8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF1.png b/wadsrc_bm/static/brightmaps/doom/CPOSF1.png new file mode 100644 index 000000000..a445fff92 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSF1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF2.png b/wadsrc_bm/static/brightmaps/doom/CPOSF2.png new file mode 100644 index 000000000..4a5eb267c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSF2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF3.png b/wadsrc_bm/static/brightmaps/doom/CPOSF3.png new file mode 100644 index 000000000..b545edbb2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSF3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF4.png b/wadsrc_bm/static/brightmaps/doom/CPOSF4.png new file mode 100644 index 000000000..50c3c135d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSF4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF5.png b/wadsrc_bm/static/brightmaps/doom/CPOSF5.png new file mode 100644 index 000000000..f9e53d24f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSF5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF6.png b/wadsrc_bm/static/brightmaps/doom/CPOSF6.png new file mode 100644 index 000000000..574378a25 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSF6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF7.png b/wadsrc_bm/static/brightmaps/doom/CPOSF7.png new file mode 100644 index 000000000..14e4c5681 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSF7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CPOSF8.png b/wadsrc_bm/static/brightmaps/doom/CPOSF8.png new file mode 100644 index 000000000..e80c306a1 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CPOSF8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRF1.png b/wadsrc_bm/static/brightmaps/doom/CYBRF1.png new file mode 100644 index 000000000..e97a94f17 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRF1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRF2.png b/wadsrc_bm/static/brightmaps/doom/CYBRF2.png new file mode 100644 index 000000000..886e5b20d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRF2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRF3.png b/wadsrc_bm/static/brightmaps/doom/CYBRF3.png new file mode 100644 index 000000000..ea6ccde8e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRF3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRF4.png b/wadsrc_bm/static/brightmaps/doom/CYBRF4.png new file mode 100644 index 000000000..d53db24cd Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRF4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRF5.png b/wadsrc_bm/static/brightmaps/doom/CYBRF5.png new file mode 100644 index 000000000..959741072 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRF5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRF6.png b/wadsrc_bm/static/brightmaps/doom/CYBRF6.png new file mode 100644 index 000000000..bd4574a19 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRF6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRF7.png b/wadsrc_bm/static/brightmaps/doom/CYBRF7.png new file mode 100644 index 000000000..78dcba173 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRF7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRF8.png b/wadsrc_bm/static/brightmaps/doom/CYBRF8.png new file mode 100644 index 000000000..549050d2b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRF8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRJ0.png b/wadsrc_bm/static/brightmaps/doom/CYBRJ0.png new file mode 100644 index 000000000..40845cc73 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRJ0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRK0.png b/wadsrc_bm/static/brightmaps/doom/CYBRK0.png new file mode 100644 index 000000000..5eabd6c17 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRK0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRL0.png b/wadsrc_bm/static/brightmaps/doom/CYBRL0.png new file mode 100644 index 000000000..2a542c685 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRL0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRM0.png b/wadsrc_bm/static/brightmaps/doom/CYBRM0.png new file mode 100644 index 000000000..ffe528adb Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRM0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRN0.png b/wadsrc_bm/static/brightmaps/doom/CYBRN0.png new file mode 100644 index 000000000..0b5760b4a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRN0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/CYBRO0.png b/wadsrc_bm/static/brightmaps/doom/CYBRO0.png new file mode 100644 index 000000000..8b52093c3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/CYBRO0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/FATTG1.png b/wadsrc_bm/static/brightmaps/doom/FATTG1.png new file mode 100644 index 000000000..bce6010b7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/FATTG1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/FATTG2G8.png b/wadsrc_bm/static/brightmaps/doom/FATTG2G8.png new file mode 100644 index 000000000..06b82243f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/FATTG2G8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/FATTH1.png b/wadsrc_bm/static/brightmaps/doom/FATTH1.png new file mode 100644 index 000000000..e22d536f9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/FATTH1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/FATTH2H8.png b/wadsrc_bm/static/brightmaps/doom/FATTH2H8.png new file mode 100644 index 000000000..c6a763f1a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/FATTH2H8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/FATTH3H7.png b/wadsrc_bm/static/brightmaps/doom/FATTH3H7.png new file mode 100644 index 000000000..1b7ca4c67 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/FATTH3H7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/FATTH4H6.png b/wadsrc_bm/static/brightmaps/doom/FATTH4H6.png new file mode 100644 index 000000000..82fb052a1 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/FATTH4H6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/FATTH5.png b/wadsrc_bm/static/brightmaps/doom/FATTH5.png new file mode 100644 index 000000000..00ab9b984 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/FATTH5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/FCANA0.png b/wadsrc_bm/static/brightmaps/doom/FCANA0.png new file mode 100644 index 000000000..3cb6b9d5b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/FCANA0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/FCANB0.png b/wadsrc_bm/static/brightmaps/doom/FCANB0.png new file mode 100644 index 000000000..c4ad1484f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/FCANB0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/FCANC0.png b/wadsrc_bm/static/brightmaps/doom/FCANC0.png new file mode 100644 index 000000000..7b430607c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/FCANC0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/HEADC1.png b/wadsrc_bm/static/brightmaps/doom/HEADC1.png new file mode 100644 index 000000000..81fe3e7c6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/HEADC1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/HEADC2C8.png b/wadsrc_bm/static/brightmaps/doom/HEADC2C8.png new file mode 100644 index 000000000..d4fe4df87 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/HEADC2C8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/HEADC3C7.png b/wadsrc_bm/static/brightmaps/doom/HEADC3C7.png new file mode 100644 index 000000000..4dd996ca3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/HEADC3C7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/HEADD1.png b/wadsrc_bm/static/brightmaps/doom/HEADD1.png new file mode 100644 index 000000000..43c2b9820 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/HEADD1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/HEADD2D8.png b/wadsrc_bm/static/brightmaps/doom/HEADD2D8.png new file mode 100644 index 000000000..5bd6655bb Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/HEADD2D8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/HEADD3D7.png b/wadsrc_bm/static/brightmaps/doom/HEADD3D7.png new file mode 100644 index 000000000..12862b89e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/HEADD3D7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/PAINF1.png b/wadsrc_bm/static/brightmaps/doom/PAINF1.png new file mode 100644 index 000000000..26e4486c8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/PAINF1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/PAINF2F8.png b/wadsrc_bm/static/brightmaps/doom/PAINF2F8.png new file mode 100644 index 000000000..dbb5277eb Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/PAINF2F8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/PAINF3F7.png b/wadsrc_bm/static/brightmaps/doom/PAINF3F7.png new file mode 100644 index 000000000..044b88aa9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/PAINF3F7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/PLAYF1.png b/wadsrc_bm/static/brightmaps/doom/PLAYF1.png new file mode 100644 index 000000000..f3f83fe8e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/PLAYF1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/PLAYF2F8.png b/wadsrc_bm/static/brightmaps/doom/PLAYF2F8.png new file mode 100644 index 000000000..d7e948c55 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/PLAYF2F8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/PLAYF3F7.png b/wadsrc_bm/static/brightmaps/doom/PLAYF3F7.png new file mode 100644 index 000000000..8e1616cf6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/PLAYF3F7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/PLAYF4F6.png b/wadsrc_bm/static/brightmaps/doom/PLAYF4F6.png new file mode 100644 index 000000000..9def391d7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/PLAYF4F6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/PLAYF5.png b/wadsrc_bm/static/brightmaps/doom/PLAYF5.png new file mode 100644 index 000000000..520a9abfa Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/PLAYF5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/POSSE1.png b/wadsrc_bm/static/brightmaps/doom/POSSE1.png new file mode 100644 index 000000000..5983ef59d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/POSSE1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/POSSE2E8.png b/wadsrc_bm/static/brightmaps/doom/POSSE2E8.png new file mode 100644 index 000000000..65c4056ae Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/POSSE2E8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/POSSE3E7.png b/wadsrc_bm/static/brightmaps/doom/POSSE3E7.png new file mode 100644 index 000000000..464bb94dc Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/POSSE3E7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/POSSF1.png b/wadsrc_bm/static/brightmaps/doom/POSSF1.png new file mode 100644 index 000000000..fe2a07221 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/POSSF1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/POSSF2F8.png b/wadsrc_bm/static/brightmaps/doom/POSSF2F8.png new file mode 100644 index 000000000..0ecd256bc Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/POSSF2F8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/POSSF3F7.png b/wadsrc_bm/static/brightmaps/doom/POSSF3F7.png new file mode 100644 index 000000000..07d202c18 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/POSSF3F7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/POSSF4F6.png b/wadsrc_bm/static/brightmaps/doom/POSSF4F6.png new file mode 100644 index 000000000..bc5fb14f9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/POSSF4F6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/POSSF5.png b/wadsrc_bm/static/brightmaps/doom/POSSF5.png new file mode 100644 index 000000000..5ca4b3169 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/POSSF5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SKELJ1.png b/wadsrc_bm/static/brightmaps/doom/SKELJ1.png new file mode 100644 index 000000000..82db405af Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SKELJ1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SKELJ2.png b/wadsrc_bm/static/brightmaps/doom/SKELJ2.png new file mode 100644 index 000000000..8bef7b58a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SKELJ2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SKELJ3.png b/wadsrc_bm/static/brightmaps/doom/SKELJ3.png new file mode 100644 index 000000000..ac551476b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SKELJ3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SKELJ4.png b/wadsrc_bm/static/brightmaps/doom/SKELJ4.png new file mode 100644 index 000000000..84d839a06 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SKELJ4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SKELJ5.png b/wadsrc_bm/static/brightmaps/doom/SKELJ5.png new file mode 100644 index 000000000..bdc5efc3f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SKELJ5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SKELJ6.png b/wadsrc_bm/static/brightmaps/doom/SKELJ6.png new file mode 100644 index 000000000..a16d9853b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SKELJ6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SKELJ7.png b/wadsrc_bm/static/brightmaps/doom/SKELJ7.png new file mode 100644 index 000000000..9e8e4912d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SKELJ7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SKELJ8.png b/wadsrc_bm/static/brightmaps/doom/SKELJ8.png new file mode 100644 index 000000000..333bd678b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SKELJ8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SMRTA0.png b/wadsrc_bm/static/brightmaps/doom/SMRTA0.png new file mode 100644 index 000000000..49867963e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SMRTA0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SMRTB0.png b/wadsrc_bm/static/brightmaps/doom/SMRTB0.png new file mode 100644 index 000000000..e6291b8f5 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SMRTB0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SMRTC0.png b/wadsrc_bm/static/brightmaps/doom/SMRTC0.png new file mode 100644 index 000000000..4b7bb5f51 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SMRTC0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SMRTD0.png b/wadsrc_bm/static/brightmaps/doom/SMRTD0.png new file mode 100644 index 000000000..f6d611491 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SMRTD0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDG1.png b/wadsrc_bm/static/brightmaps/doom/SPIDG1.png new file mode 100644 index 000000000..5bee5c0b7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDG1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDG2G8.png b/wadsrc_bm/static/brightmaps/doom/SPIDG2G8.png new file mode 100644 index 000000000..0075bc06b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDG2G8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDH1.png b/wadsrc_bm/static/brightmaps/doom/SPIDH1.png new file mode 100644 index 000000000..e7d0756fa Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDH1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDH2H8.png b/wadsrc_bm/static/brightmaps/doom/SPIDH2H8.png new file mode 100644 index 000000000..1a36d14bc Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDH2H8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDH3H7.png b/wadsrc_bm/static/brightmaps/doom/SPIDH3H7.png new file mode 100644 index 000000000..654313cfa Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDH3H7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDL0.png b/wadsrc_bm/static/brightmaps/doom/SPIDL0.png new file mode 100644 index 000000000..53c899c38 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDL0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDM0.png b/wadsrc_bm/static/brightmaps/doom/SPIDM0.png new file mode 100644 index 000000000..d9fbea53f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDM0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDN0.png b/wadsrc_bm/static/brightmaps/doom/SPIDN0.png new file mode 100644 index 000000000..3d40b9a09 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDN0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDO0.png b/wadsrc_bm/static/brightmaps/doom/SPIDO0.png new file mode 100644 index 000000000..0273fe6aa Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDO0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDP0.png b/wadsrc_bm/static/brightmaps/doom/SPIDP0.png new file mode 100644 index 000000000..addf14464 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDP0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDQ0.png b/wadsrc_bm/static/brightmaps/doom/SPIDQ0.png new file mode 100644 index 000000000..954f6061f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDQ0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPIDR0.png b/wadsrc_bm/static/brightmaps/doom/SPIDR0.png new file mode 100644 index 000000000..02b299b15 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPIDR0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSE1.png b/wadsrc_bm/static/brightmaps/doom/SPOSE1.png new file mode 100644 index 000000000..5983ef59d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPOSE1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSE2E8.png b/wadsrc_bm/static/brightmaps/doom/SPOSE2E8.png new file mode 100644 index 000000000..ddbb00da2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPOSE2E8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSE3E7.png b/wadsrc_bm/static/brightmaps/doom/SPOSE3E7.png new file mode 100644 index 000000000..527486c47 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPOSE3E7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSF1.png b/wadsrc_bm/static/brightmaps/doom/SPOSF1.png new file mode 100644 index 000000000..ba6a74c07 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPOSF1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSF2F8.png b/wadsrc_bm/static/brightmaps/doom/SPOSF2F8.png new file mode 100644 index 000000000..e42e83b01 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPOSF2F8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSF3F7.png b/wadsrc_bm/static/brightmaps/doom/SPOSF3F7.png new file mode 100644 index 000000000..ff1e66f9f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPOSF3F7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSF4F6.png b/wadsrc_bm/static/brightmaps/doom/SPOSF4F6.png new file mode 100644 index 000000000..d8445c71d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPOSF4F6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/SPOSF5.png b/wadsrc_bm/static/brightmaps/doom/SPOSF5.png new file mode 100644 index 000000000..2fdf53286 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/SPOSF5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/TREDA0.png b/wadsrc_bm/static/brightmaps/doom/TREDA0.png new file mode 100644 index 000000000..d7318f94a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/TREDA0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/TREDB0.png b/wadsrc_bm/static/brightmaps/doom/TREDB0.png new file mode 100644 index 000000000..15ba5a665 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/TREDB0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/TREDC0.png b/wadsrc_bm/static/brightmaps/doom/TREDC0.png new file mode 100644 index 000000000..47842aa3f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/TREDC0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/TREDD0.png b/wadsrc_bm/static/brightmaps/doom/TREDD0.png new file mode 100644 index 000000000..f4cb483b8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/TREDD0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/TbluB0.png b/wadsrc_bm/static/brightmaps/doom/TbluB0.png new file mode 100644 index 000000000..6d020512c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/TbluB0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/TbluC0.png b/wadsrc_bm/static/brightmaps/doom/TbluC0.png new file mode 100644 index 000000000..e1771d71c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/TbluC0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/sswvg0.png b/wadsrc_bm/static/brightmaps/doom/sswvg0.png new file mode 100644 index 000000000..904092f8d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/sswvg0.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileg1.png b/wadsrc_bm/static/brightmaps/doom/vileg1.png new file mode 100644 index 000000000..c02f31d78 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileg1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileg2.png b/wadsrc_bm/static/brightmaps/doom/vileg2.png new file mode 100644 index 000000000..979863d54 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileg2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileg3.png b/wadsrc_bm/static/brightmaps/doom/vileg3.png new file mode 100644 index 000000000..3646c90bc Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileg3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileg4.png b/wadsrc_bm/static/brightmaps/doom/vileg4.png new file mode 100644 index 000000000..26bac2477 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileg4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileg5.png b/wadsrc_bm/static/brightmaps/doom/vileg5.png new file mode 100644 index 000000000..1f0b75a99 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileg5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileg6.png b/wadsrc_bm/static/brightmaps/doom/vileg6.png new file mode 100644 index 000000000..7412bf595 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileg6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileg7.png b/wadsrc_bm/static/brightmaps/doom/vileg7.png new file mode 100644 index 000000000..b98488d1f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileg7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileg8.png b/wadsrc_bm/static/brightmaps/doom/vileg8.png new file mode 100644 index 000000000..440e189c0 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileg8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileh1.png b/wadsrc_bm/static/brightmaps/doom/vileh1.png new file mode 100644 index 000000000..713a2204a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileh1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileh2.png b/wadsrc_bm/static/brightmaps/doom/vileh2.png new file mode 100644 index 000000000..606f1dc2e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileh2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileh3.png b/wadsrc_bm/static/brightmaps/doom/vileh3.png new file mode 100644 index 000000000..cf5d27d53 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileh3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileh4.png b/wadsrc_bm/static/brightmaps/doom/vileh4.png new file mode 100644 index 000000000..60bd8a14b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileh4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileh5.png b/wadsrc_bm/static/brightmaps/doom/vileh5.png new file mode 100644 index 000000000..db2dd8d2a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileh5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileh6.png b/wadsrc_bm/static/brightmaps/doom/vileh6.png new file mode 100644 index 000000000..3c776f987 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileh6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileh7.png b/wadsrc_bm/static/brightmaps/doom/vileh7.png new file mode 100644 index 000000000..e8818101a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileh7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileh8.png b/wadsrc_bm/static/brightmaps/doom/vileh8.png new file mode 100644 index 000000000..9078b7fe2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileh8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilei1.png b/wadsrc_bm/static/brightmaps/doom/vilei1.png new file mode 100644 index 000000000..ca8d54001 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilei1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilei2.png b/wadsrc_bm/static/brightmaps/doom/vilei2.png new file mode 100644 index 000000000..a76359f33 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilei2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilei3.png b/wadsrc_bm/static/brightmaps/doom/vilei3.png new file mode 100644 index 000000000..5ec97664a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilei3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilei4.png b/wadsrc_bm/static/brightmaps/doom/vilei4.png new file mode 100644 index 000000000..99fa6dbb3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilei4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilei5.png b/wadsrc_bm/static/brightmaps/doom/vilei5.png new file mode 100644 index 000000000..34b260006 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilei5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilei6.png b/wadsrc_bm/static/brightmaps/doom/vilei6.png new file mode 100644 index 000000000..435fe6f31 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilei6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilei7.png b/wadsrc_bm/static/brightmaps/doom/vilei7.png new file mode 100644 index 000000000..b362c411f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilei7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilei8.png b/wadsrc_bm/static/brightmaps/doom/vilei8.png new file mode 100644 index 000000000..6dd3d603f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilei8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilej1.png b/wadsrc_bm/static/brightmaps/doom/vilej1.png new file mode 100644 index 000000000..3a8b234a9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilej1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilej2.png b/wadsrc_bm/static/brightmaps/doom/vilej2.png new file mode 100644 index 000000000..ed42c147d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilej2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilej3.png b/wadsrc_bm/static/brightmaps/doom/vilej3.png new file mode 100644 index 000000000..f9e45f1ce Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilej3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilej4.png b/wadsrc_bm/static/brightmaps/doom/vilej4.png new file mode 100644 index 000000000..2c35d4aa0 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilej4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilej5.png b/wadsrc_bm/static/brightmaps/doom/vilej5.png new file mode 100644 index 000000000..40da621d2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilej5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilej6.png b/wadsrc_bm/static/brightmaps/doom/vilej6.png new file mode 100644 index 000000000..ba3620ef6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilej6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilej7.png b/wadsrc_bm/static/brightmaps/doom/vilej7.png new file mode 100644 index 000000000..1b98db0c2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilej7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilej8.png b/wadsrc_bm/static/brightmaps/doom/vilej8.png new file mode 100644 index 000000000..1c4fc05e2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilej8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilek1.png b/wadsrc_bm/static/brightmaps/doom/vilek1.png new file mode 100644 index 000000000..204b6963f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilek1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilek2.png b/wadsrc_bm/static/brightmaps/doom/vilek2.png new file mode 100644 index 000000000..34dc1c6e3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilek2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilek3.png b/wadsrc_bm/static/brightmaps/doom/vilek3.png new file mode 100644 index 000000000..c24152dc6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilek3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilek4.png b/wadsrc_bm/static/brightmaps/doom/vilek4.png new file mode 100644 index 000000000..268241dd6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilek4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilek5.png b/wadsrc_bm/static/brightmaps/doom/vilek5.png new file mode 100644 index 000000000..a2d742dee Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilek5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilek6.png b/wadsrc_bm/static/brightmaps/doom/vilek6.png new file mode 100644 index 000000000..025d95c3a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilek6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilek7.png b/wadsrc_bm/static/brightmaps/doom/vilek7.png new file mode 100644 index 000000000..cadd45a67 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilek7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilek8.png b/wadsrc_bm/static/brightmaps/doom/vilek8.png new file mode 100644 index 000000000..f3a79e724 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilek8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilel1.png b/wadsrc_bm/static/brightmaps/doom/vilel1.png new file mode 100644 index 000000000..fbfd4fe44 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilel1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilel2.png b/wadsrc_bm/static/brightmaps/doom/vilel2.png new file mode 100644 index 000000000..7e5b9946e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilel2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilel3.png b/wadsrc_bm/static/brightmaps/doom/vilel3.png new file mode 100644 index 000000000..f949c0812 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilel3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilel4.png b/wadsrc_bm/static/brightmaps/doom/vilel4.png new file mode 100644 index 000000000..3d8912874 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilel4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilel5.png b/wadsrc_bm/static/brightmaps/doom/vilel5.png new file mode 100644 index 000000000..93289dcb8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilel5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilel6.png b/wadsrc_bm/static/brightmaps/doom/vilel6.png new file mode 100644 index 000000000..63efe375f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilel6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilel7.png b/wadsrc_bm/static/brightmaps/doom/vilel7.png new file mode 100644 index 000000000..d89739cd6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilel7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilel8.png b/wadsrc_bm/static/brightmaps/doom/vilel8.png new file mode 100644 index 000000000..eebf5c454 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilel8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilem1.png b/wadsrc_bm/static/brightmaps/doom/vilem1.png new file mode 100644 index 000000000..bf90c37ae Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilem1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilem2.png b/wadsrc_bm/static/brightmaps/doom/vilem2.png new file mode 100644 index 000000000..b99e00cbe Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilem2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilem3.png b/wadsrc_bm/static/brightmaps/doom/vilem3.png new file mode 100644 index 000000000..8440e7dd6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilem3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilem4.png b/wadsrc_bm/static/brightmaps/doom/vilem4.png new file mode 100644 index 000000000..c2c5f9e46 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilem4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilem5.png b/wadsrc_bm/static/brightmaps/doom/vilem5.png new file mode 100644 index 000000000..08fa83dbd Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilem5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilem6.png b/wadsrc_bm/static/brightmaps/doom/vilem6.png new file mode 100644 index 000000000..436c98271 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilem6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilem7.png b/wadsrc_bm/static/brightmaps/doom/vilem7.png new file mode 100644 index 000000000..04c3f875a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilem7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilem8.png b/wadsrc_bm/static/brightmaps/doom/vilem8.png new file mode 100644 index 000000000..9e4b78505 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilem8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilen1.png b/wadsrc_bm/static/brightmaps/doom/vilen1.png new file mode 100644 index 000000000..e69819c77 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilen1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilen2.png b/wadsrc_bm/static/brightmaps/doom/vilen2.png new file mode 100644 index 000000000..1979d5b76 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilen2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilen3.png b/wadsrc_bm/static/brightmaps/doom/vilen3.png new file mode 100644 index 000000000..8a9e3c5d9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilen3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilen4.png b/wadsrc_bm/static/brightmaps/doom/vilen4.png new file mode 100644 index 000000000..1f8dd401f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilen4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilen5.png b/wadsrc_bm/static/brightmaps/doom/vilen5.png new file mode 100644 index 000000000..616209e86 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilen5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilen6.png b/wadsrc_bm/static/brightmaps/doom/vilen6.png new file mode 100644 index 000000000..99418df5c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilen6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilen7.png b/wadsrc_bm/static/brightmaps/doom/vilen7.png new file mode 100644 index 000000000..90fd7c9d0 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilen7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilen8.png b/wadsrc_bm/static/brightmaps/doom/vilen8.png new file mode 100644 index 000000000..4ba737c78 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilen8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileo1.png b/wadsrc_bm/static/brightmaps/doom/vileo1.png new file mode 100644 index 000000000..ec07c2461 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileo1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileo2.png b/wadsrc_bm/static/brightmaps/doom/vileo2.png new file mode 100644 index 000000000..375580791 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileo2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileo3.png b/wadsrc_bm/static/brightmaps/doom/vileo3.png new file mode 100644 index 000000000..365592a37 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileo3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileo4.png b/wadsrc_bm/static/brightmaps/doom/vileo4.png new file mode 100644 index 000000000..ef7d2bf8b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileo4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileo5.png b/wadsrc_bm/static/brightmaps/doom/vileo5.png new file mode 100644 index 000000000..7c0339697 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileo5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileo6.png b/wadsrc_bm/static/brightmaps/doom/vileo6.png new file mode 100644 index 000000000..83fb00eed Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileo6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileo7.png b/wadsrc_bm/static/brightmaps/doom/vileo7.png new file mode 100644 index 000000000..9deff5dcc Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileo7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vileo8.png b/wadsrc_bm/static/brightmaps/doom/vileo8.png new file mode 100644 index 000000000..e5097856a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vileo8.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilep1.png b/wadsrc_bm/static/brightmaps/doom/vilep1.png new file mode 100644 index 000000000..28162cc1d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilep1.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilep2.png b/wadsrc_bm/static/brightmaps/doom/vilep2.png new file mode 100644 index 000000000..c2dc72c6e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilep2.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilep3.png b/wadsrc_bm/static/brightmaps/doom/vilep3.png new file mode 100644 index 000000000..20e2d96c3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilep3.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilep4.png b/wadsrc_bm/static/brightmaps/doom/vilep4.png new file mode 100644 index 000000000..2aaaf49a9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilep4.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilep5.png b/wadsrc_bm/static/brightmaps/doom/vilep5.png new file mode 100644 index 000000000..8aac2d406 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilep5.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilep6.png b/wadsrc_bm/static/brightmaps/doom/vilep6.png new file mode 100644 index 000000000..cce3301a9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilep6.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilep7.png b/wadsrc_bm/static/brightmaps/doom/vilep7.png new file mode 100644 index 000000000..e159aeac0 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilep7.png differ diff --git a/wadsrc_bm/static/brightmaps/doom/vilep8.png b/wadsrc_bm/static/brightmaps/doom/vilep8.png new file mode 100644 index 000000000..71d88866b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/doom/vilep8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/BEASI1.png b/wadsrc_bm/static/brightmaps/heretic/BEASI1.png new file mode 100644 index 000000000..0a19b43b8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/BEASI1.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/BEASI2I8.png b/wadsrc_bm/static/brightmaps/heretic/BEASI2I8.png new file mode 100644 index 000000000..187cbb346 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/BEASI2I8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/BEASI3I7.png b/wadsrc_bm/static/brightmaps/heretic/BEASI3I7.png new file mode 100644 index 000000000..d3d7b8f27 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/BEASI3I7.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/CHDLA0.png b/wadsrc_bm/static/brightmaps/heretic/CHDLA0.png new file mode 100644 index 000000000..41a0f6a88 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/CHDLA0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/CHDLB0.png b/wadsrc_bm/static/brightmaps/heretic/CHDLB0.png new file mode 100644 index 000000000..cf551809e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/CHDLB0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/CHDLC0.png b/wadsrc_bm/static/brightmaps/heretic/CHDLC0.png new file mode 100644 index 000000000..b881e8214 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/CHDLC0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/CLNKI0.png b/wadsrc_bm/static/brightmaps/heretic/CLNKI0.png new file mode 100644 index 000000000..782dec58f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/CLNKI0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/CLNKJ0.png b/wadsrc_bm/static/brightmaps/heretic/CLNKJ0.png new file mode 100644 index 000000000..3feb2be43 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/CLNKJ0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/CLNKK0.png b/wadsrc_bm/static/brightmaps/heretic/CLNKK0.png new file mode 100644 index 000000000..576a03682 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/CLNKK0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/CLNKL0.png b/wadsrc_bm/static/brightmaps/heretic/CLNKL0.png new file mode 100644 index 000000000..7ba9fbbab Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/CLNKL0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/CLNKM0.png b/wadsrc_bm/static/brightmaps/heretic/CLNKM0.png new file mode 100644 index 000000000..0cd0fd06b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/CLNKM0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/CLNKN0.png b/wadsrc_bm/static/brightmaps/heretic/CLNKN0.png new file mode 100644 index 000000000..89af9c1b5 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/CLNKN0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD1.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD1.png new file mode 100644 index 000000000..c96bc6c7d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXD1.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD2.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD2.png new file mode 100644 index 000000000..1f2befd89 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXD2.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD3.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD3.png new file mode 100644 index 000000000..db5360e2d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXD3.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD4.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD4.png new file mode 100644 index 000000000..8f0c4212e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXD4.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD5.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD5.png new file mode 100644 index 000000000..50fcfcd64 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXD5.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD6.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD6.png new file mode 100644 index 000000000..395ae0fb6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXD6.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD7.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD7.png new file mode 100644 index 000000000..e1362d4ff Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXD7.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXD8.png b/wadsrc_bm/static/brightmaps/heretic/IMPXD8.png new file mode 100644 index 000000000..df216ac7c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXD8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE1.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE1.png new file mode 100644 index 000000000..6adc110ce Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXE1.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE2.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE2.png new file mode 100644 index 000000000..518f9c1a7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXE2.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE3.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE3.png new file mode 100644 index 000000000..316c3ecc3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXE3.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE4.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE4.png new file mode 100644 index 000000000..959a5cfd2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXE4.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE5.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE5.png new file mode 100644 index 000000000..652b426de Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXE5.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE6.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE6.png new file mode 100644 index 000000000..b374b7be2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXE6.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE7.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE7.png new file mode 100644 index 000000000..96608c722 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXE7.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXE8.png b/wadsrc_bm/static/brightmaps/heretic/IMPXE8.png new file mode 100644 index 000000000..94b5f9507 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXE8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXF1.png b/wadsrc_bm/static/brightmaps/heretic/IMPXF1.png new file mode 100644 index 000000000..d6dfaebc9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXF1.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXF2.png b/wadsrc_bm/static/brightmaps/heretic/IMPXF2.png new file mode 100644 index 000000000..ee3934811 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXF2.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXF3.png b/wadsrc_bm/static/brightmaps/heretic/IMPXF3.png new file mode 100644 index 000000000..4ee0cf231 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXF3.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXF4.png b/wadsrc_bm/static/brightmaps/heretic/IMPXF4.png new file mode 100644 index 000000000..9344cf57d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXF4.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXF5.png b/wadsrc_bm/static/brightmaps/heretic/IMPXF5.png new file mode 100644 index 000000000..da598d4be Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXF5.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXF6.png b/wadsrc_bm/static/brightmaps/heretic/IMPXF6.png new file mode 100644 index 000000000..d22bf8942 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXF6.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXF7.png b/wadsrc_bm/static/brightmaps/heretic/IMPXF7.png new file mode 100644 index 000000000..13bc8ebb9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXF7.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/IMPXF8.png b/wadsrc_bm/static/brightmaps/heretic/IMPXF8.png new file mode 100644 index 000000000..03fc7c236 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/IMPXF8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHB1.png b/wadsrc_bm/static/brightmaps/heretic/LICHB1.png new file mode 100644 index 000000000..fc7d83921 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/LICHB1.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHB2B8.png b/wadsrc_bm/static/brightmaps/heretic/LICHB2B8.png new file mode 100644 index 000000000..a5e3565f7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/LICHB2B8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHB3B7.png b/wadsrc_bm/static/brightmaps/heretic/LICHB3B7.png new file mode 100644 index 000000000..0992e0e9a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/LICHB3B7.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHC0.png b/wadsrc_bm/static/brightmaps/heretic/LICHC0.png new file mode 100644 index 000000000..cc28951c0 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/LICHC0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHD0.png b/wadsrc_bm/static/brightmaps/heretic/LICHD0.png new file mode 100644 index 000000000..76679dbd1 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/LICHD0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHE0.png b/wadsrc_bm/static/brightmaps/heretic/LICHE0.png new file mode 100644 index 000000000..c00bf135f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/LICHE0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHF0.png b/wadsrc_bm/static/brightmaps/heretic/LICHF0.png new file mode 100644 index 000000000..065598a9d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/LICHF0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHG0.png b/wadsrc_bm/static/brightmaps/heretic/LICHG0.png new file mode 100644 index 000000000..9d707324e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/LICHG0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/LICHH0.png b/wadsrc_bm/static/brightmaps/heretic/LICHH0.png new file mode 100644 index 000000000..b2e39d506 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/LICHH0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/PLAYF1.png b/wadsrc_bm/static/brightmaps/heretic/PLAYF1.png new file mode 100644 index 000000000..c3c4817da Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/PLAYF1.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/PLAYF2F8.png b/wadsrc_bm/static/brightmaps/heretic/PLAYF2F8.png new file mode 100644 index 000000000..e42de9266 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/PLAYF2F8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/PLAYF3F7.png b/wadsrc_bm/static/brightmaps/heretic/PLAYF3F7.png new file mode 100644 index 000000000..8aae224ee Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/PLAYF3F7.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/PLAYF4F6.png b/wadsrc_bm/static/brightmaps/heretic/PLAYF4F6.png new file mode 100644 index 000000000..0b893064d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/PLAYF4F6.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHA0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHA0.png new file mode 100644 index 000000000..328c0363f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SDTHA0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHB0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHB0.png new file mode 100644 index 000000000..61b111e54 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SDTHB0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHC0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHC0.png new file mode 100644 index 000000000..9bbcffbde Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SDTHC0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHD0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHD0.png new file mode 100644 index 000000000..22a51d62d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SDTHD0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHE0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHE0.png new file mode 100644 index 000000000..acfa9c9a3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SDTHE0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHF0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHF0.png new file mode 100644 index 000000000..68c78cd7a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SDTHF0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHG0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHG0.png new file mode 100644 index 000000000..b43ad9dc2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SDTHG0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SDTHH0.png b/wadsrc_bm/static/brightmaps/heretic/SDTHH0.png new file mode 100644 index 000000000..c6393b551 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SDTHH0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R1.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R1.png new file mode 100644 index 000000000..a60cc15fc Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2R1.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R2.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R2.png new file mode 100644 index 000000000..e369c437f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2R2.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R3.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R3.png new file mode 100644 index 000000000..81e042385 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2R3.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R4.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R4.png new file mode 100644 index 000000000..d54a2dbcf Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2R4.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R5.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R5.png new file mode 100644 index 000000000..4fa0696eb Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2R5.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R6.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R6.png new file mode 100644 index 000000000..7ad493b16 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2R6.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R7.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R7.png new file mode 100644 index 000000000..ecc3e1cd4 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2R7.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2R8.png b/wadsrc_bm/static/brightmaps/heretic/SOR2R8.png new file mode 100644 index 000000000..6150dc46c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2R8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S1.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S1.png new file mode 100644 index 000000000..0365f4491 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2S1.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S2.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S2.png new file mode 100644 index 000000000..a5ab0c3a6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2S2.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S3.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S3.png new file mode 100644 index 000000000..c793d5712 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2S3.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S4.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S4.png new file mode 100644 index 000000000..bfc18a04d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2S4.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S5.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S5.png new file mode 100644 index 000000000..a32e46d6b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2S5.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S6.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S6.png new file mode 100644 index 000000000..b57ad7117 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2S6.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S7.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S7.png new file mode 100644 index 000000000..f73a05c19 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2S7.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2S8.png b/wadsrc_bm/static/brightmaps/heretic/SOR2S8.png new file mode 100644 index 000000000..708f81e25 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2S8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T1.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T1.png new file mode 100644 index 000000000..8c980b09f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2T1.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T2.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T2.png new file mode 100644 index 000000000..0eaa52c1d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2T2.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T3.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T3.png new file mode 100644 index 000000000..4a7519576 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2T3.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T4.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T4.png new file mode 100644 index 000000000..a77238767 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2T4.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T5.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T5.png new file mode 100644 index 000000000..0a6d72d3e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2T5.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T6.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T6.png new file mode 100644 index 000000000..3beb542fa Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2T6.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T7.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T7.png new file mode 100644 index 000000000..186715a3a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2T7.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/SOR2T8.png b/wadsrc_bm/static/brightmaps/heretic/SOR2T8.png new file mode 100644 index 000000000..58e7e87e2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/SOR2T8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/VLCOE0.png b/wadsrc_bm/static/brightmaps/heretic/VLCOE0.png new file mode 100644 index 000000000..b5058c570 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/VLCOE0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDC1.png b/wadsrc_bm/static/brightmaps/heretic/WZRDC1.png new file mode 100644 index 000000000..d4fb4ab47 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDC1.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDC2C8.png b/wadsrc_bm/static/brightmaps/heretic/WZRDC2C8.png new file mode 100644 index 000000000..8abe02262 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDC2C8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDC3C7.png b/wadsrc_bm/static/brightmaps/heretic/WZRDC3C7.png new file mode 100644 index 000000000..139467032 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDC3C7.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDC4C6.png b/wadsrc_bm/static/brightmaps/heretic/WZRDC4C6.png new file mode 100644 index 000000000..446272b65 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDC4C6.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDC5.png b/wadsrc_bm/static/brightmaps/heretic/WZRDC5.png new file mode 100644 index 000000000..d4fb4ab47 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDC5.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDD1.png b/wadsrc_bm/static/brightmaps/heretic/WZRDD1.png new file mode 100644 index 000000000..c516516dc Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDD1.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDD2D8.png b/wadsrc_bm/static/brightmaps/heretic/WZRDD2D8.png new file mode 100644 index 000000000..066954491 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDD2D8.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDD3D7.png b/wadsrc_bm/static/brightmaps/heretic/WZRDD3D7.png new file mode 100644 index 000000000..980e7286f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDD3D7.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDD4D6.png b/wadsrc_bm/static/brightmaps/heretic/WZRDD4D6.png new file mode 100644 index 000000000..b1ba1d202 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDD4D6.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDD5.png b/wadsrc_bm/static/brightmaps/heretic/WZRDD5.png new file mode 100644 index 000000000..7394eae62 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDD5.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDF0.png b/wadsrc_bm/static/brightmaps/heretic/WZRDF0.png new file mode 100644 index 000000000..c47019cb0 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDF0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDG0.png b/wadsrc_bm/static/brightmaps/heretic/WZRDG0.png new file mode 100644 index 000000000..92bfa5ce1 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDG0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDH0.png b/wadsrc_bm/static/brightmaps/heretic/WZRDH0.png new file mode 100644 index 000000000..e6518ce5a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDH0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDI0.png b/wadsrc_bm/static/brightmaps/heretic/WZRDI0.png new file mode 100644 index 000000000..1ccd71e26 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDI0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDJ0.png b/wadsrc_bm/static/brightmaps/heretic/WZRDJ0.png new file mode 100644 index 000000000..43a845620 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDJ0.png differ diff --git a/wadsrc_bm/static/brightmaps/heretic/WZRDK0.png b/wadsrc_bm/static/brightmaps/heretic/WZRDK0.png new file mode 100644 index 000000000..d5d52c473 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/heretic/WZRDK0.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/CDLRA0.png b/wadsrc_bm/static/brightmaps/hexen/CDLRA0.png new file mode 100644 index 000000000..b6dba0050 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/CDLRA0.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/CDLRB0.png b/wadsrc_bm/static/brightmaps/hexen/CDLRB0.png new file mode 100644 index 000000000..fd0a687ff Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/CDLRB0.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/CDLRC0.png b/wadsrc_bm/static/brightmaps/hexen/CDLRC0.png new file mode 100644 index 000000000..687106816 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/CDLRC0.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/CENTF1.png b/wadsrc_bm/static/brightmaps/hexen/CENTF1.png new file mode 100644 index 000000000..bce50ffe4 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/CENTF1.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/CENTF2.png b/wadsrc_bm/static/brightmaps/hexen/CENTF2.png new file mode 100644 index 000000000..23ba1876c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/CENTF2.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/CENTF8.png b/wadsrc_bm/static/brightmaps/hexen/CENTF8.png new file mode 100644 index 000000000..da9bdf69f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/CENTF8.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/ICEYG1.png b/wadsrc_bm/static/brightmaps/hexen/ICEYG1.png new file mode 100644 index 000000000..6a4e2cd01 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/ICEYG1.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/ICEYG2G8.png b/wadsrc_bm/static/brightmaps/hexen/ICEYG2G8.png new file mode 100644 index 000000000..3b18f61f9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/ICEYG2G8.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/ICEYG3G7.png b/wadsrc_bm/static/brightmaps/hexen/ICEYG3G7.png new file mode 100644 index 000000000..35927e629 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/ICEYG3G7.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/ICEYG4G6.png b/wadsrc_bm/static/brightmaps/hexen/ICEYG4G6.png new file mode 100644 index 000000000..a6f727182 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/ICEYG4G6.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/ICEYG5.png b/wadsrc_bm/static/brightmaps/hexen/ICEYG5.png new file mode 100644 index 000000000..b219d6853 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/ICEYG5.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF1.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF1.png new file mode 100644 index 000000000..fbfd6822e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/MAGEF1.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF2.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF2.png new file mode 100644 index 000000000..b7e617a20 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/MAGEF2.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF3.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF3.png new file mode 100644 index 000000000..3ca5f9f45 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/MAGEF3.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF4.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF4.png new file mode 100644 index 000000000..cb67cc179 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/MAGEF4.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF5.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF5.png new file mode 100644 index 000000000..55dcaf6a4 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/MAGEF5.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF6.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF6.png new file mode 100644 index 000000000..488808e50 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/MAGEF6.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF7.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF7.png new file mode 100644 index 000000000..b70f45e94 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/MAGEF7.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/MAGEF8.png b/wadsrc_bm/static/brightmaps/hexen/MAGEF8.png new file mode 100644 index 000000000..a55c5a0c7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/MAGEF8.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHE1.png b/wadsrc_bm/static/brightmaps/hexen/WRTHE1.png new file mode 100644 index 000000000..083ff7c73 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHE1.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHE2E8.png b/wadsrc_bm/static/brightmaps/hexen/WRTHE2E8.png new file mode 100644 index 000000000..c9c0e483c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHE2E8.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHE3E7.png b/wadsrc_bm/static/brightmaps/hexen/WRTHE3E7.png new file mode 100644 index 000000000..1f9772895 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHE3E7.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHE4E6.png b/wadsrc_bm/static/brightmaps/hexen/WRTHE4E6.png new file mode 100644 index 000000000..264a4c0df Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHE4E6.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHE5.png b/wadsrc_bm/static/brightmaps/hexen/WRTHE5.png new file mode 100644 index 000000000..53d504835 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHE5.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHF1.png b/wadsrc_bm/static/brightmaps/hexen/WRTHF1.png new file mode 100644 index 000000000..d29521070 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHF1.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHF2F8.png b/wadsrc_bm/static/brightmaps/hexen/WRTHF2F8.png new file mode 100644 index 000000000..afadf834d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHF2F8.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHF3F7.png b/wadsrc_bm/static/brightmaps/hexen/WRTHF3F7.png new file mode 100644 index 000000000..1e27285ce Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHF3F7.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHF4F6.png b/wadsrc_bm/static/brightmaps/hexen/WRTHF4F6.png new file mode 100644 index 000000000..29111a3fd Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHF4F6.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHF5.png b/wadsrc_bm/static/brightmaps/hexen/WRTHF5.png new file mode 100644 index 000000000..91ec627ca Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHF5.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHG1.png b/wadsrc_bm/static/brightmaps/hexen/WRTHG1.png new file mode 100644 index 000000000..e56d4fea0 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHG1.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHG2G8.png b/wadsrc_bm/static/brightmaps/hexen/WRTHG2G8.png new file mode 100644 index 000000000..6bc265bc6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHG2G8.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHG3G7.png b/wadsrc_bm/static/brightmaps/hexen/WRTHG3G7.png new file mode 100644 index 000000000..58efdb75f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHG3G7.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHG4G6.png b/wadsrc_bm/static/brightmaps/hexen/WRTHG4G6.png new file mode 100644 index 000000000..aafc01176 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHG4G6.png differ diff --git a/wadsrc_bm/static/brightmaps/hexen/WRTHG5.png b/wadsrc_bm/static/brightmaps/hexen/WRTHG5.png new file mode 100644 index 000000000..3615bebb2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/hexen/WRTHG5.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE1.png b/wadsrc_bm/static/brightmaps/strife/MLDRE1.png new file mode 100644 index 000000000..a7c723d62 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/MLDRE1.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE2.png b/wadsrc_bm/static/brightmaps/strife/MLDRE2.png new file mode 100644 index 000000000..0305db515 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/MLDRE2.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE3.png b/wadsrc_bm/static/brightmaps/strife/MLDRE3.png new file mode 100644 index 000000000..ec6c34db7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/MLDRE3.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE4.png b/wadsrc_bm/static/brightmaps/strife/MLDRE4.png new file mode 100644 index 000000000..22c8db94f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/MLDRE4.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE5.png b/wadsrc_bm/static/brightmaps/strife/MLDRE5.png new file mode 100644 index 000000000..118e48d09 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/MLDRE5.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE6.png b/wadsrc_bm/static/brightmaps/strife/MLDRE6.png new file mode 100644 index 000000000..bed99f89e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/MLDRE6.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE7.png b/wadsrc_bm/static/brightmaps/strife/MLDRE7.png new file mode 100644 index 000000000..f90672e02 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/MLDRE7.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/MLDRE8.png b/wadsrc_bm/static/brightmaps/strife/MLDRE8.png new file mode 100644 index 000000000..94f18ca65 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/MLDRE8.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG1.png b/wadsrc_bm/static/brightmaps/strife/PGRDG1.png new file mode 100644 index 000000000..c6e01e28e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDG1.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG2.png b/wadsrc_bm/static/brightmaps/strife/PGRDG2.png new file mode 100644 index 000000000..45e5414f2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDG2.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG3.png b/wadsrc_bm/static/brightmaps/strife/PGRDG3.png new file mode 100644 index 000000000..1bf159e4b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDG3.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG4.png b/wadsrc_bm/static/brightmaps/strife/PGRDG4.png new file mode 100644 index 000000000..610d29ec6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDG4.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG5.png b/wadsrc_bm/static/brightmaps/strife/PGRDG5.png new file mode 100644 index 000000000..3c437481d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDG5.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG6.png b/wadsrc_bm/static/brightmaps/strife/PGRDG6.png new file mode 100644 index 000000000..1c36855e7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDG6.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG7.png b/wadsrc_bm/static/brightmaps/strife/PGRDG7.png new file mode 100644 index 000000000..fa2412f7d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDG7.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDG8.png b/wadsrc_bm/static/brightmaps/strife/PGRDG8.png new file mode 100644 index 000000000..378feb8c6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDG8.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDI0.png b/wadsrc_bm/static/brightmaps/strife/PGRDI0.png new file mode 100644 index 000000000..4a1e3eaff Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDI0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDJ0.png b/wadsrc_bm/static/brightmaps/strife/PGRDJ0.png new file mode 100644 index 000000000..23b915deb Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDJ0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDK0.png b/wadsrc_bm/static/brightmaps/strife/PGRDK0.png new file mode 100644 index 000000000..626ec4004 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDK0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDL0.png b/wadsrc_bm/static/brightmaps/strife/PGRDL0.png new file mode 100644 index 000000000..30da82890 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDL0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDM0.png b/wadsrc_bm/static/brightmaps/strife/PGRDM0.png new file mode 100644 index 000000000..cbee2897f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDM0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PGRDN0.png b/wadsrc_bm/static/brightmaps/strife/PGRDN0.png new file mode 100644 index 000000000..f097b1df3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PGRDN0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/PRGRO0.png b/wadsrc_bm/static/brightmaps/strife/PRGRO0.png new file mode 100644 index 000000000..1267140d3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/PRGRO0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/RBB3A0.png b/wadsrc_bm/static/brightmaps/strife/RBB3A0.png new file mode 100644 index 000000000..9c0d07351 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/RBB3A0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/RBB3B0.png b/wadsrc_bm/static/brightmaps/strife/RBB3B0.png new file mode 100644 index 000000000..03a4d8476 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/RBB3B0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB1J0.png b/wadsrc_bm/static/brightmaps/strife/ROB1J0.png new file mode 100644 index 000000000..e6f423766 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB1J0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB1K0.png b/wadsrc_bm/static/brightmaps/strife/ROB1K0.png new file mode 100644 index 000000000..61925a2d5 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB1K0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB1L0.png b/wadsrc_bm/static/brightmaps/strife/ROB1L0.png new file mode 100644 index 000000000..6e51ffa1a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB1L0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB1M0.png b/wadsrc_bm/static/brightmaps/strife/ROB1M0.png new file mode 100644 index 000000000..13fcabbeb Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB1M0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB1N0.png b/wadsrc_bm/static/brightmaps/strife/ROB1N0.png new file mode 100644 index 000000000..f82245b64 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB1N0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB1O0.png b/wadsrc_bm/static/brightmaps/strife/ROB1O0.png new file mode 100644 index 000000000..94ac418a5 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB1O0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB1P0.png b/wadsrc_bm/static/brightmaps/strife/ROB1P0.png new file mode 100644 index 000000000..87c59a15f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB1P0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F1.png b/wadsrc_bm/static/brightmaps/strife/ROB2F1.png new file mode 100644 index 000000000..c6f85b0b2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2F1.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F2.png b/wadsrc_bm/static/brightmaps/strife/ROB2F2.png new file mode 100644 index 000000000..21ed37563 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2F2.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F3.png b/wadsrc_bm/static/brightmaps/strife/ROB2F3.png new file mode 100644 index 000000000..ea2917b43 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2F3.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F4.png b/wadsrc_bm/static/brightmaps/strife/ROB2F4.png new file mode 100644 index 000000000..7c805d97a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2F4.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F5.png b/wadsrc_bm/static/brightmaps/strife/ROB2F5.png new file mode 100644 index 000000000..ae3669a79 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2F5.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F6.png b/wadsrc_bm/static/brightmaps/strife/ROB2F6.png new file mode 100644 index 000000000..5bb74e497 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2F6.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F7.png b/wadsrc_bm/static/brightmaps/strife/ROB2F7.png new file mode 100644 index 000000000..fe11f5476 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2F7.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2F8.png b/wadsrc_bm/static/brightmaps/strife/ROB2F8.png new file mode 100644 index 000000000..f19350a2a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2F8.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2G0.png b/wadsrc_bm/static/brightmaps/strife/ROB2G0.png new file mode 100644 index 000000000..df39f0d16 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2G0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2H0.png b/wadsrc_bm/static/brightmaps/strife/ROB2H0.png new file mode 100644 index 000000000..cb64f9d09 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2H0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2I0.png b/wadsrc_bm/static/brightmaps/strife/ROB2I0.png new file mode 100644 index 000000000..11a6f151e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2I0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2J0.png b/wadsrc_bm/static/brightmaps/strife/ROB2J0.png new file mode 100644 index 000000000..19572c6a3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2J0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2K0.png b/wadsrc_bm/static/brightmaps/strife/ROB2K0.png new file mode 100644 index 000000000..76935bebb Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2K0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2L0.png b/wadsrc_bm/static/brightmaps/strife/ROB2L0.png new file mode 100644 index 000000000..c33e51178 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2L0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2M0.png b/wadsrc_bm/static/brightmaps/strife/ROB2M0.png new file mode 100644 index 000000000..d0200d1c8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2M0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2N0.png b/wadsrc_bm/static/brightmaps/strife/ROB2N0.png new file mode 100644 index 000000000..e68aa58cc Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2N0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB2O0.png b/wadsrc_bm/static/brightmaps/strife/ROB2O0.png new file mode 100644 index 000000000..3510ca12f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB2O0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F1.png b/wadsrc_bm/static/brightmaps/strife/ROB3F1.png new file mode 100644 index 000000000..8e95df7f6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3F1.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F2.png b/wadsrc_bm/static/brightmaps/strife/ROB3F2.png new file mode 100644 index 000000000..6a144b7b5 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3F2.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F3.png b/wadsrc_bm/static/brightmaps/strife/ROB3F3.png new file mode 100644 index 000000000..ec92b6c98 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3F3.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F4.png b/wadsrc_bm/static/brightmaps/strife/ROB3F4.png new file mode 100644 index 000000000..80a9420cd Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3F4.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F5.png b/wadsrc_bm/static/brightmaps/strife/ROB3F5.png new file mode 100644 index 000000000..4cedbae57 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3F5.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F6.png b/wadsrc_bm/static/brightmaps/strife/ROB3F6.png new file mode 100644 index 000000000..0773b64e3 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3F6.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F7.png b/wadsrc_bm/static/brightmaps/strife/ROB3F7.png new file mode 100644 index 000000000..2b8fe006e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3F7.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3F8.png b/wadsrc_bm/static/brightmaps/strife/ROB3F8.png new file mode 100644 index 000000000..709de86b2 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3F8.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H1.png b/wadsrc_bm/static/brightmaps/strife/ROB3H1.png new file mode 100644 index 000000000..d1d2482bf Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3H1.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H2.png b/wadsrc_bm/static/brightmaps/strife/ROB3H2.png new file mode 100644 index 000000000..75a0cecd8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3H2.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H3.png b/wadsrc_bm/static/brightmaps/strife/ROB3H3.png new file mode 100644 index 000000000..dd082dddc Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3H3.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H4.png b/wadsrc_bm/static/brightmaps/strife/ROB3H4.png new file mode 100644 index 000000000..32f9d9d76 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3H4.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H5.png b/wadsrc_bm/static/brightmaps/strife/ROB3H5.png new file mode 100644 index 000000000..d93f8a96e Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3H5.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H6.png b/wadsrc_bm/static/brightmaps/strife/ROB3H6.png new file mode 100644 index 000000000..6d0171b17 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3H6.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H7.png b/wadsrc_bm/static/brightmaps/strife/ROB3H7.png new file mode 100644 index 000000000..04ba80e7c Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3H7.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3H8.png b/wadsrc_bm/static/brightmaps/strife/ROB3H8.png new file mode 100644 index 000000000..a728ced7a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3H8.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I1.png b/wadsrc_bm/static/brightmaps/strife/ROB3I1.png new file mode 100644 index 000000000..e76aab455 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3I1.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I2.png b/wadsrc_bm/static/brightmaps/strife/ROB3I2.png new file mode 100644 index 000000000..9aab11709 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3I2.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I3.png b/wadsrc_bm/static/brightmaps/strife/ROB3I3.png new file mode 100644 index 000000000..a00229462 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3I3.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I4.png b/wadsrc_bm/static/brightmaps/strife/ROB3I4.png new file mode 100644 index 000000000..4aade5fcc Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3I4.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I5.png b/wadsrc_bm/static/brightmaps/strife/ROB3I5.png new file mode 100644 index 000000000..4e39617d7 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3I5.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I6.png b/wadsrc_bm/static/brightmaps/strife/ROB3I6.png new file mode 100644 index 000000000..c8a63623b Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3I6.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I7.png b/wadsrc_bm/static/brightmaps/strife/ROB3I7.png new file mode 100644 index 000000000..7009e2de8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3I7.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3I8.png b/wadsrc_bm/static/brightmaps/strife/ROB3I8.png new file mode 100644 index 000000000..4880d6242 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3I8.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J1.png b/wadsrc_bm/static/brightmaps/strife/ROB3J1.png new file mode 100644 index 000000000..e97f9eec6 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3J1.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J2.png b/wadsrc_bm/static/brightmaps/strife/ROB3J2.png new file mode 100644 index 000000000..1e54031e5 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3J2.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J3.png b/wadsrc_bm/static/brightmaps/strife/ROB3J3.png new file mode 100644 index 000000000..74392cceb Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3J3.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J4.png b/wadsrc_bm/static/brightmaps/strife/ROB3J4.png new file mode 100644 index 000000000..85e324869 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3J4.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J6.png b/wadsrc_bm/static/brightmaps/strife/ROB3J6.png new file mode 100644 index 000000000..7a8dc6540 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3J6.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J7.png b/wadsrc_bm/static/brightmaps/strife/ROB3J7.png new file mode 100644 index 000000000..08e531958 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3J7.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3J8.png b/wadsrc_bm/static/brightmaps/strife/ROB3J8.png new file mode 100644 index 000000000..0aad4ac5f Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3J8.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3M0.png b/wadsrc_bm/static/brightmaps/strife/ROB3M0.png new file mode 100644 index 000000000..8ff876d39 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3M0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3N0.png b/wadsrc_bm/static/brightmaps/strife/ROB3N0.png new file mode 100644 index 000000000..953df2057 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3N0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3O0.png b/wadsrc_bm/static/brightmaps/strife/ROB3O0.png new file mode 100644 index 000000000..dc6e98186 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3O0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3P0.png b/wadsrc_bm/static/brightmaps/strife/ROB3P0.png new file mode 100644 index 000000000..4c15cbd51 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3P0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3Q0.png b/wadsrc_bm/static/brightmaps/strife/ROB3Q0.png new file mode 100644 index 000000000..c66b6d654 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3Q0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3T0.png b/wadsrc_bm/static/brightmaps/strife/ROB3T0.png new file mode 100644 index 000000000..aa2db3891 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3T0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3U0.png b/wadsrc_bm/static/brightmaps/strife/ROB3U0.png new file mode 100644 index 000000000..2faae7cc9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3U0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3V0.png b/wadsrc_bm/static/brightmaps/strife/ROB3V0.png new file mode 100644 index 000000000..9c3af1027 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3V0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3W0.png b/wadsrc_bm/static/brightmaps/strife/ROB3W0.png new file mode 100644 index 000000000..799a8f944 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3W0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3X0.png b/wadsrc_bm/static/brightmaps/strife/ROB3X0.png new file mode 100644 index 000000000..fa45574c8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3X0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3Y0.png b/wadsrc_bm/static/brightmaps/strife/ROB3Y0.png new file mode 100644 index 000000000..c9b50001d Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3Y0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3Z0.png b/wadsrc_bm/static/brightmaps/strife/ROB3Z0.png new file mode 100644 index 000000000..3bcb03248 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3Z0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3[0.png b/wadsrc_bm/static/brightmaps/strife/ROB3[0.png new file mode 100644 index 000000000..7ccf983e0 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3[0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3]0.png b/wadsrc_bm/static/brightmaps/strife/ROB3]0.png new file mode 100644 index 000000000..e86a1f1fe Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3]0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/ROB3^0.png b/wadsrc_bm/static/brightmaps/strife/ROB3^0.png new file mode 100644 index 000000000..f67a424b8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/ROB3^0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/SEWRH0.png b/wadsrc_bm/static/brightmaps/strife/SEWRH0.png new file mode 100644 index 000000000..b439f2617 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/SEWRH0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLKP0.png b/wadsrc_bm/static/brightmaps/strife/STLKP0.png new file mode 100644 index 000000000..12c44fe99 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLKP0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLKQ0.png b/wadsrc_bm/static/brightmaps/strife/STLKQ0.png new file mode 100644 index 000000000..5065e9c6a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLKQ0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLKR0.png b/wadsrc_bm/static/brightmaps/strife/STLKR0.png new file mode 100644 index 000000000..16fa49db0 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLKR0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLKS0.png b/wadsrc_bm/static/brightmaps/strife/STLKS0.png new file mode 100644 index 000000000..5065e9c6a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLKS0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLKT0.png b/wadsrc_bm/static/brightmaps/strife/STLKT0.png new file mode 100644 index 000000000..a65e78c34 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLKT0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLKU0.png b/wadsrc_bm/static/brightmaps/strife/STLKU0.png new file mode 100644 index 000000000..c4399848a Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLKU0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLKV0.png b/wadsrc_bm/static/brightmaps/strife/STLKV0.png new file mode 100644 index 000000000..ce4ea1741 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLKV0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLKW0.png b/wadsrc_bm/static/brightmaps/strife/STLKW0.png new file mode 100644 index 000000000..b50fcd5c8 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLKW0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLKX0.png b/wadsrc_bm/static/brightmaps/strife/STLKX0.png new file mode 100644 index 000000000..4ae22cb05 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLKX0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLKY0.png b/wadsrc_bm/static/brightmaps/strife/STLKY0.png new file mode 100644 index 000000000..417f7fed1 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLKY0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLKZ0.png b/wadsrc_bm/static/brightmaps/strife/STLKZ0.png new file mode 100644 index 000000000..acb6a3fa0 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLKZ0.png differ diff --git a/wadsrc_bm/static/brightmaps/strife/STLK[0.png b/wadsrc_bm/static/brightmaps/strife/STLK[0.png new file mode 100644 index 000000000..6b47d56e9 Binary files /dev/null and b/wadsrc_bm/static/brightmaps/strife/STLK[0.png differ diff --git a/wadsrc_bm/static/doomdefs.bm b/wadsrc_bm/static/doomdefs.bm new file mode 100644 index 000000000..78159bddd --- /dev/null +++ b/wadsrc_bm/static/doomdefs.bm @@ -0,0 +1,2181 @@ +brightmap sprite CELLA0 +{ + map "brightmaps/doom/cella0.png" + iwad +} + +brightmap sprite CELPA0 +{ + map "brightmaps/doom/celpa0.png" + iwad +} + +brightmap sprite PLAYF1 +{ + map "brightmaps/doom/PLAYf1.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF2F8 +{ + map "brightmaps/doom/PLAYf2f8.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF3F7 +{ + map "brightmaps/doom/PLAYf3f7.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF4F6 +{ + map "brightmaps/doom/PLAYf4f6.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF5 +{ + map "brightmaps/doom/PLAYf5.png" + iwad + disablefullbright +} + +brightmap sprite POSSF1 +{ + map "brightmaps/doom/possf1.png" + iwad + disablefullbright +} + +brightmap sprite POSSF2F8 +{ + map "brightmaps/doom/possf2f8.png" + iwad + disablefullbright +} + +brightmap sprite POSSF3F7 +{ + map "brightmaps/doom/possf3f7.png" + iwad + disablefullbright +} + +brightmap sprite POSSF4F6 +{ + map "brightmaps/doom/possf4f6.png" + iwad + disablefullbright +} + +brightmap sprite POSSF5 +{ + map "brightmaps/doom/possf5.png" + iwad + disablefullbright +} + +brightmap sprite SPOSF1 +{ + map "brightmaps/doom/SPOSf1.png" + iwad + disablefullbright +} + +brightmap sprite SPOSF2F8 +{ + map "brightmaps/doom/SPOSf2f8.png" + iwad + disablefullbright +} + +brightmap sprite SPOSF3F7 +{ + map "brightmaps/doom/SPOSf3f7.png" + iwad + disablefullbright +} + +brightmap sprite SPOSF4F6 +{ + map "brightmaps/doom/SPOSf4f6.png" + iwad + disablefullbright +} + +brightmap sprite SPOSF5 +{ + iwad + map "brightmaps/doom/SPOSf5.png" + disablefullbright +} + +brightmap sprite CPOSE1 +{ + map "brightmaps/doom/CPOSE1.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE2 +{ + map "brightmaps/doom/CPOSE2.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE3 +{ + map "brightmaps/doom/CPOSE3.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE4 +{ + iwad + disablefullbright +} + +brightmap sprite CPOSE5 +{ + map "brightmaps/doom/CPOSE5.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE6 +{ + map "brightmaps/doom/CPOSE6.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE7 +{ + map "brightmaps/doom/CPOSE7.png" + iwad + disablefullbright +} + +brightmap sprite CPOSE8 +{ + map "brightmaps/doom/CPOSE8.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF1 +{ + map "brightmaps/doom/CPOSF1.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF2 +{ + map "brightmaps/doom/CPOSF2.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF3 +{ + map "brightmaps/doom/CPOSF3.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF4 +{ + map "brightmaps/doom/CPOSF4.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF5 +{ + map "brightmaps/doom/CPOSF5.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF6 +{ + map "brightmaps/doom/CPOSF6.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF7 +{ + map "brightmaps/doom/CPOSF7.png" + iwad + disablefullbright +} + +brightmap sprite CPOSF8 +{ + map "brightmaps/doom/CPOSF8.png" + iwad + disablefullbright +} + +brightmap sprite SSWVG0 +{ + map "brightmaps/doom/sswvg0.png" + iwad + disablefullbright +} + +brightmap sprite BSPIA1D1 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIA2a8 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIA3A7 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIA4A6 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIA5D5 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIG1 +{ + map "brightmaps/doom/bspig1.png" + iwad + disablefullbright +} + +brightmap sprite BSPIG2G8 +{ + map "brightmaps/doom/bspig2g8.png" + iwad + disablefullbright +} + +brightmap sprite BSPIG3G7 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIG4G6 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIG5 +{ + iwad + disablefullbright +} + +brightmap sprite BSPIH1 +{ + map "brightmaps/doom/bspih1.png" + iwad + disablefullbright +} + +brightmap sprite BSPIH2H8 +{ + map "brightmaps/doom/bspih2h8.png" + iwad + disablefullbright +} + +brightmap sprite BSPIH3H7 +{ + map "brightmaps/doom/bspih3h7.png" + iwad + disablefullbright +} + +brightmap sprite BSPIH4H6 +{ + map "brightmaps/doom/bspih4h6.png" + iwad + disablefullbright +} + +brightmap sprite BSPIH5 +{ + map "brightmaps/doom/bspih5.png" + iwad + disablefullbright +} + +brightmap sprite BOSSA1 +{ + map "brightmaps/doom/bossa1.png" + iwad +} + +brightmap sprite BOSSA2A8 +{ + map "brightmaps/doom/bossa2a8.png" + iwad +} + +brightmap sprite BOSSA3A7 +{ + map "brightmaps/doom/bossa3a7.png" + iwad +} + +brightmap sprite BOSSA4A6 +{ + map "brightmaps/doom/bossa4a6.png" + iwad +} + +brightmap sprite BOSSA5 +{ + map "brightmaps/doom/bossa5.png" + iwad +} + +brightmap sprite BOSSb1 +{ + map "brightmaps/doom/bossb1.png" + iwad +} + +brightmap sprite BOSSB2B8 +{ + map "brightmaps/doom/bossb2b8.png" + iwad +} + +brightmap sprite BOSSB3B7 +{ + map "brightmaps/doom/bossb3b7.png" + iwad +} + +brightmap sprite BOSSB4B6 +{ + map "brightmaps/doom/bossb4b6.png" + iwad +} + +brightmap sprite BOSSB5 +{ + map "brightmaps/doom/bossb5.png" + iwad +} + +brightmap sprite BOSSC1 +{ + map "brightmaps/doom/bossc1.png" + iwad +} + +brightmap sprite BOSSC2C8 +{ + map "brightmaps/doom/bossc2c8.png" + iwad +} + +brightmap sprite BOSSC3C7 +{ + map "brightmaps/doom/bossc3c7.png" + iwad +} + +brightmap sprite BOSSC4C6 +{ + map "brightmaps/doom/bossc4c6.png" + iwad +} + +brightmap sprite BOSSC5 +{ + map "brightmaps/doom/bossc5.png" + iwad +} + +brightmap sprite BOSSD1 +{ + map "brightmaps/doom/bossd1.png" + iwad +} + +brightmap sprite BOSSD2D8 +{ + map "brightmaps/doom/bossd2d8.png" + iwad +} + +brightmap sprite BOSSD3D7 +{ + map "brightmaps/doom/bossd3d7.png" + iwad +} + +brightmap sprite BOSSD4D6 +{ + map "brightmaps/doom/bossd4d6.png" + iwad +} + +brightmap sprite BOSSD5 +{ + map "brightmaps/doom/bossd5.png" + iwad +} + +brightmap sprite BOSSE1 +{ + map "brightmaps/doom/bosse1.png" + iwad +} + +brightmap sprite BOSSE2 +{ + map "brightmaps/doom/bosse2.png" + iwad +} + +brightmap sprite BOSSE3 +{ + map "brightmaps/doom/bosse3.png" + iwad +} + +brightmap sprite BOSSE4 +{ + map "brightmaps/doom/bosse4.png" + iwad +} + +brightmap sprite BOSSE5 +{ + map "brightmaps/doom/bosse5.png" + iwad +} + +brightmap sprite BOSSE6 +{ + map "brightmaps/doom/bosse6.png" + iwad +} + +brightmap sprite BOSSE7 +{ + map "brightmaps/doom/bosse7.png" + iwad +} + +brightmap sprite BOSSE8 +{ + map "brightmaps/doom/bosse8.png" + iwad +} + +brightmap sprite BOSSF1 +{ + map "brightmaps/doom/BOSSF1.png" + iwad +} + +brightmap sprite BOSSF2 +{ + map "brightmaps/doom/BOSSF2.png" + iwad +} + +brightmap sprite BOSSF3 +{ + map "brightmaps/doom/BOSSF3.png" + iwad +} + +brightmap sprite BOSSF4 +{ + map "brightmaps/doom/BOSSF4.png" + iwad +} + +brightmap sprite BOSSF5 +{ + map "brightmaps/doom/BOSSF5.png" + iwad +} + +brightmap sprite BOSSF6 +{ + map "brightmaps/doom/BOSSF6.png" + iwad +} + +brightmap sprite BOSSF7 +{ + map "brightmaps/doom/BOSSF7.png" + iwad +} + +brightmap sprite BOSSF8 +{ + map "brightmaps/doom/BOSSF8.png" + iwad +} + +brightmap sprite BOSSG1 +{ + map "brightmaps/doom/BOSSG1.png" + iwad +} + +brightmap sprite BOSSG2 +{ + map "brightmaps/doom/BOSSG2.png" + iwad +} + +brightmap sprite BOSSG3 +{ + map "brightmaps/doom/BOSSG3.png" + iwad +} + +brightmap sprite BOSSG4 +{ + map "brightmaps/doom/BOSSG4.png" + iwad +} + +brightmap sprite BOSSG5 +{ + map "brightmaps/doom/BOSSG5.png" + iwad +} + +brightmap sprite BOSSG6 +{ + map "brightmaps/doom/BOSSG6.png" + iwad +} + +brightmap sprite BOSSG7 +{ + map "brightmaps/doom/BOSSG7.png" + iwad +} + +brightmap sprite BOSSG8 +{ + map "brightmaps/doom/BOSSG8.png" + iwad +} + +brightmap sprite BOSSH1 +{ + map "brightmaps/doom/BOSSH1.png" + iwad +} + +brightmap sprite BOSSH2 +{ + map "brightmaps/doom/BOSSH2.png" + iwad +} + +brightmap sprite BOSSH3 +{ + map "brightmaps/doom/BOSSH3.png" + iwad +} + +brightmap sprite BOSSH4 +{ + map "brightmaps/doom/BOSSH4.png" + iwad +} + +brightmap sprite BOSSH5 +{ + map "brightmaps/doom/BOSSH5.png" + iwad +} + +brightmap sprite BOSSH6 +{ + map "brightmaps/doom/BOSSH6.png" + iwad +} + +brightmap sprite BOSSH7 +{ + map "brightmaps/doom/BOSSH7.png" + iwad +} + +brightmap sprite BOSSH8 +{ + map "brightmaps/doom/BOSSH8.png" + iwad +} + +brightmap sprite BOSSI0 +{ + map "brightmaps/doom/BOSSI0.png" + iwad +} + +brightmap sprite BOSSJ0 +{ + map "brightmaps/doom/BOSSJ0.png" + iwad +} + +brightmap sprite BOSSK0 +{ + map "brightmaps/doom/BOSSK0.png" + iwad +} + +brightmap sprite BOSSL0 +{ + map "brightmaps/doom/BOSSL0.png" + iwad +} + +brightmap sprite BOSSM0 +{ + map "brightmaps/doom/BOSSM0.png" + iwad +} + +brightmap sprite BOS2A1C1 +{ + map "brightmaps/doom/bossa1.png" + iwad +} + +brightmap sprite BOS2A2C8 +{ + map "brightmaps/doom/bossa2a8.png" + iwad +} + +brightmap sprite BOS2A3C7 +{ + map "brightmaps/doom/bossa3a7.png" + iwad +} + +brightmap sprite BOS2A4C6 +{ + map "brightmaps/doom/bossa4a6.png" + iwad +} + +brightmap sprite BOS2A5C5 +{ + map "brightmaps/doom/bossa5.png" + iwad +} + +brightmap sprite BOS2b1D1 +{ + map "brightmaps/doom/bossb1.png" + iwad +} + +brightmap sprite BOS2B2D8 +{ + map "brightmaps/doom/bossb2b8.png" + iwad +} + +brightmap sprite BOS2B3D7 +{ + map "brightmaps/doom/bossb3b7.png" + iwad +} + +brightmap sprite BOS2B4D6 +{ + map "brightmaps/doom/bossb4b6.png" + iwad +} + +brightmap sprite BOS2B5D5 +{ + map "brightmaps/doom/bossb5.png" + iwad +} + +brightmap sprite BOS2E1 +{ + map "brightmaps/doom/bosse1.png" + iwad +} + +brightmap sprite BOS2E2 +{ + map "brightmaps/doom/bosse2.png" + iwad +} + +brightmap sprite BOS2E3 +{ + map "brightmaps/doom/bosse3.png" + iwad +} + +brightmap sprite BOS2E4 +{ + map "brightmaps/doom/bosse4.png" + iwad +} + +brightmap sprite BOS2E5 +{ + map "brightmaps/doom/bosse5.png" + iwad +} + +brightmap sprite BOS2E6 +{ + map "brightmaps/doom/bosse6.png" + iwad +} + +brightmap sprite BOS2E7 +{ + map "brightmaps/doom/bosse7.png" + iwad +} + +brightmap sprite BOS2E8 +{ + map "brightmaps/doom/bosse8.png" + iwad +} + +brightmap sprite BOS2F1 +{ + map "brightmaps/doom/BOSSF1.png" + iwad +} + +brightmap sprite BOS2F2 +{ + map "brightmaps/doom/BOSSF2.png" + iwad +} + +brightmap sprite BOS2F3 +{ + map "brightmaps/doom/BOSSF3.png" + iwad +} + +brightmap sprite BOS2F4 +{ + map "brightmaps/doom/BOSSF4.png" + iwad +} + +brightmap sprite BOS2F5 +{ + map "brightmaps/doom/BOSSF5.png" + iwad +} + +brightmap sprite BOS2F6 +{ + map "brightmaps/doom/BOSSF6.png" + iwad +} + +brightmap sprite BOS2F7 +{ + map "brightmaps/doom/BOSSF7.png" + iwad +} + +brightmap sprite BOS2F8 +{ + map "brightmaps/doom/BOSSF8.png" + iwad +} + +brightmap sprite BOS2G1 +{ + map "brightmaps/doom/BOSSG1.png" + iwad +} + +brightmap sprite BOS2G2 +{ + map "brightmaps/doom/BOSSG2.png" + iwad +} + +brightmap sprite BOS2G3 +{ + map "brightmaps/doom/BOSSG3.png" + iwad +} + +brightmap sprite BOS2G4 +{ + map "brightmaps/doom/BOSSG4.png" + iwad +} + +brightmap sprite BOS2G5 +{ + map "brightmaps/doom/BOSSG5.png" + iwad +} + +brightmap sprite BOS2G6 +{ + map "brightmaps/doom/BOSSG6.png" + iwad +} + +brightmap sprite BOS2G7 +{ + map "brightmaps/doom/BOSSG7.png" + iwad +} + +brightmap sprite BOS2G8 +{ + map "brightmaps/doom/BOSSG8.png" + iwad +} + +brightmap sprite BOS2H1 +{ + map "brightmaps/doom/BOSSH1.png" + iwad +} + +brightmap sprite BOS2H2 +{ + map "brightmaps/doom/BOSSH2.png" + iwad +} + +brightmap sprite BOS2H3 +{ + map "brightmaps/doom/BOSSH3.png" + iwad +} + +brightmap sprite BOS2H4 +{ + map "brightmaps/doom/BOSSH4.png" + iwad +} + +brightmap sprite BOS2H5 +{ + map "brightmaps/doom/BOSSH5.png" + iwad +} + +brightmap sprite BOS2H6 +{ + map "brightmaps/doom/BOSSH6.png" + iwad +} + +brightmap sprite BOS2H7 +{ + map "brightmaps/doom/BOSSH7.png" + iwad +} + +brightmap sprite BOS2H8 +{ + map "brightmaps/doom/BOSSH8.png" + iwad +} + +brightmap sprite BOS2I0 +{ + map "brightmaps/doom/BOSSI0.png" + iwad +} + +brightmap sprite BOS2J0 +{ + map "brightmaps/doom/BOSSJ0.png" + iwad +} + +brightmap sprite BOS2K0 +{ + map "brightmaps/doom/BOSSK0.png" + iwad +} + +brightmap sprite BOS2L0 +{ + map "brightmaps/doom/BOSSL0.png" + iwad +} + +brightmap sprite BOS2M0 +{ + map "brightmaps/doom/BOSSM0.png" + iwad +} + +brightmap sprite BOS2A6C4 +{ + map "brightmaps/doom/BOS2A6C4.png" + iwad +} + +brightmap sprite BOS2A7C3 +{ + map "brightmaps/doom/BOS2A7C3.png" + iwad +} + +brightmap sprite BOS2A8C2 +{ + map "brightmaps/doom/BOS2A8C2.png" + iwad +} + +brightmap sprite BOS2B6D4 +{ + map "brightmaps/doom/BOS2B6D4.png" + iwad +} + +brightmap sprite BOS2B7D3 +{ + map "brightmaps/doom/BOS2B7D3.png" + iwad +} + +brightmap sprite BOS2B8D2 +{ + map "brightmaps/doom/BOS2B8D2.png" + iwad +} + +brightmap sprite SKELJ1 +{ + map "brightmaps/doom/SKELJ1.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ2 +{ + map "brightmaps/doom/SKELJ2.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ3 +{ + map "brightmaps/doom/SKELJ3.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ4 +{ + map "brightmaps/doom/SKELJ4.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ5 +{ + map "brightmaps/doom/SKELJ5.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ6 +{ + map "brightmaps/doom/SKELJ6.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ7 +{ + map "brightmaps/doom/SKELJ7.png" + iwad + disablefullbright +} + +brightmap sprite SKELJ8 +{ + map "brightmaps/doom/SKELJ8.png" + iwad + disablefullbright +} + +brightmap sprite FATTH1 +{ + map "brightmaps/doom/FATTH1.png" + iwad + disablefullbright +} + +brightmap sprite FATTH2H8 +{ + map "brightmaps/doom/FATTH2H8.png" + iwad + disablefullbright +} + +brightmap sprite FATTH3H7 +{ + map "brightmaps/doom/FATTH3H7.png" + iwad + disablefullbright +} + +brightmap sprite FATTH4H6 +{ + map "brightmaps/doom/FATTH4H6.png" + iwad + disablefullbright +} + +brightmap sprite FATTH5 +{ + map "brightmaps/doom/FATTH5.png" + iwad + disablefullbright +} + +brightmap sprite HEADC1 +{ + map "brightmaps/doom/HEADC1.png" + iwad + disablefullbright +} + +brightmap sprite HEADC2C8 +{ + map "brightmaps/doom/HEADC2C8.png" + iwad + disablefullbright +} + +brightmap sprite HEADC3C7 +{ + map "brightmaps/doom/HEADC3C7.png" + iwad + disablefullbright +} + +brightmap sprite HEADD1 +{ + map "brightmaps/doom/HEADD1.png" + iwad + disablefullbright +} + +brightmap sprite HEADD2D8 +{ + map "brightmaps/doom/HEADD2D8.png" + iwad + disablefullbright +} + +brightmap sprite HEADD3D7 +{ + map "brightmaps/doom/HEADD3D7.png" + iwad + disablefullbright +} + +brightmap sprite HEADD4D6 +{ + iwad + disablefullbright +} + +brightmap sprite HEADD5 +{ + iwad + disablefullbright +} + +brightmap sprite PAINF1 +{ + map "brightmaps/doom/PAINf1.png" + iwad + disablefullbright +} + +brightmap sprite PAINF2F8 +{ + map "brightmaps/doom/PAINf2f8.png" + iwad + disablefullbright +} + +brightmap sprite PAINF3F7 +{ + map "brightmaps/doom/PAINf3f7.png" + iwad + disablefullbright +} + +brightmap sprite PAINF4F6 +{ + iwad + disablefullbright +} + +brightmap sprite PAINF5 +{ + iwad + disablefullbright +} + +brightmap sprite CYBRF1 +{ + map "brightmaps/doom/CYBRF1.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF2 +{ + map "brightmaps/doom/CYBRF2.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF3 +{ + map "brightmaps/doom/CYBRF3.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF4 +{ + map "brightmaps/doom/CYBRF4.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF5 +{ + map "brightmaps/doom/CYBRF5.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF6 +{ + map "brightmaps/doom/CYBRF6.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF7 +{ + map "brightmaps/doom/CYBRF7.png" + iwad + disablefullbright +} + +brightmap sprite CYBRF8 +{ + map "brightmaps/doom/CYBRF8.png" + iwad + disablefullbright +} + +brightmap sprite CYBRJ0 +{ + map "brightmaps/doom/CYBRJ0.png" + iwad + disablefullbright +} + +brightmap sprite CYBRK0 +{ + map "brightmaps/doom/CYBRK0.png" + iwad + disablefullbright +} + +brightmap sprite CYBRL0 +{ + map "brightmaps/doom/CYBRL0.png" + iwad + disablefullbright +} + +brightmap sprite CYBRM0 +{ + map "brightmaps/doom/CYBRM0.png" + iwad + disablefullbright +} + +brightmap sprite CYBRN0 +{ + map "brightmaps/doom/CYBRN0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDA1D1 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDA2D8 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDA3D7 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDA4D6 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDA5D5 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDG1 +{ + map "brightmaps/doom/SPIDG1.png" + iwad + disablefullbright +} + +brightmap sprite SPIDG2G8 +{ + map "brightmaps/doom/SPIDG2G8.png" + iwad + disablefullbright +} + +brightmap sprite SPIDG3G7 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDG4G6 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDG5 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDH1 +{ + map "brightmaps/doom/SPIDH1.png" + iwad + disablefullbright +} + +brightmap sprite SPIDG2G8 +{ + map "brightmaps/doom/SPIDH2H8.png" + iwad + disablefullbright +} + +brightmap sprite SPIDH3H7 +{ + map "brightmaps/doom/SPIDH3H7.png" + iwad + disablefullbright +} + +brightmap sprite SPIDH4H6 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDH5 +{ + iwad + disablefullbright +} + +brightmap sprite SPIDH1 +{ + map "brightmaps/doom/SPIDH1.png" + iwad + disablefullbright +} + +brightmap sprite SPIDL0 +{ + map "brightmaps/doom/SPIDL0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDM0 +{ + map "brightmaps/doom/SPIDM0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDN0 +{ + map "brightmaps/doom/SPIDN0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDO0 +{ + map "brightmaps/doom/SPIDO0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDP0 +{ + map "brightmaps/doom/SPIDP0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDQ0 +{ + map "brightmaps/doom/SPIDQ0.png" + iwad + disablefullbright +} + +brightmap sprite SPIDR0 +{ + map "brightmaps/doom/SPIDR0.png" + iwad + disablefullbright +} + +brightmap sprite BON2B0 +{ + map "brightmaps/doom/BON2B0.png" + iwad + disablefullbright +} + +brightmap sprite BON2c0 +{ + map "brightmaps/doom/BON2c0.png" + iwad + disablefullbright +} + +brightmap sprite BON2d0 +{ + map "brightmaps/doom/BON2d0.png" + iwad + disablefullbright +} + +brightmap sprite FCANA0 +{ + map "brightmaps/doom/FCANA0.png" + iwad + disablefullbright +} + +brightmap sprite FCANb0 +{ + map "brightmaps/doom/FCANb0.png" + iwad + disablefullbright +} + +brightmap sprite FCANc0 +{ + map "brightmaps/doom/FCANc0.png" + iwad + disablefullbright +} + +brightmap sprite treda0 +{ + map "brightmaps/doom/treda0.png" + iwad + disablefullbright +} + +brightmap sprite tredb0 +{ + map "brightmaps/doom/tredb0.png" + iwad + disablefullbright +} + +brightmap sprite tredc0 +{ + map "brightmaps/doom/tredc0.png" + iwad + disablefullbright +} + +brightmap sprite tredd0 +{ + map "brightmaps/doom/tredd0.png" + iwad + disablefullbright +} + +brightmap sprite TBLUA0 +{ + map "brightmaps/doom/treda0.png" + iwad + disablefullbright +} + +brightmap sprite TBLUb0 +{ + map "brightmaps/doom/TBLUb0.png" + iwad + disablefullbright +} + +brightmap sprite TBLUc0 +{ + map "brightmaps/doom/TBLUc0.png" + iwad + disablefullbright +} + +brightmap sprite TBLUd0 +{ + map "brightmaps/doom/tredd0.png" + iwad + disablefullbright +} + +brightmap sprite TGRNA0 +{ + map "brightmaps/doom/treda0.png" + iwad + disablefullbright +} + +brightmap sprite TGRNb0 +{ + map "brightmaps/doom/tredb0.png" + iwad + disablefullbright +} + +brightmap sprite TGRNc0 +{ + map "brightmaps/doom/tredc0.png" + iwad + disablefullbright +} + +brightmap sprite TGRNd0 +{ + map "brightmaps/doom/tredd0.png" + iwad + disablefullbright +} + +brightmap sprite SMRTA0 +{ + map "brightmaps/doom/SMRTA0.png" + iwad + disablefullbright +} + +brightmap sprite SMRTb0 +{ + map "brightmaps/doom/SMRTb0.png" + iwad + disablefullbright +} + +brightmap sprite SMRTc0 +{ + map "brightmaps/doom/SMRTc0.png" + iwad + disablefullbright +} + +brightmap sprite SMRTd0 +{ + map "brightmaps/doom/SMRTd0.png" + iwad + disablefullbright +} + +brightmap sprite SMbTA0 +{ + map "brightmaps/doom/SMRTA0.png" + iwad + disablefullbright +} + +brightmap sprite SMbTb0 +{ + map "brightmaps/doom/SMRTb0.png" + iwad + disablefullbright +} + +brightmap sprite SMbTc0 +{ + map "brightmaps/doom/SMRTc0.png" + iwad + disablefullbright +} + +brightmap sprite SMbTd0 +{ + map "brightmaps/doom/SMRTd0.png" + iwad + disablefullbright +} + +brightmap sprite SMgTA0 +{ + map "brightmaps/doom/SMRTA0.png" + iwad + disablefullbright +} + +brightmap sprite SMgTb0 +{ + map "brightmaps/doom/SMRTb0.png" + iwad + disablefullbright +} + +brightmap sprite SMgTc0 +{ + map "brightmaps/doom/SMRTc0.png" + iwad + disablefullbright +} + +brightmap sprite SMgTd0 +{ + map "brightmaps/doom/SMRTd0.png" + iwad + disablefullbright +} + +brightmap sprite vileg1 +{ + map "brightmaps/doom/vileg1.png" + iwad + disablefullbright +} + +brightmap sprite vileg2 +{ + map "brightmaps/doom/vileg2.png" + iwad + disablefullbright +} + +brightmap sprite vileg3 +{ + map "brightmaps/doom/vileg3.png" + iwad + disablefullbright +} + +brightmap sprite vileg4 +{ + map "brightmaps/doom/vileg4.png" + iwad + disablefullbright +} + +brightmap sprite vileg5 +{ + map "brightmaps/doom/vileg5.png" + iwad + disablefullbright +} + +brightmap sprite vileg6 +{ + map "brightmaps/doom/vileg6.png" + iwad + disablefullbright +} + +brightmap sprite vileg7 +{ + map "brightmaps/doom/vileg7.png" + iwad + disablefullbright +} + +brightmap sprite vileg8 +{ + map "brightmaps/doom/vileg8.png" + iwad + disablefullbright +} + +brightmap sprite vileh1 +{ + map "brightmaps/doom/vileh1.png" + iwad + disablefullbright +} + +brightmap sprite vileh2 +{ + map "brightmaps/doom/vileh2.png" + iwad + disablefullbright +} + +brightmap sprite vileh3 +{ + map "brightmaps/doom/vileh3.png" + iwad + disablefullbright +} + +brightmap sprite vileh4 +{ + map "brightmaps/doom/vileh4.png" + iwad + disablefullbright +} + +brightmap sprite vileh5 +{ + map "brightmaps/doom/vileh5.png" + iwad + disablefullbright +} + +brightmap sprite vileh6 +{ + map "brightmaps/doom/vileh6.png" + iwad + disablefullbright +} + +brightmap sprite vileh7 +{ + map "brightmaps/doom/vileh7.png" + iwad + disablefullbright +} + +brightmap sprite vileh8 +{ + map "brightmaps/doom/vileh8.png" + iwad + disablefullbright +} + +brightmap sprite vilei1 +{ + map "brightmaps/doom/vilei1.png" + iwad + disablefullbright +} + +brightmap sprite vilei2 +{ + map "brightmaps/doom/vilei2.png" + iwad + disablefullbright +} + +brightmap sprite vilei3 +{ + map "brightmaps/doom/vilei3.png" + iwad + disablefullbright +} + +brightmap sprite vilei4 +{ + map "brightmaps/doom/vilei4.png" + iwad + disablefullbright +} + +brightmap sprite vilei5 +{ + map "brightmaps/doom/vilei5.png" + iwad + disablefullbright +} + +brightmap sprite vilei6 +{ + map "brightmaps/doom/vilei6.png" + iwad + disablefullbright +} + +brightmap sprite vilei7 +{ + map "brightmaps/doom/vilei7.png" + iwad + disablefullbright +} + +brightmap sprite vilei8 +{ + map "brightmaps/doom/vilei8.png" + iwad + disablefullbright +} + +brightmap sprite vilej1 +{ + map "brightmaps/doom/vilej1.png" + iwad + disablefullbright +} + +brightmap sprite vilej2 +{ + map "brightmaps/doom/vilej2.png" + iwad + disablefullbright +} + +brightmap sprite vilej3 +{ + map "brightmaps/doom/vilej3.png" + iwad + disablefullbright +} + +brightmap sprite vilej4 +{ + map "brightmaps/doom/vilej4.png" + iwad + disablefullbright +} + +brightmap sprite vilej5 +{ + map "brightmaps/doom/vilej5.png" + iwad + disablefullbright +} + +brightmap sprite vilej6 +{ + map "brightmaps/doom/vilej6.png" + iwad + disablefullbright +} + +brightmap sprite vilej7 +{ + map "brightmaps/doom/vilej7.png" + iwad + disablefullbright +} + +brightmap sprite vilej8 +{ + map "brightmaps/doom/vilej8.png" + iwad + disablefullbright +} + +brightmap sprite vilek1 +{ + map "brightmaps/doom/vilek1.png" + iwad + disablefullbright +} + +brightmap sprite vilek2 +{ + map "brightmaps/doom/vilek2.png" + iwad + disablefullbright +} + +brightmap sprite vilek3 +{ + map "brightmaps/doom/vilek3.png" + iwad + disablefullbright +} + +brightmap sprite vilek4 +{ + map "brightmaps/doom/vilek4.png" + iwad + disablefullbright +} + +brightmap sprite vilek5 +{ + map "brightmaps/doom/vilek5.png" + iwad + disablefullbright +} + +brightmap sprite vilek6 +{ + map "brightmaps/doom/vilek6.png" + iwad + disablefullbright +} + +brightmap sprite vilek7 +{ + map "brightmaps/doom/vilek7.png" + iwad + disablefullbright +} + +brightmap sprite vilek8 +{ + map "brightmaps/doom/vilek8.png" + iwad + disablefullbright +} + +brightmap sprite vilel1 +{ + map "brightmaps/doom/vilel1.png" + iwad + disablefullbright +} + +brightmap sprite vilel2 +{ + map "brightmaps/doom/vilel2.png" + iwad + disablefullbright +} + +brightmap sprite vilel3 +{ + map "brightmaps/doom/vilel3.png" + iwad + disablefullbright +} + +brightmap sprite vilel4 +{ + map "brightmaps/doom/vilel4.png" + iwad + disablefullbright +} + +brightmap sprite vilel5 +{ + map "brightmaps/doom/vilel5.png" + iwad + disablefullbright +} + +brightmap sprite vilel6 +{ + map "brightmaps/doom/vilel6.png" + iwad + disablefullbright +} + +brightmap sprite vilel7 +{ + map "brightmaps/doom/vilel7.png" + iwad + disablefullbright +} + +brightmap sprite vilel8 +{ + map "brightmaps/doom/vilel8.png" + iwad + disablefullbright +} + +brightmap sprite vilem1 +{ + map "brightmaps/doom/vilem1.png" + iwad + disablefullbright +} + +brightmap sprite vilem2 +{ + map "brightmaps/doom/vilem2.png" + iwad + disablefullbright +} + +brightmap sprite vilem3 +{ + map "brightmaps/doom/vilem3.png" + iwad + disablefullbright +} + +brightmap sprite vilem4 +{ + map "brightmaps/doom/vilem4.png" + iwad + disablefullbright +} + +brightmap sprite vilem5 +{ + map "brightmaps/doom/vilem5.png" + iwad + disablefullbright +} + +brightmap sprite vilem6 +{ + map "brightmaps/doom/vilem6.png" + iwad + disablefullbright +} + +brightmap sprite vilem7 +{ + map "brightmaps/doom/vilem7.png" + iwad + disablefullbright +} + +brightmap sprite vilem8 +{ + map "brightmaps/doom/vilem8.png" + iwad + disablefullbright +} + +brightmap sprite vilen1 +{ + map "brightmaps/doom/vilen1.png" + iwad + disablefullbright +} + +brightmap sprite vilen2 +{ + map "brightmaps/doom/vilen2.png" + iwad + disablefullbright +} + +brightmap sprite vilen3 +{ + map "brightmaps/doom/vilen3.png" + iwad + disablefullbright +} + +brightmap sprite vilen4 +{ + map "brightmaps/doom/vilen4.png" + iwad + disablefullbright +} + +brightmap sprite vilen5 +{ + map "brightmaps/doom/vilen5.png" + iwad + disablefullbright +} + +brightmap sprite vilen6 +{ + map "brightmaps/doom/vilen6.png" + iwad + disablefullbright +} + +brightmap sprite vilen7 +{ + map "brightmaps/doom/vilen7.png" + iwad + disablefullbright +} + +brightmap sprite vilen8 +{ + map "brightmaps/doom/vilen8.png" + iwad + disablefullbright +} + +brightmap sprite vileo1 +{ + map "brightmaps/doom/vileo1.png" + iwad + disablefullbright +} + +brightmap sprite vileo2 +{ + map "brightmaps/doom/vileo2.png" + iwad + disablefullbright +} + +brightmap sprite vileo3 +{ + map "brightmaps/doom/vileo3.png" + iwad + disablefullbright +} + +brightmap sprite vileo4 +{ + map "brightmaps/doom/vileo4.png" + iwad + disablefullbright +} + +brightmap sprite vileo5 +{ + map "brightmaps/doom/vileo5.png" + iwad + disablefullbright +} + +brightmap sprite vileo6 +{ + map "brightmaps/doom/vileo6.png" + iwad + disablefullbright +} + +brightmap sprite vileo7 +{ + map "brightmaps/doom/vileo7.png" + iwad + disablefullbright +} + +brightmap sprite vileo8 +{ + map "brightmaps/doom/vileo8.png" + iwad + disablefullbright +} + +brightmap sprite vilep1 +{ + map "brightmaps/doom/vilep1.png" + iwad + disablefullbright +} + +brightmap sprite vilep2 +{ + map "brightmaps/doom/vilep2.png" + iwad + disablefullbright +} + +brightmap sprite vilep3 +{ + map "brightmaps/doom/vilep3.png" + iwad + disablefullbright +} + +brightmap sprite vilep4 +{ + map "brightmaps/doom/vilep4.png" + iwad + disablefullbright +} + +brightmap sprite vilep5 +{ + map "brightmaps/doom/vilep5.png" + iwad + disablefullbright +} + +brightmap sprite vilep6 +{ + map "brightmaps/doom/vilep6.png" + iwad + disablefullbright +} + +brightmap sprite vilep7 +{ + map "brightmaps/doom/vilep7.png" + iwad + disablefullbright +} + +brightmap sprite vilep8 +{ + map "brightmaps/doom/vilep8.png" + iwad + disablefullbright +} diff --git a/wadsrc_bm/static/hexndefs.bm b/wadsrc_bm/static/hexndefs.bm new file mode 100644 index 000000000..180f6b15c --- /dev/null +++ b/wadsrc_bm/static/hexndefs.bm @@ -0,0 +1,268 @@ + +brightmap sprite CDLRA0 +{ + map "brightmaps/hexen/CDLRA0.png" + iwad + disablefullbright +} + +brightmap sprite CDLRB0 +{ + map "brightmaps/hexen/CDLRB0.png" + iwad + disablefullbright +} + +brightmap sprite CDLRC0 +{ + map "brightmaps/hexen/CDLRC0.png" + iwad + disablefullbright +} + +brightmap sprite CENTF1 +{ + map "brightmaps/hexen/CENTF1.png" + iwad + disablefullbright +} + +brightmap sprite CENTF2 +{ + map "brightmaps/hexen/CENTF2.png" + iwad + disablefullbright +} + +brightmap sprite CENTF3 +{ + iwad + disablefullbright +} + +brightmap sprite CENTF4 +{ + iwad + disablefullbright +} + +brightmap sprite CENTF5 +{ + iwad + disablefullbright +} + +brightmap sprite CENTF6 +{ + iwad + disablefullbright +} + +brightmap sprite CENTF7 +{ + iwad + disablefullbright +} + +brightmap sprite CENTF8 +{ + map "brightmaps/hexen/CENTF8.png" + iwad + disablefullbright +} + +brightmap sprite ICEYG1 +{ + map "brightmaps/hexen/ICEYG1.png" + iwad + disablefullbright +} + +brightmap sprite ICEYG2G8 +{ + map "brightmaps/hexen/ICEYG2G8.png" + iwad + disablefullbright +} + +brightmap sprite ICEYG3G7 +{ + map "brightmaps/hexen/ICEYG3G7.png" + iwad + disablefullbright +} + +brightmap sprite ICEYG4G6 +{ + map "brightmaps/hexen/ICEYG4G6.png" + iwad + disablefullbright +} + +brightmap sprite ICEYG5 +{ + map "brightmaps/hexen/ICEYG5.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF1 +{ + map "brightmaps/hexen/MAGEF1.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF2 +{ + map "brightmaps/hexen/MAGEF2.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF3 +{ + map "brightmaps/hexen/MAGEF3.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF4 +{ + map "brightmaps/hexen/MAGEF4.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF5 +{ + map "brightmaps/hexen/MAGEF5.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF6 +{ + map "brightmaps/hexen/MAGEF6.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF7 +{ + map "brightmaps/hexen/MAGEF7.png" + iwad + disablefullbright +} + +brightmap sprite MAGEF8 +{ + map "brightmaps/hexen/MAGEF8.png" + iwad + disablefullbright +} + +brightmap sprite WRTHE1 +{ + map "brightmaps/hexen/WRTHE1.png" + iwad + disablefullbright +} + +brightmap sprite WRTHE2E8 +{ + map "brightmaps/hexen/WRTHE2E8.png" + iwad + disablefullbright +} + +brightmap sprite WRTHE3E7 +{ + map "brightmaps/hexen/WRTHE3E7.png" + iwad + disablefullbright +} + +brightmap sprite WRTHE4E6 +{ + map "brightmaps/hexen/WRTHE4E6.png" + iwad + disablefullbright +} + +brightmap sprite WRTHE5 +{ + map "brightmaps/hexen/WRTHE5.png" + iwad + disablefullbright +} + +brightmap sprite WRTHF1 +{ + map "brightmaps/hexen/WRTHF1.png" + iwad + disablefullbright +} + +brightmap sprite WRTHF2F8 +{ + map "brightmaps/hexen/WRTHF2F8.png" + iwad + disablefullbright +} + +brightmap sprite WRTHF3F7 +{ + map "brightmaps/hexen/WRTHF3F7.png" + iwad + disablefullbright +} + +brightmap sprite WRTHF4F6 +{ + map "brightmaps/hexen/WRTHF4F6.png" + iwad + disablefullbright +} + +brightmap sprite WRTHF5 +{ + map "brightmaps/hexen/WRTHF5.png" + iwad + disablefullbright +} + +brightmap sprite WRTHG1 +{ + map "brightmaps/hexen/WRTHG1.png" + iwad + disablefullbright +} + +brightmap sprite WRTHG2G8 +{ + map "brightmaps/hexen/WRTHG2G8.png" + iwad + disablefullbright +} + +brightmap sprite WRTHG3G7 +{ + map "brightmaps/hexen/WRTHG3G7.png" + iwad + disablefullbright +} + +brightmap sprite WRTHG4G6 +{ + map "brightmaps/hexen/WRTHG4G6.png" + iwad + disablefullbright +} + +brightmap sprite WRTHG5 +{ + map "brightmaps/hexen/WRTHG5.png" + iwad + disablefullbright +} diff --git a/wadsrc_bm/static/hticdefs.bm b/wadsrc_bm/static/hticdefs.bm new file mode 100644 index 000000000..a61afcf62 --- /dev/null +++ b/wadsrc_bm/static/hticdefs.bm @@ -0,0 +1,692 @@ +brightmap sprite BEASI1 +{ + map "brightmaps/heretic/BEASI1.png" + iwad + disablefullbright +} + +brightmap sprite BEASI2I8 +{ + map "brightmaps/heretic/BEASI2I8.png" + iwad + disablefullbright +} + +brightmap sprite BEASI3I7 +{ + map "brightmaps/heretic/BEASI3I7.png" + iwad + disablefullbright +} + +brightmap sprite CHDLA0 +{ + map "brightmaps/heretic/CHDLA0.png" + iwad + disablefullbright +} + +brightmap sprite CHDLB0 +{ + map "brightmaps/heretic/CHDLB0.png" + iwad + disablefullbright +} + +brightmap sprite CHDLC0 +{ + map "brightmaps/heretic/CHDLC0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKI0 +{ + map "brightmaps/heretic/CLNKI0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKJ0 +{ + map "brightmaps/heretic/CLNKJ0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKK0 +{ + map "brightmaps/heretic/CLNKK0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKL0 +{ + map "brightmaps/heretic/CLNKL0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKM0 +{ + map "brightmaps/heretic/CLNKM0.png" + iwad + disablefullbright +} + +brightmap sprite CLNKN0 +{ + map "brightmaps/heretic/CLNKN0.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD1 +{ + map "brightmaps/heretic/IMPXD1.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD2 +{ + map "brightmaps/heretic/IMPXD2.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD3 +{ + map "brightmaps/heretic/IMPXD3.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD4 +{ + map "brightmaps/heretic/IMPXD4.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD5 +{ + map "brightmaps/heretic/IMPXD5.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD6 +{ + map "brightmaps/heretic/IMPXD6.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD7 +{ + map "brightmaps/heretic/IMPXD7.png" + iwad + disablefullbright +} + +brightmap sprite IMPXD8 +{ + map "brightmaps/heretic/IMPXD8.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE1 +{ + map "brightmaps/heretic/IMPXE1.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE2 +{ + map "brightmaps/heretic/IMPXE2.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE3 +{ + map "brightmaps/heretic/IMPXE3.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE4 +{ + map "brightmaps/heretic/IMPXE4.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE5 +{ + map "brightmaps/heretic/IMPXE5.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE6 +{ + map "brightmaps/heretic/IMPXE6.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE7 +{ + map "brightmaps/heretic/IMPXE7.png" + iwad + disablefullbright +} + +brightmap sprite IMPXE8 +{ + map "brightmaps/heretic/IMPXE8.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF1 +{ + map "brightmaps/heretic/IMPXF1.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF2 +{ + map "brightmaps/heretic/IMPXF2.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF3 +{ + map "brightmaps/heretic/IMPXF3.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF4 +{ + map "brightmaps/heretic/IMPXF4.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF5 +{ + map "brightmaps/heretic/IMPXF5.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF6 +{ + map "brightmaps/heretic/IMPXF6.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF7 +{ + map "brightmaps/heretic/IMPXF7.png" + iwad + disablefullbright +} + +brightmap sprite IMPXF8 +{ + map "brightmaps/heretic/IMPXF8.png" + iwad + disablefullbright +} + +brightmap sprite LICHB1 +{ + map "brightmaps/heretic/LICHB1.png" + iwad + disablefullbright +} + +brightmap sprite LICHB2B8 +{ + map "brightmaps/heretic/LICHB2B8.png" + iwad + disablefullbright +} + +brightmap sprite LICHB3M7 +{ + map "brightmaps/heretic/LICHB3B7.png" + iwad + disablefullbright +} + +brightmap sprite LICHC0 +{ + map "brightmaps/heretic/LICHC0.png" + iwad + disablefullbright +} + +brightmap sprite LICHD0 +{ + map "brightmaps/heretic/LICHD0.png" + iwad + disablefullbright +} + +brightmap sprite LICHE0 +{ + map "brightmaps/heretic/LICHE0.png" + iwad + disablefullbright +} + +brightmap sprite LICHF0 +{ + map "brightmaps/heretic/LICHF0.png" + iwad + disablefullbright +} + +brightmap sprite LICHG0 +{ + map "brightmaps/heretic/LICHG0.png" + iwad + disablefullbright +} + +brightmap sprite LICHH0 +{ + map "brightmaps/heretic/LICHH0.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF1 +{ + map "brightmaps/heretic/PLAYf1.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF2F8 +{ + map "brightmaps/heretic/PLAYf2f8.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF3F7 +{ + map "brightmaps/heretic/PLAYf3f7.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF4F6 +{ + map "brightmaps/heretic/PLAYf4f6.png" + iwad + disablefullbright +} + +brightmap sprite PLAYF5 +{ + iwad + disablefullbright +} + +brightmap sprite SDTHA0 +{ + map "brightmaps/heretic/SDTHA0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHB0 +{ + map "brightmaps/heretic/SDTHB0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHC0 +{ + map "brightmaps/heretic/SDTHC0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHD0 +{ + map "brightmaps/heretic/SDTHD0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHE0 +{ + map "brightmaps/heretic/SDTHE0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHF0 +{ + map "brightmaps/heretic/SDTHF0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHG0 +{ + map "brightmaps/heretic/SDTHG0.png" + iwad + disablefullbright +} + +brightmap sprite SDTHH0 +{ + map "brightmaps/heretic/SDTHH0.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R1 +{ + map "brightmaps/heretic/SOR2R1.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R2 +{ + map "brightmaps/heretic/SOR2R2.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R3 +{ + map "brightmaps/heretic/SOR2R3.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R4 +{ + map "brightmaps/heretic/SOR2R4.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R5 +{ + map "brightmaps/heretic/SOR2R5.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R6 +{ + map "brightmaps/heretic/SOR2R6.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R7 +{ + map "brightmaps/heretic/SOR2R7.png" + iwad + disablefullbright +} + +brightmap sprite SOR2R8 +{ + map "brightmaps/heretic/SOR2R8.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S1 +{ + map "brightmaps/heretic/SOR2S1.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S2 +{ + map "brightmaps/heretic/SOR2S2.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S3 +{ + map "brightmaps/heretic/SOR2S3.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S4 +{ + map "brightmaps/heretic/SOR2S4.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S5 +{ + map "brightmaps/heretic/SOR2S5.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S6 +{ + map "brightmaps/heretic/SOR2S6.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S7 +{ + map "brightmaps/heretic/SOR2S7.png" + iwad + disablefullbright +} + +brightmap sprite SOR2S8 +{ + map "brightmaps/heretic/SOR2S8.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T1 +{ + map "brightmaps/heretic/SOR2T1.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T2 +{ + map "brightmaps/heretic/SOR2T2.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T3 +{ + map "brightmaps/heretic/SOR2T3.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T4 +{ + map "brightmaps/heretic/SOR2T4.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T5 +{ + map "brightmaps/heretic/SOR2T5.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T6 +{ + map "brightmaps/heretic/SOR2T6.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T7 +{ + map "brightmaps/heretic/SOR2T7.png" + iwad + disablefullbright +} + +brightmap sprite SOR2T8 +{ + map "brightmaps/heretic/SOR2T8.png" + iwad + disablefullbright +} + +brightmap sprite VLCOE0 +{ + map "brightmaps/heretic/VLCOE0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDC1 +{ + map "brightmaps/heretic/WZRDC1.png" + iwad + disablefullbright +} + +brightmap sprite WZRDC2C8 +{ + map "brightmaps/heretic/WZRDC2C8.png" + iwad + disablefullbright +} + +brightmap sprite WZRDC3C7 +{ + map "brightmaps/heretic/WZRDC3C7.png" + iwad + disablefullbright +} + +brightmap sprite WZRDC4C6 +{ + map "brightmaps/heretic/WZRDC4C6.png" + iwad + disablefullbright +} + +brightmap sprite WZRDC5 +{ + map "brightmaps/heretic/WZRDC5.png" + iwad + disablefullbright +} + +brightmap sprite WZRDD1 +{ + map "brightmaps/heretic/WZRDD1.png" + iwad + disablefullbright +} + +brightmap sprite WZRDD2D8 +{ + map "brightmaps/heretic/WZRDD2D8.png" + iwad + disablefullbright +} + +brightmap sprite WZRDD3D7 +{ + map "brightmaps/heretic/WZRDD3D7.png" + iwad + disablefullbright +} + +brightmap sprite WZRDD4D6 +{ + map "brightmaps/heretic/WZRDD4D6.png" + iwad + disablefullbright +} + +brightmap sprite WZRDD5 +{ + map "brightmaps/heretic/WZRDD5.png" + iwad + disablefullbright +} + +brightmap sprite WZRDF0 +{ + map "brightmaps/heretic/WZRDF0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDG0 +{ + map "brightmaps/heretic/WZRDG0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDH0 +{ + map "brightmaps/heretic/WZRDH0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDI0 +{ + map "brightmaps/heretic/WZRDI0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDJ0 +{ + map "brightmaps/heretic/WZRDJ0.png" + iwad + disablefullbright +} + +brightmap sprite WZRDK0 +{ + map "brightmaps/heretic/WZRDK0.png" + iwad + disablefullbright +} + diff --git a/wadsrc_bm/static/strfdefs.bm b/wadsrc_bm/static/strfdefs.bm new file mode 100644 index 000000000..75c2fd9c2 --- /dev/null +++ b/wadsrc_bm/static/strfdefs.bm @@ -0,0 +1,1253 @@ +brightmap sprite HMN1F1 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F2 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F3 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F4 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F5 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F6 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F7 +{ + iwad + disablefullbright +} + +brightmap sprite HMN1F8 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF1 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF2 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF3 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF4 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF5 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF6 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF7 +{ + iwad + disablefullbright +} + +brightmap sprite LEADF8 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRE1 +{ + map "brightmaps/strife/MLDRE1.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE2 +{ + map "brightmaps/strife/MLDRE2.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE3 +{ + map "brightmaps/strife/MLDRE3.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE4 +{ + map "brightmaps/strife/MLDRE4.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE5 +{ + map "brightmaps/strife/MLDRE5.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE6 +{ + map "brightmaps/strife/MLDRE6.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE7 +{ + map "brightmaps/strife/MLDRE7.png" + disablefullbright + iwad +} + +brightmap sprite MLDRE8 +{ + map "brightmaps/strife/MLDRE8.png" + disablefullbright + iwad +} + +brightmap sprite MLDRF1 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF2 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF3 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF4 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF5 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF6 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF7 +{ + iwad + disablefullbright +} + +brightmap sprite MLDRF8 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDG1 +{ + map "brightmaps/strife/PGRDG1.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG2 +{ + map "brightmaps/strife/PGRDG2.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG3 +{ + map "brightmaps/strife/PGRDG3.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG4 +{ + map "brightmaps/strife/PGRDG4.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG5 +{ + map "brightmaps/strife/PGRDG5.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG6 +{ + map "brightmaps/strife/PGRDG6.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG7 +{ + map "brightmaps/strife/PGRDG7.png" + disablefullbright + iwad +} + +brightmap sprite PGRDG8 +{ + map "brightmaps/strife/PGRDG8.png" + disablefullbright + iwad +} + +brightmap sprite PGRDH1 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH2 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH3 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH4 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH5 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH6 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH7 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDH8 +{ + iwad + disablefullbright +} + +brightmap sprite PGRDI0 +{ + map "brightmaps/strife/PGRDI0.png" + disablefullbright + iwad +} + +brightmap sprite PGRDJ0 +{ + map "brightmaps/strife/PGRDJ0.png" + disablefullbright + iwad +} + +brightmap sprite PGRDK0 +{ + map "brightmaps/strife/PGRDK0.png" + disablefullbright + iwad +} + +brightmap sprite PGRDL0 +{ + map "brightmaps/strife/PGRDL0.png" + disablefullbright + iwad +} + +brightmap sprite PGRDM0 +{ + map "brightmaps/strife/PGRDM0.png" + disablefullbright + iwad +} + +brightmap sprite PGRDN0 +{ + map "brightmaps/strife/PGRDN0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1G1 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G2 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G3 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G4 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G5 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G6 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G7 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1G8 +{ + iwad + disablefullbright +} + +brightmap sprite ROB1j0 +{ + map "brightmaps/strife/ROB1J0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1K0 +{ + map "brightmaps/strife/ROB1K0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1L0 +{ + map "brightmaps/strife/ROB1L0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1M0 +{ + map "brightmaps/strife/ROB1M0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1N0 +{ + map "brightmaps/strife/ROB1N0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1O0 +{ + map "brightmaps/strife/ROB1O0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1P0 +{ + map "brightmaps/strife/ROB1P0.png" + disablefullbright + iwad +} + +brightmap sprite ROB1Q0 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E1 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E2 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E3 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E4 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E5 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E6 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E7 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2E8 +{ + iwad + disablefullbright +} + +brightmap sprite ROB2F1 +{ + map "brightmaps/strife/ROB2F1.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F2 +{ + map "brightmaps/strife/ROB2F2.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F3 +{ + map "brightmaps/strife/ROB2F3.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F4 +{ + map "brightmaps/strife/ROB2F4.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F5 +{ + map "brightmaps/strife/ROB2F5.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F6 +{ + map "brightmaps/strife/ROB2F6.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F7 +{ + map "brightmaps/strife/ROB2F7.png" + disablefullbright + iwad +} + +brightmap sprite ROB2F8 +{ + map "brightmaps/strife/ROB2F8.png" + disablefullbright + iwad +} + +brightmap sprite ROB2G0 +{ + map "brightmaps/strife/ROB2G0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2H0 +{ + map "brightmaps/strife/ROB2H0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2I0 +{ + map "brightmaps/strife/ROB2I0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2J0 +{ + map "brightmaps/strife/ROB2J0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2K0 +{ + map "brightmaps/strife/ROB2K0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2L0 +{ + map "brightmaps/strife/ROB2L0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2M0 +{ + map "brightmaps/strife/ROB2M0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2N0 +{ + map "brightmaps/strife/ROB2N0.png" + disablefullbright + iwad +} + +brightmap sprite ROB2O0 +{ + map "brightmaps/strife/ROB2O0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F1 +{ + map "brightmaps/strife/ROB3F1.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F2 +{ + map "brightmaps/strife/ROB3F2.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F3 +{ + map "brightmaps/strife/ROB3F3.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F4 +{ + map "brightmaps/strife/ROB3F4.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F5 +{ + map "brightmaps/strife/ROB3F5.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F6 +{ + map "brightmaps/strife/ROB3F6.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F7 +{ + map "brightmaps/strife/ROB3F7.png" + disablefullbright + iwad +} + +brightmap sprite ROB3F8 +{ + map "brightmaps/strife/ROB3F8.png" + disablefullbright + iwad +} + +brightmap sprite ROB3G1 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G2 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G3 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G4 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G5 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G6 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G7 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3G8 +{ + iwad + disablefullbright +} + +brightmap sprite ROB3H1 +{ + map "brightmaps/strife/ROB3H1.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H2 +{ + map "brightmaps/strife/ROB3H2.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H3 +{ + map "brightmaps/strife/ROB3H3.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H4 +{ + map "brightmaps/strife/ROB3H4.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H5 +{ + map "brightmaps/strife/ROB3H5.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H6 +{ + map "brightmaps/strife/ROB3H6.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H7 +{ + map "brightmaps/strife/ROB3H7.png" + disablefullbright + iwad +} + +brightmap sprite ROB3H8 +{ + map "brightmaps/strife/ROB3H8.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I1 +{ + map "brightmaps/strife/ROB3I1.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I2 +{ + map "brightmaps/strife/ROB3I2.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I3 +{ + map "brightmaps/strife/ROB3I3.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I4 +{ + map "brightmaps/strife/ROB3I4.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I5 +{ + map "brightmaps/strife/ROB3I5.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I6 +{ + map "brightmaps/strife/ROB3I6.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I7 +{ + map "brightmaps/strife/ROB3I7.png" + disablefullbright + iwad +} + +brightmap sprite ROB3I8 +{ + map "brightmaps/strife/ROB3I8.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J1 +{ + map "brightmaps/strife/ROB3J1.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J2 +{ + map "brightmaps/strife/ROB3J2.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J3 +{ + map "brightmaps/strife/ROB3J3.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J4 +{ + map "brightmaps/strife/ROB3J4.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J5 +{ + disablefullbright + iwad +} + +brightmap sprite ROB3J6 +{ + map "brightmaps/strife/ROB3J6.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J7 +{ + map "brightmaps/strife/ROB3J7.png" + disablefullbright + iwad +} + +brightmap sprite ROB3J8 +{ + map "brightmaps/strife/ROB3J8.png" + disablefullbright + iwad +} + +brightmap sprite ROB3M0 +{ + map "brightmaps/strife/ROB3M0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3N0 +{ + map "brightmaps/strife/ROB3N0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3O0 +{ + map "brightmaps/strife/ROB3O0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3P0 +{ + map "brightmaps/strife/ROB3P0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3Q0 +{ + map "brightmaps/strife/ROB3Q0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3R0 +{ + disablefullbright + iwad +} + +brightmap sprite ROB3S0 +{ + disablefullbright + iwad +} + +brightmap sprite ROB3T0 +{ + map "brightmaps/strife/ROB3T0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3U0 +{ + map "brightmaps/strife/ROB3U0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3V0 +{ + map "brightmaps/strife/ROB3V0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3W0 +{ + map "brightmaps/strife/ROB3W0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3X0 +{ + map "brightmaps/strife/ROB3X0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3Y0 +{ + map "brightmaps/strife/ROB3Y0.png" + disablefullbright + iwad +} + +brightmap sprite ROB3Z0 +{ + map "brightmaps/strife/ROB3Z0.png" + disablefullbright + iwad +} + +brightmap sprite "ROB3[0" +{ + map "brightmaps/strife/ROB3[0.png" + disablefullbright + iwad +} + +brightmap sprite "ROB3\0" +{ + map "brightmaps/strife/ROB3^0.png" + disablefullbright + iwad +} + +brightmap sprite "ROB3]0" +{ + map "brightmaps/strife/ROB3]0.png" + disablefullbright + iwad +} + +brightmap sprite RBB3A0 +{ + map "brightmaps/strife/RBB3A0.png" + disablefullbright + iwad +} + +brightmap sprite RBB3B0 +{ + map "brightmaps/strife/RBB3B0.png" + disablefullbright + iwad +} + +brightmap sprite PRGRH0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRI0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRJ0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRK0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRL0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRM0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRO0 +{ + map "brightmaps/strife/prgro0.png" + iwad + disablefullbright +} + +brightmap sprite PRGRP0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRQ0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRR0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRS0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRT0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRU0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRV0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRW0 +{ + iwad + disablefullbright +} + +brightmap sprite PRGRX0 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRC1 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRC8C2 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRC7C3 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRC6C4 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRC5 +{ + disablefullbright +} + +brightmap sprite SEWRE0 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRF0 +{ + iwad + disablefullbright +} + +brightmap sprite SEWRG0 +{ + iwad + disablefullbright +} + +brightmap sprite sewrh0 +{ + map "brightmaps/strife/SEWRH0.png" + disablefullbright + iwad +} + +brightmap sprite STLKP0 +{ + map "brightmaps/strife/STLKP0.png" + disablefullbright + iwad +} + +brightmap sprite STLKQ0 +{ + map "brightmaps/strife/STLKQ0.png" + disablefullbright + iwad +} + +brightmap sprite STLKR0 +{ + map "brightmaps/strife/STLKR0.png" + disablefullbright + iwad +} + +brightmap sprite STLKS0 +{ + map "brightmaps/strife/STLKS0.png" + disablefullbright + iwad +} + +brightmap sprite STLKT0 +{ + map "brightmaps/strife/STLKT0.png" + disablefullbright + iwad +} + +brightmap sprite STLKU0 +{ + map "brightmaps/strife/STLKU0.png" + disablefullbright + iwad +} + +brightmap sprite STLKV0 +{ + map "brightmaps/strife/STLKV0.png" + disablefullbright + iwad +} + +brightmap sprite STLKW0 +{ + map "brightmaps/strife/STLKW0.png" + disablefullbright + iwad +} + +brightmap sprite STLKX0 +{ + map "brightmaps/strife/STLKX0.png" + disablefullbright + iwad +} + +brightmap sprite STLKY0 +{ + map "brightmaps/strife/STLKY0.png" + disablefullbright + iwad +} + +brightmap sprite STLKZ0 +{ + map "brightmaps/strife/STLKZ0.png" + disablefullbright + iwad +} + +brightmap sprite "STLK[0" +{ + map "brightmaps/strife/STLK[0.png" + disablefullbright + iwad +} + diff --git a/wadsrc_lights/CMakeLists.txt b/wadsrc_lights/CMakeLists.txt new file mode 100644 index 000000000..92f89314a --- /dev/null +++ b/wadsrc_lights/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required( VERSION 2.4 ) + +add_pk3(lights.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) diff --git a/wadsrc_lights/lights.vcproj b/wadsrc_lights/lights.vcproj new file mode 100644 index 000000000..b3b2cc5d4 --- /dev/null +++ b/wadsrc_lights/lights.vcproj @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wadsrc_lights/static/doomdefs.txt b/wadsrc_lights/static/doomdefs.txt new file mode 100644 index 000000000..4e9f1e760 --- /dev/null +++ b/wadsrc_lights/static/doomdefs.txt @@ -0,0 +1,1258 @@ +// ------------------------------------------------------ +// ------------------ DOOM GAME LIGHTS ------------------ +// ------------------------------------------------------ + +// ------------------ +// -- Doom Weapons -- +// ------------------ + +// Bullet puff +flickerlight BPUFF1 +{ + color 0.5 0.5 0.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight BPUFF2 +{ + color 0.5 0.5 0.0 + size 3 + secondarySize 4 + chance 0.8 +} + +object BulletPuff +{ + frame PUFFA { light BPUFF1 } + frame PUFFB { light BPUFF2 } +} + +// Rocket +pointlight ROCKET +{ + color 1.0 0.7 0.0 + size 56 +} + +flickerlight ROCKET_X1 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight ROCKET_X2 +{ + color 0.5 0.1 0.0 + size 80 + secondarySize 88 + chance 0.3 +} + +flickerlight ROCKET_X3 +{ + color 0.3 0.0 0.0 + size 96 + secondarySize 104 + chance 0.3 +} + +object Rocket +{ + frame MISLA { light ROCKET } + + frame MISLB { light ROCKET_X1 } + frame MISLC { light ROCKET_X2 } + frame MISLD { light ROCKET_X3 } +} + +// Plasma +pointlight PLASMABALL +{ + color 0.0 0.1 1.0 + size 56 +} + +flickerlight PLASMA_X1 +{ + color 0.2 0.2 1.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight PLASMA_X2 +{ + color 0.2 0.2 0.8 + size 80 + secondarySize 88 + chance 0.4 +} + +flickerlight PLASMA_X3 +{ + color 0.1 0.1 0.5 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight PLASMA_X4 +{ + color 0.0 0.0 0.2 + size 8 + secondarySize 16 + chance 0.4 +} + +object PlasmaBall +{ + frame PLSSA { light PLASMABALL } + frame PLSSB { light PLASMABALL } + + frame PLSEA { light PLASMA_X1 } + frame PLSEB { light PLASMA_X2 } + frame PLSEC { light PLASMA_X2 } + frame PLSED { light PLASMA_X3 } + frame PLSEE { light PLASMA_X4 } +} + +// Beta Plasma 1 +pointlight PLASMABALL1 +{ + color 0.1 1.0 0.0 + size 56 +} + +flickerlight PLASMA1_X1 +{ + color 0.2 1.0 0.2 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight PLASMA1_X2 +{ + color 0.2 0.8 0.2 + size 80 + secondarySize 88 + chance 0.4 +} + +flickerlight PLASMA1_X3 +{ + color 0.1 0.5 0.1 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight PLASMA1_X4 +{ + color 0.0 0.2 0.0 + size 8 + secondarySize 16 + chance 0.4 +} + +object PlasmaBall1 +{ + frame PLS1A { light PLASMABALL1 } + frame PLS1B { light PLASMABALL1 } + + frame PLS1C { light PLASMA1_X1 } + frame PLS1D { light PLASMA1_X2 } + frame PLS1E { light PLASMA1_X2 } + frame PLS1F { light PLASMA1_X3 } + frame PLS1G { light PLASMA1_X4 } +} + +// Beta Plasma 2 +pointlight PLASMABALL2 +{ + color 1.0 0.1 0.0 + size 56 +} + +flickerlight PLASMA1_X1 +{ + color 0.9 0.2 0.2 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight PLASMA1_X2 +{ + color 0.6 0.2 0.2 + size 80 + secondarySize 88 + chance 0.4 +} + +flickerlight PLASMA1_X3 +{ + color 0.2 0.0 0.0 + size 8 + secondarySize 16 + chance 0.4 +} + +object PlasmaBall2 +{ + frame PLS2A { light PLASMABALL2 } + frame PLS2B { light PLASMABALL2 } + + frame PLS2C { light PLASMA2_X1 } + frame PLS2D { light PLASMA2_X2 } + frame PLS2E { light PLASMA2_X3 } +} + +// BFG +pointlight BFGBALL +{ + color 0.0 1.0 0.0 + size 80 +} + +flickerlight BFGBALL_X1 +{ + color 0.2 1.0 0.2 + size 80 + secondarySize 88 + chance 0.3 +} + +flickerlight BFGBALL_X2 +{ + color 0.3 1.0 0.3 + size 104 + secondarySize 112 + chance 0.3 +} + +flickerlight BFGBALL_X3 +{ + color 0.5 1.0 0.5 + size 120 + secondarySize 128 + chance 0.3 +} + +flickerlight BFGBALL_X4 +{ + color 0.2 0.7 0.2 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight BFGBALL_X5 +{ + color 0.1 0.3 0.1 + size 48 + secondarySize 56 + chance 0.3 +} + +object BFGBall +{ + frame BFS1A { light BFGBALL } + frame BFS1B { light BFGBALL } + + frame BFE1A { light BFGBALL_X1 } + frame BFE1B { light BFGBALL_X2 } + frame BFE1C { light BFGBALL_X3 } + frame BFE1D { light BFGBALL_X1 } + frame BFE1E { light BFGBALL_X4 } + frame BFE1F { light BFGBALL_X5 } +} + + +object BFGExtra +{ + frame BFE2A { light BFGBALL } + frame BFE2B { light BFGBALL_X1 } + frame BFE2C { light BFGBALL_X4 } + frame BFE2D { light BFGBALL_X5 } +} + + + +// ---------------------- +// -- Doom Decorations -- +// ---------------------- + +// Barrel +pulselight BARREL +{ + color 0.0 0.5 0.0 + size 20 + secondarySize 21 + interval 0.5 + offset 0 36 0 + dontlightself 1 +} + +object ExplosiveBarrel +{ + frame BAR1 { light BARREL } + + frame BEXPC { light ROCKET_X1 } + frame BEXPD { light ROCKET_X2 } + frame BEXPE { light ROCKET_X3 } +} + +// Floor lamp +pointlight LAMP +{ + color 1.0 1.0 0.8 + size 56 + offset 0 44 0 +} + +object Column +{ + frame COLU { light LAMP } +} + +// Short tech lamp +pulselight SMALLLAMP +{ + color 0.8 0.8 1.0 + size 56 + secondarySize 58 + interval 0.4 + offset 0 44 0 +} + +object TechLamp2 +{ + frame TLP2 { light SMALLLAMP } +} + +// Tall tech lamp +pulselight BIGLAMP +{ + color 0.8 0.8 1.0 + size 64 + secondarySize 66 + interval 0.4 + offset 0 72 0 +} + +object TechLamp +{ + frame TLMP { light BIGLAMP } +} + +// Tall red torch +flickerlight2 BIGREDTORCH +{ + color 1.0 0.3 0.0 + size 64 + secondarySize 72 + interval 0.1 + offset 0 60 0 +} + +object RedTorch +{ + frame TRED { light BIGREDTORCH } +} + +// Tall green torch +flickerlight2 BIGGREENTORCH +{ + color 0.0 1.0 0.0 + size 64 + secondarySize 72 + interval 0.1 + offset 0 60 0 +} + +object GreenTorch +{ + frame TGRN { light BIGGREENTORCH } +} + +// Tall blue torch +flickerlight2 BIGBLUETORCH +{ + color 0.0 0.0 1.0 + size 64 + secondarySize 72 + interval 0.1 + offset 0 60 0 +} + +object BlueTorch +{ + frame TBLU { light BIGBLUETORCH } +} + +// Small red torch +flickerlight2 SMALLREDTORCH +{ + color 1.0 0.3 0.0 + size 48 + secondarySize 54 + interval 0.1 + offset 0 35 0 +} + +object ShortRedTorch +{ + frame SMRT { light SMALLREDTORCH } +} + +// Small green torch +flickerlight2 SMALLGREENTORCH +{ + color 0.0 1.0 0.0 + size 48 + secondarySize 54 + interval 0.1 + offset 0 35 0 +} + +object ShortGreenTorch +{ + frame SMGT { light SMALLGREENTORCH } +} + +// Small blue torch +flickerlight2 SMALLBLUETORCH +{ + color 0.0 0.0 1.0 + size 48 + secondarySize 54 + interval 0.1 + offset 0 35 0 +} + +object ShortBlueTorch +{ + frame SMBT { light SMALLBLUETORCH } +} + +// Burning barrel +flickerlight2 FIREBARREL +{ + color 1.0 0.9 0.0 + size 48 + secondarySize 54 + interval 0.1 + offset 0 32 0 +} + +object BurningBarrel +{ + frame FCAN { light FIREBARREL } +} + +// Skulls w/candles +flickerlight2 SKULLCANDLES +{ + color 1.0 1.0 0.0 + size 32 + secondarySize 34 + interval 0.1 + offset 0 24 0 +} + +object HeadCandles +{ + frame POL3 { light SKULLCANDLES } +} + +// Candle +pointlight CANDLE +{ + color 1.0 1.0 0.0 + size 16 + offset 0 16 0 +} + +object Candlestick +{ + frame CAND { light CANDLE } +} + +// Candelabra +pointlight CANDELABRA +{ + color 1.0 1.0 0.0 + size 48 + offset 0 52 0 +} + +object Candelabra +{ + frame CBRA { light CANDELABRA } +} + + + +// ---------------- +// -- Doom Items -- +// ---------------- + +// Soul Sphere +pulselight SOULSPHERE +{ + color 0.0 0.0 1.0 + size 40 + secondarySize 42 + interval 2.0 + offset 0 16 0 +} + +object SoulSphere +{ + frame SOUL { light SOULSPHERE } +} + +// Invulnerability Sphere +pulselight INVULN +{ + color 0.0 1.0 0.0 + size 40 + secondarySize 42 + interval 2.0 + offset 0 16 0 +} + +object InvulnerabilitySphere +{ + frame PINV { light INVULN } +} + +// Blur Sphere +pointlight BLURSPHERE1 +{ + color 1.0 0.0 0.0 + size 40 + offset 0 16 0 +} + +pointlight BLURSPHERE2 +{ + color 0.0 0.0 1.0 + size 32 + offset 0 16 0 +} + +pointlight BLURSPHERE3 +{ + color 0.0 0.0 1.0 + size 24 + offset 0 16 0 +} + +pointlight BLURSPHERE4 +{ + color 0.0 0.0 1.0 + size 16 + offset 0 16 0 +} + +pointlight BLURSPHERE5 +{ + color 0.0 0.0 1.0 + size 8 + offset 0 16 0 +} + +object BlurSphere +{ + frame PINS { light BLURSPHERE1 } + + frame PINSA { light BLURSPHERE2 } + frame PINSB { light BLURSPHERE3 } + frame PINSC { light BLURSPHERE4 } + frame PINSD { light BLURSPHERE5 } +} + +// Health Potion +pulselight HEALTHPOTION +{ + color 0.0 0.0 0.6 + size 16 + secondarySize 18 + interval 2.0 +} + +object HealthBonus +{ + frame BON1 { light HEALTHPOTION } +} + +// Armour Helmet +pulselight ARMORBONUS +{ + color 0.0 0.6 0.0 + size 16 + secondarySize 14 + interval 1.0 + dontlightself 1 +} + +object ArmorBonus +{ + frame BON2 { light ARMORBONUS } +} + +// Blue Keys +object BlueCard +{ + frame BKEY { light HEALTHPOTION } +} + +object BlueSkull +{ + frame BSKU { light HEALTHPOTION } +} + +// Yellow Keys +pulselight YELLOWKEY +{ + color 0.6 0.6 0.0 + size 16 + secondarySize 18 + interval 2.0 +} + +object YellowCard +{ + frame YKEY { light YELLOWKEY } +} + +object YellowSkull +{ + frame YSKU { light YELLOWKEY } +} + +// Red Keys +pulselight REDKEY +{ + color 0.6 0.0 0.0 + size 16 + secondarySize 18 + interval 2.0 +} + +object RedCard +{ + frame RKEY { light REDKEY } +} + +object RedSkull +{ + frame RSKU { light REDKEY } +} + +// Green armour +pointlight GREENARMOR1 +{ + color 0.0 0.6 0.0 + size 48 +} + +pointlight GREENARMOR2 +{ + color 0.0 0.6 0.0 + size 32 +} + +object GreenArmor +{ + frame ARM1A { light GREENARMOR1 } + frame ARM1B { light GREENARMOR2 } +} + +// Blue armour +pointlight BLUEARMOR1 +{ + color 0.0 0.0 0.6 + size 48 +} + +pointlight BLUEARMOR2 +{ + color 0.0 0.0 0.6 + size 32 +} + +object BlueArmor +{ + frame ARM2A { light BLUEARMOR1 } + frame ARM2B { light BLUEARMOR2 } +} + + + +// ------------------ +// -- Doom Enemies -- +// ------------------ + +// Zombies +flickerlight2 ZOMBIEATK +{ + color 1.0 0.8 0.2 + size 48 + secondarySize 56 + interval 1 + offset 0 40 0 +} + +object ZombieMan +{ + frame POSSF { light ZOMBIEATK } +} + +object ShotgunGuy +{ + frame SPOSF { light ZOMBIEATK } +} + +object ChaingunGuy +{ + frame CPOSE { light ZOMBIEATK } + frame CPOSF { light ZOMBIEATK } +} + +object DoomPlayer +{ + frame PLAYF { light ZOMBIEATK } +} + + +// Doom Imp Fireball +pointlight IMPBALL +{ + color 1.0 0.5 0.0 + size 64 +} + +// Doom imp fireball explosion +flickerlight IMPBALL_X1 +{ + color 0.7 0.2 0.0 + size 80 + secondarySize 88 + chance 0.25 +} + +flickerlight IMPBALL_X2 +{ + color 0.4 0.0 0.0 + size 96 + secondarySize 104 + chance 0.25 +} + +flickerlight IMPBALL_X3 +{ + color 0.2 0.0 0.0 + size 112 + secondarySize 120 + chance 0.25 +} + +object DoomImpBall +{ + frame BAL1A { light IMPBALL } + frame BAL1B { light IMPBALL } + + frame BAL1C { light IMPBALL_X1 } + frame BAL1D { light IMPBALL_X2 } + frame BAL1E { light IMPBALL_X3 } +} + +pointlight SPECTRE +{ + color 0.5 0.5 0.5 + size 48 + offset 0 24 0 + subtractive 1 +} + +/* +object Spectre +{ + frame SARG { light SPECTRE } +} +*/ + +// Cacodemon fireball +flickerlight CACOBALL +{ + color 1.0 0.2 0.6 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight CACOBALL_X1 +{ + color 0.9 0.1 0.4 + size 72 + secondarySize 80 + chance 0.25 +} + +flickerlight CACOBALL_X2 +{ + color 0.6 0.0 0.1 + size 88 + secondarySize 96 + chance 0.25 +} + +flickerlight CACOBALL_X3 +{ + color 0.3 0.0 0.0 + size 104 + secondarySize 112 + chance 0.25 +} + +object CacodemonBall +{ + frame BAL2A { light CACOBALL } + frame BAL2B { light CACOBALL } + + frame BAL2C { light CACOBALL_X1 } + frame BAL2D { light CACOBALL_X2 } + frame BAL2E { light CACOBALL_X3 } +} + +// Baron / Hell Knight fireball +pointlight BARONBALL +{ + color 0.0 1.0 0.0 + size 64 +} + +flickerlight BARONBALL_X1 +{ + color 0.0 0.7 0.0 + size 80 + secondarySize 88 + chance 0.25 +} + +flickerlight BARONBALL_X2 +{ + color 0.0 0.4 0.0 + size 96 + secondarySize 104 + chance 0.25 +} + +flickerlight BARONBALL_X3 +{ + color 0.0 0.2 0.0 + size 112 + secondarySize 120 + chance 0.25 +} + +object BaronBall +{ + frame BAL7A { light BARONBALL } + frame BAL7B { light BARONBALL } + + frame BAL7C { light BARONBALL_X1 } + frame BAL7D { light BARONBALL_X2 } + frame BAL7E { light BARONBALL_X3 } +} + +// Lost Soul +flickerlight LOSTSOUL +{ + color 1.0 0.3 0.0 + size 56 + secondarysize 64 + chance 0.1 +} + +flickerlight LOSTSOUL_X1 +{ + color 0.8 0.3 0.0 + size 72 + secondarySize 80 + chance 0.25 +} + +flickerlight LOSTSOUL_X2 +{ + color 0.6 0.2 0.0 + size 88 + secondarySize 96 + chance 0.25 +} + +flickerlight LOSTSOUL_X3 +{ + color 0.4 0.1 0.0 + size 104 + secondarySize 112 + chance 0.25 +} + +flickerlight LOSTSOUL_X4 +{ + color 0.2 0.0 0.0 + size 112 + secondarySize 120 + chance 0.25 +} + +object LostSoul +{ + frame SKULA { light LOSTSOUL } + frame SKULB { light LOSTSOUL } + frame SKULC { light LOSTSOUL } + frame SKULD { light LOSTSOUL } + frame SKULE { light LOSTSOUL } + frame SKULF { light LOSTSOUL } + frame SKULG { light LOSTSOUL } + + frame SKULH { light LOSTSOUL_X1 } + frame SKULI { light LOSTSOUL_X2 } + frame SKULJ { light LOSTSOUL_X3 } + frame SKULK { light LOSTSOUL_X4 } +} + +// Mancubus Fireball +object FatShot +{ + frame MANFA { light IMPBALL } + frame MANFB { light IMPBALL } + + frame MISLB { light ROCKET_X1 } + frame MISLC { light ROCKET_X2 } + frame MISLD { light ROCKET_X3 } +} + +// Arachnotron Fireball +pointlight ARACHPLAS +{ + color 0.6 1.0 0.0 + size 56 +} + +flickerlight ARACHPLAS_X1 +{ + color 0.4 0.8 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight ARACHPLAS_X2 +{ + color 0.6 0.6 0.0 + size 88 + secondarySize 96 + chance 0.3 +} + +flickerlight ARACHPLAS_X3 +{ + color 0.4 0.4 0.0 + size 48 + secondarySize 32 + chance 0.3 +} + +flickerlight ARACHPLAS_X4 +{ + color 0.2 0.2 0.0 + size 24 + secondarySize 16 + chance 0.3 +} + +object ArachnotronPlasma +{ + frame APLSA { light ARACHPLAS } + frame APLSB { light ARACHPLAS } + + frame APBXA { light ARACHPLAS_X1 } + frame APBXB { light ARACHPLAS_X2 } + frame APBXC { light ARACHPLAS_X2 } + frame APBXD { light ARACHPLAS_X3 } + frame APBXE { light ARACHPLAS_X4 } +} + +// Revenant tracer +pointlight TRACER +{ + color 1.0 0.3 0.0 + size 48 +} + +flickerlight TRACER_X1 +{ + color 1.0 0.2 0.0 + size 64 + secondarySize 72 + chance 0.25 +} + +flickerlight TRACER_X2 +{ + color 0.6 0.0 0.0 + size 80 + secondarySize 88 + chance 0.25 +} + +flickerlight TRACER_X3 +{ + color 0.3 0.0 0.0 + size 96 + secondarySize 104 + chance 0.25 +} + +object RevenantTracer +{ + frame FATBA { light TRACER } + frame FATBB { light TRACER } + + frame FBXPA { light TRACER_X1 } + frame FBXPB { light TRACER_X2 } + frame FBXPC { light TRACER_X3 } +} + +// Arch Vile Fire +flickerlight ARCHFIRE1 +{ + color 1.0 1.0 0.0 + size 24 + secondarySize 32 + chance 0.3 + offset 0 8 0 +} + +flickerlight ARCHFIRE2 +{ + color 1.0 1.0 0.0 + size 40 + secondarySize 48 + chance 0.3 + offset 0 24 0 +} + +flickerlight ARCHFIRE3 +{ + color 1.0 1.0 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 32 0 +} + +flickerlight ARCHFIRE4 +{ + color 0.8 0.8 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 40 0 +} + +flickerlight ARCHFIRE5 +{ + color 0.8 0.8 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 48 0 +} + +flickerlight ARCHFIRE6 +{ + color 0.6 0.6 0.0 + size 48 + secondarySize 56 + chance 0.3 + offset 0 64 0 +} + +flickerlight ARCHFIRE7 +{ + color 0.4 0.4 0.0 + size 32 + secondarySize 40 + chance 0.3 + offset 0 72 0 +} + +flickerlight ARCHFIRE8 +{ + color 0.2 0.2 0.0 + size 16 + secondarySize 24 + chance 0.3 + offset 0 80 0 +} + +object ArchvileFire +{ + frame FIREA { light ARCHFIRE1 } + frame FIREB { light ARCHFIRE2 } + frame FIREC { light ARCHFIRE3 } + frame FIRED { light ARCHFIRE4 } + frame FIREE { light ARCHFIRE5 } + frame FIREF { light ARCHFIRE6 } + frame FIREG { light ARCHFIRE7 } + frame FIREH { light ARCHFIRE8 } +} + +// Arch-vile +flickerlight ARCHATK1 +{ + color 1.0 1.0 0.0 + size 32 + secondarySize 48 + chance 0.3 + offset 0 80 0 +} + +flickerlight ARCHATK2 +{ + color 1.0 1.0 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 80 0 +} + +flickerlight ARCHATK3 +{ + color 1.0 1.0 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 64 0 +} + +flickerlight ARCHATK4 +{ + color 1.0 1.0 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 48 0 +} + +flickerlight ARCHATK5 +{ + color 1.0 1.0 0.0 + size 80 + secondarySize 88 + chance 0.3 + offset 0 40 0 +} + +flickerlight ARCHATK6 +{ + color 0.7 0.7 0.0 + size 96 + secondarySize 104 + chance 0.3 + offset 0 40 0 +} + +flickerlight ARCHATK7 +{ + color 0.3 0.3 0.0 + size 104 + secondarySize 112 + chance 0.3 + offset 0 40 0 +} + +pulselight ARCHRES +{ + color 0.6 0.0 0.0 + size 64 + secondarySize 70 + interval 0.5 + offset 0 36 0 +} + +object Archvile +{ + frame VILEH { light ARCHATK1 } + frame VILEI { light ARCHATK2 } + frame VILEJ { light ARCHATK3 } + frame VILEK { light ARCHATK4 } + frame VILEL { light ARCHATK4 } + frame VILEM { light ARCHATK4 } + frame VILEN { light ARCHATK5 } + frame VILEO { light ARCHATK6 } + frame VILEP { light ARCHATK7 } + + frame VILE[ { light ARCHRES } + frame VILE\ { light ARCHRES } + frame VILE] { light ARCHRES } +} + +// ------------------ +// -- Doom Effects -- +// ------------------ + +// Doom Teleport fog +flickerlight DTFOG1 +{ + color 0.4 1.0 0.4 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight DTFOG2 +{ + color 0.4 1.0 0.4 + size 40 + secondarySize 48 + chance 0.4 +} + +flickerlight DTFOG3 +{ + color 0.4 1.0 0.4 + size 24 + secondarySize 32 + chance 0.4 +} + +flickerlight DTFOG4 +{ + color 0.4 1.0 0.4 + size 10 + secondarySize 16 + chance 0.4 +} + +object TeleportFog +{ + frame TFOGA { light DTFOG1 } + frame TFOGB { light DTFOG2 } + frame TFOGC { light DTFOG2 } + frame TFOGD { light DTFOG2 } + frame TFOGE { light DTFOG3 } + frame TFOGF { light DTFOG4 } + frame TFOGI { light DTFOG4 } + frame TFOGJ { light DTFOG3 } +} diff --git a/wadsrc_lights/static/hexndefs.txt b/wadsrc_lights/static/hexndefs.txt new file mode 100644 index 000000000..6c03da6db --- /dev/null +++ b/wadsrc_lights/static/hexndefs.txt @@ -0,0 +1,1604 @@ +// ------------------------------------------------------ +// ----------------- HEXEN GAME LIGHTS ------------------ +// ------------------------------------------------------ + +// ------------------- +// -- Hexen Weapons -- +// ------------------- + +// Charged Axe Puff +flickerlight CAXEPUFF1 +{ + color 0.4 0.4 1.0 + size 40 + secondarySize 44 + chance 0.5 +} + +flickerlight CAXEPUFF2 +{ + color 0.2 0.2 0.8 + size 48 + secondarySize 52 + chance 0.5 +} + +flickerlight CAXEPUFF3 +{ + color 0.0 0.0 0.5 + size 44 + secondarySize 48 + chance 0.5 +} + +object AxePuffGlow +{ + frame FAXER { light CAXEPUFF1 } + frame FAXES { light CAXEPUFF1 } + frame FAXET { light CAXEPUFF2 } + frame FAXEU { light CAXEPUFF2 } + frame FAXEV { light CAXEPUFF3 } + frame FAXEW { light CAXEPUFF3 } + frame FAXEX { light CAXEPUFF3 } +} + +// Flying Hammer +flickerlight THROWHAMMER +{ + color 1.0 0.2 0.0 + size 48 + secondarySize 52 + chance 0.4 +} + +flickerlight THROWHAMMER_X1 +{ + color 1.0 0.7 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight THROWHAMMER_X2 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight THROWHAMMER_X3 +{ + color 1.0 0.7 0.0 + size 72 + secondarySize 80 + chance 0.4 +} + +flickerlight THROWHAMMER_X4 +{ + color 0.8 0.8 0.0 + size 80 + secondarySize 84 + chance 0.4 +} + +flickerlight THROWHAMMER_X5 +{ + color 0.5 0.5 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight THROWHAMMER_X6 +{ + color 0.2 0.2 0.0 + size 40 + secondarySize 48 + chance 0.4 +} + +object HammerMissile +{ + frame FHFXA { light THROWHAMMER } + frame FHFXB { light THROWHAMMER } + frame FHFXC { light THROWHAMMER } + frame FHFXD { light THROWHAMMER } + frame FHFXE { light THROWHAMMER } + frame FHFXF { light THROWHAMMER } + frame FHFXG { light THROWHAMMER } + frame FHFXH { light THROWHAMMER } + + frame FHFXI { light THROWHAMMER_X1 } + frame FHFXJ { light THROWHAMMER_X2 } + frame FHFXK { light THROWHAMMER_X3 } + frame FHFXL { light THROWHAMMER_X4 } + frame FHFXM { light THROWHAMMER_X4 } + frame FHFXN { light THROWHAMMER_X4 } + frame FHFXO { light THROWHAMMER_X4 } + frame FHFXP { light THROWHAMMER_X4 } + frame FHFXQ { light THROWHAMMER_X5 } + frame FHFXR { light THROWHAMMER_X6 } +} + +// Fighter sword shot +flickerlight SWORDSHOT +{ + color 0.0 1.0 0.0 + size 48 + secondarySize 44 + chance 0.4 +} + +flickerlight SWORDSHOT_X1 +{ + color 0.0 1.0 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight SWORDSHOT_X2 +{ + color 0.0 1.0 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight SWORDSHOT_X3 +{ + color 0.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight SWORDSHOT_X4 +{ + color 0.0 0.4 0.0 + size 40 + secondarySize 48 + chance 0.4 +} + +flickerlight SWORDSHOT_X5 +{ + color 0.0 0.2 0.0 + size 32 + secondarySize 40 + chance 0.4 +} + +object FSwordMissile +{ + frame FSFXA { light SWORDSHOT } + frame FSFXB { light SWORDSHOT } + frame FSFXC { light SWORDSHOT } + + frame FSFXD { light SWORDSHOT_X1 } + frame FSFXE { light SWORDSHOT_X2 } + frame FSFXF { light SWORDSHOT_X2 } + frame FSFXG { light SWORDSHOT_X2 } + frame FSFXH { light SWORDSHOT_X3 } + frame FSFXI { light SWORDSHOT_X3 } + frame FSFXJ { light SWORDSHOT_X4 } + frame FSFXK { light SWORDSHOT_X5 } + frame FSFXL { light SWORDSHOT_X5 } +} + +// Cleric Serpent Staff ball +pointlight CSTAFFBALL +{ + color 0.0 1.0 0.0 + size 40 +} + +flickerlight CSTAFFBALL_X1 +{ + color 0.0 1.0 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight CSTAFFBALL_X2 +{ + color 0.0 0.7 0.0 + size 60 + secondarySize 68 + chance 0.3 +} + +flickerlight CSTAFFBALL_X3 +{ + color 0.0 0.5 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight CSTAFFBALL_X4 +{ + color 0.0 0.3 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +object CStaffMissile +{ + frame CSSFD { light CSTAFFBALL } + frame CSSFE { light CSTAFFBALL } + + frame CSSFF { light CSTAFFBALL_X1 } + frame CSSFG { light CSTAFFBALL_X2 } + frame CSSFH { light CSTAFFBALL_X3 } + frame CSSFI { light CSTAFFBALL_X4 } +} + +// Cleric fire hands +flickerlight CFLAMETRAIL +{ + color 1.0 0.8 0.0 + size 40 + secondarySize 44 + chance 0.5 +} + +flickerlight CFLAME1 +{ + color 1.0 0.8 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight CFLAME2 +{ + color 1.0 0.8 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight CFLAME3 +{ + color 0.7 0.4 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight CFLAME4 +{ + color 0.5 0.2 0.0 + size 32 + secondarySize 40 + chance 0.4 +} + +flickerlight CFLAME5 +{ + color 0.2 0.2 0.0 + size 24 + secondarySize 32 + chance 0.4 +} + +object FlamePuff2 +{ + frame CFFXB { light CFLAME1 } + frame CFFXC { light CFLAME2 } + frame CFFXD { light CFLAME2 } + frame CFFXE { light CFLAME2 } + frame CFFXF { light CFLAME2 } + frame CFFXG { light CFLAME2 } + frame CFFXH { light CFLAME2 } + frame CFFXI { light CFLAME2 } + frame CFFXJ { light CFLAME3 } + frame CFFXK { light CFLAME4 } + frame CFFXL { light CFLAME5 } +} + +object CFlameFloor +{ + frame CFFX { light CFLAMETRAIL } +} + +// Wraithverge +flickerlight GHOST +{ + color 1.0 1.0 1.0 + size 56 + secondarySize 52 + chance 0.7 + subtractive 1 +} + +object HolyMissile +{ + frame SPIRP { light GHOST } +} + +object HolySpirit +{ + frame SPIRA { light GHOST } + frame SPIRB { light GHOST } +} + +// Mage wand +pointlight MWAND_X1 +{ + color 0.3 0.3 1.0 + size 32 +} + +pointlight MWAND_X2 +{ + color 0.2 0.2 0.8 + size 40 +} + +pointlight MWAND_X3 +{ + color 0.1 0.1 0.6 + size 48 +} + +pointlight MWAND_X4 +{ + color 0.0 0.0 0.4 + size 56 +} + +object MageWandMissile +{ + frame MWNDE { light MWAND_X1 } + frame MWNDF { light MWAND_X2 } + frame MWNDG { light MWAND_X3 } + frame MWNDH { light MWAND_X4 } +} + +// Frost shards +flickerlight MFROSTSHARD +{ + color 0.3 0.3 1.0 + size 32 + secondarySize 40 + chance 0.3 +} + +flickerlight MFROSTSHARD_X1 +{ + color 0.3 0.3 1.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight MFROSTSHARD_X2 +{ + color 0.2 0.2 0.8 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight MFROSTSHARD_X3 +{ + color 0.1 0.1 0.5 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight MFROSTSHARD_X4 +{ + color 0.0 0.0 0.2 + size 64 + secondarySize 68 + chance 0.3 +} + +object FrostMissile +{ + frame SHRD { light MFROSTSHARD } + + frame SHEXA { light MFROSTSHARD_X1 } + frame SHEXB { light MFROSTSHARD_X2 } + frame SHEXC { light MFROSTSHARD_X3 } + frame SHEXD { light MFROSTSHARD_X4 } +} + +// Mage lightning +flickerlight MAGELIGHT +{ + color 0.4 0.4 1.0 + size 48 + secondarySize 52 + chance 0.7 +} + +object LightningCeiling +{ + frame MLFX { light MAGELIGHT } + frame MLF2 { light MAGELIGHT } +} + +object LightningFloor +{ + frame MLFX { light MAGELIGHT } + frame MLF2 { light MAGELIGHT } +} + +object LightningZap +{ + frame MLFX { light MAGELIGHT } + frame MLF2 { light MAGELIGHT } +} + +// BloodScourge +flickerlight BSBALL +{ + color 1.0 0.2 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight BSBALL_X1 +{ + color 1.0 0.4 0.0 + size 24 + secondarySize 28 + chance 0.3 +} + +flickerlight BSBALL_X2 +{ + color 0.7 0.3 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight BSBALL_X3 +{ + color 0.5 0.2 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight BSBALL_X4 +{ + color 0.3 0.1 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +object MageStaffFX2 +{ + frame MSP2A { light BSBALL } + frame MSP2B { light BSBALL } + frame MSP2C { light BSBALL } + frame MSP2D { light BSBALL } + + frame MSP2E { light BSBALL_X1 } + frame MSP2F { light BSBALL_X2 } + frame MSP2G { light BSBALL_X3 } + frame MSP2H { light BSBALL_X4 } +} + +// ------------------- +// -- Hexen Weapons -- +// ------------------- + +// Stalker slimeball +pointlight STALKERSLIME +{ + color 0.0 1.0 0.0 + size 40 +} + +flickerlight STALKERSLIME_X1 +{ + color 0.0 1.0 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight STALKERSLIME_X2 +{ + color 0.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight STALKERSLIME_X3 +{ + color 0.0 0.5 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight STALKERSLIME_X4 +{ + color 0.0 0.2 0.0 + size 68 + secondarySize 76 + chance 0.4 +} + +object SerpentFX +{ + frame SSFXA { light STALKERSLIME } + frame SSFXB { light STALKERSLIME } + + frame SSFXC { light STALKERSLIME_X1 } + frame SSFXD { light STALKERSLIME_X2 } + frame SSFXE { light STALKERSLIME_X3 } + frame SSFXF { light STALKERSLIME_X3 } + frame SSFXG { light STALKERSLIME_X4 } + frame SSFXH { light STALKERSLIME_X4 } +} + +// Centaur fireball +pointlight TAURBALL +{ + color 0.2 0.2 1.0 + size 48 +} + +flickerlight TAURBALL_X1 +{ + color 0.2 0.2 1.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight TAURBALL_X2 +{ + color 0.2 0.2 0.7 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight TAURBALL_X3 +{ + color 0.1 0.1 0.5 + size 72 + secondarySize 80 + chance 0.4 +} + +flickerlight TAURBALL_X4 +{ + color 0.0 0.0 0.3 + size 80 + secondarySize 88 + chance 0.4 +} + +object CentaurFX +{ + frame CTFXA { light TAURBALL } + + frame CTFXB { light TAURBALL_X1 } + frame CTFXC { light TAURBALL_X2 } + frame CTFXD { light TAURBALL_X3 } + frame CTFXE { light TAURBALL_X4 } + frame CTFXF { light TAURBALL_X4 } +} + +// Green Chaos Serpent fireball +flickerlight SERPENTBALL +{ + color 1.0 0.95 0.0 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight SERPENTBALL_X1 +{ + color 1.0 0.95 0.0 + size 64 + secondarySize 72 + chance 0.5 +} + +flickerlight SERPENTBALL_X2 +{ + color 0.8 0.8 0.0 + size 72 + secondarySize 80 + chance 0.5 +} + +flickerlight SERPENTBALL_X3 +{ + color 0.5 0.5 0.0 + size 88 + secondarySize 96 + chance 0.5 +} + +flickerlight SERPENTBALL_X4 +{ + color 0.2 0.2 0.0 + size 96 + secondarySize 104 + chance 0.5 +} + +object Demon1FX1 +{ + frame DMFXA { light SERPENTBALL } + frame DMFXB { light SERPENTBALL } + frame DMFXC { light SERPENTBALL } + + frame DMFXD { light SERPENTBALL_X1 } + frame DMFXE { light SERPENTBALL_X2 } + frame DMFXF { light SERPENTBALL_X3 } + frame DMFXG { light SERPENTBALL_X4 } + frame DMFXH { light SERPENTBALL_X4 } +} + +// Brown Chaos Serpent gasball +pointlight CSGASBALL +{ + color 0.0 1.0 0.0 + size 48 +} + +flickerlight CSGASBALL_X1 +{ + color 0.0 1.0 0.0 + size 64 + secondarySize 72 + chance 0.5 +} + +flickerlight CSGASBALL_X2 +{ + color 0.0 0.8 0.0 + size 72 + secondarySize 80 + chance 0.5 +} + +flickerlight CSGASBALL_X3 +{ + color 0.0 0.5 0.0 + size 88 + secondarySize 96 + chance 0.5 +} + +flickerlight CSGASBALL_X4 +{ + color 0.0 0.2 0.0 + size 96 + secondarySize 104 + chance 0.5 +} + +object Demon2FX1 +{ + frame D2FXA { light CSGASBALL } + frame D2FXB { light CSGASBALL } + frame D2FXC { light CSGASBALL } + frame D2FXD { light CSGASBALL } + frame D2FXE { light CSGASBALL } + frame D2FXF { light CSGASBALL } + + frame D2FXG { light CSGASBALL_X1 } + frame D2FXH { light CSGASBALL_X2 } + frame D2FXI { light CSGASBALL_X2 } + frame D2FXJ { light CSGASBALL_X3 } + frame D2FXK { light CSGASBALL_X4 } + frame D2FXL { light CSGASBALL_X4 } +} + +// Reaver fireball +pointlight REAVERBALL +{ + color 1.0 0.5 0.0 + size 48 +} + +flickerlight REAVERBALL_X1 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 72 +} + +flickerlight REAVERBALL_X2 +{ + color 0.6 0.2 0.0 + size 60 + secondarySize 68 +} + +flickerlight REAVERBALL_X3 +{ + color 0.2 0.0 0.0 + size 56 + secondarySize 64 +} + +object WraithFX1 +{ + frame WRBLA { light REAVERBALL } + frame WRBLB { light REAVERBALL } + frame WRBLC { light REAVERBALL } + + frame WRBLD { light REAVERBALL_X1 } + frame WRBLE { light REAVERBALL_X2 } + frame WRBLF { light REAVERBALL_X3 } +} + +// Dragon Fireball +flickerlight DRAGONBALL +{ + color 1.0 1.0 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +object DragonFireball +{ + frame DRFXA { light DRAGONBALL } + frame DRFXB { light DRAGONBALL } + frame DRFXC { light DRAGONBALL } + frame DRFXD { light DRAGONBALL } + frame DRFXE { light DRAGONBALL } + frame DRFXF { light DRAGONBALL } + + frame DRFXG { light DRAGONBALL_X1 } + frame DRFXH { light DRAGONBALL_X2 } + frame DRFXI { light DRAGONBALL_X2 } + frame DRFXJ { light DRAGONBALL_X3 } + frame DRFXK { light DRAGONBALL_X4 } +} + +flickerlight DRAGONBALL_X1 +{ + color 0.8 0.8 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight DRAGONBALL_X2 +{ + color 0.6 0.6 0.0 + size 96 + secondarySize 104 + chance 0.3 +} + +flickerlight DRAGONBALL_X3 +{ + color 0.4 0.4 0.0 + size 88 + secondarySize 96 + chance 0.3 +} + +flickerlight DRAGONBALL_X4 +{ + color 0.2 0.2 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +object DragonExplosion +{ + frame CFCFQ { light DRAGONBALL_X1 } + frame CFCFR { light DRAGONBALL_X2 } + frame CFCFS { light DRAGONBALL_X2 } + frame CFCFT { light DRAGONBALL_X2 } + frame CFCFU { light DRAGONBALL_X3 } + frame CFCFV { light DRAGONBALL_X3 } + frame CFCFW { light DRAGONBALL_X4 } +} + +// Bishop fireball +pointlight BISHOPBALL +{ + color 0.6 1.0 0.0 + size 48 +} + +flickerlight BISHOPBALL_X1 +{ + color 0.6 1.0 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight BISHOPBALL_X2 +{ + color 0.2 0.8 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight BISHOPBALL_X3 +{ + color 0.1 0.5 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight BISHOPBALL_X4 +{ + color 0.0 0.3 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +object BishopFX +{ + frame BPFXA { light BISHOPBALL } + frame BPFXB { light BISHOPBALL } + + frame BPFXC { light BISHOPBALL_X1 } + frame BPFXD { light BISHOPBALL_X2 } + frame BPFXE { light BISHOPBALL_X2 } + frame BPFXF { light BISHOPBALL_X3 } + frame BPFXG { light BISHOPBALL_X3 } + frame BPFXH { light BISHOPBALL_X4 } +} + +// Fire gargoyle +flickerlight FGARG +{ + color 1.0 1.0 0.0 + size 40 + secondarySize 48 + chance 0.4 +} + +flickerlight FGARGATK +{ + color 1.0 1.0 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight FGARGBALL_X1 +{ + color 0.8 0.8 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight FGARGBALL_X2 +{ + color 0.5 0.5 0.0 + size 50 + secondarySize 54 + chance 0.4 +} + +flickerlight FGARGBALL_X3 +{ + color 0.2 0.2 0.0 + size 44 + secondarySize 48 + chance 0.4 +} + +object FireDemon +{ + frame FDMNA { light FGARG } + frame FDMNB { light FGARG } + frame FDMNC { light FGARG } + frame FDMND { light FGARG } + frame FDMNH { light FGARG } + frame FDMNI { light FGARG } + frame FDMNJ { light FGARG } + + frame FDMNK { light FGARGATK } +} + +object FireDemonMissile +{ + frame FDMBA { light FGARG } + + frame FDMBB { light FGARGBALL_X1 } + frame FDMBC { light FGARGBALL_X2 } + frame FDMBD { light FGARGBALL_X3 } +} + +// Wendigo +pointlight ICEGUYATK +{ + color 0.3 0.3 1.0 + size 64 +} + +pointlight ICEBALL +{ + color 0.3 0.3 1.0 + size 56 +} + +flickerlight ICEBALL_X1 +{ + color 0.3 0.3 1.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight ICEBALL_X2 +{ + color 0.3 0.3 0.7 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight ICEBALL_X3 +{ + color 0.2 0.2 0.4 + size 72 + secondarySize 74 + chance 0.3 +} + +flickerlight ICEBALL_X4 +{ + color 0.0 0.0 0.2 + size 74 + secondarySize 80 + chance 0.3 +} + +pointlight ICESHARD +{ + color 0.3 0.3 1.0 + size 40 +} + +object IceGuyFX +{ + frame ICPRA { light ICEBALL } + frame ICPRB { light ICEBALL } + frame ICPRC { light ICEBALL } + + frame ICPRD { light ICEBALL_X1 } + frame ICPRE { light ICEBALL_X2 } + frame ICPRF { light ICEBALL_X3 } + frame ICPRG { light ICEBALL_X4 } +} + +object IceGuyFX2 +{ + frame ICPRN { light ICESHARD } + frame ICPRO { light ICESHARD } + frame ICPRP { light ICESHARD } +} + +object IceGuy +{ + frame ICEYG { light ICEGUYATK } +} + +// Heresiarch +flickerlight HARCHATK +{ + color 1.0 0.0 1.0 + size 64 + secondarySize 72 + chance 0.4 +} + +pointlight HARCHBLUCUBE +{ + color 0.0 0.0 1.0 + size 32 +} + +pointlight HARCHGRNCUBE +{ + color 0.0 1.0 0.0 + size 32 +} + +pointlight HARCHPURCUBE +{ + color 1.0 0.0 1.0 + size 32 +} + +flickerlight HARCHBALL_X1 +{ + color 0.8 0.0 0.8 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight HARCHBALL_X2 +{ + color 0.5 0.0 0.5 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight HARCHBALL_X3 +{ + color 0.2 0.0 0.2 + size 72 + secondarySize 76 + chance 0.4 +} + +flickerlight HARCHBALL2_X1 +{ + color 0.0 0.8 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight HARCHBALL2_X2 +{ + color 0.0 0.5 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +flickerlight HARCHBALL2_X3 +{ + color 0.0 0.2 0.0 + size 72 + secondarySize 76 + chance 0.4 +} + +flickerlight HARCHHEAD +{ + color 1.0 0.5 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +object SorcFX1 +{ + frame SBS1 { light HARCHHEAD } +} + +object SorcFX2 +{ + frame SBS2 { light HARCHPURCUBE } +} + +object SorcFX3 +{ + frame SBS3A { light HARCHGRNCUBE } + frame SBS3B { light HARCHGRNCUBE } + + frame SBS3C { light HARCHBALL2_X1 } + frame SBS3D { light HARCHBALL2_X2 } + frame SBS3E { light HARCHBALL2_X3 } +} + +object SorcFX4 +{ + frame SBS4A { light HARCHPURCUBE } + frame SBS4B { light HARCHPURCUBE } + + frame SBS4C { light HARCHBALL_X1 } + frame SBS4D { light HARCHBALL_X2 } + frame SBS4E { light HARCHBALL_X3 } +} + +object SorcBall1 +{ + frame SBMP { light HARCHPURCUBE } +} + +object SorcBall2 +{ + frame SBMB { light HARCHBLUCUBE } +} + +object SorcBall3 +{ + frame SBMG { light HARCHGRNCUBE } +} + +object Heresiarch +{ + frame SORCE { light HARCHATK } + frame SORCF { light HARCHATK } +} + +// Korax +object Korax +{ + frame KORXF { light HARCHATK } + frame KORXG { light HARCHATK } +} + +// ----------------------- +// -- Hexen Decorations -- +// ----------------------- + +// Candles +flickerlight2 HCANDLES +{ + color 1.0 1.0 0.0 + size 16 + secondarySize 20 + interval 0.1 +} + +object ZCandle +{ + frame CNDL { light HCANDLES } +} + +// Twined torch +flickerlight2 TWINETORCH +{ + color 1.0 0.7 0.0 + size 46 + secondarySize 52 + interval 0.1 + offset 0 64 0 +} + +object ZTwinedTorch +{ + frame TWTRA { light TWINETORCH } + frame TWTRB { light TWINETORCH } + frame TWTRC { light TWINETORCH } + frame TWTRD { light TWINETORCH } + frame TWTRE { light TWINETORCH } + frame TWTRF { light TWINETORCH } + frame TWTRG { light TWINETORCH } + frame TWTRH { light TWINETORCH } +} + +object ZTwinedTorchUnlit +{ + frame TWTRA { light TWINETORCH } + frame TWTRB { light TWINETORCH } + frame TWTRC { light TWINETORCH } + frame TWTRD { light TWINETORCH } + frame TWTRE { light TWINETORCH } + frame TWTRF { light TWINETORCH } + frame TWTRG { light TWINETORCH } + frame TWTRH { light TWINETORCH } +} + + +// Wall torch +flickerlight2 WALLTORCH2 +{ + color 1.0 0.7 0.0 + size 24 + secondarySize 28 + interval 0.1 + offset 0 24 0 +} + +object ZWallTorch +{ + frame WLTRA { light WALLTORCH2 } + frame WLTRB { light WALLTORCH2 } + frame WLTRC { light WALLTORCH2 } + frame WLTRD { light WALLTORCH2 } + frame WLTRE { light WALLTORCH2 } + frame WLTRF { light WALLTORCH2 } + frame WLTRG { light WALLTORCH2 } + frame WLTRH { light WALLTORCH2 } +} + + +object ZWallTorchUnlit +{ + frame WLTRA { light WALLTORCH2 } + frame WLTRB { light WALLTORCH2 } + frame WLTRC { light WALLTORCH2 } + frame WLTRD { light WALLTORCH2 } + frame WLTRE { light WALLTORCH2 } + frame WLTRF { light WALLTORCH2 } + frame WLTRG { light WALLTORCH2 } + frame WLTRH { light WALLTORCH2 } +} + + +// Fire bull +flickerlight2 FIREBULL +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 70 + interval 0.1 + offset 0 40 0 +} + +flickerlight2 FIREBULL2 +{ + color 1.0 0.7 0.0 + size 48 + secondarySize 60 + interval 0.1 + offset 0 40 0 +} + +object ZFireBull +{ + frame FBULA { light FIREBULL } + frame FBULB { light FIREBULL } + frame FBULC { light FIREBULL } + frame FBULD { light FIREBULL } + frame FBULE { light FIREBULL } + frame FBULF { light FIREBULL } + frame FBULG { light FIREBULL } + frame FBULI { light FIREBULL2 } + frame FBULJ { light FIREBULL } +} + +object ZFireBullUnlit +{ + frame FBULA { light FIREBULL } + frame FBULB { light FIREBULL } + frame FBULC { light FIREBULL } + frame FBULD { light FIREBULL } + frame FBULE { light FIREBULL } + frame FBULF { light FIREBULL } + frame FBULG { light FIREBULL } + frame FBULI { light FIREBULL2 } + frame FBULJ { light FIREBULL } +} + + +// Cauldron +flickerlight2 CAULFLAME +{ + color 1.0 0.9 0.0 + size 24 + secondarySize 26 + interval 0.1 +} + +object ZCauldron +{ + frame CDRNB { light CAULFLAME } + frame CDRNC { light CAULFLAME } + frame CDRND { light CAULFLAME } + frame CDRNE { light CAULFLAME } + frame CDRNF { light CAULFLAME } + frame CDRNG { light CAULFLAME } + frame CDRNH { light CAULFLAME } +} + +object ZCauldronUnlit +{ + frame CDRNB { light CAULFLAME } + frame CDRNC { light CAULFLAME } + frame CDRND { light CAULFLAME } + frame CDRNE { light CAULFLAME } + frame CDRNF { light CAULFLAME } + frame CDRNG { light CAULFLAME } + frame CDRNH { light CAULFLAME } +} + +// Blue candle +flickerlight2 BCANDLE +{ + color 0.3 0.3 1.0 + size 14 + secondarySize 16 + interval 0.1 +} + +object ZBlueCandle +{ + frame BCAN { light BCANDLE } +} + +// Small flame +object FlameSmall +{ + frame FFSM { light HCANDLES } +} + +object FlameSmallTemp +{ + frame FFSM { light HCANDLES } +} + +// Large flame +flickerlight2 LARGEFLAME +{ + color 1.0 0.7 0.0 + size 40 + secondarySize 48 + interval 0.1 +} + +object FlameLarge +{ + frame FFLG { light LARGEFLAME } +} + +object FlameLargeTemp +{ + frame FFLG { light LARGEFLAME } +} + +// Chandelier +flickerlight2 CHANDELIER +{ + color 1.0 1.0 0.0 + size 64 + secondarySize 68 + interval 0.1 +} + +object ZChandelier +{ + frame CDLR { light CHANDELIER } +} + +// Brass torch +flickerlight2 BRASSTORCH +{ + color 1.0 0.7 0.0 + size 40 + secondarySize 48 + interval 0.1 + offset 0 32 0 +} + +object BrassTorch +{ + frame BRTR { light BRASSTORCH } +} + +// Skull flame +object FireThing +{ + frame FSKL { light BRASSTORCH } +} + +// Teleport smoke +flickerlight2 TELESMOKE +{ + color 1.0 0.0 0.0 + size 64 + secondarySize 72 + interval 0.1 + offset 0 44 0 +} + +object TeleSmoke +{ + frame TSMK { light TELESMOKE } +} + +// Fireball +pointlight HFIREBALL +{ + color 1.0 0.4 0.0 + size 48 +} + +object FireBall +{ + frame FBL1A { light HFIREBALL } + frame FBL1B { light HFIREBALL } +} + +// ----------------- +// -- Hexen Items -- +// ----------------- + +// Blue mana +pointlight MANA1 +{ + color 0.0 0.0 0.7 + size 24 + offset 0 36 0 +} + +object Mana1 +{ + frame MAN1 { light MANA1 } +} + +// Green mana +pointlight MANA2 +{ + color 0.0 0.6 0.0 + size 24 + offset 0 36 0 +} + +object Mana2 +{ + frame MAN2 { light MANA2 } +} + +// Combined mana +pointlight MANA3 +{ + color 0.7 0.0 0.0 + size 24 + offset 0 36 0 +} + +object Mana3 +{ + frame MAN3 { light MANA3 } +} + +// ZXmasTree +flickerlight2 XMASFIRE1 +{ + color 1.0 0.7 0.0 + size 16 + secondarySize 24 + interval 0.1 + offset 0 48 0 +} + + +flickerlight2 XMASFIRE2 +{ + color 1.0 0.8 0.0 + size 32 + secondarySize 48 + interval 0.1 + offset 0 48 0 +} + + +flickerlight2 XMASFIRE3 +{ + color 1.0 0.9 0.0 + size 48 + secondarySize 64 + interval 0.1 + offset 0 32 0 +} + + +flickerlight2 XMASFIRE4 +{ + color 1.0 0.8 0.0 + size 32 + secondarySize 40 + interval 0.1 + offset 0 120 0 +} + + +flickerlight2 XMASFIRE5 +{ + color 1.0 0.7 0.0 + size 12 + secondarySize 20 + interval 0.1 + offset 0 140 0 +} + + +flickerlight2 XMASFIRE6 +{ + color 1.0 0.8 0.0 + size 10 + secondarySize 14 + interval 0.1 + offset 0 148 0 +} + + +object ZXmasTree +{ + frame XMASB { light XMASFIRE1 } + frame XMASC { light XMASFIRE2 } + frame XMASD { light XMASFIRE3 } + frame XMASE { light XMASFIRE3 } + frame XMASF { light XMASFIRE4 } + frame XMASG { light XMASFIRE5 } + frame XMASH { light XMASFIRE6 } +} + + + + +// TreeDestructible +flickerlight2 TDESTRUCT1 +{ + color 1.0 0.8 0.0 + size 48 + secondarySize 56 + interval 0.1 + offset 0 32 0 +} + + +flickerlight2 TDESTRUCT2 +{ + color 1.0 0.9 0.0 + size 56 + secondarySize 72 + interval 0.1 + offset 0 32 0 +} + + +flickerlight2 TDESTRUCT3 +{ + color 1.0 0.8 0.0 + size 40 + secondarySize 48 + interval 0.1 + offset 0 20 0 +} + + +flickerlight2 TDESTRUCT4 +{ + color 1.0 0.7 0.0 + size 16 + secondarySize 24 + interval 0.1 + offset 0 12 0 +} + +flickerlight2 TDESTRUCT5 +{ + color 1.0 0.7 0.0 + size 8 + secondarySize 12 + interval 0.1 + offset 0 4 0 +} + + + + +object TreeDestructible +{ + frame TRDTH { light TDESTRUCT1 } + frame TRDTI { light TDESTRUCT2 } + frame TRDTJ { light TDESTRUCT2 } + frame TRDTK { light TDESTRUCT2 } + frame TRDTL { light TDESTRUCT2 } + frame TRDTM { light TDESTRUCT3 } + frame TRDTN { light TDESTRUCT4 } + frame TRDTO { light TDESTRUCT4 } + frame TRDTP { light TDESTRUCT5 } +} diff --git a/wadsrc_lights/static/hticdefs.txt b/wadsrc_lights/static/hticdefs.txt new file mode 100644 index 000000000..92fa2852d --- /dev/null +++ b/wadsrc_lights/static/hticdefs.txt @@ -0,0 +1,1854 @@ +// ------------------------------------------------------ +// ---------------- HERETIC GAME LIGHTS ----------------- +// ------------------------------------------------------ + +// --------------------- +// -- Heretic Weapons -- +// --------------------- + +// Wand puffs +pointlight WANDPUFF1 +{ + color 1.0 1.0 0.0 + size 32 +} + +pointlight WANDPUFF2 +{ + color 0.7 0.7 0.0 + size 24 +} + +pointlight WANDPUFF3 +{ + color 0.4 0.4 0.0 + size 16 +} + +pointlight WANDPUFF4 +{ + color 0.2 0.2 0.0 + size 8 +} + +object GoldWandPuff1 +{ + frame PUF2A { light WANDPUFF1 } + frame PUF2B { light WANDPUFF2 } + frame PUF2C { light WANDPUFF3 } + frame PUF2D { light WANDPUFF4 } +} + +object GoldWandPuff2 +{ + frame PUF2C { light WANDPUFF3 } + frame PUF2D { light WANDPUFF4 } +} + +// Tomed wand projectile +pointlight WANDBALL +{ + color 1.0 1.0 0.0 + size 24 +} + +pointlight WANDBALL_X1 +{ + color 0.8 0.8 0.0 + size 32 +} + +pointlight WANDBALL_X2 +{ + color 0.6 0.6 0.0 + size 34 +} + +pointlight WANDBALL_X3 +{ + color 0.4 0.4 0.0 + size 36 +} + +pointlight WANDBALL_X4 +{ + color 0.2 0.2 0.0 + size 38 +} + +object GoldWandFX2 +{ + frame FX01C { light WANDBALL } + frame FX01D { light WANDBALL } + + frame FX01E { light WANDBALL_X1 } + frame FX01F { light WANDBALL_X2 } + frame FX01G { light WANDBALL_X3 } + frame FX01H { light WANDBALL_X4 } +} + +// Crossbow secondary projectile +pointlight SMALLBOWBOLT +{ + color 0.0 1.0 0.0 + size 40 +} + +flickerlight SMALLBOWBOLT_X1 +{ + color 0.0 0.7 0.0 + size 48 + secondarySize 52 + chance 0.3 +} + +flickerlight SMALLBOWBOLT_X2 +{ + color 0.0 0.4 0.0 + size 40 + secondarySize 44 + chance 0.3 +} + +flickerlight SMALLBOWBOLT_X3 +{ + color 0.0 0.2 0.0 + size 32 + secondarySize 36 + chance 0.3 +} + +object CrossbowFX3 +{ + frame FX03A { light SMALLBOWBOLT } + + frame FX03C { light SMALLBOWBOLT_X1 } + frame FX03D { light SMALLBOWBOLT_X2 } + frame FX03E { light SMALLBOWBOLT_X3 } +} + +// Crossbow primary proectile +pointlight BIGBOWBOLT +{ + color 0.7 1.0 0.0 + size 64 +} + +flickerlight BIGBOWBOLT_X1 +{ + color 0.4 0.8 0.0 + size 72 + secondarySize 74 + chance 0.3 +} + +flickerlight BIGBOWBOLT_X2 +{ + color 0.4 0.6 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight BIGBOWBOLT_X3 +{ + color 0.2 0.4 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +object CrossbowFX1 +{ + frame FX03B { light BIGBOWBOLT } + + frame FX03H { light BIGBOWBOLT_X1 } + frame FX03I { light BIGBOWBOLT_X2 } + frame FX03J { light BIGBOWBOLT_X3 } +} + +// Tomed crossbow projectile +object CrossbowFX2 +{ + frame FX03B { light BIGBOWBOLT } + + frame FX03H { light BIGBOWBOLT_X1 } + frame FX03I { light BIGBOWBOLT_X2 } + frame FX03J { light BIGBOWBOLT_X3 } +} + +// Tomed crossbow trail (slows down too much :P) +pointlight BOWTRAIL1 +{ + color 0.0 1.0 0.0 + size 24 +} + +pointlight BOWTRAIL2 +{ + color 0.0 0.7 0.0 + size 16 +} + +//object CrossbowFX4 +//{ + //frame FX03F { light BOWTRAIL1 } + //frame FX03G { light BOWTRAIL2 } +//} + +// Claw puff +pointlight CLAWPUFF1 +{ + color 0.4 0.4 1.0 + size 32 +} + +pointlight CLAWPUFF2 +{ + color 0.3 0.3 0.8 + size 24 +} + +pointlight CLAWPUFF3 +{ + color 0.2 0.2 0.6 + size 16 +} + +pointlight CLAWPUFF4 +{ + color 0.1 0.1 0.4 + size 8 +} + +object BlasterPuff +{ + frame FX17A { light CLAWPUFF1 } + frame FX17B { light CLAWPUFF2 } + frame FX17C { light CLAWPUFF3 } + frame FX17D { light CLAWPUFF4 } + frame FX17F { light CLAWPUFF1 } + frame FX17G { light CLAWPUFF2 } + frame FX17H { light CLAWPUFF3 } + frame FX17I { light CLAWPUFF4 } +} + +// Tomed claw puff +pointlight BIGCLAWPUFF1 +{ + color 0.4 0.4 1.0 + size 56 +} + +pointlight BIGCLAWPUFF2 +{ + color 0.3 0.3 0.8 + size 48 +} + +pointlight BIGCLAWPUFF3 +{ + color 0.2 0.2 0.6 + size 40 +} + +pointlight BIGCLAWPUFF4 +{ + color 0.1 0.1 0.4 + size 32 +} + +pointlight BIGCLAWPUFF5 +{ + color 0.0 0.0 0.2 + size 24 +} + +object BlasterFX1 +{ + frame FX18C { light BIGCLAWPUFF1 } + frame FX18D { light BIGCLAWPUFF2 } + frame FX18E { light BIGCLAWPUFF3 } + frame FX18F { light BIGCLAWPUFF4 } + frame FX18G { light BIGCLAWPUFF5 } +} + +// Hellstaff bolt +pointlight HELLSTAFFBALL +{ + color 1.0 0.2 0.2 + size 56 +} + +flickerlight HELLSTAFFBALL_X1 +{ + color 1.0 0.4 0.4 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight HELLSTAFFBALL_X2 +{ + color 0.8 0.3 0.3 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight HELLSTAFFBALL_X3 +{ + color 0.6 0.2 0.2 + size 80 + secondarySize 88 + chance 0.3 +} + +flickerlight HELLSTAFFBALL_X4 +{ + color 0.4 0.1 0.1 + size 88 + secondarySize 96 + chance 0.3 +} + +flickerlight HELLSTAFFBALL_X5 +{ + color 0.2 0.0 0.0 + size 96 + secondarySize 104 + chance 0.3 +} + +object HornRodFX1 +{ + frame FX00A { light HELLSTAFFBALL } + frame FX00B { light HELLSTAFFBALL } + + frame FX00H { light HELLSTAFFBALL_X1 } + frame FX00I { light HELLSTAFFBALL_X2 } + frame FX00J { light HELLSTAFFBALL_X3 } + frame FX00K { light HELLSTAFFBALL_X4 } + frame FX00L { light HELLSTAFFBALL_X5 } +} + +object HornRodFX2 +{ + frame FX00C { light HELLSTAFFBALL } + frame FX00D { light HELLSTAFFBALL } + frame FX00E { light HELLSTAFFBALL } + frame FX00F { light HELLSTAFFBALL } + + frame FX00H { light HELLSTAFFBALL_X1 } + frame FX00I { light HELLSTAFFBALL_X2 } + frame FX00J { light HELLSTAFFBALL_X3 } + frame FX00K { light HELLSTAFFBALL_X4 } + frame FX00L { light HELLSTAFFBALL_X5 } +} + +// Tomed hellstaff rain +pointlight REDRAIN +{ + color 1.0 0.0 0.0 + size 32 +} + +pointlight REDRAIN_X1 +{ + color 1.0 0.4 0.4 + size 48 +} + +pointlight REDRAIN_X2 +{ + color 0.8 0.3 0.3 + size 40 +} + +pointlight REDRAIN_X3 +{ + color 0.5 0.1 0.1 + size 32 +} + +pointlight REDRAIN_X4 +{ + color 0.3 0.0 0.0 + size 24 +} + +object RainPillar +{ + frame FX22A { light REDRAIN } + frame FX22B { light REDRAIN } + + frame FX22C { light REDRAIN_X1 } + frame FX22D { light REDRAIN_X2 } + frame FX22E { light REDRAIN_X3 } + frame FX22F { light REDRAIN_X4 } +} + +// Phoenix rod shot +pointlight PHOENIXSHOT +{ + color 1.0 0.6 0.0 + size 64 +} + +flickerlight PHOENIX_X1 +{ + color 1.0 0.8 0.4 + size 104 + secondarySize 112 + chance 0.3 +} + +flickerlight PHOENIX_X2 +{ + color 1.0 0.6 0.0 + size 88 + secondarySize 96 + chance 0.3 +} + +flickerlight PHOENIX_X3 +{ + color 0.8 0.6 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight PHOENIX_X4 +{ + color 0.6 0.4 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight PHOENIX_X5 +{ + color 0.4 0.2 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight PHOENIX_X6 +{ + color 0.2 0.0 0.0 + size 24 + secondarySize 32 + chance 0.3 +} + +object PhoenixFX1 +{ + frame FX04A { light PHOENIXSHOT } + + frame FX08A { light PHOENIX_X1 } + frame FX08B { light PHOENIX_X2 } + frame FX08C { light PHOENIX_X3 } + frame FX08D { light PHOENIX_X4 } + frame FX08E { light PHOENIX_X5 } + frame FX08F { light PHOENIX_X6 } + frame FX08G { light PHOENIX_X6 } + frame FX08H { light PHOENIX_X6 } +} + +// Phoenix rod flamethrower +flickerlight PHOENIXFLAME +{ + color 0.7 0.4 0.0 + size 48 + secondarySize 56 + chance 0.5 +} + +flickerlight PHOENIXFLAME2 +{ + color 0.5 0.2 0.0 + size 24 + secondarySize 32 + chance 0.5 +} + +flickerlight PHOENIXFLAME3 +{ + color 0.3 0.1 0.0 + size 16 + secondarySize 24 + chance 0.5 +} + +object PhoenixFX2 +{ + frame FX09A { light PHOENIXFLAME } + frame FX09B { light PHOENIXFLAME } + + frame FX09C { light PHOENIXFLAME2 } + frame FX09D { light PHOENIXFLAME3 } +} + +// Mace ball explosion +flickerlight MACEBALL_X1 +{ + color 0.8 0.8 0.2 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight MACEBALL_X2 +{ + color 0.6 0.6 0.1 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight MACEBALL_X3 +{ + color 0.4 0.4 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +flickerlight MACEBALL_X4 +{ + color 0.2 0.2 0.0 + size 16 + secondarySize 24 + chance 0.3 +} + +object MaceFX1 +{ + frame FX02G { light MACEBALL_X1 } + frame FX02H { light MACEBALL_X2 } + frame FX02I { light MACEBALL_X3 } + frame FX02J { light MACEBALL_X4 } +} + +object MaceFX2 +{ + frame FX02G { light MACEBALL_X1 } + frame FX02H { light MACEBALL_X2 } + frame FX02I { light MACEBALL_X3 } + frame FX02J { light MACEBALL_X4 } +} + +object MaceFX3 +{ + frame FX02G { light MACEBALL_X1 } + frame FX02H { light MACEBALL_X2 } + frame FX02I { light MACEBALL_X3 } + frame FX02J { light MACEBALL_X4 } +} + +object MaceFX4 +{ + frame FX02G { light MACEBALL_X1 } + frame FX02H { light MACEBALL_X2 } + frame FX02I { light MACEBALL_X3 } + frame FX02J { light MACEBALL_X4 } +} + +// --------------------- +// -- Heretic Enemies -- +// --------------------- + +// Heretic imp fireball +pointlight HIMPBALL +{ + color 1.0 0.8 0.0 + size 32 +} + +flickerlight HIMPBALL_X1 +{ + color 0.8 0.5 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight HIMPBALL_X2 +{ + color 0.6 0.3 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight HIMPBALL_X3 +{ + color 0.3 0.1 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +object HereticImpBall +{ + frame FX10A { light HIMPBALL } + frame FX10B { light HIMPBALL } + frame FX10C { light HIMPBALL } + + frame FX10D { light HIMPBALL } + frame FX10E { light HIMPBALL_X1 } + frame FX10F { light HIMPBALL_X2 } + frame FX10G { light HIMPBALL_X3 } +} + +// Mummy +flickerlight MUMMYATK +{ + color 1.0 1.0 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +object MummyLeader +{ + frame MUMMY { light MUMMYATK } +} + +object MummyLeaderGhost +{ + frame MUMMY { light MUMMYATK } +} + +// Mummy fireball +flickerlight MUMMYBALL +{ + color 1.0 1.0 0.0 + size 40 + secondarySize 48 + chance 0.4 +} + +flickerlight MUMMYBALL_X1 +{ + color 0.7 0.7 0.0 + size 48 + secondarySize 56 + chance 0.4 +} + +flickerlight MUMMYBALL_X2 +{ + color 0.4 0.4 0.0 + size 56 + secondarySize 64 + chance 0.4 +} + +flickerlight MUMMYBALL_X3 +{ + color 0.2 0.2 0.0 + size 64 + secondarySize 72 + chance 0.4 +} + +object MummyFX1 +{ + frame FX15A { light MUMMYBALL } + frame FX15B { light MUMMYBALL } + frame FX15C { light MUMMYBALL } + + frame FX15D { light MUMMYBALL_X1 } + frame FX15E { light MUMMYBALL_X2 } + frame FX15F { light MUMMYBALL_X3 } +} + +// Green flying axe +pointlight GREENAXE +{ + color 0.0 1.0 0.0 + size 32 +} + +flickerlight GREENAXE_X1 +{ + color 0.0 0.7 0.0 + size 32 + secondarySize 48 + chance 0.3 +} + +flickerlight GREENAXE_X2 +{ + color 0.0 0.4 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight GREENAXE_X3 +{ + color 0.0 0.2 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +object KnightAxe +{ + frame SPAXA { light GREENAXE } + frame SPAXB { light GREENAXE } + frame SPAXC { light GREENAXE } + + frame SPAXD { light GREENAXE_X1 } + frame SPAXE { light GREENAXE_X2 } + frame SPAXF { light GREENAXE_X3 } +} + +// Red flying axe +pointlight REDAXE +{ + color 1.0 0.0 0.0 + size 32 +} + +flickerlight REDAXE_X1 +{ + color 0.7 0.0 0.0 + size 32 + secondarySize 48 + chance 0.3 +} + +flickerlight REDAXE_X2 +{ + color 0.4 0.0 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight REDAXE_X3 +{ + color 0.2 0.0 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +object RedAxe +{ + frame RAXEA { light REDAXE } + frame RAXEB { light REDAXE } + + frame RAXEC { light REDAXE_X1 } + frame RAXED { light REDAXE_X2 } + frame RAXEE { light REDAXE_X3 } +} + +// Disciple fireball +flickerlight DISCIPLEBALL +{ + color 1.0 0.0 1.0 + size 32 + secondarySize 40 + chance 0.3 +} + +flickerlight DISCIPLEBALL_X1 +{ + color 0.7 0.0 0.7 + size 16 + secondarySize 24 + chance 0.3 +} + +flickerlight DISCIPLEBALL_X2 +{ + color 0.3 0.0 0.3 + size 8 + secondarySize 16 + chance 0.3 +} + +object WizardFX1 +{ + frame FX11A { light DISCIPLEBALL } + frame FX11B { light DISCIPLEBALL } + frame FX11C { light DISCIPLEBALL } + + frame FX11D { light DISCIPLEBALL } + frame FX11E { light DISCIPLEBALL } + frame FX11F { light DISCIPLEBALL_X1 } + frame FX11G { light DISCIPLEBALL_X2 } +} + +// Iron lich death explosion +flickerlight IRONLICH1 +{ + color 1.0 0.4 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 40 0 +} + +flickerlight IRONLICH2 +{ + color 1.0 0.7 0.0 + size 80 + secondarySize 88 + chance 0.3 + offset 0 44 0 +} + +flickerlight IRONLICH3 +{ + color 0.8 0.4 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 48 0 +} + +flickerlight IRONLICH4 +{ + color 0.4 0.0 0.0 + size 48 + secondarySize 56 + chance 0.3 + offset 0 40 0 +} + +object Ironlich +{ + frame LICHD { light IRONLICH1 } + frame LICHE { light IRONLICH2 } + frame LICHF { light IRONLICH3 } + frame LICHG { light IRONLICH4 } +} + +// IronLich frost ball +pointlight FROSTBALL +{ + color 0.4 0.4 1.0 + size 48 +} + +pointlight FROSTBALL_X1 +{ + color 0.4 0.4 1.0 + size 64 +} + +pointlight FROSTBALL_X2 +{ + color 0.2 0.2 0.7 + size 56 +} + +pointlight FROSTBALL_X3 +{ + color 0.0 0.0 0.4 + size 48 +} + +pointlight FROSTBALL_X4 +{ + color 0.0 0.0 0.2 + size 40 +} + +object HeadFX1 +{ + frame FX05A { light FROSTBALL } + frame FX05B { light FROSTBALL } + frame FX05C { light FROSTBALL } + + frame FX05D { light FROSTBALL_X1 } + frame FX05E { light FROSTBALL_X2 } + frame FX05F { light FROSTBALL_X3 } + frame FX05G { light FROSTBALL_X4 } +} + +// Frost shard (spawned by frost ball) +pointlight FROSTSHARD +{ + color 0.0 0.0 0.5 + size 32 +} + +object HeadFX2 +{ + frame FX05H { light FROSTSHARD } + frame FX05I { light FROSTSHARD } + frame FX05J { light FROSTSHARD } +} + +// Ironlich fire wall +flickerlight LICHFIRE +{ + color 1.0 0.7 0.0 + size 48 + secondarySize 56 + chance 0.5 +} + +flickerlight LICHFIRE_X1 +{ + color 0.9 0.4 0.0 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight LICHFIRE_X2 +{ + color 0.7 0.1 0.0 + size 48 + secondarySize 56 + chance 0.5 +} + +flickerlight LICHFIRE_X3 +{ + color 0.4 0.0 0.0 + size 40 + secondarySize 48 + chance 0.5 +} + +flickerlight LICHFIRE_X4 +{ + color 0.2 0.0 0.0 + size 32 + secondarySize 40 + chance 0.5 +} + +object HeadFX3 +{ + frame FX06A { light LICHFIRE } + frame FX06B { light LICHFIRE } + frame FX06C { light LICHFIRE } + + frame FX06D { light LICHFIRE_X1 } + frame FX06E { light LICHFIRE_X2 } + frame FX06F { light LICHFIRE_X3 } + frame FX06G { light LICHFIRE_X4 } +} + +// Clinker death explosion +flickerlight CLINK_X1 +{ + color 1.0 0.8 0.0 + size 40 + secondarySize 48 + chance 0.5 +} + +flickerlight CLINK_X2 +{ + color 1.0 0.6 0.0 + size 64 + secondarySize 72 + chance 0.5 +} + +flickerlight CLINK_X3 +{ + color 0.6 0.3 0.0 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight CLINK_X4 +{ + color 0.3 0.0 0.0 + size 48 + secondarySize 56 + chance 0.5 +} + +object Clink +{ + frame CLNKK { light CLINK_X1 } + frame CLNKL { light CLINK_X2 } + frame CLNKM { light CLINK_X3 } + frame CLNKN { light CLINK_X4 } +} + +// Weredragon +flickerlight BEASTATK +{ + color 1.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.5 + offset 0 48 0 +} + +object Beast +{ + frame BEASI { light BEASTATK } +} + +// Weredragon fireball +flickerlight BEASTBALL +{ + color 1.0 0.4 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight BEASTBALL_X1 +{ + color 0.8 0.2 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight BEASTBALL_X2 +{ + color 0.6 0.0 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight BEASTBALL_X3 +{ + color 0.4 0.0 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +flickerlight BEASTBALL_X4 +{ + color 0.2 0.0 0.0 + size 28 + secondarySize 32 + chance 0.3 +} + +object BeastBall +{ + frame FRB1A { light BEASTBALL } + frame FRB1B { light BEASTBALL } + frame FRB1C { light BEASTBALL } + + frame FRB1D { light BEASTBALL_X1 } + frame FRB1E { light BEASTBALL_X2 } + frame FRB1F { light BEASTBALL_X3 } + frame FRB1G { light BEASTBALL_X4 } +} + +// Small ophidian shot +pointlight SNAKESHOT1 +{ + color 0.5 0.3 1.0 + size 24 +} + +flickerlight SNAKESHOT1_X1 +{ + color 0.5 0.3 1.0 + size 24 + secondarySize 26 + chance 0.3 +} + +flickerlight SNAKESHOT1_X2 +{ + color 0.4 0.1 0.7 + size 24 + secondarySize 26 + chance 0.3 +} + +flickerlight SNAKESHOT1_X3 +{ + color 0.3 0.0 0.5 + size 28 + secondarySize 30 + chance 0.3 +} + +flickerlight SNAKESHOT1_X4 +{ + color 0.3 0.0 0.3 + size 26 + secondarySize 28 + chance 0.3 +} + +object SnakeProjA +{ + frame SNFXA { light SNAKESHOT1 } + frame SNFXB { light SNAKESHOT1 } + frame SNFXC { light SNAKESHOT1 } + frame SNFXD { light SNAKESHOT1 } + + frame SNFXE { light SNAKESHOT1_X1 } + frame SNFXF { light SNAKESHOT1_X2 } + frame SNFXG { light SNAKESHOT1_X3 } + frame SNFXH { light SNAKESHOT1_X4 } +} + +// Large ophidian shot +pointlight SNAKESHOT2 +{ + color 1.0 0.6 0.0 + size 32 +} + +flickerlight SNAKESHOT2_X1 +{ + color 1.0 0.6 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight SNAKESHOT2_X2 +{ + color 0.6 0.3 0.0 + size 48 + secondarySize 52 + chance 0.3 +} + +flickerlight SNAKESHOT2_X3 +{ + color 0.3 0.0 0.0 + size 44 + secondarySize 48 + chance 0.3 +} + +object SnakeProjB +{ + frame SNFXJ { light SNAKESHOT2 } + frame SNFXK { light SNAKESHOT2 } + + frame SNFXL { light SNAKESHOT2_X1 } + frame SNFXM { light SNAKESHOT2_X2 } + frame SNFXN { light SNAKESHOT2_X3 } +} + +// Maulotaur fireball +flickerlight MAULBALL +{ + color 1.0 0.7 0.0 + size 40 + secondarySize 48 + chance 0.5 +} + +flickerlight MAULBALL_X1 +{ + color 0.8 0.6 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight MAULBALL_X2 +{ + color 0.8 0.4 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight MAULBALL_X3 +{ + color 0.6 0.2 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight MAULBALL_X4 +{ + color 0.4 0.1 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +object MinotaurFX1 +{ + frame FX12A { light MAULBALL } + frame FX12B { light MAULBALL } + + frame FX12C { light MAULBALL_X1 } + frame FX12D { light MAULBALL_X2 } + frame FX12E { light MAULBALL_X3 } + frame FX12F { light MAULBALL_X3 } + frame FX12G { light MAULBALL_X4 } + frame FX12H { light MAULBALL_X4 } +} + +// Maulotaur ground flame +pulselight MAULFLAME +{ + color 1.0 0.7 0.0 + size 1 + secondarySize 64 + interval 6.0 +} + +flickerlight MAULFLAME_X1 +{ + color 1.0 0.7 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight MAULFLAME_X2 +{ + color 1.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight MAULFLAME_X3 +{ + color 0.7 0.4 0.0 + size 64 + secondarySize 68 + chance 0.3 +} + +flickerlight MAULFLAME_X4 +{ + color 0.5 0.1 0.0 + size 68 + secondarySize 72 + chance 0.3 +} + +flickerlight MAULFLAME_X5 +{ + color 0.2 0.0 0.0 + size 72 + secondarySize 76 + chance 0.3 +} + +object MinotaurFX3 +{ + frame FX13B { light MAULFLAME } + frame FX13C { light MAULFLAME } + frame FX13D { light MAULFLAME } + frame FX13E { light MAULFLAME } + frame FX13F { light MAULFLAME } + frame FX13G { light MAULFLAME } + frame FX13H { light MAULFLAME } + + frame FX13I { light MAULFLAME_X1 } + frame FX13J { light MAULFLAME_X2 } + frame FX13K { light MAULFLAME_X3 } + frame FX13L { light MAULFLAME_X4 } + frame FX13M { light MAULFLAME_X5 } +} + +// D'Sparil serpent fireball +flickerlight SERPENTBALL +{ + color 1.0 0.95 0.0 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight SERPENTBALL_X1 +{ + color 1.0 0.95 0.0 + size 64 + secondarySize 72 + chance 0.5 +} + +flickerlight SERPENTBALL_X2 +{ + color 0.8 0.8 0.0 + size 72 + secondarySize 80 + chance 0.5 +} + +flickerlight SERPENTBALL_X3 +{ + color 0.5 0.5 0.0 + size 88 + secondarySize 96 + chance 0.5 +} + +flickerlight SERPENTBALL_X4 +{ + color 0.2 0.2 0.0 + size 96 + secondarySize 104 + chance 0.5 +} + +object SorcererFX1 +{ + frame FX14A { light SERPENTBALL } + frame FX14B { light SERPENTBALL } + frame FX14C { light SERPENTBALL } + + frame FX14D { light SERPENTBALL_X1 } + frame FX14E { light SERPENTBALL_X2 } + frame FX14F { light SERPENTBALL_X3 } + frame FX14G { light SERPENTBALL_X4 } + frame FX14H { light SERPENTBALL_X4 } +} + +// D'Sparil blue bolt +flickerlight DSPARILBALL +{ + color 0.3 0.3 1.0 + size 56 + secondarySize 64 + chance 0.5 +} + +flickerlight DSPARILBALL_X1 +{ + color 0.3 0.3 1.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight DSPARILBALL_X2 +{ + color 0.2 0.2 0.8 + size 80 + secondarySize 88 + chance 0.3 +} + +flickerlight DSPARILBALL_X3 +{ + color 0.1 0.1 0.6 + size 88 + secondarySize 92 + chance 0.3 +} + +flickerlight DSPARILBALL_X4 +{ + color 0.0 0.0 0.4 + size 82 + secondarySize 86 + chance 0.3 +} + +flickerlight DSPARILBALL_X5 +{ + color 0.0 0.0 0.2 + size 82 + secondarySize 86 + chance 0.3 +} + +object Sorcerer2FX1 +{ + frame FX16A { light DSPARILBALL } + frame FX16B { light DSPARILBALL } + frame FX16C { light DSPARILBALL } + + frame FX16G { light DSPARILBALL_X1 } + frame FX16H { light DSPARILBALL_X2 } + frame FX16I { light DSPARILBALL_X3 } + frame FX16J { light DSPARILBALL_X4 } + frame FX16K { light DSPARILBALL_X5 } + frame FX16L { light DSPARILBALL_X5 } +} + +// D'Sparil +flickerlight DSPARILATK +{ + color 0.3 0.3 1.0 + size 64 + secondarySize 72 + chance 0.5 +} + +object Sorcerer2 +{ + frame SOR2R { light DSPARILATK } + frame SOR2S { light DSPARILATK } + frame SOR2T { light DSPARILATK } +} + +// ------------------------- +// -- Heretic Decorations -- +// ------------------------- + +// Wall Torch +flickerlight2 WALLTORCH +{ + color 1.0 0.8 0.0 + size 32 + secondarySize 36 + interval 0.1 + offset 0 70 0 +} + +object WallTorch +{ + frame WTRH { light WALLTORCH } +} + +// Fire Brazier +flickerlight2 FIREBRAZ +{ + color 1.0 0.8 0.0 + size 68 + secondarySize 76 + interval 0.1 + offset 0 48 0 +} + +object FireBrazier +{ + frame KFR1 { light FIREBRAZ } +} + +// Serpent torch +flickerlight2 SERPTORCH +{ + color 1.0 0.8 0.0 + size 48 + secondarySize 56 + interval 0.1 + offset 0 48 0 +} + +object SerpentTorch +{ + frame SRTC { light SERPTORCH } +} + +// Chandelier +flickerlight2 CHANDELIER +{ + color 1.0 1.0 0.0 + size 64 + secondarySize 68 + interval 0.1 +} + +object Chandelier +{ + frame CHDL { light CHANDELIER } +} + +// Pod +flickerlight POD_X1 +{ + color 0.0 1.0 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight POD_X2 +{ + color 0.0 0.7 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight POD_X3 +{ + color 0.0 0.4 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight POD_X4 +{ + color 0.0 0.2 0.0 + size 80 + secondarySize 88 + chance 0.3 +} + +object Pod +{ + frame PPODC { light POD_X1 } + frame PPODD { light POD_X2 } + frame PPODE { light POD_X3 } + frame PPODF { light POD_X4 } +} + +// Big volcano fireball +flickerlight VOLCANOBALL1 +{ + color 1.0 0.5 0.0 + size 56 + secondarySize 64 + chance 0.5 +} + +object VolcanoBlast +{ + frame VFBL { light VOLCANOBALL1 } +} + +// Small volcano fireball +flickerlight VOLCANOBALL1 +{ + color 1.0 0.5 0.0 + size 40 + secondarySize 48 + chance 0.5 +} + +object VolcanoTBlast +{ + frame VTFB { light VOLCANOBALL1 } +} + +// Blue Key Statue +pointlight BLUESTATUE +{ + color 0.0 0.0 1.0 + size 32 + offset 0 64 0 +} + +object KeyGizmoBlue +{ + frame KGZ1 { light BLUESTATUE } +} + +// Yellow Key Statue +pointlight YELLOWSTATUE +{ + color 1.0 1.0 0.0 + size 32 + offset 0 64 0 +} + +object KeyGizmoYellow +{ + frame KGZ1 { light YELLOWSTATUE } +} + +// Green Key Statue +pointlight GREENSTATUE +{ + color 0.0 1.0 0.0 + size 32 + offset 0 64 0 +} + +object KeyGizmoGreen +{ + frame KGZ1 { light GREENSTATUE } +} + +// ------------------- +// -- Heretic Items -- +// ------------------- + +// Time bomb explosion +flickerlight TIMEBOMB_X1 +{ + color 1.0 0.6 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight TIMEBOMB_X1 +{ + color 0.8 0.4 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight TIMEBOMB_X1 +{ + color 0.6 0.2 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight TIMEBOMB_X1 +{ + color 0.4 0.0 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight TIMEBOMB_X1 +{ + color 0.2 0.0 0.0 + size 80 + secondarySize 88 + chance 0.3 +} + +object ActivatedTimeBomb +{ + frame XPL1A { light TIMEBOMB_X1 } + frame XPL1B { light TIMEBOMB_X2 } + frame XPL1C { light TIMEBOMB_X3 } + frame XPL1D { light TIMEBOMB_X4 } + frame XPL1E { light TIMEBOMB_X5 } + frame XPL1F { light TIMEBOMB_X5 } +} + +// Small wand ammo +pointlight SWANDAMMO +{ + color 1.0 1.0 0.0 + size 8 +} + +object GoldWandAmmo +{ + frame AMG1 { light SWANDAMMO } +} + +// Large wand ammo +pulselight LWANDAMMO +{ + color 1.0 1.0 0.0 + size 16 + secondarySize 18 + interval 2.0 +} + +object GoldWandHefty +{ + frame AMG2 { light LWANDAMMO } +} + +// Ethereal arrows +pointlight ETHARROWS +{ + color 0.0 1.0 0.0 + size 12 + offset 0 8 0 +} + +object CrossbowAmmo +{ + frame AMC1 { light ETHARROWS } +} + +// Quiver of ethereal arrows +pulselight ETHQUIVER +{ + color 0.0 1.0 0.0 + size 16 + secondarySize 18 + interval 2.0 + offset 0 16 0 +} + +object CrossbowHefty +{ + frame AMC2 { light ETHQUIVER } +} + +// Small claw ammo +pulselight SCLAWAMMO +{ + color 0.0 0.0 1.0 + size 8 + secondarySize 10 + interval 2.0 +} + +object BlasterAmmo +{ + frame AMB1 { light SCLAWAMMO } +} + +// Large claw ammo +pulselight LCLAWAMMO +{ + color 0.0 0.0 1.0 + size 16 + secondarySize 18 + interval 2.0 + offset 0 6 0 +} + +object BlasterHefty +{ + frame AMB2 { light LCLAWAMMO } +} + +// Small hellstaff ammo +pulselight SSTAFFAMMO +{ + color 1.0 0.0 0.0 + size 8 + secondarySize 10 + interval 2.0 +} + +object SkullRodAmmo +{ + frame AMS1 { light SSTAFFAMMO } +} + +// Large hellstaff ammo +pulselight LSTAFFAMMO +{ + color 1.0 0.0 0.0 + size 16 + secondarySize 18 + interval 2.0 +} + +object SkullRodHefty +{ + frame AMS2 { light LSTAFFAMMO } +} + +// Small phoenix rod ammo +pulselight SRODAMMO +{ + color 1.0 0.6 0.0 + size 8 + secondarySize 10 + interval 2.0 +} + +object PhoenixRodAmmo +{ + frame AMP1 { light SRODAMMO } +} + +// Large phoenix rod ammo +pulselight LRODAMMO +{ + color 1.0 0.6 0.0 + size 16 + secondarySize 18 + interval 2.0 +} + +object PhoenixRodHefty +{ + frame AMP2 { light LRODAMMO } +} + +// Yellow Key +pulselight HYELLOWKEY +{ + color 1.0 1.0 0.0 + size 24 + secondarySize 26 + interval 2.0 +} +object KeyYellow +{ + frame CKYY { light HYELLOWKEY } +} + +// Blue Key +pulselight HBLUEKEY +{ + color 0.0 0.0 1.0 + size 24 + secondarySize 26 + interval 2.0 +} + +object KeyBlue +{ + frame BKYY { light HBLUEKEY } +} + +// Green Key +pulselight HGREENKEY +{ + color 0.0 1.0 0.0 + size 24 + secondarySize 26 + interval 2.0 +} + +object KeyGreen +{ + frame AKYY { light HGREENKEY } +} + +// --------------------- +// -- Heretic Effects -- +// --------------------- + +// Heretic Teleport fog +pointlight HTFOG1 +{ + color 0.4 0.4 1.0 + size 64 +} + +pointlight HTFOG2 +{ + color 0.4 0.4 1.0 + size 40 +} + +pointlight HTFOG3 +{ + color 0.4 0.4 1.0 + size 16 +} + +flickerlight HTFOG4 +{ + color 0.5 0.5 1.0 + size 40 + secondarySize 48 + chance 0.4 +} + +flickerlight HTFOG5 +{ + color 0.5 0.5 1.0 + size 56 + secondarySize 64 + chance 0.4 +} + +object TeleportFog +{ + frame TELEA { light HTFOG1 } + frame TELEB { light HTFOG2 } + frame TELEC { light HTFOG3 } + frame TELED { light HTFOG4 } + frame TELEE { light HTFOG4 } + frame TELEF { light HTFOG4 } + frame TELEG { light HTFOG5 } + frame TELEH { light HTFOG5 } +} \ No newline at end of file diff --git a/wadsrc_lights/static/strfdefs.txt b/wadsrc_lights/static/strfdefs.txt new file mode 100644 index 000000000..8a2bdcc5d --- /dev/null +++ b/wadsrc_lights/static/strfdefs.txt @@ -0,0 +1,2874 @@ +// ------------------------------------------------------ +// ---------------- STRIFE GAME LIGHTS ------------------ +// ------------------------------------------------------ +// -------------------- +// -- Strife Weapons -- +// -------------------- + +// Bullet puff +flickerlight SPUFF1 +{ + color 1.0 1.0 0.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight SPUFF2 +{ + color 1.0 0.8 0.0 + size 5 + secondarySize 6 + chance 0.8 +} + +flickerlight SPUFF3 +{ + color 1.0 0.6 0.0 + size 8 + secondarySize 10 + chance 0.8 +} + +flickerlight SPUFF4 +{ + color 0.8 0.8 1.0 + size 2 + secondarySize 4 + chance 0.8 +} + +flickerlight SPUFF5 +{ + color 0.8 0.8 1.0 + size 4 + secondarySize 6 + chance 0.8 +} + +flickerlight SPUFF6 +{ + color 0.6 0.6 1.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight SPUFF7 +{ + color 0.4 0.4 0.8 + size 7 + secondarySize 9 + chance 0.8 +} + +flickerlight SPUFF8 +{ + color 1.0 1.0 0.0 + size 2 + secondarySize 4 + chance 0.8 +} + +flickerlight SPUFF9 +{ + color 1.0 0.8 0.0 + size 3 + secondarySize 4 + chance 0.8 +} + +flickerlight SPUFF10 +{ + color 1.0 0.6 0.0 + size 5 + secondarySize 6 + chance 0.8 +} + +flickerlight SPUFF11 +{ + color 1.0 0.4 0.0 + size 7 + secondarySize 8 + chance 0.8 +} + +object StrifePuff +{ + frame PUFYA { light SPUFF1 } + frame PUFYB { light SPUFF2 } + frame PUFYC { light SPUFF3 } + + frame POW3A { light SPUFF4 } + frame POW3B { light SPUFF5 } + frame POW3C { light SPUFF6 } + frame POW3D { light SPUFF7 } + frame POW3E { light SPUFF8 } + frame POW3F { light SPUFF9 } + frame POW3G { light SPUFF10 } + frame POW3H { light SPUFF11 } +} + +flickerlight SSPARK1 +{ + color 0.5 0.5 1.0 + size 4 + secondarySize 6 + chance 0.8 +} + +flickerlight SSPARK2 +{ + color 0.5 0.5 1.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight SSPARK3 +{ + color 0.4 0.4 1.0 + size 8 + secondarySize 10 + chance 0.8 +} + +flickerlight SSPARK4 +{ + color 0.3 0.3 1.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight SSPARK5 +{ + color 0.2 0.2 1.0 + size 4 + secondarySize 6 + chance 0.8 +} + +object StrifeSpark +{ + frame POW3A { light SPUFF4 } + frame POW3B { light SPUFF5 } + frame POW3C { light SPUFF6 } + frame POW3D { light SPUFF7 } + frame POW3E { light SPUFF8 } + frame POW3F { light SPUFF9 } + frame POW3G { light SPUFF10 } + frame POW3H { light SPUFF11 } + + frame POW2A { light SSPARK5 } + frame POW2B { light SSPARK5 } + frame POW2C { light SSPARK5 } + frame POW2D { light SSPARK5 } + frame POW2E { light SSPARK5 } +} + +// Arrow +flickerlight ARROWZAP1 +{ + color 0.4 0.4 1.0 + size 8 + secondarySize 16 + chance 0.4 +} + +flickerlight ARROWZAP2 +{ + color 0.45 0.45 1.0 + size 16 + secondarySize 24 + chance 0.4 +} + +flickerlight ARROWZAP3 +{ + color 0.5 0.5 1.0 + size 24 + secondarySize 30 + chance 0.4 +} + +flickerlight ARROWZAP4 +{ + color 0.6 0.6 1.0 + size 30 + secondarySize 36 + chance 0.4 +} + +flickerlight ARROWZAP5 +{ + color 0.7 0.7 1.0 + size 36 + secondarySize 40 + chance 0.4 +} + +flickerlight ARROWZAP6 +{ + color 0.8 0.8 1.0 + size 40 + secondarySize 42 + chance 0.4 +} + +object ElectricBolt +{ + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +// Missile +pointlight MISSILE +{ + color 1.0 0.7 0.0 + size 56 + offset -40 0 0 +} + +flickerlight MISSILE_X1 +{ + color 1.0 0.7 0.0 + size 56 + secondarySize 60 + chance 0.3 +} + +flickerlight MISSILE_X2 +{ + color 1.0 0.65 0.0 + size 60 + secondarySize 64 + chance 0.3 +} + +flickerlight MISSILE_X3 +{ + color 1.0 0.6 0.0 + size 64 + secondarySize 68 + chance 0.3 +} + +flickerlight MISSILE_X4 +{ + color 1.0 0.6 0.0 + size 68 + secondarySize 72 + chance 0.3 +} + +flickerlight MISSILE_X5 +{ + color 1.0 0.6 0.0 + size 72 + secondarySize 76 + chance 0.3 +} + +flickerlight MISSILE_X6 +{ + color 1.0 0.6 0.0 + size 76 + secondarySize 80 + chance 0.3 +} + +flickerlight MISSILE_X7 +{ + color 1.0 0.6 0.0 + size 80 + secondarySize 88 + chance 0.3 +} + +object MiniMissile +{ + frame MICRA { light MISSILE } + + frame SMISA { light MISSILE_X1 } + frame SMISB { light MISSILE_X2 } + frame SMISC { light MISSILE_X3 } + frame SMISD { light MISSILE_X4 } + frame SMISE { light MISSILE_X5 } + frame SMISF { light MISSILE_X6 } + frame SMISG { light MISSILE_X7 } +} + +// Flame +pointlight FLMMISSILE +{ + color 1.0 0.7 0.0 + size 56 +} + +pointlight FLMMSL_X1 +{ + color 1.0 0.7 0.0 + size 52 +} + +pointlight FLMMSL_X2 +{ + color 0.8 0.56 0.0 + size 46 +} + +pointlight FLMMSL_X3 +{ + color 0.6 0.42 0.0 + size 38 +} + +pointlight FLMMSL_X4 +{ + color 0.4 0.28 0.0 + size 24 +} + +pointlight FLMMSL_X5 +{ + color 0.2 0.14 0.0 + size 16 +} + +object FlameMissile +{ + frame FRBLA { light FLMMISSILE } + frame FRBLB { light FLMMISSILE } + frame FRBLC { light FLMMISSILE } + + frame FRBLD { light FLMMSL_X1 } + frame FRBLE { light FLMMSL_X2 } + frame FRBLF { light FLMMSL_X3 } + frame FRBLG { light FLMMSL_X4 } + frame FRBLH { light FLMMSL_X5 } +} + +// Mauler +flickerlight MPUFFG +{ + color 0.0 1.0 0.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight MPUFF1 +{ + color 1.0 1.0 1.0 + size 6 + secondarySize 8 + chance 0.8 +} + +flickerlight MPUFF2 +{ + color 1.0 1.0 1.0 + size 8 + secondarySize 10 + chance 0.8 +} + +flickerlight MPUFF3 +{ + color 1.0 1.0 1.0 + size 10 + secondarySize 12 + chance 0.8 +} + +flickerlight MPUFF4 +{ + color 1.0 1.0 1.0 + size 12 + secondarySize 14 + chance 0.8 +} + +flickerlight MPUFF5 +{ + color 1.0 1.0 1.0 + size 14 + secondarySize 16 + chance 0.8 +} + +object MaulerPuff +{ + frame MPUFA { light MPUFFG } + frame MPUFB { light MPUFFG } + frame POW1A { light MPUFF1 } + frame POW1B { light MPUFF2 } + frame POW1C { light MPUFF3 } + frame POW1D { light MPUFF4 } + frame POW1E { light MPUFF5 } +} + +pointlight MTORPEDO +{ + color 0.0 1.0 0.0 + size 80 +} + +flickerlight MTORP_X1 +{ + color 0.5 1.0 0.5 + size 80 + secondarySize 84 + chance 0.3 +} + +flickerlight MTORP_X2 +{ + color 0.4 1.0 0.4 + size 84 + secondarySize 88 + chance 0.3 +} + +flickerlight MTORP_X3 +{ + color 0.2 1.0 0.2 + size 88 + secondarySize 92 + chance 0.3 +} + +flickerlight MTORP_X4 +{ + color 0.125 0.5 0.125 + size 92 + secondarySize 96 + chance 0.3 +} + +flickerlight MTORP_X5 +{ + color 0.0 0.25 0.0 + size 96 + secondarySize 100 + chance 0.3 +} + +object MaulerTorpedo +{ + frame TORP { light MTORPEDO } + + frame THITA { light MTORP_X1 } + frame THITB { light MTORP_X2 } + frame THITC { light MTORP_X3 } + frame THITD { light MTORP_X4 } + frame THITE { light MTORP_X5 } +} + +flickerlight MWAVE_X1 +{ + color 0.0 1.0 0.0 + size 112 + secondarySize 128 + chance 0.3 +} + +flickerlight MWAVE_X2 +{ + color 0.0 0.75 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight MWAVE_X3 +{ + color 0.0 0.5 0.0 + size 24 + secondarySize 32 + chance 0.3 +} + +object MaulerTorpedoWave +{ + frame TWAVA { light MWAVE_X1 } + frame TWAVB { light MWAVE_X2 } + frame TWAVC { light MWAVE_X3 } +} + +// High Explosive Grenade +flickerlight HEGRENADE_X1 +{ + color 1.0 0.30 0.10 + size 80 + secondarySize 84 + chance 0.3 +} + +flickerlight HEGRENADE_X2 +{ + color 1.0 0.28 0.08 + size 72 + secondarySize 76 + chance 0.3 + offset 0 28 0 +} + +flickerlight HEGRENADE_X3 +{ + color 1.0 0.26 0.10 + size 57 + secondarySize 62 + chance 0.3 + offset 0 40 0 +} + +flickerlight HEGRENADE_X4 +{ + color 1.0 0.24 0.08 + size 28 + secondarySize 32 + chance 0.3 + offset 0 64 0 +} + +object HEGrenade +{ + frame BNG4A { light POWCRYS_X1 } + frame BNG4B { light POWCRYS_X2 } + frame BNG4C { light POWCRYS_X3 } + frame BNG4D { light POWCRYS_X4 } + frame BNG4E { light POWCRYS_X5 } + frame BNG4F { light POWCRYS_X6 } + frame BNG4G { light POWCRYS_X7 } + frame BNG4H { light POWCRYS_X8 } + frame BNG4I { light POWCRYS_X9 } + frame BNG4J { light POWCRYS_X10 } + + frame BNG4K { light HEGRENADE_X1 } + frame BNG4L { light HEGRENADE_X2 } + frame BNG4M { light HEGRENADE_X3 } + frame BNG4N { light HEGRENADE_X4 } +} + +// Phosphorous Fire Grenade +flickerlight PHFIRE_FX1 +{ + color 1.0 0.75 0.0 + size 28 + secondarySize 32 + chance 0.3 +} + +flickerlight PHFIRE_FX2 +{ + color 1.0 0.7 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight PHFIRE_FX3 +{ + color 1.0 0.65 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight PHFIRE_FX4 +{ + color 1.0 0.55 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight PHFIRE_FX5 +{ + color 1.0 0.5 0.0 + size 66 + secondarySize 72 + chance 0.3 +} + +flickerlight PHFIRE_FX6 +{ + color 1.0 0.55 0.0 + size 66 + secondarySize 72 + chance 0.3 +} + +flickerlight PHFIRE_FX7 +{ + color 1.0 0.6 0.0 + size 66 + secondarySize 72 + chance 0.3 +} + +flickerlight PHFIRE_FX8 +{ + color 1.0 0.5 0.0 + size 60 + secondarySize 68 + chance 0.3 +} + +flickerlight PHFIRE_FX9 +{ + color 1.0 0.4 0.0 + size 48 + secondarySize 52 + chance 0.3 +} + +flickerlight PHFIRE_FX10 +{ + color 1.0 0.45 0.0 + size 44 + secondarySize 48 + chance 0.3 +} + +flickerlight PHFIRE_FX11 +{ + color 1.0 0.3 0.0 + size 36 + secondarySize 40 + chance 0.3 +} + +object PhosphorousFire +{ + frame FLBEA { light PHFIRE_FX1 } + frame FLBEB { light PHFIRE_FX2 } + frame FLBEC { light PHFIRE_FX3 } + frame FLBED { light PHFIRE_FX4 } + frame FLBEE { light PHFIRE_FX5 } + frame FLBEF { light PHFIRE_FX6 } + frame FLBEG { light PHFIRE_FX7 } + + frame FLBEH { light PHFIRE_FX8 } + frame FLBEI { light PHFIRE_FX9 } + frame FLBEJ { light PHFIRE_FX10 } + frame FLBEK { light PHFIRE_FX11 } +} + +// ------------------ +// -- Strife Items -- +// ------------------ + +// Degnin Ore +flickerlight DEGORE_X1 +{ + color 1.0 0.6 0.0 + size 32 + secondarySize 40 + chance 0.3 +} + +flickerlight DEGORE_X2 +{ + color 1.0 0.8 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight DEGORE_X3 +{ + color 1.0 0.8 0.0 + size 44 + secondarySize 52 + chance 0.3 +} + +flickerlight DEGORE_X4 +{ + color 1.0 0.75 0.0 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight DEGORE_X5 +{ + color 1.0 0.7 0.0 + size 52 + secondarySize 60 + chance 0.3 +} + +flickerlight DEGORE_X6 +{ + color 1.0 0.5 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight DEGORE_X7 +{ + color 0.5 0.125 0.0 + size 60 + secondarySize 68 + chance 0.3 +} + +flickerlight DEGORE_X8 +{ + color 0.25 0.05 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +object DegninOre +{ + frame BNG3A { light DEGORE_X1 } + frame BNG3B { light DEGORE_X2 } + frame BNG3C { light DEGORE_X3 } + frame BNG3D { light DEGORE_X4 } + frame BNG3E { light DEGORE_X5 } + frame BNG3F { light DEGORE_X6 } + frame BNG3G { light DEGORE_X7 } + frame BNG3H { light DEGORE_X8 } +} + +// Power Coupling +pointlight POWCOUP1 +{ + color 0.5 0.5 1.0 + size 24 +} + +pointlight POWCOUP2 +{ + color 0.7 0.7 1.0 + size 32 +} + +object PowerCoupling +{ + frame COUPA { light POWCOUP1 } + frame COUPB { light POWCOUP2 } +} + +// Energy Ammo +pointlight ENERGY1 +{ + color 0.4 1.0 0.4 + size 16 +} + +pointlight ENERGY2 +{ + color 0.4 1.0 0.4 + size 32 +} + +object EnergyPod +{ + frame BRY1B { light ENERGY1 } +} + +object EnergyPack +{ + frame CPACB { light ENERGY2 } +} + +// ----------------------- +// -- Strife Characters -- +// ----------------------- + +// Humanoids +flickerlight2 HUMNDATK +{ + color 1.0 0.8 0.2 + size 48 + secondarySize 56 + interval 1 + offset 0 40 0 +} + +object Acolyte +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteTan +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteRed +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteRust +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteGray +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteDGreen +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteGold +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteLGreen +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteBlue +{ + frame AGRDF { light HUMNDATK } +} + +object AcolyteShadow +{ + frame AGRDF { light HUMNDATK } +} + +object Rebel +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel1 +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel2 +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel3 +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel4 +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel5 +{ + frame HMN1F { light HUMNDATK } +} + +object Rebel6 +{ + frame HMN1F { light HUMNDATK } +} + +object Macil1 +{ + frame LEADF { light HUMNDATK } +} + +object Macil2 +{ + frame LEADF { light HUMNDATK } +} + +object StrifePlayer +{ + //frame PLAYF { light HUMNDATK } + + frame BURNA { light PHFIRE_FX1 } + frame BURNB { light PHFIRE_FX2 } + frame BURNC { light PHFIRE_FX3 } + frame BURND { light PHFIRE_FX4 } + frame BURNE { light PHFIRE_FX5 } + frame BURNF { light PHFIRE_FX6 } + frame BURNG { light PHFIRE_FX7 } + frame BURNH { light PHFIRE_FX6 } + frame BURNI { light PHFIRE_FX5 } + frame BURNJ { light PHFIRE_FX4 } + frame BURNK { light PHFIRE_FX3 } + frame BURNL { light PHFIRE_FX2 } + frame BURNM { light PHFIRE_FX1 } + frame BURNN { light PHFIRE_FX2 } + frame BURNO { light PHFIRE_FX3 } + frame BURNP { light PHFIRE_FX4 } + frame BURNQ { light PHFIRE_FX5 } + + frame BURNR { light PHFIRE_FX8 } + frame BURNS { light PHFIRE_FX9 } + frame BURNT { light PHFIRE_FX10 } + frame BURNU { light PHFIRE_FX11 } +} + +// Turret +flickerlight2 CTURRETATK1 +{ + color 1.0 0.8 0.2 + size 40 + secondarySize 48 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETATK2 +{ + color 1.0 0.8 0.2 + size 48 + secondarySize 56 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETDTH1 +{ + color 1.0 1.0 1.0 + size 32 + secondarySize 36 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETDTH2 +{ + color 0.9 0.9 0.9 + size 36 + secondarySize 40 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETDTH3 +{ + color 0.7 0.7 0.7 + size 42 + secondarySize 46 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETDTH4 +{ + color 0.5 0.5 0.5 + size 48 + secondarySize 52 + interval 1 + offset 0 0 0 +} + +flickerlight2 CTURRETDTH5 +{ + color 0.3 0.3 0.3 + size 52 + secondarySize 56 + interval 1 + offset 0 0 0 +} + +object CeilingTurret +{ + frame TURTB { light CTURRETATK1 } + frame TURTD { light CTURRETATK2 } + + frame BALLA { light CTURRETDTH1 } + frame BALLB { light CTURRETDTH2 } + frame BALLC { light CTURRETDTH3 } + frame BALLD { light CTURRETDTH4 } + frame BALLE { light CTURRETDTH5 } +} + +// Stalker +flickerlight2 STLKATK +{ + color 1.0 0.8 0.2 + size 48 + secondarySize 56 + interval 1 + offset 0 10 0 +} + +flickerlight STLKDTH1 +{ + color 0.2 1.0 0.2 + size 32 + secondarySize 36 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH2 +{ + color 0.3 1.0 0.3 + size 36 + secondarySize 40 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH3 +{ + color 0.2 1.0 0.2 + size 40 + secondarySize 48 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH4 +{ + color 0.35 1.0 0.35 + size 44 + secondarySize 52 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH5 +{ + color 0.5 1.0 0.2 + size 40 + secondarySize 44 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH6 +{ + color 1.0 0.2 0.0 + size 32 + secondarySize 40 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH7 +{ + color 0.7 0.3 0.0 + size 40 + secondarySize 48 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH8 +{ + color 0.5 0.15 0.0 + size 36 + secondarySize 44 + chance 0.3 + offset 0 15 0 +} + +flickerlight STLKDTH9 +{ + color 0.35 0.05 0.0 + size 32 + secondarySize 36 + chance 0.3 + offset 0 15 0 +} + +object Stalker +{ + frame STLKM { light STLKATK } // Not used in Strife + + frame STLKQ { light STLKDTH1 } + frame STLKR { light STLKDTH1 } + frame STLKS { light STLKDTH1 } + frame STLKT { light STLKDTH2 } + frame STLKU { light STLKDTH3 } + frame STLKV { light STLKDTH4 } + frame STLKW { light STLKDTH5 } + frame STLKX { light STLKDTH6 } + frame STLKY { light STLKDTH7 } + frame STLKZ { light STLKDTH8 } + frame STLK[ { light STLKDTH9 } +} + +// Sentinel +flickerlight SNTNLDTH1 +{ + color 1.0 0.4 0.0 + size 24 + secondarySize 36 + chance 0.3 + offset 0 12 0 +} + +flickerlight SNTNLDTH2 +{ + color 1.0 0.6 0.0 + size 48 + secondarySize 56 + chance 0.3 + offset 0 12 0 +} + +object Sentinel +{ + frame SEWRG { light SNTNLDTH1 } + frame SEWRH { light SNTNLDTH2 } +} + +pointlight SNTNL_FX1 +{ + color 1.0 0.0 0.0 + size 16 +} + +pointlight SNTNL_FX2 +{ + color 0.5 0.0 0.0 + size 16 +} + +pointlight SNTNL_FX3 +{ + color 1.0 0.0 0.0 + size 18 +} + +pointlight SNTNL_FX4 +{ + color 0.8 0.0 0.0 + size 20 +} + +pointlight SNTNL_FX5 +{ + color 0.6 0.0 0.0 + size 22 +} + +pointlight SNTNL_FX6 +{ + color 0.4 0.0 0.0 + size 24 +} + +pointlight SNTNL_FX7 +{ + color 0.2 0.0 0.0 + size 28 +} + +object SentinelFX1 +{ + frame SHT1A { light SNTNL_FX1 } + frame SHT1B { light SNTNL_FX2 } + + frame POW1F { light SNTNL_FX3 } + frame POW1G { light SNTNL_FX4 } + frame POW1H { light SNTNL_FX5 } + frame POW1I { light SNTNL_FX6 } + frame POW1J { light SNTNL_FX7 } +} + +object SentinelFX2 +{ + frame SHT1A { light SNTNL_FX1 } + frame SHT1B { light SNTNL_FX2 } + + frame POW1F { light SNTNL_FX3 } + frame POW1G { light SNTNL_FX4 } + frame POW1H { light SNTNL_FX5 } + frame POW1I { light SNTNL_FX6 } + frame POW1J { light SNTNL_FX7 } +} + +// Crusader +flickerlight CRSDRDTH1 +{ + color 1.0 0.5 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 80 0 +} + +flickerlight CRSDRDTH2 +{ + color 1.0 0.8 0.0 + size 68 + secondarySize 74 + chance 0.3 + offset 0 40 0 +} + +flickerlight CRSDRDTH3 +{ + color 1.0 0.8 0.0 + size 72 + secondarySize 76 + chance 0.3 + offset 0 40 0 +} + +flickerlight CRSDRDTH4 +{ + color 1.0 0.9 0.0 + size 76 + secondarySize 80 + chance 0.3 + offset 0 40 0 +} + +flickerlight CRSDRDTH5 +{ + color 1.0 0.6 0.0 + size 80 + secondarySize 84 + chance 0.3 + offset 0 40 0 +} + +object Crusader +{ + frame ROB2H { light CRSDRDTH1 } + frame ROB2I { light CRSDRDTH2 } + frame ROB2J { light CRSDRDTH3 } + frame ROB2K { light CRSDRDTH4 } + frame ROB2L { light CRSDRDTH5 } + frame ROB2M { light CRSDRDTH4 } + frame ROB2N { light CRSDRDTH3 } + frame ROB2O { light CRSDRDTH2 } +} + +object FastFlameMissile +{ + frame FRBLA { light FLMMISSILE } + frame FRBLB { light FLMMISSILE } + frame FRBLC { light FLMMISSILE } + + frame FRBLD { light FLMMSL_X1 } + frame FRBLE { light FLMMSL_X2 } + frame FRBLF { light FLMMSL_X3 } + frame FRBLG { light FLMMSL_X4 } + frame FRBLH { light FLMMSL_X5 } +} + +object CrusaderMissile +{ + frame MICRA { light MISSILE } + + frame SMISA { light MISSILE_X1 } + frame SMISB { light MISSILE_X2 } + frame SMISC { light MISSILE_X3 } + frame SMISD { light MISSILE_X4 } + frame SMISE { light MISSILE_X5 } + frame SMISF { light MISSILE_X6 } + frame SMISG { light MISSILE_X7 } +} + +// Reaver +flickerlight REAV_X1 +{ + color 1.0 0.3 0.0 + size 16 + secondarySize 20 + chance 0.3 + offset 0 16 16 +} + +flickerlight REAV_X2 +{ + color 1.0 0.2 0.0 + size 32 + secondarySize 40 + chance 0.3 + offset 0 32 -16 +} + +flickerlight REAV_X3 +{ + color 1.0 0.6 0.0 + size 40 + secondarySize 44 + chance 0.3 + offset 0 12 16 +} + +flickerlight REAV_X4 +{ + color 1.0 0.5 0.0 + size 20 + secondarySize 24 + chance 0.3 + offset 0 10 0 +} + +flickerlight REAV_X5 +{ + color 1.0 0.8 0.0 + size 28 + secondarySize 32 + chance 0.3 + offset 0 18 0 +} + +flickerlight REAV_X6 +{ + color 1.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 20 0 +} + +flickerlight REAV_X7 +{ + color 0.5 0.05 0.0 + size 52 + secondarySize 56 + chance 0.3 + offset 0 20 0 +} + +object Reaver +{ + frame ROB1F { light HUMNDATK } + + frame ROB1K { light REAV_X1 } + frame ROB1L { light REAV_X2 } + frame ROB1M { light REAV_X3 } + frame ROB1N { light REAV_X4 } + frame ROB1O { light REAV_X5 } + frame ROB1P { light REAV_X6 } + frame ROB1Q { light REAV_X7 } +} + +// Templar +flickerlight2 TEMPATK +{ + color 0.2 1.0 0.2 + size 48 + secondarySize 56 + interval 1 + offset 20 40 0 +} + +flickerlight TEMP_X1 +{ + color 1.0 0.8 0.2 + size 8 + secondarySize 12 + chance 0.3 + offset 0 20 32 +} + +flickerlight TEMP_X2 +{ + color 1.0 0.5 0.0 + size 32 + secondarySize 36 + chance 0.3 + offset 0 20 24 +} + +flickerlight TEMP_X3 +{ + color 1.0 0.75 0.1 + size 24 + secondarySize 28 + chance 0.3 + offset 0 20 24 +} + +flickerlight TEMP_X4 +{ + color 1.0 0.65 0.1 + size 28 + secondarySize 32 + chance 0.3 + offset 0 20 16 +} + +flickerlight TEMP_X5 +{ + color 1.0 0.6 0.0 + size 30 + secondarySize 34 + chance 0.3 + offset 0 20 8 +} + +flickerlight TEMP_X6 +{ + color 1.0 0.5 0.0 + size 32 + secondarySize 36 + chance 0.3 + offset 0 20 0 +} + +object Templar +{ + frame PGRDG { light TEMPATK } + + frame PGRDI { light TEMP_X1 } + frame PGRDJ { light TEMP_X2 } + frame PGRDK { light TEMP_X3 } + frame PGRDL { light TEMP_X4 } + frame PGRDM { light TEMP_X5 } + frame PGRDN { light TEMP_X6 } +} + +// Inquisitor +flickerlight2 INQATK1 +{ + color 1.0 0.6 0.0 + size 88 + secondarySize 96 + interval 1 + offset 20 72 -40 +} + +flickerlight2 INQATK2 +{ + color 1.0 0.6 0.0 + size 88 + secondarySize 96 + interval 1 + offset 20 96 0 +} + +flickerlight2 INQFLY1 +{ + color 0.5 0.5 1.0 + size 80 + secondarySize 84 + interval 1 + offset -40 36 0 +} + +flickerlight2 INQFLY2 +{ + color 0.33 0.33 1.0 + size 64 + secondarySize 72 + interval 1 + offset -40 36 0 +} + +flickerlight INQDTH1 +{ + color 1.0 0.4 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 72 0 +} + +flickerlight INQDTH2 +{ + color 1.0 0.7 0.0 + size 84 + secondarySize 96 + chance 0.3 + offset 0 64 0 +} + +flickerlight INQDTH3 +{ + color 1.0 0.6 0.0 + size 92 + secondarySize 100 + chance 0.3 + offset 0 56 0 +} + +flickerlight INQDTH4 +{ + color 0.7 0.07 0.0 + size 72 + secondarySize 80 + chance 0.3 + offset 0 40 0 +} + +flickerlight INQDTH5 +{ + color 0.3 0.0 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 40 0 +} + +flickerlight INQDTH6 +{ + color 0.5 0.3 0.0 + size 32 + secondarySize 40 + chance 0.3 + offset 0 32 0 +} + +flickerlight INQDTH7 +{ + color 1.0 0.6 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 32 0 +} + +flickerlight INQDTH8 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 32 0 +} + +flickerlight INQDTH9 +{ + color 1.0 0.7 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 56 0 +} + +flickerlight INQDTH10 +{ + color 1.0 0.6 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 56 0 +} + +flickerlight INQDTH11 +{ + color 1.0 0.5 0.0 + size 100 + secondarySize 128 + chance 0.3 + offset 0 32 0 +} + +flickerlight INQDTH12 +{ + color 1.0 0.4 0.0 + size 80 + secondarySize 96 + chance 0.3 + offset 0 32 0 +} + +flickerlight INQDTH13 +{ + color 1.0 0.3 0.0 + size 60 + secondarySize 72 + chance 0.3 + offset 0 24 0 +} + +flickerlight INQDTH14 +{ + color 0.5 0.15 0.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 18 0 +} + +object Inquisitor +{ + frame ROB3F { light INQATK1 } + frame ROB3J { light INQATK2 } + + frame ROB3H { light INQFLY1 } + frame ROB3I { light INQFLY2 } + + frame ROB3M { light INQDTH1 } + frame ROB3N { light INQDTH2 } + frame ROB3O { light INQDTH3 } + frame ROB3P { light INQDTH4 } + frame ROB3Q { light INQDTH5 } + frame ROB3R { light INQDTH6 } + frame ROB3S { light INQDTH6 } + frame ROB3T { light INQDTH6 } + frame ROB3U { light INQDTH7 } + frame ROB3V { light INQDTH8 } + frame ROB3W { light INQDTH6 } + frame ROB3X { light INQDTH6 } + frame ROB3Y { light INQDTH9 } + frame ROB3Z { light INQDTH10 } + frame ROB3[ { light INQDTH11 } + frame ROB3\ { light INQDTH12 } + frame RBB3] { light INQDTH13 } + frame RBB3A { light INQDTH12 } + frame RBB3B { light INQDTH13 } + frame RBB3C { light INQDTH14 } +} + +flickerlight INQSHOT_X1 +{ + color 1.0 0.8 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight INQSHOT_X2 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight INQSHOT_X3 +{ + color 0.8 0.45 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight INQSHOT_X4 +{ + color 0.5 0.3 0.0 + size 80 + secondarySize 84 + chance 0.3 +} + +flickerlight INQSHOT_X5 +{ + color 1.0 0.6 0.0 + size 56 + secondarySize 60 + chance 0.3 +} + +flickerlight INQSHOT_X6 +{ + color 1.0 0.7 0.0 + size 60 + secondarySize 64 + chance 0.3 +} + +flickerlight INQSHOT_X7 +{ + color 1.0 0.7 0.0 + size 64 + secondarySize 68 + chance 0.3 +} + +flickerlight INQSHOT_X8 +{ + color 1.0 0.6 0.0 + size 40 + secondarySize 48 + chance 0.3 +} + +flickerlight INQSHOT_X9 +{ + color 1.0 0.4 0.0 + size 24 + secondarySize 32 + chance 0.3 +} + +object InquisitorShot +{ + frame BNG2A { light INQSHOT_X1 } + frame BNG2B { light INQSHOT_X2 } + frame BNG2C { light INQSHOT_X3 } + frame BNG2D { light INQSHOT_X4 } + frame BNG2E { light INQSHOT_X5 } + frame BNG2F { light INQSHOT_X6 } + frame BNG2G { light INQSHOT_X7 } + frame BNG2H { light INQSHOT_X8 } + frame BNG2I { light INQSHOT_X9 } +} + +// Programmer +flickerlight PROGATK1 +{ + color 0.5 0.5 1.0 + size 56 + secondarySize 64 + chance 0.3 + offset 0 60 0 +} + +flickerlight PROGATK2 +{ + color 0.6 0.6 1.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 60 0 +} + +flickerlight PROGATK3 +{ + color 0.8 0.8 1.0 + size 80 + secondarySize 96 + chance 0.3 + offset 0 60 0 +} + +flickerlight PROGDTH1 +{ + color 1.0 0.4 0.0 + size 112 + secondarySize 128 + chance 0.3 + offset 0 40 0 +} + +flickerlight PROGDTH2 +{ + color 1.0 0.6 0.0 + size 128 + secondarySize 140 + chance 0.3 + offset 0 40 0 +} + +object Programmer +{ + frame PRGRH { light PROGATK1 } + frame PRGRI { light PROGATK2 } + frame PRGRJ { light PROGATK3 } + + frame PRGRN { light PROGDTH1 } + frame PRGRO { light PROGDTH2 } +} + +flickerlight BASE_X1 +{ + color 1.0 0.55 0.0 + size 96 + secondarySize 112 + chance 0.3 + offset 0 40 0 +} + +flickerlight BASE_X2 +{ + color 1.0 0.50 0.0 + size 80 + secondarySize 96 + chance 0.3 + offset 0 40 0 +} + +flickerlight BASE_X3 +{ + color 0.5 0.2 0.0 + size 64 + secondarySize 72 + chance 0.3 + offset 0 32 0 +} + +object ProgrammerBase +{ + frame BASEA { light BASE_X1 } + frame BASEB { light BASE_X2 } + frame BASEC { light BASE_X3 } +} + +// Bishop +flickerlight BISHOP +{ + color 1.0 1.0 1.0 + size 96 + secondarySize 108 + chance 0.3 + offset 0 120 0 +} + +object StrifeBishop +{ + frame MLDRE { light BISHOP } +} + +object BishopMissile +{ + frame MISS { light MISSILE } + + frame SMISA { light MISSILE_X1} + frame SMISB { light MISSILE_X2} + frame SMISC { light MISSILE_X3} + frame SMISD { light MISSILE_X4} + frame SMISE { light MISSILE_X5} + frame SMISF { light MISSILE_X6} + frame SMISG { light MISSILE_X7} +} + +// ------------------ +// - Strife Objects - +// ------------------ + +// Lights +pointlight LIGHT1 +{ + color 1.0 1.0 1.0 + size 56 + offset 0 30 0 +} + +pointlight LIGHT2 +{ + color 1.0 1.0 1.0 + size 40 + offset 0 72 0 +} + +pointlight LIGHT3 +{ + color 1.0 1.0 1.0 + size 64 +} + +pointlight LIGHT4 +{ + color 1.0 1.0 1.0 + size 64 + offset 0 80 0 +} + +pointlight LIGHT5 +{ + color 1.0 1.0 1.0 + size 56 + offset 0 72 0 +} + +pointlight CLIGHT1 +{ + color 1.0 1.0 0.0 + size 24 + offset 0 12 0 +} + +pulselight CLIGHT2 +{ + color 1.0 1.0 0.0 + size 48 + secondarySize 50 + interval 8.0 + offset 0 64 0 +} + +pulselight LLIGHT +{ + color 1.0 0.5 0.0 + size 24 + secondarySize 32 + interval 12.0 + offset 0 76 0 +} + +pulselight TLLIGHT1 +{ + color 0.9 0.9 1.0 + size 56 + secondarySize 64 + interval 3.0 + offset 0 48 0 +} + +pointlight TLLIGHT2 +{ + color 1.0 1.0 0.5 + size 80 + offset 0 56 0 +} + +flickerlight HTECH +{ + color 0.3 1.0 0.3 + size 96 + secondarySize 104 + chance 0.5 + offset 0 80 0 +} + +pulselight BCOLUMN +{ + color 0.5 1.0 0.5 + size 120 + secondarySize 128 + interval 10.0 + offset 0 64 0 +} + +pulselight FBUBBLE +{ + color 0.5 1.0 0.5 + size 60 + secondarySize 64 + interval 10.0 + offset 0 32 0 +} + +pulselight CBUBBLE +{ + color 0.5 1.0 0.5 + size 60 + secondarySize 64 + interval 10.0 +} + +pointlight SPIDLGHT1 +{ + color 0.5 1.0 0.5 + size 64 + offset 0 10 0 +} + +pointlight SPIDLGHT2 +{ + color 0.2 0.75 0.2 + size 56 + offset 0 10 0 +} + +pointlight SPIDLGHT3 +{ + color 0.0 0.25 0.0 + size 48 + offset 0 10 0 +} + +object LightSilverFluorescent +{ + frame LITS { light LIGHT1 } +} + +object LightBrownFluorescent +{ + frame LITB { light LIGHT1 } +} + +object LightGoldFluorescent +{ + frame LITG { light LIGHT1 } +} + +object LightGlobe +{ + frame LITE { light LIGHT5 } +} + +object PillarHugeTech +{ + frame HUGE { light HTECH } +} + +object Candle +{ + frame KNDL { light CLIGHT1 } +} + +object StrifeCandelabra +{ + frame CLBR { light CLIGHT2 } +} + +object CageLight +{ + frame CAGE { light LIGHT3 } +} + +object OutsideLamp +{ + frame LAMP { light LIGHT4 } +} + +object PoleLantern +{ + frame LANT { light LLIGHT } +} + +object TechLampSilver +{ + frame TECHA { light TLLIGHT1 } +} + +object TechLampBrass +{ + frame TECHB { light TLLIGHT2 } +} + +object AlienBubbleColumn +{ + frame BUBB { light BCOLUMN } +} + +object AlienFloorBubble +{ + frame BUBF { light FBUBBLE } +} + +object AlienCeilingBubble +{ + frame BUBC { light CBUBBLE } +} + +object AlienSpiderLight +{ + frame SPDLA { light SPIDLGHT1 } + frame SPDLB { light SPIDLGHT2 } + frame SPDLC { light SPIDLGHT3 } +} + +// Burning Things +flickerlight BBARREL +{ + color 1.0 0.6 0.0 + size 32 + secondarySize 40 + chance 0.8 + offset 0 32 0 +} + +flickerlight BBOWL +{ + color 1.0 0.7 0.0 + size 24 + secondarySize 32 + chance 0.5 + offset 0 10 0 +} + +flickerlight BBRAZIER +{ + color 1.0 0.8 0.0 + size 40 + secondarySize 48 + chance 0.2 + offset 0 32 0 +} + +pulselight STORCH +{ + color 1.0 0.6 0.0 + size 28 + secondarySize 32 + interval 5.0 + offset 0 56 0 +} + +pulselight MTORCH +{ + color 1.0 0.6 0.0 + size 56 + secondarySize 64 + interval 5.0 + offset 0 64 0 +} + +pulselight LTORCH +{ + color 1.0 0.8 0.0 + size 64 + secondarySize 72 + interval 2.0 + offset 0 64 0 +} + +pulselight HTORCH +{ + color 1.0 0.6 0.0 + size 72 + secondarySize 76 + interval 3.0 + offset 0 72 0 +} + +object StrifeBurningBarrel +{ + frame BBAR { light BBARREL } +} + +object BurningBowl +{ + frame BOWL { light BBOWL } +} + +object BurningBrazier +{ + frame BRAZ { light BBRAZIER } +} + +object SmallTorchLit +{ + frame TRHL { light STORCH } +} + +object MediumTorch +{ + frame LTRH { light MTORCH } +} + +object LargeTorch +{ + frame LMPC { light LTORCH } +} + +object HugeTorch +{ + frame LOGS { light HTORCH } +} + +// Power Crystal +pointlight PCRYSTAL +{ + color 1.0 1.0 0.0 + size 40 + offset 0 16 0 +} + +pointlight PCRYSTAL1 +{ + color 0.4 0.4 1.0 + size 24 + offset 0 12 0 +} + +pointlight PCRYSTAL2 +{ + color 0.5 0.5 1.0 + size 30 + offset 0 18 0 +} + +pointlight PCRYSTAL3 +{ + color 0.45 0.45 1.0 + size 32 + offset 0 24 0 +} + +pointlight PCRYSTAL4 +{ + color 0.35 0.35 1.0 + size 28 + offset 0 32 0 +} + +pointlight PCRYSTAL5 +{ + color 0.1 0.1 1.0 + size 18 + offset 0 40 0 +} + +flickerlight POWCRYS_X1 +{ + color 1.0 0.7 0.1 + size 108 + secondarySize 112 + chance 0.3 +} + +flickerlight POWCRYS_X2 +{ + color 1.0 0.75 0.2 + size 112 + secondarySize 116 + chance 0.3 +} + +flickerlight POWCRYS_X3 +{ + color 1.0 0.8 0.4 + size 116 + secondarySize 120 + chance 0.3 +} + +flickerlight POWCRYS_X4 +{ + color 1.0 0.75 0.3 + size 115 + secondarySize 117 + chance 0.3 +} + +flickerlight POWCRYS_X5 +{ + color 1.0 0.7 0.27 + size 114 + secondarySize 113 + chance 0.3 +} + +flickerlight POWCRYS_X6 +{ + color 1.0 0.65 0.24 + size 113 + secondarySize 115 + chance 0.3 +} + +flickerlight POWCRYS_X6 +{ + color 1.0 0.62 0.22 + size 112 + secondarySize 114 + chance 0.3 +} + +flickerlight POWCRYS_X7 +{ + color 1.0 0.6 0.20 + size 111 + secondarySize 113 + chance 0.3 +} + +flickerlight POWCRYS_X8 +{ + color 1.0 0.58 0.18 + size 110 + secondarySize 112 + chance 0.3 +} + +flickerlight POWCRYS_X9 +{ + color 1.0 0.56 0.16 + size 109 + secondarySize 111 + chance 0.3 +} + +flickerlight POWCRYS_X10 +{ + color 1.0 0.54 0.14 + size 108 + secondarySize 110 + chance 0.3 +} + +flickerlight POWCRYS_X11 +{ + color 1.0 0.52 0.12 + size 107 + secondarySize 109 + chance 0.3 +} + +flickerlight POWCRYS_X12 +{ + color 1.0 0.5 0.10 + size 106 + secondarySize 108 + chance 0.3 +} + +flickerlight POWCRYS_X13 +{ + color 1.0 0.48 0.10 + size 105 + secondarySize 106 + chance 0.3 +} + +flickerlight POWCRYS_X14 +{ + color 1.0 0.46 0.08 + size 103 + secondarySize 104 + chance 0.3 +} + +flickerlight POWCRYS_X15 +{ + color 1.0 0.44 0.06 + size 102 + secondarySize 104 + chance 0.3 +} + +flickerlight POWCRYS_X16 +{ + color 1.0 0.42 0.04 + size 101 + secondarySize 103 + chance 0.3 +} + +flickerlight POWCRYS_X15 +{ + color 1.0 0.4 0.02 + size 100 + secondarySize 102 + chance 0.3 +} + +flickerlight POWCRYS_X16 +{ + color 1.0 0.38 0.0 + size 99 + secondarySize 101 + chance 0.3 +} + +flickerlight POWCRYS_X17 +{ + color 1.0 0.36 0.02 + size 98 + secondarySize 100 + chance 0.3 +} + +flickerlight POWCRYS_X18 +{ + color 1.0 0.34 0.0 + size 97 + secondarySize 100 + chance 0.3 +} + +flickerlight POWCRYS_X19 +{ + color 1.0 0.32 0.0 + size 96 + secondarySize 99 + chance 0.3 +} + +flickerlight POWCRYS_X20 +{ + color 1.0 0.3 0.0 + size 95 + secondarySize 98 + chance 0.3 +} + +flickerlight POWCRYS_X21 +{ + color 1.0 0.28 0.0 + size 94 + secondarySize 93 + chance 0.3 +} + +flickerlight POWCRYS_X22 +{ + color 1.0 0.26 0.0 + size 93 + secondarySize 92 + chance 0.3 +} + +flickerlight POWCRYS_X23 +{ + color 1.0 0.24 0.0 + size 92 + secondarySize 91 + chance 0.3 +} + +flickerlight POWCRYS_X24 +{ + color 1.0 0.22 0.0 + size 90 + secondarySize 92 + chance 0.3 +} + +flickerlight POWCRYS_X25 +{ + color 1.0 0.2 0.0 + size 86 + secondarySize 90 + chance 0.3 +} + +object PowerCrystal +{ + frame CRYS { light PCRYSTAL } + + frame CRYSB { light PCRYSTAL1 } + frame CRYSC { light PCRYSTAL2 } + frame CRYSD { light PCRYSTAL3 } + frame CRYSE { light PCRYSTAL4 } + frame CRYSF { light PCRYSTAL5 } + + frame BOOMA { light POWCRYS_X1 } + frame BOOMB { light POWCRYS_X2 } + frame BOOMC { light POWCRYS_X3 } + frame BOOMD { light POWCRYS_X4 } + frame BOOME { light POWCRYS_X5 } + frame BOOMF { light POWCRYS_X6 } + frame BOOMG { light POWCRYS_X7 } + frame BOOMH { light POWCRYS_X8 } + frame BOOMI { light POWCRYS_X9 } + frame BOOMJ { light POWCRYS_X10 } + frame BOOMK { light POWCRYS_X11 } + frame BOOML { light POWCRYS_X12 } + frame BOOMM { light POWCRYS_X13 } + frame BOOMN { light POWCRYS_X14 } + frame BOOMO { light POWCRYS_X15 } + frame BOOMP { light POWCRYS_X16 } + frame BOOMQ { light POWCRYS_X17 } + frame BOOMR { light POWCRYS_X18 } + frame BOOMS { light POWCRYS_X19 } + frame BOOMT { light POWCRYS_X20 } + frame BOOMU { light POWCRYS_X21 } + frame BOOMV { light POWCRYS_X22 } + frame BOOMW { light POWCRYS_X23 } + frame BOOMX { light POWCRYS_X24 } + frame BOOMY { light POWCRYS_X25 } +} + +// Computer +pulselight COMPUTER +{ + color 0.25 1.0 0.25 + size 112 + secondarySize 128 + interval 0.25 + offset 0 64 0 +} + +object Computer +{ + frame SECRA { light COMPUTER } + frame SECRB { light COMPUTER } + frame SECRC { light COMPUTER } + frame SECRD { light COMPUTER } +} + +// Strife Explosive Barrel +flickerlight BARREL_X1 +{ + color 1.0 0.6 0.1 + size 48 + secondarySize 56 + chance 0.3 +} + +flickerlight BARREL_X2 +{ + color 1.0 0.8 0.0 + size 56 + secondarySize 64 + chance 0.3 +} + +flickerlight BARREL_X3 +{ + color 1.0 0.7 0.0 + size 72 + secondarySize 80 + chance 0.3 +} + +flickerlight BARREL_X4 +{ + color 1.0 0.6 0.0 + size 80 + secondarySize 88 + chance 0.3 +} + +flickerlight BARREL_X5 +{ + color 1.0 0.5 0.0 + size 72 + secondarySize 76 + chance 0.3 +} + +flickerlight BARREL_X6 +{ + color 1.0 0.45 0.0 + size 56 + secondarySize 60 + chance 0.3 +} + +flickerlight BARREL_X7 +{ + color 1.0 0.4 0.0 + size 52 + secondarySize 56 + chance 0.3 + offset 0 24 0 +} + +flickerlight BARREL_X8 +{ + color 1.0 0.35 0.0 + size 36 + secondarySize 40 + chance 0.3 + offset 0 40 0 +} + +flickerlight BARREL_X9 +{ + color 1.0 0.3 0.0 + size 16 + secondarySize 24 + chance 0.3 + offset 0 56 0 +} + +object ExplosiveBarrel2 +{ + frame BARTC { light BARREL_X1 } + frame BARTD { light BARREL_X2 } + frame BARTE { light BARREL_X3 } + frame BARTF { light BARREL_X4 } + frame BARTG { light BARREL_X5 } + frame BARTH { light BARREL_X6 } + frame BARTI { light BARREL_X7 } + frame BARTJ { light BARREL_X8 } + frame BARTK { light BARREL_X9 } +} + +// Alarm +pointlight KLAXON +{ + color 1.0 0.0 0.0 + size 24 +} + +object KlaxonWarningLight +{ + frame KLAXC { light KLAXON } +} + +// ------------------ +// - Strife Effects - +// ------------------ + +// Bang Cloud +object Bang4Cloud +{ + frame BNG4B { light POWCRYS_X2 } + frame BNG4C { light POWCRYS_X3 } + frame BNG4D { light POWCRYS_X4 } + frame BNG4E { light POWCRYS_X5 } + frame BNG4F { light POWCRYS_X6 } + frame BNG4G { light POWCRYS_X7 } + frame BNG4H { light POWCRYS_X8 } + frame BNG4I { light POWCRYS_X9 } + frame BNG4J { light POWCRYS_X10 } + + frame BNG4K { light HEGRENADE_X1 } + frame BNG4L { light HEGRENADE_X2 } + frame BNG4M { light HEGRENADE_X3 } + frame BNG4N { light HEGRENADE_X4 } +} + +// Fire Droplet +object FireDroplet +{ + frame FFOTA { light PHFIRE_FX8 } + frame FFOTB { light PHFIRE_FX9 } + frame FFOTC { light PHFIRE_FX10 } + frame FFOTD { light PHFIRE_FX11 } +} + +// Lighning +flickerlight ZAPBALL1 +{ + color 0.8 0.8 1.0 + size 64 + secondarySize 72 + chance 0.3 +} + +flickerlight ZAPBALL2 +{ + color 0.8 0.8 1.0 + size 128 + secondarySize 144 + chance 0.5 +} + +flickerlight LIGHTNING1 +{ + color 0.8 0.8 1.0 + size 72 + secondarySize 80 + chance 0.8 +} + +flickerlight LIGHTNING2 +{ + color 0.8 0.8 1.0 + size 80 + secondarySize 96 + chance 0.8 +} + +flickerlight LIGHT_SPT +{ + color 0.8 0.8 1.0 + size 24 + secondarySize 32 + chance 0.8 +} + +flickerlight LGNTAIL +{ + color 0.4 0.4 0.5 + size 72 + secondarySize 80 + chance 0.8 +} + +object StrifeZap1 +{ + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBase +{ + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBall1 +{ + frame ZOT3 { light ZAPBALL1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBall2 +{ + frame ZOT3 { light ZAPBALL1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBigBall1 +{ + frame ZOT7 { light ZAPBALL2 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBigBall2 +{ + frame ZOT7 { light ZAPBALL2 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningH1 +{ + frame ZAP6 { light LIGHTNING1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningH2 +{ + frame ZAP6 { light LIGHTNING1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningH3 +{ + frame ZAP6 { light LIGHTNING1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningHTail +{ + frame ZAP6 { light LGNTAIL } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningV1 +{ + frame ZOT1 { light LIGHTNING1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningV2 +{ + frame ZOT1 { light LIGHTNING1 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningSpot +{ + frame ZAP5 { light LIGHT_SPT } +} + +object SpectralLightningBigV1 +{ + frame ZOT2 { light LIGHTNING2 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +object SpectralLightningBigV2 +{ + frame ZOT2 { light LIGHTNING2 } + + frame ZAP1A { light ARROWZAP1 } + frame ZAP1B { light ARROWZAP2 } + frame ZAP1C { light ARROWZAP3 } + frame ZAP1D { light ARROWZAP4 } + frame ZAP1E { light ARROWZAP5 } + frame ZAP1F { light ARROWZAP6 } +} + +// Teleport +pointlight TFOG1 +{ + color 0.5 0.5 0.25 + size 32 + offset 0 40 0 +} + +pointlight TFOG2 +{ + color 0.5 0.5 0.25 + size 40 + offset 0 40 0 +} + +pointlight TFOG3 +{ + color 0.5 0.5 0.25 + size 48 + offset 0 40 0 +} + +pointlight TFOG4 +{ + color 0.5 0.5 0.25 + size 56 + offset 0 40 0 +} + +pointlight TFOG5 +{ + color 0.5 0.5 0.25 + size 64 + offset 0 40 0 +} + +pointlight TFOG6 +{ + color 0.5 0.5 0.25 + size 72 + offset 0 40 0 +} + +object TeleportFog +{ + frame TFOGA { light TFOG1 } + frame TFOGB { light TFOG2 } + frame TFOGC { light TFOG3 } + frame TFOGD { light TFOG4 } + frame TFOGE { light TFOG5 } + frame TFOGF { light TFOG6 } +} \ No newline at end of file diff --git a/zlib/zlib.vcproj b/zlib/zlib.vcproj index 3e0ba5ff7..06d9ed48c 100644 --- a/zlib/zlib.vcproj +++ b/zlib/zlib.vcproj @@ -1,10 +1,11 @@ - - - - - -