diff --git a/.gitignore b/.gitignore index e94b5b5f6..1b078ed63 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ /Release /wadsrc_wad *.user +/build /debug /release */debug @@ -41,6 +42,7 @@ /jpeg-6b/x64/ /lzma/x64/ /zlib/x64/ +/build_vc2013_64bit /build_vc2015 /build_vc2015-32 /build_vc2015-64 diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f0bf8293..80eac0c54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required( VERSION 2.8.7 ) -project(ZDoom) +project(GZDoom) if( COMMAND cmake_policy ) if( POLICY CMP0011 ) @@ -44,11 +44,11 @@ function( add_pk3 PK3_NAME PK3_DIR ) DEPENDS zipdir ) endif() - # Touch the zipdir executable here so that the pk3s are forced to - # rebuild each time since their dependecy has "changed." - add_custom_target( ${PK3_TARGET} ALL - COMMAND ${CMAKE_COMMAND} -E touch $ - DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ) + # Touch the zipdir executable here so that the pk3s are forced to + # rebuild each time since their dependecy has "changed." + add_custom_target( ${PK3_TARGET} ALL + COMMAND ${CMAKE_COMMAND} -E touch $ + DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ) endfunction() # Macro for building libraries without debugging information @@ -68,7 +68,7 @@ IF( NOT CMAKE_BUILD_TYPE ) ENDIF() 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 @@ -255,6 +255,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/docs/licenses/xBRZ.jpg b/docs/licenses/xBRZ.jpg new file mode 100644 index 000000000..ab8335391 Binary files /dev/null and b/docs/licenses/xBRZ.jpg differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1453822ec..00de8421e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,6 +11,7 @@ include( CheckFunctionExists ) include( CheckCXXCompilerFlag ) include( CheckLibraryExists ) include( FindPkgConfig ) +include( FindOpenGL ) if( NOT APPLE ) option( NO_ASM "Disable assembly code" OFF ) @@ -235,6 +236,14 @@ else() endif() endif() +# Check if we have OpenGL + +if( NOT OPENGL_FOUND ) + message( FATAL_ERROR "OpenGL is required for building." ) +endif( NOT OPENGL_FOUND ) + +set( ZDOOM_LIBS ${ZDOOM_LIBS} ${OPENGL_LIBRARIES} ) +include_directories( ${OPENGL_INCLUDE_DIR} ) if( NOT NO_OPENAL ) find_package( OpenAL ) @@ -471,6 +480,22 @@ else() set( BACKPATCH 0 ) endif() +if( X64 ) + set( HAVE_MMX 1 ) +else( X64 ) + set( SAFE_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ) + + if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmmx") + endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) + + CHECK_CXX_SOURCE_COMPILES("#include + 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 ) @@ -647,6 +672,7 @@ set( PLAT_WIN32_SOURCES win32/i_system.cpp win32/i_specialpaths.cpp win32/st_start.cpp + win32/win32gliface.cpp win32/win32video.cpp ) set( PLAT_POSIX_SOURCES posix/i_cd.cpp @@ -662,6 +688,7 @@ set( PLAT_SDL_SOURCES posix/sdl/i_system.cpp posix/sdl/i_timer.cpp posix/sdl/sdlvideo.cpp + posix/sdl/sdlglvideo.cpp posix/sdl/st_start.cpp ) set( PLAT_UNIX_SOURCES posix/unix/i_specialpaths.cpp ) @@ -718,6 +745,25 @@ else() set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} ) endif() +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() @@ -811,6 +857,21 @@ file( GLOB HEADER_FILES thingdef/*.h xlat/*.h zscript/*.h + gl/*.h + gl/api/*.h + gl/data/*.h + gl/dynlights/*.h + gl/hqnx/*.h + gl/hqnx_asm/*.h + gl/xbr/*.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 ) @@ -1006,6 +1067,85 @@ set( FASTMATH_SOURCES sound/sndfile_decoder.cpp sound/music_pseudo_mididevice.cpp wildmidi/wildmidi_lib.cpp + gl/compatibility/gl_20.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_2ddrawer.cpp + gl/renderer/gl_quaddrawer.cpp + gl/renderer/gl_renderer.cpp + gl/renderer/gl_renderstate.cpp + gl/renderer/gl_renderbuffers.cpp + gl/renderer/gl_lightdata.cpp + gl/renderer/gl_postprocess.cpp + gl/renderer/gl_postprocessstate.cpp + gl/hqnx/init.cpp + gl/hqnx/hq2x.cpp + gl/hqnx/hq3x.cpp + gl/hqnx/hq4x.cpp + gl/xbr/xbrz.cpp + gl/xbr/xbrz_old.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/stereo3d/gl_quadstereo.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/shaders/gl_shaderprogram.cpp + gl/shaders/gl_presentshader.cpp + gl/shaders/gl_bloomshader.cpp + gl/shaders/gl_blurshader.cpp + gl/shaders/gl_colormapshader.cpp + gl/shaders/gl_tonemapshader.cpp + gl/shaders/gl_lensshader.cpp + gl/system/gl_interface.cpp + gl/system/gl_framebuffer.cpp + gl/system/gl_debug.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 ) set (PCH_SOURCES @@ -1099,6 +1239,7 @@ set (PCH_SOURCES p_mobj.cpp p_pillar.cpp p_plats.cpp + p_portals.cpp p_pspr.cpp p_pusher.cpp p_saveg.cpp @@ -1123,7 +1264,7 @@ set (PCH_SOURCES p_xlat.cpp parsecontext.cpp po_man.cpp - portal.cpp + portal.cpp r_utility.cpp sc_man.cpp st_stuff.cpp @@ -1415,6 +1556,20 @@ source_group("Games\\Strife Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DI source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+") source_group("Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/math/.+") 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 MMX version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/hqnx_asm/.+") +source_group("OpenGL Renderer\\XBRZ" 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 522405dd6..28e68b64a 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1381,6 +1381,14 @@ public: int ApplyDamageFactor(FName damagetype, int damage) 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 b1d9c4959..a6b437f2f 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1478,6 +1478,7 @@ void G_AirControlChanged () // // //========================================================================== +void gl_SerializeGlobals(FArchive &arc); void G_SerializeLevel (FArchive &arc, bool hubLoad) { @@ -1485,6 +1486,7 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad) Renderer->StartSerialize(arc); if (arc.IsLoading()) P_DestroyThinkers(hubLoad); + gl_SerializeGlobals(arc); arc << level.flags << level.flags2 diff --git a/src/gl/compatibility/gl_20.cpp b/src/gl/compatibility/gl_20.cpp new file mode 100644 index 000000000..e192b213e --- /dev/null +++ b/src/gl/compatibility/gl_20.cpp @@ -0,0 +1,852 @@ +/* +** gl_20.cpp +** +** Fallback code for ancient hardware +** This file collects everything larger that is only needed for +** OpenGL 2.0/no shader compatibility. +** +**--------------------------------------------------------------------------- +** Copyright 2005-2016 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 "menu/menu.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 "r_utility.h" +#include "gl/dynlights/gl_dynlight.h" +#include "gl/utility/gl_geometric.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/data/gl_vertexbuffer.h" + + +CVAR(Bool, gl_lights_additive, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + +//========================================================================== +// +// Do some tinkering with the menus so that certain options only appear +// when they are actually valid. +// +//========================================================================== + +void gl_PatchMenu() +{ + // Radial fog and Doom lighting are not available without full shader support. + + FOptionValues **opt = OptionValues.CheckKey("LightingModes"); + if (opt != NULL) + { + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + { + // Delete 'Doom' lighting mode + if ((*opt)->mValues[i].Value == 2.0 || (*opt)->mValues[i].Value == 8.0) + { + (*opt)->mValues.Delete(i); + } + } + } + + opt = OptionValues.CheckKey("FogMode"); + if (opt != NULL) + { + for(int i = (*opt)->mValues.Size()-1; i>=0; i--) + { + // Delete 'Radial' fog mode + if ((*opt)->mValues[i].Value == 2.0) + { + (*opt)->mValues.Delete(i); + } + } + } + + // disable features that don't work without shaders. + if (gl_lightmode == 2 || gl_lightmode == 8) gl_lightmode = 3; + if (gl_fogmode == 2) gl_fogmode = 1; + + // todo: remove more unsupported stuff like postprocessing options. +} + + +//========================================================================== +// +// +// +//========================================================================== + +void gl_SetTextureMode(int type) +{ + static float white[] = {1.f,1.f,1.f,1.f}; + + if (type == TM_MASK) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_OPAQUE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_INVERSE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA); + } + else if (type == TM_INVERTOPAQUE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); + glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PRIMARY_COLOR); + glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); + } + else // if (type == TM_MODULATE) + { + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +static int ffTextureMode; +static bool ffTextureEnabled; +static bool ffFogEnabled; +static PalEntry ffFogColor; +static int ffSpecialEffect; +static float ffFogDensity; +static bool currentTextureMatrixState; +static bool currentModelMatrixState; + +void FRenderState::ApplyFixedFunction() +{ + if (mTextureMode != ffTextureMode) + { + ffTextureMode = mTextureMode; + if (ffTextureMode == TM_CLAMPY) ffTextureMode = TM_MODULATE; // this cannot be replicated. Too bad if it creates visual artifacts + gl_SetTextureMode(ffTextureMode); + } + if (mTextureEnabled != ffTextureEnabled) + { + if ((ffTextureEnabled = mTextureEnabled)) glEnable(GL_TEXTURE_2D); + else glDisable(GL_TEXTURE_2D); + } + if (mFogEnabled != ffFogEnabled) + { + if ((ffFogEnabled = mFogEnabled)) + { + glEnable(GL_FOG); + } + else glDisable(GL_FOG); + } + if (mFogEnabled) + { + if (ffFogColor != mFogColor) + { + ffFogColor = mFogColor; + GLfloat FogColor[4] = { mFogColor.r / 255.0f,mFogColor.g / 255.0f,mFogColor.b / 255.0f,0.0f }; + glFogfv(GL_FOG_COLOR, FogColor); + } + if (ffFogDensity != mLightParms[2]) + { + glFogf(GL_FOG_DENSITY, mLightParms[2] * -0.6931471f); // = 1/log(2) + ffFogDensity = mLightParms[2]; + } + } + if (mSpecialEffect != ffSpecialEffect) + { + switch (ffSpecialEffect) + { + case EFF_SPHEREMAP: + glDisable(GL_TEXTURE_GEN_T); + glDisable(GL_TEXTURE_GEN_S); + + default: + break; + } + switch (mSpecialEffect) + { + case EFF_SPHEREMAP: + // Use sphere mapping for this + glEnable(GL_TEXTURE_GEN_T); + glEnable(GL_TEXTURE_GEN_S); + glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); + break; + + default: + break; + } + ffSpecialEffect = mSpecialEffect; + } + + FStateVec4 col = mColor; + + col.vec[0] += mDynColor.vec[0]; + col.vec[1] += mDynColor.vec[1]; + col.vec[2] += mDynColor.vec[2]; + col.vec[0] = clamp(col.vec[0], 0.f, 1.f); + + col.vec[0] = clamp(col.vec[0], 0.f, 1.f); + col.vec[1] = clamp(col.vec[1], 0.f, 1.f); + col.vec[2] = clamp(col.vec[2], 0.f, 1.f); + col.vec[3] = clamp(col.vec[3], 0.f, 1.f); + + col.vec[0] *= (mObjectColor.r / 255.f); + col.vec[1] *= (mObjectColor.g / 255.f); + col.vec[2] *= (mObjectColor.b / 255.f); + col.vec[3] *= (mObjectColor.a / 255.f); + glColor4fv(col.vec); + + glEnable(GL_BLEND); + if (mAlphaThreshold > 0) + { + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, mAlphaThreshold * col.vec[3]); + } + else + { + glDisable(GL_ALPHA_TEST); + } + + if (mTextureMatrixEnabled) + { + glMatrixMode(GL_TEXTURE); + glLoadMatrixf(mTextureMatrix.get()); + currentTextureMatrixState = true; + } + else if (currentTextureMatrixState) + { + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + currentTextureMatrixState = false; + } + + if (mModelMatrixEnabled) + { + VSMatrix mult = mViewMatrix; + mult.multMatrix(mModelMatrix); + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(mult.get()); + currentModelMatrixState = true; + } + else if (currentModelMatrixState) + { + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(mViewMatrix.get()); + currentModelMatrixState = false; + } + + +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_FillScreen(); + +void FRenderState::DrawColormapOverlay() +{ + float r, g, b; + if (mColormapState > CM_DEFAULT && 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 }; + + if (m[0] < 0 && m[1] < 0 && m[2] < 0) + { + gl_RenderState.SetColor(1, 1, 1, 1); + gl_RenderState.BlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); + gl_FillScreen(); + + r = scm->ColorizeStart[0]; + g = scm->ColorizeStart[1]; + b = scm->ColorizeStart[2]; + } + else + { + r = scm->ColorizeEnd[0]; + g = scm->ColorizeEnd[1]; + b = scm->ColorizeEnd[2]; + } + } + else if (mColormapState == CM_LITE) + { + if (gl_enhanced_nightvision) + { + r = 0.375f, g = 1.0f, b = 0.375f; + } + else + { + return; + } + } + 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; + } + else return; + + gl_RenderState.SetColor(r, g, b, 1.f); + gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); + gl_FillScreen(); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} + +//========================================================================== +// +// Sets up the parameters to render one dynamic light onto one plane +// +//========================================================================== + +bool gl_SetupLight(int group, Plane & p, ADynamicLight * light, Vector & nearPt, Vector & up, Vector & right, + float & scale, bool checkside, bool additive) +{ + Vector fn, pos; + + DVector3 lpos = light->PosRelative(group); + + float dist = fabsf(p.DistToPoint(lpos.X, lpos.Z, lpos.Y)); + float radius = light->GetRadius(); + + if (radius <= 0.f) return false; + if (dist > radius) return false; + if (checkside && gl_lights_checkside && p.PointOnSide(lpos.X, lpos.Z, lpos.Y)) + { + return false; + } + if (!light->visibletoplayer) + { + return false; + } + + scale = 1.0f / ((2.f * radius) - dist); + + // project light position onto plane (find closest point on plane) + + + pos.Set(lpos.X, lpos.Z, lpos.Y); + fn = p.Normal(); + fn.GetRightUp(right, up); + +#ifdef _MSC_VER + nearPt = pos + fn * dist; +#else + Vector tmpVec = fn * dist; + nearPt = pos + tmpVec; +#endif + + float cs = 1.0f - (dist / radius); + if (additive) cs *= 0.2f; // otherwise the light gets too strong. + float r = light->GetRed() / 255.0f * cs; + float g = light->GetGreen() / 255.0f * cs; + float b = light->GetBlue() / 255.0f * cs; + + if (light->IsSubtractive()) + { + Vector v; + + gl_RenderState.BlendEquation(GL_FUNC_REVERSE_SUBTRACT); + v.Set(r, g, b); + r = v.Length() - r; + g = v.Length() - g; + b = v.Length() - b; + } + else + { + gl_RenderState.BlendEquation(GL_FUNC_ADD); + } + gl_RenderState.SetColor(r, g, b); + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool gl_SetupLightTexture() +{ + if (GLRenderer->gllight == nullptr) return false; + FMaterial * pat = FMaterial::ValidateTexture(GLRenderer->gllight, false); + gl_RenderState.SetMaterial(pat, CLAMP_XY_NOMIP, 0, -1, false); + return true; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool GLWall::PutWallCompat(int passflag) +{ + static int list_indices[2][2] = + { { GLLDL_WALLS_PLAIN, GLLDL_WALLS_FOG },{ GLLDL_WALLS_MASKED, GLLDL_WALLS_FOGMASKED } }; + + // are lights possible? + if (gl_fixedcolormap != CM_DEFAULT || !gl_lights || seg->sidedef == nullptr || type == RENDERWALL_M2SNF || !gltexture) return false; + + // multipassing these is problematic. + if ((flags&GLWF_SKYHACK && type == RENDERWALL_M2S)) return false; + + // Any lights affecting this wall? + if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + if (seg->sidedef->lighthead == nullptr) return false; + } + else if (sub) + { + if (sub->lighthead == nullptr) return false; + } + + bool foggy = gl_CheckFog(&Colormap, lightlevel) || (level.flags&LEVEL_HASFADETABLE) || gl_lights_additive; + bool masked = passflag == 2 && gltexture->isMasked(); + + int list = list_indices[masked][foggy]; + gl_drawinfo->dldrawlists[list].AddWall(this); + return true; + +} + +//========================================================================== +// +// +// +//========================================================================== + +bool GLFlat::PutFlatCompat(bool fog) +{ + // are lights possible? + if (gl_fixedcolormap != CM_DEFAULT || !gl_lights || !gltexture || renderstyle != STYLE_Translucent || alpha < 1.f - FLT_EPSILON || sector->lighthead == NULL) return false; + + static int list_indices[2][2] = + { { GLLDL_FLATS_PLAIN, GLLDL_FLATS_FOG },{ GLLDL_FLATS_MASKED, GLLDL_FLATS_FOGMASKED } }; + + bool masked = gltexture->isMasked() && ((renderflags&SSRF_RENDER3DPLANES) || stack); + bool foggy = gl_CheckFog(&Colormap, lightlevel) || (level.flags&LEVEL_HASFADETABLE) || gl_lights_additive; + + + int list = list_indices[masked][foggy]; + gl_drawinfo->dldrawlists[list].AddFlat(this); + return true; +} + + +//========================================================================== +// +// Fog boundary without any shader support +// +//========================================================================== + +void GLWall::RenderFogBoundaryCompat() +{ + // without shaders some approximation is needed. This won't look as good + // as the shader version but it's an acceptable compromise. + float fogdensity = gl_GetFogDensity(lightlevel, Colormap.FadeColor); + + float dist1 = Dist2(ViewPos.X, ViewPos.Y, glseg.x1, glseg.y1); + float dist2 = Dist2(ViewPos.X, ViewPos.Y, glseg.x2, glseg.y2); + + // these values were determined by trial and error and are scale dependent! + float fogd1 = (0.95f - exp(-fogdensity*dist1 / 62500.f)) * 1.05f; + float fogd2 = (0.95f - exp(-fogdensity*dist2 / 62500.f)) * 1.05f; + + float fc[4] = { Colormap.FadeColor.r / 255.0f,Colormap.FadeColor.g / 255.0f,Colormap.FadeColor.b / 255.0f,fogd2 }; + + gl_RenderState.EnableTexture(false); + gl_RenderState.EnableFog(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0); + gl_RenderState.Apply(); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(-1.0f, -128.0f); + glDepthFunc(GL_LEQUAL); + glColor4f(fc[0], fc[1], fc[2], fogd1); + glBegin(GL_TRIANGLE_FAN); + glTexCoord2f(tcs[LOLFT].u, tcs[LOLFT].v); + glVertex3f(glseg.x1, zbottom[0], glseg.y1); + glTexCoord2f(tcs[UPLFT].u, tcs[UPLFT].v); + glVertex3f(glseg.x1, ztop[0], glseg.y1); + glColor4f(fc[0], fc[1], fc[2], fogd2); + glTexCoord2f(tcs[UPRGT].u, tcs[UPRGT].v); + glVertex3f(glseg.x2, ztop[1], glseg.y2); + glTexCoord2f(tcs[LORGT].u, tcs[LORGT].v); + glVertex3f(glseg.x2, zbottom[1], glseg.y2); + glEnd(); + glDepthFunc(GL_LESS); + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); + gl_RenderState.EnableFog(true); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); + gl_RenderState.EnableTexture(true); +} + +//========================================================================== +// +// Flats +// +//========================================================================== + +void GLFlat::DrawSubsectorLights(subsector_t * sub, int pass) +{ + Plane p; + Vector nearPt, up, right, t1; + float scale; + + FLightNode * node = sub->lighthead; + while (node) + { + ADynamicLight * light = node->lightsource; + + if (light->flags2&MF2_DORMANT || + (pass == GLPASS_LIGHTTEX && light->IsAdditive()) || + (pass == GLPASS_LIGHTTEX_ADDITIVE && !light->IsAdditive())) + { + node = node->nextLight; + continue; + } + + // 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 + double planeh = plane.plane.ZatPoint(light); + if (gl_lights_checkside && ((planehZ() && ceiling) || (planeh>light->Z() && !ceiling))) + { + node = node->nextLight; + continue; + } + + p.Set(plane.plane); + if (!gl_SetupLight(sub->sector->PortalGroup, p, light, nearPt, up, right, scale, false, pass != GLPASS_LIGHTTEX)) + { + node = node->nextLight; + continue; + } + gl_RenderState.Apply(); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (unsigned int k = 0; k < sub->numlines; k++) + { + vertex_t *vt = sub->firstline[k].v1; + ptr->x = vt->fX(); + ptr->z = plane.plane.ZatPoint(vt) + dz; + ptr->y = vt->fY(); + t1.Set(ptr->x, ptr->z, ptr->y); + Vector nearToVert = t1 - nearPt; + + ptr->u = (nearToVert.Dot(right) * scale) + 0.5f; + ptr->v = (nearToVert.Dot(up) * scale) + 0.5f; + ptr++; + } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + node = node->nextLight; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void GLFlat::DrawLightsCompat(int pass) +{ + gl_RenderState.Apply(); + // 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) + { + DrawSubsectorLights(sub, pass); + } + } + + // 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) + { + DrawSubsectorLights(node->sub, pass); + node = node->next; + } + } +} + + +//========================================================================== +// +// Sets up the texture coordinates for one light to be rendered +// +//========================================================================== +bool GLWall::PrepareLight(ADynamicLight * light, int pass) +{ + 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; + Vector nearPt, up, right; + float scale; + + p.Init(vtx, 4); + + if (!p.ValidNormal()) + { + return false; + } + + if (!gl_SetupLight(seg->frontsector->PortalGroup, p, light, nearPt, up, right, scale, true, pass != GLPASS_LIGHTTEX)) + { + return false; + } + + Vector t1; + int outcnt[4] = { 0,0,0,0 }; + + 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; + + // quick check whether the light touches this polygon + 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]++; + + } + // The light doesn't touch this polygon + if (outcnt[0] == 4 || outcnt[1] == 4 || outcnt[2] == 4 || outcnt[3] == 4) return false; + + draw_dlight++; + return true; +} + + +void GLWall::RenderLightsCompat(int pass) +{ + FLightNode * node; + + // black fog is diminishing light and should affect lights less than the rest! + if (pass == GLPASS_LIGHTTEX) gl_SetFog((255 + lightlevel) >> 1, 0, NULL, false); + else gl_SetFog(lightlevel, 0, &Colormap, true); + + if (seg->sidedef == NULL) + { + return; + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + // Iterate through all dynamic lights which touch this wall and render them + node = seg->sidedef->lighthead; + } + else if (sub) + { + // To avoid constant rechecking for polyobjects use the subsector's lightlist instead + node = sub->lighthead; + } + else + { + return; + } + + texcoord save[4]; + memcpy(save, tcs, sizeof(tcs)); + while (node) + { + ADynamicLight * light = node->lightsource; + + if (light->flags2&MF2_DORMANT || + (pass == GLPASS_LIGHTTEX && light->IsAdditive()) || + (pass == GLPASS_LIGHTTEX_ADDITIVE && !light->IsAdditive())) + { + node = node->nextLight; + continue; + } + if (PrepareLight(light, pass)) + { + vertcount = 0; + RenderWall(RWF_TEXTURED); + } + node = node->nextLight; + } + memcpy(tcs, save, sizeof(tcs)); + vertcount = 0; +} + +//========================================================================== +// +// +// +//========================================================================== + +void FGLRenderer::RenderMultipassStuff() +{ + // First pass: empty background with sector light only + + // Part 1: solid geometry. This is set up so that there are no transparent parts + + // remove any remaining texture bindings and shaders whick may get in the way. + gl_RenderState.EnableTexture(false); + gl_RenderState.EnableBrightmap(false); + gl_RenderState.Apply(); + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_PLAIN); + + // Part 2: masked geometry. This is set up so that only pixels with alpha>0.5 will show + // This creates a blank surface that only fills the nontransparent parts of the texture + gl_RenderState.EnableTexture(true); + gl_RenderState.SetTextureMode(TM_MASK); + gl_RenderState.EnableBrightmap(true); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_PLAIN); + + // Part 3: The base of fogged surfaces, including the texture + gl_RenderState.EnableBrightmap(false); + gl_RenderState.SetTextureMode(TM_MODULATE); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(GLPASS_PLAIN); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_PLAIN); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_PLAIN); + + // second pass: draw lights + glDepthMask(false); + if (mLightCount && !gl_fixedcolormap) + { + if (gl_SetupLightTexture()) + { + gl_RenderState.BlendFunc(GL_ONE, GL_ONE); + glDepthFunc(GL_EQUAL); + if (glset.lightmode == 8) gl_RenderState.SetSoftLightLevel(255); + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX); + gl_RenderState.BlendEquation(GL_FUNC_ADD); + } + else gl_lights = false; + } + + // third pass: modulated texture + gl_RenderState.SetColor(0xffffffff); + gl_RenderState.BlendFunc(GL_DST_COLOR, GL_ZERO); + gl_RenderState.EnableFog(false); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0); + glDepthFunc(GL_LEQUAL); + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_TEXONLY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_TEXONLY); + gl_RenderState.AlphaFunc(GL_GREATER, gl_mask_threshold); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_TEXONLY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_TEXONLY); + + // fourth pass: additive lights + gl_RenderState.EnableFog(true); + gl_RenderState.BlendFunc(GL_ONE, GL_ONE); + glDepthFunc(GL_EQUAL); + if (gl_SetupLightTexture()) + { + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_WALLS_MASKED].DrawWalls(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_FLATS_PLAIN].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_FLATS_MASKED].DrawFlats(GLPASS_LIGHTTEX_ADDITIVE); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].DrawWalls(GLPASS_LIGHTTEX_FOGGY); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOGMASKED].DrawWalls(GLPASS_LIGHTTEX_FOGGY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOG].DrawFlats(GLPASS_LIGHTTEX_FOGGY); + gl_drawinfo->dldrawlists[GLLDL_FLATS_FOGMASKED].DrawFlats(GLPASS_LIGHTTEX_FOGGY); + } + else gl_lights = false; + + glDepthFunc(GL_LESS); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.EnableFog(true); + gl_RenderState.BlendFunc(GL_ONE, GL_ZERO); + glDepthMask(true); + +} + diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp new file mode 100644 index 000000000..2aea2b8a3 --- /dev/null +++ b/src/gl/data/gl_data.cpp @@ -0,0 +1,538 @@ +/* +** 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_tags.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. +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.isSlope()) s->reflect[sector_t::floor] = arg1/255.f; + if (!s->ceilingplane.isSlope()) sectors[secnum].reflect[sector_t::ceiling] = arg2/255.f; + } + + return true; +} + +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_90/4)*9) >> 28; + } + else + { + rot = (ang + (angle_t)(ANGLE_90/4)*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=v->sectors[i]->ceilingplane.ZatPoint(v); + else height=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() +{ + 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", + seg->v1->fX(), seg->v1->fY(), seg->v2->fX(), seg->v2->fY(), + 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", + seg->v1->fX(), seg->v1->fY(), seg->v2->fX(), seg->v2->fY(), + 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..f1bc27ee4 --- /dev/null +++ b/src/gl/data/gl_data.h @@ -0,0 +1,76 @@ + +#ifndef __GLC_DATA_H +#define __GLC_DATA_H + +#include "doomtype.h" +#include "vectors.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 +{ + DVector2 mDisplacement; + int plane; + GLSectorStackPortal *glportal; // for quick access to the render data. This is only valid during BSP traversal! + + GLSectorStackPortal *GetRenderState(); +}; + +struct FGLLinePortal +{ + // defines the complete span of this portal, if this is of type PORTT_LINKED. + vertex_t *v1 = nullptr, *v2 = nullptr; // vertices, from v1 to v2 + TArray lines; + int validcount = 0; +}; + +extern TArray portals; +extern TArray linePortalToGL; + +extern TArray currentmapsection; + +void gl_InitPortals(); +void gl_BuildPortalCoverage(FPortalCoverage *coverage, subsector_t *subsector, const DVector2 &displacement); +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..bc0f4129f --- /dev/null +++ b/src/gl/data/gl_matrix.cpp @@ -0,0 +1,486 @@ +/* -------------------------------------------------- + +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 +#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 +void +VSMatrix::translate(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) +{ + mMatrix[12] = mMatrix[0] * x + mMatrix[4] * y + mMatrix[8] * z + mMatrix[12]; + mMatrix[13] = mMatrix[1] * x + mMatrix[5] * y + mMatrix[9] * z + mMatrix[13]; + mMatrix[14] = mMatrix[2] * x + mMatrix[6] * y + mMatrix[10] * z + mMatrix[14]; +} + + +// gl Scale implementation +void +VSMatrix::scale(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z) +{ + mMatrix[0] *= x; mMatrix[1] *= x; mMatrix[2] *= x; mMatrix[3] *= x; + mMatrix[4] *= y; mMatrix[5] *= y; mMatrix[6] *= y; mMatrix[7] *= y; + mMatrix[8] *= z; mMatrix[9] *= z; mMatrix[10] *= z; mMatrix[11] *= z; +} + + +// gl Rotate implementation +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..3ec1f5ff4 --- /dev/null +++ b/src/gl/data/gl_matrix.h @@ -0,0 +1,115 @@ + +// 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 multVector(FLOATTYPE *aVector); + 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); + } + bool inverseMatrix(VSMatrix &result); + void transpose(); + + 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..847bf6f61 --- /dev/null +++ b/src/gl/data/gl_portaldata.cpp @@ -0,0 +1,535 @@ +/* +** 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 +{ + DVector2 mDisplacement; + + // for the hash code + operator intptr_t() const { return (FLOAT2FIXED(mDisplacement.X) >> 8) + (FLOAT2FIXED(mDisplacement.Y) << 8); } + bool operator != (const FPortalID &other) const + { + return mDisplacement != other.mDisplacement; + } +}; + +struct FPortalSector +{ + sector_t *mSub; + int mPlane; +}; + +typedef TArray FPortalSectors; + +typedef TMap FPortalMap; + +TArray portals; +TArray linePortalToGL; +TArray glLinePortals; + +//========================================================================== +// +// +// +//========================================================================== + +GLSectorStackPortal *FPortal::GetRenderState() +{ + if (glportal == NULL) glportal = new GLSectorStackPortal(this); + return glportal; +} + +//========================================================================== +// +// this is left as fixed_t because the nodes also are, it makes no sense +// to convert this without converting the nodes as well. +// +//========================================================================== + +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; + TArray collect; + FCoverageVertex center; + + //========================================================================== + // + // + // + //========================================================================== + + FCoverageBuilder(subsector_t *sub) + { + target = sub; + } + + //========================================================================== + // + // 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 * 65536.); + } + + //========================================================================== + // + // + // + //========================================================================== + + 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, const DVector2 &displacement) +{ + TArray shape; + double centerx=0, centery=0; + + shape.Resize(subsector->numlines); + for(unsigned i=0; inumlines; i++) + { + centerx += (shape[i].x = FLOAT2FIXED(subsector->firstline[i].v1->fX() + displacement.X)); + centery += (shape[i].y = FLOAT2FIXED(subsector->firstline[i].v1->fY() + displacement.Y)); + } + + FCoverageBuilder build(subsector); + 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;iGetPortalType(j); + if (ptype== PORTS_STACKEDSECTORTHING || ptype == PORTS_PORTAL || ptype == PORTS_LINKEDPORTAL) // only offset-displacing portal types + { + FPortalID id = { sec->GetPortalDisplacement(j) }; + + FPortalSectors &sss = collection[id]; + FPortalSector ss = { sec, j }; + sss.Push(ss); + } + } + } +} + +void gl_InitPortals() +{ + FPortalMap collection; + + if (numnodes == 0) return; + + for(int i=0;idx); + double fdy = FIXED2DBL(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) + { + // add separate portals for floor and ceiling. + if (planeflags & i) + { + FPortal *portal = new FPortal; + portal->mDisplacement = pair->Key.mDisplacement; + 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, pair->Key.mDisplacement); + } + sec->portals[plane] = portal; + } + } + } + } + } + + // Now group the line portals (each group must be a continuous set of colinear linedefs with no gaps) + glLinePortals.Clear(); + linePortalToGL.Clear(); + TArray tempindex; + + tempindex.Reserve(linePortals.Size()); + memset(&tempindex[0], -1, linePortals.Size() * sizeof(int)); + + for (unsigned i = 0; i < linePortals.Size(); i++) + { + auto port = linePortals[i]; + bool gotsome; + + if (tempindex[i] == -1) + { + tempindex[i] = glLinePortals.Size(); + line_t *pSrcLine = linePortals[i].mOrigin; + line_t *pLine = linePortals[i].mDestination; + FGLLinePortal &glport = glLinePortals[glLinePortals.Reserve(1)]; + glport.lines.Push(&linePortals[i]); + + // We cannot do this grouping for non-linked portals because they can be changed at run time. + if (linePortals[i].mType == PORTT_LINKED && pLine != nullptr) + { + glport.v1 = pLine->v1; + glport.v2 = pLine->v2; + do + { + // now collect all other colinear lines connected to this one. We run this loop as long as it still finds a match + gotsome = false; + for (unsigned j = 0; j < linePortals.Size(); j++) + { + if (tempindex[j] == -1) + { + line_t *pSrcLine2 = linePortals[j].mOrigin; + line_t *pLine2 = linePortals[j].mDestination; + // angular precision is intentionally reduced to 32 bit BAM to account for precision problems (otherwise many not perfectly horizontal or vertical portals aren't found here.) + unsigned srcang = pSrcLine->Delta().Angle().BAMs(); + unsigned dstang = pLine->Delta().Angle().BAMs(); + if ((pSrcLine->v2 == pSrcLine2->v1 && pLine->v1 == pLine2->v2) || + (pSrcLine->v1 == pSrcLine2->v2 && pLine->v2 == pLine2->v1)) + { + // The line connects, now check the translation + unsigned srcang2 = pSrcLine2->Delta().Angle().BAMs(); + unsigned dstang2 = pLine2->Delta().Angle().BAMs(); + if (srcang == srcang2 && dstang == dstang2) + { + // The lines connect and both source and destination are colinear, so this is a match + gotsome = true; + tempindex[j] = tempindex[i]; + if (pLine->v1 == pLine2->v2) glport.v1 = pLine2->v1; + else glport.v2 = pLine2->v2; + glport.lines.Push(&linePortals[j]); + } + } + } + } + } while (gotsome); + } + } + } + linePortalToGL.Resize(linePortals.Size()); + for (unsigned i = 0; i < linePortals.Size(); i++) + { + linePortalToGL[i] = &glLinePortals[tempindex[i]]; + /* + Printf("portal at line %d translates to GL portal %d, range = %f,%f to %f,%f\n", + int(linePortals[i].mOrigin - lines), tempindex[i], linePortalToGL[i]->v1->fixX() / 65536., linePortalToGL[i]->v1->fixY() / 65536., linePortalToGL[i]->v2->fixX() / 65536., linePortalToGL[i]->v2->fixY() / 65536.); + */ + } +} + +CCMD(dumpportals) +{ + for(unsigned i=0;imDisplacement.X; + double ydisp = portals[i]->mDisplacement.Y; + 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->GetGLPortal(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->fX() + xdisp, sub->firstline[k].v1->fY() + 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->fX(), csub->firstline[m].v1->fY()); + } + 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..73ceddb13 --- /dev/null +++ b/src/gl/data/gl_setup.cpp @@ -0,0 +1,744 @@ +/* +** 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_spec.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 TArray MapSectionCollector; + +static void DoSetMapSection(subsector_t *sub, int num) +{ + MapSectionCollector.Resize(1); + MapSectionCollector[0] = sub; + sub->mapsection = num; + for (unsigned a = 0; a < MapSectionCollector.Size(); a++) + { + sub = MapSectionCollector[a]; + for (DWORD i = 0; i < sub->numlines; i++) + { + seg_t * seg = sub->firstline + i; + + if (seg->PartnerSeg) + { + subsector_t * sub2 = seg->PartnerSeg->Subsector; + + if (sub2->mapsection != num) + { + assert(sub2->mapsection == 0); + sub2->mapsection = num; + MapSectionCollector.Push(sub2); + } + } + } + } + MapSectionCollector.Clear(); +} + +//========================================================================== +// +// 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 +{ + double X, Y; + + operator int() const { return xs_FloorToInt(X) + 65536 * xs_FloorToInt(Y); } + bool operator!= (const cvertex_t &other) const { return fabs(X - other.X) >= EQUAL_EPSILON || fabs(Y - other.Y) >= EQUAL_EPSILON; } + cvertex_t& operator =(const vertex_t *v) { X = v->fX(); Y = v->fY(); 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(DMSG_NOTIFY, "Found hack: (%f,%f) (%f,%f)\n", seg[j].v1->fX(), seg[j].v1->fY(), seg[j].v2->fX(), seg[j].v2->fY()); + 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==34) + { + 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.isSlope()); + + 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)+1. || sec->floorplane.isSlope()) + { + 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; + + 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(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 = ln->v1->fPos(); + *v2 = ln->v2->fPos(); + } + else + { + *v2 = ln->v1->fPos(); + *v1 = ln->v2->fPos(); + } +} + +static int 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].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]++; + DVector2 sidestart, sideend, segend = seg->v2->fPos(); + 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..0309b2bcd --- /dev/null +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -0,0 +1,494 @@ +/* +** 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 "r_state.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(bool wantbuffer) +{ + vbo_id = 0; + if (wantbuffer) glGenBuffers(1, &vbo_id); +} + +FVertexBuffer::~FVertexBuffer() +{ + if (vbo_id != 0) + { + glDeleteBuffers(1, &vbo_id); + } +} + + +void FSimpleVertexBuffer::BindVBO() +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + if (!gl.legacyMode) + { + glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSimpleVertex), &VSiO->x); + glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSimpleVertex), &VSiO->u); + glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSimpleVertex), &VSiO->color); + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); + glEnableVertexAttribArray(VATTR_COLOR); + glDisableVertexAttribArray(VATTR_VERTEX2); + } + else + { + glVertexPointer(3, GL_FLOAT, sizeof(FSimpleVertex), &VSiO->x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FSimpleVertex), &VSiO->u); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(FSimpleVertex), &VSiO->color); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + } +} + +void FSimpleVertexBuffer::EnableColorArray(bool on) +{ + if (on) + { + if (!gl.legacyMode) + { + glEnableVertexAttribArray(VATTR_COLOR); + } + else + { + glEnableClientState(GL_COLOR_ARRAY); + } + } + else + { + if (!gl.legacyMode) + { + glDisableVertexAttribArray(VATTR_COLOR); + } + else + { + glDisableClientState(GL_COLOR_ARRAY); + } + } +} + + +void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count) +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl_RenderState.ResetVertexBuffer(); + gl_RenderState.SetVertexBuffer(this); + glBufferData(GL_ARRAY_BUFFER, count * sizeof(*verts), verts, GL_STREAM_DRAW); +} + +//========================================================================== +// +// +// +//========================================================================== + +FFlatVertexBuffer::FFlatVertexBuffer(int width, int height) +: FVertexBuffer(!gl.legacyMode) +{ + switch (gl.buffermethod) + { + case BM_PERSISTENT: + { + 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); + DPrintf(DMSG_NOTIFY, "Using persistent buffer\n"); + break; + } + + case BM_DEFERRED: + { + unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, bytesize, NULL, GL_STREAM_DRAW); + map = nullptr; + DPrintf(DMSG_NOTIFY, "Using deferred buffer\n"); + break; + } + + default: + { + map = new FFlatVertex[BUFFER_SIZE]; + DPrintf(DMSG_NOTIFY, "Using client array buffer\n"); + break; + } + } + mIndex = mCurIndex = 0; + mNumReserved = NUM_RESERVED; + vbo_shadowdata.Resize(mNumReserved); + + // the first quad is reserved for handling coordinates through uniforms. + vbo_shadowdata[0].Set(0, 0, 0, 0, 0); + vbo_shadowdata[1].Set(1, 0, 0, 0, 0); + vbo_shadowdata[2].Set(2, 0, 0, 0, 0); + vbo_shadowdata[3].Set(3, 0, 0, 0, 0); + + // and the second one for the fullscreen quad used for blend overlays. + vbo_shadowdata[4].Set(0, 0, 0, 0, 0); + vbo_shadowdata[5].Set(0, (float)height, 0, 0, 0); + vbo_shadowdata[6].Set((float)width, 0, 0, 0, 0); + vbo_shadowdata[7].Set((float)width, (float)height, 0, 0, 0); + + // and this is for the postprocessing copy operation + vbo_shadowdata[8].Set(-1.0f, -1.0f, 0, 0.0f, 0.0f); + vbo_shadowdata[9].Set(-1.0f, 1.0f, 0, 0.0f, 1.f); + vbo_shadowdata[10].Set(1.0f, -1.0f, 0, 1.f, 0.0f); + vbo_shadowdata[11].Set(1.0f, 1.0f, 0, 1.f, 1.f); + + // The next two are the stencil caps. + vbo_shadowdata[12].Set(-32767.0f, 32767.0f, -32767.0f, 0, 0); + vbo_shadowdata[13].Set(-32767.0f, 32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[14].Set(32767.0f, 32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[15].Set(32767.0f, 32767.0f, -32767.0f, 0, 0); + + vbo_shadowdata[16].Set(-32767.0f, -32767.0f, -32767.0f, 0, 0); + vbo_shadowdata[17].Set(-32767.0f, -32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[18].Set(32767.0f, -32767.0f, 32767.0f, 0, 0); + vbo_shadowdata[19].Set(32767.0f, -32767.0f, -32767.0f, 0, 0); + + if (gl.buffermethod == BM_DEFERRED) + { + Map(); + memcpy(map, &vbo_shadowdata[0], mNumReserved * sizeof(FFlatVertex)); + Unmap(); + } + +} + +FFlatVertexBuffer::~FFlatVertexBuffer() +{ + if (vbo_id != 0) + { + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glUnmapBuffer(GL_ARRAY_BUFFER); + glBindBuffer(GL_ARRAY_BUFFER, 0); + } + if (gl.legacyMode) + { + delete[] map; + } + map = nullptr; +} + + +void FFlatVertexBuffer::BindVBO() +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + if (!gl.legacyMode) + { + 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); + glDisableVertexAttribArray(VATTR_COLOR); + glDisableVertexAttribArray(VATTR_VERTEX2); + } + else + { + glVertexPointer(3, GL_FLOAT, sizeof(FFlatVertex), &map->x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FFlatVertex), &map->u); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } +} + +void FFlatVertexBuffer::Map() +{ + if (gl.buffermethod == BM_DEFERRED) + { + unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl_RenderState.ResetVertexBuffer(); + map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, bytesize, GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT); + } +} + +void FFlatVertexBuffer::Unmap() +{ + if (gl.buffermethod == BM_DEFERRED) + { + unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + gl_RenderState.ResetVertexBuffer(); + glUnmapBuffer(GL_ARRAY_BUFFER); + map = nullptr; + } +} + +//========================================================================== +// +// Initialize a single vertex +// +//========================================================================== + +void FFlatVertex::SetFlatVertex(vertex_t *vt, const secplane_t & plane) +{ + x = vt->fX(); + y = vt->fY(); + z = plane.ZatPoint(vt); + 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() +{ + vbo_shadowdata.Resize(mNumReserved); + CreateFlatVBO(); + mCurIndex = mIndex = vbo_shadowdata.Size(); + Map(); + memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex)); + Unmap(); +} + +//========================================================================== +// +// +// +//========================================================================== + +void FFlatVertexBuffer::CheckPlanes(sector_t *sector) +{ + if (sector->GetPlaneTexZ(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) +{ + 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..0efff5508 --- /dev/null +++ b/src/gl/data/gl_vertexbuffer.h @@ -0,0 +1,291 @@ +#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; + +enum +{ + VATTR_VERTEX_BIT, + VATTR_TEXCOORD_BIT, + VATTR_COLOR_BIT, + VATTR_VERTEX2_BIT, + VATTR_NORMAL_BIT +}; + + +class FVertexBuffer +{ +protected: + unsigned int vbo_id; + +public: + FVertexBuffer(bool wantbuffer = true); + virtual ~FVertexBuffer(); + virtual void BindVBO() = 0; + void EnableBufferArrays(int enable, int disable); +}; + +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; + } +}; + +struct FSimpleVertex +{ + float x, z, y; // world position + float u, v; // texture coordinates + 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; + } +}; + +#define VTO ((FFlatVertex*)NULL) +#define VSiO ((FSimpleVertex*)NULL) + +class FSimpleVertexBuffer : public FVertexBuffer +{ + TArray mBuffer; +public: + FSimpleVertexBuffer() + { + } + void BindVBO(); + void set(FSimpleVertex *verts, int count); + void EnableColorArray(bool on); +}; + +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; + +public: + enum + { + QUAD_INDEX = 0, + FULLSCREEN_INDEX = 4, + PRESENT_INDEX = 8, + STENCILTOP_INDEX = 12, + STENCILBOTTOM_INDEX = 16, + + NUM_RESERVED = 20 + }; + + TArray vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer and as stand-in for pre GL 4.x + + FFlatVertexBuffer(int width, int height); + ~FFlatVertexBuffer(); + + void BindVBO(); + + void CreateVBO(); + void CheckUpdate(sector_t *sector); + + FFlatVertex *GetBuffer() + { + return &map[mCurIndex]; + } + FFlatVertex *Alloc(int num, int *poffset) + { + FFlatVertex *p = GetBuffer(); + *poffset = mCurIndex; + mCurIndex += num; + if (mCurIndex >= BUFFER_SIZE_TO_USE) mCurIndex = mIndex; + return p; + } + + 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(); + glDrawArrays(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; + } + + void Map(); + void Unmap(); + +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; + } + + void SetXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0, PalEntry col = 0xffffffff) + { + x = xx; + y = yy; + z = zz; + 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; + + // indices for sky cubemap faces + int mFaceStart[7]; + int mSideStart; + + 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); + void BindVBO(); + int FaceStart(int i) + { + if (i >= 0 && i < 7) return mFaceStart[i]; + else return mSideStart; + } + +}; + +#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]; + FModelVertex *vbo_ptr; + uint32_t ibo_id; + +public: + + FModelVertexBuffer(bool needindex, bool singleframe); + ~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, unsigned int size); + void BindVBO(); +}; + +#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..ac929e7c0 --- /dev/null +++ b/src/gl/dynlights/a_dynlight.cpp @@ -0,0 +1,826 @@ +/* +** a_dynlight.cpp +** Implements actors representing dynamic lights (hardware independent) +** +**--------------------------------------------------------------------------- +** Copyright 2003 Timothy Stump +** Copyright 2005-2016 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 "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 "templates.h" +#include "doomdata.h" +#include "r_utility.h" +#include "portal.h" +#include "doomstat.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(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) AddZ(-Sector->floorplane.ZatPoint(this), false); + lighttype = PointLight; +} + +void AVavoomLightWhite::BeginPlay () +{ + m_Radius[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_Radius[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_currentRadius; + arc << m_Radius[0] << m_Radius[1]; + + if (lighttype == PulseLight) arc << m_lastUpdate << m_cycler; + if (arc.IsLoading()) + { + // The default constructor which is used for creating objects before deserialization will not set this variable. + // It needs to be true for all placed lights. + visibletoplayer = true; + LinkLight(); + } +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::BeginPlay() +{ + //Super::BeginPlay(); + ChangeStatNum(STAT_DLIGHT); + + m_Radius[0] = args[LIGHT_INTENSITY]; + m_Radius[1] = args[LIGHT_SECONDARY_INTENSITY]; + visibletoplayer = true; +} + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::PostBeginPlay() +{ + Super::PostBeginPlay(); + + if (!(SpawnFlags & MTF_DORMANT)) + { + Activate (NULL); + } + + subsector = R_PointInSubsector(Pos()); +} + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::Activate(AActor *activator) +{ + //Super::Activate(activator); + flags2&=~MF2_DORMANT; + + m_currentRadius = float(m_Radius[0]); + m_tickCount = 0; + + if (lighttype == PulseLight) + { + float pulseTime = Angles.Yaw.Degrees / TICRATE; + + m_lastUpdate = level.maptime; + m_cycler.SetParams(float(m_Radius[1]), float(m_Radius[0]), pulseTime); + m_cycler.ShouldCycle(true); + m_cycler.SetCycleType(CYCLE_Sin); + m_currentRadius = (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; + visibletoplayer = target->IsVisibleToPlayer(); // cache this value for the renderer to speed up calculations. + } + + // 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_currentRadius = m_cycler.GetVal(); + break; + } + + case FlickerLight: + { + BYTE rnd = randLight(); + float pct = Angles.Yaw.Degrees / 360.f; + + m_currentRadius = float(m_Radius[rnd >= pct * 255]); + break; + } + + case RandomFlickerLight: + { + int flickerRange = m_Radius[1] - m_Radius[0]; + float amt = randLight() / 255.f; + + m_tickCount++; + + if (m_tickCount > Angles.Yaw.Degrees) + { + m_currentRadius = float(m_Radius[0] + (amt * flickerRange)); + m_tickCount = 0; + } + break; + } + +#if 0 + // These need some more work elsewhere + case ColorFlickerLight: + { + BYTE rnd = randLight(); + float pct = Angles.Yaw.Degrees/360.f; + + m_currentRadius = m_Radius[rnd >= pct * 255]; + break; + } + + case RandomColorFlickerLight: + { + int flickerRange = m_Radius[1] - m_Radius[0]; + float amt = randLight() / 255.f; + + m_tickCount++; + + if (m_tickCount > Angles.Yaw.Degrees) + { + m_currentRadius = m_Radius[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_currentRadius = intensity; + break; + } + + case PointLight: + m_currentRadius = float(m_Radius[0]); + break; + } + + UpdateLocation(); +} + + + + +//========================================================================== +// +// +// +//========================================================================== +void ADynamicLight::UpdateLocation() +{ + double oldx= X(); + double oldy= Y(); + double oldradius= radius; + float intensity; + + if (IsActive()) + { + if (target) + { + DAngle angle = target->Angles.Yaw; + double s = angle.Sin(); + double c = angle.Cos(); + + DVector3 pos = target->Vec3Offset(m_off.X * c + m_off.Y * s, m_off.X * s - m_off.Y * c, m_off.Z + target->GetBobOffset()); + SetXYZ(pos); // attached lights do not need to go into the regular blockmap + Prev = target->Pos(); + subsector = R_PointInSubsector(Prev); + 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 || lighttype == PulseLight) + { + intensity = float(MAX(m_Radius[0], m_Radius[1])); + } + else + { + intensity = m_currentRadius; + } + radius = intensity * 2.0f; + + if (X() != oldx || Y() != oldy || radius != oldradius) + { + //Update the light lists + LinkLight(); + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== + +void ADynamicLight::SetOrigin(double x, double y, double z, bool moving) +{ + Super::SetOrigin(x, y, z, moving); + LinkLight(); +} + +//========================================================================== +// +// +// +//========================================================================== + +void ADynamicLight::SetOffset(const DVector3 &pos) +{ + m_off = pos; + 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 +// +//========================================================================== + +double ADynamicLight::DistToSeg(const DVector3 &pos, seg_t *seg) +{ + double u, px, py; + + double seg_dx = seg->v2->fX() - seg->v1->fX(); + double seg_dy = seg->v2->fY() - seg->v1->fY(); + double seg_length_sq = seg_dx * seg_dx + seg_dy * seg_dy; + + u = (((pos.X - seg->v1->fX()) * seg_dx) + (pos.Y - seg->v1->fY()) * seg_dy) / seg_length_sq; + if (u < 0.) u = 0.; // clamp the test point to the line segment + else if (u > 1.) u = 1.; + + px = seg->v1->fX() + (u * seg_dx); + py = seg->v1->fY() + (u * seg_dy); + + px -= pos.X; + py -= pos.Y; + + return (px*px) + (py*py); +} + + +//========================================================================== +// +// Collect all touched sidedefs and subsectors +// to sidedefs and sector parts. +// +//========================================================================== + +void ADynamicLight::CollectWithinRadius(const DVector3 &pos, 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; + + // check distance from x/y to seg and if within radius add this seg and, if present the opposing subsector (lather/rinse/repeat) + // If out of range we do not need to bother with this seg. + if (DistToSeg(pos, seg) <= radius) + { + if (seg->sidedef && seg->linedef && seg->linedef->validcount != ::validcount) + { + // light is in front of the seg + if ((pos.Y - seg->v1->fY()) * (seg->v2->fX() - seg->v1->fX()) + (seg->v1->fX() - pos.X) * (seg->v2->fY() - seg->v1->fY()) <= 0) + { + seg->linedef->validcount = validcount; + touching_sides = AddLightNode(&seg->sidedef->lighthead, seg->sidedef, this, touching_sides); + } + } + if (seg->linedef) + { + FLinePortal *port = seg->linedef->getPortal(); + if (port && port->mType == PORTT_LINKED) + { + line_t *other = port->mDestination; + if (other->validcount != ::validcount) + { + subsector_t *othersub = R_PointInSubsector(other->v1->fPos() + other->Delta() / 2); + if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(other), othersub, radius); + } + } + } + + seg_t *partner = seg->PartnerSeg; + if (partner) + { + subsector_t *sub = partner->Subsector; + if (sub != NULL && sub->validcount != ::validcount) + { + CollectWithinRadius(pos, sub, radius); + } + } + } + } + sector_t *sec = subSec->sector; + if (!sec->PortalBlocksSight(sector_t::ceiling)) + { + line_t *other = subSec->firstline->linedef; + if (sec->GetPortalPlaneZ(sector_t::ceiling) < Z() + radius) + { + DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::ceiling); + subsector_t *othersub = R_PointInSubsector(refpos); + if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, radius); + } + } + if (!sec->PortalBlocksSight(sector_t::floor)) + { + line_t *other = subSec->firstline->linedef; + if (sec->GetPortalPlaneZ(sector_t::floor) > Z() - radius) + { + DVector2 refpos = other->v1->fPos() + other->Delta() / 2 + sec->GetPortalDisplacement(sector_t::floor); + subsector_t *othersub = R_PointInSubsector(refpos); + if (othersub->validcount != ::validcount) CollectWithinRadius(PosRelative(othersub->sector), othersub, 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 sqrt + subsector_t * subSec = R_PointInSubsector(Pos()); + ::validcount++; + CollectWithinRadius(Pos(), subSec, radius*radius); + + } + + // 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(), + dl->X(), dl->Y(), dl->Z(), dl->args[LIGHT_RED], + dl->args[LIGHT_GREEN], dl->args[LIGHT_BLUE], 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..b12290ab6 --- /dev/null +++ b/src/gl/dynlights/gl_dynlight.cpp @@ -0,0 +1,1364 @@ +/* +** 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" + +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 PClassActor * GetRealType(PClassActor * ti) +{ + PClassActor *rep = ti->GetReplacement(false); + if (rep != ti && rep != NULL && rep->IsDescendantOf(RUNTIME_CLASS(ADehackedPickup))) + { + return rep; + } + 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 SetParameter(double p) { m_Param = p; } + void SetArg(int arg, BYTE val) { m_Args[arg] = val; } + BYTE GetArg(int arg) { return m_Args[arg]; } + void SetOffset(float* ft) { m_Pos.X = ft[0]; m_Pos.Z = ft[1]; m_Pos.Y = 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]; + double m_Param; + DVector3 m_Pos; + 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_Pos.Zero(); + memset(m_Args, 0, 5); + m_Param = 0; + + m_subtractive = false; + m_additive = false; + m_halo = false; + m_dontlightself = false; +} + +void FLightDefaults::ApplyProperties(ADynamicLight * light) const +{ + light->lighttype = m_type; + light->Angles.Yaw.Degrees = m_Param; + light->SetOffset(m_Pos); + light->halo = m_halo; + for (int a = 0; a < 3; a++) light->args[a] = clamp((int)(m_Args[a]), 0, 255); + light->m_Radius[0] = int(m_Args[LIGHT_INTENSITY]); + light->m_Radius[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->SetParameter(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->SetParameter(floatVal*360.); + 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->SetParameter(floatVal * 360.); + 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->Pos(), 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..6b6e40c2d --- /dev/null +++ b/src/gl/dynlights/gl_dynlight.h @@ -0,0 +1,191 @@ +#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 GetRadius() const { return (IsActive() ? m_currentRadius * 2.f : 0.f); } + void LinkLight(); + void UnlinkLight(); + size_t PointerSubstitution (DObject *old, DObject *notOld); + + void BeginPlay(); + void SetOrigin (double x, double y, double z, bool moving = false); + void PostBeginPlay(); + void Destroy(); + void Activate(AActor *activator); + void Deactivate(AActor *activator); + void SetOffset(const DVector3 &pos); + 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: + double DistToSeg(const DVector3 &pos, seg_t *seg); + void CollectWithinRadius(const DVector3 &pos, subsector_t *subSec, float radius); + +protected: + DVector3 m_off; + float m_currentRadius; + int m_tickCount; + unsigned int m_lastUpdate; + FCycler m_cycler; + subsector_t * subsector; + +public: + int m_Radius[2]; + BYTE lightflags; + BYTE lighttype; + bool owned; + bool halo; + BYTE color2[3]; + bool visibletoplayer; + 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(int group, Plane & p, ADynamicLight * light, bool checkside, 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..89cdd1ecb --- /dev/null +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -0,0 +1,135 @@ +/* +** 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 (Bool, gl_light_sprites, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); +CVAR (Bool, gl_light_particles, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + +//========================================================================== +// +// Sets up the parameters to render one dynamic light onto one plane +// +//========================================================================== +bool gl_GetLight(int group, Plane & p, ADynamicLight * light, bool checkside, FDynLightData &ldata) +{ + int i = 0; + + DVector3 pos = light->PosRelative(group); + + float dist = fabsf(p.DistToPoint(pos.X, pos.Z, pos.Y)); + float radius = (light->GetRadius()); + + if (radius <= 0.f) return false; + if (dist > radius) return false; + if (checkside && gl_lights_checkside && p.PointOnSide(pos.X, pos.Z, pos.Y)) + { + return false; + } + + + float cs; + if (light->IsAdditive()) + { + cs = 0.2f; + i = 2; + } + else + { + cs = 1.0f; + } + + float r = light->GetRed() / 255.0f * cs; + float g = light->GetGreen() / 255.0f * cs; + float b = light->GetBlue() / 255.0f * cs; + + 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] = pos.X; + data[1] = pos.Z; + data[2] = pos.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..eee1788dc --- /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, const DVector3 &pos) +{ + FTextureID floorpic = sec->GetTexture(sector_t::floor); + FTexture *tex = TexMan[floorpic]; + if (tex != NULL && tex->isGlowing()) + { + double floordiff = pos.Z - sec->floorplane.ZatPoint(pos); + if (floordiff < tex->gl_info.GlowHeight && tex->gl_info.GlowHeight != 0) + { + int maxlight = (255 + lightlevel) >> 1; + double lightfrac = floordiff / tex->gl_info.GlowHeight; + if (lightfrac < 0) lightfrac = 0; + lightlevel = int(lightfrac*lightlevel + maxlight*(1 - lightfrac)); + } + } + return lightlevel; +} + diff --git a/src/gl/dynlights/gl_glow.h b/src/gl/dynlights/gl_glow.h new file mode 100644 index 000000000..7d9ae9f7f --- /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, const DVector3 &pos); + +#endif diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp new file mode 100644 index 000000000..604b6f9a2 --- /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.lightmethod == LM_DIRECT) + { + 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.lightmethod == LM_DIRECT) + { + 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.lightmethod == LM_DEFERRED) + { + glBindBuffer(mBufferType, mBufferId); + mBufferPointer = (float*)glMapBufferRange(mBufferType, 0, mByteSize, GL_MAP_WRITE_BIT); + } +} + +void FLightBuffer::Finish() +{ + if (gl.lightmethod == LM_DEFERRED) + { + 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_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..c3e700571 --- /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 + +#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..637d1fb78 --- /dev/null +++ b/src/gl/hqnx/hq2x.cpp @@ -0,0 +1,2808 @@ +/* + * 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 "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 + +#if defined( __GNUC__ ) + #ifdef __MINGW32__ + #define HQX_CALLCONV __stdcall + #else + #define HQX_CALLCONV + #endif +#else + #define HQX_CALLCONV +#endif + +#if 0 //defined(_WIN32) + #ifdef DLL_EXPORT + #define HQX_API __declspec(dllexport) + #else + #define HQX_API __declspec(dllimport) + #endif +#else + #define HQX_API +#endif + +HQX_API void HQX_CALLCONV hqxInit(void); +HQX_API void HQX_CALLCONV hq2x_32( uint32_t * src, uint32_t * dest, int width, int height ); +HQX_API void HQX_CALLCONV hq3x_32( uint32_t * src, uint32_t * dest, int width, int height ); +HQX_API void HQX_CALLCONV hq4x_32( uint32_t * src, uint32_t * dest, int width, int height ); + +HQX_API void HQX_CALLCONV hq2x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height ); +HQX_API void HQX_CALLCONV hq3x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height ); +HQX_API void HQX_CALLCONV hq4x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height ); + +#endif diff --git a/src/gl/hqnx/init.cpp b/src/gl/hqnx/init.cpp new file mode 100644 index 000000000..0e8c2db1c --- /dev/null +++ b/src/gl/hqnx/init.cpp @@ -0,0 +1,38 @@ +/* + * 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 "hqx.h" + +uint32_t *RGBtoYUV; +uint32_t YUV1, YUV2; + +HQX_API void HQX_CALLCONV hqxInit(void) +{ + /* Initalize RGB to YUV lookup table */ + uint32_t c, r, g, b, y, u, v; + RGBtoYUV = new uint32_t[16777216]; + for (c = 0; c < 16777215; c++) { + r = (c & 0xFF0000) >> 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_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..38f0f1d6a --- /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() + +} \ 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..22b61ace4 --- /dev/null +++ b/src/gl/models/gl_models.cpp @@ -0,0 +1,1140 @@ +/* +** 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; + +DeletingModelArray Models; + + +void gl_LoadModels() +{ + /* + for (int i = Models.Size() - 1; i >= 0; i--) + { + Models[i]->BuildVertexBuffer(); + } + */ +} + +void gl_FlushModels() +{ + for (int i = Models.Size() - 1; i >= 0; i--) + { + Models[i]->DestroyVertexBuffer(); + } +} + +//=========================================================================== +// +// Uses a hardware buffer if either single frame (i.e. no interpolation needed) +// or shading is available (interpolation is done by the vertex shader) +// +// If interpolation has to be done on the CPU side this will fall back +// to CPU-side arrays. +// +//=========================================================================== + +FModelVertexBuffer::FModelVertexBuffer(bool needindex, bool singleframe) + : FVertexBuffer(singleframe || !gl.legacyMode) +{ + vbo_ptr = nullptr; + ibo_id = 0; + if (needindex) + { + glGenBuffers(1, &ibo_id); // The index buffer can always be a real buffer. + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FModelVertexBuffer::BindVBO() +{ + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + if (!gl.legacyMode) + { + glEnableVertexAttribArray(VATTR_VERTEX); + glEnableVertexAttribArray(VATTR_TEXCOORD); + glEnableVertexAttribArray(VATTR_VERTEX2); + glDisableVertexAttribArray(VATTR_COLOR); + } + else + { + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FModelVertexBuffer::~FModelVertexBuffer() +{ + if (ibo_id != 0) + { + glDeleteBuffers(1, &ibo_id); + } + if (vbo_ptr != nullptr) + { + delete[] vbo_ptr; + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FModelVertex *FModelVertexBuffer::LockVertexBuffer(unsigned int size) +{ + if (vbo_id > 0) + { + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, size * sizeof(FModelVertex), nullptr, GL_STATIC_DRAW); + if (!gl.legacyMode) + return (FModelVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, size * sizeof(FModelVertex), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + else + return (FModelVertex*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); + } + else + { + if (vbo_ptr != nullptr) delete[] vbo_ptr; + vbo_ptr = new FModelVertex[size]; + memset(vbo_ptr, 0, size * sizeof(FModelVertex)); + return vbo_ptr; + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FModelVertexBuffer::UnlockVertexBuffer() +{ + if (vbo_id > 0) + { + 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); + if (!gl.legacyMode) + return (unsigned int*)glMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, size * sizeof(unsigned int), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + else + return (unsigned int*)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); + } + else + { + return nullptr; + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FModelVertexBuffer::UnlockIndexBuffer() +{ + if (ibo_id > 0) + { + 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! +// +//=========================================================================== +static TArray iBuffer; + +unsigned int FModelVertexBuffer::SetupFrame(unsigned int frame1, unsigned int frame2, unsigned int size) +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + if (vbo_id > 0) + { + if (!gl.legacyMode) + { + 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); + } + else + { + // only used for single frame models so there is no vertex2 here, which has no use without a shader. + glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &VMO[frame1].u); + } + } + else if (frame1 == frame2 || size == 0 || gl_RenderState.GetInterpolationFactor() == 0.f) + { + glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &vbo_ptr[frame1].x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &vbo_ptr[frame1].u); + } + else + { + // must interpolate + iBuffer.Resize(size); + glVertexPointer(3, GL_FLOAT, sizeof(FModelVertex), &iBuffer[0].x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FModelVertex), &vbo_ptr[frame1].u); + float frac = gl_RenderState.GetInterpolationFactor(); + for (unsigned i = 0; i < size; i++) + { + iBuffer[i].x = vbo_ptr[frame1 + i].x * (1.f - frac) + vbo_ptr[frame2 + i].x * frac; + iBuffer[i].y = vbo_ptr[frame1 + i].y * (1.f - frac) + vbo_ptr[frame2 + i].y * frac; + iBuffer[i].z = vbo_ptr[frame1 + i].z * (1.f - frac) + vbo_ptr[frame2 + i].z * frac; + } + } + return frame1; +} + +//=========================================================================== +// +// FModel::~FModel +// +//=========================================================================== + +FModel::~FModel() +{ + if (mVBuf != nullptr) delete mVBuf; +} + + + + +static TArray SpriteModelFrames; +static int * SpriteModelHash; +//TArray StateModelFrames; + +static void DeleteModelHash() +{ + if (SpriteModelHash != nullptr) delete [] SpriteModelHash; + SpriteModelHash = nullptr; +} + +//=========================================================================== +// +// FindGFXFile +// +//=========================================================================== + +static int FindGFXFile(FString & fn) +{ + int lump = Wads.CheckNumForFullName(fn); // if we find something that matches the name plus the extension, return it and do not enter the substitution logic below. + if (lump != -1) return lump; + + 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", nullptr }; + + for (const char ** extp=extensions; *extp; extp++) + { + int lump = Wads.CheckNumForFullName(fn + *extp); + if (lump >= best) best = lump; + } + return best; +} + + +//=========================================================================== +// +// LoadSkin +// +//=========================================================================== + +FTextureID LoadSkin(const char * path, const char * fn) +{ + FString buffer; + + buffer.Format("%s%s", path, fn); + + int texlump = FindGFXFile(buffer); + if (texlump>=0) + { + return TexMan.CheckForTexture(Wads.GetLumpFullName(texlump), FTexture::TEX_Any, FTextureManager::TEXMAN_TryAny); + } + else + { + return FNullTextureID(); + } +} + +//=========================================================================== +// +// ModelFrameHash +// +//=========================================================================== + +static int ModelFrameHash(FSpriteModelFrame * smf) +{ + const uint32_t *table = GetCRCTable (); + uint32_t 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 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 != nullptr) + { + if (!model->Load(path, lump, buffer, len)) + { + delete model; + return -1; + } + } + else + { + // try loading as a voxel + FVoxel *voxel = R_LoadKVX(lump); + if (voxel != nullptr) + { + model = new FVoxelModel(voxel, true); + } + else + { + Printf("LoadModel: Unknown model format in '%s'\n", fullname.GetChars()); + return -1; + } + } + // The vertex buffer cannot be initialized here because this gets called before OpenGL is initialized + model->mFileName = fullname; + return Models.Push(model); +} + +//=========================================================================== +// +// gl_InitModels +// +//=========================================================================== + +void gl_InitModels() +{ + int Lump, lastLump; + FString path; + int index, surface; + 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.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1; + smf.modelIDs[0] = VoxelDefs[i]->Voxel->VoxelIndex; + smf.skinIDs[0] = md->GetPaletteTexture(); + smf.xscale = smf.yscale = smf.zscale = VoxelDefs[i]->Scale; + smf.angleoffset = VoxelDefs[i]->AngleOffset.Degrees; + 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)); + smf.modelIDs[0] = smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1; + while ((Lump = Wads.FindLump("MODELDEF", &lastLump)) != -1) + { + FScanner sc(Lump); + while (sc.GetString()) + { + if (sc.Compare("model")) + { + path = ""; + sc.MustGetString(); + memset(&smf, 0, sizeof(smf)); + smf.modelIDs[1] = smf.modelIDs[2] = smf.modelIDs[3] = -1; + smf.xscale=smf.yscale=smf.zscale=1.f; + + smf.type = PClass::FindClass(sc.String); + if (!smf.type || smf.type->Defaults == nullptr) + { + sc.ScriptError("MODELDEF: Unknown actor type '%s'\n", sc.String); + } + 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.modelIDs[index] = FindModel(path.GetChars(), sc.String); + if (smf.modelIDs[index] == -1) + { + 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 = 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_USEACTORPITCH | MDL_BADROTATION; + } + else if (sc.Compare("inheritactorroll")) + { + smf.flags |= MDL_USEACTORROLL; + } + else if (sc.Compare("useactorpitch")) + { + smf.flags |= MDL_USEACTORPITCH; + } + else if (sc.Compare("useactorroll")) + { + smf.flags |= MDL_USEACTORROLL; + } + 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.skinIDs[index]=FNullTextureID(); + } + else + { + smf.skinIDs[index] = LoadSkin(path.GetChars(), sc.String); + if (!smf.skinIDs[index].isValid()) + { + Printf("Skin '%s' not found in '%s'\n", + sc.String, smf.type->TypeName.GetChars()); + } + } + } + else if (sc.Compare("surfaceskin")) + { + sc.MustGetNumber(); + index = sc.Number; + sc.MustGetNumber(); + surface = sc.Number; + + if (index<0 || index >= MAX_MODELS_PER_FRAME) + { + sc.ScriptError("Too many models in %s", smf.type->TypeName.GetChars()); + } + + if (surface<0 || surface >= MD3_MAX_SURFACES) + { + sc.ScriptError("Invalid MD3 Surface %d in %s", MD3_MAX_SURFACES, smf.type->TypeName.GetChars()); + } + + sc.MustGetString(); + FixPathSeperator(sc.String); + if (sc.Compare("")) + { + smf.surfaceskinIDs[index][surface] = FNullTextureID(); + } + else + { + smf.surfaceskinIDs[index][surface] = LoadSkin(path.GetChars(), sc.String); + if (!smf.surfaceskinIDs[index][surface].isValid()) + { + Printf("Surface 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.modelIDs[index] != -1) + { + FModel *model = Models[smf.modelIDs[index]]; + smf.modelframes[index] = model->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); + GetDefaultByType(smf.type)->hasmodel = true; + 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 != nullptr) + { + int index = sprframe->Voxel->VoxeldefIndex; + if (dropped && sprframe->Voxel->DroppedSpin !=sprframe->Voxel->PlacedSpin) index++; + return &SpriteModelFrames[index]; + } + } + } + return nullptr; +} + + +//=========================================================================== +// +// 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 = nullptr; + 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; imodelIDs[i] != -1) + { + FModel * mdl = Models[smf->modelIDs[i]]; + FTexture *tex = smf->skinIDs[i].isValid()? TexMan(smf->skinIDs[i]) : nullptr; + mdl->BuildVertexBuffer(); + gl_RenderState.SetVertexBuffer(mdl->mVBuf); + + mdl->PushSpriteMDLFrame(smf, i); + + if ( smfNext && smf->modelframes[i] != smfNext->modelframes[i] ) + mdl->RenderFrame(tex, smf->modelframes[i], smfNext->modelframes[i], inter, translation); + else + mdl->RenderFrame(tex, 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 = spr->actor->Scale.X * smf->xscale; + float scaleFactorY = spr->actor->Scale.X * smf->yscale; + float scaleFactorZ = spr->actor->Scale.Y * smf->zscale; + float pitch = 0; + float roll = 0; + float rotateOffset = 0; + float angle = spr->actor->Angles.Yaw.Degrees; + + // [BB] Workaround for the missing pitch information. + if ( (smf->flags & MDL_PITCHFROMMOMENTUM) ) + { + const double x = spr->actor->Vel.X; + const double y = spr->actor->Vel.Y; + const double z = spr->actor->Vel.Z; + + if (spr->actor->Vel.LengthSquared() > EQUAL_EPSILON) + { + // [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 (fabs(x) > EQUAL_EPSILON || fabs(y) > EQUAL_EPSILON) + { + 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_USEACTORPITCH and MDL_USEACTORROLL flags processing. + // If both flags MDL_USEACTORPITCH and MDL_PITCHFROMMOMENTUM are set, the pitch sums up the actor pitch and the momentum vector pitch. + if (smf->flags & MDL_USEACTORPITCH) + { + double d = spr->actor->Angles.Pitch.Degrees; + if (smf->flags & MDL_BADROTATION) pitch -= d; + else pitch += d; + } + if(smf->flags & MDL_USEACTORROLL) roll += spr->actor->Angles.Roll.Degrees; + + 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(-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->modelIDs[0] != -1 ? Models[smf->modelIDs[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, spr->actor->GetClass(), nullptr, translation ); + gl_RenderState.EnableModelMatrix(false); + + glDepthFunc(GL_LESS); + if (!( spr->actor->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) + glDisable(GL_CULL_FACE); +} + + +//=========================================================================== +// +// gl_RenderHUDModel +// +//=========================================================================== + +void gl_RenderHUDModel(DPSprite *psp, float ofsX, float ofsY) +{ + AActor * playermo=players[consoleplayer].camera; + FSpriteModelFrame *smf = gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false); + + // [BB] No model found for this sprite, so we can't render anything. + if ( smf == nullptr ) + 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(ofsX/4, 0, 1, 0); + gl_RenderState.mViewMatrix.rotate((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(-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->GetState(), psp->GetTics(), playermo->player->ReadyWeapon->GetClass(), nullptr, 0 ); + + glDepthFunc(GL_LESS); + if (!( playermo->RenderStyle == LegacyRenderStyles[STYLE_Normal] )) + glDisable(GL_CULL_FACE); +} + +//=========================================================================== +// +// gl_IsHUDModelForPlayerAvailable +// +//=========================================================================== + +bool gl_IsHUDModelForPlayerAvailable (player_t * player) +{ + if (player == nullptr || player->ReadyWeapon == nullptr) + return false; + + DPSprite *psp = player->FindPSprite(PSP_WEAPON); + + if (psp == nullptr || psp->GetState() == nullptr) + return false; + + FState* state = psp->GetState(); + FSpriteModelFrame *smf = gl_FindModelFrame(player->ReadyWeapon->GetClass(), state->sprite, state->GetFrame(), false); + return ( smf != nullptr ); +} + diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h new file mode 100644 index 000000000..463f81138 --- /dev/null +++ b/src/gl/models/gl_models.h @@ -0,0 +1,403 @@ +#ifndef __GL_MODELS_H_ +#define __GL_MODELS_H_ + +#include "tarray.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 +#define MD3_MAX_SURFACES 32 + +FTextureID LoadSkin(const char * path, const char * fn); + +// [JM] Necessary forward declaration +typedef struct FSpriteModelFrame FSpriteModelFrame; + +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; + virtual void AddSkins(BYTE *hitlist) = 0; + void DestroyVertexBuffer() + { + delete mVBuf; + mVBuf = NULL; + } + virtual float getAspectFactor() { return 1.f; } + + const FSpriteModelFrame *curSpriteMDLFrame; + int curMDLIndex; + void PushSpriteMDLFrame(const FSpriteModelFrame *smf, int index) { curSpriteMDLFrame = smf; curMDLIndex = index; }; + + 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; + FTextureID * 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(); + virtual void AddSkins(BYTE *hitlist); + + 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; + + FTextureID * 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(); + virtual void AddSkins(BYTE *hitlist); +}; + +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 + FTextureID 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); + virtual void AddSkins(BYTE *hitlist); + FTextureID 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_USEACTORPITCH = 32, + MDL_USEACTORROLL = 64, + MDL_BADROTATION = 128, +}; + +struct FSpriteModelFrame +{ + int modelIDs[MAX_MODELS_PER_FRAME]; + FTextureID skinIDs[MAX_MODELS_PER_FRAME]; + FTextureID surfaceskinIDs[MAX_MODELS_PER_FRAME][MD3_MAX_SURFACES]; + 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; + float 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(DPSprite *psp, float ofsx, float ofsy); +bool gl_IsHUDModelForPlayerAvailable (player_t * player); + + +class DeletingModelArray : public TArray +{ +public: + + ~DeletingModelArray() + { + for (unsigned i = 0; i> 9) / 127.0f - 0.5f) * M_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 FTextureID[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(); + } +} + +//=========================================================================== +// +// for skin precaching +// +//=========================================================================== + +void FDMDModel::AddSkins(BYTE *hitlist) +{ + for (int i = 0; i < info.numSkins; i++) + { + if (skins[i].isValid()) + { + hitlist[skins[i].GetIndex()] |= FTexture::TEX_Flat; + } + } +} + +//=========================================================================== +// +// 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 || !skins[0].isValid()) return; + skin = TexMan(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, lodInfo[0].numTriangles * 3); + 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 FTextureID[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..b9c0a120a --- /dev/null +++ b/src/gl/models/gl_models_md3.cpp @@ -0,0 +1,408 @@ +/* +** 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 *= M_PI/128; + lng *= M_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 +{ + uint32_t Magic; + uint32_t Version; + char Name[MAX_QPATH]; + uint32_t Flags; + uint32_t Num_Frames; + uint32_t Num_Tags; + uint32_t Num_Surfaces; + uint32_t Num_Skins; + uint32_t Ofs_Frames; + uint32_t Ofs_Tags; + uint32_t Ofs_Surfaces; + uint32_t Ofs_Eof; +}; + +struct md3_surface_t +{ + uint32_t Magic; + char Name[MAX_QPATH]; + uint32_t Flags; + uint32_t Num_Frames; + uint32_t Num_Shaders; + uint32_t Num_Verts; + uint32_t Num_Triangles; + uint32_t Ofs_Triangles; + uint32_t Ofs_Shaders; + uint32_t Ofs_Texcoord; + uint32_t Ofs_XYZNormal; + uint32_t Ofs_End; +}; + +struct md3_triangle_t +{ + uint32_t vt_index[3]; +}; + +struct md3_shader_t +{ + char Name[MAX_QPATH]; + uint32_t 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 FTextureID[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].isValid()) + 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 == nullptr) + { + 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, numFrames == 1); + FModelVertex *vertptr = mVBuf->LockVertexBuffer(vbufsize); + unsigned int *indxptr = mVBuf->LockIndexBuffer(ibufsize); + + assert(vertptr != nullptr && indxptr != nullptr); + + 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(); + } +} + + +//=========================================================================== +// +// for skin precaching +// +//=========================================================================== + +void FMD3Model::AddSkins(BYTE *hitlist) +{ + for (int i = 0; i < numSurfaces; i++) + { + if (curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid()) + { + hitlist[curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].GetIndex()] |= FTexture::TEX_Flat; + } + + MD3Surface * surf = &surfaces[i]; + for (int j = 0; j < surf->numSkins; j++) + { + if (surf->skins[j].isValid()) + { + hitlist[surf->skins[j].GetIndex()] |= FTexture::TEX_Flat; + } + } + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +int FMD3Model::FindFrame(const char * name) +{ + for (int i=0;i=numFrames || frameno2>=numFrames) return; + + gl_RenderState.SetInterpolationFactor((float)inter); + for(int i=0;isurfaceskinIDs[curMDLIndex][i].isValid()) + { + surfaceSkin = TexMan(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i]); + } + else if(surf->numSkins > 0 && surf->skins[0].isValid()) + { + surfaceSkin = TexMan(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, 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 = nullptr; + surfaces = nullptr; +} diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp new file mode 100644 index 000000000..ec7f0573b --- /dev/null +++ b/src/gl/models/gl_voxels.cpp @@ -0,0 +1,459 @@ +/* +** 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 = TexMan.AddTexture(new FVoxelTexture(voxel)); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +FVoxelModel::~FVoxelModel() +{ + 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].Pivot.X; + float PivotY = mVoxel->Mips[0].Pivot.Y; + float PivotZ = mVoxel->Mips[0].Pivot.Z; + 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, 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(); + } +} + + +//=========================================================================== +// +// for skin precaching +// +//=========================================================================== + +void FVoxelModel::AddSkins(BYTE *hitlist) +{ + hitlist[mPalette.GetIndex()] |= FTexture::TEX_Flat; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +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, 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_2ddrawer.cpp b/src/gl/renderer/gl_2ddrawer.cpp new file mode 100644 index 000000000..ac7d35397 --- /dev/null +++ b/src/gl/renderer/gl_2ddrawer.cpp @@ -0,0 +1,499 @@ +/* +** gl_2ddrawer.h +** Container class for drawing 2d graphics with a vertex buffer +** +**--------------------------------------------------------------------------- +** Copyright 2016 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_framebuffer.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_2ddrawer.h" +#include "gl/textures/gl_material.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/scene/gl_drawinfo.h" +#include "gl/textures/gl_translate.h" +#include "vectors.h" + +//========================================================================== +// +// +// +//========================================================================== + +int F2DDrawer::AddData(const F2DDrawer::DataGeneric *data) +{ + int addr = mData.Reserve(data->mLen); + memcpy(&mData[addr], data, data->mLen); + mLastLineCmd = -1; + return addr; +} + +//========================================================================== +// +// Draws a texture +// +//========================================================================== + +void F2DDrawer::AddTexture(FTexture *img, 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 (gltex == nullptr) return; + + DataTexture dg; + + dg.mType = DrawTypeTexture; + dg.mLen = (sizeof(dg) + 7) & ~7; + dg.mVertCount = 4; + dg.mRenderStyle = parms.style; + dg.mMasked = !!parms.masked; + dg.mTexture = gltex; + + if (parms.colorOverlay && (parms.colorOverlay & 0xffffff) == 0) + { + // handle black overlays as reduced light. + light = 255 - APART(parms.colorOverlay); + parms.colorOverlay = 0; + } + dg.mVertIndex = (int)mVertices.Reserve(parms.colorOverlay == 0? 4 : 8); + dg.mColorOverlay = parms.colorOverlay; + dg.mTranslation = 0; + + if (!img->bHasCanvas) + { + if (!parms.alphaChannel) + { + if (parms.remap != NULL && !parms.remap->Inactive) + { + GLTranslationPalette * pal = static_cast(parms.remap->GetNative()); + if (pal) dg.mTranslation = -pal->GetIndex(); + } + } + dg.mAlphaTexture = !!(parms.style.Flags & STYLEF_RedIsAlpha); + u1 = gltex->GetUL(); + v1 = gltex->GetVT(); + u2 = gltex->GetUR(); + v2 = gltex->GetVB(); + + } + else + { + dg.mAlphaTexture = false; + u1 = 0.f; + v1 = 1.f; + u2 = 1.f; + v2 = 0.f; + } + + if (parms.flipX) + std::swap(u1, u2); + + + if (parms.windowleft > 0 || parms.windowright < parms.texwidth) + { + double wi = MIN(parms.windowright, parms.texwidth); + x += parms.windowleft * xscale; + w -= (parms.texwidth - wi + parms.windowleft) * xscale; + + u1 = float(u1 + parms.windowleft / parms.texwidth); + u2 = float(u2 - (parms.texwidth - wi) / parms.texwidth); + } + + PalEntry color; + if (parms.style.Flags & STYLEF_ColorIsFixed) + { + color = parms.fillcolor; + std::swap(color.r, color.b); + } + else + { + color = PalEntry(light, light, light); + } + color.a = (BYTE)(parms.Alpha * 255); + + // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates + dg.mScissor[0] = GLRenderer->ScreenToWindowX(parms.lclip); + dg.mScissor[1] = GLRenderer->ScreenToWindowY(parms.dclip); + dg.mScissor[2] = GLRenderer->ScreenToWindowX(parms.rclip) - dg.mScissor[0]; + dg.mScissor[3] = GLRenderer->ScreenToWindowY(parms.uclip) - dg.mScissor[1]; + + FSimpleVertex *ptr = &mVertices[dg.mVertIndex]; + ptr->Set(x, y, 0, u1, v1, color); ptr++; + ptr->Set(x, y + h, 0, u1, v2, color); ptr++; + ptr->Set(x + w, y, 0, u2, v1, color); ptr++; + ptr->Set(x + w, y + h, 0, u2, v2, color); ptr++; + if (parms.colorOverlay != 0) + { + color = parms.colorOverlay; + std::swap(color.r, color.b); + ptr->Set(x, y, 0, u1, v1, color); ptr++; + ptr->Set(x, y + h, 0, u1, v2, color); ptr++; + ptr->Set(x + w, y, 0, u2, v1, color); ptr++; + ptr->Set(x + w, y + h, 0, u2, v2, color); ptr++; + } + AddData(&dg); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::AddPoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + DAngle rotation, FDynamicColormap *colormap, int lightlevel) +{ + FMaterial *gltexture = FMaterial::ValidateTexture(texture, false); + + if (gltexture == nullptr) + { + return; + } + DataSimplePoly poly; + + poly.mType = DrawTypePoly; + poly.mLen = (sizeof(poly) + 7) & ~7; + poly.mTexture = gltexture; + poly.mColormap = colormap; + poly.mLightLevel = lightlevel; + poly.mVertCount = npoints; + poly.mVertIndex = (int)mVertices.Reserve(npoints); + + bool dorotate = rotation != 0; + + float cosrot = cos(rotation.Radians()); + float sinrot = sin(rotation.Radians()); + + float uscale = float(1.f / (texture->GetScaledWidth() * scalex)); + float vscale = float(1.f / (texture->GetScaledHeight() * scaley)); + if (texture->bHasCanvas) + { + vscale = 0 - vscale; + } + float ox = float(originx); + float oy = float(originy); + + for (int 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; + } + mVertices[poly.mVertIndex+i].Set(points[i].X, points[i].Y, 0, u*uscale, v*vscale); + } + AddData(&poly); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void F2DDrawer::AddDim(PalEntry color, float damount, int x1, int y1, int w, int h) +{ + color.a = uint8_t(damount * 255); + std::swap(color.r, color.b); + + DataGeneric dg; + + dg.mType = DrawTypeDim; + dg.mLen = (sizeof(dg) + 7) & ~7; + dg.mVertCount = 4; + dg.mVertIndex = (int)mVertices.Reserve(4); + FSimpleVertex *ptr = &mVertices[dg.mVertIndex]; + ptr->Set(x1, y1, 0, 0, 0, color); ptr++; + ptr->Set(x1, y1 + h, 0, 0, 0, color); ptr++; + ptr->Set(x1 + w, y1 + h, 0, 0, 0, color); ptr++; + ptr->Set(x1 + w, y1, 0, 0, 0, color); ptr++; + AddData(&dg); +} + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::AddClear(int left, int top, int right, int bottom, int palcolor, uint32 color) +{ + PalEntry p = palcolor == -1 || color != 0 ? (PalEntry)color : GPalette.BaseColors[palcolor]; + AddDim(p, 1.f, left, top, right - left, bottom - top); +} + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::AddFlatFill(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; + + DataFlatFill dg; + + dg.mType = DrawTypeFlatFill; + dg.mLen = (sizeof(dg) + 7) & ~7; + dg.mVertCount = 4; + dg.mVertIndex = (int)mVertices.Reserve(4); + dg.mTexture = gltexture; + + // 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(); + } + FSimpleVertex *ptr = &mVertices[dg.mVertIndex]; + 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++; + AddData(&dg); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::AddLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color) +{ + PalEntry p = color ? (PalEntry)color : GPalette.BaseColors[palcolor]; + p.a = 255; + std::swap(p.r, p.b); + + DataGeneric dg; + + dg.mType = DrawTypeLine; + dg.mLen = (sizeof(dg) + 7) & ~7; + dg.mVertCount = 2; + dg.mVertIndex = (int)mVertices.Reserve(2); + mVertices[dg.mVertIndex].Set(x1, y1, 0, 0, 0, p); + mVertices[dg.mVertIndex+1].Set(x2, y2, 0, 0, 0, p); + + // Test if we can batch multiple line commands + if (mLastLineCmd == -1) + { + mLastLineCmd = AddData(&dg); + } + else + { + DataGeneric *dg = (DataGeneric *)&mData[mLastLineCmd]; + dg->mVertCount += 2; + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::AddPixel(int x1, int y1, int palcolor, uint32 color) +{ + PalEntry p = color ? (PalEntry)color : GPalette.BaseColors[palcolor]; + p.a = 255; + std::swap(p.r, p.b); + + DataGeneric dg; + + dg.mType = DrawTypePixel; + dg.mLen = (sizeof(dg) + 7) & ~7; + dg.mVertCount = 2; + dg.mVertIndex = (int)mVertices.Reserve(1); + mVertices[dg.mVertIndex].Set(x1, y1, 0, 0, 0, p); + AddData(&dg); +} + + +//========================================================================== +// +// +// +//========================================================================== + +void F2DDrawer::Flush() +{ + F2DDrawer::EDrawType lasttype = DrawTypeTexture; + + if (mData.Size() == 0) return; + SBYTE savedlightmode = glset.lightmode; + // lightmode is only relevant for automap subsectors, + // but We cannot use the software light mode here because it doesn't properly calculate the light for 2D rendering. + if (glset.lightmode == 8) glset.lightmode = 0; + + set(&mVertices[0], mVertices.Size()); + for (unsigned i = 0; i < mData.Size();) + { + DataGeneric *dg = (DataGeneric *)&mData[i]; + // DrawTypePoly may not use the color part of the vertex buffer because it needs to use gl_SetColor to produce proper output. + if (lasttype == DrawTypePoly && dg->mType != DrawTypePoly) + { + gl_RenderState.ResetColor(); // this is needed to reset the desaturation. + EnableColorArray(true); + } + else if (lasttype != DrawTypePoly && dg->mType == DrawTypePoly) + { + EnableColorArray(false); + } + lasttype = dg->mType; + + switch (dg->mType) + { + default: + break; + + case DrawTypeTexture: + { + DataTexture *dt = static_cast(dg); + + gl_SetRenderStyle(dt->mRenderStyle, !dt->mMasked, false); + gl_RenderState.SetMaterial(dt->mTexture, CLAMP_XY_NOMIP, dt->mTranslation, -1, dt->mAlphaTexture); + if (dt->mTexture->tex->bHasCanvas) gl_RenderState.SetTextureMode(TM_OPAQUE); + + glEnable(GL_SCISSOR_TEST); + glScissor(dt->mScissor[0], dt->mScissor[1], dt->mScissor[2], dt->mScissor[3]); + + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.Apply(); + + glDrawArrays(GL_TRIANGLE_STRIP, dt->mVertIndex, 4); + + gl_RenderState.BlendEquation(GL_FUNC_ADD); + if (dt->mVertCount > 4) + { + gl_RenderState.SetTextureMode(TM_MASK); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_STRIP, dt->mVertIndex + 4, 4); + } + + const auto &viewport = GLRenderer->mScreenViewport; + glScissor(viewport.left, viewport.top, viewport.width, viewport.height); + glDisable(GL_SCISSOR_TEST); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.SetTextureMode(TM_MODULATE); + break; + } + + case DrawTypePoly: + { + DataSimplePoly *dsp = static_cast(dg); + + FColormap cm; + cm = dsp->mColormap; + gl_SetColor(dsp->mLightLevel, 0, cm, 1.f); + gl_RenderState.SetMaterial(dsp->mTexture, CLAMP_NONE, 0, -1, false); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_FAN, dsp->mVertIndex, dsp->mVertCount); + break; + } + + case DrawTypeFlatFill: + { + DataFlatFill *dff = static_cast(dg); + gl_RenderState.SetMaterial(dff->mTexture, CLAMP_NONE, 0, -1, false); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_STRIP, dg->mVertIndex, dg->mVertCount); + break; + } + + case DrawTypeDim: + gl_RenderState.EnableTexture(false); + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.AlphaFunc(GL_GREATER, 0); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_FAN, dg->mVertIndex, dg->mVertCount); + gl_RenderState.EnableTexture(true); + break; + + case DrawTypeLine: + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(); + glDrawArrays(GL_LINES, dg->mVertIndex, dg->mVertCount); + gl_RenderState.EnableTexture(true); + break; + + case DrawTypePixel: + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(); + glDrawArrays(GL_POINTS, dg->mVertIndex, dg->mVertCount); + gl_RenderState.EnableTexture(true); + break; + + } + i += dg->mLen; + } + mVertices.Clear(); + mData.Clear(); + gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); + glset.lightmode = savedlightmode; +} + + diff --git a/src/gl/renderer/gl_2ddrawer.h b/src/gl/renderer/gl_2ddrawer.h new file mode 100644 index 000000000..32d2ad1f5 --- /dev/null +++ b/src/gl/renderer/gl_2ddrawer.h @@ -0,0 +1,73 @@ +#ifndef __2DDRAWER_H +#define __2DDRAWER_H + +#include "tarray.h" +#include "gl/data/gl_vertexbuffer.h" + +class F2DDrawer : public FSimpleVertexBuffer +{ + enum EDrawType + { + DrawTypeTexture, + DrawTypeDim, + DrawTypeFlatFill, + DrawTypePoly, + DrawTypeLine, + DrawTypePixel + }; + + struct DataGeneric + { + EDrawType mType; + uint32_t mLen; + int mVertIndex; + int mVertCount; + }; + + struct DataTexture : public DataGeneric + { + FMaterial *mTexture; + int mScissor[4]; + uint32_t mColorOverlay; + int mTranslation; + FRenderStyle mRenderStyle; + bool mMasked; + bool mAlphaTexture; + }; + + struct DataFlatFill : public DataGeneric + { + FMaterial *mTexture; + }; + + struct DataSimplePoly : public DataGeneric + { + FMaterial *mTexture; + int mLightLevel; + FDynamicColormap *mColormap; + }; + + TArray mVertices; + TArray mData; + int mLastLineCmd = -1; // consecutive lines can be batched into a single draw call so keep this info around. + + int AddData(const DataGeneric *data); + +public: + void AddTexture(FTexture *img, DrawParms &parms); + void AddDim(PalEntry color, float damount, int x1, int y1, int w, int h); + void AddClear(int left, int top, int right, int bottom, int palcolor, uint32 color); + void AddFlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin); + + void AddPoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + DAngle rotation, FDynamicColormap *colormap, int lightlevel); + + void AddLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color); + void AddPixel(int x1, int y1, int palcolor, uint32 color); + + void Flush(); +}; + + +#endif diff --git a/src/gl/renderer/gl_colormap.h b/src/gl/renderer/gl_colormap.h new file mode 100644 index 000000000..2122b1248 --- /dev/null +++ b/src/gl/renderer/gl_colormap.h @@ -0,0 +1,79 @@ +#ifndef __GL_COLORMAP +#define __GL_COLORMAP + +#include "doomtype.h" +#include "v_palette.h" +#include "r_data/colormaps.h" + +extern DWORD gl_fixedcolormap; + +struct lightlist_t; + +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 CopyFrom3DLight(lightlist_t *light); + + 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..c2329879c --- /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 != nullptr && GLRenderer->mShaderManager != nullptr) + { + 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..4cc7a7d04 --- /dev/null +++ b/src/gl/renderer/gl_lightdata.h @@ -0,0 +1,64 @@ +#ifndef __GL_LIGHTDATA +#define __GL_LIGHTDATA + +#include "v_palette.h" +#include "p_3dfloors.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; + + +inline void FColormap::CopyFrom3DLight(lightlist_t *light) +{ + LightColor = light->extra_colormap->Color; + desaturation = light->extra_colormap->Desaturate; + blendfactor = light->extra_colormap->Color.a; + if (light->caster && (light->caster->flags&FF_FADEWALLS) && (light->extra_colormap->Fade & 0xffffff) != 0) + FadeColor = light->extra_colormap->Fade; +} + + + +#endif \ No newline at end of file diff --git a/src/gl/renderer/gl_postprocess.cpp b/src/gl/renderer/gl_postprocess.cpp new file mode 100644 index 000000000..d7eac8007 --- /dev/null +++ b/src/gl/renderer/gl_postprocess.cpp @@ -0,0 +1,511 @@ +/* +** gl_postprocess.cpp +** Post processing effects in the render pipeline +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** 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 "colormatcher.h" +#include "gl/gl_functions.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/system/gl_debug.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderbuffers.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_postprocessstate.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/shaders/gl_bloomshader.h" +#include "gl/shaders/gl_blurshader.h" +#include "gl/shaders/gl_tonemapshader.h" +#include "gl/shaders/gl_colormapshader.h" +#include "gl/shaders/gl_lensshader.h" +#include "gl/shaders/gl_presentshader.h" +#include "gl/renderer/gl_2ddrawer.h" + +//========================================================================== +// +// CVARs +// +//========================================================================== +CVAR(Bool, gl_bloom, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CUSTOM_CVAR(Float, gl_bloom_amount, 1.4f, 0) +{ + if (self < 0.1f) self = 0.1f; +} + +CVAR(Float, gl_exposure, 0.0f, 0) + +CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +{ + if (self < 0 || self > 5) + self = 0; +} + +CUSTOM_CVAR(Int, gl_bloom_kernel_size, 7, 0) +{ + if (self < 3 || self > 15 || self % 2 == 0) + self = 7; +} + +CVAR(Bool, gl_lens, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) + +CVAR(Float, gl_lens_k, -0.12f, 0) +CVAR(Float, gl_lens_kcube, 0.1f, 0) +CVAR(Float, gl_lens_chromatic, 1.12f, 0) + +EXTERN_CVAR(Float, vid_brightness) +EXTERN_CVAR(Float, vid_contrast) + + +void FGLRenderer::RenderScreenQuad() +{ + mVBO->BindVBO(); + gl_RenderState.ResetVertexBuffer(); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4); +} + +//----------------------------------------------------------------------------- +// +// Adds bloom contribution to scene texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::BloomScene() +{ + // Only bloom things if enabled and no special fixed light mode is active + if (!gl_bloom || gl_fixedcolormap != CM_DEFAULT) + return; + + FGLDebug::PushGroup("BloomScene"); + + FGLPostProcessState savedState; + + const float blurAmount = gl_bloom_amount; + int sampleCount = gl_bloom_kernel_size; + + const auto &level0 = mBuffers->BloomLevels[0]; + + // Extract blooming pixels from scene texture: + glBindFramebuffer(GL_FRAMEBUFFER, level0.VFramebuffer); + glViewport(0, 0, level0.Width, level0.Height); + mBuffers->BindCurrentTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomExtractShader->Bind(); + mBloomExtractShader->SceneTexture.Set(0); + mBloomExtractShader->Exposure.Set(mCameraExposure); + mBloomExtractShader->Scale.Set(mSceneViewport.width / (float)mScreenViewport.width, mSceneViewport.height / (float)mScreenViewport.height); + mBloomExtractShader->Offset.Set(mSceneViewport.left / (float)mScreenViewport.width, mSceneViewport.top / (float)mScreenViewport.height); + RenderScreenQuad(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + // Blur and downscale: + for (int i = 0; i < FGLRenderBuffers::NumBloomLevels - 1; i++) + { + const auto &level = mBuffers->BloomLevels[i]; + const auto &next = mBuffers->BloomLevels[i + 1]; + mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(this, blurAmount, sampleCount, level.HTexture, next.VFramebuffer, next.Width, next.Height); + } + + // Blur and upscale: + for (int i = FGLRenderBuffers::NumBloomLevels - 1; i > 0; i--) + { + const auto &level = mBuffers->BloomLevels[i]; + const auto &next = mBuffers->BloomLevels[i - 1]; + + mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level.VTexture, level.HFramebuffer, level.Width, level.Height); + mBlurShader->BlurVertical(this, blurAmount, sampleCount, level.HTexture, level.VFramebuffer, level.Width, level.Height); + + // Linear upscale: + glBindFramebuffer(GL_FRAMEBUFFER, next.VFramebuffer); + glViewport(0, 0, next.Width, next.Height); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, level.VTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomCombineShader->Bind(); + mBloomCombineShader->BloomTexture.Set(0); + RenderScreenQuad(); + } + + mBlurShader->BlurHorizontal(this, blurAmount, sampleCount, level0.VTexture, level0.HFramebuffer, level0.Width, level0.Height); + mBlurShader->BlurVertical(this, blurAmount, sampleCount, level0.HTexture, level0.VFramebuffer, level0.Width, level0.Height); + + // Add bloom back to scene texture: + mBuffers->BindCurrentFB(); + glViewport(mSceneViewport.left, mSceneViewport.top, mSceneViewport.width, mSceneViewport.height); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_ONE, GL_ONE); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, level0.VTexture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mBloomCombineShader->Bind(); + mBloomCombineShader->BloomTexture.Set(0); + RenderScreenQuad(); + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + + FGLDebug::PopGroup(); +} + +//----------------------------------------------------------------------------- +// +// Tonemap scene texture and place the result in the HUD/2D texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::TonemapScene() +{ + if (gl_tonemap == 0) + return; + + FGLDebug::PushGroup("TonemapScene"); + + FGLPostProcessState savedState; + + mBuffers->BindNextFB(); + mBuffers->BindCurrentTexture(0); + mTonemapShader->Bind(); + mTonemapShader->SceneTexture.Set(0); + + if (mTonemapShader->IsPaletteMode()) + { + mTonemapShader->PaletteLUT.Set(1); + BindTonemapPalette(1); + } + else + { + mTonemapShader->Exposure.Set(mCameraExposure); + } + + RenderScreenQuad(); + mBuffers->NextTexture(); + + FGLDebug::PopGroup(); +} + +void FGLRenderer::BindTonemapPalette(int texunit) +{ + if (mTonemapPalette) + { + mTonemapPalette->Bind(texunit, 0, false); + } + else + { + TArray lut; + lut.Resize(512 * 512 * 4); + for (int r = 0; r < 64; r++) + { + for (int g = 0; g < 64; g++) + { + for (int b = 0; b < 64; b++) + { + PalEntry color = GPalette.BaseColors[(BYTE)PTM_BestColor((uint32 *)GPalette.BaseColors, (r << 2) | (r >> 4), (g << 2) | (g >> 4), (b << 2) | (b >> 4), 0, 256)]; + int index = ((r * 64 + g) * 64 + b) * 4; + lut[index] = color.r; + lut[index + 1] = color.g; + lut[index + 2] = color.b; + lut[index + 3] = 255; + } + } + } + + mTonemapPalette = new FHardwareTexture(512, 512, true); + mTonemapPalette->CreateTexture(&lut[0], 512, 512, texunit, false, 0, "mTonemapPalette"); + + glActiveTexture(GL_TEXTURE0 + texunit); + 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); + glActiveTexture(GL_TEXTURE0); + } +} + +void FGLRenderer::ClearTonemapPalette() +{ + delete mTonemapPalette; + mTonemapPalette = nullptr; +} + +//----------------------------------------------------------------------------- +// +// Colormap scene texture and place the result in the HUD/2D texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::ColormapScene() +{ + if (gl_fixedcolormap < CM_FIRSTSPECIALCOLORMAP || gl_fixedcolormap >= CM_MAXCOLORMAP) + return; + + FGLDebug::PushGroup("ColormapScene"); + + FGLPostProcessState savedState; + + mBuffers->BindNextFB(); + mBuffers->BindCurrentTexture(0); + mColormapShader->Bind(); + + 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 }; + + mColormapShader->MapStart.Set(scm->ColorizeStart[0], scm->ColorizeStart[1], scm->ColorizeStart[2], 0.f); + mColormapShader->MapRange.Set(m); + + RenderScreenQuad(); + mBuffers->NextTexture(); + + FGLDebug::PopGroup(); +} + +//----------------------------------------------------------------------------- +// +// Apply lens distortion and place the result in the HUD/2D texture +// +//----------------------------------------------------------------------------- + +void FGLRenderer::LensDistortScene() +{ + if (gl_lens == 0) + return; + + FGLDebug::PushGroup("LensDistortScene"); + + float k[4] = + { + gl_lens_k, + gl_lens_k * gl_lens_chromatic, + gl_lens_k * gl_lens_chromatic * gl_lens_chromatic, + 0.0f + }; + float kcube[4] = + { + gl_lens_kcube, + gl_lens_kcube * gl_lens_chromatic, + gl_lens_kcube * gl_lens_chromatic * gl_lens_chromatic, + 0.0f + }; + + float aspect = mSceneViewport.width / mSceneViewport.height; + + // Scale factor to keep sampling within the input texture + float r2 = aspect * aspect * 0.25 + 0.25f; + float sqrt_r2 = sqrt(r2); + float f0 = 1.0f + MAX(r2 * (k[0] + kcube[0] * sqrt_r2), 0.0f); + float f2 = 1.0f + MAX(r2 * (k[2] + kcube[2] * sqrt_r2), 0.0f); + float f = MAX(f0, f2); + float scale = 1.0f / f; + + FGLPostProcessState savedState; + + mBuffers->BindNextFB(); + mBuffers->BindCurrentTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + mLensShader->Bind(); + mLensShader->InputTexture.Set(0); + mLensShader->AspectRatio.Set(aspect); + mLensShader->Scale.Set(scale); + mLensShader->LensDistortionCoefficient.Set(k); + mLensShader->CubicDistortionValue.Set(kcube); + RenderScreenQuad(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + mBuffers->NextTexture(); + + FGLDebug::PopGroup(); +} + +//----------------------------------------------------------------------------- +// +// Gamma correct while copying to frame buffer +// +//----------------------------------------------------------------------------- + +void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) +{ + m2DDrawer->Flush(); // draw all pending 2D stuff before copying the buffer + FGLDebug::PushGroup("CopyToBackbuffer"); + if (FGLRenderBuffers::IsEnabled()) + { + FGLPostProcessState savedState; + mBuffers->BindOutputFB(); + + GL_IRECT box; + if (bounds) + { + box = *bounds; + } + else + { + ClearBorders(); + box = mOutputLetterbox; + } + + // Present what was rendered: + glViewport(box.left, box.top, box.width, box.height); + + mPresentShader->Bind(); + mPresentShader->InputTexture.Set(0); + if (!applyGamma || framebuffer->IsHWGammaActive()) + { + mPresentShader->InvGamma.Set(1.0f); + mPresentShader->Contrast.Set(1.0f); + mPresentShader->Brightness.Set(0.0f); + } + else + { + mPresentShader->InvGamma.Set(1.0f / clamp(Gamma, 0.1f, 4.f)); + mPresentShader->Contrast.Set(clamp(vid_contrast, 0.1f, 3.f)); + mPresentShader->Brightness.Set(clamp(vid_brightness, -0.8f, 0.8f)); + } + mPresentShader->Scale.Set(mScreenViewport.width / (float)mBuffers->GetWidth(), mScreenViewport.height / (float)mBuffers->GetHeight()); + mBuffers->BindCurrentTexture(0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + RenderScreenQuad(); + } + else if (!bounds) + { + FGLPostProcessState savedState; + ClearBorders(); + } + FGLDebug::PopGroup(); +} + +//----------------------------------------------------------------------------- +// +// Fills the black bars around the screen letterbox +// +//----------------------------------------------------------------------------- + +void FGLRenderer::ClearBorders() +{ + const auto &box = mOutputLetterbox; + + int clientWidth = framebuffer->GetClientWidth(); + int clientHeight = framebuffer->GetClientHeight(); + if (clientWidth == 0 || clientHeight == 0) + return; + + glViewport(0, 0, clientWidth, clientHeight); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + glEnable(GL_SCISSOR_TEST); + if (box.top > 0) + { + glScissor(0, 0, clientWidth, box.top); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientHeight - box.top - box.height > 0) + { + glScissor(0, box.top + box.height, clientWidth, clientHeight - box.top - box.height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (box.left > 0) + { + glScissor(0, box.top, box.left, box.height); + glClear(GL_COLOR_BUFFER_BIT); + } + if (clientWidth - box.left - box.width > 0) + { + glScissor(box.left + box.width, box.top, clientWidth - box.left - box.width, box.height); + glClear(GL_COLOR_BUFFER_BIT); + } + glDisable(GL_SCISSOR_TEST); +} + + +// [SP] Re-implemented BestColor for more precision rather than speed. This function is only ever called once until the game palette is changed. + +int FGLRenderer::PTM_BestColor (const uint32 *pal_in, int r, int g, int b, int first, int num) +{ + const PalEntry *pal = (const PalEntry *)pal_in; + static double powtable[256]; + static bool firstTime = true; + + double fbestdist, fdist; + int bestcolor; + + if (firstTime) + { + firstTime = false; + for (int x = 0; x < 256; x++) powtable[x] = pow((double)x/255,1.2); + } + + for (int color = first; color < num; color++) + { + double x = powtable[abs(r-pal[color].r)]; + double y = powtable[abs(g-pal[color].g)]; + double z = powtable[abs(b-pal[color].b)]; + fdist = x + y + z; + if (color == first || fdist < fbestdist) + { + if (fdist == 0) + return color; + + fbestdist = fdist; + bestcolor = color; + } + } + return bestcolor; +} + diff --git a/src/gl/renderer/gl_postprocessstate.cpp b/src/gl/renderer/gl_postprocessstate.cpp new file mode 100644 index 000000000..05cca7f31 --- /dev/null +++ b/src/gl/renderer/gl_postprocessstate.cpp @@ -0,0 +1,133 @@ +/* +** gl_postprocessstate.cpp +** Render state maintenance +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** 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_postprocessstate.h" + +//----------------------------------------------------------------------------- +// +// Saves state modified by post processing shaders +// +//----------------------------------------------------------------------------- + +FGLPostProcessState::FGLPostProcessState() +{ + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); + glActiveTexture(GL_TEXTURE0); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + glBindTexture(GL_TEXTURE_2D, 0); + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding[0]); + glBindSampler(0, 0); + glActiveTexture(GL_TEXTURE0 + 1); + glGetIntegerv(GL_SAMPLER_BINDING, &samplerBinding[1]); + glBindSampler(1, 0); + glActiveTexture(GL_TEXTURE0); + } + + glGetBooleanv(GL_BLEND, &blendEnabled); + glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); + glGetBooleanv(GL_DEPTH_TEST, &depthEnabled); + glGetBooleanv(GL_MULTISAMPLE, &multisampleEnabled); + glGetIntegerv(GL_CURRENT_PROGRAM, ¤tProgram); + glGetIntegerv(GL_BLEND_EQUATION_RGB, &blendEquationRgb); + glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &blendEquationAlpha); + glGetIntegerv(GL_BLEND_SRC_RGB, &blendSrcRgb); + glGetIntegerv(GL_BLEND_SRC_ALPHA, &blendSrcAlpha); + glGetIntegerv(GL_BLEND_DST_RGB, &blendDestRgb); + glGetIntegerv(GL_BLEND_DST_ALPHA, &blendDestAlpha); + + glDisable(GL_MULTISAMPLE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_SCISSOR_TEST); + glDisable(GL_BLEND); +} + +//----------------------------------------------------------------------------- +// +// Restores state at the end of post processing +// +//----------------------------------------------------------------------------- + +FGLPostProcessState::~FGLPostProcessState() +{ + if (blendEnabled) + glEnable(GL_BLEND); + else + glDisable(GL_BLEND); + + if (scissorEnabled) + glEnable(GL_SCISSOR_TEST); + else + glDisable(GL_SCISSOR_TEST); + + if (depthEnabled) + glEnable(GL_DEPTH_TEST); + else + glDisable(GL_DEPTH_TEST); + + if (multisampleEnabled) + glEnable(GL_MULTISAMPLE); + else + glDisable(GL_MULTISAMPLE); + + glBlendEquationSeparate(blendEquationRgb, blendEquationAlpha); + glBlendFuncSeparate(blendSrcRgb, blendDestRgb, blendSrcAlpha, blendDestAlpha); + + glUseProgram(currentProgram); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, 0); + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + glBindSampler(0, samplerBinding[0]); + glBindSampler(1, samplerBinding[1]); + } + glBindTexture(GL_TEXTURE_2D, textureBinding); + glActiveTexture(activeTex); +} diff --git a/src/gl/renderer/gl_postprocessstate.h b/src/gl/renderer/gl_postprocessstate.h new file mode 100644 index 000000000..4f2ca81a1 --- /dev/null +++ b/src/gl/renderer/gl_postprocessstate.h @@ -0,0 +1,37 @@ +#ifndef __GL_POSTPROCESSSTATE_H +#define __GL_POSTPROCESSSTATE_H + +#include +#include "gl/system/gl_interface.h" +#include "gl/data/gl_data.h" +#include "gl/data/gl_matrix.h" +#include "c_cvars.h" +#include "r_defs.h" + +class FGLPostProcessState +{ +public: + FGLPostProcessState(); + ~FGLPostProcessState(); + +private: + FGLPostProcessState(const FGLPostProcessState &) = delete; + FGLPostProcessState &operator=(const FGLPostProcessState &) = delete; + + GLint activeTex; + GLint textureBinding; + GLint samplerBinding[2]; + GLboolean blendEnabled; + GLboolean scissorEnabled; + GLboolean depthEnabled; + GLboolean multisampleEnabled; + GLint currentProgram; + GLint blendEquationRgb; + GLint blendEquationAlpha; + GLint blendSrcRgb; + GLint blendSrcAlpha; + GLint blendDestRgb; + GLint blendDestAlpha; +}; + +#endif diff --git a/src/gl/renderer/gl_quaddrawer.cpp b/src/gl/renderer/gl_quaddrawer.cpp new file mode 100644 index 000000000..eedac12e5 --- /dev/null +++ b/src/gl/renderer/gl_quaddrawer.cpp @@ -0,0 +1,86 @@ +/* +** gl_quaddrawer.h +** +**--------------------------------------------------------------------------- +** Copyright 2016 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/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_quaddrawer.h" +#include "gl/data/gl_matrix.h" + +/* +** For handling of dynamically created quads when no persistently mapped +** buffer or client array is available (i.e. GL 3.x core profiles) +** +** In this situation the 4 vertices of a quad primitive are being passed +** as a matrix uniform because that is a lot faster than any kind of +** temporary buffer change. +*/ + +FFlatVertex FQuadDrawer::buffer[4]; + +//========================================================================== +// +// +// +//========================================================================== + +void FQuadDrawer::DoRender(int type) +{ + // When this gets called, the render state must already be applied so we can just + // send our vertices to the current shader. + float matV[16], matT[16]; + + for(int i=0;i<4;i++) + { + matV[i*4+0] = buffer[i].x; + matV[i*4+1] = buffer[i].z; + matV[i*4+2] = buffer[i].y; + matV[i*4+3] = 1; + matT[i*4+0] = buffer[i].u; + matT[i*4+1] = buffer[i].v; + matT[i*4+2] = matT[i*4+3] = 0; + } + FShader *shader = GLRenderer->mShaderManager->GetActiveShader(); + glUniformMatrix4fv(shader->vertexmatrix_index, 1, false, matV); + glUniformMatrix4fv(shader->texcoordmatrix_index, 1, false, matT); + glUniform1i(shader->quadmode_index, 1); + GLRenderer->mVBO->RenderArray(type, FFlatVertexBuffer::QUAD_INDEX, 4); + glUniform1i(shader->quadmode_index, 0); +} diff --git a/src/gl/renderer/gl_quaddrawer.h b/src/gl/renderer/gl_quaddrawer.h new file mode 100644 index 000000000..b9db60684 --- /dev/null +++ b/src/gl/renderer/gl_quaddrawer.h @@ -0,0 +1,44 @@ +#ifndef __QDRAWER_H +#define __QDRAWER_H + +#include "gl/data/gl_vertexbuffer.h" + +class FQuadDrawer +{ + FFlatVertex *p; + int ndx; + static FFlatVertex buffer[4]; + + void DoRender(int type); +public: + + FQuadDrawer() + { + if (gl.buffermethod == BM_DEFERRED) + { + p = buffer; + } + else + { + p = GLRenderer->mVBO->Alloc(4, &ndx); + } + } + void Set(int ndx, float x, float y, float z, float s, float t) + { + p[ndx].Set(x, y, z, s, t); + } + void Render(int type) + { + if (gl.buffermethod == BM_DEFERRED) + { + DoRender(type); + } + else + { + GLRenderer->mVBO->RenderArray(type, ndx, 4); + } + } +}; + + +#endif diff --git a/src/gl/renderer/gl_renderbuffers.cpp b/src/gl/renderer/gl_renderbuffers.cpp new file mode 100644 index 000000000..f66ea1354 --- /dev/null +++ b/src/gl/renderer/gl_renderbuffers.cpp @@ -0,0 +1,554 @@ +/* +** gl_renderbuffers.cpp +** Render buffers used during rendering +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** 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 "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/system/gl_debug.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" +#include "w_wad.h" +#include "i_system.h" +#include "doomerrors.h" + +CVAR(Int, gl_multisample, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); +CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) + +//========================================================================== +// +// Initialize render buffers and textures used in rendering passes +// +//========================================================================== + +FGLRenderBuffers::FGLRenderBuffers() +{ + for (int i = 0; i < NumPipelineTextures; i++) + { + mPipelineTexture[i] = 0; + mPipelineFB[i] = 0; + } + + glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&mOutputFB); + glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples); +} + +//========================================================================== +// +// Free render buffer resources +// +//========================================================================== + +FGLRenderBuffers::~FGLRenderBuffers() +{ + ClearScene(); + ClearPipeline(); + ClearBloom(); +} + +void FGLRenderBuffers::ClearScene() +{ + DeleteFrameBuffer(mSceneFB); + DeleteRenderBuffer(mSceneMultisample); + DeleteRenderBuffer(mSceneDepthStencil); + DeleteRenderBuffer(mSceneDepth); + DeleteRenderBuffer(mSceneStencil); +} + +void FGLRenderBuffers::ClearPipeline() +{ + for (int i = 0; i < NumPipelineTextures; i++) + { + DeleteFrameBuffer(mPipelineFB[i]); + DeleteTexture(mPipelineTexture[i]); + } +} + +void FGLRenderBuffers::ClearBloom() +{ + for (int i = 0; i < NumBloomLevels; i++) + { + auto &level = BloomLevels[i]; + DeleteFrameBuffer(level.HFramebuffer); + DeleteFrameBuffer(level.VFramebuffer); + DeleteTexture(level.HTexture); + DeleteTexture(level.VTexture); + level = FGLBloomTextureLevel(); + } +} + +void FGLRenderBuffers::DeleteTexture(GLuint &handle) +{ + if (handle != 0) + glDeleteTextures(1, &handle); + handle = 0; +} + +void FGLRenderBuffers::DeleteRenderBuffer(GLuint &handle) +{ + if (handle != 0) + glDeleteRenderbuffers(1, &handle); + handle = 0; +} + +void FGLRenderBuffers::DeleteFrameBuffer(GLuint &handle) +{ + if (handle != 0) + glDeleteFramebuffers(1, &handle); + handle = 0; +} + +//========================================================================== +// +// Makes sure all render buffers have sizes suitable for rending at the +// specified resolution +// +//========================================================================== + +bool FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHeight) +{ + if (gl_renderbuffers != BuffersActive) + { + if (BuffersActive) + glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB); + BuffersActive = gl_renderbuffers; + GLRenderer->mShaderManager->ResetFixedColormap(); + } + + if (!IsEnabled()) + return false; + + if (width <= 0 || height <= 0) + I_FatalError("Requested invalid render buffer sizes: screen = %dx%d", width, height); + + int samples = clamp((int)gl_multisample, 0, mMaxSamples); + + GLint activeTex; + GLint textureBinding; + glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex); + glActiveTexture(GL_TEXTURE0); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding); + + if (width == mWidth && height == mHeight && mSamples != samples) + { + CreateScene(mWidth, mHeight, samples); + mSamples = samples; + } + else if (width != mWidth || height != mHeight) + { + CreatePipeline(width, height); + CreateScene(width, height, samples); + mWidth = width; + mHeight = height; + mSamples = samples; + } + + // Bloom bluring buffers need to match the scene to avoid bloom bleeding artifacts + if (mBloomWidth != sceneWidth || mBloomHeight != sceneHeight) + { + CreateBloom(sceneWidth, sceneHeight); + mBloomWidth = sceneWidth; + mBloomHeight = sceneHeight; + } + + glBindTexture(GL_TEXTURE_2D, textureBinding); + glActiveTexture(activeTex); + glBindRenderbuffer(GL_RENDERBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); + + if (FailedCreate) + { + ClearScene(); + ClearPipeline(); + ClearBloom(); + mWidth = 0; + mHeight = 0; + mSamples = 0; + mBloomWidth = 0; + mBloomHeight = 0; + } + + return !FailedCreate; +} + +//========================================================================== +// +// Creates the scene buffers +// +//========================================================================== + +void FGLRenderBuffers::CreateScene(int width, int height, int samples) +{ + ClearScene(); + + if (samples > 1) + mSceneMultisample = CreateRenderBuffer("SceneMultisample", GL_RGBA16F, samples, width, height); + + mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height); + mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); +} + +//========================================================================== +// +// Creates the buffers needed for post processing steps +// +//========================================================================== + +void FGLRenderBuffers::CreatePipeline(int width, int height) +{ + ClearPipeline(); + + for (int i = 0; i < NumPipelineTextures; i++) + { + mPipelineTexture[i] = Create2DTexture("PipelineTexture", GL_RGBA16F, width, height); + mPipelineFB[i] = CreateFrameBuffer("PipelineFB", mPipelineTexture[i]); + } +} + +//========================================================================== +// +// Creates bloom pass working buffers +// +//========================================================================== + +void FGLRenderBuffers::CreateBloom(int width, int height) +{ + ClearBloom(); + + // No scene, no bloom! + if (width <= 0 || height <= 0) + return; + + int bloomWidth = MAX(width / 2, 1); + int bloomHeight = MAX(height / 2, 1); + for (int i = 0; i < NumBloomLevels; i++) + { + auto &level = BloomLevels[i]; + level.Width = MAX(bloomWidth / 2, 1); + level.Height = MAX(bloomHeight / 2, 1); + + level.VTexture = Create2DTexture("Bloom.VTexture", GL_RGBA16F, level.Width, level.Height); + level.HTexture = Create2DTexture("Bloom.HTexture", GL_RGBA16F, level.Width, level.Height); + level.VFramebuffer = CreateFrameBuffer("Bloom.VFramebuffer", level.VTexture); + level.HFramebuffer = CreateFrameBuffer("Bloom.HFramebuffer", level.HTexture); + + bloomWidth = level.Width; + bloomHeight = level.Height; + } +} + +//========================================================================== +// +// Creates a 2D texture defaulting to linear filtering and clamp to edge +// +//========================================================================== + +GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height) +{ + GLuint type = (format == GL_RGBA16F) ? GL_FLOAT : GL_UNSIGNED_BYTE; + GLuint handle = 0; + glGenTextures(1, &handle); + glBindTexture(GL_TEXTURE_2D, handle); + FGLDebug::LabelObject(GL_TEXTURE, handle, name); + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, type, nullptr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + 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 handle; +} + +//========================================================================== +// +// Creates a render buffer +// +//========================================================================== + +GLuint FGLRenderBuffers::CreateRenderBuffer(const FString &name, GLuint format, int width, int height) +{ + GLuint handle = 0; + glGenRenderbuffers(1, &handle); + glBindRenderbuffer(GL_RENDERBUFFER, handle); + FGLDebug::LabelObject(GL_RENDERBUFFER, handle, name); + glRenderbufferStorage(GL_RENDERBUFFER, format, width, height); + return handle; +} + +GLuint FGLRenderBuffers::CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height) +{ + if (samples <= 1) + return CreateRenderBuffer(name, format, width, height); + + GLuint handle = 0; + glGenRenderbuffers(1, &handle); + glBindRenderbuffer(GL_RENDERBUFFER, handle); + FGLDebug::LabelObject(GL_RENDERBUFFER, handle, name); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, format, width, height); + return handle; +} + +//========================================================================== +// +// Creates a frame buffer +// +//========================================================================== + +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer) +{ + GLuint handle = 0; + glGenFramebuffers(1, &handle); + glBindFramebuffer(GL_FRAMEBUFFER, handle); + FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); + if (CheckFrameBufferCompleteness()) + ClearFrameBuffer(false, false); + return handle; +} + +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer) +{ + GLuint handle = 0; + glGenFramebuffers(1, &handle); + glBindFramebuffer(GL_FRAMEBUFFER, handle); + FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); + if (colorIsARenderBuffer) + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); + else + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthstencil); + if (CheckFrameBufferCompleteness()) + ClearFrameBuffer(true, true); + return handle; +} + +GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer) +{ + GLuint handle = 0; + glGenFramebuffers(1, &handle); + glBindFramebuffer(GL_FRAMEBUFFER, handle); + FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name); + if (colorIsARenderBuffer) + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); + else + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil); + if (CheckFrameBufferCompleteness()) + ClearFrameBuffer(true, true); + return handle; +} + +//========================================================================== +// +// Verifies that the frame buffer setup is valid +// +//========================================================================== + +bool FGLRenderBuffers::CheckFrameBufferCompleteness() +{ + GLenum result = glCheckFramebufferStatus(GL_FRAMEBUFFER); + if (result == GL_FRAMEBUFFER_COMPLETE) + return true; + + FailedCreate = true; + +#if 0 + FString error = "glCheckFramebufferStatus failed: "; + switch (result) + { + default: error.AppendFormat("error code %d", (int)result); break; + case GL_FRAMEBUFFER_UNDEFINED: error << "GL_FRAMEBUFFER_UNDEFINED"; break; + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT"; break; + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: error << "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"; break; + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER"; break; + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: error << "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER"; break; + case GL_FRAMEBUFFER_UNSUPPORTED: error << "GL_FRAMEBUFFER_UNSUPPORTED"; break; + case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: error << "GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"; break; + case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: error << "GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS"; break; + } + I_FatalError(error); +#endif + + return false; +} + +//========================================================================== +// +// Clear frame buffer to make sure it never contains uninitialized data +// +//========================================================================== + +void FGLRenderBuffers::ClearFrameBuffer(bool stencil, bool depth) +{ + GLboolean scissorEnabled; + GLint stencilValue; + GLdouble depthValue; + glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled); + glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilValue); + glGetDoublev(GL_DEPTH_CLEAR_VALUE, &depthValue); + glDisable(GL_SCISSOR_TEST); + glClearColor(0.0, 0.0, 0.0, 0.0); + glClearDepth(0.0); + glClearStencil(0); + GLenum flags = GL_COLOR_BUFFER_BIT; + if (stencil) + flags |= GL_STENCIL_BUFFER_BIT; + if (depth) + flags |= GL_DEPTH_BUFFER_BIT; + glClear(flags); + glClearStencil(stencilValue); + glClearDepth(depthValue); + if (scissorEnabled) + glEnable(GL_SCISSOR_TEST); +} + +//========================================================================== +// +// Resolves the multisample frame buffer by copying it to the scene texture +// +//========================================================================== + +void FGLRenderBuffers::BlitSceneToTexture() +{ + mCurrentPipelineTexture = 0; + + if (mSamples <= 1) + return; + + glBindFramebuffer(GL_READ_FRAMEBUFFER, mSceneFB); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mPipelineFB[mCurrentPipelineTexture]); + glBlitFramebuffer(0, 0, mWidth, mHeight, 0, 0, mWidth, mHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); + + if ((gl.flags & RFL_INVALIDATE_BUFFER) != 0) + { + GLenum attachments[2] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_STENCIL_ATTACHMENT }; + glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 2, attachments); + } + + glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); +} + +//========================================================================== +// +// Makes the scene frame buffer active (multisample, depth, stecil, etc.) +// +//========================================================================== + +void FGLRenderBuffers::BindSceneFB() +{ + glBindFramebuffer(GL_FRAMEBUFFER, mSceneFB); +} + +//========================================================================== +// +// Binds the current scene/effect/hud texture to the specified texture unit +// +//========================================================================== + +void FGLRenderBuffers::BindCurrentTexture(int index) +{ + glActiveTexture(GL_TEXTURE0 + index); + glBindTexture(GL_TEXTURE_2D, mPipelineTexture[mCurrentPipelineTexture]); +} + +//========================================================================== +// +// Makes the frame buffer for the current texture active +// +//========================================================================== + +void FGLRenderBuffers::BindCurrentFB() +{ + glBindFramebuffer(GL_FRAMEBUFFER, mPipelineFB[mCurrentPipelineTexture]); +} + +//========================================================================== +// +// Makes the frame buffer for the next texture active +// +//========================================================================== + +void FGLRenderBuffers::BindNextFB() +{ + int out = (mCurrentPipelineTexture + 1) % NumPipelineTextures; + glBindFramebuffer(GL_FRAMEBUFFER, mPipelineFB[out]); +} + +//========================================================================== +// +// Next pipeline texture now contains the output +// +//========================================================================== + +void FGLRenderBuffers::NextTexture() +{ + mCurrentPipelineTexture = (mCurrentPipelineTexture + 1) % NumPipelineTextures; +} + +//========================================================================== +// +// Makes the screen frame buffer active +// +//========================================================================== + +void FGLRenderBuffers::BindOutputFB() +{ + glBindFramebuffer(GL_FRAMEBUFFER, mOutputFB); +} + +//========================================================================== +// +// Returns true if render buffers are supported and should be used +// +//========================================================================== + +bool FGLRenderBuffers::IsEnabled() +{ + return BuffersActive && !gl.legacyMode && !FailedCreate; +} + +bool FGLRenderBuffers::FailedCreate = false; +bool FGLRenderBuffers::BuffersActive = false; diff --git a/src/gl/renderer/gl_renderbuffers.h b/src/gl/renderer/gl_renderbuffers.h new file mode 100644 index 000000000..08303a912 --- /dev/null +++ b/src/gl/renderer/gl_renderbuffers.h @@ -0,0 +1,90 @@ +#ifndef __GL_RENDERBUFFERS_H +#define __GL_RENDERBUFFERS_H + +#include "gl/shaders/gl_shader.h" + +class FGLBloomTextureLevel +{ +public: + GLuint VTexture = 0; + GLuint VFramebuffer = 0; + GLuint HTexture = 0; + GLuint HFramebuffer = 0; + GLuint Width = 0; + GLuint Height = 0; +}; + +class FGLRenderBuffers +{ +public: + FGLRenderBuffers(); + ~FGLRenderBuffers(); + + bool Setup(int width, int height, int sceneWidth, int sceneHeight); + + void BindSceneFB(); + void BlitSceneToTexture(); + + void BindCurrentTexture(int index); + void BindCurrentFB(); + void BindNextFB(); + void NextTexture(); + + void BindOutputFB(); + + enum { NumBloomLevels = 4 }; + FGLBloomTextureLevel BloomLevels[NumBloomLevels]; + + static bool IsEnabled(); + + int GetWidth() const { return mWidth; } + int GetHeight() const { return mHeight; } + +private: + void ClearScene(); + void ClearPipeline(); + void ClearBloom(); + void CreateScene(int width, int height, int samples); + void CreatePipeline(int width, int height); + void CreateBloom(int width, int height); + GLuint Create2DTexture(const FString &name, GLuint format, int width, int height); + GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height); + GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); + GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer); + bool CheckFrameBufferCompleteness(); + void ClearFrameBuffer(bool stencil, bool depth); + void DeleteTexture(GLuint &handle); + void DeleteRenderBuffer(GLuint &handle); + void DeleteFrameBuffer(GLuint &handle); + + int mWidth = 0; + int mHeight = 0; + int mSamples = 0; + int mMaxSamples = 0; + int mBloomWidth = 0; + int mBloomHeight = 0; + + static const int NumPipelineTextures = 2; + int mCurrentPipelineTexture = 0; + + // Buffers for the scene + GLuint mSceneMultisample = 0; + GLuint mSceneDepthStencil = 0; + GLuint mSceneDepth = 0; + GLuint mSceneStencil = 0; + GLuint mSceneFB = 0; + + // Effect/HUD buffers + GLuint mPipelineTexture[NumPipelineTextures]; + GLuint mPipelineFB[NumPipelineTextures]; + + // Back buffer frame buffer + GLuint mOutputFB = 0; + + static bool FailedCreate; + static bool BuffersActive; +}; + +#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..f9d627d93 --- /dev/null +++ b/src/gl/renderer/gl_renderer.cpp @@ -0,0 +1,427 @@ +/* +** 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 "doomstat.h" + +#include "gl/system/gl_interface.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.h" +#include "gl/system/gl_debug.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_lightdata.h" +#include "gl/renderer/gl_renderstate.h" +#include "gl/renderer/gl_renderbuffers.h" +#include "gl/renderer/gl_2ddrawer.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/shaders/gl_bloomshader.h" +#include "gl/shaders/gl_blurshader.h" +#include "gl/shaders/gl_tonemapshader.h" +#include "gl/shaders/gl_colormapshader.h" +#include "gl/shaders/gl_lensshader.h" +#include "gl/shaders/gl_presentshader.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" + +EXTERN_CVAR(Int, screenblocks) + +CVAR(Bool, gl_scale_viewport, true, 0); + +//=========================================================================== +// +// Renderer interface +// +//=========================================================================== + +//----------------------------------------------------------------------------- +// +// Initialize +// +//----------------------------------------------------------------------------- + +FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb) +{ + framebuffer = fb; + mClipPortal = nullptr; + mCurrentPortal = nullptr; + mMirrorCount = 0; + mPlaneMirrorCount = 0; + mLightCount = 0; + mAngles = FRotator(0.f, 0.f, 0.f); + mViewVector = FVector2(0,0); + mVBO = nullptr; + mSkyVBO = nullptr; + gl_spriteindex = 0; + mShaderManager = nullptr; + gllight = glpart2 = glpart = mirrortexture = nullptr; + mLights = nullptr; + m2DDrawer = nullptr; + mTonemapPalette = nullptr; + mBuffers = nullptr; + mPresentShader = nullptr; + mBloomExtractShader = nullptr; + mBloomCombineShader = nullptr; + mBlurShader = nullptr; + mTonemapShader = nullptr; + mTonemapPalette = nullptr; + mColormapShader = nullptr; + mLensShader = nullptr; +} + +void gl_LoadModels(); +void gl_FlushModels(); + +void FGLRenderer::Initialize(int width, int height) +{ + mBuffers = new FGLRenderBuffers(); + mBloomExtractShader = new FBloomExtractShader(); + mBloomCombineShader = new FBloomCombineShader(); + mBlurShader = new FBlurShader(); + mTonemapShader = new FTonemapShader(); + mColormapShader = new FColormapShader(); + mTonemapPalette = nullptr; + mLensShader = new FLensShader(); + mPresentShader = new FPresentShader(); + m2DDrawer = new F2DDrawer; + + // needed for the core profile, because someone decided it was a good idea to remove the default VAO. + if (!gl.legacyMode) + { + glGenVertexArrays(1, &mVAOID); + glBindVertexArray(mVAOID); + FGLDebug::LabelObject(GL_VERTEX_ARRAY, mVAOID, "FGLRenderer.mVAOID"); + } + else mVAOID = 0; + + gllight = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/gllight.png"), FTexture::TEX_MiscPatch); + 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(width, height); + mSkyVBO = new FSkyVertexBuffer; + if (!gl.legacyMode) mLights = new FLightBuffer(); + else mLights = NULL; + gl_RenderState.SetVertexBuffer(mVBO); + mFBID = 0; + mOldFBID = 0; + + SetupLevel(); + mShaderManager = new FShaderManager; + mSamplerManager = new FSamplerManager; + gl_LoadModels(); +} + +FGLRenderer::~FGLRenderer() +{ + gl_FlushModels(); + gl_DeleteAllAttachedLights(); + FMaterial::FlushAll(); + if (m2DDrawer != nullptr) delete m2DDrawer; + 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); + if (mVAOID != 0) + { + glBindVertexArray(0); + glDeleteVertexArrays(1, &mVAOID); + } + if (mBuffers) delete mBuffers; + if (mPresentShader) delete mPresentShader; + if (mBloomExtractShader) delete mBloomExtractShader; + if (mBloomCombineShader) delete mBloomCombineShader; + if (mBlurShader) delete mBlurShader; + if (mTonemapShader) delete mTonemapShader; + if (mTonemapPalette) delete mTonemapPalette; + if (mColormapShader) delete mColormapShader; + if (mLensShader) delete mLensShader; +} + +//========================================================================== +// +// Calculates the viewport values needed for 2D and 3D operations +// +//========================================================================== + +void FGLRenderer::SetOutputViewport(GL_IRECT *bounds) +{ + if (bounds) + { + mSceneViewport = *bounds; + mScreenViewport = *bounds; + mOutputLetterbox = *bounds; + return; + } + + // Special handling so the view with a visible status bar displays properly + int height, width; + if (screenblocks >= 10) + { + height = framebuffer->GetHeight(); + width = framebuffer->GetWidth(); + } + else + { + height = (screenblocks*framebuffer->GetHeight() / 10) & ~7; + width = (screenblocks*framebuffer->GetWidth() / 10); + } + + // Back buffer letterbox for the final output + int clientWidth = framebuffer->GetClientWidth(); + int clientHeight = framebuffer->GetClientHeight(); + if (clientWidth == 0 || clientHeight == 0) + { + // When window is minimized there may not be any client area. + // Pretend to the rest of the render code that we just have a very small window. + clientWidth = 160; + clientHeight = 120; + } + int screenWidth = framebuffer->GetWidth(); + int screenHeight = framebuffer->GetHeight(); + float scale = MIN(clientWidth / (float)screenWidth, clientHeight / (float)screenHeight); + mOutputLetterbox.width = (int)round(screenWidth * scale); + mOutputLetterbox.height = (int)round(screenHeight * scale); + mOutputLetterbox.left = (clientWidth - mOutputLetterbox.width) / 2; + mOutputLetterbox.top = (clientHeight - mOutputLetterbox.height) / 2; + + // The entire renderable area, including the 2D HUD + mScreenViewport.left = 0; + mScreenViewport.top = 0; + mScreenViewport.width = screenWidth; + mScreenViewport.height = screenHeight; + + // Viewport for the 3D scene + mSceneViewport.left = viewwindowx; + mSceneViewport.top = screenHeight - (height + viewwindowy - ((height - viewheight) / 2)); + mSceneViewport.width = viewwidth; + mSceneViewport.height = height; + + // Scale viewports to fit letterbox + if (gl_scale_viewport || !FGLRenderBuffers::IsEnabled()) + { + mScreenViewport.width = mOutputLetterbox.width; + mScreenViewport.height = mOutputLetterbox.height; + mSceneViewport.left = (int)round(mSceneViewport.left * scale); + mSceneViewport.top = (int)round(mSceneViewport.top * scale); + mSceneViewport.width = (int)round(mSceneViewport.width * scale); + mSceneViewport.height = (int)round(mSceneViewport.height * scale); + + // Without render buffers we have to render directly to the letterbox + if (!FGLRenderBuffers::IsEnabled()) + { + mScreenViewport.left += mOutputLetterbox.left; + mScreenViewport.top += mOutputLetterbox.top; + mSceneViewport.left += mOutputLetterbox.left; + mSceneViewport.top += mOutputLetterbox.top; + } + } +} + +//=========================================================================== +// +// Calculates the OpenGL window coordinates for a zdoom screen position +// +//=========================================================================== + +int FGLRenderer::ScreenToWindowX(int x) +{ + return mScreenViewport.left + (int)round(x * mScreenViewport.width / (float)framebuffer->GetWidth()); +} + +int FGLRenderer::ScreenToWindowY(int y) +{ + return mScreenViewport.top + mScreenViewport.height - (int)round(y * mScreenViewport.height / (float)framebuffer->GetHeight()); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::SetupLevel() +{ + mVBO->CreateVBO(); +} + +void FGLRenderer::Begin2D() +{ + if (mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height)) + { + if (mDrawingScene2D) + mBuffers->BindSceneFB(); + else + mBuffers->BindCurrentFB(); + } + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + glScissor(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + + gl_RenderState.EnableFog(false); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +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, bool thruportal) +{ + GLSprite glsprite; + glsprite.Process(thing, sector, thruportal); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +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() +{ + bool firstBind = (mFBID == 0); + if (mFBID == 0) + glGenFramebuffers(1, &mFBID); + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mOldFBID); + glBindFramebuffer(GL_FRAMEBUFFER, mFBID); + if (firstBind) + FGLDebug::LabelObject(GL_FRAMEBUFFER, mFBID, "OffscreenFB"); + return true; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +void FGLRenderer::EndOffscreen() +{ + glBindFramebuffer(GL_FRAMEBUFFER, mOldFBID); +} + +//=========================================================================== +// +// +// +//=========================================================================== + +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; +} diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h new file mode 100644 index 000000000..f652b4765 --- /dev/null +++ b/src/gl/renderer/gl_renderer.h @@ -0,0 +1,228 @@ +#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; +class FShaderManager; +class GLPortal; +class FLightBuffer; +class FSamplerManager; +class DPSprite; +class FGLRenderBuffers; +class FBloomExtractShader; +class FBloomCombineShader; +class FBlurShader; +class FTonemapShader; +class FColormapShader; +class FLensShader; +class FPresentShader; +class F2DDrawer; +class FHardwareTexture; + +inline float DEG2RAD(float deg) +{ + return deg * float(M_PI / 180.0); +} + +inline float RAD2DEG(float deg) +{ + return deg * float(180. / M_PI); +} + +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; + } +}; + +enum +{ + DM_MAINVIEW, + DM_OFFSCREEN, + DM_PORTAL +}; + +class FGLRenderer +{ +public: + + OpenGLFrameBuffer *framebuffer; + GLPortal *mClipPortal; + GLPortal *mCurrentPortal; + int mMirrorCount; + int mPlaneMirrorCount; + int mLightCount; + float mCurrentFoV; + AActor *mViewActor; + FShaderManager *mShaderManager; + FSamplerManager *mSamplerManager; + int gl_spriteindex; + unsigned int mFBID; + unsigned int mVAOID; + int mOldFBID; + + FGLRenderBuffers *mBuffers; + FBloomExtractShader *mBloomExtractShader; + FBloomCombineShader *mBloomCombineShader; + FBlurShader *mBlurShader; + FTonemapShader *mTonemapShader; + FColormapShader *mColormapShader; + FHardwareTexture *mTonemapPalette; + FLensShader *mLensShader; + FPresentShader *mPresentShader; + + FTexture *gllight; + FTexture *glpart2; + FTexture *glpart; + FTexture *mirrortexture; + + float mSky1Pos, mSky2Pos; + + FRotator mAngles; + FVector2 mViewVector; + + FFlatVertexBuffer *mVBO; + FSkyVertexBuffer *mSkyVBO; + FLightBuffer *mLights; + F2DDrawer *m2DDrawer; + + GL_IRECT mScreenViewport; + GL_IRECT mSceneViewport; + GL_IRECT mOutputLetterbox; + bool mDrawingScene2D = false; + float mCameraExposure = 1.0f; + + float mSceneClearColor[3]; + + FGLRenderer(OpenGLFrameBuffer *fb); + ~FGLRenderer() ; + + void SetOutputViewport(GL_IRECT *bounds); + int ScreenToWindowX(int x); + int ScreenToWindowY(int y); + + angle_t FrustumAngle(); + void SetViewArea(); + void Set3DViewport(bool mainview); + void Reset3DViewport(); + 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(DAngle viewangle); + void SetupView(float viewx, float viewy, float viewz, DAngle viewangle, bool mirror, bool planemirror); + + void Initialize(int width, int height); + + void CreateScene(); + void RenderMultipassStuff(); + void RenderScene(int recursion); + void RenderTranslucent(); + void DrawScene(int drawmode); + void DrawBlend(sector_t * viewsector); + + void DrawPSprite (player_t * player,DPSprite *psp,float sx, float sy, bool hudModelStep, int OverrideShader, bool alphatexture); + void DrawPlayerSprites(sector_t * viewsector, bool hudModelStep); + void DrawTargeterSprites(); + + void Begin2D(); + void ClearBorders(); + + void ProcessLowerMiniseg(seg_t *seg, sector_t * frontsector, sector_t * backsector); + void ProcessSprite(AActor *thing, sector_t *sector, bool thruportal); + 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 RenderScreenQuad(); + void SetFixedColormap (player_t *player); + void WriteSavePic (player_t *player, FILE *file, int width, int height); + void EndDrawScene(sector_t * viewsector); + void BloomScene(); + void TonemapScene(); + void ColormapScene(); + void BindTonemapPalette(int texunit); + void ClearTonemapPalette(); + void LensDistortScene(); + void CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma); + void Flush() { CopyToBackbuffer(nullptr, true); } + + void SetProjection(float fov, float ratio, float fovratio); + void SetProjection(VSMatrix matrix); // raw matrix input from stereo 3d modes + void SetViewMatrix(float vx, float vy, float vz, bool mirror, bool planemirror); + void ProcessScene(bool toscreen = false); + + bool StartOffscreen(); + void EndOffscreen(); + + void StartSimplePolys(); + void FinishSimplePolys(); + + void FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, + double originx, double originy, double scalex, double scaley, + DAngle rotation, FDynamicColormap *colormap, int lightlevel); + + int PTM_BestColor (const uint32 *pal_in, int r, int g, int b, int first, int num); +}; + +// 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..c3cc905e5 --- /dev/null +++ b/src/gl/renderer/gl_renderstate.cpp @@ -0,0 +1,402 @@ +/* +** 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" +#include "gl/renderer/gl_renderbuffers.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; + mClipLineEnabled = mSplitEnabled = 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; + mModelMatrixEnabled = false; + mTextureMatrixEnabled = false; + mObjectColor = 0xffffffff; + mVertexBuffer = mCurrentVertexBuffer = NULL; + mColormapState = CM_DEFAULT; + mSoftLight = 0; + mLightParms[0] = mLightParms[1] = mLightParms[2] = 0.0f; + mLightParms[3] = -1.f; + mSpecialEffect = EFF_NONE; + mClipHeight = 0.f; + mClipHeightDirection = 0.f; + mShaderTimer = 0.0f; + ClearClipSplit(); + + stSrcBlend = stDstBlend = -1; + stBlendEquation = -1; + stAlphaThreshold = -1.f; + stAlphaTest = 0; + mLastDepthClamp = true; + mInterpolationFactor = 0.0f; + + mColor.Set(1.0f, 1.0f, 1.0f, 1.0f); + mCameraPos.Set(0.0f, 0.0f, 0.0f, 0.0f); + mGlowTop.Set(0.0f, 0.0f, 0.0f, 0.0f); + mGlowBottom.Set(0.0f, 0.0f, 0.0f, 0.0f); + mGlowTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f); + mGlowBottomPlane.Set(0.0f, 0.0f, 0.0f, 0.0f); + mSplitTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f); + mSplitBottomPlane.Set(0.0f, 0.0f, 0.0f, 0.0f); + mClipLine.Set(0.0f, 0.0f, 0.0f, 0.0f); + mDynColor.Set(0.0f, 0.0f, 0.0f, 0.0f); + mEffectState = 0; + activeShader = nullptr; + mProjectionMatrix.loadIdentity(); + mViewMatrix.loadIdentity(); + mModelMatrix.loadIdentity(); + mTextureMatrix.loadIdentity(); +} + +//========================================================================== +// +// Apply shader settings +// +//========================================================================== + +bool FRenderState::ApplyShader() +{ + static const float nulvec[] = { 0.f, 0.f, 0.f, 0.f }; + 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->muClipHeight.Set(mClipHeight); + activeShader->muClipHeightDirection.Set(mClipHeightDirection); + 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. + activeShader->muGlowTopColor.Set(nulvec); + activeShader->muGlowBottomColor.Set(nulvec); + activeShader->muGlowTopPlane.Set(nulvec); + activeShader->muGlowBottomPlane.Set(nulvec); + activeShader->currentglowstate = 0; + } + + if (mSplitEnabled) + { + activeShader->muSplitTopPlane.Set(mSplitTopPlane.vec); + activeShader->muSplitBottomPlane.Set(mSplitBottomPlane.vec); + activeShader->currentsplitstate = 1; + } + else if (activeShader->currentsplitstate) + { + activeShader->muSplitTopPlane.Set(nulvec); + activeShader->muSplitBottomPlane.Set(nulvec); + activeShader->currentsplitstate = 0; + } + + if (mClipLineEnabled) + { + activeShader->muClipLine.Set(mClipLine.vec); + activeShader->currentcliplinestate = 1; + } + else if (activeShader->currentcliplinestate) + { + activeShader->muClipLine.Set(-10000000.0, 0, 0, 0); + activeShader->currentcliplinestate = 0; + } + + if (mColormapState != activeShader->currentfixedcolormap) + { + float r, g, b; + activeShader->currentfixedcolormap = mColormapState; + if (mColormapState == CM_DEFAULT) + { + activeShader->muFixedColormap.Set(0); + } + else if (mColormapState > CM_DEFAULT && mColormapState < CM_MAXCOLORMAP) + { + if (FGLRenderBuffers::IsEnabled()) + { + // When using postprocessing to apply the colormap, we must render the image fullbright here. + activeShader->muFixedColormap.Set(2); + activeShader->muColormapStart.Set(1, 1, 1, 1.f); + } + else + { + 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; + } + if (!gl.legacyMode) + { + ApplyShader(); + } + else + { + ApplyFixedFunction(); + } +} + + + +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 (!gl.legacyMode) + { + if (index > -1 && GLRenderer->mLights->GetBufferType() == GL_UNIFORM_BUFFER) + { + index = GLRenderer->mLights->BindUBO(index); + } + activeShader->muLightIndex.Set(index); + } +} + +void FRenderState::SetClipHeight(float height, float direction) +{ + mClipHeight = height; + mClipHeightDirection = direction; +#if 1 + // This still doesn't work... :( + if (gl.flags & RFL_NO_CLIP_PLANES) return; +#endif + if (direction != 0.f) + { + /* + if (gl.flags & RFL_NO_CLIP_PLANES) + { + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadMatrixf(mViewMatrix.get()); + // Plane mirrors never are slopes. + double d[4] = { 0, direction, 0, -direction * height }; + glClipPlane(GL_CLIP_PLANE0, d); + glPopMatrix(); + } + */ + glEnable(GL_CLIP_DISTANCE0); + } + else + { + glDisable(GL_CLIP_DISTANCE0); // GL_CLIP_PLANE0 is the same value so no need to make a distinction + } +} diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h new file mode 100644 index 000000000..6acf44026 --- /dev/null +++ b/src/gl/renderer/gl_renderstate.h @@ -0,0 +1,447 @@ +#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 mSplitEnabled; + bool mClipLineEnabled; + 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 mModelMatrixEnabled; + bool mTextureMatrixEnabled; + bool mLastDepthClamp; + float mInterpolationFactor; + float mClipHeight, mClipHeightDirection; + float mShaderTimer; + + FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer; + FStateVec4 mColor; + FStateVec4 mCameraPos; + FStateVec4 mGlowTop, mGlowBottom; + FStateVec4 mGlowTopPlane, mGlowBottomPlane; + FStateVec4 mSplitTopPlane, mSplitBottomPlane; + FStateVec4 mClipLine; + 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. + // Without shaders this translation must be applied to any texture. + if (alphatexture) + { + if (mat->tex->UseBasePalette() || gl.legacyMode) 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; + } + + float GetClipHeight() + { + return mClipHeight; + } + + float GetClipHeightDirection() + { + return mClipHeightDirection; + } + + FStateVec4 &GetClipLine() + { + return mClipLine; + } + + bool GetClipLineState() + { + return mClipLineEnabled; + } + + void SetClipHeight(float height, float direction); + + 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 EnableSplit(bool on) + { + if (!(gl.flags & RFL_NO_CLIP_PLANES)) + { + mSplitEnabled = on; + if (on) + { + glEnable(GL_CLIP_DISTANCE3); + glEnable(GL_CLIP_DISTANCE4); + } + else + { + glDisable(GL_CLIP_DISTANCE3); + glDisable(GL_CLIP_DISTANCE4); + } + } + } + + void SetClipLine(line_t *line) + { + mClipLine.Set(line->v1->fX(), line->v1->fY(), line->Delta().X, line->Delta().Y); + } + + void EnableClipLine(bool on) + { + if (!(gl.flags & RFL_NO_CLIP_PLANES)) + { + mClipLineEnabled = on; + if (on) + { + glEnable(GL_CLIP_DISTANCE0); + } + else + { + glDisable(GL_CLIP_DISTANCE0); + } + } + } + + 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) + { + DVector3 tn = top.Normal(); + DVector3 bn = bottom.Normal(); + mGlowTopPlane.Set(tn.X, tn.Y, 1. / tn.Z, top.fD()); + mGlowBottomPlane.Set(bn.X, bn.Y, 1. / bn.Z, bottom.fD()); + } + + void SetSplitPlanes(const secplane_t &top, const secplane_t &bottom) + { + DVector3 tn = top.Normal(); + DVector3 bn = bottom.Normal(); + mSplitTopPlane.Set(tn.X, tn.Y, 1. / tn.Z, top.fD()); + mSplitBottomPlane.Set(bn.X, bn.Y, 1. / bn.Z, bottom.fD()); + } + + 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; + } + + int GetFixedColormap() + { + return mColormapState; + } + + 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 SetInterpolationFactor(float fac) + { + mInterpolationFactor = fac; + } + + float GetInterpolationFactor() + { + return mInterpolationFactor; + } + + // Backwards compatibility crap follows + void ApplyFixedFunction(); + void DrawColormapOverlay(); +}; + +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..5f95902a3 --- /dev/null +++ b/src/gl/scene/gl_bsp.cpp @@ -0,0 +1,597 @@ +/* +** 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 "doomdata.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) + +extern fixed_t viewx, viewy; + +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); + clipper.SetBlocked(false); + } + 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, bool portalclip) +{ +#ifdef _DEBUG + if (seg->linedef - lines == 38) + { + int a = 0; + } +#endif + + angle_t startAngle, endAngle; + sector_t * backsector = NULL; + sector_t bs; + + if (portalclip) + { + int clipres = GLRenderer->mClipPortal->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; + + BYTE ispoly = BYTE(seg->sidedef->Flags & WALLF_POLYOBJ); + + if (!seg->backsector) + { + clipper.SafeAddClipRange(startAngle, endAngle); + } + else if (!ispoly) // 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 (ispoly || seg->linedef->validcount!=validcount) + { + if (!ispoly) 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, GLRenderer->mClipPortal != NULL); + } + 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, GLRenderer->mClipPortal != NULL); + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + AddLine (seg, GLRenderer->mClipPortal != NULL); + } + seg++; + } + } + ClipWall.Unclock(); +} + +//========================================================================== +// +// Adds lines that lie directly on the portal boundary. +// Only two-sided lines will be handled here, and no polyobjects +// +//========================================================================== + +inline bool PointOnLine(const DVector2 &pos, const line_t *line) +{ + double v = (pos.Y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - pos.X) * line->Delta().Y; + return fabs(v) <= EQUAL_EPSILON; +} + +static inline void AddSpecialPortalLines(subsector_t * sub, sector_t * sector, line_t *line) +{ + currentsector = sector; + currentsubsector = sub; + + ClipWall.Clock(); + int count = sub->numlines; + seg_t * seg = sub->firstline; + + while (count--) + { + if (seg->linedef != NULL && seg->PartnerSeg != NULL) + { + if (PointOnLine(seg->v1->fPos(), line) && PointOnLine(seg->v2->fPos(), line)) + AddLine(seg, false); + } + seg++; + } + ClipWall.Unclock(); +} + + +//========================================================================== +// +// R_RenderThings +// +//========================================================================== + +static inline void RenderThings(subsector_t * sub, sector_t * sector) +{ + + SetupSprite.Clock(); + sector_t * sec=sub->sector; + // Handle all things in sector. + for (AActor * thing = sec->thinglist; thing; thing = thing->snext) + { + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != NULL && *cvar >= 0) + { + double dist = (thing->Pos() - ViewPos).LengthSquared(); + double check = (double)**cvar; + if (dist >= check * check) + { + continue; + } + } + + GLRenderer->ProcessSprite(thing, sector, false); + } + for (msecnode_t *node = sec->render_thinglist; node; node = node->m_snext) + { + AActor *thing = node->m_thing; + FIntCVar *cvar = thing->GetClass()->distancecheck; + if (cvar != NULL && *cvar >= 0) + { + double dist = (thing->Pos() - ViewPos).LengthSquared(); + double check = (double)**cvar; + if (dist >= check * check) + { + continue; + } + } + + GLRenderer->ProcessSprite(thing, sector, true); + } + 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; + +#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 (sub->flags & SSECF_POLYORG) return; // never render polyobject origin subsectors because their vertices no longer are where one may expect. + + 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); + } + if (clipper.IsBlocked()) return; // if we are inside a stacked sector portal which hasn't unclipped anything yet. + + fakesector=gl_FakeFlat(sector, &fake, false); + + if (GLRenderer->mClipPortal) + { + int clipres = GLRenderer->mClipPortal->ClipSubsector(sub); + if (clipres == GLPortal::PClip_InFront) + { + line_t *line = GLRenderer->mClipPortal->ClipLine(); + // The subsector is out of range, but we still have to check lines that lie directly on the boundary and may expose their upper or lower parts. + if (line) AddSpecialPortalLines(sub, fakesector, line); + return; + } + } + + 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->GetGLPortal(sector_t::ceiling); + if (portal != NULL) + { + GLSectorStackPortal *glportal = portal->GetRenderState(); + glportal->AddSubsector(sub); + } + + portal = fakesector->GetGLPortal(sector_t::floor); + if (portal != NULL) + { + GLSectorStackPortal *glportal = portal->GetRenderState(); + 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..cd076d58a --- /dev/null +++ b/src/gl/scene/gl_clipper.cpp @@ -0,0 +1,465 @@ +/* +* +** 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; + + blocked = false; + 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 around 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. +// +//----------------------------------------------------------------------------- + +fixed_t viewx, viewy; + +void R_SetView() +{ + viewx = FLOAT2FIXED(ViewPos.X); + viewy = FLOAT2FIXED(ViewPos.Y); +} + +angle_t R_PointToPseudoAngle(double x, double y) +{ + double vecx = x - ViewPos.X; + double vecy = y - ViewPos.Y; + + 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 BYTE 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 float *bspcoord) +{ + angle_t angle1, angle2; + + int boxpos; + const BYTE* check; + + // Find the corners of the box + // that define the edges from current viewpoint. + boxpos = (ViewPos.X <= bspcoord[BOXLEFT] ? 0 : ViewPos.X < bspcoord[BOXRIGHT ] ? 1 : 2) + + (ViewPos.Y >= bspcoord[BOXTOP ] ? 0 : ViewPos.Y > bspcoord[BOXBOTTOM] ? 4 : 8); + + if (boxpos == 5) return true; + + check = checkcoord[boxpos]; + angle1 = R_PointToPseudoAngle (bspcoord[check[0]], bspcoord[check[1]]); + angle2 = R_PointToPseudoAngle (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..8da75080e --- /dev/null +++ b/src/gl/scene/gl_clipper.h @@ -0,0 +1,159 @@ +#ifndef __GL_CLIPPER +#define __GL_CLIPPER + +#include "doomtype.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 + bool blocked; + + 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() + { + blocked = false; + 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)); + } + + void SetBlocked(bool on) + { + blocked = on; + } + + bool IsBlocked() const + { + return blocked; + } + + bool CheckBox(const float *bspcoord); +}; + + +extern Clipper clipper; + +angle_t R_PointToPseudoAngle(double x, double y); +void R_SetView(); + +// 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(p.X, p.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..c9de15144 --- /dev/null +++ b/src/gl/scene/gl_decal.cpp @@ -0,0 +1,409 @@ +/* +** 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" +#include "gl/renderer/gl_quaddrawer.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; + float 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 = decal->Alpha; + + // now clip the decal to the actual polygon + float decalwidth = tex->TextureWidth() * decal->ScaleX; + float decalheight= tex->TextureHeight() * decal->ScaleY; + float decallefto = tex->GetLeftOffset() * decal->ScaleX; + float decaltopo = tex->GetTopOffset() * 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 - (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+= (flipy? decalheight-decaltopo : decaltopo); + + dv[1].z=dv[2].z = 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 / decal->ScaleX); + dv[3].u=dv[2].u = tex->GetU(righttex / 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. + double 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_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_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); + } + + FQuadDrawer qd; + for (i = 0; i < 4; i++) + { + qd.Set(i, dv[i].x, dv[i].z, dv[i].y, dv[i].u, dv[i].v); + } + + if (lightlist == NULL) + { + gl_RenderState.Apply(); + qd.Render(GL_TRIANGLE_FAN); + } + else + { + for (unsigned k = 0; k < lightlist->Size(); k++) + { + secplane_t &lowplane = k == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[k + 1].plane; + + float low1 = lowplane.ZatPoint(dv[1].x, dv[1].y); + float low2 = lowplane.ZatPoint(dv[2].x, dv[2].y); + + if (low1 < dv[1].z || low2 < dv[2].z) + { + int thisll = (*lightlist)[k].caster != NULL ? gl_ClampLight(*(*lightlist)[k].p_lightlevel) : lightlevel; + FColormap thiscm; + thiscm.FadeColor = Colormap.FadeColor; + thiscm.CopyFrom3DLight(&(*lightlist)[k]); + gl_SetColor(thisll, rel, thiscm, a); + if (glset.nocoloredspritelighting) thiscm.Decolorize(); + gl_SetFog(thisll, rel, &thiscm, RenderStyle == STYLE_Add); + gl_RenderState.SetSplitPlanes((*lightlist)[k].plane, lowplane); + + gl_RenderState.Apply(); + qd.Render(GL_TRIANGLE_FAN); + } + if (low1 <= dv[0].z && low2 <= dv[3].z) break; + } + } + + 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) + { + if (lightlist != NULL) + { + gl_RenderState.EnableSplit(true); + } + else + { + gl_SetFog(lightlevel, rellight + getExtraLight(), &Colormap, false); + } + + DBaseDecal *decal = seg->sidedef->AttachedDecals; + while (decal) + { + DrawDecal(decal); + decal = decal->WallNext; + } + + if (lightlist != NULL) + { + gl_RenderState.EnableSplit(false); + } + + } +} + diff --git a/src/gl/scene/gl_drawinfo.cpp b/src/gl/scene/gl_drawinfo.cpp new file mode 100644 index 000000000..c34d79816 --- /dev/null +++ b/src/gl/scene/gl_drawinfo.cpp @@ -0,0 +1,1310 @@ +/* +** 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" +#include "gl/renderer/gl_quaddrawer.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) +{ + float farthest = -FLT_MAX; + float nearest = FLT_MAX; + SortNode * best = NULL; + SortNode * node = head; + float bestdist = FLT_MAX; + + while (node) + { + GLDrawItem * it = &drawitems[node->itemindex]; + if (it->rendertype == GLDIT_WALL) + { + float d = walls[it->index].ViewDistance; + if (d > farthest) farthest = d; + if (d < nearest) nearest = d; + } + node = node->next; + } + if (farthest == INT_MIN) return NULL; + node = head; + farthest = (farthest + nearest) / 2; + while (node) + { + GLDrawItem * it = &drawitems[node->itemindex]; + if (it->rendertype == GLDIT_WALL) + { + float di = fabsf(walls[it->index].ViewDistance - farthest); + if (!best || di < bestdist) + { + best = node; + bestdist = di; + } + } + node = node->next; + } + 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 > ViewPos.Z; + + 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, if available + if (gl.flags & RFL_NO_CLIP_PLANES) + { + GLWall * ws1; + ws->vertcount = 0; // invalidate current vertices. + ws1=&walls[walls.Size()-1]; + ws=&walls[drawitems[sort->itemindex].index]; // may have been reallocated! + float newtexv = ws->tcs[GLWall::UPLFT].v + ((ws->tcs[GLWall::LOLFT].v - ws->tcs[GLWall::UPLFT].v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]); + + // I make the very big assumption here that translucent walls in sloped sectors + // and 3D-floors never coexist in the same level. If that were the case this + // code would become extremely more complicated. + if (!ceiling) + { + ws->ztop[1] = ws1->zbottom[1] = ws->ztop[0] = ws1->zbottom[0] = fh->z; + ws->tcs[GLWall::UPRGT].v = ws1->tcs[GLWall::LORGT].v = ws->tcs[GLWall::UPLFT].v = ws1->tcs[GLWall::LOLFT].v = newtexv; + } + else + { + ws1->ztop[1] = ws->zbottom[1] = ws1->ztop[0] = ws->zbottom[0] = fh->z; + ws1->tcs[GLWall::UPLFT].v = ws->tcs[GLWall::LOLFT].v = ws1->tcs[GLWall::UPRGT].v = ws->tcs[GLWall::LORGT].v=newtexv; + } + } + + 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 > ViewPos.Z; + + 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, if available + if (gl.flags & RFL_NO_CLIP_PLANES) + { + GLSprite * ss1; + ss1=&sprites[sprites.Size()-1]; + ss=&sprites[drawitems[sort->itemindex].index]; // may have been reallocated! + float newtexv=ss->vt + ((ss->vb-ss->vt)/(ss->z2-ss->z1))*(fh->z-ss->z1); + + if (!ceiling) + { + ss->z1=ss1->z2=fh->z; + ss->vt=ss1->vb=newtexv; + } + else + { + ss1->z1=ss->z2=fh->z; + ss1->vt=ss->vb=newtexv; + } + } + + 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->tcs[GLWall::UPLFT].u + r * (ws->tcs[GLWall::UPRGT].u - ws->tcs[GLWall::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])); + + ws->vertcount = 0; // invalidate current vertices. + 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->glseg.fracleft = ws->glseg.fracright = ws->glseg.fracleft + r*(ws->glseg.fracright - ws->glseg.fracleft); + ws1->ztop[0]=ws->ztop[1]=izt; + ws1->zbottom[0]=ws->zbottom[1]=izb; + ws1->tcs[GLWall::LOLFT].u = ws1->tcs[GLWall::UPLFT].u = ws->tcs[GLWall::LORGT].u = ws->tcs[GLWall::UPRGT].u = iu; + if (gl.buffermethod == BM_DEFERRED) + { + ws->MakeVertices(false); + ws1->MakeVertices(false); + } + + 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 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 > ViewPos.Z ? 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) + { + GLRenderer->mVBO->Map(); + MakeSortList(); + sorted=DoSort(SortNodes[SortNodeStart]); + GLRenderer->mVBO->Unmap(); + } + gl_RenderState.ClearClipSplit(); + if (!(gl.flags & RFL_NO_CLIP_PLANES)) + { + glEnable(GL_CLIP_DISTANCE1); + glEnable(GL_CLIP_DISTANCE2); + } + DoDrawSorted(sorted); + if (!(gl.flags & RFL_NO_CLIP_PLANES)) + { + glDisable(GL_CLIP_DISTANCE1); + glDisable(GL_CLIP_DISTANCE2); + } + 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 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; + if (gl.legacyMode) + { + dldrawlists = new GLDrawList[GLLDL_TYPES]; + } +} + +FDrawInfo::~FDrawInfo() +{ + if (dldrawlists != NULL) delete[] dldrawlists; + 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; i < GLDL_TYPES; i++) drawlists[i].Reset(); + if (dldrawlists != NULL) + { + for (int i = 0; i < GLLDL_TYPES; i++) dldrawlists[i].Reset(); + } +} + +//========================================================================== +// +// +// +//========================================================================== +void FDrawInfo::EndDrawInfo() +{ + FDrawInfo * di = gl_drawinfo; + + for(int i=0;idrawlists[i].Reset(); + if (di->dldrawlists != NULL) + { + for (int i = 0; i < GLLDL_TYPES; i++) di->dldrawlists[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(); + FQuadDrawer qd; + qd.Set(0, ws->x1, ws->z1, ws->y1, 0, 0); + qd.Set(1, ws->x1, ws->z2, ws->y1, 0, 0); + qd.Set(2, ws->x2, ws->z2, ws->y2, 0, 0); + qd.Set(3, ws->x2, ws->z1, ws->y2, 0, 0); + qd.Render(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(); + FQuadDrawer qd; + qd.Set(0, ws->x1, ws->z1, ws->y1, 0, 0); + qd.Set(1, ws->x1, ws->z2, ws->y1, 0, 0); + qd.Set(2, ws->x2, ws->z2, ws->y2, 0, 0); + qd.Set(3, ws->x2, ws->z1, ws->y2, 0, 0); + qd.Render(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 = ViewPos.X; + float fviewy = ViewPos.Y; + float fviewz = ViewPos.Z; + + 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); + + FQuadDrawer qd; + qd.Set(0, px1, planez, py1, px1 / 64, -py1 / 64); + qd.Set(1, px2, planez, py2, px2 / 64, -py2 / 64); + qd.Set(2, px3, planez, py3, px3 / 64, -py3 / 64); + qd.Set(3, px4, planez, py4, px4 / 64, -py4 / 64); + qd.Render(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. + double backz = fakebsector->ceilingplane.ZatPoint(seg->v1); + double frontz = fakefsector->ceilingplane.ZatPoint(seg->v1); + + if (fakebsector->GetTexture(sector_t::ceiling)==skyflatnum) return; + if (backz < ViewPos.Z) 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 = v1->fX(); + ws.y1 = v1->fY(); + ws.x2 = v2->fX(); + ws.y2 = v2->fY(); + + ws.z1= frontz; + ws.z2= 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. + double backz = fakebsector->floorplane.ZatPoint(seg->v1); + double frontz = fakefsector->floorplane.ZatPoint(seg->v1); + + + if (fakebsector->GetTexture(sector_t::floor) == skyflatnum) return; + if (fakebsector->GetPlaneTexZ(sector_t::floor) > ViewPos.Z) 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 = v1->fX(); + ws.y1 = v1->fY(); + ws.x2 = v2->fX(); + ws.y2 = v2->fY(); + + ws.z2= frontz; + ws.z1= 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..0e7296ee3 --- /dev/null +++ b/src/gl/scene/gl_drawinfo.h @@ -0,0 +1,301 @@ +#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, +}; + +// more lists for handling of dynamic lights +enum DLDrawListType +{ + // These are organized so that the various multipass rendering modes have to be set as few times as possible + GLLDL_WALLS_PLAIN, // dynamic lights on normal walls + GLLDL_WALLS_MASKED, // dynamic lights on masked midtextures + + GLLDL_FLATS_PLAIN, // dynamic lights on normal flats + GLLDL_FLATS_MASKED, // dynamic lights on masked flats + + GLLDL_WALLS_FOG, // lights on fogged walls + GLLDL_WALLS_FOGMASKED, // lights on fogged masked midtextures + + GLLDL_FLATS_FOG, // lights on fogged walls + GLLDL_FLATS_FOGMASKED, // lights on fogged masked midtextures + + GLLDL_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 + + // these are only used with texture based dynamic lights + GLPASS_BASE, // untextured base for dynamic lights + GLPASS_BASE_MASKED, // same but with active texture + GLPASS_LIGHTTEX, // lighttexture pass + GLPASS_TEXONLY, // finishing texture pass + GLPASS_LIGHTTEX_ADDITIVE, // lighttexture pass (additive) + GLPASS_LIGHTTEX_FOGGY, // lighttexture pass on foggy surfaces (forces all lights to be additive) + +}; + +//========================================================================== +// +// 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; + float Planez; + float 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]; + GLDrawList *dldrawlists = NULL; // only gets allocated when needed. + + FDrawInfo(); + ~FDrawInfo(); + void ClearBuffers(); + + bool DoOneSectorUpper(subsector_t * subsec, float planez); + bool DoOneSectorLower(subsector_t * subsec, float planez); + bool DoFakeBridge(subsector_t * subsec, float planez); + bool DoFakeCeilingBridge(subsector_t * subsec, float 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, float backheight); + void AddLowerMissingTexture(side_t * side, subsector_t *sub, float 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..04a19a7ed --- /dev/null +++ b/src/gl/scene/gl_fakeflat.cpp @@ -0,0 +1,404 @@ +/* +** 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; + double bs_floorheight1; + double bs_floorheight2; + double bs_ceilingheight1; + double bs_ceilingheight2; + double fs_floorheight1; + double fs_floorheight2; + double fs_ceilingheight1; + double fs_ceilingheight2; + + // Mirrors and horizons always block the view + //if (linedef->special==Line_Mirror || linedef->special==Line_Horizon) return true; + + // Lines with portals must never block. + // Portals which require the sky flat are excluded here, because for them the special sky semantics apply. + if (!(frontsector->GetPortal(sector_t::ceiling)->mFlags & PORTSF_SKYFLATONLY) || + !(frontsector->GetPortal(sector_t::floor)->mFlags & PORTSF_SKYFLATONLY) || + !(backsector->GetPortal(sector_t::ceiling)->mFlags & PORTSF_SKYFLATONLY) || + !(backsector->GetPortal(sector_t::floor)->mFlags & PORTSF_SKYFLATONLY)) + { + 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.isSlope()) + { + fs_ceilingheight1 = frontsector->ceilingplane.ZatPoint(linedef->v1); + fs_ceilingheight2 = frontsector->ceilingplane.ZatPoint(linedef->v2); + } + else + { + fs_ceilingheight2 = fs_ceilingheight1 = frontsector->ceilingplane.fD(); + } + + if (frontsector->floorplane.isSlope()) + { + fs_floorheight1 = frontsector->floorplane.ZatPoint(linedef->v1); + fs_floorheight2 = frontsector->floorplane.ZatPoint(linedef->v2); + } + else + { + fs_floorheight2 = fs_floorheight1 = -frontsector->floorplane.fD(); + } + + if (backsector->ceilingplane.isSlope()) + { + bs_ceilingheight1 = backsector->ceilingplane.ZatPoint(linedef->v1); + bs_ceilingheight2 = backsector->ceilingplane.ZatPoint(linedef->v2); + } + else + { + bs_ceilingheight2 = bs_ceilingheight1 = backsector->ceilingplane.fD(); + } + + if (backsector->floorplane.isSlope()) + { + bs_floorheight1 = backsector->floorplane.ZatPoint(linedef->v1); + bs_floorheight2 = backsector->floorplane.ZatPoint(linedef->v2); + } + else + { + bs_floorheight2 = bs_floorheight1 = -backsector->floorplane.fD(); + } + + // 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; + + double cz1 = frontsector->ceilingplane.ZatPoint(v1); + double cz2 = frontsector->ceilingplane.ZatPoint(v2); + double fz1 = s->floorplane.ZatPoint(v1); + double fz2 = s->floorplane.ZatPoint(v2); + + // allow some tolerance in case slopes are involved + if (cz1 <= fz1 + 1. / 100 && cz2 <= fz2 + 1. / 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.isSlope() && !sec->ceilingplane.isSlope()) + { + *dest = *sec; + dest->ceilingplane=sec->floorplane; + dest->ceilingplane.FlipVert(); + dest->planes[sector_t::ceiling].TexZ = dest->planes[sector_t::floor].TexZ; + dest->ClearPortal(sector_t::ceiling); + dest->ClearPortal(sector_t::floor); + 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->ClearPortal(sector_t::ceiling); + + 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->ClearPortal(sector_t::floor); + + 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..9e9a73e5d --- /dev/null +++ b/src/gl/scene/gl_flats.cpp @@ -0,0 +1,815 @@ +/* +** 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 "portal.h" +#include "templates.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" +#include "gl/renderer/gl_quaddrawer.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->Offs.isZero() || + secplane->Scale.X != 1. || secplane->Scale.Y != 1 || + secplane->Angle != 0 || + gltexture->TextureWidth() != 64 || + gltexture->TextureHeight() != 64) + { + float uoffs = secplane->Offs.X / gltexture->TextureWidth(); + float voffs = secplane->Offs.Y / gltexture->TextureHeight(); + + float xscale1 = secplane->Scale.X; + float yscale1 = secplane->Scale.Y; + if (gltexture->tex->bHasCanvas) + { + yscale1 = 0 - yscale1; + } + float angle = -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 (renderstyle == STYLE_Add) return; // no lights on additively blended surfaces. + + 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 + double planeh = plane.plane.ZatPoint(light); + if (gl_lights_checkside && ((planehZ() && ceiling) || (planeh>light->Z() && !ceiling))) + { + node = node->nextLight; + continue; + } + + p.Set(plane.plane); + gl_GetLight(sub->sector->PortalGroup, p, light, 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) +{ + if (gl.buffermethod != BM_DEFERRED) + { + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (unsigned int k = 0; k < sub->numlines; k++) + { + vertex_t *vt = sub->firstline[k].v1; + ptr->x = vt->fX(); + ptr->z = plane.plane.ZatPoint(vt) + dz; + ptr->y = vt->fY(); + ptr->u = vt->fX() / 64.f; + ptr->v = -vt->fY() / 64.f; + ptr++; + } + GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_FAN); + } + else + { + // if we cannot access the buffer, use the quad drawer as fallback by splitting the subsector into quads. + // Trying to get this into the vertex buffer in the processing pass is too costly and this is only used for render hacks. + FQuadDrawer qd; + unsigned int vi[4]; + + vi[0] = 0; + for (unsigned int i = 1; i < sub->numlines-1; i += 2) + { + if (i < sub->numlines - 3) + { + for (unsigned int j = 1; j < 4; j++) + { + vi[j] = MIN(i + j, sub->numlines - 1); + } + for (unsigned int x = 0; x < 4; x++) + { + vertex_t *vt = sub->firstline[vi[x]].v1; + qd.Set(x, vt->fX(), plane.plane.ZatPoint(vt) + dz, vt->fY(), vt->fX() / 64.f, -vt->fY() / 64.f); + } + qd.Render(GL_TRIANGLE_FAN); + } + } + } + + flatvertices += sub->numlines; + flatprimitives++; +} + + +//========================================================================== +// +// this is only used by LM_DEFERRED +// +//========================================================================== + +void GLFlat::ProcessLights(bool istrans) +{ + dynlightindex = GLRenderer->mLights->GetIndexPtr(); + + // 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 (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 + // (can this case even happen?) + 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; + } + } +} + + +//========================================================================== +// +// special handling for skyboxes which need texture clamping. +// This will find the bounding rectangle of the sector and just +// draw one single polygon filling that rectangle with a clamped +// texture. +// +//========================================================================== + +void GLFlat::DrawSkyboxSector(int pass, bool processlights) +{ + + float minx = FLT_MAX, miny = FLT_MAX; + float maxx = -FLT_MAX, maxy = -FLT_MAX; + + for (int i = 0; i < sector->linecount; i++) + { + line_t *ln = sector->lines[i]; + float x = ln->v1->fX(); + float y = ln->v1->fY(); + if (x < minx) minx = x; + if (y < miny) miny = y; + if (x > maxx) maxx = x; + if (y > maxy) maxy = y; + x = ln->v2->fX(); + y = ln->v2->fY(); + if (x < minx) minx = x; + if (y < miny) miny = y; + if (x > maxx) maxx = x; + if (y > maxy) maxy = y; + } + + float z = plane.plane.ZatPoint(0., 0.) + dz; + static float uvals[] = { 0, 0, 1, 1 }; + static float vvals[] = { 1, 0, 0, 1 }; + int rot = -xs_FloorToInt(plane.Angle / 90.f); + + FQuadDrawer qd; + + qd.Set(0, minx, z, miny, uvals[rot & 3], vvals[rot & 3]); + qd.Set(1, minx, z, maxy, uvals[(rot + 1) & 3], vvals[(rot + 1) & 3]); + qd.Set(2, maxx, z, maxy, uvals[(rot + 2) & 3], vvals[(rot + 2) & 3]); + qd.Set(3, maxx, z, miny, uvals[(rot + 3) & 3], vvals[(rot + 3) & 3]); + qd.Render(GL_TRIANGLE_FAN); + + flatvertices += 4; + flatprimitives++; +} + + +//========================================================================== +// +// +// +//========================================================================== +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: // Same, but also creates the dynlight data. + gl_SetColor(lightlevel, rel, Colormap,1.0f); + gl_SetFog(lightlevel, rel, &Colormap, false); + if (sector->special != GLSector_Skybox) + { + 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); + } + else + { + gl_RenderState.SetMaterial(gltexture, CLAMP_XY, 0, -1, false); + DrawSkyboxSector(pass, (pass == GLPASS_ALL || dynlightindex > -1)); + } + 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, !gl.legacyMode, true); + gl_RenderState.EnableTextureMatrix(false); + } + if (renderstyle==STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + break; + + case GLPASS_LIGHTTEX: + case GLPASS_LIGHTTEX_ADDITIVE: + case GLPASS_LIGHTTEX_FOGGY: + DrawLightsCompat(pass); + break; + + case GLPASS_TEXONLY: + gl_RenderState.SetMaterial(gltexture, CLAMP_NONE, 0, -1, false); + gl_SetPlaneTextureRotation(&plane, gltexture); + DrawSubsectors(pass, false, false); + gl_RenderState.EnableTextureMatrix(false); + 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 (gl.legacyMode) + { + if (PutFlatCompat(fog)) return; + } + 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; + } + dynlightindex = -1; // make sure this is always initialized to something proper. + 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) + { + 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 = gl_ClampLight(*light->p_lightlevel); + + if (rover->flags & FF_FOG) Colormap.LightColor = (light->extra_colormap)->Fade; + else Colormap.CopyFrom3DLight(light); + + + 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; + FSectorPortal *port; + +#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; + dynlightindex = -1; + + byte &srf = gl_drawinfo->sectorrenderflags[sector->sectornum]; + + // + // + // + // do floors + // + // + // + if (frontsector->floorplane.ZatPoint(ViewPos) <= ViewPos.Z) + { + // process the original floor first. + + srf |= SSRF_RENDERFLOOR; + + lightlevel = gl_ClampLight(frontsector->GetFloorLight()); + Colormap = frontsector->ColorMap; + port = frontsector->ValidatePortal(sector_t::floor); + if ((stack = (port != NULL))) + { + if (port->mType == PORTS_STACKEDSECTORTHING) + { + gl_drawinfo->AddFloorStack(sector); // stacked sector things require visplane merging. + } + alpha = frontsector->GetAlpha(sector_t::floor); + } + else + { + alpha = 1.0f - frontsector->GetReflect(sector_t::floor); + } + + if (alpha != 0.f && frontsector->GetTexture(sector_t::floor) != skyflatnum) + { + 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->lightsource == NULL) + && (light->p_lightlevel != &frontsector->lightlevel)) + { + lightlevel = gl_ClampLight(*light->p_lightlevel); + } + + Colormap.CopyFrom3DLight(light); + } + renderstyle = STYLE_Translucent; + Process(frontsector, false, false); + } + } + + // + // + // + // do ceilings + // + // + // + if (frontsector->ceilingplane.ZatPoint(ViewPos) >= ViewPos.Z) + { + // process the original ceiling first. + + srf |= SSRF_RENDERCEILING; + + lightlevel = gl_ClampLight(frontsector->GetCeilingLight()); + Colormap = frontsector->ColorMap; + port = frontsector->ValidatePortal(sector_t::ceiling); + if ((stack = (port != NULL))) + { + if (port->mType == PORTS_STACKEDSECTORTHING) + { + gl_drawinfo->AddCeilingStack(sector); + } + alpha = frontsector->GetAlpha(sector_t::ceiling); + } + else + { + alpha = 1.0f - frontsector->GetReflect(sector_t::ceiling); + } + + if (alpha != 0.f && frontsector->GetTexture(sector_t::ceiling) != skyflatnum) + { + 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 = gl_ClampLight(*light->p_lightlevel); + } + Colormap.CopyFrom3DLight(light); + } + renderstyle = STYLE_Translucent; + 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! + double lastceilingheight = sector->CenterCeiling(); // render only in the range of the + double 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)) + { + double ff_top = rover->top.plane->ZatPoint(sector->centerspot); + if (ff_top < lastceilingheight) + { + if (ViewPos.Z <= rover->top.plane->ZatPoint(ViewPos)) + { + 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)) + { + double ff_bottom = rover->bottom.plane->ZatPoint(sector->centerspot); + if (ff_bottom < lastceilingheight) + { + if (ViewPos.Z <= rover->bottom.plane->ZatPoint(ViewPos)) + { + 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 += EQUAL_EPSILON; + } + } + } + } + + 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)) + { + double ff_bottom = rover->bottom.plane->ZatPoint(sector->centerspot); + if (ff_bottom > lastfloorheight || (rover->flags&FF_FIX)) + { + if (ViewPos.Z >= rover->bottom.plane->ZatPoint(ViewPos)) + { + 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)) + { + double ff_top = rover->top.plane->ZatPoint(sector->centerspot); + if (ff_top > lastfloorheight) + { + if (ViewPos.Z >= rover->top.plane->ZatPoint(ViewPos)) + { + 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 -= EQUAL_EPSILON; + } + } + } + } + } +} + diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp new file mode 100644 index 000000000..bd60713b6 --- /dev/null +++ b/src/gl/scene/gl_portal.cpp @@ -0,0 +1,1270 @@ +/* +** 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 "r_sky.h" +#include "portal.h" +#include "p_maputl.h" +#include "d_player.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/renderer/gl_quaddrawer.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) + +extern bool r_showviewer; + +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; +UniqueList UniqueLineToLines; + +void gl_RenderActorsInPortal(FGLLinePortal *glport); + +//========================================================================== +// +// +// +//========================================================================== + +void GLPortal::BeginScene() +{ + UniqueSkies.Clear(); + UniqueHorizons.Clear(); + UniquePlaneMirrors.Clear(); + UniqueLineToLines.Clear(); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLPortal::ClearScreen() +{ + bool multi = !!glIsEnabled(GL_MULTISAMPLE); + gl_MatrixStack.Push(gl_RenderState.mViewMatrix); + gl_MatrixStack.Push(gl_RenderState.mProjectionMatrix); + + gl_RenderState.mViewMatrix.loadIdentity(); + gl_RenderState.mProjectionMatrix.ortho(0, SCREENWIDTH, SCREENHEIGHT, 0, -1.0f, 1.0f); + gl_RenderState.ApplyMatrices(); + + glDisable(GL_MULTISAMPLE); + glDisable(GL_DEPTH_TEST); + + glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::FULLSCREEN_INDEX, 4); + + glEnable(GL_DEPTH_TEST); + gl_MatrixStack.Pop(gl_RenderState.mProjectionMatrix); + gl_MatrixStack.Pop(gl_RenderState.mViewMatrix); + gl_RenderState.ApplyMatrices(); + if (multi) glEnable(GL_MULTISAMPLE); +} + +//----------------------------------------------------------------------------- +// +// DrawPortalStencil +// +//----------------------------------------------------------------------------- +void GLPortal::DrawPortalStencil() +{ + if (mPrimIndices.Size() == 0) + { + mPrimIndices.Resize(2 * lines.Size()); + + for (unsigned int i = 0; i < lines.Size(); i++) + { + if (gl.buffermethod != BM_DEFERRED) lines[i].MakeVertices(false); + mPrimIndices[i * 2] = lines[i].vertindex; + mPrimIndices[i * 2 + 1] = lines[i].vertcount; + } + } + gl_RenderState.Apply(); + for (unsigned int i = 0; i < mPrimIndices.Size(); i += 2) + { + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, mPrimIndices[i], mPrimIndices[i + 1]); + } + if (NeedCap() && lines.Size() > 1) + { + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILTOP_INDEX, 4); + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILBOTTOM_INDEX, 4); + } +} + + + + + + +//----------------------------------------------------------------------------- +// +// 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 && doquery) 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; + + if (QueryObject) + { + 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); + } + } + + // save viewpoint + savedViewPos = ViewPos; + savedAngle = ViewAngle; + savedviewactor=GLRenderer->mViewActor; + savedviewarea=in_area; + savedviewpath[0] = ViewPath[0]; + savedviewpath[1] = ViewPath[1]; + savedvisibility = camera ? camera->renderflags & RF_INVISIBLE : ActorRenderFlags::FromInt(0); + + + PrevPortal = GLRenderer->mCurrentPortal; + PrevClipPortal = GLRenderer->mClipPortal; + GLRenderer->mClipPortal = NULL; // Portals which need this have to set it themselves + GLRenderer->mCurrentPortal = this; + + if (PrevPortal != NULL) PrevPortal->PushState(); + PortalAll.Unclock(); + return true; +} + + +inline void GLPortal::ClearClipper() +{ + DAngle angleOffset = deltaangle(savedAngle, ViewAngle); + + clipper.Clear(); + + static int call=0; + + // Set the clipper to the minimal visible area + clipper.SafeAddClipRange(0,0xffffffff); + for (unsigned int i = 0; i < lines.Size(); i++) + { + DAngle startAngle = (DVector2(lines[i].glseg.x2, lines[i].glseg.y2) - savedViewPos).Angle() + angleOffset; + DAngle endAngle = (DVector2(lines[i].glseg.x1, lines[i].glseg.y1) - savedViewPos).Angle() + angleOffset; + + if (deltaangle(endAngle, startAngle) < 0) + { + clipper.SafeRemoveClipRangeRealAngles(startAngle.BAMs(), endAngle.BAMs()); + } + } + + // and finally clip it to the visible area + angle_t a1 = GLRenderer->FrustumAngle(); + if (a1 < ANGLE_180) clipper.SafeAddClipRangeRealAngles(ViewAngle.BAMs() + a1, ViewAngle.BAMs() - a1); + + // lock the parts that have just been clipped out. + clipper.SetSilhouette(); +} + +//----------------------------------------------------------------------------- +// +// End +// +//----------------------------------------------------------------------------- +void GLPortal::End(bool usestencil) +{ + bool needdepth = NeedDepthBuffer(); + + PortalAll.Clock(); + if (PrevPortal != NULL) PrevPortal->PopState(); + GLRenderer->mCurrentPortal = PrevPortal; + GLRenderer->mClipPortal = PrevClipPortal; + + if (usestencil) + { + if (needdepth) FDrawInfo::EndDrawInfo(); + + // Restore the old view + ViewPath[0] = savedviewpath[0]; + ViewPath[1] = savedviewpath[1]; + ViewPos = savedViewPos; + ViewAngle = savedAngle; + GLRenderer->mViewActor=savedviewactor; + in_area=savedviewarea; + if (camera != nullptr) camera->renderflags = (camera->renderflags & ~RF_INVISIBLE) | savedvisibility; + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, 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 + ViewPos = savedViewPos; + ViewAngle = savedAngle; + GLRenderer->mViewActor=savedviewactor; + in_area=savedviewarea; + if (camera != nullptr) camera->renderflags |= savedvisibility; + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, 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 severely 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++; + AActor *origin = portal->mSkybox; + portal->mFlags |= PORTSF_INSKYBOX; + extralight = 0; + + PlaneMirrorMode = 0; + + bool oldclamp = gl_RenderState.SetDepthClamp(false); + ViewPos = origin->InterpolatedPosition(r_TicFracF); + ViewAngle += (origin->PrevAngles.Yaw + deltaangle(origin->PrevAngles.Yaw, origin->Angles.Yaw) * r_TicFracF); + + // Don't let the viewpoint be too close to a floor or ceiling + double floorh = origin->Sector->floorplane.ZatPoint(origin->Pos()); + double ceilh = origin->Sector->ceilingplane.ZatPoint(origin->Pos()); + if (ViewPos.Z < floorh + 4) ViewPos.Z = floorh + 4; + if (ViewPos.Z > ceilh - 4) ViewPos.Z = ceilh - 4; + + GLRenderer->mViewActor = origin; + + inskybox = true; + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag & 1), !!(PlaneMirrorFlag & 1)); + GLRenderer->SetViewArea(); + ClearClipper(); + + int mapsection = R_PointInSubsector(ViewPos)->mapsection; + + SaveMapSection(); + currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); + + GLRenderer->DrawScene(DM_PORTAL); + portal->mFlags &= ~PORTSF_INSKYBOX; + 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; + + ViewPos += origin->mDisplacement; + GLRenderer->mViewActor = NULL; + + // avoid recursions! + if (origin->plane != -1) instack[origin->plane]++; + + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + SaveMapSection(); + SetupCoverage(); + ClearClipper(); + + // If the viewpoint is not within the portal, we need to invalidate the entire clip area. + // The portal will re-validate the necessary parts when its subsectors get traversed. + subsector_t *sub = R_PointInSubsector(ViewPos); + if (!(gl_drawinfo->ss_renderflags[sub - ::subsectors] & SSRF_SEEN)) + { + clipper.SafeAddClipRange(0, ANGLE_MAX); + clipper.SetBlocked(true); + } + + GLRenderer->DrawScene(DM_PORTAL); + 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; + + double planez = origin->ZatPoint(ViewPos); + ViewPos.Z = 2 * planez - ViewPos.Z; + GLRenderer->mViewActor = NULL; + PlaneMirrorMode = origin->fC() < 0 ? -1 : 1; + + PlaneMirrorFlag++; + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + ClearClipper(); + + gl_RenderState.SetClipHeight(planez, PlaneMirrorMode < 0? -1.f : 1.f); + GLRenderer->DrawScene(DM_PORTAL); + gl_RenderState.SetClipHeight(0.f, 0.f); + PlaneMirrorFlag--; + PlaneMirrorMode=old_pm; +} + +void GLPlaneMirrorPortal::PushState() +{ + planestack.Push(gl_RenderState.GetClipHeight()); + planestack.Push(gl_RenderState.GetClipHeightDirection()); + gl_RenderState.SetClipHeight(0.f, 0.f); +} + +void GLPlaneMirrorPortal::PopState() +{ + float d, f; + planestack.Pop(d); + planestack.Pop(f); + gl_RenderState.SetClipHeight(f, d); +} + +//----------------------------------------------------------------------------- +// +// Common code for line to line and mirror portals +// +//----------------------------------------------------------------------------- + +void GLLinePortal::PushState() +{ + FStateVec4 &v = gl_RenderState.GetClipLine(); + planestack.Push(v.vec[0]); + planestack.Push(v.vec[1]); + planestack.Push(v.vec[2]); + planestack.Push(v.vec[3]); + planestack.Push(gl_RenderState.GetClipLineState()); + gl_RenderState.EnableClipLine(false); +} + +void GLLinePortal::PopState() +{ + FStateVec4 &v = gl_RenderState.GetClipLine(); + float e; + planestack.Pop(e); + planestack.Pop(v.vec[3]); + planestack.Pop(v.vec[2]); + planestack.Pop(v.vec[1]); + planestack.Pop(v.vec[0]); + gl_RenderState.EnableClipLine(e != 0); +} + +int GLLinePortal::ClipSeg(seg_t *seg) +{ + line_t *linedef = seg->linedef; + if (!linedef) + { + return PClip_Inside; // should be handled properly. + } + return P_ClipLineToPortal(linedef, line(), ViewPos) ? PClip_InFront : PClip_Inside; +} + +int GLLinePortal::ClipSubsector(subsector_t *sub) +{ + // this seg is completely behind the mirror! + for(unsigned int i=0;inumlines;i++) + { + if (P_PointOnLineSidePrecise(sub->firstline[i].v1->fPos(), line()) == 0) return PClip_Inside; + } + return PClip_InFront; +} + +int GLLinePortal::ClipPoint(const DVector2 &pos) +{ + if (P_PointOnLineSidePrecise(pos, line())) + { + return PClip_InFront; + } + return PClip_Inside; +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Mirror Portal +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// +// R_EnterMirror +// +//----------------------------------------------------------------------------- +void GLMirrorPortal::DrawContents() +{ + if (renderdepth>r_mirror_recursions) + { + ClearScreen(); + return; + } + + GLRenderer->mClipPortal = this; + DAngle StartAngle = ViewAngle; + DVector3 StartPos = ViewPos; + + vertex_t *v1 = linedef->v1; + vertex_t *v2 = linedef->v2; + + // Reflect the current view behind the mirror. + if (linedef->Delta().X == 0) + { + // vertical mirror + ViewPos.X = 2 * v1->fX() - StartPos.X; + + // Compensation for reendering inaccuracies + if (StartPos.X < v1->fX()) ViewPos.X -= 0.1; + else ViewPos.X += 0.1; + } + else if (linedef->Delta().Y == 0) + { + // horizontal mirror + ViewPos.Y = 2*v1->fY() - StartPos.Y; + + // Compensation for reendering inaccuracies + if (StartPos.YfY()) ViewPos.Y -= 0.1; + else ViewPos.Y += 0.1; + } + else + { + // any mirror--use floats to avoid integer overflow. + // Use doubles to avoid losing precision which is very important here. + + double dx = v2->fX() - v1->fX(); + double dy = v2->fY() - v1->fY(); + double x1 = v1->fX(); + double y1 = v1->fY(); + double x = StartPos.X; + double y = StartPos.Y; + + // the above two cases catch len == 0 + double r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy); + + ViewPos.X = (x1 + r * dx)*2 - x; + ViewPos.Y = (y1 + r * dy)*2 - y; + + // Compensation for reendering inaccuracies + FVector2 v(-dx, dy); + v.MakeUnit(); + + ViewPos.X+= v[1] * renderdepth / 2; + ViewPos.Y+= v[0] * renderdepth / 2; + } + ViewAngle = linedef->Delta().Angle() * 2. - StartAngle; + + GLRenderer->mViewActor = NULL; + + MirrorFlag++; + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, 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); + + gl_RenderState.SetClipLine(linedef); + gl_RenderState.EnableClipLine(true); + GLRenderer->DrawScene(DM_PORTAL); + gl_RenderState.EnableClipLine(false); + + MirrorFlag--; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Line to line Portal +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- +void GLLineToLinePortal::DrawContents() +{ + // TODO: Handle recursion more intelligently + if (renderdepth>r_mirror_recursions) + { + ClearScreen(); + return; + } + + GLRenderer->mClipPortal = this; + + line_t *origin = glport->lines[0]->mOrigin; + P_TranslatePortalXY(origin, ViewPos.X, ViewPos.Y); + P_TranslatePortalAngle(origin, ViewAngle); + P_TranslatePortalZ(origin, ViewPos.Z); + P_TranslatePortalXY(origin, ViewPath[0].X, ViewPath[0].Y); + P_TranslatePortalXY(origin, ViewPath[1].X, ViewPath[1].Y); + if (!r_showviewer && camera != nullptr && P_PointOnLineSidePrecise(ViewPath[0], glport->lines[0]->mDestination) != P_PointOnLineSidePrecise(ViewPath[1], glport->lines[0]->mDestination)) + { + double distp = (ViewPath[0] - ViewPath[1]).Length(); + if (distp > EQUAL_EPSILON) + { + double dist1 = (ViewPos - ViewPath[0]).Length(); + double dist2 = (ViewPos - ViewPath[1]).Length(); + + if (dist1 + dist2 < distp + 1) + { + camera->renderflags |= RF_INVISIBLE; + } + } + } + + + SaveMapSection(); + + for (unsigned i = 0; i < lines.Size(); i++) + { + line_t *line = lines[i].seg->linedef->getPortalDestination(); + subsector_t *sub; + if (line->sidedef[0]->Flags & WALLF_POLYOBJ) + sub = R_PointInSubsector(line->v1->fixX(), line->v1->fixY()); + else sub = line->frontsector->subsectors[0]; + int mapsection = sub->mapsection; + currentmapsection[mapsection >> 3] |= 1 << (mapsection & 7); + } + + GLRenderer->mViewActor = nullptr; + GLRenderer->SetupView(ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1)); + + ClearClipper(); + gl_RenderState.SetClipLine(glport->lines[0]->mDestination); + gl_RenderState.EnableClipLine(true); + GLRenderer->DrawScene(DM_PORTAL); + gl_RenderState.EnableClipLine(false); + RestoreMapSection(); +} + +void GLLineToLinePortal::RenderAttached() +{ + gl_RenderActorsInPortal(glport); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// 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::GLHorizonPortal(GLHorizonInfo * pt, bool local) + : GLPortal(local) +{ + origin = pt; + + // create the vertex data for this horizon portal. + GLSectorPlane * sp = &origin->plane; + const float vx = ViewPos.X; + const float vy = ViewPos.Y; + const float vz = ViewPos.Z; + const float z = sp->Texheight; + const float tz = (z - vz); + + // Draw to some far away boundary + // This is not drawn as larger strips because it causes visual glitches. + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + for (float x = -32768 + vx; x<32768 + vx; x += 4096) + { + for (float y = -32768 + vy; y<32768 + vy; y += 4096) + { + 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++; + } + } + + // fill the gap between the polygon and the true horizon + // Since I can't draw into infinity there can always be a + // small gap + 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++; + + vcount = GLRenderer->mVBO->GetCount(ptr, &voffset) - 10; + +} + +//----------------------------------------------------------------------------- +// +// GLHorizonPortal::DrawContents +// +//----------------------------------------------------------------------------- +void GLHorizonPortal::DrawContents() +{ + PortalAll.Clock(); + + FMaterial * gltexture; + PalEntry color; + player_t * player=&players[consoleplayer]; + GLSectorPlane * sp = &origin->plane; + + gltexture=FMaterial::ValidateTexture(sp->texture, false, true); + if (!gltexture) + { + ClearScreen(); + PortalAll.Unclock(); + return; + } + gl_RenderState.SetCameraPos(ViewPos.X, ViewPos.Y, ViewPos.Z); + + + 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(); + + + for (unsigned i = 0; i < vcount; i += 4) + { + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, voffset + i, 4); + } + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, voffset + vcount, 10); + + gl_RenderState.EnableTextureMatrix(false); + PortalAll.Unclock(); + +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// +// +// Eternity-style horizon portal +// +// To the rest of the engine these masquerade as a skybox portal +// Internally they need to draw two horizon or sky portals +// and will use the respective classes to achieve that. +// +// +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void GLEEHorizonPortal::DrawContents() +{ + PortalAll.Clock(); + sector_t *sector = portal->mOrigin; + if (sector->GetTexture(sector_t::floor) == skyflatnum || + sector->GetTexture(sector_t::ceiling) == skyflatnum) + { + GLSkyInfo skyinfo; + skyinfo.init(sector->sky, 0); + GLSkyPortal sky(&skyinfo, true); + sky.DrawContents(); + } + if (sector->GetTexture(sector_t::ceiling) != skyflatnum) + { + GLHorizonInfo horz; + horz.plane.GetFromSector(sector, true); + horz.lightlevel = gl_ClampLight(sector->GetCeilingLight()); + horz.colormap = sector->ColorMap; + if (portal->mType == PORTS_PLANE) + { + horz.plane.Texheight = ViewPos.Z + fabs(horz.plane.Texheight); + } + GLHorizonPortal ceil(&horz, true); + ceil.DrawContents(); + } + if (sector->GetTexture(sector_t::floor) != skyflatnum) + { + GLHorizonInfo horz; + horz.plane.GetFromSector(sector, false); + horz.lightlevel = gl_ClampLight(sector->GetFloorLight()); + horz.colormap = sector->ColorMap; + if (portal->mType == PORTS_PLANE) + { + horz.plane.Texheight = ViewPos.Z - fabs(horz.plane.Texheight); + } + GLHorizonPortal floor(&horz, true); + floor.DrawContents(); + } + + + +} + +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 *GLLineToLinePortal::GetName() { return "LineToLine"; } +const char *GLHorizonPortal::GetName() { return "Horizon"; } +const char *GLEEHorizonPortal::GetName() { return "EEHorizon"; } + diff --git a/src/gl/scene/gl_portal.h b/src/gl/scene/gl_portal.h new file mode 100644 index 000000000..fbd3a0c7f --- /dev/null +++ b/src/gl/scene/gl_portal.h @@ -0,0 +1,404 @@ +/* +** 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" +#include "gl/data/gl_data.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)); + } + void init(int sky1, PalEntry fadecolor); +}; + +extern UniqueList UniqueSkies; +extern UniqueList UniqueHorizons; +extern UniqueList UniquePlaneMirrors; +extern UniqueList UniqueLineToLines; +struct GLEEHorizonPortal; + +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(); + + DVector3 savedViewPos; + DAngle savedAngle; + AActor * savedviewactor; + area_t savedviewarea; + ActorRenderFlags savedvisibility; + DVector3 savedviewpath[2]; + GLPortal *PrevPortal; + GLPortal *PrevClipPortal; + TArray savedmapsection; + TArray mPrimIndices; + +protected: + TArray lines; + int level; + + GLPortal(bool local = false) { if (!local) 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(); + virtual void PushState() {} + virtual void PopState() {} + +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 ClipSubsector(subsector_t *sub) { return PClip_Inside; } + virtual int ClipPoint(const DVector2 &pos) { return PClip_Inside; } + virtual line_t *ClipLine() { return NULL; } + virtual void RenderAttached() {} + + static void BeginScene(); + static void StartFrame(); + static bool RenderFirstSkyPortal(int recursion); + static void EndFrame(); + static GLPortal * FindPortal(const void * src); +}; + +struct GLLinePortal : public GLPortal +{ + // this must be the same as at the start of line_t, so that we can pass in this structure directly to P_ClipLineToPortal. + vertex_t *v1, *v2; // vertices, from v1 to v2 + DVector2 delta; // precalculated v2 - v1 for side checking + + angle_t angv1, angv2; // for quick comparisons with a line or subsector + + GLLinePortal(line_t *line) + { + v1 = line->v1; + v2 = line->v2; + CalcDelta(); + } + + GLLinePortal(FGLLinePortal *line) + { + if (line->lines[0]->mType != PORTT_LINKED || line->v1 == nullptr) + { + // For non-linked portals we must check the actual linedef. + line_t *lline = line->lines[0]->mDestination; + v1 = lline->v1; + v2 = lline->v2; + } + else + { + // For linked portals we can check the merged span. + v1 = line->v1; + v2 = line->v2; + } + CalcDelta(); + } + + void CalcDelta() + { + delta = v2->fPos() - v1->fPos(); + } + + line_t *line() + { + vertex_t **pv = &v1; + return reinterpret_cast(pv); + } + + virtual int ClipSeg(seg_t *seg); + virtual int ClipSubsector(subsector_t *sub); + virtual int ClipPoint(const DVector2 &pos); + virtual bool NeedCap() { return false; } + virtual void PushState(); + virtual void PopState(); +}; + + +struct GLMirrorPortal : public GLLinePortal +{ + // 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) + : GLLinePortal(line) + { + linedef=line; + } +}; + + +struct GLLineToLinePortal : public GLLinePortal +{ + FGLLinePortal *glport; +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return glport; } + virtual const char *GetName(); + virtual line_t *ClipLine() { return line(); } + virtual void RenderAttached(); + +public: + + GLLineToLinePortal(FGLLinePortal *ll) + : GLLinePortal(ll) + { + glport = ll; + } +}; + + +struct GLSkyboxPortal : public GLPortal +{ + FSectorPortal * portal; + +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return portal; } + virtual bool IsSky() { return true; } + virtual const char *GetName(); + +public: + + + GLSkyboxPortal(FSectorPortal * pt) + { + portal=pt; + } + +}; + + +struct GLSkyPortal : public GLPortal +{ + GLSkyInfo * origin; + friend struct GLEEHorizonPortal; + +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, bool local = false) + : GLPortal(local) + { + 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(); + virtual void PushState(); + virtual void PopState(); + secplane_t * origin; + +public: + + GLPlaneMirrorPortal(secplane_t * pt) + { + origin=pt; + } + +}; + + +struct GLHorizonPortal : public GLPortal +{ + GLHorizonInfo * origin; + unsigned int voffset; + unsigned int vcount; + friend struct GLEEHorizonPortal; + +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, bool local = false); +}; + +struct GLEEHorizonPortal : public GLPortal +{ + FSectorPortal * portal; + +protected: + virtual void DrawContents(); + virtual void * GetSource() const { return portal; } + virtual bool NeedDepthBuffer() { return false; } + virtual bool NeedCap() { return false; } + virtual const char *GetName(); + +public: + + GLEEHorizonPortal(FSectorPortal *pt) + { + portal=pt; + } + +}; + +#endif diff --git a/src/gl/scene/gl_renderhacks.cpp b/src/gl/scene/gl_renderhacks.cpp new file mode 100644 index 000000000..150ad1554 --- /dev/null +++ b/src/gl/scene/gl_renderhacks.cpp @@ -0,0 +1,1228 @@ +/* +** 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, float Backheight) +{ + if (!side->segs[0]->backsector) return; + + totalms.Clock(); + for (int i = 0; i < side->numsegs; 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; i < MissingUpperTextures.Size(); i++) + { + if (MissingUpperTextures[i].sub == sub) + { + // Use the lowest adjoining height to draw a fake ceiling if necessary + if (Backheight < MissingUpperTextures[i].Planez) + { + MissingUpperTextures[i].Planez = Backheight; + MissingUpperTextures[i].seg = seg; + } + + msi.MTI_Index = i; + msi.seg = seg; + MissingUpperSegs.Push(msi); + totalms.Unclock(); + return; + } + } + mti.seg = seg; + mti.sub = sub; + mti.Planez = Backheight; + msi.MTI_Index = MissingUpperTextures.Push(mti); + msi.seg = seg; + MissingUpperSegs.Push(msi); + } + } + totalms.Unclock(); +} + +//========================================================================== +// +// Collects all sectors that might need a fake floor +// +//========================================================================== +void FDrawInfo::AddLowerMissingTexture(side_t * side, subsector_t *sub, float Backheight) +{ + sector_t *backsec = side->segs[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; i < side->numsegs; 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.Size(); i++) + { + if (MissingLowerTextures[i].sub == sub) + { + // Use the highest adjoining height to draw a fake floor if necessary + if (Backheight > 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, float 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.isSlope()) return false; + + // Is the neighboring ceiling lower 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 + if (sec->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, float 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.isSlope()) 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, float 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.isSlope()) 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 + // No texture checks though! + if (sec->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, float 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.isSlope()) 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 < MissingUpperTextures.Size(); i++) + { + if (!MissingUpperTextures[i].seg) continue; + HandledSubsectors.Clear(); + validcount++; + + if (MissingUpperTextures[i].Planez > ViewPos.Z) + { + // 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; j < HandledSubsectors.Size(); j++) + { + gl_subsectorrendernode * node = SSR_List.GetNew(); + node->sub = 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; j < HandledSubsectors.Size(); j++) + { + for (unsigned int k = 0; k < MissingUpperTextures.Size(); k++) + { + if (MissingUpperTextures[k].sub == HandledSubsectors[j]) + { + MissingUpperTextures[k].seg = NULL; + } + } + } + } + else MissingUpperTextures[i].seg = NULL; + continue; + } + } + + if (!MissingUpperTextures[i].seg->PartnerSeg) 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); + float planez = (float)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; j < HandledSubsectors.Size(); j++) + { + gl_subsectorrendernode * node = SSR_List.GetNew(); + node->sub = HandledSubsectors[j]; + AddOtherCeilingPlane(fakesector->sectornum, node); + } + } + continue; + } + } + + for (unsigned int i = 0; i < MissingLowerTextures.Size(); i++) + { + if (!MissingLowerTextures[i].seg) continue; + HandledSubsectors.Clear(); + validcount++; + + if (MissingLowerTextures[i].Planez < ViewPos.Z) + { + // close the hole only if all neighboring sectors are an exact height match + // Otherwise just fill in the missing textures. + MissingLowerTextures[i].sub->validcount = 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; j < HandledSubsectors.Size(); j++) + { + gl_subsectorrendernode * node = SSR_List.GetNew(); + node->sub = 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; j < HandledSubsectors.Size(); j++) + { + for (unsigned int k = 0; k < MissingLowerTextures.Size(); k++) + { + if (MissingLowerTextures[k].sub == HandledSubsectors[j]) + { + MissingLowerTextures[k].seg = NULL; + } + } + } + } + else MissingLowerTextures[i].seg = NULL; + continue; + } + } + + if (!MissingLowerTextures[i].seg->PartnerSeg) 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); + float planez = (float)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; j < HandledSubsectors.Size(); j++) + { + gl_subsectorrendernode * node = SSR_List.GetNew(); + node->sub = 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) < ViewPos.Z) continue; // out of sight + + // 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->ValidatePortal(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; + + 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) > ViewPos.Z) continue; // out of sight + if (seg->backsector->transdoor) continue; + if (seg->backsector->GetTexture(sector_t::floor) == skyflatnum) continue; + if (seg->backsector->ValidatePortal(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 && ViewPos.Z < anchor->GetPlaneTexZ(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(ViewPos); + + // 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->GetGLPortal(sector_t::ceiling) != nullptr) 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->planes[sector_t::ceiling].xform != anchor->planes[sector_t::ceiling].xform) + { + // 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->GetGLPortal(sector_t::floor) != nullptr) 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->planes[sector_t::floor].xform != anchor->planes[sector_t::floor].xform) + { + // 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;iGetGLPortal(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->mDisplacement); + } + + portal->GetRenderState()->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;iGetGLPortal(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->mDisplacement); + } + + GLSectorStackPortal *glportal = portal->GetRenderState(); + 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..48d4fb7ff --- /dev/null +++ b/src/gl/scene/gl_scene.cpp @@ -0,0 +1,1409 @@ +/* +** 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/renderer/gl_renderbuffers.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_translate.h" +#include "gl/textures/gl_material.h" +#include "gl/textures/gl_skyboxtexture.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 (Bool, cl_capfps) +EXTERN_CVAR (Bool, r_deathcamera) + + +extern int viewpitch; +extern bool NoInterpolateView; +extern bool r_showviewer; + +DWORD gl_fixedcolormap; +area_t in_area; +TArray currentmapsection; + +void gl_ParseDefs(); + +//----------------------------------------------------------------------------- +// +// R_FrustumAngle +// +//----------------------------------------------------------------------------- +angle_t FGLRenderer::FrustumAngle() +{ + float tilt= fabs(mAngles.Pitch.Degrees); + + // 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 = DAngle(floatangle).BAMs(); + 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(ViewPos)->render_sector; + + // Get the heightsec state from the render sector, not the current one! + if (viewsector->heightsec && !(viewsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) + { + in_area = ViewPos.Z <= viewsector->heightsec->floorplane.ZatPoint(ViewPos) ? area_below : + (ViewPos.Z > viewsector->heightsec->ceilingplane.ZatPoint(ViewPos) && + !(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::Reset3DViewport() +{ + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); +} + +//----------------------------------------------------------------------------- +// +// sets 3D viewport and initial state +// +//----------------------------------------------------------------------------- + +void FGLRenderer::Set3DViewport(bool mainview) +{ + if (mainview && mBuffers->Setup(mScreenViewport.width, mScreenViewport.height, mSceneViewport.width, mSceneViewport.height)) + { + mBuffers->BindSceneFB(); + } + + // Always clear all buffers with scissor test disabled. + // This is faster on newer hardware because it allows the GPU to skip + // reading from slower memory where the full buffers are stored. + glDisable(GL_SCISSOR_TEST); + glClearColor(mSceneClearColor[0], mSceneClearColor[1], mSceneClearColor[2], 1.0f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + const auto &bounds = mSceneViewport; + glViewport(bounds.left, bounds.top, bounds.width, bounds.height); + glScissor(bounds.left, bounds.top, bounds.width, bounds.height); + + glEnable(GL_SCISSOR_TEST); + + 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(DAngle viewangle) +{ + mAngles.Yaw = float(270.0-viewangle.Degrees); + DVector2 v = ViewAngle.ToVector(); + mViewVector.X = v.X; + mViewVector.Y = v.Y; + + 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); +} + +// raw matrix input from stereo 3d modes +void FGLRenderer::SetProjection(VSMatrix matrix) +{ + gl_RenderState.mProjectionMatrix.loadIdentity(); + gl_RenderState.mProjectionMatrix.multMatrix(matrix); +} + +//----------------------------------------------------------------------------- +// +// Setup the modelview matrix +// +//----------------------------------------------------------------------------- + +void FGLRenderer::SetViewMatrix(float vx, float vy, float vz, 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.Degrees, 0.0f, 0.0f, 1.0f); + gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Pitch.Degrees, 1.0f, 0.0f, 0.0f); + gl_RenderState.mViewMatrix.rotate(GLRenderer->mAngles.Yaw.Degrees, 0.0f, mult, 0.0f); + gl_RenderState.mViewMatrix.translate(vx * mult, -vz * planemult , -vy); + gl_RenderState.mViewMatrix.scale(-mult, planemult, 1); +} + + +//----------------------------------------------------------------------------- +// +// SetupView +// Setup the view rotation matrix for the given viewpoint +// +//----------------------------------------------------------------------------- +void FGLRenderer::SetupView(float vx, float vy, float vz, DAngle va, bool mirror, bool planemirror) +{ + SetViewAngle(va); + SetViewMatrix(vx, vy, vz, 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(); + GLRenderer->mVBO->Map(); + R_SetView(); + validcount++; // used for processing sidedefs only once by the renderer. + gl_RenderBSPNode (nodes + numnodes - 1); + if (GLRenderer->mCurrentPortal != NULL) GLRenderer->mCurrentPortal->RenderAttached(); + 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 + GLRenderer->mVBO->Unmap(); + + 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(ViewPos.X, ViewPos.Y, ViewPos.Z); + + 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. + bool haslights = mLightCount > 0 && gl_fixedcolormap == CM_DEFAULT && gl_lights; + if (gl.lightmethod == LM_DEFERRED && haslights) + { + 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 (!haslights || gl.lightmethod == LM_DEFERRED) + { + pass = GLPASS_PLAIN; + } + else if (gl.lightmethod == LM_DIRECT) + { + pass = GLPASS_ALL; + } + else + { + // process everything that needs to handle textured dynamic lights. + if (haslights) RenderMultipassStuff(); + + // The remaining lists which are unaffected by dynamic lights are just processed as normal. + 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(); + if (gl.legacyMode) + { + // also process the render lists with walls and dynamic lights + gl_drawinfo->dldrawlists[GLLDL_WALLS_PLAIN].DrawDecals(); + gl_drawinfo->dldrawlists[GLLDL_WALLS_FOG].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(ViewPos.X, ViewPos.Y, ViewPos.Z); + + // 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! +// +//----------------------------------------------------------------------------- + +void FGLRenderer::DrawScene(int drawmode) +{ + static int recursion=0; + + if (camera != nullptr) + { + ActorRenderFlags savedflags = camera->renderflags; + if (drawmode != DM_PORTAL && !r_showviewer) + { + camera->renderflags |= RF_INVISIBLE; + } + CreateScene(); + camera->renderflags = savedflags; + } + else + { + CreateScene(); + } + GLRenderer->mClipPortal = NULL; // this must be reset before any portal recursion takes place. + + RenderScene(recursion); + + // Handle all portals after rendering the opaque objects but before + // doing all translucent stuff + recursion++; + GLPortal::EndFrame(); + recursion--; + RenderTranslucent(); +} + + +void gl_FillScreen() +{ + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.EnableTexture(false); + gl_RenderState.Apply(); + // The fullscreen quad is stored at index 4 in the main vertex buffer. + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, FFlatVertexBuffer::FULLSCREEN_INDEX, 4); +} + +//========================================================================== +// +// 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++) + { + double lightbottom; + if (i < lightlist.Size() - 1) + lightbottom = lightlist[i + 1].plane.ZatPoint(ViewPos); + else + lightbottom = viewsector->floorplane.ZatPoint(ViewPos); + + if (lightbottom < ViewPos.Z && (!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); + gl_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); + } + + gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if (blend[3]>0.0f) + { + gl_RenderState.SetColor(blend[0], blend[1], blend[2], blend[3]); + gl_FillScreen(); + } + gl_RenderState.ResetColor(); + gl_RenderState.EnableTexture(true); +} + + +//----------------------------------------------------------------------------- +// +// 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); + + Reset3DViewport(); + // [BB] Only draw the sprites if we didn't render a HUD model before. + if ( renderHUDModel == false ) + { + DrawPlayerSprites (viewsector, false); + } + if (gl.legacyMode) + { + gl_RenderState.DrawColormapOverlay(); + } + + gl_RenderState.SetFixedColormap(CM_DEFAULT); + gl_RenderState.SetSoftLightLevel(-1); + DrawTargeterSprites(); + if (!FGLRenderBuffers::IsEnabled()) + { + 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(ViewPos)->mapsection; + memset(¤tmapsection[0], 0, currentmapsection.Size()); + currentmapsection[mapsection>>3] |= 1 << (mapsection & 7); + DrawScene(toscreen ? DM_MAINVIEW : DM_OFFSCREEN); + 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 * lviewsector; + mSceneClearColor[0] = 0.0f; + mSceneClearColor[1] = 0.0f; + mSceneClearColor[2] = 0.0f; + 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 = ViewPitch.Normalized180().Radians(); + 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.Degrees = ViewRoll.Degrees; + + // 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; + } + + if (toscreen) + { + if (gl_exposure == 0.0f) + { + float light = viewsector->lightlevel / 255.0f; + float exposure = MAX(1.0f + (1.0f - light * light) * 0.9f, 0.5f); + mCameraExposure = mCameraExposure * 0.995f + exposure * 0.005f; + } + else + { + mCameraExposure = gl_exposure; + } + } + + // 'viewsector' will not survive the rendering so it cannot be used anymore below. + lviewsector = viewsector; + + // Render (potentially) multiple views for stereo 3d + float viewShift[3]; + const s3d::Stereo3DMode& stereo3dMode = mainview && toscreen? s3d::Stereo3DMode::getCurrentMode() : s3d::Stereo3DMode::getMonoMode(); + 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. + SetOutputViewport(bounds); + Set3DViewport(mainview); + mDrawingScene2D = true; + 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 ViewPos + eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift); + s3d::ScopedViewShifter viewShifter(viewShift); + SetViewMatrix(ViewPos.X, ViewPos.Y, ViewPos.Z, false, false); + gl_RenderState.ApplyMatrices(); + + clipper.Clear(); + angle_t a1 = FrustumAngle(); + clipper.SafeAddClipRangeRealAngles(ViewAngle.BAMs() + a1, ViewAngle.BAMs() - a1); + + ProcessScene(toscreen); + if (mainview && toscreen) EndDrawScene(lviewsector); // do not call this for camera textures. + if (mainview && FGLRenderBuffers::IsEnabled()) + { + mBuffers->BlitSceneToTexture(); + BloomScene(); + TonemapScene(); + ColormapScene(); + LensDistortScene(); + + // This should be done after postprocessing, not before. + mBuffers->BindCurrentFB(); + glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); + DrawBlend(lviewsector); + } + mDrawingScene2D = false; + eye->TearDown(); + } + stereo3dMode.TearDown(); + + gl_frameCount++; // This counter must be increased right before the interpolations are restored. + interpolator.RestoreInterpolations (); + return lviewsector; +} + +//----------------------------------------------------------------------------- +// +// 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_TicFracF = 1.; + else r_TicFracF = I_GetTimeFrac (&r_FrameTime); + gl_frameMS = I_MSTime(); + + P_FindParticleSubsectors (); + + if (!gl.legacyMode) GLRenderer->mLights->Clear(); + + // NoInterpolateView should have no bearing on camera textures, but needs to be preserved for the main view below. + bool saved_niv = NoInterpolateView; + NoInterpolateView = false; + // prepare all camera textures that have been used in the last frame + FCanvasTextureInfo::UpdateAll(); + NoInterpolateView = saved_niv; + + + // 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, 1.7f, 2.333333f}; + + // now render the main view + float fovratio; + float ratio = ratios[WidescreenRatio]; + if (! Is54Aspect(WidescreenRatio)) + { + 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.Degrees, 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(); + if (!gl.legacyMode) 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.Degrees, 1.6f, 1.6f, true, false); + glDisable(GL_STENCIL_TEST); + gl_RenderState.SetFixedColormap(CM_DEFAULT); + gl_RenderState.SetSoftLightLevel(-1); + screen->Begin2D(false); + if (!FGLRenderBuffers::IsEnabled()) + { + DrawBlend(viewsector); + } + CopyToBackbuffer(&bounds, false); + 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 PrecacheSprite(FTexture *tex, SpriteHits &hits); + void Precache(BYTE *texhitlist, TMap &actorhitlist); + 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 (cache & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky)) + { + FMaterial * gltex = FMaterial::ValidateTexture(tex, false); + if (gltex) gltex->Precache(); + } +} + +//========================================================================== +// +// DFrameBuffer :: PrecacheSprite +// +//========================================================================== + +void FGLInterface::PrecacheSprite(FTexture *tex, SpriteHits &hits) +{ + FMaterial * gltex = FMaterial::ValidateTexture(tex, true); + if (gltex) gltex->PrecacheList(hits); +} + +//========================================================================== +// +// DFrameBuffer :: Precache +// +//========================================================================== + +void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhitlist) +{ + SpriteHits *spritelist = new SpriteHits[sprites.Size()]; + SpriteHits **spritehitlist = new SpriteHits*[TexMan.NumTextures()]; + TMap::Iterator it(actorhitlist); + TMap::Pair *pair; + BYTE *modellist = new BYTE[Models.Size()]; + memset(modellist, 0, Models.Size()); + memset(spritehitlist, 0, sizeof(SpriteHits**) * TexMan.NumTextures()); + + // this isn't done by the main code so it needs to be done here first: + // 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(); + texhitlist[index] |= FTextureManager::HIT_Flat; + } + } + } + } + } + + // Check all used actors. + // 1. mark all sprites associated with its states + // 2. mark all model data and skins associated with its states + while (it.NextPair(pair)) + { + PClassActor *cls = pair->Key; + int gltrans = GLTranslationPalette::GetInternalTranslation(GetDefaultByType(cls)->Translation); + + for (int i = 0; i < cls->NumOwnedStates; i++) + { + spritelist[cls->OwnedStates[i].sprite].Insert(gltrans, true); + FSpriteModelFrame * smf = gl_FindModelFrame(cls, cls->OwnedStates[i].sprite, cls->OwnedStates[i].Frame, false); + if (smf != NULL) + { + for (int i = 0; i < MAX_MODELS_PER_FRAME; i++) + { + if (smf->skinIDs[i].isValid()) + { + texhitlist[smf->skinIDs[i].GetIndex()] |= FTexture::TEX_Flat; + } + else if (smf->modelIDs[i] != -1) + { + Models[smf->modelIDs[i]]->PushSpriteMDLFrame(smf, i); + Models[smf->modelIDs[i]]->AddSkins(texhitlist); + } + if (smf->modelIDs[i] != -1) + { + modellist[smf->modelIDs[i]] = 1; + } + } + } + } + } + + // mark all sprite textures belonging to the marked sprites. + for (int i = (int)(sprites.Size() - 1); i >= 0; i--) + { + if (spritelist[i].CountUsed()) + { + int j, k; + for (j = 0; j < sprites[i].numframes; j++) + { + const spriteframe_t *frame = &SpriteFrames[sprites[i].spriteframes + j]; + + for (k = 0; k < 16; k++) + { + FTextureID pic = frame->Texture[k]; + if (pic.isValid()) + { + spritehitlist[pic.GetIndex()] = &spritelist[i]; + } + } + } + } + } + + // delete everything unused before creating any new resources to avoid memory usage peaks. + + // delete unused models + for (unsigned i = 0; i < Models.Size(); i++) + { + if (!modellist[i]) Models[i]->DestroyVertexBuffer(); + } + + // delete unused textures + int cnt = TexMan.NumTextures(); + for (int i = cnt - 1; i >= 0; i--) + { + FTexture *tex = TexMan.ByIndex(i); + if (tex != nullptr) + { + if (!texhitlist[i]) + { + if (tex->gl_info.Material[0]) tex->gl_info.Material[0]->Clean(true); + } + if (spritehitlist[i] == nullptr || (*spritehitlist[i]).CountUsed() == 0) + { + if (tex->gl_info.Material[1]) tex->gl_info.Material[1]->Clean(true); + } + } + } + + if (gl_precache) + { + // cache all used textures + for (int i = cnt - 1; i >= 0; i--) + { + FTexture *tex = TexMan.ByIndex(i); + if (tex != nullptr) + { + PrecacheTexture(tex, texhitlist[i]); + if (spritehitlist[i] != nullptr && (*spritehitlist[i]).CountUsed() > 0) + { + PrecacheSprite(tex, *spritehitlist[i]); + } + } + } + + // cache all used models + for (unsigned i = 0; i < Models.Size(); i++) + { + if (modellist[i]) + Models[i]->BuildVertexBuffer(); + } + } + + delete[] spritehitlist; + delete[] spritelist; + delete[] modellist; +} + + +//========================================================================== +// +// 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]; + GLRenderer->mSceneClearColor[0] = pe.r / 255.f; + GLRenderer->mSceneClearColor[1] = pe.g / 255.f; + GLRenderer->mSceneClearColor[2] = pe.b / 255.f; +} + +//=========================================================================== +// +// 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); + + if (gl.legacyMode) + { + // In legacy mode, fail if the requested texture is too large. + if (gltex->GetWidth() > screen->GetWidth() || gltex->GetHeight() > screen->GetHeight()) return; + glFlush(); + } + else + { + GLRenderer->StartOffscreen(); + gltex->BindToFrameBuffer(); + } + + 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 (gl.legacyMode) + { + 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..6d82aefa7 --- /dev/null +++ b/src/gl/scene/gl_sky.cpp @@ -0,0 +1,414 @@ +/* +** 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 "portal.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; + +//========================================================================== +// +// Set up the skyinfo struct +// +//========================================================================== + +void GLSkyInfo::init(int sky1, PalEntry FadeColor) +{ + memset(this, 0, sizeof(*this)); + 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); + texture[0] = FMaterial::ValidateTexture(texno, false, true); + if (!texture[0] || texture[0]->tex->UseType == FTexture::TEX_Null) goto normalsky; + skytexno1 = texno; + x_offset[0] = s->GetTextureXOffset(pos) * (360.f/65536.f); + y_offset = s->GetTextureYOffset(pos); + mirrored = !l->args[2]; + } + else + { + normalsky: + if (level.flags&LEVEL_DOUBLESKY) + { + texture[1] = FMaterial::ValidateTexture(sky1texture, false, true); + x_offset[1] = GLRenderer->mSky1Pos; + 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! + { + texture[0] = FMaterial::ValidateTexture(sky2texture, false, true); + skytexno1 = sky2texture; + sky2 = true; + x_offset[0] = GLRenderer->mSky2Pos; + } + else if (!doublesky) + { + texture[0] = FMaterial::ValidateTexture(sky1texture, false, true); + skytexno1 = sky1texture; + x_offset[0] = GLRenderer->mSky1Pos; + } + } + if (skyfog > 0) + { + fadecolor = FadeColor; + fadecolor.a = 0; + } + else fadecolor = 0; + +} + + +//========================================================================== +// +// Calculate sky texture for ceiling or floor +// +//========================================================================== + +void GLWall::SkyPlane(sector_t *sector, int plane, bool allowreflect) +{ + int ptype = -1; + + FSectorPortal *sportal = sector->ValidatePortal(plane); + if (sportal != nullptr && sportal->mFlags & PORTSF_INSKYBOX) sportal = nullptr; // no recursions, delete it here to simplify the following code + + // Either a regular sky or a skybox with skyboxes disabled + if ((sportal == nullptr && sector->GetTexture(plane) == skyflatnum) || (gl_noskyboxes && sportal != nullptr && sportal->mType == PORTS_SKYVIEWPOINT)) + { + GLSkyInfo skyinfo; + skyinfo.init(sector->sky, Colormap.FadeColor); + ptype = PORTALTYPE_SKY; + sky = UniqueSkies.Get(&skyinfo); + } + else if (sportal != nullptr) + { + switch (sportal->mType) + { + case PORTS_STACKEDSECTORTHING: + case PORTS_PORTAL: + case PORTS_LINKEDPORTAL: + { + FPortal *glport = sector->GetGLPortal(plane); + if (glport != NULL) + { + if (sector->PortalBlocksView(plane)) return; + + if (GLPortal::instack[1 - plane]) return; + ptype = PORTALTYPE_SECTORSTACK; + portal = glport; + } + break; + } + + case PORTS_SKYVIEWPOINT: + case PORTS_HORIZON: + case PORTS_PLANE: + ptype = PORTALTYPE_SKYBOX; + secportal = sportal; + break; + } + } + else if (allowreflect && sector->GetReflect(plane) > 0) + { + if ((plane == sector_t::ceiling && ViewPos.Z > sector->ceilingplane.fD()) || + (plane == sector_t::floor && ViewPos.Z < -sector->floorplane.fD())) return; + ptype = PORTALTYPE_PLANEMIRROR; + planemirror = plane == sector_t::ceiling ? §or->ceilingplane : §or->floorplane; + } + if (ptype != -1) + { + PutPortal(ptype); + } +} + + +//========================================================================== +// +// Calculate sky texture for a line +// +//========================================================================== + +void GLWall::SkyLine(sector_t *fs, line_t *line) +{ + FSectorPortal *secport = line->GetTransferredPortal(); + GLSkyInfo skyinfo; + int ptype; + + // JUSTHIT is used as an indicator that a skybox is in use. + // This is to avoid recursion + + if (!gl_noskyboxes && secport && (secport->mSkybox == nullptr || !(secport->mFlags & PORTSF_INSKYBOX))) + { + ptype = PORTALTYPE_SKYBOX; + secportal = secport; + } + else + { + skyinfo.init(fs->sky, Colormap.FadeColor); + ptype = PORTALTYPE_SKY; + sky = UniqueSkies.Get(&skyinfo); + } + ztop[0] = zceil[0]; + ztop[1] = zceil[1]; + zbottom[0] = zfloor[0]; + zbottom[1] = zfloor[1]; + PutPortal(ptype); +} + + +//========================================================================== +// +// 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 == GLSector_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.isSlope() && !fs->floorplane.isSlope()) + { + if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+1.) + { + 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]= + 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] = bs->ceilingplane.ZatPoint(v1); + zbottom[1] = bs->ceilingplane.ZatPoint(v2); + flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment! + } + } + else + { + float frontreflect = fs->GetReflect(sector_t::ceiling); + if (frontreflect > 0) + { + float backreflect = bs->GetReflect(sector_t::ceiling); + if (backreflect > 0 && bs->ceilingplane.fD() == fs->ceilingplane.fD()) + { + // Don't add intra-portal line to the portal. + return; + } + } + else + { + int type = fs->GetPortalType(sector_t::ceiling); + if (type == PORTS_STACKEDSECTORTHING || type == PORTS_PORTAL || type == PORTS_LINKEDPORTAL) + { + FPortal *pfront = fs->GetGLPortal(sector_t::ceiling); + FPortal *pback = bs->GetGLPortal(sector_t::ceiling); + if (pfront == NULL || fs->PortalBlocksView(sector_t::ceiling)) return; + if (pfront == pback && !bs->PortalBlocksView(sector_t::ceiling)) return; + } + } + + // stacked sectors + ztop[0] = ztop[1] = 32768.0f; + zbottom[0] = fs->ceilingplane.ZatPoint(v1); + zbottom[1] = fs->ceilingplane.ZatPoint(v2); + + } + + 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 == GLSector_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(ViewPos) > ViewPos.Z) 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] = bs->floorplane.ZatPoint(v1); + ztop[1] = bs->floorplane.ZatPoint(v2); + flags|=GLWF_SKYHACK; // mid textures on such lines need special treatment! + } + } + else + { + float frontreflect = fs->GetReflect(sector_t::floor); + if (frontreflect > 0) + { + float backreflect = bs->GetReflect(sector_t::floor); + if (backreflect > 0 && bs->floorplane.fD() == fs->floorplane.fD()) + { + // Don't add intra-portal line to the portal. + return; + } + } + else + { + int type = fs->GetPortalType(sector_t::floor); + if (type == PORTS_STACKEDSECTORTHING || type == PORTS_PORTAL || type == PORTS_LINKEDPORTAL) + { + FPortal *pfront = fs->GetGLPortal(sector_t::floor); + FPortal *pback = bs->GetGLPortal(sector_t::floor); + if (pfront == NULL || fs->PortalBlocksView(sector_t::floor)) return; + if (pfront == pback && !bs->PortalBlocksView(sector_t::floor)) return; + } + } + + // stacked sectors + zbottom[0]=zbottom[1]=-32768.0f; + ztop[0] = fs->floorplane.ZatPoint(v1); + ztop[1] = fs->floorplane.ZatPoint(v2); + } + + 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..97c5cb458 --- /dev/null +++ b/src/gl/scene/gl_skydome.cpp @@ -0,0 +1,541 @@ +/* +** 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 "r_utility.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(); +} + +FSkyVertexBuffer::~FSkyVertexBuffer() +{ +} + +void FSkyVertexBuffer::BindVBO() +{ + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + if (!gl.legacyMode) + { + 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); + glDisableVertexAttribArray(VATTR_VERTEX2); + } + else + { + glVertexPointer(3, GL_FLOAT, sizeof(FSkyVertex), &VSO->x); + glTexCoordPointer(2, GL_FLOAT, sizeof(FSkyVertex), &VSO->u); + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(FSkyVertex), &VSO->color); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyVertexBuffer::SkyVertex(int r, int c, bool zflip) +{ + static const FAngle maxSideAngle = 60.f; + static const float scale = 10000.; + + FAngle topAngle = (c / (float)mColumns * 360.f); + FAngle sideAngle = maxSideAngle * (mRows - r) / mRows; + float height = sideAngle.Sin(); + float realRadius = scale * sideAngle.Cos(); + FVector2 pos = topAngle.ToVector(realRadius); + float z = (!zflip) ? scale * height : -scale * height; + + FSkyVertex vert; + + vert.color = r == 0 ? 0xffffff : 0xffffffff; + + // And the texture coordinates. + if (!zflip) // 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) z += 300; + // And finally the vertex. + vert.x = -pos.X; // Doom mirrors the sky vertically! + vert.y = z - 1.f; + vert.z = pos.Y; + + mVertices.Push(vert); +} + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void FSkyVertexBuffer::CreateSkyHemisphere(int hemi) +{ + int r, c; + bool zflip = !!(hemi & SKYHEMI_LOWER); + + mPrimStart.Push(mVertices.Size()); + + for (c = 0; c < mColumns; c++) + { + SkyVertex(1, c, zflip); + } + + // 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 + zflip, c, zflip); + SkyVertex(r + 1 - zflip, c, zflip); + } + } +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +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()); + + mSideStart = mVertices.Size(); + mFaceStart[0] = mSideStart + 10; + mFaceStart[1] = mFaceStart[0] + 4; + mFaceStart[2] = mFaceStart[1] + 4; + mFaceStart[3] = mFaceStart[2] + 4; + mFaceStart[4] = mFaceStart[3] + 4; + mFaceStart[5] = mFaceStart[4] + 4; + mFaceStart[6] = mFaceStart[5] + 4; + mVertices.Reserve(10 + 7*4); + FSkyVertex *ptr = &mVertices[mSideStart]; + + // all sides + ptr[0].SetXYZ(128.f, 128.f, -128.f, 0, 0); + ptr[1].SetXYZ(128.f, -128.f, -128.f, 0, 1); + ptr[2].SetXYZ(-128.f, 128.f, -128.f, 0.25f, 0); + ptr[3].SetXYZ(-128.f, -128.f, -128.f, 0.25f, 1); + ptr[4].SetXYZ(-128.f, 128.f, 128.f, 0.5f, 0); + ptr[5].SetXYZ(-128.f, -128.f, 128.f, 0.5f, 1); + ptr[6].SetXYZ(128.f, 128.f, 128.f, 0.75f, 0); + ptr[7].SetXYZ(128.f, -128.f, 128.f, 0.75f, 1); + ptr[8].SetXYZ(128.f, 128.f, -128.f, 1, 0); + ptr[9].SetXYZ(128.f, -128.f, -128.f, 1, 1); + + // north face + ptr[10].SetXYZ(128.f, 128.f, -128.f, 0, 0); + ptr[11].SetXYZ(-128.f, 128.f, -128.f, 1, 0); + ptr[12].SetXYZ(128.f, -128.f, -128.f, 0, 1); + ptr[13].SetXYZ(-128.f, -128.f, -128.f, 1, 1); + + // east face + ptr[14].SetXYZ(-128.f, 128.f, -128.f, 0, 0); + ptr[15].SetXYZ(-128.f, 128.f, 128.f, 1, 0); + ptr[16].SetXYZ(-128.f, -128.f, -128.f, 0, 1); + ptr[17].SetXYZ(-128.f, -128.f, 128.f, 1, 1); + + // south face + ptr[18].SetXYZ(-128.f, 128.f, 128.f, 0, 0); + ptr[19].SetXYZ(128.f, 128.f, 128.f, 1, 0); + ptr[20].SetXYZ(-128.f, -128.f, 128.f, 0, 1); + ptr[21].SetXYZ(128.f, -128.f, 128.f, 1, 1); + + // west face + ptr[22].SetXYZ(128.f, 128.f, 128.f, 0, 0); + ptr[23].SetXYZ(128.f, 128.f, -128.f, 1, 0); + ptr[24].SetXYZ(128.f, -128.f, 128.f, 0, 1); + ptr[25].SetXYZ(128.f, -128.f, -128.f, 1, 1); + + // bottom face + ptr[26].SetXYZ(128.f, -128.f, -128.f, 0, 0); + ptr[27].SetXYZ(-128.f, -128.f, -128.f, 1, 0); + ptr[28].SetXYZ(128.f, -128.f, 128.f, 0, 1); + ptr[29].SetXYZ(-128.f, -128.f, 128.f, 1, 1); + + // top face + ptr[30].SetXYZ(128.f, 128.f, -128.f, 0, 0); + ptr[31].SetXYZ(-128.f, 128.f, -128.f, 1, 0); + ptr[32].SetXYZ(128.f, 128.f, 128.f, 0, 1); + ptr[33].SetXYZ(-128.f, 128.f, 128.f, 1, 1); + + // top face flipped + ptr[34].SetXYZ(128.f, 128.f, -128.f, 0, 1); + ptr[35].SetXYZ(-128.f, 128.f, -128.f, 1, 1); + ptr[36].SetXYZ(128.f, 128.f, 128.f, 0, 0); + ptr[37].SetXYZ(-128.f, 128.f, 128.f, 1, 0); + + 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); + // The color array can only be activated now if this is drawn without shader + if (gl.legacyMode) + { + glEnableClientState(GL_COLOR_ARRAY); + } + } + 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 = texw < 1024.f ? floor(1024.f / float(texw)) : 1.f; + 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); + + 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(); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(0), 4); + + // east + tex = FMaterial::ValidateTexture(sb->faces[1], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(1), 4); + + // south + tex = FMaterial::ValidateTexture(sb->faces[2], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(2), 4); + + // west + tex = FMaterial::ValidateTexture(sb->faces[3], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(3), 4); + } + else + { + faces=1; + tex = FMaterial::ValidateTexture(sb->faces[0], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(-1), 10); + } + + // top + tex = FMaterial::ValidateTexture(sb->faces[faces], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(sb->fliptop? 6:5), 4); + + // bottom + tex = FMaterial::ValidateTexture(sb->faces[faces+1], false); + gl_RenderState.SetMaterial(tex, CLAMP_XY, 0, -1, false); + gl_RenderState.Apply(); + glDrawArrays(GL_TRIANGLE_STRIP, GLRenderer->mSkyVBO->FaceStart(4), 4); + + 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)); + + gl_RenderState.SetVertexBuffer(GLRenderer->mSkyVBO); + if (origin->texture[0] && origin->texture[0]->tex->gl_info.bSkybox) + { + RenderBox(origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2); + } + else + { + 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_GREATER, 0.f); + + 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..07f397d6d --- /dev/null +++ b/src/gl/scene/gl_sprite.cpp @@ -0,0 +1,1186 @@ +/* +** 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 "a_pickups.h" +#include "d_player.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" +#include "gl/renderer/gl_quaddrawer.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_faces_camera, false, 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_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) + +static const float LARGE_VALUE = 1e19f; + + +//========================================================================== +// +// +// +//========================================================================== + +void GLSprite::CalculateVertices(FVector3 *v) +{ + // [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)))); + + const bool drawBillboardFacingCamera = gl_billboard_faces_camera; + // [Nash] has +ROLLSPRITE + const bool drawRollSpriteActor = (actor != nullptr && actor->renderflags & RF_ROLLSPRITE); + + + // [fgsfds] check sprite type mask + DWORD spritetype = (DWORD)-1; + if (actor != nullptr) spritetype = actor->renderflags & RF_SPRITETYPEMASK; + + // [Nash] is a flat sprite + const bool isFlatSprite = (actor != nullptr) && (spritetype == RF_WALLSPRITE || spritetype == RF_FLATSPRITE); + const bool dontFlip = (actor != nullptr) && (actor->renderflags & RF_DONTFLIP); + const bool useOffsets = (actor != nullptr) && !(actor->renderflags & RF_ROLLCENTER); + + // [Nash] check for special sprite drawing modes + if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || isFlatSprite) + { + // Compute center of sprite + float xcenter = (x1 + x2)*0.5; + float ycenter = (y1 + y2)*0.5; + float zcenter = (z1 + z2)*0.5; + float xx = -xcenter + x; + float zz = -zcenter + z; + float yy = -ycenter + y; + Matrix3x4 mat; + mat.MakeIdentity(); + mat.Translate(xcenter, zcenter, ycenter); // move to sprite center + + // Order of rotations matters. Perform yaw rotation (Y, face camera) before pitch (X, tilt up/down). + if (drawBillboardFacingCamera && !isFlatSprite) + { + // [CMB] Rotate relative to camera XY position, not just camera direction, + // which is nicer in VR + float xrel = xcenter - ViewPos.X; + float yrel = ycenter - ViewPos.Y; + float absAngleDeg = RAD2DEG(atan2(-yrel, xrel)); + float counterRotationDeg = 270. - GLRenderer->mAngles.Yaw.Degrees; // counteracts existing sprite rotation + float relAngleDeg = counterRotationDeg + absAngleDeg; + + mat.Rotate(0, 1, 0, relAngleDeg); + } + + // [fgsfds] calculate yaw vectors + float yawvecX = 0, yawvecY = 0, rollDegrees = 0; + float angleRad = (270. - GLRenderer->mAngles.Yaw).Radians(); + if (actor) rollDegrees = actor->Angles.Roll.Degrees; + if (isFlatSprite) + { + yawvecX = actor->Angles.Yaw.Cos(); + yawvecY = actor->Angles.Yaw.Sin(); + } + + // [MC] This is the only thing that I changed in Nash's submission which + // was constantly applying roll to everything. That was wrong. Flat sprites + // with roll literally look like paper thing space ships trying to swerve. + // However, it does well with wall sprites. + // Also, renamed FLOORSPRITE to FLATSPRITE because that's technically incorrect. + // I plan on adding proper FLOORSPRITEs which can actually curve along sloped + // 3D floors later... if possible. + + // Here we need some form of priority in order to work. + if (spritetype == RF_FLATSPRITE) + { + float pitchDegrees = -actor->Angles.Pitch.Degrees; + DVector3 apos = { x, y, z }; + DVector3 diff = ViewPos - apos; + DAngle angto = diff.Angle(); + + angto = deltaangle(actor->Angles.Yaw, angto); + + bool noFlipSprite = (!dontFlip || (fabs(angto) < 90.)); + mat.Rotate(0, 1, 0, (noFlipSprite) ? 0 : 180); + + mat.Rotate(-yawvecY, 0, yawvecX, (noFlipSprite) ? -pitchDegrees : pitchDegrees); + if (drawRollSpriteActor) + { + if (useOffsets) mat.Translate(xx, zz, yy); + mat.Rotate(yawvecX, 0, yawvecY, (noFlipSprite) ? -rollDegrees : rollDegrees); + if (useOffsets) mat.Translate(-xx, -zz, -yy); + } + } + // [fgsfds] Rotate the sprite about the sight vector (roll) + else if (spritetype == RF_WALLSPRITE) + { + mat.Rotate(0, 1, 0, 0); + if (drawRollSpriteActor) + { + if (useOffsets) mat.Translate(xx, zz, yy); + mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); + if (useOffsets) mat.Translate(-xx, -zz, -yy); + } + } + else if (drawRollSpriteActor) + { + if (useOffsets) mat.Translate(xx, zz, yy); + if (drawWithXYBillboard) + { + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); + } + mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees); + if (useOffsets) mat.Translate(-xx, -zz, -yy); + } + else 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. + mat.Rotate(-sin(angleRad), 0, cos(angleRad), -GLRenderer->mAngles.Pitch.Degrees); + } + + mat.Translate(-xcenter, -zcenter, -ycenter); // retreat from sprite center + v[0] = mat * FVector3(x1, z1, y1); + v[1] = mat * FVector3(x2, z1, y2); + v[2] = mat * FVector3(x1, z2, y1); + v[3] = mat * FVector3(x2, z2, y2); + } + else // traditional "Y" billboard mode + { + v[0] = FVector3(x1, z1, y1); + v[1] = FVector3(x2, z1, y2); + v[2] = FVector3(x1, z2, y1); + v[3] = FVector3(x2, z2, y2); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +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 dist=Dist2(ViewPos.X, ViewPos.Y, 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); + + //gl_SetColor(lightlevel, rel, Colormap, trans); + + unsigned int iter = lightlist? lightlist->Size() : 1; + bool clipping = false; + if (lightlist || topclip != LARGE_VALUE || bottomclip != -LARGE_VALUE) + { + clipping = true; + gl_RenderState.EnableSplit(true); + } + + secplane_t bottomp = { { 0, 0, -1. }, bottomclip }; + secplane_t topp = { { 0, 0, -1. }, topclip }; + for (unsigned i = 0; i < iter; i++) + { + if (lightlist) + { + // set up the light slice + secplane_t *topplane = i == 0 ? &topp : &(*lightlist)[i].plane; + secplane_t *lowplane = i == (*lightlist).Size() - 1 ? &bottomp : &(*lightlist)[i + 1].plane; + + int thislight = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; + int thisll = actor == nullptr? thislight : (uint8_t)gl_CheckSpriteGlow(actor->Sector, thislight, actor->InterpolatedPosition(r_TicFracF)); + + FColormap thiscm; + thiscm.FadeColor = Colormap.FadeColor; + thiscm.CopyFrom3DLight(&(*lightlist)[i]); + if (glset.nocoloredspritelighting) + { + thiscm.Decolorize(); + } + + gl_SetColor(thisll, rel, thiscm, trans); + if (!foglayer) + { + gl_SetFog(thislight, rel, &thiscm, additivefog); + } + gl_RenderState.SetSplitPlanes(*topplane, *lowplane); + } + else if (clipping) + { + gl_RenderState.SetSplitPlanes(topp, bottomp); + } + + if (!modelframe) + { + gl_RenderState.Apply(); + + FVector3 v[4]; + CalculateVertices(v); + + + FQuadDrawer qd; + qd.Set(0, v[0][0], v[0][1], v[0][2], ul, vt); + qd.Set(1, v[1][0], v[1][1], v[1][2], ur, vt); + qd.Set(2, v[2][0], v[2][1], v[2][2], ul, vb); + qd.Set(3, v[3][0], v[3][1], v[3][2], ur, vb); + qd.Render(GL_TRIANGLE_STRIP); + + 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(); + qd.Render(GL_TRIANGLE_STRIP); + gl_RenderState.SetFixedColormap(CM_DEFAULT); + } + } + else + { + gl_RenderModel(this); + } + } + + if (clipping) + { + gl_RenderState.EnableSplit(false); + } + + 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; + double lightbottom; + unsigned int i; + bool put=false; + TArray & lightlist=frontsector->e->XFloor.lightlist; + + for(i=0;ifloorplane.ZatPoint(actor); + + if (lightbottom>8; + copySprite.Colormap.LightColor.g=(copySprite.Colormap.LightColor.g*ThingColor.g)>>8; + copySprite.Colormap.LightColor.b=(copySprite.Colormap.LightColor.b*ThingColor.b)>>8; + } + + z1=copySprite.z2=lightbottom; + vt=copySprite.vb=copySprite.vt+ + (lightbottom-copySprite.z1)*(copySprite.vb-copySprite.vt)/(z2-copySprite.z1); + copySprite.PutSprite(translucent); + put=true; + } + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void GLSprite::PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight) +{ + const float NO_VAL = 100000000.0f; + bool clipthing = (thing->player || thing->flags3&MF3_ISMONSTER || thing->IsKindOf(RUNTIME_CLASS(AInventory))) && (thing->flags&MF_ICECORPSE || !(thing->flags&MF_CORPSE)); + bool smarterclip = !clipthing && gl_spriteclip == 3; + if (clipthing || gl_spriteclip > 1) + { + + float btm = NO_VAL; + float top = -NO_VAL; + 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]; + float floorh = ff->top.plane->ZatPoint(thingpos); + float ceilingh = ff->bottom.plane->ZatPoint(thingpos); + if (floorh == thing->floorz) + { + btm = floorh; + } + if (ceilingh == thing->ceilingz) + { + top = ceilingh; + } + if (btm != NO_VAL && top != -NO_VAL) + { + break; + } + } + } + else if (thing->Sector->heightsec && !(thing->Sector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC)) + { + if (thing->flags2&MF2_ONMOBJ && thing->floorz == + thing->Sector->heightsec->floorplane.ZatPoint(thingpos)) + { + btm = thing->floorz; + top = thing->ceilingz; + } + } + if (btm == NO_VAL) + btm = thing->Sector->floorplane.ZatPoint(thing) - thing->Floorclip; + if (top == NO_VAL) + top = thing->Sector->ceilingplane.ZatPoint(thingpos); + + // +/-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, int thruportal) +{ + sector_t rs; + sector_t * rendersector; + + // Don't waste time projecting sprites that are definitely not visible. + if (thing == NULL || thing->sprite == 0 || !thing->IsVisibleToPlayer()) + { + return; + } + + if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->Alpha)) + { + if (!(thing->flags & MF_STEALTH) || !gl_fixedcolormap || !gl_enhanced_nightvision || thing == camera) + return; + } + + int spritenum = thing->sprite; + DVector2 sprscale = thing->Scale; + if (thing->player != NULL) + { + P_CheckPlayerSprite(thing, spritenum, sprscale); + } + + // If this thing is in a map section that's not in view it can't possibly be visible + if (!thruportal && !(currentmapsection[thing->subsector->mapsection >> 3] & (1 << (thing->subsector->mapsection & 7)))) return; + + // [RH] Interpolate the sprite's position to make it look smooth + DVector3 thingpos = thing->InterpolatedPosition(r_TicFracF); + if (thruportal == 1) thingpos += Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup); + + // Too close to the camera. This doesn't look good if it is a sprite. + if (fabs(thingpos.X - ViewPos.X) < 2 && fabs(thingpos.Y - ViewPos.Y) < 2) + { + if (ViewPos.Z >= thingpos.Z - 2 && ViewPos.Z <= thingpos.Z + thing->Height + 2) + { + // exclude vertically moving objects from this check. + if (!thing->Vel.isZero()) + { + if (!gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, false)) + { + return; + } + } + } + } + + // don't draw first frame of a player missile + if (thing->flags&MF_MISSILE) + { + if (!(thing->flags7 & MF7_FLYCHEAT) && thing->target == GLRenderer->mViewActor && GLRenderer->mViewActor != NULL) + { + double speed = thing->Vel.Length(); + if (speed >= thing->target->radius / 2) + { + double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius * 2); + if ((thingpos - ViewPos).LengthSquared() < clipdist * clipdist) return; + } + } + thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again. + } + + if (thruportal != 2 && GLRenderer->mClipPortal) + { + int clipres = GLRenderer->mClipPortal->ClipPoint(thingpos); + if (clipres == GLPortal::PClip_InFront) return; + } + + player_t *player = &players[consoleplayer]; + FloatRect r; + + if (sector->sectornum != thing->Sector->sectornum && !thruportal) + { + rendersector = gl_FakeFlat(thing->Sector, &rs, false); + } + else + { + rendersector = sector; + } + topclip = rendersector->PortalBlocksMovement(sector_t::ceiling) ? LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::ceiling); + bottomclip = rendersector->PortalBlocksMovement(sector_t::floor) ? -LARGE_VALUE : rendersector->GetPortalPlaneZ(sector_t::floor); + + DWORD spritetype = (thing->renderflags & RF_SPRITETYPEMASK); + x = thingpos.X; + z = thingpos.Z; + y = thingpos.Y; + if (spritetype != RF_FLATSPRITE) z -= thing->Floorclip; + + // [RH] Make floatbobbing a renderer-only effect. + if (thing->flags2 & MF2_FLOATBOB) + { + float fz = thing->GetBobOffset(r_TicFracF); + z += fz; + } + + modelframe = gl_FindModelFrame(thing->GetClass(), spritenum, thing->frame, !!(thing->flags & MF_DROPPED)); + if (!modelframe) + { + bool mirror; + DAngle ang = (thingpos - ViewPos).Angle(); + FTextureID patch; + if (thing->flags7 & MF7_SPRITEANGLE) + patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (thing->SpriteAngle).BAMs(), &mirror); + else + patch = gl_GetSpriteFrame(spritenum, thing->frame, -1, (ang - (thing->Angles.Yaw + thing->SpriteRotation)).BAMs(), &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(sprscale.X, sprscale.Y); + + float rightfac = -r.left; + float leftfac = rightfac - r.width; + + z1 = z - r.top; + z2 = z1 - r.height; + + float spriteheight = sprscale.Y * 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, thingpos, spriteheight); + } + + float viewvecX; + float viewvecY; + switch (spritetype) + { + 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_FLATSPRITE: + case RF_WALLSPRITE: + viewvecX = thing->Angles.Yaw.Cos(); + viewvecY = thing->Angles.Yaw.Sin(); + + 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 = FloatToFixed((x - ViewPos.X) * ViewTanCos + (y - ViewPos.Y) * 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, thingpos); + + 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 = 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 && !gl.legacyMode) + { + // 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 ) ); + + + // no light splitting when: + // 1. no lightlist + // 2. any fixed colormap + // 3. any bright object + // 4. any with render style shadow (which doesn't use the sector light) + // 5. anything with render style reverse subtract (light effect is not what would be desired here) + if (thing->Sector->e->XFloor.lightlist.Size() != 0 && gl_fixedcolormap == CM_DEFAULT && !fullbright && + RenderStyle.BlendOp != STYLEOP_Shadow && RenderStyle.BlendOp != STYLEOP_RevSub) + { + if (gl.flags & RFL_NO_CLIP_PLANES) // on old hardware we are rather limited... + { + lightlist = NULL; + if (!drawWithXYBillboard && !modelframe) + { + SplitSprite(thing->Sector, hw_styleflags != STYLEHW_Solid); + } + } + else + { + lightlist = &thing->Sector->e->XFloor.lightlist; + } + } + else + { + lightlist = NULL; + } + + PutSprite(hw_styleflags != STYLEHW_Solid); + rendered_sprites++; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void GLSprite::ProcessParticle (particle_t *particle, sector_t *sector)//, int shade, int fakeside) +{ + if (GLRenderer->mClipPortal) + { + int clipres = GLRenderer->mClipPortal->ClipPoint(particle->Pos); + 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 = (BYTE)clamp(sector->lightlevel, 0, 255); + + if (gl_fixedcolormap) + { + Colormap.Clear(); + } + else if (!particle->bright) + { + TArray & lightlist=sector->e->XFloor.lightlist; + double lightbottom; + + Colormap = sector->ColorMap; + for(unsigned int i=0;iPos); + else lightbottom = sector->floorplane.ZatPoint(particle->Pos); + + if (lightbottom < particle->Pos.Z) + { + lightlevel = gl_ClampLight(*lightlist[i].p_lightlevel); + Colormap.LightColor = (lightlist[i].extra_colormap)->Color; + break; + } + } + if (glset.nocoloredspritelighting) + { + Colormap.Decolorize(); // ZDoom never applies colored light to particles. + } + } + 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; + topclip = LARGE_VALUE; + bottomclip = -LARGE_VALUE; + + // [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 = particle->Pos.X; + y = particle->Pos.Y; + z = particle->Pos.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 = FloatToFixed((x - ViewPos.X) * ViewTanCos + (y - ViewPos.Y) * ViewTanSin); + + actor=NULL; + this->particle=particle; + fullbright = !!particle->bright; + + // [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; + + if (sector->e->XFloor.lightlist.Size() != 0 && gl_fixedcolormap == CM_DEFAULT && !fullbright) + lightlist = §or->e->XFloor.lightlist; + else + lightlist = NULL; + + PutSprite(hw_styleflags != STYLEHW_Solid); + rendered_sprites++; +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_RenderActorsInPortal(FGLLinePortal *glport) +{ + TMap processcheck; + if (glport->validcount == validcount) return; // only process once per frame + glport->validcount = validcount; + for (auto port : glport->lines) + { + line_t *line = port->mOrigin; + if (line->isLinePortal()) // only crossable ones + { + FLinePortal *port2 = port->mDestination->getPortal(); + // process only if the other side links back to this one. + if (port2 != nullptr && port->mDestination == port2->mOrigin && port->mOrigin == port2->mDestination) + { + + for (portnode_t *node = port->render_thinglist; node != nullptr; node = node->m_snext) + { + AActor *th = node->m_thing; + + // process each actor only once per portal. + bool *check = processcheck.CheckKey(th); + if (check && *check) continue; + processcheck[th] = true; + + DAngle savedangle = th->Angles.Yaw; + DVector3 savedpos = th->Pos(); + DVector3 newpos = savedpos; + sector_t fakesector; + + P_TranslatePortalXY(line, newpos.X, newpos.Y); + P_TranslatePortalZ(line, newpos.Z); + P_TranslatePortalAngle(line, th->Angles.Yaw); + th->SetXYZ(newpos); + th->Prev += newpos - savedpos; + + GLSprite spr; + th->fillcolor = 0xff0000ff; + spr.Process(th, gl_FakeFlat(th->Sector, &fakesector, false), 2); + th->fillcolor = 0xffffffff; + th->Angles.Yaw = savedangle; + th->SetXYZ(savedpos); + th->Prev -= newpos - savedpos; + } + } + } + } +} \ No newline at end of file diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp new file mode 100644 index 000000000..329459bd1 --- /dev/null +++ b/src/gl/scene/gl_spritelight.cpp @@ -0,0 +1,142 @@ +/* +** 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, float x, float y, float 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->visibletoplayer && !(light->flags2&MF2_DORMANT) && (!(light->flags4&MF4_DONTLIGHTSELF) || light->target != self)) + { + float dist; + + // This is a performance critical section of code where we cannot afford to let the compiler decide whether to inline the function or not. + // This will do the calculations explicitly rather than calling one of AActor's utility functions. + if (Displacements.size > 0) + { + int fromgroup = light->Sector->PortalGroup; + int togroup = subsec->sector->PortalGroup; + if (fromgroup == togroup || fromgroup == 0 || togroup == 0) goto direct; + + DVector2 offset = Displacements.getOffset(fromgroup, togroup); + dist = FVector3(x - light->X() - offset.X, y - light->Y() - offset.Y, z - light->Z()).LengthSquared(); + } + else + { + direct: + dist = FVector3(x - light->X(), y - light->Y(), z - light->Z()).LengthSquared(); + } + + radius = light->GetRadius(); + + if (dist < radius * radius) + { + dist = sqrtf(dist); // only calculate the square root if we really need it. + + frac = 1.0f - (dist / radius); + + if (frac > 0) + { + lr = light->GetRed() / 255.0f; + lg = light->GetGreen() / 255.0f; + lb = light->GetBlue() / 255.0f; + 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->Center(), thing->subsector); + } + else if (particle != NULL) + { + gl_SetDynSpriteLight(NULL, particle->Pos.X, particle->Pos.Y, particle->Pos.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..27ad8e059 --- /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(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[UPRGT].u - tcs[UPLFT].u) / polyw; + float facv = (tcs[UPRGT].v - tcs[UPLFT].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[UPLFT].u + facu * fracfac; + ptr->v = tcs[UPLFT].v + facv * fracfac; + ptr++; + } +} + +//========================================================================== +// +// Split upper edge of wall +// +//========================================================================== + +void GLWall::SplitLowerEdge(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[LORGT].u - tcs[LOLFT].u) / polyw; + float facv = (tcs[LORGT].v - tcs[LOLFT].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[LOLFT].u + facu * fracfac; + ptr->v = tcs[LOLFT].v + facv * fracfac; + ptr++; + } +} + +//========================================================================== +// +// Split left edge of wall +// +//========================================================================== + +void GLWall::SplitLeftEdge(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[UPLFT].v - tcs[LOLFT].v) / polyh1 : 0; + float factu1 = polyh1 ? (tcs[UPLFT].u - tcs[LOLFT].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[UPLFT].u; + ptr->v = factv1*(vi->heightlist[i] - ztop[0]) + tcs[UPLFT].v; + ptr++; + i++; + } + } +} + +//========================================================================== +// +// Split right edge of wall +// +//========================================================================== + +void GLWall::SplitRightEdge(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[UPRGT].v - tcs[LORGT].v) / polyh2 : 0; + float factu2 = polyh2 ? (tcs[UPRGT].u - tcs[LORGT].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[UPRGT].u; + ptr->v = factv2*(vi->heightlist[i] - ztop[1]) + tcs[UPRGT].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..32dc6ee5b --- /dev/null +++ b/src/gl/scene/gl_wall.h @@ -0,0 +1,399 @@ +#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; +struct FGLLinePortal; + +enum +{ + GLSector_NoSkyDraw = 89, + GLSector_Skybox = 90, +}; + +enum WallTypes +{ + RENDERWALL_NONE, + RENDERWALL_TOP, + RENDERWALL_M1S, + RENDERWALL_M2S, + RENDERWALL_BOTTOM, + RENDERWALL_FOGBOUNDARY, + RENDERWALL_MIRRORSURFACE, + RENDERWALL_M2SNF, + RENDERWALL_COLOR, + RENDERWALL_FFBLOCK, + // Insert new types at the end! +}; + +enum PortalTypes +{ + PORTALTYPE_SKY, + PORTALTYPE_HORIZON, + PORTALTYPE_SKYBOX, + PORTALTYPE_SECTORSTACK, + PORTALTYPE_PLANEMIRROR, + PORTALTYPE_MIRROR, + PORTALTYPE_LINETOLINE, +}; + +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; + float Texheight; + float Angle; + FVector2 Offs; + FVector2 Scale; + + void GetFromSector(sector_t * sec, int ceiling) + { + Offs.X = (float)sec->GetXOffset(ceiling); + Offs.Y = (float)sec->GetYOffset(ceiling); + Scale.X = (float)sec->GetXScale(ceiling); + Scale.Y = (float)sec->GetYScale(ceiling); + Angle = (float)sec->GetAngle(ceiling).Degrees; + texture = sec->GetTexture(ceiling); + plane = sec->GetSecPlane(ceiling); + Texheight = (float)((ceiling == sector_t::ceiling)? plane.fD() : -plane.fD()); + } +}; + + +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_NOSPLIT = 4, + RWF_NORENDER = 8, + }; + + enum + { + LOLFT, + UPLFT, + UPRGT, + LORGT, + }; + + friend struct GLDrawList; + friend class GLPortal; + + GLSeg glseg; + vertex_t * vertexes[2]; // required for polygon splitting + float ztop[2],zbottom[2]; + texcoord tcs[4]; + float alpha; + FMaterial *gltexture; + + FColormap Colormap; + ERenderStyle RenderStyle; + + float ViewDistance; + + TArray *lightlist; + 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! + FSectorPortal *secportal; // sector portal (formerly skybox) + GLSkyInfo * sky; // for normal sky + GLHorizonInfo * horizon; // for horizon information + FPortal * portal; // stacked sector portals + secplane_t * planemirror; // for plane mirrors + FGLLinePortal *lineportal; // line-to-line portals + }; + + + 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]; + + unsigned int vertindex; + unsigned int vertcount; + +public: + seg_t * seg; // this gives the easiest access to all other structs involved + subsector_t * sub; // For polyobjects +private: + + void CheckGlowing(); + bool PutWallCompat(int passflag); + void PutWall(bool translucent); + void PutPortal(int ptype); + void CheckTexturePosition(); + + void RenderFogBoundaryCompat(); + void RenderLightsCompat(int pass); + + void Put3DWall(lightlist_t * lightlist, bool translucent); + bool SplitWallComplex(sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright); + void SplitWall(sector_t * frontsector, bool translucent); + + void SetupLights(); + bool PrepareLight(ADynamicLight * light, int pass); + void MakeVertices(bool nosplit); + void RenderWall(int textured); + void RenderTextured(int rflags); + + void FloodPlane(int pass); + + void SkyPlane(sector_t *sector, int plane, bool allowmirror); + void SkyLine(sector_t *sec, line_t *line); + 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 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, + float topleft, float topright, float bottomleft, float bottomright, float t_ofs); + + void DoTexture(int type,seg_t * seg,int peg, + float ceilingrefheight, float floorrefheight, + float CeilingHeightstart,float CeilingHeightend, + float FloorHeightstart,float FloorHeightend, + float v_offset); + + void DoMidTexture(seg_t * seg, bool drawfogboundary, + sector_t * front, sector_t * back, + sector_t * realfront, sector_t * realback, + float fch1, float fch2, float ffh1, float ffh2, + float bch1, float bch2, float bfh1, float bfh2); + + void GetPlanePos(F3DFloor::planeref * planeref, float & left, float & right); + + void BuildFFBlock(seg_t * seg, F3DFloor * rover, + float ff_topleft, float ff_topright, + float ff_bottomleft, float ff_bottomright); + void InverseFloors(seg_t * seg, sector_t * frontsector, + float topleft, float topright, + float bottomleft, float bottomright); + void ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector, + float topleft, float topright, + float bottomleft, float bottomright); + void DoFFloorBlocks(seg_t * seg, sector_t * frontsector, sector_t * backsector, + float fch1, float fch2, float ffh1, float ffh2, + float bch1, float bch2, float bfh1, float bfh2); + + void DrawDecal(DBaseDecal *actor); + void DoDrawDecals(); + + void RenderFogBoundary(); + void RenderMirrorSurface(); + void RenderTranslucentWall(); + + void SplitLeftEdge (FFlatVertex *&ptr); + void SplitRightEdge(FFlatVertex *&ptr); + void SplitUpperEdge(FFlatVertex *&ptr); + void SplitLowerEdge(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; + 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 ceiling; + BYTE renderflags; + int vboindex; + //int vboheight; + + int dynlightindex; + + // compatibility fallback stuff. + void DrawSubsectorLights(subsector_t * sub, int pass); + void DrawLightsCompat(int pass); + bool PutFlatCompat(bool fog); + + void SetupSubsectorLights(int pass, subsector_t * sub, int *dli = NULL); + void DrawSubsector(subsector_t * sub); + void DrawSkyboxSector(int pass, bool processlights); + 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); + + int 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 topclip; + float bottomclip; + + 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; + TArray *lightlist; + + void SplitSprite(sector_t * frontsector, bool translucent); + void SetLowerParam(); + void PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight); + void CalculateVertices(FVector3 *v); + +public: + + void Draw(int pass); + void PutSprite(bool translucent); + void Process(AActor* thing,sector_t * sector, int thruportal = false); + void ProcessParticle (particle_t *particle, sector_t *sector);//, int shade, int fakeside) + void SetThingColor(PalEntry); + + // 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, float x, float y, float z, subsector_t *subsec); +void gl_SetDynSpriteLight(AActor *actor, particle_t *particle); +void gl_RenderActorsInPortal(FGLLinePortal *glport); + +#endif diff --git a/src/gl/scene/gl_walls.cpp b/src/gl/scene/gl_walls.cpp new file mode 100644 index 000000000..f8bb2a876 --- /dev/null +++ b/src/gl/scene/gl_walls.cpp @@ -0,0 +1,1818 @@ +/* +** 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 "r_utility.h" +#include "p_maputl.h" +#include "doomdata.h" +#include "portal.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) +{ + 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 + 3, //RENDERWALL_FOGBOUNDARY, // translucent + 1, //RENDERWALL_MIRRORSURFACE, // only created from PORTALTYPE_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 + }; + + + if (gltexture && gltexture->GetTransparent() && passflag[type] == 2) + { + translucent = true; + } + + if (gl_fixedcolormap) + { + // light planes don't get drawn with fullbright rendering + if (gltexture == NULL) return; + Colormap.Clear(); + } + + CheckGlowing(); + + if (translucent) // translucent walls + { + ViewDistance = (ViewPos - (seg->linedef->v1->fPos() + seg->linedef->Delta() / 2)).XY().LengthSquared(); + if (gl.buffermethod == BM_DEFERRED) MakeVertices(true); + gl_drawinfo->drawlists[GLDL_TRANSLUCENT].AddWall(this); + } + else + { + if (gl.legacyMode && !translucent) + { + if (PutWallCompat(passflag[type])) return; + } + + 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; + } + if (gl.buffermethod == BM_DEFERRED) MakeVertices(false); + gl_drawinfo->drawlists[list].AddWall(this); + + } + lightlist = NULL; + vertcount = 0; // make sure that following parts of the same linedef do not get this one's vertex info. +} + +void GLWall::PutPortal(int ptype) +{ + GLPortal * portal; + + if (gl.buffermethod == BM_DEFERRED) MakeVertices(false); + switch (ptype) + { + // portals don't go into the draw list. + // Instead they are added to the portal manager + case PORTALTYPE_HORIZON: + horizon=UniqueHorizons.Get(horizon); + portal=GLPortal::FindPortal(horizon); + if (!portal) portal=new GLHorizonPortal(horizon); + portal->AddLine(this); + break; + + case PORTALTYPE_SKYBOX: + portal = GLPortal::FindPortal(secportal); + if (!portal) + { + // either a regular skybox or an Eternity-style horizon + if (secportal->mType != PORTS_SKYVIEWPOINT) portal = new GLEEHorizonPortal(secportal); + else portal = new GLSkyboxPortal(secportal); + } + portal->AddLine(this); + break; + + case PORTALTYPE_SECTORSTACK: + portal = this->portal->GetRenderState(); + portal->AddLine(this); + break; + + case PORTALTYPE_PLANEMIRROR: + if (GLPortal::PlaneMirrorMode * planemirror->fC() <=0) + { + //@sync-portal + planemirror=UniquePlaneMirrors.Get(planemirror); + portal=GLPortal::FindPortal(planemirror); + if (!portal) portal=new GLPlaneMirrorPortal(planemirror); + portal->AddLine(this); + } + break; + + case PORTALTYPE_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 PORTALTYPE_LINETOLINE: + portal=GLPortal::FindPortal(lineportal); + if (!portal) + { + line_t *otherside = lineportal->lines[0]->mDestination; + if (otherside != NULL && otherside->portalindex < linePortals.Size()) + { + gl_RenderActorsInPortal(linePortalToGL[otherside->portalindex]); + } + portal = new GLLineToLinePortal(lineportal); + } + portal->AddLine(this); + break; + + case PORTALTYPE_SKY: + portal=GLPortal::FindPortal(sky); + if (!portal) portal=new GLSkyPortal(sky); + portal->AddLine(this); + break; + } + vertcount = 0; +} +//========================================================================== +// +// Sets 3D-floor lighting info +// +//========================================================================== + +void GLWall::Put3DWall(lightlist_t * lightlist, bool translucent) +{ + // 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.CopyFrom3DLight(lightlist); + PutWall(translucent); +} + +//========================================================================== +// +// Splits a wall vertically if a 3D-floor +// creates different lighting across the wall +// +//========================================================================== + +bool GLWall::SplitWallComplex(sector_t * frontsector, bool translucent, float& maplightbottomleft, float& maplightbottomright) +{ + GLWall copyWall1, copyWall2; + + // check for an intersection with the upper plane + if ((maplightbottomleftztop[1]) || + (maplightbottomleft>ztop[0] && maplightbottomright(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y1)); + + 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 two 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.tcs[UPRGT].u = copyWall2.tcs[UPLFT].u = tcs[UPLFT].u + coeff * (tcs[UPRGT].u - tcs[UPLFT].u); + copyWall1.tcs[UPRGT].v = copyWall2.tcs[UPLFT].v = tcs[UPLFT].v + coeff * (tcs[UPRGT].v - tcs[UPLFT].v); + copyWall1.tcs[LORGT].u = copyWall2.tcs[LOLFT].u = tcs[LOLFT].u + coeff * (tcs[LORGT].u - tcs[LOLFT].u); + copyWall1.tcs[LORGT].v = copyWall2.tcs[LOLFT].v = tcs[LOLFT].v + coeff * (tcs[LORGT].v - tcs[LOLFT].v); + + copyWall1.SplitWall(frontsector, translucent); + copyWall2.SplitWall(frontsector, translucent); + return true; + } + } + + // check for an intersection with the lower plane + if ((maplightbottomleftzbottom[1]) || + (maplightbottomleft>zbottom[0] && maplightbottomright(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y1)); + + 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 two 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.tcs[UPRGT].u = copyWall2.tcs[UPLFT].u = tcs[UPLFT].u + coeff * (tcs[UPRGT].u - tcs[UPLFT].u); + copyWall1.tcs[UPRGT].v = copyWall2.tcs[UPLFT].v = tcs[UPLFT].v + coeff * (tcs[UPRGT].v - tcs[UPLFT].v); + copyWall1.tcs[LORGT].u = copyWall2.tcs[LOLFT].u = tcs[LOLFT].u + coeff * (tcs[LORGT].u - tcs[LOLFT].u); + copyWall1.tcs[LORGT].v = copyWall2.tcs[LOLFT].v = tcs[LOLFT].v + coeff * (tcs[LORGT].v - tcs[LOLFT].v); + + copyWall1.SplitWall(frontsector, translucent); + copyWall2.SplitWall(frontsector, translucent); + return true; + } + } + + return false; +} + +void GLWall::SplitWall(sector_t * frontsector, bool translucent) +{ + GLWall copyWall1; + float maplightbottomleft; + float maplightbottomright; + unsigned int i; + int origlight = lightlevel; + FColormap origcm=Colormap; + + 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 and lower planes of the wall segment + if ((maplightbottomleftztop[1]) || + (maplightbottomleft > ztop[0] && maplightbottomright < ztop[1]) || + (maplightbottomleftzbottom[1]) || + (maplightbottomleft > zbottom[0] && maplightbottomright < zbottom[1])) + { + if (!(gl.flags & RFL_NO_CLIP_PLANES)) + { + // Use hardware clipping if this cannot be done cleanly. + this->lightlist = &lightlist; + PutWall(translucent); + + goto out; + } + // crappy fallback if no clip planes available + else if (SplitWallComplex(frontsector, translucent, maplightbottomleft, maplightbottomright)) + { + goto out; + } + } + + // 3D floor is completely within this light + if (maplightbottomleft<=zbottom[0] && maplightbottomright<=zbottom[1]) + { + Put3DWall(&lightlist[i], translucent); + goto out; + } + + 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; + tcs[UPLFT].v=copyWall1.tcs[LOLFT].v=copyWall1.tcs[UPLFT].v+ + (maplightbottomleft-copyWall1.ztop[0])*(copyWall1.tcs[LOLFT].v-copyWall1.tcs[UPLFT].v)/(zbottom[0]-copyWall1.ztop[0]); + tcs[UPRGT].v=copyWall1.tcs[LORGT].v=copyWall1.tcs[UPRGT].v+ + (maplightbottomright-copyWall1.ztop[1])*(copyWall1.tcs[LORGT].v-copyWall1.tcs[UPRGT].v)/(zbottom[1]-copyWall1.ztop[1]); + copyWall1.Put3DWall(&lightlist[i], translucent); + } + if (ztop[0]==zbottom[0] && ztop[1]==zbottom[1]) + { + //::SplitWall.Unclock(); + goto out; + } + } + } + + Put3DWall(&lightlist[lightlist.Size()-1], translucent); + +out: + lightlevel=origlight; + Colormap=origcm; + flags &= ~GLWF_NOSPLITUPPER; + this->lightlist = NULL; + //::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] = fs->GetPlaneTexZ(sector_t::ceiling); + zbottom[1] = zbottom[0] = fs->GetPlaneTexZ(sector_t::floor); + + if (ViewPos.Z < fs->GetPlaneTexZ(sector_t::ceiling)) + { + if (ViewPos.Z > fs->GetPlaneTexZ(sector_t::floor)) + zbottom[1] = zbottom[0] = ViewPos.Z; + + if (fs->GetTexture(sector_t::ceiling) == skyflatnum) + { + SkyPlane(fs, sector_t::ceiling, false); + } + else + { + 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; + PutPortal(PORTALTYPE_HORIZON); + } + ztop[1] = ztop[0] = zbottom[0]; + } + + if (ViewPos.Z > fs->GetPlaneTexZ(sector_t::floor)) + { + zbottom[1] = zbottom[0] = fs->GetPlaneTexZ(sector_t::floor); + if (fs->GetTexture(sector_t::floor) == skyflatnum) + { + SkyPlane(fs, sector_t::floor, false); + } + else + { + 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; + PutPortal(PORTALTYPE_HORIZON); + } + } + return true; +} + +//========================================================================== +// +// +// +//========================================================================== +bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float texturetop, + float topleft, float topright, float bottomleft, float bottomright, float 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(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] = topleft; + zbottom[0] = bottomleft; + + if (tci) + { + tcs[UPLFT].v = tci->FloatToTexV(-ztop[0] + texturetop); + tcs[LOLFT].v = tci->FloatToTexV(-zbottom[0] + texturetop); + } + } + else + { + // ceiling below floor - clip to the visible part of the wall + float dch = topright - topleft; + float dfh = bottomright - bottomleft; + float inter_x = (bottomleft - topleft) / (dch - dfh); + + float inter_y = topleft + inter_x * dch; + + 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] = inter_y; + + if (tci) + { + tcs[LOLFT].v = tcs[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] = topright; + zbottom[1] = bottomright; + + if (tci) + { + tcs[UPRGT].v = tci->FloatToTexV(-ztop[1] + texturetop); + tcs[LORGT].v = tci->FloatToTexV(-zbottom[1] + texturetop); + } + } + else + { + // ceiling below floor - clip to the visible part of the wall + float dch = topright - topleft; + float dfh = bottomright - bottomleft; + float inter_x = (bottomleft - topleft) / (dch - dfh); + + float inter_y = topleft + inter_x * dch; + + 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] = inter_y; + if (tci) + { + tcs[LORGT].v = tcs[UPRGT].v = tci->FloatToTexV(-ztop[1] + texturetop); + } + } + + tcs[UPLFT].u = tcs[LOLFT].u = l_ul + texlength * glseg.fracleft; + tcs[UPRGT].u = tcs[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 = (tcs[UPLFT].v > tcs[LOLFT].v || tcs[UPRGT].v > tcs[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 + tcs[UPLFT].v += 1.f; + tcs[UPRGT].v += 1.f; + tcs[LOLFT].v += 1.f; + tcs[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 (tcs[UPLFT].v < tcs[UPRGT].v) + { + sub = float(xs_FloorToInt(tcs[UPLFT].v)); + } + else + { + sub = float(xs_FloorToInt(tcs[UPRGT].v)); + } + tcs[UPLFT].v -= sub; + tcs[UPRGT].v -= sub; + tcs[LOLFT].v -= sub; + tcs[LORGT].v -= sub; + + if ((tcs[UPLFT].v == 0.f && tcs[UPRGT].v == 0.f && tcs[LOLFT].v <= 1.f && tcs[LORGT].v <= 1.f) || + (tcs[UPLFT].v >= 0.f && tcs[UPRGT].v >= 0.f && tcs[LOLFT].v == 1.f && tcs[LORGT].v == 1.f)) + { + flags |= GLT_CLAMPY; + } + + // Check if this is marked as a skybox and if so, do the same for x. + // This intentionally only tests the seg's frontsector. + if (seg->frontsector->special == GLSector_Skybox) + { + sub = (float)xs_FloorToInt(tcs[UPLFT].u); + tcs[UPLFT].u -= sub; + tcs[UPRGT].u -= sub; + tcs[LOLFT].u -= sub; + tcs[LORGT].u -= sub; + if ((tcs[UPLFT].u == 0.f && tcs[LOLFT].u == 0.f && tcs[UPRGT].u <= 1.f && tcs[LORGT].u <= 1.f) || + (tcs[UPLFT].u >= 0.f && tcs[LOLFT].u >= 0.f && tcs[UPRGT].u == 1.f && tcs[LORGT].u == 1.f)) + { + flags |= GLT_CLAMPX; + } + } +} + +//========================================================================== +// +// Handle one sided walls, upper and lower texture +// +//========================================================================== +void GLWall::DoTexture(int _type,seg_t * seg, int peg, + float ceilingrefheight,float floorrefheight, + float topleft,float topright, + float bottomleft,float bottomright, + float 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; + float flh=ceilingrefheight-floorrefheight; + int texpos; + BYTE savedflags = flags; + + 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, texpos); + + type = _type; + + float floatceilingref = ceilingrefheight + tci.RowOffset(seg->sidedef->GetTextureYOffset(texpos)); + if (peg) floatceilingref += tci.mRenderHeight - flh - v_offset; + + if (!SetWallCoordinates(seg, &tci, floatceilingref, topleft, topright, bottomleft, bottomright, + seg->sidedef->GetTextureXOffset(texpos))) return; + + if (seg->linedef->special == Line_Mirror && _type == RENDERWALL_M1S && gl_mirrors) + { + PutPortal(PORTALTYPE_MIRROR); + } + else + { + + 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 = savedflags; +} + + +//========================================================================== +// +// +// +//========================================================================== + +void GLWall::DoMidTexture(seg_t * seg, bool drawfogboundary, + sector_t * front, sector_t * back, + sector_t * realfront, sector_t * realback, + float fch1, float fch2, float ffh1, float ffh2, + float bch1, float bch2, float bfh1, float bfh2) + +{ + FTexCoordInfo tci; + float topleft,bottomleft,topright,bottomright; + GLSeg glsave=glseg; + float texturetop, texturebottom; + bool wrap = (seg->linedef->flags&ML_WRAP_MIDTEX) || (seg->sidedef->Flags&WALLF_WRAP_MIDTEX); + bool mirrory = false; + + // + // + // 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, side_t::mid); + if (tci.mRenderHeight < 0) + { + mirrory = true; + tci.mRenderHeight = -tci.mRenderHeight; + tci.mScale.Y = -tci.mScale.Y; + } + float 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; + } + else + { + texturetop = MIN(realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling)) + rowoffset; + texturebottom = texturetop - tci.mRenderHeight; + } + } + 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 + // + // + float 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]. + float texwidth = tci.TextureAdjustWidth(); + + if (t_ofs >= 0) + { + float div = t_ofs / texwidth; + t_ofs = (div - xs_FloorToInt(div)) * texwidth; + } + else + { + float div = (-t_ofs) / texwidth; + t_ofs = texwidth - (div - xs_FloorToInt(div)) * texwidth; + } + + + // Now check whether the linedef is completely within the texture range of [0..1]. + // If so we should use horizontal texture clamping to prevent filtering artifacts + // at the edges. + + float textureoffset = tci.TextureOffset(t_ofs); + int righttex = int(textureoffset) + 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; + } + } + if (mirrory) + { + tci.mRenderHeight = -tci.mRenderHeight; + tci.mScale.Y = -tci.mScale.Y; + } + SetWallCoordinates(seg, &tci, texturetop, topleft, topright, bottomleft, bottomright, t_ofs); + + // + // + // draw fog sheet if required + // + // + if (drawfogboundary) + { + flags |= GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER; + type=RENDERWALL_FOGBOUNDARY; + FMaterial *savetex = gltexture; + gltexture = NULL; + PutWall(true); + if (!savetex) + { + flags &= ~(GLWF_NOSPLITUPPER|GLWF_NOSPLITLOWER); + return; + } + gltexture = savetex; + type=RENDERWALL_M2SNF; + } + else type=RENDERWALL_M2S; + + // + // + // set up alpha blending + // + // + if (seg->linedef->alpha != 0) + { + bool translucent = false; + + switch (seg->linedef->flags& ML_ADDTRANS)//TRANSBITS) + { + case 0: + RenderStyle=STYLE_Translucent; + alpha = seg->linedef->alpha; + translucent =alpha < 1. || (gltexture && gltexture->GetTransparent()); + break; + + case ML_ADDTRANS: + RenderStyle=STYLE_Add; + alpha = 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])/(tcs[LOLFT].v-tcs[UPLFT].v); + // only split the vertical area of the polygon that does not contain slopes. + float splittopv = MAX(tcs[UPLFT].v, tcs[UPRGT].v); + float splitbotv = MIN(tcs[LOLFT].v, tcs[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-tcs[UPLFT].v); + split.tcs[UPLFT].v=split.tcs[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-tcs[UPLFT].v); + split.tcs[LOLFT].v=split.tcs[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, + float ff_topleft, float ff_topright, + float ff_bottomleft, float 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, 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, side_t::bottom); + } + else + { + gltexture = FMaterial::ValidateTexture(mastersd->GetTexture(side_t::mid), false, true); + if (!gltexture) return; + gltexture->GetTexCoordInfo(&tci, mastersd, side_t::mid); + } + + to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? 0 : tci.TextureOffset(mastersd->GetTextureXOffset(side_t::mid)); + + ul = tci.FloatToTexU(to + tci.TextureOffset(seg->sidedef->GetTextureXOffset(side_t::mid))); + + texlength = tci.FloatToTexU(seg->sidedef->TexelLength); + + tcs[UPLFT].u = tcs[LOLFT].u = ul + texlength * glseg.fracleft; + tcs[UPRGT].u = tcs[LORGT].u = ul + texlength * glseg.fracright; + + float rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); + to = (rover->flags&(FF_UPPERTEXTURE | FF_LOWERTEXTURE)) ? + 0.f : tci.RowOffset(mastersd->GetTextureYOffset(side_t::mid)); + + to += rowoffset + rover->top.model->GetPlaneTexZ(rover->top.isceiling); + + tcs[UPLFT].v = tci.FloatToTexV(to - ff_topleft); + tcs[UPRGT].v = tci.FloatToTexV(to - ff_topright); + tcs[LOLFT].v = tci.FloatToTexV(to - ff_bottomleft); + tcs[LORGT].v = tci.FloatToTexV(to - ff_bottomright); + type = RENDERWALL_FFBLOCK; + CheckTexturePosition(); + } + + ztop[0] = ff_topleft; + ztop[1] = ff_topright; + zbottom[0] = ff_bottomleft;//-0.001f; + zbottom[1] = 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, float &left, float &right) +{ + left=planeref->plane->ZatPoint(vertexes[0]); + right=planeref->plane->ZatPoint(vertexes[1]); +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::InverseFloors(seg_t * seg, sector_t * frontsector, + float topleft, float topright, + float bottomleft, float bottomright) +{ + TArray & frontffloors = frontsector->e->XFloor.ffloors; + + for (unsigned int i = 0; i < frontffloors.Size(); i++) + { + F3DFloor * rover = frontffloors[i]; + if (!(rover->flags&FF_EXISTS)) continue; + if (!(rover->flags&FF_RENDERSIDES)) continue; + if (!(rover->flags&(FF_INVERTSIDES | FF_ALLSIDES))) continue; + + float ff_topleft; + float ff_topright; + float ff_bottomleft; + float 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 < bottomleft && ff_bottomright < bottomright) + { + ff_bottomleft = bottomleft; + ff_bottomright = bottomright; + } + if (ff_topleft < ff_bottomleft || ff_topright < ff_bottomright) continue; + + BuildFFBlock(seg, rover, ff_topleft, ff_topright, ff_bottomleft, ff_bottomright); + topleft = ff_bottomleft; + topright = ff_bottomright; + + if (topleft <= bottomleft && topright <= bottomright) return; + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::ClipFFloors(seg_t * seg, F3DFloor * ffloor, sector_t * frontsector, + float topleft, float topright, + float bottomleft, float bottomright) +{ + TArray & frontffloors = frontsector->e->XFloor.ffloors; + + int flags = ffloor->flags & (FF_SWIMMABLE | FF_TRANSLUCENT); + + for (unsigned int i = 0; i < frontffloors.Size(); i++) + { + F3DFloor * rover = frontffloors[i]; + if (!(rover->flags&FF_EXISTS)) continue; + if (!(rover->flags&FF_RENDERSIDES)) continue; + if ((rover->flags&(FF_SWIMMABLE | FF_TRANSLUCENT)) != flags) continue; + + float ff_topleft; + float ff_topright; + float ff_bottomleft; + float 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_topleft < bottomleft && ff_topright < bottomright) goto done; + + GetPlanePos(&rover->bottom, 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, + float fch1, float fch2, float ffh1, float ffh2, + float bch1, float bch2, float bfh1, float bfh2) + +{ + TArray & backffloors = backsector->e->XFloor.ffloors; + float 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 (fch1 < bch1 && fch2 < bch2) + { + topleft = fch1; + topright = fch2; + } + else + { + topleft = bch1; + topright = bch2; + } + + if (ffh1 > bfh1 && ffh2 > bfh2) + { + bottomleft = ffh1; + bottomright = ffh2; + } + else + { + bottomleft = bfh1; + bottomright = bfh2; + } + + for (unsigned int i = 0; i < backffloors.Size(); i++) + { + F3DFloor * rover = backffloors[i]; + if (!(rover->flags&FF_EXISTS)) continue; + if (!(rover->flags&FF_RENDERSIDES) || (rover->flags&FF_INVERTSIDES)) continue; + + float ff_topleft; + float ff_topright; + float ff_bottomleft; + float 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; + float fch1; + float ffh1; + float fch2; + float ffh2; + float frefz, crefz; + sector_t * realfront; + sector_t * realback; + sector_t * segfront; + sector_t * segback; + +#ifdef _DEBUG + if (seg->linedef - lines < 4) + { + int a = 0; + } +#endif + + // note: we always have a valid sidedef and linedef reference when getting here. + + this->seg = seg; + vertindex = 0; + vertcount = 0; + + 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; + } + frefz = realfront->GetPlaneTexZ(sector_t::floor); + crefz = realfront->GetPlaneTexZ(sector_t::ceiling); + + 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 (fabs(v1->fX() - v2->fX()) > fabs(v1->fY() - v2->fY())) + { + glseg.fracleft = (seg->v1->fX() - v1->fX()) / (v2->fX() - v1->fX()); + glseg.fracright = (seg->v2->fX() - v1->fX()) / float(v2->fX() - v1->fX()); + } + else + { + glseg.fracleft = (seg->v1->fY() - v1->fY()) / (v2->fY() - v1->fY()); + glseg.fracright = (seg->v2->fY() - v1->fY()) / (v2->fY() - v1->fY()); + } + v1 = seg->v1; + v2 = seg->v2; + } + + + vertexes[0] = v1; + vertexes[1] = v2; + + glseg.x1 = v1->fX(); + glseg.y1 = v1->fY(); + glseg.x2 = v2->fX(); + glseg.y2 = v2->fY(); + Colormap = frontsector->ColorMap; + flags = 0; + dynlightindex = -1; + lightlist = NULL; + + 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; + + zfloor[0] = ffh1 = segfront->floorplane.ZatPoint(v1); + zfloor[1] = ffh2 = segfront->floorplane.ZatPoint(v2); + zceil[0] = fch1 = segfront->ceilingplane.ZatPoint(v1); + zceil[1] = fch2 = segfront->ceilingplane.ZatPoint(v2); + + 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); + + if (seg->linedef->isVisualPortal()) + { + lineportal = linePortalToGL[seg->linedef->portalindex]; + ztop[0] = zceil[0]; + ztop[1] = zceil[1]; + zbottom[0] = zfloor[0]; + zbottom[1] = zfloor[1]; + PutPortal(PORTALTYPE_LINETOLINE); + } + else if (seg->linedef->portaltransferred > 0) + { + SkyLine(frontsector, seg->linedef); + } + else + { + // 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, + crefz, frefz, // must come from the original! + fch1, fch2, ffh1, ffh2, 0); + } + } + } + else // two sided + { + float bfh1 = segback->floorplane.ZatPoint(v1); + float bfh2 = segback->floorplane.ZatPoint(v2); + float bch1 = segback->ceilingplane.ZatPoint(v1); + float bch2 = segback->ceilingplane.ZatPoint(v2); + + 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) + { + float 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, + crefz, realback->GetPlaneTexZ(sector_t::ceiling), + fch1, fch2, bch1a, bch2a, 0); + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + if ((frontsector->ceilingplane.isSlope() || backsector->ceilingplane.isSlope()) && + 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, + crefz, 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 (seg->linedef->isVisualPortal() && seg->sidedef == seg->linedef->sidedef[0]) + { + lineportal = linePortalToGL[seg->linedef->portalindex]; + ztop[0] = bch1; + ztop[1] = bch2; + zbottom[0] = bfh1; + zbottom[1] = bfh2; + PutPortal(PORTALTYPE_LINETOLINE); + } + else 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 (fch1 < bfh1 && fch2 < bfh2) + { + bfh1 = fch1; + bfh2 = fch2; + } + + if (bfh1 > ffh1 || 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), frefz, + bfh1, bfh2, ffh1, ffh2, + frontsector->GetTexture(sector_t::ceiling) == skyflatnum && backsector->GetTexture(sector_t::ceiling) == skyflatnum ? + frefz - realback->GetPlaneTexZ(sector_t::ceiling) : + frefz - crefz); + } + else if (!(seg->sidedef->Flags & WALLF_POLYOBJ)) + { + if ((frontsector->floorplane.isSlope() || backsector->floorplane.isSlope()) && + 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), frefz, + bfh1, bfh2, ffh1, ffh2, frefz - crefz); + } + } + 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; + lightlist = NULL; + + float ffh = frontsector->GetPlaneTexZ(sector_t::floor); + float bfh = backsector->GetPlaneTexZ(sector_t::floor); + + vertindex = 0; + vertcount = 0; + 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 = v1->fX(); + glseg.y1 = v1->fY(); + glseg.x2 = v2->fX(); + glseg.y2 = v2->fY(); + 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 = -1; + + zfloor[0] = zfloor[1] = ffh; + + gltexture = FMaterial::ValidateTexture(frontsector->GetTexture(sector_t::floor), false, true); + + if (gltexture) + { + FTexCoordInfo tci; + type = RENDERWALL_BOTTOM; + gltexture->GetTexCoordInfo(&tci, 1.f, 1.f); + SetWallCoordinates(seg, &tci, 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..9f521ad11 --- /dev/null +++ b/src/gl/scene/gl_walls_draw.cpp @@ -0,0 +1,477 @@ +/* +** 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" +#include "gl/renderer/gl_quaddrawer.h" + +EXTERN_CVAR(Bool, gl_seamless) + +//========================================================================== +// +// Collect lights for shader +// +//========================================================================== +FDynLightData lightdata; + + +void GLWall::SetupLights() +{ + if (RenderStyle == STYLE_Add) return; // no lights on additively blended surfaces. + + // 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: + 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 = node->lightsource->X(); + float y = node->lightsource->Y(); + float z = node->lightsource->Z(); + float dist = fabsf(p.DistToPoint(x, z, y)); + float radius = node->lightsource->GetRadius(); + 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(seg->frontsector->PortalGroup, p, node->lightsource, true, lightdata); + } + } + } + node = node->nextLight; + } + + dynlightindex = GLRenderer->mLights->UploadLights(lightdata); +} + +//========================================================================== +// +// build the vertices for this wall +// +//========================================================================== + +void GLWall::MakeVertices(bool nosplit) +{ + if (vertcount == 0) + { + bool split = (gl_seamless && !nosplit && seg->sidedef != NULL && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & GLWF_NOSPLIT)); + + FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer(); + + ptr->Set(glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v); + ptr++; + if (split && glseg.fracleft == 0) SplitLeftEdge(ptr); + ptr->Set(glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v); + ptr++; + if (split && !(flags & GLWF_NOSPLITUPPER)) SplitUpperEdge(ptr); + ptr->Set(glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v); + ptr++; + if (split && glseg.fracright == 1) SplitRightEdge(ptr); + ptr->Set(glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v); + ptr++; + if (split && !(flags & GLWF_NOSPLITLOWER)) SplitLowerEdge(ptr); + vertcount = GLRenderer->mVBO->GetCount(ptr, &vertindex); + } +} + + +//========================================================================== +// +// General purpose wall rendering function +// everything goes through here +// +//========================================================================== + +void GLWall::RenderWall(int textured) +{ + gl_RenderState.Apply(); + gl_RenderState.ApplyLightIndex(dynlightindex); + if (gl.buffermethod != BM_DEFERRED) + { + MakeVertices(!(textured&RWF_NOSPLIT)); + } + else if (vertcount == 0) + { + // This should never happen but in case it actually does, use the quad drawer as fallback (without edge splitting.) + // This way it at least gets drawn. + FQuadDrawer qd; + qd.Set(0, glseg.x1, zbottom[0], glseg.y1, tcs[LOLFT].u, tcs[LOLFT].v); + qd.Set(1, glseg.x1, ztop[0], glseg.y1, tcs[UPLFT].u, tcs[UPLFT].v); + qd.Set(2, glseg.x2, ztop[1], glseg.y2, tcs[UPRGT].u, tcs[UPRGT].v); + qd.Set(3, glseg.x2, zbottom[1], glseg.y2, tcs[LORGT].u, tcs[LORGT].v); + qd.Render(GL_TRIANGLE_FAN); + vertexcount += 4; + return; + } + GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, vertindex, vertcount); + vertexcount += vertcount; +} + +//========================================================================== +// +// +// +//========================================================================== + +void GLWall::RenderFogBoundary() +{ + if (gl_fogmode && gl_fixedcolormap == 0) + { + if (!gl.legacyMode) + { + 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); + } + else + { + RenderFogBoundaryCompat(); + } + } +} + + +//========================================================================== +// +// +// +//========================================================================== +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(); + + if (!gl.legacyMode) + { + // 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. + tcs[LOLFT].u = tcs[LORGT].u = tcs[UPLFT].u = tcs[UPRGT].u = v.X(); + tcs[LOLFT].v = tcs[LORGT].v = tcs[UPLFT].v = tcs[UPRGT].v = v.Z(); + + gl_RenderState.EnableTextureMatrix(true); + gl_RenderState.mTextureMatrix.computeNormalMatrix(gl_RenderState.mViewMatrix); + } + else + { + glNormal3fv(&v[0]); + } + + // 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::RenderTextured(int rflags) +{ + int tmode = gl_RenderState.GetTextureMode(); + int rel = rellight + getExtraLight(); + + if (flags & GLWF_GLOW) + { + gl_RenderState.EnableGlow(true); + gl_RenderState.SetGlowPlanes(topplane, bottomplane); + gl_RenderState.SetGlowParams(topglowcolor, bottomglowcolor); + } + gl_RenderState.SetMaterial(gltexture, flags & 3, 0, -1, false); + + if (type == RENDERWALL_M2SNF) + { + if (flags & GLT_CLAMPY) + { + if (tmode == TM_MODULATE) gl_RenderState.SetTextureMode(TM_CLAMPY); + } + gl_SetFog(255, 0, NULL, false); + } + + float absalpha = fabsf(alpha); + if (lightlist == NULL) + { + gl_SetColor(lightlevel, rel, Colormap, absalpha); + if (type != RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, RenderStyle == STYLE_Add); + RenderWall(rflags); + } + else + { + gl_RenderState.EnableSplit(true); + + for (unsigned i = 0; i < lightlist->Size(); i++) + { + secplane_t &lowplane = i == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[i + 1].plane; + // this must use the exact same calculation method as GLWall::Process etc. + float low1 = lowplane.ZatPoint(vertexes[0]); + float low2 = lowplane.ZatPoint(vertexes[1]); + + if (low1 < ztop[0] || low2 < ztop[1]) + { + int thisll = (*lightlist)[i].caster != NULL ? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel; + FColormap thiscm; + thiscm.FadeColor = Colormap.FadeColor; + thiscm.CopyFrom3DLight(&(*lightlist)[i]); + gl_SetColor(thisll, rel, thiscm, absalpha); + if (type != RENDERWALL_M2SNF) gl_SetFog(thisll, rel, &thiscm, RenderStyle == STYLE_Add); + gl_RenderState.SetSplitPlanes((*lightlist)[i].plane, lowplane); + RenderWall(rflags); + } + if (low1 <= zbottom[0] && low2 <= zbottom[1]) break; + } + + gl_RenderState.EnableSplit(false); + } + gl_RenderState.SetTextureMode(tmode); + gl_RenderState.EnableGlow(false); +} + +//========================================================================== +// +// +// +//========================================================================== + +void GLWall::RenderTranslucentWall() +{ + if (gltexture) + { + if (gl_fixedcolormap == CM_DEFAULT && gl_lights && gl.lightmethod == LM_DIRECT) + { + SetupLights(); + } + if (!gltexture->GetTransparent()) gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_threshold); + else gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + if (RenderStyle == STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA,GL_ONE); + RenderTextured(RWF_TEXTURED | RWF_NOSPLIT); + if (RenderStyle == STYLE_Add) gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else + { + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_SetColor(lightlevel, 0, Colormap, fabsf(alpha)); + gl_SetFog(lightlevel, 0, &Colormap, RenderStyle == STYLE_Add); + gl_RenderState.EnableTexture(false); + RenderWall(RWF_NOSPLIT); + gl_RenderState.EnableTexture(true); + } +} + +//========================================================================== +// +// +// +//========================================================================== +void GLWall::Draw(int pass) +{ + switch (pass) + { + case GLPASS_LIGHTSONLY: + SetupLights(); + break; + + case GLPASS_ALL: + SetupLights(); + // fall through + case GLPASS_PLAIN: + RenderTextured(RWF_TEXTURED); + break; + + case GLPASS_TRANSLUCENT: + + switch (type) + { + case RENDERWALL_MIRRORSURFACE: + RenderMirrorSurface(); + break; + + case RENDERWALL_FOGBOUNDARY: + RenderFogBoundary(); + break; + + default: + RenderTranslucentWall(); + break; + } + break; + + case GLPASS_LIGHTTEX: + case GLPASS_LIGHTTEX_ADDITIVE: + case GLPASS_LIGHTTEX_FOGGY: + RenderLightsCompat(pass); + break; + + case GLPASS_TEXONLY: + gl_RenderState.SetMaterial(gltexture, flags & 3, 0, -1, false); + RenderWall(RWF_TEXTURED); + break; + } +} diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp new file mode 100644 index 000000000..598254c10 --- /dev/null +++ b/src/gl/scene/gl_weapon.cpp @@ -0,0 +1,487 @@ +/* +** 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" +#include "gl/renderer/gl_quaddrawer.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,DPSprite *psp, float sx, float 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 17:10 21:9 + static float xratio[] = {1.f, 3.f/4, 5.f/6, 40.f/51, 1.f, 40.f/51, 4.f/7}; + + // [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->GetSprite(), psp->GetFrame(), 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 = 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 - sy - r.top; + + AWeapon * wi=player->ReadyWeapon; + if (wi && wi->YAdjust != 0) + { + float fYAd = wi->YAdjust; + if (screenblocks >= 11) + { + ftexturemid -= fYAd; + } + else if (!st_scale) + { + ftexturemid -= 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(); + FQuadDrawer qd; + qd.Set(0, x1, y1, 0, fU1, fV1); + qd.Set(1, x1, y2, 0, fU1, fV2); + qd.Set(2, x2, y1, 0, fU2, fV1); + qd.Set(3, x2, y2, 0, fU2, fV2); + qd.Render(GL_TRIANGLE_STRIP); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.5f); +} + +//========================================================================== +// +// +// +//========================================================================== + +static bool isBright(DPSprite *psp) +{ + if (psp != nullptr && psp->GetState() != nullptr) + { + bool disablefullbright = false; + FTextureID lump = gl_GetSpriteFrame(psp->GetSprite(), psp->GetFrame(), 0, 0, NULL); + if (lump.isValid()) + { + FMaterial * tex = FMaterial::ValidateTexture(lump, false, false); + if (tex) + disablefullbright = tex->tex->gl_info.bDisableFullbright; + } + return psp->GetState()->GetFullbright() && !disablefullbright; + } + return false; +} + +//========================================================================== +// +// R_DrawPlayerSprites +// +//========================================================================== + +EXTERN_CVAR(Bool, gl_brightfog) + +void FGLRenderer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) +{ + bool brightflash = false; + unsigned int i; + int lightlevel=0; + 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; + + float bobx, boby, wx, wy; + DPSprite *weapon; + + P_BobWeapon(camera->player, &bobx, &boby, r_TicFracF); + + // Interpolate the main weapon layer once so as to be able to add it to other layers. + if ((weapon = camera->player->FindPSprite(PSP_WEAPON)) != nullptr) + { + if (weapon->firstTic) + { + wx = weapon->x; + wy = weapon->y; + } + else + { + wx = weapon->oldx + (weapon->x - weapon->oldx) * r_TicFracF; + wy = weapon->oldy + (weapon->y - weapon->oldy) * r_TicFracF; + } + } + else + { + wx = 0; + wy = 0; + } + + if (gl_fixedcolormap) + { + lightlevel=255; + cm.Clear(); + fakesec = viewsector; + } + else + { + fakesec = gl_FakeFlat(viewsector, &fs, false); + + // calculate light level for weapon sprites + lightlevel = gl_ClampLight(fakesec->lightlevel); + + // calculate colormap for weapon sprites + if (viewsector->e->XFloor.ffloors.Size() && !glset.nocoloredspritelighting) + { + TArray & lightlist = viewsector->e->XFloor.lightlist; + for(i=0;ifloorplane.ZatPoint(ViewPos); + } + + if (lightbottomviewz) + { + cm = lightlist[i].extra_colormap; + lightlevel = gl_ClampLight(*lightlist[i].p_lightlevel); + break; + } + } + } + else + { + cm=fakesec->ColorMap; + if (glset.nocoloredspritelighting) cm.ClearColor(); + } + + lightlevel = gl_CalcLightLevel(lightlevel, getExtraLight(), true); + + if (glset.lightmode == 8) + { + // 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; + } + else + { + lightlevel = (2 * lightlevel + 255) / 3; + } + lightlevel = gl_CheckSpriteGlow(viewsector, lightlevel, playermo->Pos()); + + } + + // 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; + } + } + if (vis.RenderStyle.AsDWORD == 0) + { + // This is RenderStyle None. + return; + } + + // 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; + } + } + } + + 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 = vis.Alpha; + } + + // now draw the different layers of the weapon + gl_RenderState.EnableBrightmap(true); + gl_RenderState.SetObjectColor(ThingColor); + gl_RenderState.AlphaFunc(GL_GEQUAL, gl_mask_sprite_threshold); + + // 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(DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext()) + { + if (psp->GetState() != nullptr) + { + FColormap cmc = cm; + int ll = lightlevel; + if (isBright(psp)) + { + 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; + } + ll = 255; + } + // 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(ll, 0, cmc, trans, true); + } + + if (psp->firstTic) + { // Can't interpolate the first tic. + psp->firstTic = false; + psp->oldx = psp->x; + psp->oldy = psp->y; + } + + float sx = psp->oldx + (psp->x - psp->oldx) * r_TicFracF; + float sy = psp->oldy + (psp->y - psp->oldy) * r_TicFracF; + + if (psp->Flags & PSPF_ADDBOB) + { + sx += bobx; + sy += boby; + } + + if (psp->Flags & PSPF_ADDWEAPON && psp->GetID() != PSP_WEAPON) + { + sx += wx; + sy += wy; + } + + + DrawPSprite(player, psp, sx, sy, 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() +{ + 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 (DPSprite *psp = player->FindPSprite(PSP_TARGETCENTER); psp != nullptr; psp = psp->GetNext()) + { + if (psp->GetState() != nullptr) DrawPSprite(player, psp, psp->x, psp->y, false, 0, false); + } +} \ No newline at end of file diff --git a/src/gl/shaders/gl_bloomshader.cpp b/src/gl/shaders/gl_bloomshader.cpp new file mode 100644 index 000000000..9e8f60133 --- /dev/null +++ b/src/gl/shaders/gl_bloomshader.cpp @@ -0,0 +1,81 @@ +/* +** gl_bloomshader.cpp +** Shaders used to do bloom +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** 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 "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/shaders/gl_bloomshader.h" + +void FBloomExtractShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomextract.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/bloomextract"); + mShader.SetAttribLocation(0, "PositionInProjection"); + SceneTexture.Init(mShader, "SceneTexture"); + Exposure.Init(mShader, "ExposureAdjustment"); + Scale.Init(mShader, "Scale"); + Offset.Init(mShader, "Offset"); + } + mShader.Bind(); +} + +void FBloomCombineShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomcombine.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/bloomcombine"); + mShader.SetAttribLocation(0, "PositionInProjection"); + BloomTexture.Init(mShader, "Bloom"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_bloomshader.h b/src/gl/shaders/gl_bloomshader.h new file mode 100644 index 000000000..b20277a42 --- /dev/null +++ b/src/gl/shaders/gl_bloomshader.h @@ -0,0 +1,31 @@ +#ifndef __GL_BLOOMSHADER_H +#define __GL_BLOOMSHADER_H + +#include "gl_shaderprogram.h" + +class FBloomExtractShader +{ +public: + void Bind(); + + FBufferedUniformSampler SceneTexture; + FBufferedUniform1f Exposure; + FBufferedUniform2f Scale; + FBufferedUniform2f Offset; + +private: + FShaderProgram mShader; +}; + +class FBloomCombineShader +{ +public: + void Bind(); + + FBufferedUniformSampler BloomTexture; + +private: + FShaderProgram mShader; +}; + +#endif \ No newline at end of file diff --git a/src/gl/shaders/gl_blurshader.cpp b/src/gl/shaders/gl_blurshader.cpp new file mode 100644 index 000000000..bf2e29c7e --- /dev/null +++ b/src/gl/shaders/gl_blurshader.cpp @@ -0,0 +1,261 @@ +/* +** gl_blurshader.cpp +** Gaussian blur shader +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** 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 "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/shaders/gl_blurshader.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/renderer/gl_renderer.h" + +//========================================================================== +// +// Performs a vertical gaussian blur pass +// +//========================================================================== + +void FBlurShader::BlurVertical(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height) +{ + Blur(renderer, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, true); +} + +//========================================================================== +// +// Performs a horizontal gaussian blur pass +// +//========================================================================== + +void FBlurShader::BlurHorizontal(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height) +{ + Blur(renderer, blurAmount, sampleCount, inputTexture, outputFrameBuffer, width, height, false); +} + +//========================================================================== +// +// Helper for BlurVertical and BlurHorizontal. Executes the actual pass +// +//========================================================================== + +void FBlurShader::Blur(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical) +{ + BlurSetup *setup = GetSetup(blurAmount, sampleCount); + if (vertical) + setup->VerticalShader->Bind(); + else + setup->HorizontalShader->Bind(); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, inputTexture); + 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); + + glBindFramebuffer(GL_FRAMEBUFFER, outputFrameBuffer); + glViewport(0, 0, width, height); + glDisable(GL_BLEND); + + renderer->RenderScreenQuad(); +} + +//========================================================================== +// +// Compiles the blur shaders needed for the specified blur amount and +// kernel size +// +//========================================================================== + +FBlurShader::BlurSetup *FBlurShader::GetSetup(float blurAmount, int sampleCount) +{ + for (size_t mBlurSetupIndex = 0; mBlurSetupIndex < mBlurSetups.Size(); mBlurSetupIndex++) + { + if (mBlurSetups[mBlurSetupIndex].blurAmount == blurAmount && mBlurSetups[mBlurSetupIndex].sampleCount == sampleCount) + { + return &mBlurSetups[mBlurSetupIndex]; + } + } + + BlurSetup blurSetup(blurAmount, sampleCount); + + FString vertexCode = VertexShaderCode(); + FString horizontalCode = FragmentShaderCode(blurAmount, sampleCount, false); + FString verticalCode = FragmentShaderCode(blurAmount, sampleCount, true); + + blurSetup.VerticalShader = std::make_shared(); + blurSetup.VerticalShader->Compile(FShaderProgram::Vertex, "vertical blur vertex shader", vertexCode, "", 330); + blurSetup.VerticalShader->Compile(FShaderProgram::Fragment, "vertical blur fragment shader", verticalCode, "", 330); + blurSetup.VerticalShader->SetFragDataLocation(0, "FragColor"); + blurSetup.VerticalShader->SetAttribLocation(0, "PositionInProjection"); + blurSetup.VerticalShader->Link("vertical blur"); + blurSetup.VerticalShader->Bind(); + glUniform1i(glGetUniformLocation(*blurSetup.VerticalShader.get(), "SourceTexture"), 0); + + blurSetup.HorizontalShader = std::make_shared(); + blurSetup.HorizontalShader->Compile(FShaderProgram::Vertex, "horizontal blur vertex shader", vertexCode, "", 330); + blurSetup.HorizontalShader->Compile(FShaderProgram::Fragment, "horizontal blur fragment shader", horizontalCode, "", 330); + blurSetup.HorizontalShader->SetFragDataLocation(0, "FragColor"); + blurSetup.HorizontalShader->SetAttribLocation(0, "PositionInProjection"); + blurSetup.HorizontalShader->Link("horizontal blur"); + blurSetup.HorizontalShader->Bind(); + glUniform1i(glGetUniformLocation(*blurSetup.HorizontalShader.get(), "SourceTexture"), 0); + + mBlurSetups.Push(blurSetup); + + return &mBlurSetups[mBlurSetups.Size() - 1]; +} + +//========================================================================== +// +// The vertex shader GLSL code +// +//========================================================================== + +FString FBlurShader::VertexShaderCode() +{ + return R"( + in vec4 PositionInProjection; + out vec2 TexCoord; + + void main() + { + gl_Position = PositionInProjection; + TexCoord = (gl_Position.xy + 1.0) * 0.5; + } + )"; +} + +//========================================================================== +// +// Generates the fragment shader GLSL code for a specific blur setup +// +//========================================================================== + +FString FBlurShader::FragmentShaderCode(float blurAmount, int sampleCount, bool vertical) +{ + TArray sampleWeights; + TArray sampleOffsets; + ComputeBlurSamples(sampleCount, blurAmount, sampleWeights, sampleOffsets); + + const char *fragmentShader = + R"( + in vec2 TexCoord; + uniform sampler2D SourceTexture; + out vec4 FragColor; + #if __VERSION__ < 130 + uniform float ScaleX; + uniform float ScaleY; + vec4 textureOffset(sampler2D s, vec2 texCoord, ivec2 offset) + { + return texture2D(s, texCoord + vec2(ScaleX * float(offset.x), ScaleY * float(offset.y))); + } + #endif + void main() + { + FragColor = %s; + } + )"; + + FString loopCode; + for (int i = 0; i < sampleCount; i++) + { + if (i > 0) + loopCode += " + "; + + if (vertical) + loopCode.AppendFormat("\r\n\t\t\ttextureOffset(SourceTexture, TexCoord, ivec2(0, %d)) * %f", sampleOffsets[i], (double)sampleWeights[i]); + else + loopCode.AppendFormat("\r\n\t\t\ttextureOffset(SourceTexture, TexCoord, ivec2(%d, 0)) * %f", sampleOffsets[i], (double)sampleWeights[i]); + } + + FString code; + code.Format(fragmentShader, loopCode.GetChars()); + return code; +} + +//========================================================================== +// +// Calculates the sample weight for a specific offset in the kernel +// +//========================================================================== + +float FBlurShader::ComputeGaussian(float n, float theta) // theta = Blur Amount +{ + return (float)((1.0f / sqrtf(2 * (float)M_PI * theta)) * expf(-(n * n) / (2.0f * theta * theta))); +} + +//========================================================================== +// +// Calculates the sample weights and offsets +// +//========================================================================== + +void FBlurShader::ComputeBlurSamples(int sampleCount, float blurAmount, TArray &sampleWeights, TArray &sampleOffsets) +{ + sampleWeights.Resize(sampleCount); + sampleOffsets.Resize(sampleCount); + + sampleWeights[0] = ComputeGaussian(0, blurAmount); + sampleOffsets[0] = 0; + + float totalWeights = sampleWeights[0]; + + for (int i = 0; i < sampleCount / 2; i++) + { + float weight = ComputeGaussian(i + 1.0f, blurAmount); + + sampleWeights[i * 2 + 1] = weight; + sampleWeights[i * 2 + 2] = weight; + sampleOffsets[i * 2 + 1] = i + 1; + sampleOffsets[i * 2 + 2] = -i - 1; + + totalWeights += weight * 2; + } + + for (int i = 0; i < sampleCount; i++) + { + sampleWeights[i] /= totalWeights; + } +} diff --git a/src/gl/shaders/gl_blurshader.h b/src/gl/shaders/gl_blurshader.h new file mode 100644 index 000000000..92ef5f115 --- /dev/null +++ b/src/gl/shaders/gl_blurshader.h @@ -0,0 +1,41 @@ +#ifndef __GL_BLURSHADER_H +#define __GL_BLURSHADER_H + +#include "gl_shaderprogram.h" +#include + +class FGLRenderer; + +class FBlurShader +{ +public: + void BlurVertical(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height); + void BlurHorizontal(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height); + +private: + void Blur(FGLRenderer *renderer, float blurAmount, int sampleCount, GLuint inputTexture, GLuint outputFrameBuffer, int width, int height, bool vertical); + + struct BlurSetup + { + BlurSetup(float blurAmount, int sampleCount) : blurAmount(blurAmount), sampleCount(sampleCount) { } + + float blurAmount; + int sampleCount; + std::shared_ptr VerticalShader; + std::shared_ptr HorizontalShader; + FBufferedUniform1f VerticalScaleX, VerticalScaleY; + FBufferedUniform1f HorizontalScaleX, HorizontalScaleY; + }; + + BlurSetup *GetSetup(float blurAmount, int sampleCount); + + FString VertexShaderCode(); + FString FragmentShaderCode(float blurAmount, int sampleCount, bool vertical); + + float ComputeGaussian(float n, float theta); + void ComputeBlurSamples(int sampleCount, float blurAmount, TArray &sample_weights, TArray &sample_offsets); + + TArray mBlurSetups; +}; + +#endif \ No newline at end of file diff --git a/src/gl/shaders/gl_colormapshader.cpp b/src/gl/shaders/gl_colormapshader.cpp new file mode 100644 index 000000000..f28003150 --- /dev/null +++ b/src/gl/shaders/gl_colormapshader.cpp @@ -0,0 +1,67 @@ +/* +** gl_colormapshader.cpp +** Applies a fullscreen colormap to the scene +** +**--------------------------------------------------------------------------- +** Copyright 2016 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 "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/shaders/gl_colormapshader.h" + +void FColormapShader::Bind() +{ + auto &shader = mShader; + if (!shader) + { + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/colormap.fp", "", 330); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/colormap"); + shader.SetAttribLocation(0, "PositionInProjection"); + MapStart.Init(shader, "uFixedColormapStart"); + MapRange.Init(shader, "uFixedColormapRange"); + } + shader.Bind(); +} + diff --git a/src/gl/shaders/gl_colormapshader.h b/src/gl/shaders/gl_colormapshader.h new file mode 100644 index 000000000..b20c23a4c --- /dev/null +++ b/src/gl/shaders/gl_colormapshader.h @@ -0,0 +1,20 @@ +#ifndef __GL_COLORMAPSHADER_H +#define __GL_COLORMAPSHADER_H + +#include "gl_shaderprogram.h" + +class FColormapShader +{ +public: + void Bind(); + + FBufferedUniformSampler SceneTexture; + FUniform4f MapStart; + FUniform4f MapRange; + +private: + + FShaderProgram mShader; +}; + +#endif \ No newline at end of file diff --git a/src/gl/shaders/gl_lensshader.cpp b/src/gl/shaders/gl_lensshader.cpp new file mode 100644 index 000000000..4dc23f14d --- /dev/null +++ b/src/gl/shaders/gl_lensshader.cpp @@ -0,0 +1,68 @@ +/* +** gl_lensshader.cpp +** Lens distortion with chromatic aberration shader +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** 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 "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/shaders/gl_lensshader.h" + +void FLensShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/lensdistortion.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/lensdistortion"); + mShader.SetAttribLocation(0, "PositionInProjection"); + InputTexture.Init(mShader, "InputTexture"); + AspectRatio.Init(mShader, "Aspect"); + Scale.Init(mShader, "Scale"); + LensDistortionCoefficient.Init(mShader, "k"); + CubicDistortionValue.Init(mShader, "kcube"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_lensshader.h b/src/gl/shaders/gl_lensshader.h new file mode 100644 index 000000000..7e9ef6392 --- /dev/null +++ b/src/gl/shaders/gl_lensshader.h @@ -0,0 +1,21 @@ +#ifndef __GL_LENSSHADER_H +#define __GL_LENSSHADER_H + +#include "gl_shaderprogram.h" + +class FLensShader +{ +public: + void Bind(); + + FBufferedUniformSampler InputTexture; + FBufferedUniform1f AspectRatio; + FBufferedUniform1f Scale; + FBufferedUniform4f LensDistortionCoefficient; + FBufferedUniform4f CubicDistortionValue; + +private: + FShaderProgram mShader; +}; + +#endif \ No newline at end of file diff --git a/src/gl/shaders/gl_presentshader.cpp b/src/gl/shaders/gl_presentshader.cpp new file mode 100644 index 000000000..426253639 --- /dev/null +++ b/src/gl/shaders/gl_presentshader.cpp @@ -0,0 +1,69 @@ +/* +** gl_presentshader.cpp +** Copy rendered texture to back buffer, possibly with gamma correction +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** 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 "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/shaders/gl_presentshader.h" + +void FPresentShader::Bind() +{ + if (!mShader) + { + mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquadscale.vp", "", 330); + mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/present.fp", "", 330); + mShader.SetFragDataLocation(0, "FragColor"); + mShader.Link("shaders/glsl/present"); + mShader.SetAttribLocation(0, "PositionInProjection"); + mShader.SetAttribLocation(1, "UV"); + InputTexture.Init(mShader, "InputTexture"); + InvGamma.Init(mShader, "InvGamma"); + Contrast.Init(mShader, "Contrast"); + Brightness.Init(mShader, "Brightness"); + Scale.Init(mShader, "UVScale"); + } + mShader.Bind(); +} diff --git a/src/gl/shaders/gl_presentshader.h b/src/gl/shaders/gl_presentshader.h new file mode 100644 index 000000000..6f4e899bb --- /dev/null +++ b/src/gl/shaders/gl_presentshader.h @@ -0,0 +1,21 @@ +#ifndef __GL_PRESENTSHADER_H +#define __GL_PRESENTSHADER_H + +#include "gl_shaderprogram.h" + +class FPresentShader +{ +public: + void Bind(); + + FBufferedUniformSampler InputTexture; + FBufferedUniform1f InvGamma; + FBufferedUniform1f Contrast; + FBufferedUniform1f Brightness; + FBufferedUniform2f Scale; + +private: + FShaderProgram mShader; +}; + +#endif \ 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..3c574bd62 --- /dev/null +++ b/src/gl/shaders/gl_shader.cpp @@ -0,0 +1,669 @@ +/* +** 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/system/gl_debug.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/shaders/gl_shaderprogram.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! +// + FString vp_comb; + + assert(GLRenderer->mLights != NULL); + // On the shader side there is no difference between LM_DEFERRED and LM_DIRECT, it only decides how the buffer is initialized. + unsigned int lightbuffertype = GLRenderer->mLights->GetBufferType(); + unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize(); + if (lightbuffertype == GL_UNIFORM_BUFFER) + { + // This differentiation is for some Intel drivers which fail on #extension, so use of #version 140 is necessary + if (gl.glslversion < 1.4f) + { + 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"; + } + + if (gl.buffermethod == BM_DEFERRED) + { + vp_comb << "#define USE_QUAD_DRAWER\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; + } + } + + if (gl.flags & RFL_NO_CLIP_PLANES) + { + // On ATI's GL3 drivers we have to disable gl_ClipDistance because it's hopelessly broken. + // This will cause some glitches and regressions but is the only way to avoid total display garbage. + vp_comb.Substitute("gl_ClipDistance", "//"); + } + + hVertProg = glCreateShader(GL_VERTEX_SHADER); + hFragProg = glCreateShader(GL_FRAGMENT_SHADER); + + FGLDebug::LabelObject(GL_SHADER, hVertProg, vert_prog_lump); + FGLDebug::LabelObject(GL_SHADER, hFragProg, frag_prog_lump); + + 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(); + FGLDebug::LabelObject(GL_PROGRAM, hShader, name); + + 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"); + muSplitBottomPlane.Init(hShader, "uSplitBottomPlane"); + muSplitTopPlane.Init(hShader, "uSplitTopPlane"); + muClipLine.Init(hShader, "uClipLine"); + muFixedColormap.Init(hShader, "uFixedColormap"); + muInterpolationFactor.Init(hShader, "uInterpolationFactor"); + muClipHeight.Init(hShader, "uClipHeight"); + muClipHeightDirection.Init(hShader, "uClipHeightDirection"); + 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"); + vertexmatrix_index = glGetUniformLocation(hShader, "uQuadVertices"); + texcoordmatrix_index = glGetUniformLocation(hShader, "uQuadTexCoords"); + quadmode_index = glGetUniformLocation(hShader, "uQuadMode"); + + if (!gl.legacyMode && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + { + int tempindex = glGetUniformBlockIndex(hShader, "LightBufferUBO"); + if (tempindex != -1) glUniformBlockBinding(hShader, tempindex, LIGHTBUF_BINDINGPOINT); + } + + glUseProgram(hShader); + if (quadmode_index > 0) glUniform1i(quadmode_index, 0); + + // 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); + int 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() +{ + if (!gl.legacyMode) CompileShaders(); +} + +//========================================================================== +// +// +// +//========================================================================== + +FShaderManager::~FShaderManager() +{ + if (!gl.legacyMode) 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) +{ + if (gl.legacyMode) + { + glMatrixMode(GL_PROJECTION); + glLoadMatrixf(proj->get()); + glMatrixMode(GL_MODELVIEW); + glLoadMatrixf(view->get()); + } + else + { + 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..e205d0cf8 --- /dev/null +++ b/src/gl/shaders/gl_shader.h @@ -0,0 +1,368 @@ + +#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, + VATTR_NORMAL = 4 +}; + + +//========================================================================== +// +// +//========================================================================== + +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); + } + } + + void Set(float f1, float f2) + { + if (mBuffer[0] != f1 || mBuffer[1] != f2) + { + mBuffer[0] = f1; + mBuffer[1] = f2; + glUniform2fv(mIndex, 1, mBuffer); + } + } + +}; + +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 FBufferedUniformSampler +{ + int mBuffer; + int mIndex; + +public: + void Init(GLuint hShader, const GLchar *name) + { + mIndex = glGetUniformLocation(hShader, name); + mBuffer = -1; + } + + void Set(int newvalue) + { + if (newvalue != mBuffer) + { + mBuffer = newvalue; + glUniform1i(mIndex, newvalue); + } + } +}; + + +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; + FUniform4f muSplitBottomPlane; + FUniform4f muSplitTopPlane; + FUniform4f muClipLine; + FBufferedUniform1f muInterpolationFactor; + FBufferedUniform1f muClipHeight; + FBufferedUniform1f muClipHeightDirection; + FBufferedUniform1f muAlphaThreshold; + FBufferedUniform1f muTimer; + + int lights_index; + int projectionmatrix_index; + int viewmatrix_index; + int modelmatrix_index; + int texturematrix_index; +public: + int vertexmatrix_index; + int texcoordmatrix_index; + int quadmode_index; + int fakevb_index; +private: + int currentglowstate = 0; + int currentsplitstate = 0; + int currentcliplinestate = 0; + int currentfixedcolormap = 0; + bool currentTextureMatrixState = true;// by setting the matrix state to 'true' it is guaranteed to be set the first time the render state gets applied. + bool currentModelMatrixState = true; + +public: + FShader(const char *name) + : mName(name) + { + hShader = hVertProg = hFragProg = 0; + } + + ~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_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp new file mode 100644 index 000000000..80a7ea99e --- /dev/null +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -0,0 +1,259 @@ +/* +** gl_shaderprogram.cpp +** GLSL shader program compile and link +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** 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 "gl/gl_functions.h" +#include "vectors.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" +#include "gl/system/gl_debug.h" +#include "gl/shaders/gl_shaderprogram.h" +#include "w_wad.h" +#include "i_system.h" +#include "doomerrors.h" + +FShaderProgram::FShaderProgram() +{ + for (int i = 0; i < NumShaderTypes; i++) + mShaders[i] = 0; +} + +//========================================================================== +// +// Free shader program resources +// +//========================================================================== + +FShaderProgram::~FShaderProgram() +{ + if (mProgram != 0) + glDeleteProgram(mProgram); + + for (int i = 0; i < NumShaderTypes; i++) + { + if (mShaders[i] != 0) + glDeleteShader(mShaders[i]); + } +} + +//========================================================================== +// +// Creates an OpenGL shader object for the specified type of shader +// +//========================================================================== + +void FShaderProgram::CreateShader(ShaderType type) +{ + GLenum gltype = 0; + switch (type) + { + default: + case Vertex: gltype = GL_VERTEX_SHADER; break; + case Fragment: gltype = GL_FRAGMENT_SHADER; break; + } + mShaders[type] = glCreateShader(gltype); +} + +//========================================================================== +// +// Compiles a shader and attaches it the program object +// +//========================================================================== + +void FShaderProgram::Compile(ShaderType type, const char *lumpName, const char *defines, int maxGlslVersion) +{ + int lump = Wads.CheckNumForFullName(lumpName); + if (lump == -1) I_FatalError("Unable to load '%s'", lumpName); + FString code = Wads.ReadLump(lump).GetString().GetChars(); + Compile(type, lumpName, code, defines, maxGlslVersion); +} + +void FShaderProgram::Compile(ShaderType type, const char *name, const FString &code, const char *defines, int maxGlslVersion) +{ + CreateShader(type); + + const auto &handle = mShaders[type]; + + FGLDebug::LabelObject(GL_SHADER, handle, name); + + FString patchedCode = PatchShader(type, code, defines, maxGlslVersion); + int lengths[1] = { (int)patchedCode.Len() }; + const char *sources[1] = { patchedCode.GetChars() }; + glShaderSource(handle, 1, sources, lengths); + + glCompileShader(handle); + + GLint status = 0; + glGetShaderiv(handle, GL_COMPILE_STATUS, &status); + if (status == GL_FALSE) + { + I_FatalError("Compile Shader '%s':\n%s\n", name, GetShaderInfoLog(handle).GetChars()); + } + else + { + if (mProgram == 0) + mProgram = glCreateProgram(); + glAttachShader(mProgram, handle); + } +} + +//========================================================================== +// +// Binds a fragment output variable to a frame buffer render target +// +//========================================================================== + +void FShaderProgram::SetFragDataLocation(int index, const char *name) +{ + glBindFragDataLocation(mProgram, index, name); +} + +//========================================================================== +// +// Links a program with the compiled shaders +// +//========================================================================== + +void FShaderProgram::Link(const char *name) +{ + FGLDebug::LabelObject(GL_PROGRAM, mProgram, name); + glLinkProgram(mProgram); + + GLint status = 0; + glGetProgramiv(mProgram, GL_LINK_STATUS, &status); + if (status == GL_FALSE) + { + I_FatalError("Link Shader '%s':\n%s\n", name, GetProgramInfoLog(mProgram).GetChars()); + } +} + +//========================================================================== +// +// Set vertex attribute location +// +//========================================================================== + +void FShaderProgram::SetAttribLocation(int index, const char *name) +{ + glBindAttribLocation(mProgram, index, name); +} + +//========================================================================== +// +// Makes the shader the active program +// +//========================================================================== + +void FShaderProgram::Bind() +{ + glUseProgram(mProgram); +} + +//========================================================================== +// +// Returns the shader info log (warnings and compile errors) +// +//========================================================================== + +FString FShaderProgram::GetShaderInfoLog(GLuint handle) +{ + static char buffer[10000]; + GLsizei length = 0; + buffer[0] = 0; + glGetShaderInfoLog(handle, 10000, &length, buffer); + return FString(buffer); +} + +//========================================================================== +// +// Returns the program info log (warnings and compile errors) +// +//========================================================================== + +FString FShaderProgram::GetProgramInfoLog(GLuint handle) +{ + static char buffer[10000]; + GLsizei length = 0; + buffer[0] = 0; + glGetProgramInfoLog(handle, 10000, &length, buffer); + return FString(buffer); +} + +//========================================================================== +// +// Patches a shader to be compatible with the version of OpenGL in use +// +//========================================================================== + +FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const char *defines, int maxGlslVersion) +{ + FString patchedCode; + + int shaderVersion = MIN((int)round(gl.glslversion * 10) * 10, maxGlslVersion); + patchedCode.AppendFormat("#version %d\n", shaderVersion); + + // TODO: Find some way to add extension requirements to the patching + // + // #extension GL_ARB_uniform_buffer_object : require + // #extension GL_ARB_shader_storage_buffer_object : require + + if (defines) + patchedCode << defines; + + // these settings are actually pointless but there seem to be some old ATI drivers that fail to compile the shader without setting the precision here. + patchedCode << "precision highp int;\n"; + patchedCode << "precision highp float;\n"; + + patchedCode << "#line 1\n"; + patchedCode << code; + + return patchedCode; +} + +//========================================================================== +// +// patch the shader source to work with +// GLSL 1.2 keywords and identifiers +// +//========================================================================== + diff --git a/src/gl/shaders/gl_shaderprogram.h b/src/gl/shaders/gl_shaderprogram.h new file mode 100644 index 000000000..aabfb1f6f --- /dev/null +++ b/src/gl/shaders/gl_shaderprogram.h @@ -0,0 +1,43 @@ +#ifndef __GL_SHADERPROGRAM_H +#define __GL_SHADERPROGRAM_H + +#include "gl_shader.h" + +class FShaderProgram +{ +public: + FShaderProgram(); + ~FShaderProgram(); + + enum ShaderType + { + Vertex, + Fragment, + NumShaderTypes + }; + + void Compile(ShaderType type, const char *lumpName, const char *defines, int maxGlslVersion); + void Compile(ShaderType type, const char *name, const FString &code, const char *defines, int maxGlslVersion); + void SetFragDataLocation(int index, const char *name); + void Link(const char *name); + void SetAttribLocation(int index, const char *name); + void Bind(); + + operator GLuint() const { return mProgram; } + explicit operator bool() const { return mProgram != 0; } + +private: + FShaderProgram(const FShaderProgram &) = delete; + FShaderProgram &operator=(const FShaderProgram &) = delete; + + static FString PatchShader(ShaderType type, const FString &code, const char *defines, int maxGlslVersion); + + void CreateShader(ShaderType type); + FString GetShaderInfoLog(GLuint handle); + FString GetProgramInfoLog(GLuint handle); + + GLuint mProgram = 0; + GLuint mShaders[NumShaderTypes]; +}; + +#endif \ No newline at end of file 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/shaders/gl_tonemapshader.cpp b/src/gl/shaders/gl_tonemapshader.cpp new file mode 100644 index 000000000..56708a694 --- /dev/null +++ b/src/gl/shaders/gl_tonemapshader.cpp @@ -0,0 +1,85 @@ +/* +** gl_tonemapshader.cpp +** Converts a HDR texture to 0-1 range by applying a tonemap operator +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** 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 "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/shaders/gl_tonemapshader.h" + +void FTonemapShader::Bind() +{ + auto &shader = mShader[gl_tonemap]; + if (!shader) + { + shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330); + shader.Compile(FShaderProgram::Fragment, "shaders/glsl/tonemap.fp", GetDefines(gl_tonemap), 330); + shader.SetFragDataLocation(0, "FragColor"); + shader.Link("shaders/glsl/tonemap"); + shader.SetAttribLocation(0, "PositionInProjection"); + SceneTexture.Init(shader, "InputTexture"); + Exposure.Init(shader, "ExposureAdjustment"); + PaletteLUT.Init(shader, "PaletteLUT"); + } + shader.Bind(); +} + +bool FTonemapShader::IsPaletteMode() +{ + return gl_tonemap == Palette; +} + +const char *FTonemapShader::GetDefines(int mode) +{ + switch (mode) + { + default: + case Linear: return "#define LINEAR\n"; + case Reinhard: return "#define REINHARD\n"; + case HejlDawson: return "#define HEJLDAWSON\n"; + case Uncharted2: return "#define UNCHARTED2\n"; + case Palette: return "#define PALETTE\n"; + } +} diff --git a/src/gl/shaders/gl_tonemapshader.h b/src/gl/shaders/gl_tonemapshader.h new file mode 100644 index 000000000..7ec24117b --- /dev/null +++ b/src/gl/shaders/gl_tonemapshader.h @@ -0,0 +1,34 @@ +#ifndef __GL_TONEMAPSHADER_H +#define __GL_TONEMAPSHADER_H + +#include "gl_shaderprogram.h" + +class FTonemapShader +{ +public: + void Bind(); + + FBufferedUniformSampler SceneTexture; + FBufferedUniform1f Exposure; + FBufferedUniformSampler PaletteLUT; + + static bool IsPaletteMode(); + +private: + enum TonemapMode + { + None, + Uncharted2, + HejlDawson, + Reinhard, + Linear, + Palette, + NumTonemapModes + }; + + static const char *GetDefines(int mode); + + FShaderProgram mShader[NumTonemapModes]; +}; + +#endif \ No newline at end of file diff --git a/src/gl/stereo3d/gl_anaglyph.cpp b/src/gl/stereo3d/gl_anaglyph.cpp new file mode 100644 index 000000000..c84c35091 --- /dev/null +++ b/src/gl/stereo3d/gl_anaglyph.cpp @@ -0,0 +1,72 @@ +/* +** 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(float ipd) +{ + static GreenMagenta instance(ipd); + return instance; +} + + +/* static */ +const RedCyan& RedCyan::getInstance(float ipd) +{ + static RedCyan instance(ipd); + return instance; +} + + +/* static */ +const AmberBlue& AmberBlue::getInstance(float ipd) +{ + static AmberBlue 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..a82ce0f3b --- /dev/null +++ b/src/gl/stereo3d/gl_anaglyph.h @@ -0,0 +1,132 @@ +/* +** 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) {} +}; + +class AmberBlue : public MaskAnaglyph +{ +public: + static const AmberBlue& getInstance(float ipd); + + AmberBlue(float ipd) : MaskAnaglyph(ColorMask(true, true, false), ipd) {} +}; + +// TODO matrix anaglyph + + +} /* namespace s3d */ + + +#endif /* GL_ANAGLYPH_H_ */ diff --git a/src/gl/stereo3d/gl_quadstereo.cpp b/src/gl/stereo3d/gl_quadstereo.cpp new file mode 100644 index 000000000..63bbbedc1 --- /dev/null +++ b/src/gl/stereo3d/gl_quadstereo.cpp @@ -0,0 +1,67 @@ +/* +** gl_quadstereo.cpp +** Quad-buffered OpenGL stereoscopic 3D mode 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_quadstereo.h" + +namespace s3d { + +QuadStereo::QuadStereo(double ipdMeters) + : leftEye(ipdMeters), rightEye(ipdMeters) +{ + // Check whether quad-buffered stereo is supported in the current context + // We are assuming the OpenGL context is already current at this point, + // i.e. this constructor is called "just in time". + GLboolean supportsStereo, supportsBuffered; + glGetBooleanv(GL_STEREO, &supportsStereo); + glGetBooleanv(GL_DOUBLEBUFFER, &supportsBuffered); + bool bQuadStereoSupported = supportsStereo && supportsBuffered; + leftEye.bQuadStereoSupported = bQuadStereoSupported; + rightEye.bQuadStereoSupported = bQuadStereoSupported; + + eye_ptrs.Push(&leftEye); + // If stereo is not supported, just draw scene once (left eye view only) + if (bQuadStereoSupported) { + eye_ptrs.Push(&rightEye); + } +} + +/* static */ +const QuadStereo& QuadStereo::getInstance(float ipd) +{ + static QuadStereo instance(ipd); + return instance; +} + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_quadstereo.h b/src/gl/stereo3d/gl_quadstereo.h new file mode 100644 index 000000000..f27fb78f8 --- /dev/null +++ b/src/gl/stereo3d/gl_quadstereo.h @@ -0,0 +1,97 @@ +/* +** gl_quadstereo.h +** Quad-buffered OpenGL stereoscopic 3D mode for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2016 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_QUADSTEREO_H_ +#define GL_QUADSTEREO_H_ + +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" +#include "gl/system/gl_system.h" + +namespace s3d { + + +class QuadStereoLeftPose : public LeftEyePose +{ +public: + QuadStereoLeftPose(float ipd) : LeftEyePose(ipd), bQuadStereoSupported(false) {} + virtual void SetUp() const { + if (bQuadStereoSupported) + glDrawBuffer(GL_BACK_LEFT); + } + virtual void TearDown() const { + if (bQuadStereoSupported) + glDrawBuffer(GL_BACK); + } + bool bQuadStereoSupported; +}; + +class QuadStereoRightPose : public RightEyePose +{ +public: + QuadStereoRightPose(float ipd) : RightEyePose(ipd), bQuadStereoSupported(false){} + virtual void SetUp() const { + if (bQuadStereoSupported) + glDrawBuffer(GL_BACK_RIGHT); + } + virtual void TearDown() const { + if (bQuadStereoSupported) + glDrawBuffer(GL_BACK); + } + bool bQuadStereoSupported; +}; + +// To use Quad-buffered stereo mode with nvidia 3d vision glasses, +// you must either: +// A) be using a Quadro series video card, OR +// +// B) be using nvidia driver version 314.07 or later +// AND have your monitor set to 120 Hz refresh rate +// AND have gzdoom in true full screen mode +class QuadStereo : public Stereo3DMode +{ +public: + QuadStereo(double ipdMeters); + static const QuadStereo& getInstance(float ipd); +private: + QuadStereoLeftPose leftEye; + QuadStereoRightPose rightEye; +}; + + +} /* namespace s3d */ + + +#endif /* GL_QUADSTEREO_H_ */ diff --git a/src/gl/stereo3d/gl_stereo3d.cpp b/src/gl/stereo3d/gl_stereo3d.cpp new file mode 100644 index 000000000..d686a4a43 --- /dev/null +++ b/src/gl/stereo3d/gl_stereo3d.cpp @@ -0,0 +1,93 @@ +/* +** 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/system/gl_system.h" +#include "gl/stereo3d/gl_stereo3d.h" +#include "gl/renderer/gl_renderer.h" +#include "vectors.h" // RAD2DEG +#include "doomtype.h" // M_PI + +namespace s3d { + + +/* virtual */ +VSMatrix EyePose::GetProjection(float fov, float aspectRatio, float 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(float yaw, float 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..c56cc078f --- /dev/null +++ b/src/gl/stereo3d/gl_stereo3d.h @@ -0,0 +1,114 @@ +/* +** 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(float fov, float aspectRatio, float fovRatio) const; + virtual Viewport GetViewport(const Viewport& fullViewport) const; + virtual void GetViewShift(float yaw, float 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(); + static const Stereo3DMode& getMonoMode(); + + 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..897b28088 --- /dev/null +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -0,0 +1,116 @@ +/* +** 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/stereo3d/gl_quadstereo.h" +#include "gl/system/gl_cvars.h" + +// Set up 3D-specific console variables: +CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG) + +// For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode. +// Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo, +// but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo +CVAR(Bool, vr_enable_quadbuffered, false, CVAR_ARCHIVE | 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 7: + if (vr_enable_quadbuffered) { + setCurrentMode(QuadStereo::getInstance(vr_ipd)); + } + else { + setCurrentMode(MonoView::getInstance()); + } + break; + // TODO: 8: Oculus Rift + case 9: + setCurrentMode(AmberBlue::getInstance(vr_ipd)); + break; case 0: + default: + setCurrentMode(MonoView::getInstance()); + break; + } + return *currentStereo3DMode; +} + +const Stereo3DMode& Stereo3DMode::getMonoMode() +{ + setCurrentMode(MonoView::getInstance()); + 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..354185792 --- /dev/null +++ b/src/gl/stereo3d/gl_stereo_leftright.cpp @@ -0,0 +1,102 @@ +/* +** 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 "gl/renderer/gl_renderer.h" +#include + +EXTERN_CVAR(Float, vr_screendist) +EXTERN_CVAR(Float, vr_hunits_per_meter) + +namespace s3d { + + +/* virtual */ +VSMatrix ShiftedEyePose::GetProjection(float fov, float aspectRatio, float 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(float yaw, float outViewShift[3]) const +{ + float dx = -cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + float dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * shift; + outViewShift[0] = dx; + outViewShift[1] = dy; + outViewShift[2] = 0; +} + + +/* static */ +const LeftEyeView& LeftEyeView::getInstance(float ipd) +{ + static LeftEyeView instance(ipd); + instance.setIpd(ipd); + return instance; +} + + +/* static */ +const RightEyeView& RightEyeView::getInstance(float 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..de13a32cb --- /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(float shift) : shift(shift) {}; + float getShift() const { return shift; } + void setShift(float shift) { this->shift = shift; } + virtual VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const; + virtual void GetViewShift(float yaw, float outViewShift[3]) const; +protected: + float shift; +}; + + +class LeftEyePose : public ShiftedEyePose +{ +public: + LeftEyePose(float ipd) : ShiftedEyePose( float(-0.5) * ipd) {} + float getIpd() const { return float(-2.0)*getShift(); } + void setIpd(float ipd) { setShift(float(-0.5)*ipd); } +}; + + +class RightEyePose : public ShiftedEyePose +{ +public: + RightEyePose(float ipd) : ShiftedEyePose(float(+0.5)*ipd) {} + float getIpd() const { return float(+2.0)*shift; } + void setIpd(float ipd) { setShift(float(+0.5)*ipd); } +}; + + +/** + * As if viewed through the left eye only + */ +class LeftEyeView : public Stereo3DMode +{ +public: + static const LeftEyeView& getInstance(float ipd); + + LeftEyeView(float ipd) : eye(ipd) { eye_ptrs.Push(&eye); } + float getIpd() const { return eye.getIpd(); } + void setIpd(float ipd) { eye.setIpd(ipd); } +protected: + LeftEyePose eye; +}; + + +class RightEyeView : public Stereo3DMode +{ +public: + static const RightEyeView& getInstance(float ipd); + + RightEyeView(float ipd) : eye(ipd) { eye_ptrs.Push(&eye); } + float getIpd() const { return eye.getIpd(); } + void setIpd(float 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..f4274ed95 --- /dev/null +++ b/src/gl/stereo3d/scoped_view_shifter.cpp @@ -0,0 +1,56 @@ +/* +** scoped_view_shifter.cpp +** Stack-scoped class for temporarily changing camera viewpoint +** 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 + cachedView = ViewPos; + // modify values + ViewPos += DVector3(dxyz[0], dxyz[1], dxyz[2]); +} + +ScopedViewShifter::~ScopedViewShifter() +{ + // restore original values + ViewPos = cachedView; +} + +} \ 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..8e39d533b --- /dev/null +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -0,0 +1,60 @@ +/* +** scoped_view_shifter.h +** Stack-scoped class for temporarily changing camera viewpoint +** 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" +#include "vectors.h" + +namespace s3d { + + /** + * Temporarily shift + */ + class ScopedViewShifter + { + public: + ScopedViewShifter(float dxyz[3]); // in meters + ~ScopedViewShifter(); + + private: + DVector3 cachedView; + }; + +} /* 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..4cda3657d --- /dev/null +++ b/src/gl/system/gl_cvars.h @@ -0,0 +1,57 @@ + + +#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 (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) + +EXTERN_CVAR(Bool, gl_renderbuffers) +EXTERN_CVAR(Int, gl_multisample) + +EXTERN_CVAR(Bool, gl_bloom) +EXTERN_CVAR(Float, gl_bloom_amount) +EXTERN_CVAR(Int, gl_bloom_kernel_size) +EXTERN_CVAR(Int, gl_tonemap) +EXTERN_CVAR(Float, gl_exposure) +EXTERN_CVAR(Bool, gl_lens) +EXTERN_CVAR(Float, gl_lens_k) +EXTERN_CVAR(Float, gl_lens_kcube) +EXTERN_CVAR(Float, gl_lens_chromatic) + +EXTERN_CVAR(Int, gl_debug_level) +EXTERN_CVAR(Bool, gl_debug_breakpoint) + +#endif // _GL_INTERN_H diff --git a/src/gl/system/gl_debug.cpp b/src/gl/system/gl_debug.cpp new file mode 100644 index 000000000..023073951 --- /dev/null +++ b/src/gl/system/gl_debug.cpp @@ -0,0 +1,351 @@ +/* +** gl_debig.cpp +** OpenGL debugging support functions +** +**--------------------------------------------------------------------------- +** Copyright 2016 Magnus Norddahl +** 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/system/gl_debug.h" +#include +#include + +#ifndef _MSC_VER +#include +#endif + +CUSTOM_CVAR(Int, gl_debug_level, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (!FGLDebug::HasDebugApi()) + { + Printf("No OpenGL debug support detected.\n"); + } +} + +CVAR(Bool, gl_debug_breakpoint, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); + +//----------------------------------------------------------------------------- +// +// Updates OpenGL debugging state +// +//----------------------------------------------------------------------------- + +void FGLDebug::Update() +{ + if (!HasDebugApi()) + return; + + SetupBreakpointMode(); + UpdateLoggingLevel(); + OutputMessageLog(); +} + +//----------------------------------------------------------------------------- +// +// Label objects so they are referenced by name in debug messages and in +// OpenGL debuggers (renderdoc) +// +//----------------------------------------------------------------------------- + +void FGLDebug::LabelObject(GLenum type, GLuint handle, const FString &name) +{ + if (HasDebugApi() && gl_debug_level != 0) + { + glObjectLabel(type, handle, (GLsizei)name.Len(), name.GetChars()); + } +} + +void FGLDebug::LabelObjectPtr(void *ptr, const FString &name) +{ + if (HasDebugApi() && gl_debug_level != 0) + { + glObjectPtrLabel(ptr, (GLsizei)name.Len(), name.GetChars()); + } +} + +//----------------------------------------------------------------------------- +// +// Marks which render pass/group is executing commands so that debuggers can +// display this information +// +//----------------------------------------------------------------------------- + +void FGLDebug::PushGroup(const FString &name) +{ + if (HasDebugApi() && gl_debug_level != 0) + { + glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, (GLsizei)name.Len(), name.GetChars()); + } +} + +void FGLDebug::PopGroup() +{ + if (HasDebugApi() && gl_debug_level != 0) + { + glPopDebugGroup(); + } +} + +//----------------------------------------------------------------------------- +// +// Turns on synchronous debugging on and off based on gl_debug_breakpoint +// +// Allows getting the debugger to break exactly at the OpenGL function emitting +// a message. +// +//----------------------------------------------------------------------------- + +void FGLDebug::SetupBreakpointMode() +{ + if (mBreakpointMode != gl_debug_breakpoint) + { + if (gl_debug_breakpoint) + { + glDebugMessageCallback(&FGLDebug::DebugCallback, this); + glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); + } + else + { + glDebugMessageCallback(nullptr, nullptr); + glDisable(GL_DEBUG_OUTPUT_SYNCHRONOUS); + } + mBreakpointMode = gl_debug_breakpoint; + } +} + +//----------------------------------------------------------------------------- +// +// Tells OpenGL which debug messages we are interested in +// +//----------------------------------------------------------------------------- + +void FGLDebug::UpdateLoggingLevel() +{ + int level = gl_debug_level; + if (level != mCurrentLevel) + { + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_HIGH, 0, nullptr, level > 0); + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, nullptr, level > 1); + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW, 0, nullptr, level > 2); + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_NOTIFICATION, 0, nullptr, level > 3); + mCurrentLevel = level; + } +} + +//----------------------------------------------------------------------------- +// +// The log may already contain entries for a debug level we are no longer +// interested in.. +// +//----------------------------------------------------------------------------- + +bool FGLDebug::IsFilteredByDebugLevel(GLenum severity) +{ + int severityLevel = 0; + switch (severity) + { + case GL_DEBUG_SEVERITY_HIGH: severityLevel = 1; break; + case GL_DEBUG_SEVERITY_MEDIUM: severityLevel = 2; break; + case GL_DEBUG_SEVERITY_LOW: severityLevel = 3; break; + case GL_DEBUG_SEVERITY_NOTIFICATION: severityLevel = 4; break; + } + return severityLevel > (int)gl_debug_level; +} + +//----------------------------------------------------------------------------- +// +// Prints all logged messages to the console +// +//----------------------------------------------------------------------------- + +void FGLDebug::OutputMessageLog() +{ + if (mCurrentLevel <= 0) + return; + + GLint maxDebugMessageLength = 0; + glGetIntegerv(GL_MAX_DEBUG_MESSAGE_LENGTH, &maxDebugMessageLength); + + const int maxMessages = 50; + const int messageLogSize = maxMessages * maxDebugMessageLength; + + TArray sources, types, severities; + TArray ids; + TArray lengths; + TArray messageLog; + + sources.Resize(maxMessages); + types.Resize(maxMessages); + severities.Resize(maxMessages); + ids.Resize(maxMessages); + lengths.Resize(maxMessages); + messageLog.Resize(messageLogSize); + + while (true) + { + GLuint numMessages = glGetDebugMessageLog(maxMessages, messageLogSize, &sources[0], &types[0], &ids[0], &severities[0], &lengths[0], &messageLog[0]); + if (numMessages <= 0) break; + + GLsizei offset = 0; + for (GLuint i = 0; i < numMessages; i++) + { + if (!IsFilteredByDebugLevel(severities[i])) + PrintMessage(sources[i], types[i], ids[i], severities[i], lengths[i], &messageLog[offset]); + offset += lengths[i]; + } + } +} + +//----------------------------------------------------------------------------- +// +// Print a single message to the console +// +//----------------------------------------------------------------------------- + +void FGLDebug::PrintMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message) +{ + if (type == GL_DEBUG_TYPE_PUSH_GROUP || type == GL_DEBUG_TYPE_POP_GROUP) + return; + + const int maxMessages = 50; + + static int messagesPrinted = 0; + if (messagesPrinted > maxMessages) + return; + + FString msg(message, length); + + static std::set seenMessages; + bool alreadySeen = !seenMessages.insert(msg.GetChars()).second; + if (alreadySeen) + return; + + messagesPrinted++; + if (messagesPrinted == maxMessages) + { + Printf("Max OpenGL debug messages reached. Suppressing further output.\n"); + } + else if (messagesPrinted < maxMessages) + { + FString sourceStr = SourceToString(source); + FString typeStr = TypeToString(type); + FString severityStr = SeverityToString(severity); + if (type != GL_DEBUG_TYPE_OTHER) + Printf("[%s] %s, %s: %s\n", sourceStr.GetChars(), severityStr.GetChars(), typeStr.GetChars(), msg.GetChars()); + else + Printf("[%s] %s: %s\n", sourceStr.GetChars(), severityStr.GetChars(), msg.GetChars()); + } +} + +//----------------------------------------------------------------------------- +// +// OpenGL callback function used when synchronous debugging is enabled +// +//----------------------------------------------------------------------------- + +void FGLDebug::DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) +{ + if (IsFilteredByDebugLevel(severity)) + return; + + PrintMessage(source, type, id, severity, length, message); + + if (severity != GL_DEBUG_SEVERITY_NOTIFICATION) + { +#ifdef _MSC_VER + DebugBreak(); +#else + raise(SIGTRAP); +#endif + } +} + +//----------------------------------------------------------------------------- +// +// Enum to string helpers +// +//----------------------------------------------------------------------------- + +FString FGLDebug::SourceToString(GLenum source) +{ + FString s; + switch (source) + { + case GL_DEBUG_SOURCE_API: s = "api"; break; + case GL_DEBUG_SOURCE_WINDOW_SYSTEM: s = "window system"; break; + case GL_DEBUG_SOURCE_SHADER_COMPILER: s = "shader compiler"; break; + case GL_DEBUG_SOURCE_THIRD_PARTY: s = "third party"; break; + case GL_DEBUG_SOURCE_APPLICATION: s = "application"; break; + case GL_DEBUG_SOURCE_OTHER: s = "other"; break; + default: s.Format("%d", (int)source); + } + return s; +} + +FString FGLDebug::TypeToString(GLenum type) +{ + FString s; + switch (type) + { + case GL_DEBUG_TYPE_ERROR: s = "error"; break; + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: s = "deprecated"; break; + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: s = "undefined"; break; + case GL_DEBUG_TYPE_PORTABILITY: s = "portability"; break; + case GL_DEBUG_TYPE_PERFORMANCE: s = "performance"; break; + case GL_DEBUG_TYPE_MARKER: s = "marker"; break; + case GL_DEBUG_TYPE_PUSH_GROUP: s = "push group"; break; + case GL_DEBUG_TYPE_POP_GROUP: s = "pop group"; break; + case GL_DEBUG_TYPE_OTHER: s = "other"; break; + default: s.Format("%d", (int)type); + } + return s; +} + +FString FGLDebug::SeverityToString(GLenum severity) +{ + FString s; + switch (severity) + { + case GL_DEBUG_SEVERITY_LOW: s = "low severity"; break; + case GL_DEBUG_SEVERITY_MEDIUM: s = "medium severity"; break; + case GL_DEBUG_SEVERITY_HIGH: s = "high severity"; break; + case GL_DEBUG_SEVERITY_NOTIFICATION: s = "notification"; break; + default: s.Format("%d", (int)severity); + } + return s; +} diff --git a/src/gl/system/gl_debug.h b/src/gl/system/gl_debug.h new file mode 100644 index 000000000..52645ec16 --- /dev/null +++ b/src/gl/system/gl_debug.h @@ -0,0 +1,40 @@ +#ifndef __GL_DEBUG_H +#define __GL_DEBUG_H + +#include +#include "gl/system/gl_interface.h" +#include "c_cvars.h" +#include "r_defs.h" + +class FGLDebug +{ +public: + void Update(); + + static void LabelObject(GLenum type, GLuint handle, const FString &name); + static void LabelObjectPtr(void *ptr, const FString &name); + + static void PushGroup(const FString &name); + static void PopGroup(); + + static bool HasDebugApi() { return (gl.flags & RFL_DEBUG) != 0; } + +private: + void SetupBreakpointMode(); + void UpdateLoggingLevel(); + void OutputMessageLog(); + + static bool IsFilteredByDebugLevel(GLenum severity); + static void PrintMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message); + + static void APIENTRY DebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam); + + static FString SourceToString(GLenum source); + static FString TypeToString(GLenum type); + static FString SeverityToString(GLenum severity); + + GLenum mCurrentLevel = 0; + bool mBreakpointMode = false; +}; + +#endif diff --git a/src/gl/system/gl_extlist.txt b/src/gl/system/gl_extlist.txt new file mode 100644 index 000000000..efa51ad01 --- /dev/null +++ b/src/gl/system/gl_extlist.txt @@ -0,0 +1,16 @@ +-- List of OpenGL extensions for glLoadGen + +-- Generation of gl_load.c and gl_load.h files: +-- > lua LoadGen.lua -style=pointer_c -spec=gl -version=3.3 -profile=compatibility -extfile=gl_extlist.txt load + +APPLE_client_storage +ARB_buffer_storage +ARB_shader_storage_buffer_object +ARB_texture_compression +ARB_texture_rectangle +EXT_framebuffer_object +EXT_texture_compression_s3tc +EXT_texture_filter_anisotropic +EXT_texture_sRGB +KHR_debug +ARB_invalidate_subdata diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp new file mode 100644 index 000000000..158d7f333 --- /dev/null +++ b/src/gl/system/gl_framebuffer.cpp @@ -0,0 +1,545 @@ +/* +** 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" +#include "gl/renderer/gl_2ddrawer.h" +#include "gl_debug.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(); + +CUSTOM_CVAR(Int, vid_hwgamma, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self < 0 || self > 2) self = 2; + if (GLRenderer != NULL && GLRenderer->framebuffer != NULL) GLRenderer->framebuffer->DoSetGamma(); +} + +//========================================================================== +// +// +// +//========================================================================== + +OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : + Super(hMonitor, width, height, bits, refreshHz, fullscreen) +{ + // SetVSync needs to be at the very top to workaround a bug in Nvidia's OpenGL driver. + // If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed! + SetVSync(vid_vsync); + + // Make sure all global variables tracking OpenGL context state are reset.. + FHardwareTexture::InitGlobalState(); + FMaterial::InitGlobalState(); + gl_RenderState.Reset(); + + GLRenderer = new FGLRenderer(this); + memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256); + UpdatePalette (); + ScreenshotBuffer = NULL; + LastCamera = NULL; + + InitializeState(); + mDebug = std::make_shared(); + mDebug->Update(); + gl_SetupMenu(); + gl_GenerateGlobalBrightmapFromColormap(); + DoSetGamma(); + needsetgamma = true; + swapped = false; + Accel2D = true; +} + +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; + gl_PrintStartupLog(); + } + + 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); + if (gl.legacyMode) 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); + + GLRenderer->Initialize(GetWidth(), GetHeight()); + GLRenderer->SetOutputViewport(nullptr); + Begin2D(false); +} + +//========================================================================== +// +// Updates the screen +// +//========================================================================== + +void OpenGLFrameBuffer::Update() +{ + if (!CanUpdate()) + { + GLRenderer->Flush(); + return; + } + + Begin2D(false); + + DrawRateStuff(); + GLRenderer->Flush(); + + GLRenderer->SetOutputViewport(nullptr); + + 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(); + mDebug->Update(); +} + +//=========================================================================== +// +// 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() +{ + bool useHWGamma = m_supportsGamma && ((vid_hwgamma == 0) || (vid_hwgamma == 2 && IsFullscreen())); + if (useHWGamma) + { + WORD gammaTable[768]; + + // 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); + + HWGammaActive = true; + } + else if (HWGammaActive) + { + ResetGammaTable(); + HWGammaActive = false; + } +} + +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; + + if (GLRenderer) + GLRenderer->ClearTonemapPalette(); +} + +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; +} + + +//========================================================================== +// +// 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 OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms) +{ + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddTexture(img, parms); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color) +{ + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddLine(x1, y1, x2, y2, palcolor, color); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::DrawPixel(int x1, int y1, int palcolor, uint32 color) +{ + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddPixel(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 != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddDim(color, damount, x1, y1, w, h); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin) +{ + + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddFlatFill(left, top, right, bottom, src, local_origin); +} + +//========================================================================== +// +// +// +//========================================================================== +void OpenGLFrameBuffer::Clear(int left, int top, int right, int bottom, int palcolor, uint32 color) +{ + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr) + GLRenderer->m2DDrawer->AddClear(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, + DAngle rotation, FDynamicColormap *colormap, int lightlevel) +{ + if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr && npoints >= 3) + { + GLRenderer->m2DDrawer->AddPoly(texture, points, npoints, originx, originy, scalex, scaley, rotation, colormap, lightlevel); + } +} + + +//=========================================================================== +// +// Takes a screenshot +// +//=========================================================================== + +void OpenGLFrameBuffer::GetScreenshotBuffer(const BYTE *&buffer, int &pitch, ESSType &color_type) +{ + const auto &viewport = GLRenderer->mOutputLetterbox; + + // Grab what is in the back buffer. + // We cannot rely on SCREENWIDTH/HEIGHT here because the output may have been scaled. + TArray pixels; + pixels.Resize(viewport.width * viewport.height * 3); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + glReadPixels(viewport.left, viewport.top, viewport.width, viewport.height, GL_RGB, GL_UNSIGNED_BYTE, &pixels[0]); + glPixelStorei(GL_PACK_ALIGNMENT, 4); + + // Copy to screenshot buffer: + int w = SCREENWIDTH; + int h = SCREENHEIGHT; + + ReleaseScreenshotBuffer(); + ScreenshotBuffer = new BYTE[w * h * 3]; + + float rcpWidth = 1.0f / w; + float rcpHeight = 1.0f / h; + for (int y = 0; y < h; y++) + { + for (int x = 0; x < w; x++) + { + float u = (x + 0.5f) * rcpWidth; + float v = (y + 0.5f) * rcpHeight; + int sx = u * viewport.width; + int sy = v * viewport.height; + int sindex = (sx + sy * viewport.width) * 3; + int dindex = (x + y * w) * 3; + ScreenshotBuffer[dindex] = pixels[sindex]; + ScreenshotBuffer[dindex + 1] = pixels[sindex + 1]; + ScreenshotBuffer[dindex + 2] = pixels[sindex + 2]; + } + } + + 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..5315bb0a9 --- /dev/null +++ b/src/gl/system/gl_framebuffer.h @@ -0,0 +1,131 @@ +#ifndef __GL_FRAMEBUFFER +#define __GL_FRAMEBUFFER + +#ifdef _WIN32 +#include "win32iface.h" +#include "win32gliface.h" +#endif + +#include + +class FHardwareTexture; +class FSimpleVertexBuffer; +class FGLDebug; + +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 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 DrawTextureParms(FTexture *img, 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 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, + DAngle 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; } + bool IsHWGammaActive() const { return HWGammaActive; } + +private: + PalEntry Flash; + + // Texture creation info + int cm; + int translation; + bool iscomplex; + bool needsetgamma; + bool swapped; + + PalEntry SourcePalette[256]; + BYTE *ScreenshotBuffer; + + class Wiper + { + + protected: + FSimpleVertexBuffer *mVertexBuf; + + void MakeVBO(OpenGLFrameBuffer *fb); + + public: + Wiper(); + 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; + + bool HWGammaActive = false; + + std::shared_ptr mDebug; + +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..9185b63dc --- /dev/null +++ b/src/gl/system/gl_interface.cpp @@ -0,0 +1,347 @@ +/* +** 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 "r_data/r_translate.h" +#include "gl/system/gl_interface.h" +#include "gl/system/gl_cvars.h" + +void gl_PatchMenu(); +static TArray m_Extensions; +RenderContext gl; + +//========================================================================== +// +// +// +//========================================================================== + +static void CollectExtensions() +{ + const char *extension; + + int max = 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &max); + + if (0 == max) + { + // Try old method to collect extensions + const char *supported = (char *)glGetString(GL_EXTENSIONS); + + if (nullptr != supported) + { + char *extensions = new char[strlen(supported) + 1]; + strcpy(extensions, supported); + + char *extension = strtok(extensions, " "); + + while (extension) + { + m_Extensions.Push(FString(extension)); + extension = strtok(nullptr, " "); + } + + delete [] extensions; + } + } + else + { + // Use modern method to collect extensions + 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; +} + +//========================================================================== +// +// +// +//========================================================================== + +#define FUDGE_FUNC(name, ext) if (_ptrc_##name == NULL) _ptrc_##name = _ptrc_##name##ext; + + +void gl_LoadExtensions() +{ + InitContext(); + CollectExtensions(); + + const char *version = Args->CheckValue("-glversion"); + const char *glversion = (const char*)glGetString(GL_VERSION); + + if (version == NULL) + { + version = glversion; + } + else + { + double v1 = strtod(version, NULL); + double v2 = strtod(glversion, NULL); + if (v2 < v1) version = glversion; + else Printf("Emulating OpenGL v %s\n", version); + } + + float gl_version = (float)strtod(version, NULL) + 0.01f; + + // Don't even start if it's lower than 2.0 or no framebuffers are available (The framebuffer extension is needed for glGenerateMipmapsEXT!) + if ((gl_version < 2.0f || !CheckExtension("GL_EXT_framebuffer_object")) && gl_version < 3.0f) + { + I_FatalError("Unsupported OpenGL version.\nAt least OpenGL 2.0 with framebuffer support 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.glslversion = strtod((char*)glGetString(GL_SHADING_LANGUAGE_VERSION), NULL) + 0.01f; + + gl.vendorstring = (char*)glGetString(GL_VENDOR); + + // first test for optional features + 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 ((gl_version >= 3.3f || CheckExtension("GL_ARB_sampler_objects")) && !Args->CheckParm("-nosampler")) + { + gl.flags |= RFL_SAMPLER_OBJECTS; + } + + // The minimum requirement for the modern render path are GL 3.0 + uniform buffers + if (gl_version < 3.0f || (gl_version < 3.1f && !CheckExtension("GL_ARB_uniform_buffer_object"))) + { + gl.legacyMode = true; + gl.lightmethod = LM_LEGACY; + gl.buffermethod = BM_LEGACY; + gl.glslversion = 0; + gl.flags |= RFL_NO_CLIP_PLANES; + } + else + { + gl.legacyMode = false; + gl.lightmethod = LM_DEFERRED; + gl.buffermethod = BM_DEFERRED; + if (gl_version < 4.f) + { +#ifdef _WIN32 + if (strstr(gl.vendorstring, "ATI Tech")) + { + gl.flags |= RFL_NO_CLIP_PLANES; // gl_ClipDistance is horribly broken on ATI GL3 drivers for Windows. + } +#endif + } + else if (gl_version < 4.5f) + { + // don't use GL 4.x features when running a GL 3.x context. + 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; + gl.lightmethod = LM_DIRECT; + gl.buffermethod = BM_PERSISTENT; + } + } + else + { + // Assume that everything works without problems on GL 4.5 drivers where these things are core features. + gl.flags |= RFL_SHADER_STORAGE_BUFFER | RFL_BUFFER_STORAGE; + gl.lightmethod = LM_DIRECT; + gl.buffermethod = BM_PERSISTENT; + } + + if (gl_version >= 4.3f || CheckExtension("GL_ARB_invalidate_subdata")) gl.flags |= RFL_INVALIDATE_BUFFER; + if (gl_version >= 4.3f || CheckExtension("GL_KHR_debug")) gl.flags |= RFL_DEBUG; + + const char *lm = Args->CheckValue("-lightmethod"); + if (lm != NULL) + { + if (!stricmp(lm, "deferred") && gl.lightmethod == LM_DIRECT) gl.lightmethod = LM_DEFERRED; + } + + lm = Args->CheckValue("-buffermethod"); + if (lm != NULL) + { + if (!stricmp(lm, "deferred") && gl.buffermethod == BM_PERSISTENT) gl.buffermethod = BM_DEFERRED; + } + } + + int v; + + if (!gl.legacyMode && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + { + 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; + } + else + { + gl.maxuniforms = 0; + gl.maxuniformblock = 0; + gl.uniformblockalignment = 0; + } + + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl.max_texturesize); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + if (gl.legacyMode) + { + // fudge a bit with the framebuffer stuff to avoid redundancies in the main code. Some of the older cards do not have the ARB stuff but the calls are nearly identical. + FUDGE_FUNC(glGenerateMipmap, EXT); + FUDGE_FUNC(glGenFramebuffers, EXT); + FUDGE_FUNC(glBindFramebuffer, EXT); + FUDGE_FUNC(glDeleteFramebuffers, EXT); + FUDGE_FUNC(glFramebufferTexture2D, EXT); + FUDGE_FUNC(glGenerateMipmap, EXT); + FUDGE_FUNC(glGenFramebuffers, EXT); + FUDGE_FUNC(glBindFramebuffer, EXT); + FUDGE_FUNC(glDeleteFramebuffers, EXT); + FUDGE_FUNC(glFramebufferTexture2D, EXT); + FUDGE_FUNC(glFramebufferRenderbuffer, EXT); + FUDGE_FUNC(glGenRenderbuffers, EXT); + FUDGE_FUNC(glDeleteRenderbuffers, EXT); + FUDGE_FUNC(glRenderbufferStorage, EXT); + FUDGE_FUNC(glBindRenderbuffer, EXT); + FUDGE_FUNC(glCheckFramebufferStatus, EXT); + gl_PatchMenu(); + } +} + +//========================================================================== +// +// +// +//========================================================================== + +void gl_PrintStartupLog() +{ + int v = 0; + if (!gl.legacyMode) 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_VARYING_FLOATS, &v); + Printf ("Max. varying: %d\n", v); + + if (!gl.legacyMode && !(gl.flags & RFL_SHADER_STORAGE_BUFFER)) + { + 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); + } + + if (gl.flags & RFL_SHADER_STORAGE_BUFFER) + { + 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); + } + + // For shader-less, the special alphatexture translation must be changed to actually set the alpha, because it won't get translated by a shader. + if (gl.legacyMode) + { + FRemapTable *remap = translationtables[TRANSLATION_Standard][8]; + for (int i = 0; i < 256; i++) + { + remap->Remap[i] = i; + remap->Palette[i] = PalEntry(i, 255, 255, 255); + } + } + +} + diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h new file mode 100644 index 000000000..edaec58c0 --- /dev/null +++ b/src/gl/system/gl_interface.h @@ -0,0 +1,79 @@ +#ifndef R_RENDER +#define R_RENDER + +#include "basictypes.h" + +enum GLCompat +{ + CMPT_GL2, + CMPT_GL2_SHADER, + CMPT_GL3, + CMPT_GL4 +}; + +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, + RFL_SAMPLER_OBJECTS = 16, + + RFL_NO_CLIP_PLANES = 32, + + RFL_INVALIDATE_BUFFER = 64, + RFL_DEBUG = 128 +}; + +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) + + TM_INVERTOPAQUE, // used by GL 2.x fallback code. +}; + +enum ELightMethod +{ + LM_LEGACY = 0, // placeholder for legacy mode (textured lights), should not be checked anywhere in the code! + LM_DEFERRED = 1, // calculate lights up front in a separate pass + LM_DIRECT = 2, // calculate lights on the fly along with the render data +}; + +enum EBufferMethod +{ + BM_LEGACY = 0, // placeholder for legacy mode (client arrays), should not be checked anywhere in the code! + BM_DEFERRED = 1, // use a temporarily mapped buffer, for GL 3.x core profile + BM_PERSISTENT = 2 // use a persistently mapped buffer +}; + + +struct RenderContext +{ + unsigned int flags; + unsigned int maxuniforms; + unsigned int maxuniformblock; + unsigned int uniformblockalignment; + int lightmethod; + int buffermethod; + float glslversion; + int max_texturesize; + char * vendorstring; + bool legacyMode; + + 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..a32eb226f --- /dev/null +++ b/src/gl/system/gl_load.c @@ -0,0 +1,2564 @@ +#include +#include +#include +#include "gl_load.h" + +#if defined(__APPLE__) +#include + +static void* AppleGLGetProcAddress (const char *name) +{ + static void* image = NULL; + + if (NULL == image) + image = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_LAZY); + + return (image ? dlsym(image, name) : 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 in this file. +#pragma inline_depth(0) +#pragma warning(disable: 4055) +#pragma warning(disable: 4054) +#pragma warning(disable: 4996) +#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_APPLE_client_storage = 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_ARB_texture_compression = ogl_LOAD_FAILED; +int ogl_ext_ARB_texture_rectangle = ogl_LOAD_FAILED; +int ogl_ext_EXT_framebuffer_object = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_compression_s3tc = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; +int ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; +int ogl_ext_KHR_debug = ogl_LOAD_FAILED; +int ogl_ext_ARB_invalidate_subdata = ogl_LOAD_FAILED; + +void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags) = NULL; + +static int Load_ARB_buffer_storage(void) +{ + 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 program, GLuint storageBlockIndex, GLuint storageBlockBinding) = NULL; + +static int Load_ARB_shader_storage_buffer_object(void) +{ + int numFailed = 0; + _ptrc_glShaderStorageBlockBinding = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glShaderStorageBlockBinding"); + if(!_ptrc_glShaderStorageBlockBinding) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImageARB)(GLenum target, GLint level, void * img) = NULL; + +static int Load_ARB_texture_compression(void) +{ + int numFailed = 0; + _ptrc_glCompressedTexImage1DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage1DARB"); + if(!_ptrc_glCompressedTexImage1DARB) numFailed++; + _ptrc_glCompressedTexImage2DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage2DARB"); + if(!_ptrc_glCompressedTexImage2DARB) numFailed++; + _ptrc_glCompressedTexImage3DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage3DARB"); + if(!_ptrc_glCompressedTexImage3DARB) numFailed++; + _ptrc_glCompressedTexSubImage1DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage1DARB"); + if(!_ptrc_glCompressedTexSubImage1DARB) numFailed++; + _ptrc_glCompressedTexSubImage2DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage2DARB"); + if(!_ptrc_glCompressedTexSubImage2DARB) numFailed++; + _ptrc_glCompressedTexSubImage3DARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage3DARB"); + if(!_ptrc_glCompressedTexSubImage3DARB) numFailed++; + _ptrc_glGetCompressedTexImageARB = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, void *))IntGetProcAddress("glGetCompressedTexImageARB"); + if(!_ptrc_glGetCompressedTexImageARB) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glBindFramebufferEXT)(GLenum target, GLuint framebuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbufferEXT)(GLenum target, GLuint renderbuffer) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatusEXT)(GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffersEXT)(GLsizei n, const GLuint * framebuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffersEXT)(GLsizei n, const GLuint * renderbuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffersEXT)(GLsizei n, GLuint * framebuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffersEXT)(GLsizei n, GLuint * renderbuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmapEXT)(GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint * params) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebufferEXT)(GLuint framebuffer) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbufferEXT)(GLuint renderbuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL; + +static int Load_EXT_framebuffer_object(void) +{ + int numFailed = 0; + _ptrc_glBindFramebufferEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindFramebufferEXT"); + if(!_ptrc_glBindFramebufferEXT) numFailed++; + _ptrc_glBindRenderbufferEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindRenderbufferEXT"); + if(!_ptrc_glBindRenderbufferEXT) numFailed++; + _ptrc_glCheckFramebufferStatusEXT = (GLenum (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCheckFramebufferStatusEXT"); + if(!_ptrc_glCheckFramebufferStatusEXT) numFailed++; + _ptrc_glDeleteFramebuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteFramebuffersEXT"); + if(!_ptrc_glDeleteFramebuffersEXT) numFailed++; + _ptrc_glDeleteRenderbuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *))IntGetProcAddress("glDeleteRenderbuffersEXT"); + if(!_ptrc_glDeleteRenderbuffersEXT) numFailed++; + _ptrc_glFramebufferRenderbufferEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint))IntGetProcAddress("glFramebufferRenderbufferEXT"); + if(!_ptrc_glFramebufferRenderbufferEXT) numFailed++; + _ptrc_glFramebufferTexture1DEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture1DEXT"); + if(!_ptrc_glFramebufferTexture1DEXT) numFailed++; + _ptrc_glFramebufferTexture2DEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint))IntGetProcAddress("glFramebufferTexture2DEXT"); + if(!_ptrc_glFramebufferTexture2DEXT) numFailed++; + _ptrc_glFramebufferTexture3DEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLuint, GLint, GLint))IntGetProcAddress("glFramebufferTexture3DEXT"); + if(!_ptrc_glFramebufferTexture3DEXT) numFailed++; + _ptrc_glGenFramebuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenFramebuffersEXT"); + if(!_ptrc_glGenFramebuffersEXT) numFailed++; + _ptrc_glGenRenderbuffersEXT = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenRenderbuffersEXT"); + if(!_ptrc_glGenRenderbuffersEXT) numFailed++; + _ptrc_glGenerateMipmapEXT = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGenerateMipmapEXT"); + if(!_ptrc_glGenerateMipmapEXT) numFailed++; + _ptrc_glGetFramebufferAttachmentParameterivEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLint *))IntGetProcAddress("glGetFramebufferAttachmentParameterivEXT"); + if(!_ptrc_glGetFramebufferAttachmentParameterivEXT) numFailed++; + _ptrc_glGetRenderbufferParameterivEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetRenderbufferParameterivEXT"); + if(!_ptrc_glGetRenderbufferParameterivEXT) numFailed++; + _ptrc_glIsFramebufferEXT = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsFramebufferEXT"); + if(!_ptrc_glIsFramebufferEXT) numFailed++; + _ptrc_glIsRenderbufferEXT = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsRenderbufferEXT"); + if(!_ptrc_glIsRenderbufferEXT) numFailed++; + _ptrc_glRenderbufferStorageEXT = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLsizei, GLsizei))IntGetProcAddress("glRenderbufferStorageEXT"); + if(!_ptrc_glRenderbufferStorageEXT) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageCallback)(GLDEBUGPROC callback, const void * userParam) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageControl)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageInsert)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glGetDebugMessageLog)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetObjectLabel)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetObjectPtrLabel)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum pname, void ** params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glObjectLabel)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glObjectPtrLabel)(const void * ptr, GLsizei length, const GLchar * label) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopDebugGroup)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushDebugGroup)(GLenum source, GLuint id, GLsizei length, const GLchar * message) = NULL; + +static int Load_KHR_debug(void) +{ + int numFailed = 0; + _ptrc_glDebugMessageCallback = (void (CODEGEN_FUNCPTR *)(GLDEBUGPROC, const void *))IntGetProcAddress("glDebugMessageCallback"); + if(!_ptrc_glDebugMessageCallback) numFailed++; + _ptrc_glDebugMessageControl = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLsizei, const GLuint *, GLboolean))IntGetProcAddress("glDebugMessageControl"); + if(!_ptrc_glDebugMessageControl) numFailed++; + _ptrc_glDebugMessageInsert = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar *))IntGetProcAddress("glDebugMessageInsert"); + if(!_ptrc_glDebugMessageInsert) numFailed++; + _ptrc_glGetDebugMessageLog = (GLuint (CODEGEN_FUNCPTR *)(GLuint, GLsizei, GLenum *, GLenum *, GLuint *, GLenum *, GLsizei *, GLchar *))IntGetProcAddress("glGetDebugMessageLog"); + if(!_ptrc_glGetDebugMessageLog) numFailed++; + _ptrc_glGetObjectLabel = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetObjectLabel"); + if(!_ptrc_glGetObjectLabel) numFailed++; + _ptrc_glGetObjectPtrLabel = (void (CODEGEN_FUNCPTR *)(const void *, GLsizei, GLsizei *, GLchar *))IntGetProcAddress("glGetObjectPtrLabel"); + if(!_ptrc_glGetObjectPtrLabel) numFailed++; + _ptrc_glGetPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, void **))IntGetProcAddress("glGetPointerv"); + if(!_ptrc_glGetPointerv) numFailed++; + _ptrc_glObjectLabel = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLsizei, const GLchar *))IntGetProcAddress("glObjectLabel"); + if(!_ptrc_glObjectLabel) numFailed++; + _ptrc_glObjectPtrLabel = (void (CODEGEN_FUNCPTR *)(const void *, GLsizei, const GLchar *))IntGetProcAddress("glObjectPtrLabel"); + if(!_ptrc_glObjectPtrLabel) numFailed++; + _ptrc_glPopDebugGroup = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPopDebugGroup"); + if(!_ptrc_glPopDebugGroup) numFailed++; + _ptrc_glPushDebugGroup = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLsizei, const GLchar *))IntGetProcAddress("glPushDebugGroup"); + if(!_ptrc_glPushDebugGroup) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateBufferData)(GLuint buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateBufferSubData)(GLuint buffer, GLintptr offset, GLsizeiptr length) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum * attachments) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateSubFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateTexImage)(GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInvalidateTexSubImage)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth) = NULL; + +static int Load_ARB_invalidate_subdata(void) +{ + int numFailed = 0; + _ptrc_glInvalidateBufferData = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glInvalidateBufferData"); + if(!_ptrc_glInvalidateBufferData) numFailed++; + _ptrc_glInvalidateBufferSubData = (void (CODEGEN_FUNCPTR *)(GLuint, GLintptr, GLsizeiptr))IntGetProcAddress("glInvalidateBufferSubData"); + if(!_ptrc_glInvalidateBufferSubData) numFailed++; + _ptrc_glInvalidateFramebuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLenum *))IntGetProcAddress("glInvalidateFramebuffer"); + if(!_ptrc_glInvalidateFramebuffer) numFailed++; + _ptrc_glInvalidateSubFramebuffer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLenum *, GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glInvalidateSubFramebuffer"); + if(!_ptrc_glInvalidateSubFramebuffer) numFailed++; + _ptrc_glInvalidateTexImage = (void (CODEGEN_FUNCPTR *)(GLuint, GLint))IntGetProcAddress("glInvalidateTexImage"); + if(!_ptrc_glInvalidateTexImage) numFailed++; + _ptrc_glInvalidateTexSubImage = (void (CODEGEN_FUNCPTR *)(GLuint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei))IntGetProcAddress("glInvalidateTexSubImage"); + if(!_ptrc_glInvalidateTexSubImage) numFailed++; + return numFailed; +} + +void (CODEGEN_FUNCPTR *_ptrc_glAccum)(GLenum op, GLfloat value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glAlphaFunc)(GLenum func, GLfloat ref) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBitmap)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum sfactor, GLenum dfactor) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCallList)(GLuint list) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCallLists)(GLsizei n, GLenum type, const void * lists) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearAccum)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble depth) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearIndex)(GLfloat c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClipPlane)(GLenum plane, const GLdouble * equation) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3b)(GLbyte red, GLbyte green, GLbyte blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3bv)(const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3d)(GLdouble red, GLdouble green, GLdouble blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3f)(GLfloat red, GLfloat green, GLfloat blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3i)(GLint red, GLint green, GLint blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3s)(GLshort red, GLshort green, GLshort blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3ub)(GLubyte red, GLubyte green, GLubyte blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3ubv)(const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3ui)(GLuint red, GLuint green, GLuint blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3uiv)(const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3us)(GLushort red, GLushort green, GLushort blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor3usv)(const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4b)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4bv)(const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4d)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4i)(GLint red, GLint green, GLint blue, GLint alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4s)(GLshort red, GLshort green, GLshort blue, GLshort alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4ubv)(const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4ui)(GLuint red, GLuint green, GLuint blue, GLuint alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4uiv)(const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4us)(GLushort red, GLushort green, GLushort blue, GLushort alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColor4usv)(const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorMaterial)(GLenum face, GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteLists)(GLuint list, GLsizei range) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum func) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean flag) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble ren_near, GLdouble ren_far) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum cap) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum buf) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawPixels)(GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlag)(GLboolean flag) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagv)(const GLboolean * flag) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum cap) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnd)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndList)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1d)(GLdouble u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1dv)(const GLdouble * u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1f)(GLfloat u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1fv)(const GLfloat * u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2d)(GLdouble u, GLdouble v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2dv)(const GLdouble * u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2f)(GLfloat u, GLfloat v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2fv)(const GLfloat * u) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh1)(GLenum mode, GLint i1, GLint i2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh2)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint1)(GLint i) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint2)(GLint i, GLint j) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFeedbackBuffer)(GLsizei size, GLenum type, GLfloat * buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFinish)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFlush)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogf)(GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogfv)(GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogi)(GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogiv)(GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFrustum)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glGenLists)(GLsizei range) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum pname, GLboolean * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetClipPlane)(GLenum plane, GLdouble * equation) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum pname, GLdouble * data) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum pname, GLfloat * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum pname, GLint * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetLightfv)(GLenum light, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetLightiv)(GLenum light, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMapdv)(GLenum target, GLenum query, GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMapfv)(GLenum target, GLenum query, GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMapiv)(GLenum target, GLenum query, GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialfv)(GLenum face, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialiv)(GLenum face, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapfv)(GLenum map, GLfloat * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapuiv)(GLenum map, GLuint * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapusv)(GLenum map, GLushort * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetPolygonStipple)(GLubyte * mask) = NULL; +const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnvfv)(GLenum target, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnviv)(GLenum target, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexGendv)(GLenum coord, GLenum pname, GLdouble * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexGenfv)(GLenum coord, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexGeniv)(GLenum coord, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum target, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum target, GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexMask)(GLuint mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexd)(GLdouble c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexdv)(const GLdouble * c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexf)(GLfloat c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexfv)(const GLfloat * c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexi)(GLint c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexiv)(const GLint * c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexs)(GLshort c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexsv)(const GLshort * c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInitNames)(void) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum cap) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsList)(GLuint list) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModelf)(GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModelfv)(GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModeli)(GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightModeliv)(GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightf)(GLenum light, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightfv)(GLenum light, GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLighti)(GLenum light, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLightiv)(GLenum light, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLineStipple)(GLint factor, GLushort pattern) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat width) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glListBase)(GLuint base) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadIdentity)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixd)(const GLdouble * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixf)(const GLfloat * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadName)(GLuint name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum opcode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap1d)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap1f)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap2d)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMap2f)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1d)(GLint un, GLdouble u1, GLdouble u2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1f)(GLint un, GLfloat u1, GLfloat u2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2d)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2f)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMaterialf)(GLenum face, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMaterialfv)(GLenum face, GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMateriali)(GLenum face, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMaterialiv)(GLenum face, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMatrixMode)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixd)(const GLdouble * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixf)(const GLfloat * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNewList)(GLuint list, GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3b)(GLbyte nx, GLbyte ny, GLbyte nz) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3bv)(const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3d)(GLdouble nx, GLdouble ny, GLdouble nz) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3f)(GLfloat nx, GLfloat ny, GLfloat nz) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3i)(GLint nx, GLint ny, GLint nz) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3s)(GLshort nx, GLshort ny, GLshort nz) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormal3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glOrtho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPassThrough)(GLfloat token) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelMapfv)(GLenum map, GLsizei mapsize, const GLfloat * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelMapuiv)(GLenum map, GLsizei mapsize, const GLuint * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelMapusv)(GLenum map, GLsizei mapsize, const GLushort * values) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferf)(GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferi)(GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPixelZoom)(GLfloat xfactor, GLfloat yfactor) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat size) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum face, GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPolygonStipple)(const GLubyte * mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopAttrib)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopMatrix)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopName)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushAttrib)(GLbitfield mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushMatrix)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushName)(GLuint name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2d)(GLdouble x, GLdouble y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2f)(GLfloat x, GLfloat y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2i)(GLint x, GLint y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2s)(GLshort x, GLshort y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3d)(GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3f)(GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3i)(GLint x, GLint y, GLint z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3s)(GLshort x, GLshort y, GLshort z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4i)(GLint x, GLint y, GLint z, GLint w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4s)(GLshort x, GLshort y, GLshort z, GLshort w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum src) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectd)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectdv)(const GLdouble * v1, const GLdouble * v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectf)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectfv)(const GLfloat * v1, const GLfloat * v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRecti)(GLint x1, GLint y1, GLint x2, GLint y2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectiv)(const GLint * v1, const GLint * v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRects)(GLshort x1, GLshort y1, GLshort x2, GLshort y2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRectsv)(const GLshort * v1, const GLshort * v2) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glRenderMode)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRotated)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glScaled)(GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glScalef)(GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint x, GLint y, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSelectBuffer)(GLsizei size, GLuint * buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glShadeModel)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum func, GLint ref, GLuint mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1d)(GLdouble s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1f)(GLfloat s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1i)(GLint s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1s)(GLshort s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2d)(GLdouble s, GLdouble t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2f)(GLfloat s, GLfloat t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2i)(GLint s, GLint t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2s)(GLshort s, GLshort t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3d)(GLdouble s, GLdouble t, GLdouble r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3f)(GLfloat s, GLfloat t, GLfloat r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3i)(GLint s, GLint t, GLint r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3s)(GLshort s, GLshort t, GLshort r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4d)(GLdouble s, GLdouble t, GLdouble r, GLdouble q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4f)(GLfloat s, GLfloat t, GLfloat r, GLfloat q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4i)(GLint s, GLint t, GLint r, GLint q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4s)(GLshort s, GLshort t, GLshort r, GLshort q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnvf)(GLenum target, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnvfv)(GLenum target, GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnvi)(GLenum target, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexEnviv)(GLenum target, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGend)(GLenum coord, GLenum pname, GLdouble param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGendv)(GLenum coord, GLenum pname, const GLdouble * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGenf)(GLenum coord, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGenfv)(GLenum coord, GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGeni)(GLenum coord, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexGeniv)(GLenum coord, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum target, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum target, GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum target, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum target, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTranslated)(GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTranslatef)(GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2d)(GLdouble x, GLdouble y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2f)(GLfloat x, GLfloat y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2i)(GLint x, GLint y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2s)(GLshort x, GLshort y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex2sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3d)(GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3f)(GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3i)(GLint x, GLint y, GLint z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3s)(GLshort x, GLshort y, GLshort z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4i)(GLint x, GLint y, GLint z, GLint w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4s)(GLshort x, GLshort y, GLshort z, GLshort w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertex4sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint x, GLint y, GLsizei width, GLsizei height) = NULL; + +GLboolean (CODEGEN_FUNCPTR *_ptrc_glAreTexturesResident)(GLsizei n, const GLuint * textures, GLboolean * residences) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glArrayElement)(GLint i) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum target, GLuint texture) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei n, const GLuint * textures) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisableClientState)(GLenum ren_array) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum mode, GLint first, GLsizei count) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum mode, GLsizei count, GLenum type, const void * indices) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagPointer)(GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnableClientState)(GLenum ren_array) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei n, GLuint * textures) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexPointer)(GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexub)(GLubyte c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glIndexubv)(const GLubyte * c) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glInterleavedArrays)(GLenum format, GLsizei stride, const void * pointer) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint texture) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glNormalPointer)(GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat factor, GLfloat units) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPopClientAttrib)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPrioritizeTextures)(GLsizei n, const GLuint * textures, const GLfloat * priorities) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPushClientAttrib)(GLbitfield mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum texture) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClientActiveTexture)(GLenum texture) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum target, GLint level, void * img) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixd)(const GLdouble * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixf)(const GLfloat * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixd)(const GLdouble * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixf)(const GLfloat * m) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1d)(GLenum target, GLdouble s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1dv)(GLenum target, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1f)(GLenum target, GLfloat s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1fv)(GLenum target, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1i)(GLenum target, GLint s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1iv)(GLenum target, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1s)(GLenum target, GLshort s) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1sv)(GLenum target, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2d)(GLenum target, GLdouble s, GLdouble t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2dv)(GLenum target, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2f)(GLenum target, GLfloat s, GLfloat t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2fv)(GLenum target, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2i)(GLenum target, GLint s, GLint t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2iv)(GLenum target, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2s)(GLenum target, GLshort s, GLshort t) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2sv)(GLenum target, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3d)(GLenum target, GLdouble s, GLdouble t, GLdouble r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3dv)(GLenum target, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3f)(GLenum target, GLfloat s, GLfloat t, GLfloat r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3fv)(GLenum target, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3i)(GLenum target, GLint s, GLint t, GLint r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3iv)(GLenum target, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3s)(GLenum target, GLshort s, GLshort t, GLshort r) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3sv)(GLenum target, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4d)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4dv)(GLenum target, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4f)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4fv)(GLenum target, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4i)(GLenum target, GLint s, GLint t, GLint r, GLint q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4iv)(GLenum target, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4s)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4sv)(GLenum target, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat value, GLboolean invert) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordPointer)(GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordd)(GLdouble coord) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoorddv)(const GLdouble * coord) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordf)(GLfloat coord) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFogCoordfv)(const GLfloat * coord) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum pname, const GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3b)(GLbyte red, GLbyte green, GLbyte blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3bv)(const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3d)(GLdouble red, GLdouble green, GLdouble blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3f)(GLfloat red, GLfloat green, GLfloat blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3i)(GLint red, GLint green, GLint blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3s)(GLshort red, GLshort green, GLshort blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ub)(GLubyte red, GLubyte green, GLubyte blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ubv)(const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ui)(GLuint red, GLuint green, GLuint blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3uiv)(const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3us)(GLushort red, GLushort green, GLushort blue) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3usv)(const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColorPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2d)(GLdouble x, GLdouble y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2f)(GLfloat x, GLfloat y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2i)(GLint x, GLint y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2s)(GLshort x, GLshort y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2sv)(const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3d)(GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3dv)(const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3f)(GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3fv)(const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3i)(GLint x, GLint y, GLint z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3iv)(const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3s)(GLshort x, GLshort y, GLshort z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3sv)(const GLshort * v) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum target, GLuint id) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum target, GLuint buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum target, GLsizeiptr size, const void * data, GLenum usage) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei n, const GLuint * buffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei n, const GLuint * ids) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei n, GLuint * buffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei n, GLuint * ids) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum target, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum target, GLenum pname, void ** params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, void * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint id, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint id, GLenum pname, GLuint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum target, GLenum pname, GLint * params) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint buffer) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint id) = NULL; +void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum target, GLenum access) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum target) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint program, GLuint shader) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint program, GLuint index, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint shader) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)(void) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum type) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint program) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint shader) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint program, GLuint shader) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei n, const GLenum * bufs) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint program, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint program, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint shader, GLenum pname, GLint * params) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint program, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint program, GLint location, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint program, GLint location, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint index, GLenum pname, void ** pointer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint index, GLenum pname, GLdouble * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint index, GLenum pname, GLint * params) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint program) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint shader) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint program) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum face, GLuint mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint location, GLfloat v0) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint location, GLsizei count, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint location, GLint v0) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint location, GLsizei count, const GLint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint location, GLfloat v0, GLfloat v1) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint location, GLsizei count, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint location, GLint v0, GLint v1) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint location, GLsizei count, const GLint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint location, GLsizei count, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint location, GLint v0, GLint v1, GLint v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint location, GLsizei count, const GLint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint location, GLsizei count, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint location, GLsizei count, const GLint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint program) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint program) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint index, GLdouble x) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint index, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint index, GLfloat x) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint index, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint index, GLshort x) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint index, GLdouble x, GLdouble y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint index, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint index, GLfloat x, GLfloat y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint index, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint index, GLshort x, GLshort y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint index, GLdouble x, GLdouble y, GLdouble z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint index, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint index, GLfloat x, GLfloat y, GLfloat z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint index, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint index, GLshort x, GLshort y, GLshort z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint index, const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint index, const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint index, const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint index, const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint index, const GLdouble * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint index, const GLfloat * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint index, const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint index, const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint id, GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum primitiveMode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum target, GLuint index, GLuint buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint program, GLuint color, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum target, GLuint framebuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum target, GLuint renderbuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint ren_array) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) = NULL; +GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum target, GLenum clamp) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum buffer, GLint drawbuffer, const GLfloat * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum buffer, GLint drawbuffer, const GLint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum buffer, GLint drawbuffer, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei n, const GLuint * framebuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei n, const GLuint * renderbuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei n, const GLuint * arrays) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum target, GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum target, GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)(void) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei n, GLuint * framebuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei n, GLuint * renderbuffers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei n, GLuint * arrays) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum target, GLuint index, GLboolean * data) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint program, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum target, GLuint index, GLint * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint * params) = NULL; +const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum name, GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum target, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum target, GLenum pname, GLuint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint program, GLint location, GLuint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint index, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint index, GLenum pname, GLuint * params) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum target, GLuint index) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint framebuffer) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint renderbuffer) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint ren_array) = NULL; +void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum target, GLenum pname, const GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum target, GLenum pname, const GLuint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint location, GLuint v0) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint location, GLsizei count, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint location, GLuint v0, GLuint v1) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint location, GLsizei count, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint location, GLuint v0, GLuint v1, GLuint v2) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint location, GLsizei count, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint location, GLsizei count, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint index, GLint x) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint index, GLuint x) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint index, GLint x, GLint y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint index, GLuint x, GLuint y) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint index, const GLbyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint index, const GLint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint index, const GLshort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint index, const GLubyte * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint index, const GLuint * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint index, const GLushort * v) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params) = NULL; +GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint program, const GLchar * uniformBlockName) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint index) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum target, GLenum internalformat, GLuint buffer) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) = NULL; + +GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync sync) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex) = NULL; +GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum condition, GLbitfield flags) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum target, GLenum attachment, GLuint texture, GLint level) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum target, GLenum pname, GLint64 * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum target, GLuint index, GLint64 * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum pname, GLint64 * data) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum pname, GLuint index, GLfloat * val) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync sync) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum mode) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint maskNumber, GLbitfield mask) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout) = NULL; + +void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint unit, GLuint sampler) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei count, const GLuint * samplers) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei count, GLuint * samplers) = NULL; +GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint program, const GLchar * name) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint sampler, GLenum pname, GLint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint sampler, GLenum pname, GLuint * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint sampler, GLenum pname, GLfloat * params) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint sampler, GLenum pname, GLint * params) = NULL; +GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint sampler) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint id, GLenum target) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint sampler, GLenum pname, const GLint * param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint sampler, GLenum pname, const GLuint * param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint sampler, GLenum pname, GLfloat param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint sampler, GLenum pname, const GLfloat * param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint sampler, GLenum pname, GLint param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint sampler, GLenum pname, const GLint * param) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint index, GLuint divisor) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value) = NULL; +void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value) = NULL; + +static int Load_Version_3_3(void) +{ + int numFailed = 0; + _ptrc_glAccum = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glAccum"); + if(!_ptrc_glAccum) numFailed++; + _ptrc_glAlphaFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glAlphaFunc"); + if(!_ptrc_glAlphaFunc) numFailed++; + _ptrc_glBegin = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glBegin"); + if(!_ptrc_glBegin) numFailed++; + _ptrc_glBitmap = (void (CODEGEN_FUNCPTR *)(GLsizei, GLsizei, GLfloat, GLfloat, GLfloat, GLfloat, const GLubyte *))IntGetProcAddress("glBitmap"); + if(!_ptrc_glBitmap) numFailed++; + _ptrc_glBlendFunc = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glBlendFunc"); + if(!_ptrc_glBlendFunc) numFailed++; + _ptrc_glCallList = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glCallList"); + if(!_ptrc_glCallList) numFailed++; + _ptrc_glCallLists = (void (CODEGEN_FUNCPTR *)(GLsizei, GLenum, const void *))IntGetProcAddress("glCallLists"); + if(!_ptrc_glCallLists) numFailed++; + _ptrc_glClear = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress("glClear"); + if(!_ptrc_glClear) numFailed++; + _ptrc_glClearAccum = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glClearAccum"); + if(!_ptrc_glClearAccum) 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_glClearIndex = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glClearIndex"); + if(!_ptrc_glClearIndex) numFailed++; + _ptrc_glClearStencil = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glClearStencil"); + if(!_ptrc_glClearStencil) numFailed++; + _ptrc_glClipPlane = (void (CODEGEN_FUNCPTR *)(GLenum, const GLdouble *))IntGetProcAddress("glClipPlane"); + if(!_ptrc_glClipPlane) numFailed++; + _ptrc_glColor3b = (void (CODEGEN_FUNCPTR *)(GLbyte, GLbyte, GLbyte))IntGetProcAddress("glColor3b"); + if(!_ptrc_glColor3b) numFailed++; + _ptrc_glColor3bv = (void (CODEGEN_FUNCPTR *)(const GLbyte *))IntGetProcAddress("glColor3bv"); + if(!_ptrc_glColor3bv) numFailed++; + _ptrc_glColor3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glColor3d"); + if(!_ptrc_glColor3d) numFailed++; + _ptrc_glColor3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glColor3dv"); + if(!_ptrc_glColor3dv) numFailed++; + _ptrc_glColor3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glColor3f"); + if(!_ptrc_glColor3f) numFailed++; + _ptrc_glColor3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glColor3fv"); + if(!_ptrc_glColor3fv) numFailed++; + _ptrc_glColor3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glColor3i"); + if(!_ptrc_glColor3i) numFailed++; + _ptrc_glColor3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glColor3iv"); + if(!_ptrc_glColor3iv) numFailed++; + _ptrc_glColor3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glColor3s"); + if(!_ptrc_glColor3s) numFailed++; + _ptrc_glColor3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glColor3sv"); + if(!_ptrc_glColor3sv) numFailed++; + _ptrc_glColor3ub = (void (CODEGEN_FUNCPTR *)(GLubyte, GLubyte, GLubyte))IntGetProcAddress("glColor3ub"); + if(!_ptrc_glColor3ub) numFailed++; + _ptrc_glColor3ubv = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glColor3ubv"); + if(!_ptrc_glColor3ubv) numFailed++; + _ptrc_glColor3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glColor3ui"); + if(!_ptrc_glColor3ui) numFailed++; + _ptrc_glColor3uiv = (void (CODEGEN_FUNCPTR *)(const GLuint *))IntGetProcAddress("glColor3uiv"); + if(!_ptrc_glColor3uiv) numFailed++; + _ptrc_glColor3us = (void (CODEGEN_FUNCPTR *)(GLushort, GLushort, GLushort))IntGetProcAddress("glColor3us"); + if(!_ptrc_glColor3us) numFailed++; + _ptrc_glColor3usv = (void (CODEGEN_FUNCPTR *)(const GLushort *))IntGetProcAddress("glColor3usv"); + if(!_ptrc_glColor3usv) numFailed++; + _ptrc_glColor4b = (void (CODEGEN_FUNCPTR *)(GLbyte, GLbyte, GLbyte, GLbyte))IntGetProcAddress("glColor4b"); + if(!_ptrc_glColor4b) numFailed++; + _ptrc_glColor4bv = (void (CODEGEN_FUNCPTR *)(const GLbyte *))IntGetProcAddress("glColor4bv"); + if(!_ptrc_glColor4bv) numFailed++; + _ptrc_glColor4d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glColor4d"); + if(!_ptrc_glColor4d) numFailed++; + _ptrc_glColor4dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glColor4dv"); + if(!_ptrc_glColor4dv) numFailed++; + _ptrc_glColor4f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glColor4f"); + if(!_ptrc_glColor4f) numFailed++; + _ptrc_glColor4fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glColor4fv"); + if(!_ptrc_glColor4fv) numFailed++; + _ptrc_glColor4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glColor4i"); + if(!_ptrc_glColor4i) numFailed++; + _ptrc_glColor4iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glColor4iv"); + if(!_ptrc_glColor4iv) numFailed++; + _ptrc_glColor4s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glColor4s"); + if(!_ptrc_glColor4s) numFailed++; + _ptrc_glColor4sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glColor4sv"); + if(!_ptrc_glColor4sv) numFailed++; + _ptrc_glColor4ub = (void (CODEGEN_FUNCPTR *)(GLubyte, GLubyte, GLubyte, GLubyte))IntGetProcAddress("glColor4ub"); + if(!_ptrc_glColor4ub) numFailed++; + _ptrc_glColor4ubv = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glColor4ubv"); + if(!_ptrc_glColor4ubv) numFailed++; + _ptrc_glColor4ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint, GLuint))IntGetProcAddress("glColor4ui"); + if(!_ptrc_glColor4ui) numFailed++; + _ptrc_glColor4uiv = (void (CODEGEN_FUNCPTR *)(const GLuint *))IntGetProcAddress("glColor4uiv"); + if(!_ptrc_glColor4uiv) numFailed++; + _ptrc_glColor4us = (void (CODEGEN_FUNCPTR *)(GLushort, GLushort, GLushort, GLushort))IntGetProcAddress("glColor4us"); + if(!_ptrc_glColor4us) numFailed++; + _ptrc_glColor4usv = (void (CODEGEN_FUNCPTR *)(const GLushort *))IntGetProcAddress("glColor4usv"); + if(!_ptrc_glColor4usv) numFailed++; + _ptrc_glColorMask = (void (CODEGEN_FUNCPTR *)(GLboolean, GLboolean, GLboolean, GLboolean))IntGetProcAddress("glColorMask"); + if(!_ptrc_glColorMask) numFailed++; + _ptrc_glColorMaterial = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum))IntGetProcAddress("glColorMaterial"); + if(!_ptrc_glColorMaterial) numFailed++; + _ptrc_glCopyPixels = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei, GLenum))IntGetProcAddress("glCopyPixels"); + if(!_ptrc_glCopyPixels) numFailed++; + _ptrc_glCullFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glCullFace"); + if(!_ptrc_glCullFace) numFailed++; + _ptrc_glDeleteLists = (void (CODEGEN_FUNCPTR *)(GLuint, GLsizei))IntGetProcAddress("glDeleteLists"); + if(!_ptrc_glDeleteLists) 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_glDrawPixels = (void (CODEGEN_FUNCPTR *)(GLsizei, GLsizei, GLenum, GLenum, const void *))IntGetProcAddress("glDrawPixels"); + if(!_ptrc_glDrawPixels) numFailed++; + _ptrc_glEdgeFlag = (void (CODEGEN_FUNCPTR *)(GLboolean))IntGetProcAddress("glEdgeFlag"); + if(!_ptrc_glEdgeFlag) numFailed++; + _ptrc_glEdgeFlagv = (void (CODEGEN_FUNCPTR *)(const GLboolean *))IntGetProcAddress("glEdgeFlagv"); + if(!_ptrc_glEdgeFlagv) numFailed++; + _ptrc_glEnable = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glEnable"); + if(!_ptrc_glEnable) numFailed++; + _ptrc_glEnd = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glEnd"); + if(!_ptrc_glEnd) numFailed++; + _ptrc_glEndList = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glEndList"); + if(!_ptrc_glEndList) numFailed++; + _ptrc_glEvalCoord1d = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glEvalCoord1d"); + if(!_ptrc_glEvalCoord1d) numFailed++; + _ptrc_glEvalCoord1dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glEvalCoord1dv"); + if(!_ptrc_glEvalCoord1dv) numFailed++; + _ptrc_glEvalCoord1f = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glEvalCoord1f"); + if(!_ptrc_glEvalCoord1f) numFailed++; + _ptrc_glEvalCoord1fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glEvalCoord1fv"); + if(!_ptrc_glEvalCoord1fv) numFailed++; + _ptrc_glEvalCoord2d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glEvalCoord2d"); + if(!_ptrc_glEvalCoord2d) numFailed++; + _ptrc_glEvalCoord2dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glEvalCoord2dv"); + if(!_ptrc_glEvalCoord2dv) numFailed++; + _ptrc_glEvalCoord2f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glEvalCoord2f"); + if(!_ptrc_glEvalCoord2f) numFailed++; + _ptrc_glEvalCoord2fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glEvalCoord2fv"); + if(!_ptrc_glEvalCoord2fv) numFailed++; + _ptrc_glEvalMesh1 = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint))IntGetProcAddress("glEvalMesh1"); + if(!_ptrc_glEvalMesh1) numFailed++; + _ptrc_glEvalMesh2 = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint))IntGetProcAddress("glEvalMesh2"); + if(!_ptrc_glEvalMesh2) numFailed++; + _ptrc_glEvalPoint1 = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glEvalPoint1"); + if(!_ptrc_glEvalPoint1) numFailed++; + _ptrc_glEvalPoint2 = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glEvalPoint2"); + if(!_ptrc_glEvalPoint2) numFailed++; + _ptrc_glFeedbackBuffer = (void (CODEGEN_FUNCPTR *)(GLsizei, GLenum, GLfloat *))IntGetProcAddress("glFeedbackBuffer"); + if(!_ptrc_glFeedbackBuffer) numFailed++; + _ptrc_glFinish = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glFinish"); + if(!_ptrc_glFinish) numFailed++; + _ptrc_glFlush = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glFlush"); + if(!_ptrc_glFlush) numFailed++; + _ptrc_glFogf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glFogf"); + if(!_ptrc_glFogf) numFailed++; + _ptrc_glFogfv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glFogfv"); + if(!_ptrc_glFogfv) numFailed++; + _ptrc_glFogi = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glFogi"); + if(!_ptrc_glFogi) numFailed++; + _ptrc_glFogiv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glFogiv"); + if(!_ptrc_glFogiv) numFailed++; + _ptrc_glFrontFace = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glFrontFace"); + if(!_ptrc_glFrontFace) numFailed++; + _ptrc_glFrustum = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glFrustum"); + if(!_ptrc_glFrustum) numFailed++; + _ptrc_glGenLists = (GLuint (CODEGEN_FUNCPTR *)(GLsizei))IntGetProcAddress("glGenLists"); + if(!_ptrc_glGenLists) numFailed++; + _ptrc_glGetBooleanv = (void (CODEGEN_FUNCPTR *)(GLenum, GLboolean *))IntGetProcAddress("glGetBooleanv"); + if(!_ptrc_glGetBooleanv) numFailed++; + _ptrc_glGetClipPlane = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble *))IntGetProcAddress("glGetClipPlane"); + if(!_ptrc_glGetClipPlane) numFailed++; + _ptrc_glGetDoublev = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble *))IntGetProcAddress("glGetDoublev"); + if(!_ptrc_glGetDoublev) numFailed++; + _ptrc_glGetError = (GLenum (CODEGEN_FUNCPTR *)(void))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_glGetLightfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetLightfv"); + if(!_ptrc_glGetLightfv) numFailed++; + _ptrc_glGetLightiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetLightiv"); + if(!_ptrc_glGetLightiv) numFailed++; + _ptrc_glGetMapdv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLdouble *))IntGetProcAddress("glGetMapdv"); + if(!_ptrc_glGetMapdv) numFailed++; + _ptrc_glGetMapfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetMapfv"); + if(!_ptrc_glGetMapfv) numFailed++; + _ptrc_glGetMapiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetMapiv"); + if(!_ptrc_glGetMapiv) numFailed++; + _ptrc_glGetMaterialfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetMaterialfv"); + if(!_ptrc_glGetMaterialfv) numFailed++; + _ptrc_glGetMaterialiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetMaterialiv"); + if(!_ptrc_glGetMaterialiv) numFailed++; + _ptrc_glGetPixelMapfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat *))IntGetProcAddress("glGetPixelMapfv"); + if(!_ptrc_glGetPixelMapfv) numFailed++; + _ptrc_glGetPixelMapuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint *))IntGetProcAddress("glGetPixelMapuiv"); + if(!_ptrc_glGetPixelMapuiv) numFailed++; + _ptrc_glGetPixelMapusv = (void (CODEGEN_FUNCPTR *)(GLenum, GLushort *))IntGetProcAddress("glGetPixelMapusv"); + if(!_ptrc_glGetPixelMapusv) numFailed++; + _ptrc_glGetPolygonStipple = (void (CODEGEN_FUNCPTR *)(GLubyte *))IntGetProcAddress("glGetPolygonStipple"); + if(!_ptrc_glGetPolygonStipple) numFailed++; + _ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetString"); + if(!_ptrc_glGetString) numFailed++; + _ptrc_glGetTexEnvfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetTexEnvfv"); + if(!_ptrc_glGetTexEnvfv) numFailed++; + _ptrc_glGetTexEnviv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetTexEnviv"); + if(!_ptrc_glGetTexEnviv) numFailed++; + _ptrc_glGetTexGendv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLdouble *))IntGetProcAddress("glGetTexGendv"); + if(!_ptrc_glGetTexGendv) numFailed++; + _ptrc_glGetTexGenfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat *))IntGetProcAddress("glGetTexGenfv"); + if(!_ptrc_glGetTexGenfv) numFailed++; + _ptrc_glGetTexGeniv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint *))IntGetProcAddress("glGetTexGeniv"); + if(!_ptrc_glGetTexGeniv) numFailed++; + _ptrc_glGetTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLenum, void *))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_glIndexMask = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIndexMask"); + if(!_ptrc_glIndexMask) numFailed++; + _ptrc_glIndexd = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glIndexd"); + if(!_ptrc_glIndexd) numFailed++; + _ptrc_glIndexdv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glIndexdv"); + if(!_ptrc_glIndexdv) numFailed++; + _ptrc_glIndexf = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glIndexf"); + if(!_ptrc_glIndexf) numFailed++; + _ptrc_glIndexfv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glIndexfv"); + if(!_ptrc_glIndexfv) numFailed++; + _ptrc_glIndexi = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glIndexi"); + if(!_ptrc_glIndexi) numFailed++; + _ptrc_glIndexiv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glIndexiv"); + if(!_ptrc_glIndexiv) numFailed++; + _ptrc_glIndexs = (void (CODEGEN_FUNCPTR *)(GLshort))IntGetProcAddress("glIndexs"); + if(!_ptrc_glIndexs) numFailed++; + _ptrc_glIndexsv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glIndexsv"); + if(!_ptrc_glIndexsv) numFailed++; + _ptrc_glInitNames = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glInitNames"); + if(!_ptrc_glInitNames) numFailed++; + _ptrc_glIsEnabled = (GLboolean (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glIsEnabled"); + if(!_ptrc_glIsEnabled) numFailed++; + _ptrc_glIsList = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsList"); + if(!_ptrc_glIsList) numFailed++; + _ptrc_glLightModelf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glLightModelf"); + if(!_ptrc_glLightModelf) numFailed++; + _ptrc_glLightModelfv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glLightModelfv"); + if(!_ptrc_glLightModelfv) numFailed++; + _ptrc_glLightModeli = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glLightModeli"); + if(!_ptrc_glLightModeli) numFailed++; + _ptrc_glLightModeliv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glLightModeliv"); + if(!_ptrc_glLightModeliv) numFailed++; + _ptrc_glLightf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress("glLightf"); + if(!_ptrc_glLightf) numFailed++; + _ptrc_glLightfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress("glLightfv"); + if(!_ptrc_glLightfv) numFailed++; + _ptrc_glLighti = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress("glLighti"); + if(!_ptrc_glLighti) numFailed++; + _ptrc_glLightiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glLightiv"); + if(!_ptrc_glLightiv) numFailed++; + _ptrc_glLineStipple = (void (CODEGEN_FUNCPTR *)(GLint, GLushort))IntGetProcAddress("glLineStipple"); + if(!_ptrc_glLineStipple) numFailed++; + _ptrc_glLineWidth = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glLineWidth"); + if(!_ptrc_glLineWidth) numFailed++; + _ptrc_glListBase = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glListBase"); + if(!_ptrc_glListBase) numFailed++; + _ptrc_glLoadIdentity = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glLoadIdentity"); + if(!_ptrc_glLoadIdentity) numFailed++; + _ptrc_glLoadMatrixd = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glLoadMatrixd"); + if(!_ptrc_glLoadMatrixd) numFailed++; + _ptrc_glLoadMatrixf = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glLoadMatrixf"); + if(!_ptrc_glLoadMatrixf) numFailed++; + _ptrc_glLoadName = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glLoadName"); + if(!_ptrc_glLoadName) numFailed++; + _ptrc_glLogicOp = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glLogicOp"); + if(!_ptrc_glLogicOp) numFailed++; + _ptrc_glMap1d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble, GLdouble, GLint, GLint, const GLdouble *))IntGetProcAddress("glMap1d"); + if(!_ptrc_glMap1d) numFailed++; + _ptrc_glMap1f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat, GLfloat, GLint, GLint, const GLfloat *))IntGetProcAddress("glMap1f"); + if(!_ptrc_glMap1f) numFailed++; + _ptrc_glMap2d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *))IntGetProcAddress("glMap2d"); + if(!_ptrc_glMap2d) numFailed++; + _ptrc_glMap2f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *))IntGetProcAddress("glMap2f"); + if(!_ptrc_glMap2f) numFailed++; + _ptrc_glMapGrid1d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble, GLdouble))IntGetProcAddress("glMapGrid1d"); + if(!_ptrc_glMapGrid1d) numFailed++; + _ptrc_glMapGrid1f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat))IntGetProcAddress("glMapGrid1f"); + if(!_ptrc_glMapGrid1f) numFailed++; + _ptrc_glMapGrid2d = (void (CODEGEN_FUNCPTR *)(GLint, GLdouble, GLdouble, GLint, GLdouble, GLdouble))IntGetProcAddress("glMapGrid2d"); + if(!_ptrc_glMapGrid2d) numFailed++; + _ptrc_glMapGrid2f = (void (CODEGEN_FUNCPTR *)(GLint, GLfloat, GLfloat, GLint, GLfloat, GLfloat))IntGetProcAddress("glMapGrid2f"); + if(!_ptrc_glMapGrid2f) numFailed++; + _ptrc_glMaterialf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress("glMaterialf"); + if(!_ptrc_glMaterialf) numFailed++; + _ptrc_glMaterialfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress("glMaterialfv"); + if(!_ptrc_glMaterialfv) numFailed++; + _ptrc_glMateriali = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress("glMateriali"); + if(!_ptrc_glMateriali) numFailed++; + _ptrc_glMaterialiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glMaterialiv"); + if(!_ptrc_glMaterialiv) numFailed++; + _ptrc_glMatrixMode = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glMatrixMode"); + if(!_ptrc_glMatrixMode) numFailed++; + _ptrc_glMultMatrixd = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glMultMatrixd"); + if(!_ptrc_glMultMatrixd) numFailed++; + _ptrc_glMultMatrixf = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glMultMatrixf"); + if(!_ptrc_glMultMatrixf) numFailed++; + _ptrc_glNewList = (void (CODEGEN_FUNCPTR *)(GLuint, GLenum))IntGetProcAddress("glNewList"); + if(!_ptrc_glNewList) numFailed++; + _ptrc_glNormal3b = (void (CODEGEN_FUNCPTR *)(GLbyte, GLbyte, GLbyte))IntGetProcAddress("glNormal3b"); + if(!_ptrc_glNormal3b) numFailed++; + _ptrc_glNormal3bv = (void (CODEGEN_FUNCPTR *)(const GLbyte *))IntGetProcAddress("glNormal3bv"); + if(!_ptrc_glNormal3bv) numFailed++; + _ptrc_glNormal3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glNormal3d"); + if(!_ptrc_glNormal3d) numFailed++; + _ptrc_glNormal3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glNormal3dv"); + if(!_ptrc_glNormal3dv) numFailed++; + _ptrc_glNormal3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glNormal3f"); + if(!_ptrc_glNormal3f) numFailed++; + _ptrc_glNormal3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glNormal3fv"); + if(!_ptrc_glNormal3fv) numFailed++; + _ptrc_glNormal3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glNormal3i"); + if(!_ptrc_glNormal3i) numFailed++; + _ptrc_glNormal3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glNormal3iv"); + if(!_ptrc_glNormal3iv) numFailed++; + _ptrc_glNormal3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glNormal3s"); + if(!_ptrc_glNormal3s) numFailed++; + _ptrc_glNormal3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glNormal3sv"); + if(!_ptrc_glNormal3sv) numFailed++; + _ptrc_glOrtho = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glOrtho"); + if(!_ptrc_glOrtho) numFailed++; + _ptrc_glPassThrough = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glPassThrough"); + if(!_ptrc_glPassThrough) numFailed++; + _ptrc_glPixelMapfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLfloat *))IntGetProcAddress("glPixelMapfv"); + if(!_ptrc_glPixelMapfv) numFailed++; + _ptrc_glPixelMapuiv = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLuint *))IntGetProcAddress("glPixelMapuiv"); + if(!_ptrc_glPixelMapuiv) numFailed++; + _ptrc_glPixelMapusv = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const GLushort *))IntGetProcAddress("glPixelMapusv"); + if(!_ptrc_glPixelMapusv) 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_glPixelTransferf = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glPixelTransferf"); + if(!_ptrc_glPixelTransferf) numFailed++; + _ptrc_glPixelTransferi = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glPixelTransferi"); + if(!_ptrc_glPixelTransferi) numFailed++; + _ptrc_glPixelZoom = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glPixelZoom"); + if(!_ptrc_glPixelZoom) 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_glPolygonStipple = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glPolygonStipple"); + if(!_ptrc_glPolygonStipple) numFailed++; + _ptrc_glPopAttrib = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPopAttrib"); + if(!_ptrc_glPopAttrib) numFailed++; + _ptrc_glPopMatrix = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPopMatrix"); + if(!_ptrc_glPopMatrix) numFailed++; + _ptrc_glPopName = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPopName"); + if(!_ptrc_glPopName) numFailed++; + _ptrc_glPushAttrib = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress("glPushAttrib"); + if(!_ptrc_glPushAttrib) numFailed++; + _ptrc_glPushMatrix = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPushMatrix"); + if(!_ptrc_glPushMatrix) numFailed++; + _ptrc_glPushName = (void (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glPushName"); + if(!_ptrc_glPushName) numFailed++; + _ptrc_glRasterPos2d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glRasterPos2d"); + if(!_ptrc_glRasterPos2d) numFailed++; + _ptrc_glRasterPos2dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glRasterPos2dv"); + if(!_ptrc_glRasterPos2dv) numFailed++; + _ptrc_glRasterPos2f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glRasterPos2f"); + if(!_ptrc_glRasterPos2f) numFailed++; + _ptrc_glRasterPos2fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glRasterPos2fv"); + if(!_ptrc_glRasterPos2fv) numFailed++; + _ptrc_glRasterPos2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glRasterPos2i"); + if(!_ptrc_glRasterPos2i) numFailed++; + _ptrc_glRasterPos2iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glRasterPos2iv"); + if(!_ptrc_glRasterPos2iv) numFailed++; + _ptrc_glRasterPos2s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort))IntGetProcAddress("glRasterPos2s"); + if(!_ptrc_glRasterPos2s) numFailed++; + _ptrc_glRasterPos2sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glRasterPos2sv"); + if(!_ptrc_glRasterPos2sv) numFailed++; + _ptrc_glRasterPos3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glRasterPos3d"); + if(!_ptrc_glRasterPos3d) numFailed++; + _ptrc_glRasterPos3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glRasterPos3dv"); + if(!_ptrc_glRasterPos3dv) numFailed++; + _ptrc_glRasterPos3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glRasterPos3f"); + if(!_ptrc_glRasterPos3f) numFailed++; + _ptrc_glRasterPos3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glRasterPos3fv"); + if(!_ptrc_glRasterPos3fv) numFailed++; + _ptrc_glRasterPos3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glRasterPos3i"); + if(!_ptrc_glRasterPos3i) numFailed++; + _ptrc_glRasterPos3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glRasterPos3iv"); + if(!_ptrc_glRasterPos3iv) numFailed++; + _ptrc_glRasterPos3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glRasterPos3s"); + if(!_ptrc_glRasterPos3s) numFailed++; + _ptrc_glRasterPos3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glRasterPos3sv"); + if(!_ptrc_glRasterPos3sv) numFailed++; + _ptrc_glRasterPos4d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glRasterPos4d"); + if(!_ptrc_glRasterPos4d) numFailed++; + _ptrc_glRasterPos4dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glRasterPos4dv"); + if(!_ptrc_glRasterPos4dv) numFailed++; + _ptrc_glRasterPos4f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glRasterPos4f"); + if(!_ptrc_glRasterPos4f) numFailed++; + _ptrc_glRasterPos4fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glRasterPos4fv"); + if(!_ptrc_glRasterPos4fv) numFailed++; + _ptrc_glRasterPos4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glRasterPos4i"); + if(!_ptrc_glRasterPos4i) numFailed++; + _ptrc_glRasterPos4iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glRasterPos4iv"); + if(!_ptrc_glRasterPos4iv) numFailed++; + _ptrc_glRasterPos4s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glRasterPos4s"); + if(!_ptrc_glRasterPos4s) numFailed++; + _ptrc_glRasterPos4sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glRasterPos4sv"); + if(!_ptrc_glRasterPos4sv) numFailed++; + _ptrc_glReadBuffer = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glReadBuffer"); + if(!_ptrc_glReadBuffer) numFailed++; + _ptrc_glReadPixels = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, void *))IntGetProcAddress("glReadPixels"); + if(!_ptrc_glReadPixels) numFailed++; + _ptrc_glRectd = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glRectd"); + if(!_ptrc_glRectd) numFailed++; + _ptrc_glRectdv = (void (CODEGEN_FUNCPTR *)(const GLdouble *, const GLdouble *))IntGetProcAddress("glRectdv"); + if(!_ptrc_glRectdv) numFailed++; + _ptrc_glRectf = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glRectf"); + if(!_ptrc_glRectf) numFailed++; + _ptrc_glRectfv = (void (CODEGEN_FUNCPTR *)(const GLfloat *, const GLfloat *))IntGetProcAddress("glRectfv"); + if(!_ptrc_glRectfv) numFailed++; + _ptrc_glRecti = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glRecti"); + if(!_ptrc_glRecti) numFailed++; + _ptrc_glRectiv = (void (CODEGEN_FUNCPTR *)(const GLint *, const GLint *))IntGetProcAddress("glRectiv"); + if(!_ptrc_glRectiv) numFailed++; + _ptrc_glRects = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glRects"); + if(!_ptrc_glRects) numFailed++; + _ptrc_glRectsv = (void (CODEGEN_FUNCPTR *)(const GLshort *, const GLshort *))IntGetProcAddress("glRectsv"); + if(!_ptrc_glRectsv) numFailed++; + _ptrc_glRenderMode = (GLint (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glRenderMode"); + if(!_ptrc_glRenderMode) numFailed++; + _ptrc_glRotated = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glRotated"); + if(!_ptrc_glRotated) numFailed++; + _ptrc_glRotatef = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glRotatef"); + if(!_ptrc_glRotatef) numFailed++; + _ptrc_glScaled = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glScaled"); + if(!_ptrc_glScaled) numFailed++; + _ptrc_glScalef = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glScalef"); + if(!_ptrc_glScalef) numFailed++; + _ptrc_glScissor = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glScissor"); + if(!_ptrc_glScissor) numFailed++; + _ptrc_glSelectBuffer = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glSelectBuffer"); + if(!_ptrc_glSelectBuffer) numFailed++; + _ptrc_glShadeModel = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glShadeModel"); + if(!_ptrc_glShadeModel) 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_glTexCoord1d = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glTexCoord1d"); + if(!_ptrc_glTexCoord1d) numFailed++; + _ptrc_glTexCoord1dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glTexCoord1dv"); + if(!_ptrc_glTexCoord1dv) numFailed++; + _ptrc_glTexCoord1f = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glTexCoord1f"); + if(!_ptrc_glTexCoord1f) numFailed++; + _ptrc_glTexCoord1fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glTexCoord1fv"); + if(!_ptrc_glTexCoord1fv) numFailed++; + _ptrc_glTexCoord1i = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glTexCoord1i"); + if(!_ptrc_glTexCoord1i) numFailed++; + _ptrc_glTexCoord1iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glTexCoord1iv"); + if(!_ptrc_glTexCoord1iv) numFailed++; + _ptrc_glTexCoord1s = (void (CODEGEN_FUNCPTR *)(GLshort))IntGetProcAddress("glTexCoord1s"); + if(!_ptrc_glTexCoord1s) numFailed++; + _ptrc_glTexCoord1sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glTexCoord1sv"); + if(!_ptrc_glTexCoord1sv) numFailed++; + _ptrc_glTexCoord2d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glTexCoord2d"); + if(!_ptrc_glTexCoord2d) numFailed++; + _ptrc_glTexCoord2dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glTexCoord2dv"); + if(!_ptrc_glTexCoord2dv) numFailed++; + _ptrc_glTexCoord2f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glTexCoord2f"); + if(!_ptrc_glTexCoord2f) numFailed++; + _ptrc_glTexCoord2fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glTexCoord2fv"); + if(!_ptrc_glTexCoord2fv) numFailed++; + _ptrc_glTexCoord2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glTexCoord2i"); + if(!_ptrc_glTexCoord2i) numFailed++; + _ptrc_glTexCoord2iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glTexCoord2iv"); + if(!_ptrc_glTexCoord2iv) numFailed++; + _ptrc_glTexCoord2s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort))IntGetProcAddress("glTexCoord2s"); + if(!_ptrc_glTexCoord2s) numFailed++; + _ptrc_glTexCoord2sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glTexCoord2sv"); + if(!_ptrc_glTexCoord2sv) numFailed++; + _ptrc_glTexCoord3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glTexCoord3d"); + if(!_ptrc_glTexCoord3d) numFailed++; + _ptrc_glTexCoord3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glTexCoord3dv"); + if(!_ptrc_glTexCoord3dv) numFailed++; + _ptrc_glTexCoord3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glTexCoord3f"); + if(!_ptrc_glTexCoord3f) numFailed++; + _ptrc_glTexCoord3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glTexCoord3fv"); + if(!_ptrc_glTexCoord3fv) numFailed++; + _ptrc_glTexCoord3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glTexCoord3i"); + if(!_ptrc_glTexCoord3i) numFailed++; + _ptrc_glTexCoord3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glTexCoord3iv"); + if(!_ptrc_glTexCoord3iv) numFailed++; + _ptrc_glTexCoord3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glTexCoord3s"); + if(!_ptrc_glTexCoord3s) numFailed++; + _ptrc_glTexCoord3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glTexCoord3sv"); + if(!_ptrc_glTexCoord3sv) numFailed++; + _ptrc_glTexCoord4d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glTexCoord4d"); + if(!_ptrc_glTexCoord4d) numFailed++; + _ptrc_glTexCoord4dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glTexCoord4dv"); + if(!_ptrc_glTexCoord4dv) numFailed++; + _ptrc_glTexCoord4f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glTexCoord4f"); + if(!_ptrc_glTexCoord4f) numFailed++; + _ptrc_glTexCoord4fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glTexCoord4fv"); + if(!_ptrc_glTexCoord4fv) numFailed++; + _ptrc_glTexCoord4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glTexCoord4i"); + if(!_ptrc_glTexCoord4i) numFailed++; + _ptrc_glTexCoord4iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glTexCoord4iv"); + if(!_ptrc_glTexCoord4iv) numFailed++; + _ptrc_glTexCoord4s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glTexCoord4s"); + if(!_ptrc_glTexCoord4s) numFailed++; + _ptrc_glTexCoord4sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glTexCoord4sv"); + if(!_ptrc_glTexCoord4sv) numFailed++; + _ptrc_glTexEnvf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress("glTexEnvf"); + if(!_ptrc_glTexEnvf) numFailed++; + _ptrc_glTexEnvfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress("glTexEnvfv"); + if(!_ptrc_glTexEnvfv) numFailed++; + _ptrc_glTexEnvi = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress("glTexEnvi"); + if(!_ptrc_glTexEnvi) numFailed++; + _ptrc_glTexEnviv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glTexEnviv"); + if(!_ptrc_glTexEnviv) numFailed++; + _ptrc_glTexGend = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLdouble))IntGetProcAddress("glTexGend"); + if(!_ptrc_glTexGend) numFailed++; + _ptrc_glTexGendv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLdouble *))IntGetProcAddress("glTexGendv"); + if(!_ptrc_glTexGendv) numFailed++; + _ptrc_glTexGenf = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLfloat))IntGetProcAddress("glTexGenf"); + if(!_ptrc_glTexGenf) numFailed++; + _ptrc_glTexGenfv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLfloat *))IntGetProcAddress("glTexGenfv"); + if(!_ptrc_glTexGenfv) numFailed++; + _ptrc_glTexGeni = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLint))IntGetProcAddress("glTexGeni"); + if(!_ptrc_glTexGeni) numFailed++; + _ptrc_glTexGeniv = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, const GLint *))IntGetProcAddress("glTexGeniv"); + if(!_ptrc_glTexGeniv) numFailed++; + _ptrc_glTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const void *))IntGetProcAddress("glTexImage1D"); + if(!_ptrc_glTexImage1D) numFailed++; + _ptrc_glTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))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_glTranslated = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glTranslated"); + if(!_ptrc_glTranslated) numFailed++; + _ptrc_glTranslatef = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glTranslatef"); + if(!_ptrc_glTranslatef) numFailed++; + _ptrc_glVertex2d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glVertex2d"); + if(!_ptrc_glVertex2d) numFailed++; + _ptrc_glVertex2dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glVertex2dv"); + if(!_ptrc_glVertex2dv) numFailed++; + _ptrc_glVertex2f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glVertex2f"); + if(!_ptrc_glVertex2f) numFailed++; + _ptrc_glVertex2fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glVertex2fv"); + if(!_ptrc_glVertex2fv) numFailed++; + _ptrc_glVertex2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glVertex2i"); + if(!_ptrc_glVertex2i) numFailed++; + _ptrc_glVertex2iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glVertex2iv"); + if(!_ptrc_glVertex2iv) numFailed++; + _ptrc_glVertex2s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort))IntGetProcAddress("glVertex2s"); + if(!_ptrc_glVertex2s) numFailed++; + _ptrc_glVertex2sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glVertex2sv"); + if(!_ptrc_glVertex2sv) numFailed++; + _ptrc_glVertex3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glVertex3d"); + if(!_ptrc_glVertex3d) numFailed++; + _ptrc_glVertex3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glVertex3dv"); + if(!_ptrc_glVertex3dv) numFailed++; + _ptrc_glVertex3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glVertex3f"); + if(!_ptrc_glVertex3f) numFailed++; + _ptrc_glVertex3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glVertex3fv"); + if(!_ptrc_glVertex3fv) numFailed++; + _ptrc_glVertex3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glVertex3i"); + if(!_ptrc_glVertex3i) numFailed++; + _ptrc_glVertex3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glVertex3iv"); + if(!_ptrc_glVertex3iv) numFailed++; + _ptrc_glVertex3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glVertex3s"); + if(!_ptrc_glVertex3s) numFailed++; + _ptrc_glVertex3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glVertex3sv"); + if(!_ptrc_glVertex3sv) numFailed++; + _ptrc_glVertex4d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glVertex4d"); + if(!_ptrc_glVertex4d) numFailed++; + _ptrc_glVertex4dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glVertex4dv"); + if(!_ptrc_glVertex4dv) numFailed++; + _ptrc_glVertex4f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glVertex4f"); + if(!_ptrc_glVertex4f) numFailed++; + _ptrc_glVertex4fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glVertex4fv"); + if(!_ptrc_glVertex4fv) numFailed++; + _ptrc_glVertex4i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint, GLint))IntGetProcAddress("glVertex4i"); + if(!_ptrc_glVertex4i) numFailed++; + _ptrc_glVertex4iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glVertex4iv"); + if(!_ptrc_glVertex4iv) numFailed++; + _ptrc_glVertex4s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glVertex4s"); + if(!_ptrc_glVertex4s) numFailed++; + _ptrc_glVertex4sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glVertex4sv"); + if(!_ptrc_glVertex4sv) numFailed++; + _ptrc_glViewport = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLsizei, GLsizei))IntGetProcAddress("glViewport"); + if(!_ptrc_glViewport) numFailed++; + _ptrc_glAreTexturesResident = (GLboolean (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *, GLboolean *))IntGetProcAddress("glAreTexturesResident"); + if(!_ptrc_glAreTexturesResident) numFailed++; + _ptrc_glArrayElement = (void (CODEGEN_FUNCPTR *)(GLint))IntGetProcAddress("glArrayElement"); + if(!_ptrc_glArrayElement) numFailed++; + _ptrc_glBindTexture = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint))IntGetProcAddress("glBindTexture"); + if(!_ptrc_glBindTexture) numFailed++; + _ptrc_glColorPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const void *))IntGetProcAddress("glColorPointer"); + if(!_ptrc_glColorPointer) 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_glDisableClientState = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glDisableClientState"); + if(!_ptrc_glDisableClientState) numFailed++; + _ptrc_glDrawArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLsizei))IntGetProcAddress("glDrawArrays"); + if(!_ptrc_glDrawArrays) numFailed++; + _ptrc_glDrawElements = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const void *))IntGetProcAddress("glDrawElements"); + if(!_ptrc_glDrawElements) numFailed++; + _ptrc_glEdgeFlagPointer = (void (CODEGEN_FUNCPTR *)(GLsizei, const void *))IntGetProcAddress("glEdgeFlagPointer"); + if(!_ptrc_glEdgeFlagPointer) numFailed++; + _ptrc_glEnableClientState = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glEnableClientState"); + if(!_ptrc_glEnableClientState) numFailed++; + _ptrc_glGenTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, GLuint *))IntGetProcAddress("glGenTextures"); + if(!_ptrc_glGenTextures) numFailed++; + _ptrc_glGetPointerv = (void (CODEGEN_FUNCPTR *)(GLenum, void **))IntGetProcAddress("glGetPointerv"); + if(!_ptrc_glGetPointerv) numFailed++; + _ptrc_glIndexPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const void *))IntGetProcAddress("glIndexPointer"); + if(!_ptrc_glIndexPointer) numFailed++; + _ptrc_glIndexub = (void (CODEGEN_FUNCPTR *)(GLubyte))IntGetProcAddress("glIndexub"); + if(!_ptrc_glIndexub) numFailed++; + _ptrc_glIndexubv = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glIndexubv"); + if(!_ptrc_glIndexubv) numFailed++; + _ptrc_glInterleavedArrays = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const void *))IntGetProcAddress("glInterleavedArrays"); + if(!_ptrc_glInterleavedArrays) numFailed++; + _ptrc_glIsTexture = (GLboolean (CODEGEN_FUNCPTR *)(GLuint))IntGetProcAddress("glIsTexture"); + if(!_ptrc_glIsTexture) numFailed++; + _ptrc_glNormalPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const void *))IntGetProcAddress("glNormalPointer"); + if(!_ptrc_glNormalPointer) numFailed++; + _ptrc_glPolygonOffset = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glPolygonOffset"); + if(!_ptrc_glPolygonOffset) numFailed++; + _ptrc_glPopClientAttrib = (void (CODEGEN_FUNCPTR *)(void))IntGetProcAddress("glPopClientAttrib"); + if(!_ptrc_glPopClientAttrib) numFailed++; + _ptrc_glPrioritizeTextures = (void (CODEGEN_FUNCPTR *)(GLsizei, const GLuint *, const GLfloat *))IntGetProcAddress("glPrioritizeTextures"); + if(!_ptrc_glPrioritizeTextures) numFailed++; + _ptrc_glPushClientAttrib = (void (CODEGEN_FUNCPTR *)(GLbitfield))IntGetProcAddress("glPushClientAttrib"); + if(!_ptrc_glPushClientAttrib) numFailed++; + _ptrc_glTexCoordPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const void *))IntGetProcAddress("glTexCoordPointer"); + if(!_ptrc_glTexCoordPointer) numFailed++; + _ptrc_glTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const void *))IntGetProcAddress("glTexSubImage1D"); + if(!_ptrc_glTexSubImage1D) numFailed++; + _ptrc_glTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const void *))IntGetProcAddress("glTexSubImage2D"); + if(!_ptrc_glTexSubImage2D) numFailed++; + _ptrc_glVertexPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const void *))IntGetProcAddress("glVertexPointer"); + if(!_ptrc_glVertexPointer) 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 void *))IntGetProcAddress("glDrawRangeElements"); + if(!_ptrc_glDrawRangeElements) numFailed++; + _ptrc_glTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))IntGetProcAddress("glTexImage3D"); + if(!_ptrc_glTexImage3D) numFailed++; + _ptrc_glTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const void *))IntGetProcAddress("glTexSubImage3D"); + if(!_ptrc_glTexSubImage3D) numFailed++; + _ptrc_glActiveTexture = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glActiveTexture"); + if(!_ptrc_glActiveTexture) numFailed++; + _ptrc_glClientActiveTexture = (void (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glClientActiveTexture"); + if(!_ptrc_glClientActiveTexture) numFailed++; + _ptrc_glCompressedTexImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage1D"); + if(!_ptrc_glCompressedTexImage1D) numFailed++; + _ptrc_glCompressedTexImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage2D"); + if(!_ptrc_glCompressedTexImage2D) numFailed++; + _ptrc_glCompressedTexImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const void *))IntGetProcAddress("glCompressedTexImage3D"); + if(!_ptrc_glCompressedTexImage3D) numFailed++; + _ptrc_glCompressedTexSubImage1D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage1D"); + if(!_ptrc_glCompressedTexSubImage1D) numFailed++; + _ptrc_glCompressedTexSubImage2D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage2D"); + if(!_ptrc_glCompressedTexSubImage2D) numFailed++; + _ptrc_glCompressedTexSubImage3D = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const void *))IntGetProcAddress("glCompressedTexSubImage3D"); + if(!_ptrc_glCompressedTexSubImage3D) numFailed++; + _ptrc_glGetCompressedTexImage = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, void *))IntGetProcAddress("glGetCompressedTexImage"); + if(!_ptrc_glGetCompressedTexImage) numFailed++; + _ptrc_glLoadTransposeMatrixd = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glLoadTransposeMatrixd"); + if(!_ptrc_glLoadTransposeMatrixd) numFailed++; + _ptrc_glLoadTransposeMatrixf = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glLoadTransposeMatrixf"); + if(!_ptrc_glLoadTransposeMatrixf) numFailed++; + _ptrc_glMultTransposeMatrixd = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glMultTransposeMatrixd"); + if(!_ptrc_glMultTransposeMatrixd) numFailed++; + _ptrc_glMultTransposeMatrixf = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glMultTransposeMatrixf"); + if(!_ptrc_glMultTransposeMatrixf) numFailed++; + _ptrc_glMultiTexCoord1d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble))IntGetProcAddress("glMultiTexCoord1d"); + if(!_ptrc_glMultiTexCoord1d) numFailed++; + _ptrc_glMultiTexCoord1dv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLdouble *))IntGetProcAddress("glMultiTexCoord1dv"); + if(!_ptrc_glMultiTexCoord1dv) numFailed++; + _ptrc_glMultiTexCoord1f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat))IntGetProcAddress("glMultiTexCoord1f"); + if(!_ptrc_glMultiTexCoord1f) numFailed++; + _ptrc_glMultiTexCoord1fv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glMultiTexCoord1fv"); + if(!_ptrc_glMultiTexCoord1fv) numFailed++; + _ptrc_glMultiTexCoord1i = (void (CODEGEN_FUNCPTR *)(GLenum, GLint))IntGetProcAddress("glMultiTexCoord1i"); + if(!_ptrc_glMultiTexCoord1i) numFailed++; + _ptrc_glMultiTexCoord1iv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glMultiTexCoord1iv"); + if(!_ptrc_glMultiTexCoord1iv) numFailed++; + _ptrc_glMultiTexCoord1s = (void (CODEGEN_FUNCPTR *)(GLenum, GLshort))IntGetProcAddress("glMultiTexCoord1s"); + if(!_ptrc_glMultiTexCoord1s) numFailed++; + _ptrc_glMultiTexCoord1sv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLshort *))IntGetProcAddress("glMultiTexCoord1sv"); + if(!_ptrc_glMultiTexCoord1sv) numFailed++; + _ptrc_glMultiTexCoord2d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble, GLdouble))IntGetProcAddress("glMultiTexCoord2d"); + if(!_ptrc_glMultiTexCoord2d) numFailed++; + _ptrc_glMultiTexCoord2dv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLdouble *))IntGetProcAddress("glMultiTexCoord2dv"); + if(!_ptrc_glMultiTexCoord2dv) numFailed++; + _ptrc_glMultiTexCoord2f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat, GLfloat))IntGetProcAddress("glMultiTexCoord2f"); + if(!_ptrc_glMultiTexCoord2f) numFailed++; + _ptrc_glMultiTexCoord2fv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glMultiTexCoord2fv"); + if(!_ptrc_glMultiTexCoord2fv) numFailed++; + _ptrc_glMultiTexCoord2i = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint))IntGetProcAddress("glMultiTexCoord2i"); + if(!_ptrc_glMultiTexCoord2i) numFailed++; + _ptrc_glMultiTexCoord2iv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glMultiTexCoord2iv"); + if(!_ptrc_glMultiTexCoord2iv) numFailed++; + _ptrc_glMultiTexCoord2s = (void (CODEGEN_FUNCPTR *)(GLenum, GLshort, GLshort))IntGetProcAddress("glMultiTexCoord2s"); + if(!_ptrc_glMultiTexCoord2s) numFailed++; + _ptrc_glMultiTexCoord2sv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLshort *))IntGetProcAddress("glMultiTexCoord2sv"); + if(!_ptrc_glMultiTexCoord2sv) numFailed++; + _ptrc_glMultiTexCoord3d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glMultiTexCoord3d"); + if(!_ptrc_glMultiTexCoord3d) numFailed++; + _ptrc_glMultiTexCoord3dv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLdouble *))IntGetProcAddress("glMultiTexCoord3dv"); + if(!_ptrc_glMultiTexCoord3dv) numFailed++; + _ptrc_glMultiTexCoord3f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glMultiTexCoord3f"); + if(!_ptrc_glMultiTexCoord3f) numFailed++; + _ptrc_glMultiTexCoord3fv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glMultiTexCoord3fv"); + if(!_ptrc_glMultiTexCoord3fv) numFailed++; + _ptrc_glMultiTexCoord3i = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint))IntGetProcAddress("glMultiTexCoord3i"); + if(!_ptrc_glMultiTexCoord3i) numFailed++; + _ptrc_glMultiTexCoord3iv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glMultiTexCoord3iv"); + if(!_ptrc_glMultiTexCoord3iv) numFailed++; + _ptrc_glMultiTexCoord3s = (void (CODEGEN_FUNCPTR *)(GLenum, GLshort, GLshort, GLshort))IntGetProcAddress("glMultiTexCoord3s"); + if(!_ptrc_glMultiTexCoord3s) numFailed++; + _ptrc_glMultiTexCoord3sv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLshort *))IntGetProcAddress("glMultiTexCoord3sv"); + if(!_ptrc_glMultiTexCoord3sv) numFailed++; + _ptrc_glMultiTexCoord4d = (void (CODEGEN_FUNCPTR *)(GLenum, GLdouble, GLdouble, GLdouble, GLdouble))IntGetProcAddress("glMultiTexCoord4d"); + if(!_ptrc_glMultiTexCoord4d) numFailed++; + _ptrc_glMultiTexCoord4dv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLdouble *))IntGetProcAddress("glMultiTexCoord4dv"); + if(!_ptrc_glMultiTexCoord4dv) numFailed++; + _ptrc_glMultiTexCoord4f = (void (CODEGEN_FUNCPTR *)(GLenum, GLfloat, GLfloat, GLfloat, GLfloat))IntGetProcAddress("glMultiTexCoord4f"); + if(!_ptrc_glMultiTexCoord4f) numFailed++; + _ptrc_glMultiTexCoord4fv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLfloat *))IntGetProcAddress("glMultiTexCoord4fv"); + if(!_ptrc_glMultiTexCoord4fv) numFailed++; + _ptrc_glMultiTexCoord4i = (void (CODEGEN_FUNCPTR *)(GLenum, GLint, GLint, GLint, GLint))IntGetProcAddress("glMultiTexCoord4i"); + if(!_ptrc_glMultiTexCoord4i) numFailed++; + _ptrc_glMultiTexCoord4iv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLint *))IntGetProcAddress("glMultiTexCoord4iv"); + if(!_ptrc_glMultiTexCoord4iv) numFailed++; + _ptrc_glMultiTexCoord4s = (void (CODEGEN_FUNCPTR *)(GLenum, GLshort, GLshort, GLshort, GLshort))IntGetProcAddress("glMultiTexCoord4s"); + if(!_ptrc_glMultiTexCoord4s) numFailed++; + _ptrc_glMultiTexCoord4sv = (void (CODEGEN_FUNCPTR *)(GLenum, const GLshort *))IntGetProcAddress("glMultiTexCoord4sv"); + if(!_ptrc_glMultiTexCoord4sv) numFailed++; + _ptrc_glSampleCoverage = (void (CODEGEN_FUNCPTR *)(GLfloat, GLboolean))IntGetProcAddress("glSampleCoverage"); + if(!_ptrc_glSampleCoverage) 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_glBlendFuncSeparate = (void (CODEGEN_FUNCPTR *)(GLenum, GLenum, GLenum, GLenum))IntGetProcAddress("glBlendFuncSeparate"); + if(!_ptrc_glBlendFuncSeparate) numFailed++; + _ptrc_glFogCoordPointer = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, const void *))IntGetProcAddress("glFogCoordPointer"); + if(!_ptrc_glFogCoordPointer) numFailed++; + _ptrc_glFogCoordd = (void (CODEGEN_FUNCPTR *)(GLdouble))IntGetProcAddress("glFogCoordd"); + if(!_ptrc_glFogCoordd) numFailed++; + _ptrc_glFogCoorddv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glFogCoorddv"); + if(!_ptrc_glFogCoorddv) numFailed++; + _ptrc_glFogCoordf = (void (CODEGEN_FUNCPTR *)(GLfloat))IntGetProcAddress("glFogCoordf"); + if(!_ptrc_glFogCoordf) numFailed++; + _ptrc_glFogCoordfv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glFogCoordfv"); + if(!_ptrc_glFogCoordfv) 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 void *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_glSecondaryColor3b = (void (CODEGEN_FUNCPTR *)(GLbyte, GLbyte, GLbyte))IntGetProcAddress("glSecondaryColor3b"); + if(!_ptrc_glSecondaryColor3b) numFailed++; + _ptrc_glSecondaryColor3bv = (void (CODEGEN_FUNCPTR *)(const GLbyte *))IntGetProcAddress("glSecondaryColor3bv"); + if(!_ptrc_glSecondaryColor3bv) numFailed++; + _ptrc_glSecondaryColor3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glSecondaryColor3d"); + if(!_ptrc_glSecondaryColor3d) numFailed++; + _ptrc_glSecondaryColor3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glSecondaryColor3dv"); + if(!_ptrc_glSecondaryColor3dv) numFailed++; + _ptrc_glSecondaryColor3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glSecondaryColor3f"); + if(!_ptrc_glSecondaryColor3f) numFailed++; + _ptrc_glSecondaryColor3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glSecondaryColor3fv"); + if(!_ptrc_glSecondaryColor3fv) numFailed++; + _ptrc_glSecondaryColor3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glSecondaryColor3i"); + if(!_ptrc_glSecondaryColor3i) numFailed++; + _ptrc_glSecondaryColor3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glSecondaryColor3iv"); + if(!_ptrc_glSecondaryColor3iv) numFailed++; + _ptrc_glSecondaryColor3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glSecondaryColor3s"); + if(!_ptrc_glSecondaryColor3s) numFailed++; + _ptrc_glSecondaryColor3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glSecondaryColor3sv"); + if(!_ptrc_glSecondaryColor3sv) numFailed++; + _ptrc_glSecondaryColor3ub = (void (CODEGEN_FUNCPTR *)(GLubyte, GLubyte, GLubyte))IntGetProcAddress("glSecondaryColor3ub"); + if(!_ptrc_glSecondaryColor3ub) numFailed++; + _ptrc_glSecondaryColor3ubv = (void (CODEGEN_FUNCPTR *)(const GLubyte *))IntGetProcAddress("glSecondaryColor3ubv"); + if(!_ptrc_glSecondaryColor3ubv) numFailed++; + _ptrc_glSecondaryColor3ui = (void (CODEGEN_FUNCPTR *)(GLuint, GLuint, GLuint))IntGetProcAddress("glSecondaryColor3ui"); + if(!_ptrc_glSecondaryColor3ui) numFailed++; + _ptrc_glSecondaryColor3uiv = (void (CODEGEN_FUNCPTR *)(const GLuint *))IntGetProcAddress("glSecondaryColor3uiv"); + if(!_ptrc_glSecondaryColor3uiv) numFailed++; + _ptrc_glSecondaryColor3us = (void (CODEGEN_FUNCPTR *)(GLushort, GLushort, GLushort))IntGetProcAddress("glSecondaryColor3us"); + if(!_ptrc_glSecondaryColor3us) numFailed++; + _ptrc_glSecondaryColor3usv = (void (CODEGEN_FUNCPTR *)(const GLushort *))IntGetProcAddress("glSecondaryColor3usv"); + if(!_ptrc_glSecondaryColor3usv) numFailed++; + _ptrc_glSecondaryColorPointer = (void (CODEGEN_FUNCPTR *)(GLint, GLenum, GLsizei, const void *))IntGetProcAddress("glSecondaryColorPointer"); + if(!_ptrc_glSecondaryColorPointer) numFailed++; + _ptrc_glWindowPos2d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble))IntGetProcAddress("glWindowPos2d"); + if(!_ptrc_glWindowPos2d) numFailed++; + _ptrc_glWindowPos2dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glWindowPos2dv"); + if(!_ptrc_glWindowPos2dv) numFailed++; + _ptrc_glWindowPos2f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat))IntGetProcAddress("glWindowPos2f"); + if(!_ptrc_glWindowPos2f) numFailed++; + _ptrc_glWindowPos2fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glWindowPos2fv"); + if(!_ptrc_glWindowPos2fv) numFailed++; + _ptrc_glWindowPos2i = (void (CODEGEN_FUNCPTR *)(GLint, GLint))IntGetProcAddress("glWindowPos2i"); + if(!_ptrc_glWindowPos2i) numFailed++; + _ptrc_glWindowPos2iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glWindowPos2iv"); + if(!_ptrc_glWindowPos2iv) numFailed++; + _ptrc_glWindowPos2s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort))IntGetProcAddress("glWindowPos2s"); + if(!_ptrc_glWindowPos2s) numFailed++; + _ptrc_glWindowPos2sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glWindowPos2sv"); + if(!_ptrc_glWindowPos2sv) numFailed++; + _ptrc_glWindowPos3d = (void (CODEGEN_FUNCPTR *)(GLdouble, GLdouble, GLdouble))IntGetProcAddress("glWindowPos3d"); + if(!_ptrc_glWindowPos3d) numFailed++; + _ptrc_glWindowPos3dv = (void (CODEGEN_FUNCPTR *)(const GLdouble *))IntGetProcAddress("glWindowPos3dv"); + if(!_ptrc_glWindowPos3dv) numFailed++; + _ptrc_glWindowPos3f = (void (CODEGEN_FUNCPTR *)(GLfloat, GLfloat, GLfloat))IntGetProcAddress("glWindowPos3f"); + if(!_ptrc_glWindowPos3f) numFailed++; + _ptrc_glWindowPos3fv = (void (CODEGEN_FUNCPTR *)(const GLfloat *))IntGetProcAddress("glWindowPos3fv"); + if(!_ptrc_glWindowPos3fv) numFailed++; + _ptrc_glWindowPos3i = (void (CODEGEN_FUNCPTR *)(GLint, GLint, GLint))IntGetProcAddress("glWindowPos3i"); + if(!_ptrc_glWindowPos3i) numFailed++; + _ptrc_glWindowPos3iv = (void (CODEGEN_FUNCPTR *)(const GLint *))IntGetProcAddress("glWindowPos3iv"); + if(!_ptrc_glWindowPos3iv) numFailed++; + _ptrc_glWindowPos3s = (void (CODEGEN_FUNCPTR *)(GLshort, GLshort, GLshort))IntGetProcAddress("glWindowPos3s"); + if(!_ptrc_glWindowPos3s) numFailed++; + _ptrc_glWindowPos3sv = (void (CODEGEN_FUNCPTR *)(const GLshort *))IntGetProcAddress("glWindowPos3sv"); + if(!_ptrc_glWindowPos3sv) 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 void *, GLenum))IntGetProcAddress("glBufferData"); + if(!_ptrc_glBufferData) numFailed++; + _ptrc_glBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, const void *))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, void **))IntGetProcAddress("glGetBufferPointerv"); + if(!_ptrc_glGetBufferPointerv) numFailed++; + _ptrc_glGetBufferSubData = (void (CODEGEN_FUNCPTR *)(GLenum, GLintptr, GLsizeiptr, void *))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 *)(void))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, void **))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 void *))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 *)(void))IntGetProcAddress("glEndConditionalRender"); + if(!_ptrc_glEndConditionalRender) numFailed++; + _ptrc_glEndTransformFeedback = (void (CODEGEN_FUNCPTR *)(void))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 void *))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 void *, 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 void *, GLint))IntGetProcAddress("glDrawElementsBaseVertex"); + if(!_ptrc_glDrawElementsBaseVertex) numFailed++; + _ptrc_glDrawElementsInstancedBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, const void *, GLsizei, GLint))IntGetProcAddress("glDrawElementsInstancedBaseVertex"); + if(!_ptrc_glDrawElementsInstancedBaseVertex) numFailed++; + _ptrc_glDrawRangeElementsBaseVertex = (void (CODEGEN_FUNCPTR *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const void *, 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 void *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, GLenum, GLsizei, GLsizei, GLboolean))IntGetProcAddress("glTexImage2DMultisample"); + if(!_ptrc_glTexImage2DMultisample) numFailed++; + _ptrc_glTexImage3DMultisample = (void (CODEGEN_FUNCPTR *)(GLenum, GLsizei, GLenum, 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)(void); +typedef struct ogl_StrToExtMap_s +{ + char *extensionName; + int *extensionVariable; + PFN_LOADFUNCPOINTERS LoadExtension; +} ogl_StrToExtMap; + +static ogl_StrToExtMap ExtensionMap[11] = { + {"GL_APPLE_client_storage", &ogl_ext_APPLE_client_storage, 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_ARB_texture_compression", &ogl_ext_ARB_texture_compression, Load_ARB_texture_compression}, + {"GL_ARB_texture_rectangle", &ogl_ext_ARB_texture_rectangle, NULL}, + {"GL_EXT_framebuffer_object", &ogl_ext_EXT_framebuffer_object, Load_EXT_framebuffer_object}, + {"GL_EXT_texture_compression_s3tc", &ogl_ext_EXT_texture_compression_s3tc, NULL}, + {"GL_EXT_texture_filter_anisotropic", &ogl_ext_EXT_texture_filter_anisotropic, NULL}, + {"GL_EXT_texture_sRGB", &ogl_ext_EXT_texture_sRGB, NULL}, + {"GL_KHR_debug", &ogl_ext_KHR_debug, Load_KHR_debug}, + {"GL_ARB_invalidate_subdata", &ogl_ext_ARB_invalidate_subdata, Load_ARB_invalidate_subdata}, +}; + +static int g_extensionMapSize = 11; + +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(void) +{ + ogl_ext_APPLE_client_storage = ogl_LOAD_FAILED; + ogl_ext_ARB_buffer_storage = ogl_LOAD_FAILED; + ogl_ext_ARB_shader_storage_buffer_object = ogl_LOAD_FAILED; + ogl_ext_ARB_texture_compression = ogl_LOAD_FAILED; + ogl_ext_ARB_texture_rectangle = ogl_LOAD_FAILED; + ogl_ext_EXT_framebuffer_object = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_compression_s3tc = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_filter_anisotropic = ogl_LOAD_FAILED; + ogl_ext_EXT_texture_sRGB = ogl_LOAD_FAILED; + ogl_ext_KHR_debug = ogl_LOAD_FAILED; + ogl_ext_ARB_invalidate_subdata = 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; + } + } +} + +/* BEGINNING OF MANUAL CHANGES, DO NOT REMOVE! */ + +static void ProcExtsFromExtString(const char *strExtList) +{ + size_t iExtListLen = strlen(strExtList); + const char *strExtListEnd = strExtList + iExtListLen; + const char *strCurrPos = strExtList; + char strWorkBuff[256]; + + while (*strCurrPos) + { + /*Get the extension at our position.*/ + int iStrLen = 0; + const char *strEndStr = strchr(strCurrPos, ' '); + int iStop = 0; + if (strEndStr == NULL) + { + strEndStr = strExtListEnd; + iStop = 1; + } + + iStrLen = (int)((ptrdiff_t)strEndStr - (ptrdiff_t)strCurrPos); + + if (iStrLen > 255) + return; + + strncpy(strWorkBuff, strCurrPos, iStrLen); + strWorkBuff[iStrLen] = '\0'; + + LoadExtByName(strWorkBuff); + + strCurrPos = strEndStr + 1; + if (iStop) break; + } +} + +static int ProcExtsFromExtList(void) +{ + GLint iLoop; + GLint iNumExtensions = 0; + + if (_ptrc_glGetStringi == NULL) return 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); + } + + return iNumExtensions; +} + +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 (0 == ProcExtsFromExtList()) + { + _ptrc_glGetString = (const GLubyte * (CODEGEN_FUNCPTR *)(GLenum))IntGetProcAddress("glGetString"); + if (!_ptrc_glGetString) return ogl_LOAD_FAILED; + + ProcExtsFromExtString((const char *)_ptrc_glGetString(GL_EXTENSIONS)); + } + + numFailed = Load_Version_3_3(); + + if(numFailed == 0) + return ogl_LOAD_SUCCEEDED; + else + return ogl_LOAD_SUCCEEDED + numFailed; +} + +/* END OF MANUAL CHANGES, DO NOT REMOVE! */ + +static int g_major_version = 0; +static int g_minor_version = 0; + +static void GetGLVersion(void) +{ + glGetIntegerv(GL_MAJOR_VERSION, &g_major_version); + glGetIntegerv(GL_MINOR_VERSION, &g_minor_version); +} + +int ogl_GetMajorVersion(void) +{ + if(g_major_version == 0) + GetGLVersion(); + return g_major_version; +} + +int ogl_GetMinorVersion(void) +{ + 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..892709ccd --- /dev/null +++ b/src/gl/system/gl_load.h @@ -0,0 +1,3122 @@ +#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_APPLE_client_storage; +extern int ogl_ext_ARB_buffer_storage; +extern int ogl_ext_ARB_shader_storage_buffer_object; +extern int ogl_ext_ARB_texture_compression; +extern int ogl_ext_ARB_texture_rectangle; +extern int ogl_ext_EXT_framebuffer_object; +extern int ogl_ext_EXT_texture_compression_s3tc; +extern int ogl_ext_EXT_texture_filter_anisotropic; +extern int ogl_ext_EXT_texture_sRGB; +extern int ogl_ext_KHR_debug; +extern int ogl_ext_ARB_invalidate_subdata; + +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 + +#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_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_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 + +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 + +#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_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE + +#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_BUFFER 0x82E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DISPLAY_LIST 0x82E7 +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_PROGRAM 0x82E2 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_QUERY 0x82E3 +#define GL_SAMPLER 0x82E6 +#define GL_SHADER 0x82E1 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_VERTEX_ARRAY 0x8074 + +#define GL_2D 0x0600 +#define GL_2_BYTES 0x1407 +#define GL_3D 0x0601 +#define GL_3D_COLOR 0x0602 +#define GL_3D_COLOR_TEXTURE 0x0603 +#define GL_3_BYTES 0x1408 +#define GL_4D_COLOR_TEXTURE 0x0604 +#define GL_4_BYTES 0x1409 +#define GL_ACCUM 0x0100 +#define GL_ACCUM_ALPHA_BITS 0x0D5B +#define GL_ACCUM_BLUE_BITS 0x0D5A +#define GL_ACCUM_BUFFER_BIT 0x00000200 +#define GL_ACCUM_CLEAR_VALUE 0x0B80 +#define GL_ACCUM_GREEN_BITS 0x0D59 +#define GL_ACCUM_RED_BITS 0x0D58 +#define GL_ADD 0x0104 +#define GL_ALL_ATTRIB_BITS 0xFFFFFFFF +#define GL_ALPHA 0x1906 +#define GL_ALPHA12 0x803D +#define GL_ALPHA16 0x803E +#define GL_ALPHA4 0x803B +#define GL_ALPHA8 0x803C +#define GL_ALPHA_BIAS 0x0D1D +#define GL_ALPHA_BITS 0x0D55 +#define GL_ALPHA_SCALE 0x0D1C +#define GL_ALPHA_TEST 0x0BC0 +#define GL_ALPHA_TEST_FUNC 0x0BC1 +#define GL_ALPHA_TEST_REF 0x0BC2 +#define GL_ALWAYS 0x0207 +#define GL_AMBIENT 0x1200 +#define GL_AMBIENT_AND_DIFFUSE 0x1602 +#define GL_AND 0x1501 +#define GL_AND_INVERTED 0x1504 +#define GL_AND_REVERSE 0x1502 +#define GL_ATTRIB_STACK_DEPTH 0x0BB0 +#define GL_AUTO_NORMAL 0x0D80 +#define GL_AUX0 0x0409 +#define GL_AUX1 0x040A +#define GL_AUX2 0x040B +#define GL_AUX3 0x040C +#define GL_AUX_BUFFERS 0x0C00 +#define GL_BACK 0x0405 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_BITMAP 0x1A00 +#define GL_BITMAP_TOKEN 0x0704 +#define GL_BLEND 0x0BE2 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLUE 0x1905 +#define GL_BLUE_BIAS 0x0D1B +#define GL_BLUE_BITS 0x0D54 +#define GL_BLUE_SCALE 0x0D1A +#define GL_BYTE 0x1400 +#define GL_C3F_V3F 0x2A24 +#define GL_C4F_N3F_V3F 0x2A26 +#define GL_C4UB_V2F 0x2A22 +#define GL_C4UB_V3F 0x2A23 +#define GL_CCW 0x0901 +#define GL_CLAMP 0x2900 +#define GL_CLEAR 0x1500 +#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF +#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 +#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 +#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 +#define GL_CLIP_PLANE0 0x3000 +#define GL_CLIP_PLANE1 0x3001 +#define GL_CLIP_PLANE2 0x3002 +#define GL_CLIP_PLANE3 0x3003 +#define GL_CLIP_PLANE4 0x3004 +#define GL_CLIP_PLANE5 0x3005 +#define GL_COEFF 0x0A00 +#define GL_COLOR 0x1800 +#define GL_COLOR_ARRAY 0x8076 +#define GL_COLOR_ARRAY_POINTER 0x8090 +#define GL_COLOR_ARRAY_SIZE 0x8081 +#define GL_COLOR_ARRAY_STRIDE 0x8083 +#define GL_COLOR_ARRAY_TYPE 0x8082 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_INDEX 0x1900 +#define GL_COLOR_INDEXES 0x1603 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_COLOR_MATERIAL 0x0B57 +#define GL_COLOR_MATERIAL_FACE 0x0B55 +#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_COMPILE 0x1300 +#define GL_COMPILE_AND_EXECUTE 0x1301 +#define GL_CONSTANT_ATTENUATION 0x1207 +#define GL_COPY 0x1503 +#define GL_COPY_INVERTED 0x150C +#define GL_COPY_PIXEL_TOKEN 0x0706 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_CURRENT_BIT 0x00000001 +#define GL_CURRENT_COLOR 0x0B00 +#define GL_CURRENT_INDEX 0x0B01 +#define GL_CURRENT_NORMAL 0x0B02 +#define GL_CURRENT_RASTER_COLOR 0x0B04 +#define GL_CURRENT_RASTER_DISTANCE 0x0B09 +#define GL_CURRENT_RASTER_INDEX 0x0B05 +#define GL_CURRENT_RASTER_POSITION 0x0B07 +#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 +#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 +#define GL_CURRENT_TEXTURE_COORDS 0x0B03 +#define GL_CW 0x0900 +#define GL_DECAL 0x2101 +#define GL_DECR 0x1E03 +#define GL_DEPTH 0x1801 +#define GL_DEPTH_BIAS 0x0D1F +#define GL_DEPTH_BITS 0x0D56 +#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_SCALE 0x0D1E +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DIFFUSE 0x1201 +#define GL_DITHER 0x0BD0 +#define GL_DOMAIN 0x0A02 +#define GL_DONT_CARE 0x1100 +#define GL_DOUBLE 0x140A +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_DRAW_PIXEL_TOKEN 0x0705 +#define GL_DST_ALPHA 0x0304 +#define GL_DST_COLOR 0x0306 +#define GL_EDGE_FLAG 0x0B43 +#define GL_EDGE_FLAG_ARRAY 0x8079 +#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 +#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C +#define GL_EMISSION 0x1600 +#define GL_ENABLE_BIT 0x00002000 +#define GL_EQUAL 0x0202 +#define GL_EQUIV 0x1509 +#define GL_EVAL_BIT 0x00010000 +#define GL_EXP 0x0800 +#define GL_EXP2 0x0801 +#define GL_EXTENSIONS 0x1F03 +#define GL_EYE_LINEAR 0x2400 +#define GL_EYE_PLANE 0x2502 +#define GL_FALSE 0 +#define GL_FASTEST 0x1101 +#define GL_FEEDBACK 0x1C01 +#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 +#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 +#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 +#define GL_FILL 0x1B02 +#define GL_FLAT 0x1D00 +#define GL_FLOAT 0x1406 +#define GL_FOG 0x0B60 +#define GL_FOG_BIT 0x00000080 +#define GL_FOG_COLOR 0x0B66 +#define GL_FOG_DENSITY 0x0B62 +#define GL_FOG_END 0x0B64 +#define GL_FOG_HINT 0x0C54 +#define GL_FOG_INDEX 0x0B61 +#define GL_FOG_MODE 0x0B65 +#define GL_FOG_START 0x0B63 +#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_GREEN_BIAS 0x0D19 +#define GL_GREEN_BITS 0x0D53 +#define GL_GREEN_SCALE 0x0D18 +#define GL_HINT_BIT 0x00008000 +#define GL_INCR 0x1E02 +#define GL_INDEX_ARRAY 0x8077 +#define GL_INDEX_ARRAY_POINTER 0x8091 +#define GL_INDEX_ARRAY_STRIDE 0x8086 +#define GL_INDEX_ARRAY_TYPE 0x8085 +#define GL_INDEX_BITS 0x0D51 +#define GL_INDEX_CLEAR_VALUE 0x0C20 +#define GL_INDEX_LOGIC_OP 0x0BF1 +#define GL_INDEX_MODE 0x0C30 +#define GL_INDEX_OFFSET 0x0D13 +#define GL_INDEX_SHIFT 0x0D12 +#define GL_INDEX_WRITEMASK 0x0C21 +#define GL_INT 0x1404 +#define GL_INTENSITY 0x8049 +#define GL_INTENSITY12 0x804C +#define GL_INTENSITY16 0x804D +#define GL_INTENSITY4 0x804A +#define GL_INTENSITY8 0x804B +#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_LIGHT0 0x4000 +#define GL_LIGHT1 0x4001 +#define GL_LIGHT2 0x4002 +#define GL_LIGHT3 0x4003 +#define GL_LIGHT4 0x4004 +#define GL_LIGHT5 0x4005 +#define GL_LIGHT6 0x4006 +#define GL_LIGHT7 0x4007 +#define GL_LIGHTING 0x0B50 +#define GL_LIGHTING_BIT 0x00000040 +#define GL_LIGHT_MODEL_AMBIENT 0x0B53 +#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 +#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 +#define GL_LINE 0x1B01 +#define GL_LINEAR 0x2601 +#define GL_LINEAR_ATTENUATION 0x1208 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_LINES 0x0001 +#define GL_LINE_BIT 0x00000004 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_RESET_TOKEN 0x0707 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_LINE_STIPPLE 0x0B24 +#define GL_LINE_STIPPLE_PATTERN 0x0B25 +#define GL_LINE_STIPPLE_REPEAT 0x0B26 +#define GL_LINE_STRIP 0x0003 +#define GL_LINE_TOKEN 0x0702 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LIST_BASE 0x0B32 +#define GL_LIST_BIT 0x00020000 +#define GL_LIST_INDEX 0x0B33 +#define GL_LIST_MODE 0x0B30 +#define GL_LOAD 0x0101 +#define GL_LOGIC_OP 0x0BF1 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE12 0x8041 +#define GL_LUMINANCE12_ALPHA12 0x8047 +#define GL_LUMINANCE12_ALPHA4 0x8046 +#define GL_LUMINANCE16 0x8042 +#define GL_LUMINANCE16_ALPHA16 0x8048 +#define GL_LUMINANCE4 0x803F +#define GL_LUMINANCE4_ALPHA4 0x8043 +#define GL_LUMINANCE6_ALPHA2 0x8044 +#define GL_LUMINANCE8 0x8040 +#define GL_LUMINANCE8_ALPHA8 0x8045 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_MAP1_COLOR_4 0x0D90 +#define GL_MAP1_GRID_DOMAIN 0x0DD0 +#define GL_MAP1_GRID_SEGMENTS 0x0DD1 +#define GL_MAP1_INDEX 0x0D91 +#define GL_MAP1_NORMAL 0x0D92 +#define GL_MAP1_TEXTURE_COORD_1 0x0D93 +#define GL_MAP1_TEXTURE_COORD_2 0x0D94 +#define GL_MAP1_TEXTURE_COORD_3 0x0D95 +#define GL_MAP1_TEXTURE_COORD_4 0x0D96 +#define GL_MAP1_VERTEX_3 0x0D97 +#define GL_MAP1_VERTEX_4 0x0D98 +#define GL_MAP2_COLOR_4 0x0DB0 +#define GL_MAP2_GRID_DOMAIN 0x0DD2 +#define GL_MAP2_GRID_SEGMENTS 0x0DD3 +#define GL_MAP2_INDEX 0x0DB1 +#define GL_MAP2_NORMAL 0x0DB2 +#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 +#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 +#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 +#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 +#define GL_MAP2_VERTEX_3 0x0DB7 +#define GL_MAP2_VERTEX_4 0x0DB8 +#define GL_MAP_COLOR 0x0D10 +#define GL_MAP_STENCIL 0x0D11 +#define GL_MATRIX_MODE 0x0BA0 +#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 +#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B +#define GL_MAX_CLIP_PLANES 0x0D32 +#define GL_MAX_EVAL_ORDER 0x0D30 +#define GL_MAX_LIGHTS 0x0D31 +#define GL_MAX_LIST_NESTING 0x0B31 +#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 +#define GL_MAX_NAME_STACK_DEPTH 0x0D37 +#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 +#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_MODELVIEW 0x1700 +#define GL_MODELVIEW_MATRIX 0x0BA6 +#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 +#define GL_MODULATE 0x2100 +#define GL_MULT 0x0103 +#define GL_N3F_V3F 0x2A25 +#define GL_NAME_STACK_DEPTH 0x0D70 +#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_NORMALIZE 0x0BA1 +#define GL_NORMAL_ARRAY 0x8075 +#define GL_NORMAL_ARRAY_POINTER 0x808F +#define GL_NORMAL_ARRAY_STRIDE 0x807F +#define GL_NORMAL_ARRAY_TYPE 0x807E +#define GL_NOTEQUAL 0x0205 +#define GL_NO_ERROR 0 +#define GL_OBJECT_LINEAR 0x2401 +#define GL_OBJECT_PLANE 0x2501 +#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_ORDER 0x0A01 +#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_PASS_THROUGH_TOKEN 0x0700 +#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 +#define GL_PIXEL_MAP_A_TO_A 0x0C79 +#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 +#define GL_PIXEL_MAP_B_TO_B 0x0C78 +#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 +#define GL_PIXEL_MAP_G_TO_G 0x0C77 +#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 +#define GL_PIXEL_MAP_I_TO_A 0x0C75 +#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 +#define GL_PIXEL_MAP_I_TO_B 0x0C74 +#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 +#define GL_PIXEL_MAP_I_TO_G 0x0C73 +#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 +#define GL_PIXEL_MAP_I_TO_I 0x0C70 +#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 +#define GL_PIXEL_MAP_I_TO_R 0x0C72 +#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 +#define GL_PIXEL_MAP_R_TO_R 0x0C76 +#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 +#define GL_PIXEL_MAP_S_TO_S 0x0C71 +#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 +#define GL_PIXEL_MODE_BIT 0x00000020 +#define GL_POINT 0x1B00 +#define GL_POINTS 0x0000 +#define GL_POINT_BIT 0x00000002 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POINT_SMOOTH 0x0B10 +#define GL_POINT_SMOOTH_HINT 0x0C51 +#define GL_POINT_TOKEN 0x0701 +#define GL_POLYGON 0x0009 +#define GL_POLYGON_BIT 0x00000008 +#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_POLYGON_STIPPLE 0x0B42 +#define GL_POLYGON_STIPPLE_BIT 0x00000010 +#define GL_POLYGON_TOKEN 0x0703 +#define GL_POSITION 0x1203 +#define GL_PROJECTION 0x1701 +#define GL_PROJECTION_MATRIX 0x0BA7 +#define GL_PROJECTION_STACK_DEPTH 0x0BA4 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_Q 0x2003 +#define GL_QUADRATIC_ATTENUATION 0x1209 +#define GL_QUADS 0x0007 +#define GL_QUAD_STRIP 0x0008 +#define GL_R 0x2002 +#define GL_R3_G3_B2 0x2A10 +#define GL_READ_BUFFER 0x0C02 +#define GL_RED 0x1903 +#define GL_RED_BIAS 0x0D15 +#define GL_RED_BITS 0x0D52 +#define GL_RED_SCALE 0x0D14 +#define GL_RENDER 0x1C00 +#define GL_RENDERER 0x1F01 +#define GL_RENDER_MODE 0x0C40 +#define GL_REPEAT 0x2901 +#define GL_REPLACE 0x1E01 +#define GL_RETURN 0x0102 +#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_RGBA_MODE 0x0C31 +#define GL_RIGHT 0x0407 +#define GL_S 0x2000 +#define GL_SCISSOR_BIT 0x00080000 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_SELECT 0x1C02 +#define GL_SELECTION_BUFFER_POINTER 0x0DF3 +#define GL_SELECTION_BUFFER_SIZE 0x0DF4 +#define GL_SET 0x150F +#define GL_SHADE_MODEL 0x0B54 +#define GL_SHININESS 0x1601 +#define GL_SHORT 0x1402 +#define GL_SMOOTH 0x1D01 +#define GL_SPECULAR 0x1202 +#define GL_SPHERE_MAP 0x2402 +#define GL_SPOT_CUTOFF 0x1206 +#define GL_SPOT_DIRECTION 0x1204 +#define GL_SPOT_EXPONENT 0x1205 +#define GL_SRC_ALPHA 0x0302 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_SRC_COLOR 0x0300 +/*Copied GL_STACK_OVERFLOW From: KHR_debug*/ +/*Copied GL_STACK_UNDERFLOW From: KHR_debug*/ +#define GL_STENCIL 0x1802 +#define GL_STENCIL_BITS 0x0D57 +#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_T 0x2001 +#define GL_T2F_C3F_V3F 0x2A2A +#define GL_T2F_C4F_N3F_V3F 0x2A2C +#define GL_T2F_C4UB_V3F 0x2A29 +#define GL_T2F_N3F_V3F 0x2A2B +#define GL_T2F_V3F 0x2A27 +#define GL_T4F_C4F_N3F_V4F 0x2A2D +#define GL_T4F_V4F 0x2A28 +#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_BIT 0x00040000 +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_BORDER 0x1005 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_COMPONENTS 0x1003 +#define GL_TEXTURE_COORD_ARRAY 0x8078 +#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 +#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 +#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A +#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 +#define GL_TEXTURE_ENV 0x2300 +#define GL_TEXTURE_ENV_COLOR 0x2201 +#define GL_TEXTURE_ENV_MODE 0x2200 +#define GL_TEXTURE_GEN_MODE 0x2500 +#define GL_TEXTURE_GEN_Q 0x0C63 +#define GL_TEXTURE_GEN_R 0x0C62 +#define GL_TEXTURE_GEN_S 0x0C60 +#define GL_TEXTURE_GEN_T 0x0C61 +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_INTENSITY_SIZE 0x8061 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MATRIX 0x0BA8 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_PRIORITY 0x8066 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_RESIDENT 0x8067 +#define GL_TEXTURE_STACK_DEPTH 0x0BA5 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TRANSFORM_BIT 0x00001000 +#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_V2F 0x2A20 +#define GL_V3F 0x2A21 +#define GL_VENDOR 0x1F00 +#define GL_VERSION 0x1F02 +/*Copied GL_VERTEX_ARRAY From: KHR_debug*/ +#define GL_VERTEX_ARRAY_POINTER 0x808E +#define GL_VERTEX_ARRAY_SIZE 0x807A +#define GL_VERTEX_ARRAY_STRIDE 0x807C +#define GL_VERTEX_ARRAY_TYPE 0x807B +#define GL_VIEWPORT 0x0BA2 +#define GL_VIEWPORT_BIT 0x00000800 +#define GL_XOR 0x1506 +#define GL_ZERO 0 +#define GL_ZOOM_X 0x0D16 +#define GL_ZOOM_Y 0x0D17 + +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#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_RESCALE_NORMAL 0x803A +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SINGLE_COLOR 0x81F9 +#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_ADD_SIGNED 0x8574 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_COMBINE 0x8570 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CONSTANT 0x8576 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#define GL_INTERPOLATE 0x8575 +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_MULTISAMPLE 0x809D +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_OPERAND2_RGB 0x8592 +#define GL_PREVIOUS 0x8578 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_REFLECTION_MAP 0x8512 +#define GL_RGB_SCALE 0x8573 +#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_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_SOURCE2_RGB 0x8582 +#define GL_SUBTRACT 0x84E7 +#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_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 + +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_COLOR_SUM 0x8458 +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_DECR_WRAP 0x8508 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_FOG_COORDINATE 0x8451 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_FUNC_SUBTRACT 0x800A +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#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_DISTANCE_ATTENUATION 0x8129 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#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_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_CURRENT_QUERY 0x8865 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_FOG_COORD 0x8451 +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_SRC 0x8450 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#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_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_ALPHA 0x8589 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_ALPHA 0x858A +#define GL_SRC2_RGB 0x8582 +#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_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#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_COORD_REPLACE 0x8862 +#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_COORDS 0x8871 +#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 0x8861 +#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_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_SHADER 0x8B31 + +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#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_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_SRGB_ALPHA 0x8C42 + +#define GL_ALPHA_INTEGER 0x8D97 +#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_FRAGMENT_COLOR 0x891B +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_CLAMP_VERTEX_COLOR 0x891A +#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_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#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_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#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_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#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_GEOMETRY_SHADER 0x8A45 +#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_buffer_storage +#define GL_ARB_buffer_storage 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferStorage)(GLenum target, GLsizeiptr size, const void * data, GLbitfield flags); +#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 program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#define glShaderStorageBlockBinding _ptrc_glShaderStorageBlockBinding +#endif /*GL_ARB_shader_storage_buffer_object*/ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data); +#define glCompressedTexImage1DARB _ptrc_glCompressedTexImage1DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data); +#define glCompressedTexImage2DARB _ptrc_glCompressedTexImage2DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data); +#define glCompressedTexImage3DARB _ptrc_glCompressedTexImage3DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data); +#define glCompressedTexSubImage1DARB _ptrc_glCompressedTexSubImage1DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data); +#define glCompressedTexSubImage2DARB _ptrc_glCompressedTexSubImage2DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data); +#define glCompressedTexSubImage3DARB _ptrc_glCompressedTexSubImage3DARB +extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImageARB)(GLenum target, GLint level, void * img); +#define glGetCompressedTexImageARB _ptrc_glGetCompressedTexImageARB +#endif /*GL_ARB_texture_compression*/ + + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebufferEXT)(GLenum target, GLuint framebuffer); +#define glBindFramebufferEXT _ptrc_glBindFramebufferEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbufferEXT)(GLenum target, GLuint renderbuffer); +#define glBindRenderbufferEXT _ptrc_glBindRenderbufferEXT +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatusEXT)(GLenum target); +#define glCheckFramebufferStatusEXT _ptrc_glCheckFramebufferStatusEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffersEXT)(GLsizei n, const GLuint * framebuffers); +#define glDeleteFramebuffersEXT _ptrc_glDeleteFramebuffersEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffersEXT)(GLsizei n, const GLuint * renderbuffers); +#define glDeleteRenderbuffersEXT _ptrc_glDeleteRenderbuffersEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +#define glFramebufferRenderbufferEXT _ptrc_glFramebufferRenderbufferEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +#define glFramebufferTexture1DEXT _ptrc_glFramebufferTexture1DEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +#define glFramebufferTexture2DEXT _ptrc_glFramebufferTexture2DEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#define glFramebufferTexture3DEXT _ptrc_glFramebufferTexture3DEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffersEXT)(GLsizei n, GLuint * framebuffers); +#define glGenFramebuffersEXT _ptrc_glGenFramebuffersEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffersEXT)(GLsizei n, GLuint * renderbuffers); +#define glGenRenderbuffersEXT _ptrc_glGenRenderbuffersEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmapEXT)(GLenum target); +#define glGenerateMipmapEXT _ptrc_glGenerateMipmapEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint * params); +#define glGetFramebufferAttachmentParameterivEXT _ptrc_glGetFramebufferAttachmentParameterivEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint * params); +#define glGetRenderbufferParameterivEXT _ptrc_glGetRenderbufferParameterivEXT +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebufferEXT)(GLuint framebuffer); +#define glIsFramebufferEXT _ptrc_glIsFramebufferEXT +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbufferEXT)(GLuint renderbuffer); +#define glIsRenderbufferEXT _ptrc_glIsRenderbufferEXT +extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +#define glRenderbufferStorageEXT _ptrc_glRenderbufferStorageEXT +#endif /*GL_EXT_framebuffer_object*/ + + + + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageCallback)(GLDEBUGPROC callback, const void * userParam); +#define glDebugMessageCallback _ptrc_glDebugMessageCallback +extern void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageControl)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint * ids, GLboolean enabled); +#define glDebugMessageControl _ptrc_glDebugMessageControl +extern void (CODEGEN_FUNCPTR *_ptrc_glDebugMessageInsert)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar * buf); +#define glDebugMessageInsert _ptrc_glDebugMessageInsert +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetDebugMessageLog)(GLuint count, GLsizei bufSize, GLenum * sources, GLenum * types, GLuint * ids, GLenum * severities, GLsizei * lengths, GLchar * messageLog); +#define glGetDebugMessageLog _ptrc_glGetDebugMessageLog +extern void (CODEGEN_FUNCPTR *_ptrc_glGetObjectLabel)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei * length, GLchar * label); +#define glGetObjectLabel _ptrc_glGetObjectLabel +extern void (CODEGEN_FUNCPTR *_ptrc_glGetObjectPtrLabel)(const void * ptr, GLsizei bufSize, GLsizei * length, GLchar * label); +#define glGetObjectPtrLabel _ptrc_glGetObjectPtrLabel +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum pname, void ** params); +#define glGetPointerv _ptrc_glGetPointerv +extern void (CODEGEN_FUNCPTR *_ptrc_glObjectLabel)(GLenum identifier, GLuint name, GLsizei length, const GLchar * label); +#define glObjectLabel _ptrc_glObjectLabel +extern void (CODEGEN_FUNCPTR *_ptrc_glObjectPtrLabel)(const void * ptr, GLsizei length, const GLchar * label); +#define glObjectPtrLabel _ptrc_glObjectPtrLabel +extern void (CODEGEN_FUNCPTR *_ptrc_glPopDebugGroup)(void); +#define glPopDebugGroup _ptrc_glPopDebugGroup +extern void (CODEGEN_FUNCPTR *_ptrc_glPushDebugGroup)(GLenum source, GLuint id, GLsizei length, const GLchar * message); +#define glPushDebugGroup _ptrc_glPushDebugGroup +#endif /*GL_KHR_debug*/ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateBufferData)(GLuint buffer); +#define glInvalidateBufferData _ptrc_glInvalidateBufferData +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateBufferSubData)(GLuint buffer, GLintptr offset, GLsizeiptr length); +#define glInvalidateBufferSubData _ptrc_glInvalidateBufferSubData +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum * attachments); +#define glInvalidateFramebuffer _ptrc_glInvalidateFramebuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateSubFramebuffer)(GLenum target, GLsizei numAttachments, const GLenum * attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#define glInvalidateSubFramebuffer _ptrc_glInvalidateSubFramebuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateTexImage)(GLuint texture, GLint level); +#define glInvalidateTexImage _ptrc_glInvalidateTexImage +extern void (CODEGEN_FUNCPTR *_ptrc_glInvalidateTexSubImage)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +#define glInvalidateTexSubImage _ptrc_glInvalidateTexSubImage +#endif /*GL_ARB_invalidate_subdata*/ + +extern void (CODEGEN_FUNCPTR *_ptrc_glAccum)(GLenum op, GLfloat value); +#define glAccum _ptrc_glAccum +extern void (CODEGEN_FUNCPTR *_ptrc_glAlphaFunc)(GLenum func, GLfloat ref); +#define glAlphaFunc _ptrc_glAlphaFunc +extern void (CODEGEN_FUNCPTR *_ptrc_glBegin)(GLenum mode); +#define glBegin _ptrc_glBegin +extern void (CODEGEN_FUNCPTR *_ptrc_glBitmap)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap); +#define glBitmap _ptrc_glBitmap +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFunc)(GLenum sfactor, GLenum dfactor); +#define glBlendFunc _ptrc_glBlendFunc +extern void (CODEGEN_FUNCPTR *_ptrc_glCallList)(GLuint list); +#define glCallList _ptrc_glCallList +extern void (CODEGEN_FUNCPTR *_ptrc_glCallLists)(GLsizei n, GLenum type, const void * lists); +#define glCallLists _ptrc_glCallLists +extern void (CODEGEN_FUNCPTR *_ptrc_glClear)(GLbitfield mask); +#define glClear _ptrc_glClear +extern void (CODEGEN_FUNCPTR *_ptrc_glClearAccum)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#define glClearAccum _ptrc_glClearAccum +extern void (CODEGEN_FUNCPTR *_ptrc_glClearColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#define glClearColor _ptrc_glClearColor +extern void (CODEGEN_FUNCPTR *_ptrc_glClearDepth)(GLdouble depth); +#define glClearDepth _ptrc_glClearDepth +extern void (CODEGEN_FUNCPTR *_ptrc_glClearIndex)(GLfloat c); +#define glClearIndex _ptrc_glClearIndex +extern void (CODEGEN_FUNCPTR *_ptrc_glClearStencil)(GLint s); +#define glClearStencil _ptrc_glClearStencil +extern void (CODEGEN_FUNCPTR *_ptrc_glClipPlane)(GLenum plane, const GLdouble * equation); +#define glClipPlane _ptrc_glClipPlane +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3b)(GLbyte red, GLbyte green, GLbyte blue); +#define glColor3b _ptrc_glColor3b +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3bv)(const GLbyte * v); +#define glColor3bv _ptrc_glColor3bv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3d)(GLdouble red, GLdouble green, GLdouble blue); +#define glColor3d _ptrc_glColor3d +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3dv)(const GLdouble * v); +#define glColor3dv _ptrc_glColor3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3f)(GLfloat red, GLfloat green, GLfloat blue); +#define glColor3f _ptrc_glColor3f +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3fv)(const GLfloat * v); +#define glColor3fv _ptrc_glColor3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3i)(GLint red, GLint green, GLint blue); +#define glColor3i _ptrc_glColor3i +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3iv)(const GLint * v); +#define glColor3iv _ptrc_glColor3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3s)(GLshort red, GLshort green, GLshort blue); +#define glColor3s _ptrc_glColor3s +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3sv)(const GLshort * v); +#define glColor3sv _ptrc_glColor3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ub)(GLubyte red, GLubyte green, GLubyte blue); +#define glColor3ub _ptrc_glColor3ub +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ubv)(const GLubyte * v); +#define glColor3ubv _ptrc_glColor3ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3ui)(GLuint red, GLuint green, GLuint blue); +#define glColor3ui _ptrc_glColor3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3uiv)(const GLuint * v); +#define glColor3uiv _ptrc_glColor3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3us)(GLushort red, GLushort green, GLushort blue); +#define glColor3us _ptrc_glColor3us +extern void (CODEGEN_FUNCPTR *_ptrc_glColor3usv)(const GLushort * v); +#define glColor3usv _ptrc_glColor3usv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4b)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +#define glColor4b _ptrc_glColor4b +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4bv)(const GLbyte * v); +#define glColor4bv _ptrc_glColor4bv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4d)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +#define glColor4d _ptrc_glColor4d +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4dv)(const GLdouble * v); +#define glColor4dv _ptrc_glColor4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#define glColor4f _ptrc_glColor4f +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4fv)(const GLfloat * v); +#define glColor4fv _ptrc_glColor4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4i)(GLint red, GLint green, GLint blue, GLint alpha); +#define glColor4i _ptrc_glColor4i +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4iv)(const GLint * v); +#define glColor4iv _ptrc_glColor4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4s)(GLshort red, GLshort green, GLshort blue, GLshort alpha); +#define glColor4s _ptrc_glColor4s +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4sv)(const GLshort * v); +#define glColor4sv _ptrc_glColor4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +#define glColor4ub _ptrc_glColor4ub +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ubv)(const GLubyte * v); +#define glColor4ubv _ptrc_glColor4ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4ui)(GLuint red, GLuint green, GLuint blue, GLuint alpha); +#define glColor4ui _ptrc_glColor4ui +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4uiv)(const GLuint * v); +#define glColor4uiv _ptrc_glColor4uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4us)(GLushort red, GLushort green, GLushort blue, GLushort alpha); +#define glColor4us _ptrc_glColor4us +extern void (CODEGEN_FUNCPTR *_ptrc_glColor4usv)(const GLushort * v); +#define glColor4usv _ptrc_glColor4usv +extern void (CODEGEN_FUNCPTR *_ptrc_glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#define glColorMask _ptrc_glColorMask +extern void (CODEGEN_FUNCPTR *_ptrc_glColorMaterial)(GLenum face, GLenum mode); +#define glColorMaterial _ptrc_glColorMaterial +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +#define glCopyPixels _ptrc_glCopyPixels +extern void (CODEGEN_FUNCPTR *_ptrc_glCullFace)(GLenum mode); +#define glCullFace _ptrc_glCullFace +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteLists)(GLuint list, GLsizei range); +#define glDeleteLists _ptrc_glDeleteLists +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthFunc)(GLenum func); +#define glDepthFunc _ptrc_glDepthFunc +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthMask)(GLboolean flag); +#define glDepthMask _ptrc_glDepthMask +extern void (CODEGEN_FUNCPTR *_ptrc_glDepthRange)(GLdouble ren_near, GLdouble ren_far); +#define glDepthRange _ptrc_glDepthRange +extern void (CODEGEN_FUNCPTR *_ptrc_glDisable)(GLenum cap); +#define glDisable _ptrc_glDisable +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffer)(GLenum buf); +#define glDrawBuffer _ptrc_glDrawBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawPixels)(GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); +#define glDrawPixels _ptrc_glDrawPixels +extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlag)(GLboolean flag); +#define glEdgeFlag _ptrc_glEdgeFlag +extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagv)(const GLboolean * flag); +#define glEdgeFlagv _ptrc_glEdgeFlagv +extern void (CODEGEN_FUNCPTR *_ptrc_glEnable)(GLenum cap); +#define glEnable _ptrc_glEnable +extern void (CODEGEN_FUNCPTR *_ptrc_glEnd)(void); +#define glEnd _ptrc_glEnd +extern void (CODEGEN_FUNCPTR *_ptrc_glEndList)(void); +#define glEndList _ptrc_glEndList +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1d)(GLdouble u); +#define glEvalCoord1d _ptrc_glEvalCoord1d +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1dv)(const GLdouble * u); +#define glEvalCoord1dv _ptrc_glEvalCoord1dv +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1f)(GLfloat u); +#define glEvalCoord1f _ptrc_glEvalCoord1f +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord1fv)(const GLfloat * u); +#define glEvalCoord1fv _ptrc_glEvalCoord1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2d)(GLdouble u, GLdouble v); +#define glEvalCoord2d _ptrc_glEvalCoord2d +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2dv)(const GLdouble * u); +#define glEvalCoord2dv _ptrc_glEvalCoord2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2f)(GLfloat u, GLfloat v); +#define glEvalCoord2f _ptrc_glEvalCoord2f +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalCoord2fv)(const GLfloat * u); +#define glEvalCoord2fv _ptrc_glEvalCoord2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh1)(GLenum mode, GLint i1, GLint i2); +#define glEvalMesh1 _ptrc_glEvalMesh1 +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalMesh2)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +#define glEvalMesh2 _ptrc_glEvalMesh2 +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint1)(GLint i); +#define glEvalPoint1 _ptrc_glEvalPoint1 +extern void (CODEGEN_FUNCPTR *_ptrc_glEvalPoint2)(GLint i, GLint j); +#define glEvalPoint2 _ptrc_glEvalPoint2 +extern void (CODEGEN_FUNCPTR *_ptrc_glFeedbackBuffer)(GLsizei size, GLenum type, GLfloat * buffer); +#define glFeedbackBuffer _ptrc_glFeedbackBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glFinish)(void); +#define glFinish _ptrc_glFinish +extern void (CODEGEN_FUNCPTR *_ptrc_glFlush)(void); +#define glFlush _ptrc_glFlush +extern void (CODEGEN_FUNCPTR *_ptrc_glFogf)(GLenum pname, GLfloat param); +#define glFogf _ptrc_glFogf +extern void (CODEGEN_FUNCPTR *_ptrc_glFogfv)(GLenum pname, const GLfloat * params); +#define glFogfv _ptrc_glFogfv +extern void (CODEGEN_FUNCPTR *_ptrc_glFogi)(GLenum pname, GLint param); +#define glFogi _ptrc_glFogi +extern void (CODEGEN_FUNCPTR *_ptrc_glFogiv)(GLenum pname, const GLint * params); +#define glFogiv _ptrc_glFogiv +extern void (CODEGEN_FUNCPTR *_ptrc_glFrontFace)(GLenum mode); +#define glFrontFace _ptrc_glFrontFace +extern void (CODEGEN_FUNCPTR *_ptrc_glFrustum)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +#define glFrustum _ptrc_glFrustum +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glGenLists)(GLsizei range); +#define glGenLists _ptrc_glGenLists +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleanv)(GLenum pname, GLboolean * data); +#define glGetBooleanv _ptrc_glGetBooleanv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetClipPlane)(GLenum plane, GLdouble * equation); +#define glGetClipPlane _ptrc_glGetClipPlane +extern void (CODEGEN_FUNCPTR *_ptrc_glGetDoublev)(GLenum pname, GLdouble * data); +#define glGetDoublev _ptrc_glGetDoublev +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glGetError)(void); +#define glGetError _ptrc_glGetError +extern void (CODEGEN_FUNCPTR *_ptrc_glGetFloatv)(GLenum pname, GLfloat * data); +#define glGetFloatv _ptrc_glGetFloatv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegerv)(GLenum pname, GLint * data); +#define glGetIntegerv _ptrc_glGetIntegerv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetLightfv)(GLenum light, GLenum pname, GLfloat * params); +#define glGetLightfv _ptrc_glGetLightfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetLightiv)(GLenum light, GLenum pname, GLint * params); +#define glGetLightiv _ptrc_glGetLightiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapdv)(GLenum target, GLenum query, GLdouble * v); +#define glGetMapdv _ptrc_glGetMapdv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapfv)(GLenum target, GLenum query, GLfloat * v); +#define glGetMapfv _ptrc_glGetMapfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMapiv)(GLenum target, GLenum query, GLint * v); +#define glGetMapiv _ptrc_glGetMapiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialfv)(GLenum face, GLenum pname, GLfloat * params); +#define glGetMaterialfv _ptrc_glGetMaterialfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMaterialiv)(GLenum face, GLenum pname, GLint * params); +#define glGetMaterialiv _ptrc_glGetMaterialiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapfv)(GLenum map, GLfloat * values); +#define glGetPixelMapfv _ptrc_glGetPixelMapfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapuiv)(GLenum map, GLuint * values); +#define glGetPixelMapuiv _ptrc_glGetPixelMapuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPixelMapusv)(GLenum map, GLushort * values); +#define glGetPixelMapusv _ptrc_glGetPixelMapusv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPolygonStipple)(GLubyte * mask); +#define glGetPolygonStipple _ptrc_glGetPolygonStipple +extern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetString)(GLenum name); +#define glGetString _ptrc_glGetString +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnvfv)(GLenum target, GLenum pname, GLfloat * params); +#define glGetTexEnvfv _ptrc_glGetTexEnvfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexEnviv)(GLenum target, GLenum pname, GLint * params); +#define glGetTexEnviv _ptrc_glGetTexEnviv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGendv)(GLenum coord, GLenum pname, GLdouble * params); +#define glGetTexGendv _ptrc_glGetTexGendv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGenfv)(GLenum coord, GLenum pname, GLfloat * params); +#define glGetTexGenfv _ptrc_glGetTexGenfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexGeniv)(GLenum coord, GLenum pname, GLint * params); +#define glGetTexGeniv _ptrc_glGetTexGeniv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, void * pixels); +#define glGetTexImage _ptrc_glGetTexImage +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat * params); +#define glGetTexLevelParameterfv _ptrc_glGetTexLevelParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint * params); +#define glGetTexLevelParameteriv _ptrc_glGetTexLevelParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat * params); +#define glGetTexParameterfv _ptrc_glGetTexParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameteriv)(GLenum target, GLenum pname, GLint * params); +#define glGetTexParameteriv _ptrc_glGetTexParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glHint)(GLenum target, GLenum mode); +#define glHint _ptrc_glHint +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexMask)(GLuint mask); +#define glIndexMask _ptrc_glIndexMask +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexd)(GLdouble c); +#define glIndexd _ptrc_glIndexd +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexdv)(const GLdouble * c); +#define glIndexdv _ptrc_glIndexdv +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexf)(GLfloat c); +#define glIndexf _ptrc_glIndexf +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexfv)(const GLfloat * c); +#define glIndexfv _ptrc_glIndexfv +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexi)(GLint c); +#define glIndexi _ptrc_glIndexi +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexiv)(const GLint * c); +#define glIndexiv _ptrc_glIndexiv +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexs)(GLshort c); +#define glIndexs _ptrc_glIndexs +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexsv)(const GLshort * c); +#define glIndexsv _ptrc_glIndexsv +extern void (CODEGEN_FUNCPTR *_ptrc_glInitNames)(void); +#define glInitNames _ptrc_glInitNames +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabled)(GLenum cap); +#define glIsEnabled _ptrc_glIsEnabled +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsList)(GLuint list); +#define glIsList _ptrc_glIsList +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModelf)(GLenum pname, GLfloat param); +#define glLightModelf _ptrc_glLightModelf +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModelfv)(GLenum pname, const GLfloat * params); +#define glLightModelfv _ptrc_glLightModelfv +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModeli)(GLenum pname, GLint param); +#define glLightModeli _ptrc_glLightModeli +extern void (CODEGEN_FUNCPTR *_ptrc_glLightModeliv)(GLenum pname, const GLint * params); +#define glLightModeliv _ptrc_glLightModeliv +extern void (CODEGEN_FUNCPTR *_ptrc_glLightf)(GLenum light, GLenum pname, GLfloat param); +#define glLightf _ptrc_glLightf +extern void (CODEGEN_FUNCPTR *_ptrc_glLightfv)(GLenum light, GLenum pname, const GLfloat * params); +#define glLightfv _ptrc_glLightfv +extern void (CODEGEN_FUNCPTR *_ptrc_glLighti)(GLenum light, GLenum pname, GLint param); +#define glLighti _ptrc_glLighti +extern void (CODEGEN_FUNCPTR *_ptrc_glLightiv)(GLenum light, GLenum pname, const GLint * params); +#define glLightiv _ptrc_glLightiv +extern void (CODEGEN_FUNCPTR *_ptrc_glLineStipple)(GLint factor, GLushort pattern); +#define glLineStipple _ptrc_glLineStipple +extern void (CODEGEN_FUNCPTR *_ptrc_glLineWidth)(GLfloat width); +#define glLineWidth _ptrc_glLineWidth +extern void (CODEGEN_FUNCPTR *_ptrc_glListBase)(GLuint base); +#define glListBase _ptrc_glListBase +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadIdentity)(void); +#define glLoadIdentity _ptrc_glLoadIdentity +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixd)(const GLdouble * m); +#define glLoadMatrixd _ptrc_glLoadMatrixd +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadMatrixf)(const GLfloat * m); +#define glLoadMatrixf _ptrc_glLoadMatrixf +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadName)(GLuint name); +#define glLoadName _ptrc_glLoadName +extern void (CODEGEN_FUNCPTR *_ptrc_glLogicOp)(GLenum opcode); +#define glLogicOp _ptrc_glLogicOp +extern void (CODEGEN_FUNCPTR *_ptrc_glMap1d)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points); +#define glMap1d _ptrc_glMap1d +extern void (CODEGEN_FUNCPTR *_ptrc_glMap1f)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points); +#define glMap1f _ptrc_glMap1f +extern void (CODEGEN_FUNCPTR *_ptrc_glMap2d)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points); +#define glMap2d _ptrc_glMap2d +extern void (CODEGEN_FUNCPTR *_ptrc_glMap2f)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points); +#define glMap2f _ptrc_glMap2f +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1d)(GLint un, GLdouble u1, GLdouble u2); +#define glMapGrid1d _ptrc_glMapGrid1d +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid1f)(GLint un, GLfloat u1, GLfloat u2); +#define glMapGrid1f _ptrc_glMapGrid1f +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2d)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +#define glMapGrid2d _ptrc_glMapGrid2d +extern void (CODEGEN_FUNCPTR *_ptrc_glMapGrid2f)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +#define glMapGrid2f _ptrc_glMapGrid2f +extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialf)(GLenum face, GLenum pname, GLfloat param); +#define glMaterialf _ptrc_glMaterialf +extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialfv)(GLenum face, GLenum pname, const GLfloat * params); +#define glMaterialfv _ptrc_glMaterialfv +extern void (CODEGEN_FUNCPTR *_ptrc_glMateriali)(GLenum face, GLenum pname, GLint param); +#define glMateriali _ptrc_glMateriali +extern void (CODEGEN_FUNCPTR *_ptrc_glMaterialiv)(GLenum face, GLenum pname, const GLint * params); +#define glMaterialiv _ptrc_glMaterialiv +extern void (CODEGEN_FUNCPTR *_ptrc_glMatrixMode)(GLenum mode); +#define glMatrixMode _ptrc_glMatrixMode +extern void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixd)(const GLdouble * m); +#define glMultMatrixd _ptrc_glMultMatrixd +extern void (CODEGEN_FUNCPTR *_ptrc_glMultMatrixf)(const GLfloat * m); +#define glMultMatrixf _ptrc_glMultMatrixf +extern void (CODEGEN_FUNCPTR *_ptrc_glNewList)(GLuint list, GLenum mode); +#define glNewList _ptrc_glNewList +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3b)(GLbyte nx, GLbyte ny, GLbyte nz); +#define glNormal3b _ptrc_glNormal3b +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3bv)(const GLbyte * v); +#define glNormal3bv _ptrc_glNormal3bv +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3d)(GLdouble nx, GLdouble ny, GLdouble nz); +#define glNormal3d _ptrc_glNormal3d +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3dv)(const GLdouble * v); +#define glNormal3dv _ptrc_glNormal3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3f)(GLfloat nx, GLfloat ny, GLfloat nz); +#define glNormal3f _ptrc_glNormal3f +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3fv)(const GLfloat * v); +#define glNormal3fv _ptrc_glNormal3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3i)(GLint nx, GLint ny, GLint nz); +#define glNormal3i _ptrc_glNormal3i +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3iv)(const GLint * v); +#define glNormal3iv _ptrc_glNormal3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3s)(GLshort nx, GLshort ny, GLshort nz); +#define glNormal3s _ptrc_glNormal3s +extern void (CODEGEN_FUNCPTR *_ptrc_glNormal3sv)(const GLshort * v); +#define glNormal3sv _ptrc_glNormal3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glOrtho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +#define glOrtho _ptrc_glOrtho +extern void (CODEGEN_FUNCPTR *_ptrc_glPassThrough)(GLfloat token); +#define glPassThrough _ptrc_glPassThrough +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapfv)(GLenum map, GLsizei mapsize, const GLfloat * values); +#define glPixelMapfv _ptrc_glPixelMapfv +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapuiv)(GLenum map, GLsizei mapsize, const GLuint * values); +#define glPixelMapuiv _ptrc_glPixelMapuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelMapusv)(GLenum map, GLsizei mapsize, const GLushort * values); +#define glPixelMapusv _ptrc_glPixelMapusv +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStoref)(GLenum pname, GLfloat param); +#define glPixelStoref _ptrc_glPixelStoref +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelStorei)(GLenum pname, GLint param); +#define glPixelStorei _ptrc_glPixelStorei +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferf)(GLenum pname, GLfloat param); +#define glPixelTransferf _ptrc_glPixelTransferf +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelTransferi)(GLenum pname, GLint param); +#define glPixelTransferi _ptrc_glPixelTransferi +extern void (CODEGEN_FUNCPTR *_ptrc_glPixelZoom)(GLfloat xfactor, GLfloat yfactor); +#define glPixelZoom _ptrc_glPixelZoom +extern void (CODEGEN_FUNCPTR *_ptrc_glPointSize)(GLfloat size); +#define glPointSize _ptrc_glPointSize +extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonMode)(GLenum face, GLenum mode); +#define glPolygonMode _ptrc_glPolygonMode +extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonStipple)(const GLubyte * mask); +#define glPolygonStipple _ptrc_glPolygonStipple +extern void (CODEGEN_FUNCPTR *_ptrc_glPopAttrib)(void); +#define glPopAttrib _ptrc_glPopAttrib +extern void (CODEGEN_FUNCPTR *_ptrc_glPopMatrix)(void); +#define glPopMatrix _ptrc_glPopMatrix +extern void (CODEGEN_FUNCPTR *_ptrc_glPopName)(void); +#define glPopName _ptrc_glPopName +extern void (CODEGEN_FUNCPTR *_ptrc_glPushAttrib)(GLbitfield mask); +#define glPushAttrib _ptrc_glPushAttrib +extern void (CODEGEN_FUNCPTR *_ptrc_glPushMatrix)(void); +#define glPushMatrix _ptrc_glPushMatrix +extern void (CODEGEN_FUNCPTR *_ptrc_glPushName)(GLuint name); +#define glPushName _ptrc_glPushName +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2d)(GLdouble x, GLdouble y); +#define glRasterPos2d _ptrc_glRasterPos2d +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2dv)(const GLdouble * v); +#define glRasterPos2dv _ptrc_glRasterPos2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2f)(GLfloat x, GLfloat y); +#define glRasterPos2f _ptrc_glRasterPos2f +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2fv)(const GLfloat * v); +#define glRasterPos2fv _ptrc_glRasterPos2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2i)(GLint x, GLint y); +#define glRasterPos2i _ptrc_glRasterPos2i +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2iv)(const GLint * v); +#define glRasterPos2iv _ptrc_glRasterPos2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2s)(GLshort x, GLshort y); +#define glRasterPos2s _ptrc_glRasterPos2s +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos2sv)(const GLshort * v); +#define glRasterPos2sv _ptrc_glRasterPos2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3d)(GLdouble x, GLdouble y, GLdouble z); +#define glRasterPos3d _ptrc_glRasterPos3d +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3dv)(const GLdouble * v); +#define glRasterPos3dv _ptrc_glRasterPos3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3f)(GLfloat x, GLfloat y, GLfloat z); +#define glRasterPos3f _ptrc_glRasterPos3f +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3fv)(const GLfloat * v); +#define glRasterPos3fv _ptrc_glRasterPos3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3i)(GLint x, GLint y, GLint z); +#define glRasterPos3i _ptrc_glRasterPos3i +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3iv)(const GLint * v); +#define glRasterPos3iv _ptrc_glRasterPos3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3s)(GLshort x, GLshort y, GLshort z); +#define glRasterPos3s _ptrc_glRasterPos3s +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos3sv)(const GLshort * v); +#define glRasterPos3sv _ptrc_glRasterPos3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +#define glRasterPos4d _ptrc_glRasterPos4d +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4dv)(const GLdouble * v); +#define glRasterPos4dv _ptrc_glRasterPos4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +#define glRasterPos4f _ptrc_glRasterPos4f +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4fv)(const GLfloat * v); +#define glRasterPos4fv _ptrc_glRasterPos4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4i)(GLint x, GLint y, GLint z, GLint w); +#define glRasterPos4i _ptrc_glRasterPos4i +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4iv)(const GLint * v); +#define glRasterPos4iv _ptrc_glRasterPos4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4s)(GLshort x, GLshort y, GLshort z, GLshort w); +#define glRasterPos4s _ptrc_glRasterPos4s +extern void (CODEGEN_FUNCPTR *_ptrc_glRasterPos4sv)(const GLshort * v); +#define glRasterPos4sv _ptrc_glRasterPos4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glReadBuffer)(GLenum src); +#define glReadBuffer _ptrc_glReadBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * pixels); +#define glReadPixels _ptrc_glReadPixels +extern void (CODEGEN_FUNCPTR *_ptrc_glRectd)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +#define glRectd _ptrc_glRectd +extern void (CODEGEN_FUNCPTR *_ptrc_glRectdv)(const GLdouble * v1, const GLdouble * v2); +#define glRectdv _ptrc_glRectdv +extern void (CODEGEN_FUNCPTR *_ptrc_glRectf)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +#define glRectf _ptrc_glRectf +extern void (CODEGEN_FUNCPTR *_ptrc_glRectfv)(const GLfloat * v1, const GLfloat * v2); +#define glRectfv _ptrc_glRectfv +extern void (CODEGEN_FUNCPTR *_ptrc_glRecti)(GLint x1, GLint y1, GLint x2, GLint y2); +#define glRecti _ptrc_glRecti +extern void (CODEGEN_FUNCPTR *_ptrc_glRectiv)(const GLint * v1, const GLint * v2); +#define glRectiv _ptrc_glRectiv +extern void (CODEGEN_FUNCPTR *_ptrc_glRects)(GLshort x1, GLshort y1, GLshort x2, GLshort y2); +#define glRects _ptrc_glRects +extern void (CODEGEN_FUNCPTR *_ptrc_glRectsv)(const GLshort * v1, const GLshort * v2); +#define glRectsv _ptrc_glRectsv +extern GLint (CODEGEN_FUNCPTR *_ptrc_glRenderMode)(GLenum mode); +#define glRenderMode _ptrc_glRenderMode +extern void (CODEGEN_FUNCPTR *_ptrc_glRotated)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +#define glRotated _ptrc_glRotated +extern void (CODEGEN_FUNCPTR *_ptrc_glRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +#define glRotatef _ptrc_glRotatef +extern void (CODEGEN_FUNCPTR *_ptrc_glScaled)(GLdouble x, GLdouble y, GLdouble z); +#define glScaled _ptrc_glScaled +extern void (CODEGEN_FUNCPTR *_ptrc_glScalef)(GLfloat x, GLfloat y, GLfloat z); +#define glScalef _ptrc_glScalef +extern void (CODEGEN_FUNCPTR *_ptrc_glScissor)(GLint x, GLint y, GLsizei width, GLsizei height); +#define glScissor _ptrc_glScissor +extern void (CODEGEN_FUNCPTR *_ptrc_glSelectBuffer)(GLsizei size, GLuint * buffer); +#define glSelectBuffer _ptrc_glSelectBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glShadeModel)(GLenum mode); +#define glShadeModel _ptrc_glShadeModel +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilFunc)(GLenum func, GLint ref, GLuint mask); +#define glStencilFunc _ptrc_glStencilFunc +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilMask)(GLuint mask); +#define glStencilMask _ptrc_glStencilMask +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass); +#define glStencilOp _ptrc_glStencilOp +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1d)(GLdouble s); +#define glTexCoord1d _ptrc_glTexCoord1d +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1dv)(const GLdouble * v); +#define glTexCoord1dv _ptrc_glTexCoord1dv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1f)(GLfloat s); +#define glTexCoord1f _ptrc_glTexCoord1f +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1fv)(const GLfloat * v); +#define glTexCoord1fv _ptrc_glTexCoord1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1i)(GLint s); +#define glTexCoord1i _ptrc_glTexCoord1i +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1iv)(const GLint * v); +#define glTexCoord1iv _ptrc_glTexCoord1iv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1s)(GLshort s); +#define glTexCoord1s _ptrc_glTexCoord1s +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord1sv)(const GLshort * v); +#define glTexCoord1sv _ptrc_glTexCoord1sv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2d)(GLdouble s, GLdouble t); +#define glTexCoord2d _ptrc_glTexCoord2d +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2dv)(const GLdouble * v); +#define glTexCoord2dv _ptrc_glTexCoord2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2f)(GLfloat s, GLfloat t); +#define glTexCoord2f _ptrc_glTexCoord2f +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2fv)(const GLfloat * v); +#define glTexCoord2fv _ptrc_glTexCoord2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2i)(GLint s, GLint t); +#define glTexCoord2i _ptrc_glTexCoord2i +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2iv)(const GLint * v); +#define glTexCoord2iv _ptrc_glTexCoord2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2s)(GLshort s, GLshort t); +#define glTexCoord2s _ptrc_glTexCoord2s +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord2sv)(const GLshort * v); +#define glTexCoord2sv _ptrc_glTexCoord2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3d)(GLdouble s, GLdouble t, GLdouble r); +#define glTexCoord3d _ptrc_glTexCoord3d +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3dv)(const GLdouble * v); +#define glTexCoord3dv _ptrc_glTexCoord3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3f)(GLfloat s, GLfloat t, GLfloat r); +#define glTexCoord3f _ptrc_glTexCoord3f +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3fv)(const GLfloat * v); +#define glTexCoord3fv _ptrc_glTexCoord3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3i)(GLint s, GLint t, GLint r); +#define glTexCoord3i _ptrc_glTexCoord3i +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3iv)(const GLint * v); +#define glTexCoord3iv _ptrc_glTexCoord3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3s)(GLshort s, GLshort t, GLshort r); +#define glTexCoord3s _ptrc_glTexCoord3s +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord3sv)(const GLshort * v); +#define glTexCoord3sv _ptrc_glTexCoord3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4d)(GLdouble s, GLdouble t, GLdouble r, GLdouble q); +#define glTexCoord4d _ptrc_glTexCoord4d +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4dv)(const GLdouble * v); +#define glTexCoord4dv _ptrc_glTexCoord4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4f)(GLfloat s, GLfloat t, GLfloat r, GLfloat q); +#define glTexCoord4f _ptrc_glTexCoord4f +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4fv)(const GLfloat * v); +#define glTexCoord4fv _ptrc_glTexCoord4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4i)(GLint s, GLint t, GLint r, GLint q); +#define glTexCoord4i _ptrc_glTexCoord4i +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4iv)(const GLint * v); +#define glTexCoord4iv _ptrc_glTexCoord4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4s)(GLshort s, GLshort t, GLshort r, GLshort q); +#define glTexCoord4s _ptrc_glTexCoord4s +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoord4sv)(const GLshort * v); +#define glTexCoord4sv _ptrc_glTexCoord4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvf)(GLenum target, GLenum pname, GLfloat param); +#define glTexEnvf _ptrc_glTexEnvf +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvfv)(GLenum target, GLenum pname, const GLfloat * params); +#define glTexEnvfv _ptrc_glTexEnvfv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnvi)(GLenum target, GLenum pname, GLint param); +#define glTexEnvi _ptrc_glTexEnvi +extern void (CODEGEN_FUNCPTR *_ptrc_glTexEnviv)(GLenum target, GLenum pname, const GLint * params); +#define glTexEnviv _ptrc_glTexEnviv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGend)(GLenum coord, GLenum pname, GLdouble param); +#define glTexGend _ptrc_glTexGend +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGendv)(GLenum coord, GLenum pname, const GLdouble * params); +#define glTexGendv _ptrc_glTexGendv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGenf)(GLenum coord, GLenum pname, GLfloat param); +#define glTexGenf _ptrc_glTexGenf +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGenfv)(GLenum coord, GLenum pname, const GLfloat * params); +#define glTexGenfv _ptrc_glTexGenfv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGeni)(GLenum coord, GLenum pname, GLint param); +#define glTexGeni _ptrc_glTexGeni +extern void (CODEGEN_FUNCPTR *_ptrc_glTexGeniv)(GLenum coord, GLenum pname, const GLint * params); +#define glTexGeniv _ptrc_glTexGeniv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void * pixels); +#define glTexImage1D _ptrc_glTexImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels); +#define glTexImage2D _ptrc_glTexImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterf)(GLenum target, GLenum pname, GLfloat param); +#define glTexParameterf _ptrc_glTexParameterf +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterfv)(GLenum target, GLenum pname, const GLfloat * params); +#define glTexParameterfv _ptrc_glTexParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteri)(GLenum target, GLenum pname, GLint param); +#define glTexParameteri _ptrc_glTexParameteri +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameteriv)(GLenum target, GLenum pname, const GLint * params); +#define glTexParameteriv _ptrc_glTexParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glTranslated)(GLdouble x, GLdouble y, GLdouble z); +#define glTranslated _ptrc_glTranslated +extern void (CODEGEN_FUNCPTR *_ptrc_glTranslatef)(GLfloat x, GLfloat y, GLfloat z); +#define glTranslatef _ptrc_glTranslatef +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2d)(GLdouble x, GLdouble y); +#define glVertex2d _ptrc_glVertex2d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2dv)(const GLdouble * v); +#define glVertex2dv _ptrc_glVertex2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2f)(GLfloat x, GLfloat y); +#define glVertex2f _ptrc_glVertex2f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2fv)(const GLfloat * v); +#define glVertex2fv _ptrc_glVertex2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2i)(GLint x, GLint y); +#define glVertex2i _ptrc_glVertex2i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2iv)(const GLint * v); +#define glVertex2iv _ptrc_glVertex2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2s)(GLshort x, GLshort y); +#define glVertex2s _ptrc_glVertex2s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex2sv)(const GLshort * v); +#define glVertex2sv _ptrc_glVertex2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3d)(GLdouble x, GLdouble y, GLdouble z); +#define glVertex3d _ptrc_glVertex3d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3dv)(const GLdouble * v); +#define glVertex3dv _ptrc_glVertex3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3f)(GLfloat x, GLfloat y, GLfloat z); +#define glVertex3f _ptrc_glVertex3f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3fv)(const GLfloat * v); +#define glVertex3fv _ptrc_glVertex3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3i)(GLint x, GLint y, GLint z); +#define glVertex3i _ptrc_glVertex3i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3iv)(const GLint * v); +#define glVertex3iv _ptrc_glVertex3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3s)(GLshort x, GLshort y, GLshort z); +#define glVertex3s _ptrc_glVertex3s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex3sv)(const GLshort * v); +#define glVertex3sv _ptrc_glVertex3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +#define glVertex4d _ptrc_glVertex4d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4dv)(const GLdouble * v); +#define glVertex4dv _ptrc_glVertex4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +#define glVertex4f _ptrc_glVertex4f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4fv)(const GLfloat * v); +#define glVertex4fv _ptrc_glVertex4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4i)(GLint x, GLint y, GLint z, GLint w); +#define glVertex4i _ptrc_glVertex4i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4iv)(const GLint * v); +#define glVertex4iv _ptrc_glVertex4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4s)(GLshort x, GLshort y, GLshort z, GLshort w); +#define glVertex4s _ptrc_glVertex4s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertex4sv)(const GLshort * v); +#define glVertex4sv _ptrc_glVertex4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glViewport)(GLint x, GLint y, GLsizei width, GLsizei height); +#define glViewport _ptrc_glViewport + +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glAreTexturesResident)(GLsizei n, const GLuint * textures, GLboolean * residences); +#define glAreTexturesResident _ptrc_glAreTexturesResident +extern void (CODEGEN_FUNCPTR *_ptrc_glArrayElement)(GLint i); +#define glArrayElement _ptrc_glArrayElement +extern void (CODEGEN_FUNCPTR *_ptrc_glBindTexture)(GLenum target, GLuint texture); +#define glBindTexture _ptrc_glBindTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glColorPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer); +#define glColorPointer _ptrc_glColorPointer +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +#define glCopyTexImage1D _ptrc_glCopyTexImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +#define glCopyTexImage2D _ptrc_glCopyTexImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +#define glCopyTexSubImage1D _ptrc_glCopyTexSubImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#define glCopyTexSubImage2D _ptrc_glCopyTexSubImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteTextures)(GLsizei n, const GLuint * textures); +#define glDeleteTextures _ptrc_glDeleteTextures +extern void (CODEGEN_FUNCPTR *_ptrc_glDisableClientState)(GLenum ren_array); +#define glDisableClientState _ptrc_glDisableClientState +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawArrays)(GLenum mode, GLint first, GLsizei count); +#define glDrawArrays _ptrc_glDrawArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElements)(GLenum mode, GLsizei count, GLenum type, const void * indices); +#define glDrawElements _ptrc_glDrawElements +extern void (CODEGEN_FUNCPTR *_ptrc_glEdgeFlagPointer)(GLsizei stride, const void * pointer); +#define glEdgeFlagPointer _ptrc_glEdgeFlagPointer +extern void (CODEGEN_FUNCPTR *_ptrc_glEnableClientState)(GLenum ren_array); +#define glEnableClientState _ptrc_glEnableClientState +extern void (CODEGEN_FUNCPTR *_ptrc_glGenTextures)(GLsizei n, GLuint * textures); +#define glGenTextures _ptrc_glGenTextures +extern void (CODEGEN_FUNCPTR *_ptrc_glGetPointerv)(GLenum pname, void ** params); +#define glGetPointerv _ptrc_glGetPointerv +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexPointer)(GLenum type, GLsizei stride, const void * pointer); +#define glIndexPointer _ptrc_glIndexPointer +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexub)(GLubyte c); +#define glIndexub _ptrc_glIndexub +extern void (CODEGEN_FUNCPTR *_ptrc_glIndexubv)(const GLubyte * c); +#define glIndexubv _ptrc_glIndexubv +extern void (CODEGEN_FUNCPTR *_ptrc_glInterleavedArrays)(GLenum format, GLsizei stride, const void * pointer); +#define glInterleavedArrays _ptrc_glInterleavedArrays +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsTexture)(GLuint texture); +#define glIsTexture _ptrc_glIsTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glNormalPointer)(GLenum type, GLsizei stride, const void * pointer); +#define glNormalPointer _ptrc_glNormalPointer +extern void (CODEGEN_FUNCPTR *_ptrc_glPolygonOffset)(GLfloat factor, GLfloat units); +#define glPolygonOffset _ptrc_glPolygonOffset +extern void (CODEGEN_FUNCPTR *_ptrc_glPopClientAttrib)(void); +#define glPopClientAttrib _ptrc_glPopClientAttrib +extern void (CODEGEN_FUNCPTR *_ptrc_glPrioritizeTextures)(GLsizei n, const GLuint * textures, const GLfloat * priorities); +#define glPrioritizeTextures _ptrc_glPrioritizeTextures +extern void (CODEGEN_FUNCPTR *_ptrc_glPushClientAttrib)(GLbitfield mask); +#define glPushClientAttrib _ptrc_glPushClientAttrib +extern void (CODEGEN_FUNCPTR *_ptrc_glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer); +#define glTexCoordPointer _ptrc_glTexCoordPointer +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void * pixels); +#define glTexSubImage1D _ptrc_glTexSubImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels); +#define glTexSubImage2D _ptrc_glTexSubImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer); +#define glVertexPointer _ptrc_glVertexPointer + +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#define glCopyTexSubImage3D _ptrc_glCopyTexSubImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices); +#define glDrawRangeElements _ptrc_glDrawRangeElements +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels); +#define glTexImage3D _ptrc_glTexImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * pixels); +#define glTexSubImage3D _ptrc_glTexSubImage3D + +extern void (CODEGEN_FUNCPTR *_ptrc_glActiveTexture)(GLenum texture); +#define glActiveTexture _ptrc_glActiveTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glClientActiveTexture)(GLenum texture); +#define glClientActiveTexture _ptrc_glClientActiveTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void * data); +#define glCompressedTexImage1D _ptrc_glCompressedTexImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void * data); +#define glCompressedTexImage2D _ptrc_glCompressedTexImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexImage3D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void * data); +#define glCompressedTexImage3D _ptrc_glCompressedTexImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void * data); +#define glCompressedTexSubImage1D _ptrc_glCompressedTexSubImage1D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void * data); +#define glCompressedTexSubImage2D _ptrc_glCompressedTexSubImage2D +extern void (CODEGEN_FUNCPTR *_ptrc_glCompressedTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void * data); +#define glCompressedTexSubImage3D _ptrc_glCompressedTexSubImage3D +extern void (CODEGEN_FUNCPTR *_ptrc_glGetCompressedTexImage)(GLenum target, GLint level, void * img); +#define glGetCompressedTexImage _ptrc_glGetCompressedTexImage +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixd)(const GLdouble * m); +#define glLoadTransposeMatrixd _ptrc_glLoadTransposeMatrixd +extern void (CODEGEN_FUNCPTR *_ptrc_glLoadTransposeMatrixf)(const GLfloat * m); +#define glLoadTransposeMatrixf _ptrc_glLoadTransposeMatrixf +extern void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixd)(const GLdouble * m); +#define glMultTransposeMatrixd _ptrc_glMultTransposeMatrixd +extern void (CODEGEN_FUNCPTR *_ptrc_glMultTransposeMatrixf)(const GLfloat * m); +#define glMultTransposeMatrixf _ptrc_glMultTransposeMatrixf +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1d)(GLenum target, GLdouble s); +#define glMultiTexCoord1d _ptrc_glMultiTexCoord1d +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1dv)(GLenum target, const GLdouble * v); +#define glMultiTexCoord1dv _ptrc_glMultiTexCoord1dv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1f)(GLenum target, GLfloat s); +#define glMultiTexCoord1f _ptrc_glMultiTexCoord1f +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1fv)(GLenum target, const GLfloat * v); +#define glMultiTexCoord1fv _ptrc_glMultiTexCoord1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1i)(GLenum target, GLint s); +#define glMultiTexCoord1i _ptrc_glMultiTexCoord1i +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1iv)(GLenum target, const GLint * v); +#define glMultiTexCoord1iv _ptrc_glMultiTexCoord1iv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1s)(GLenum target, GLshort s); +#define glMultiTexCoord1s _ptrc_glMultiTexCoord1s +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord1sv)(GLenum target, const GLshort * v); +#define glMultiTexCoord1sv _ptrc_glMultiTexCoord1sv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2d)(GLenum target, GLdouble s, GLdouble t); +#define glMultiTexCoord2d _ptrc_glMultiTexCoord2d +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2dv)(GLenum target, const GLdouble * v); +#define glMultiTexCoord2dv _ptrc_glMultiTexCoord2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2f)(GLenum target, GLfloat s, GLfloat t); +#define glMultiTexCoord2f _ptrc_glMultiTexCoord2f +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2fv)(GLenum target, const GLfloat * v); +#define glMultiTexCoord2fv _ptrc_glMultiTexCoord2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2i)(GLenum target, GLint s, GLint t); +#define glMultiTexCoord2i _ptrc_glMultiTexCoord2i +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2iv)(GLenum target, const GLint * v); +#define glMultiTexCoord2iv _ptrc_glMultiTexCoord2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2s)(GLenum target, GLshort s, GLshort t); +#define glMultiTexCoord2s _ptrc_glMultiTexCoord2s +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord2sv)(GLenum target, const GLshort * v); +#define glMultiTexCoord2sv _ptrc_glMultiTexCoord2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3d)(GLenum target, GLdouble s, GLdouble t, GLdouble r); +#define glMultiTexCoord3d _ptrc_glMultiTexCoord3d +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3dv)(GLenum target, const GLdouble * v); +#define glMultiTexCoord3dv _ptrc_glMultiTexCoord3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3f)(GLenum target, GLfloat s, GLfloat t, GLfloat r); +#define glMultiTexCoord3f _ptrc_glMultiTexCoord3f +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3fv)(GLenum target, const GLfloat * v); +#define glMultiTexCoord3fv _ptrc_glMultiTexCoord3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3i)(GLenum target, GLint s, GLint t, GLint r); +#define glMultiTexCoord3i _ptrc_glMultiTexCoord3i +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3iv)(GLenum target, const GLint * v); +#define glMultiTexCoord3iv _ptrc_glMultiTexCoord3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3s)(GLenum target, GLshort s, GLshort t, GLshort r); +#define glMultiTexCoord3s _ptrc_glMultiTexCoord3s +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord3sv)(GLenum target, const GLshort * v); +#define glMultiTexCoord3sv _ptrc_glMultiTexCoord3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4d)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +#define glMultiTexCoord4d _ptrc_glMultiTexCoord4d +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4dv)(GLenum target, const GLdouble * v); +#define glMultiTexCoord4dv _ptrc_glMultiTexCoord4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4f)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +#define glMultiTexCoord4f _ptrc_glMultiTexCoord4f +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4fv)(GLenum target, const GLfloat * v); +#define glMultiTexCoord4fv _ptrc_glMultiTexCoord4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4i)(GLenum target, GLint s, GLint t, GLint r, GLint q); +#define glMultiTexCoord4i _ptrc_glMultiTexCoord4i +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4iv)(GLenum target, const GLint * v); +#define glMultiTexCoord4iv _ptrc_glMultiTexCoord4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4s)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +#define glMultiTexCoord4s _ptrc_glMultiTexCoord4s +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiTexCoord4sv)(GLenum target, const GLshort * v); +#define glMultiTexCoord4sv _ptrc_glMultiTexCoord4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glSampleCoverage)(GLfloat value, GLboolean invert); +#define glSampleCoverage _ptrc_glSampleCoverage + +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendColor)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#define glBlendColor _ptrc_glBlendColor +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquation)(GLenum mode); +#define glBlendEquation _ptrc_glBlendEquation +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendFuncSeparate)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#define glBlendFuncSeparate _ptrc_glBlendFuncSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordPointer)(GLenum type, GLsizei stride, const void * pointer); +#define glFogCoordPointer _ptrc_glFogCoordPointer +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordd)(GLdouble coord); +#define glFogCoordd _ptrc_glFogCoordd +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoorddv)(const GLdouble * coord); +#define glFogCoorddv _ptrc_glFogCoorddv +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordf)(GLfloat coord); +#define glFogCoordf _ptrc_glFogCoordf +extern void (CODEGEN_FUNCPTR *_ptrc_glFogCoordfv)(const GLfloat * coord); +#define glFogCoordfv _ptrc_glFogCoordfv +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawArrays)(GLenum mode, const GLint * first, const GLsizei * count, GLsizei drawcount); +#define glMultiDrawArrays _ptrc_glMultiDrawArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElements)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount); +#define glMultiDrawElements _ptrc_glMultiDrawElements +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterf)(GLenum pname, GLfloat param); +#define glPointParameterf _ptrc_glPointParameterf +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameterfv)(GLenum pname, const GLfloat * params); +#define glPointParameterfv _ptrc_glPointParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteri)(GLenum pname, GLint param); +#define glPointParameteri _ptrc_glPointParameteri +extern void (CODEGEN_FUNCPTR *_ptrc_glPointParameteriv)(GLenum pname, const GLint * params); +#define glPointParameteriv _ptrc_glPointParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3b)(GLbyte red, GLbyte green, GLbyte blue); +#define glSecondaryColor3b _ptrc_glSecondaryColor3b +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3bv)(const GLbyte * v); +#define glSecondaryColor3bv _ptrc_glSecondaryColor3bv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3d)(GLdouble red, GLdouble green, GLdouble blue); +#define glSecondaryColor3d _ptrc_glSecondaryColor3d +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3dv)(const GLdouble * v); +#define glSecondaryColor3dv _ptrc_glSecondaryColor3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3f)(GLfloat red, GLfloat green, GLfloat blue); +#define glSecondaryColor3f _ptrc_glSecondaryColor3f +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3fv)(const GLfloat * v); +#define glSecondaryColor3fv _ptrc_glSecondaryColor3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3i)(GLint red, GLint green, GLint blue); +#define glSecondaryColor3i _ptrc_glSecondaryColor3i +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3iv)(const GLint * v); +#define glSecondaryColor3iv _ptrc_glSecondaryColor3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3s)(GLshort red, GLshort green, GLshort blue); +#define glSecondaryColor3s _ptrc_glSecondaryColor3s +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3sv)(const GLshort * v); +#define glSecondaryColor3sv _ptrc_glSecondaryColor3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ub)(GLubyte red, GLubyte green, GLubyte blue); +#define glSecondaryColor3ub _ptrc_glSecondaryColor3ub +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ubv)(const GLubyte * v); +#define glSecondaryColor3ubv _ptrc_glSecondaryColor3ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3ui)(GLuint red, GLuint green, GLuint blue); +#define glSecondaryColor3ui _ptrc_glSecondaryColor3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3uiv)(const GLuint * v); +#define glSecondaryColor3uiv _ptrc_glSecondaryColor3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3us)(GLushort red, GLushort green, GLushort blue); +#define glSecondaryColor3us _ptrc_glSecondaryColor3us +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColor3usv)(const GLushort * v); +#define glSecondaryColor3usv _ptrc_glSecondaryColor3usv +extern void (CODEGEN_FUNCPTR *_ptrc_glSecondaryColorPointer)(GLint size, GLenum type, GLsizei stride, const void * pointer); +#define glSecondaryColorPointer _ptrc_glSecondaryColorPointer +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2d)(GLdouble x, GLdouble y); +#define glWindowPos2d _ptrc_glWindowPos2d +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2dv)(const GLdouble * v); +#define glWindowPos2dv _ptrc_glWindowPos2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2f)(GLfloat x, GLfloat y); +#define glWindowPos2f _ptrc_glWindowPos2f +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2fv)(const GLfloat * v); +#define glWindowPos2fv _ptrc_glWindowPos2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2i)(GLint x, GLint y); +#define glWindowPos2i _ptrc_glWindowPos2i +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2iv)(const GLint * v); +#define glWindowPos2iv _ptrc_glWindowPos2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2s)(GLshort x, GLshort y); +#define glWindowPos2s _ptrc_glWindowPos2s +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos2sv)(const GLshort * v); +#define glWindowPos2sv _ptrc_glWindowPos2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3d)(GLdouble x, GLdouble y, GLdouble z); +#define glWindowPos3d _ptrc_glWindowPos3d +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3dv)(const GLdouble * v); +#define glWindowPos3dv _ptrc_glWindowPos3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3f)(GLfloat x, GLfloat y, GLfloat z); +#define glWindowPos3f _ptrc_glWindowPos3f +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3fv)(const GLfloat * v); +#define glWindowPos3fv _ptrc_glWindowPos3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3i)(GLint x, GLint y, GLint z); +#define glWindowPos3i _ptrc_glWindowPos3i +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3iv)(const GLint * v); +#define glWindowPos3iv _ptrc_glWindowPos3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3s)(GLshort x, GLshort y, GLshort z); +#define glWindowPos3s _ptrc_glWindowPos3s +extern void (CODEGEN_FUNCPTR *_ptrc_glWindowPos3sv)(const GLshort * v); +#define glWindowPos3sv _ptrc_glWindowPos3sv + +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginQuery)(GLenum target, GLuint id); +#define glBeginQuery _ptrc_glBeginQuery +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBuffer)(GLenum target, GLuint buffer); +#define glBindBuffer _ptrc_glBindBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferData)(GLenum target, GLsizeiptr size, const void * data, GLenum usage); +#define glBufferData _ptrc_glBufferData +extern void (CODEGEN_FUNCPTR *_ptrc_glBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const void * data); +#define glBufferSubData _ptrc_glBufferSubData +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteBuffers)(GLsizei n, const GLuint * buffers); +#define glDeleteBuffers _ptrc_glDeleteBuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteQueries)(GLsizei n, const GLuint * ids); +#define glDeleteQueries _ptrc_glDeleteQueries +extern void (CODEGEN_FUNCPTR *_ptrc_glEndQuery)(GLenum target); +#define glEndQuery _ptrc_glEndQuery +extern void (CODEGEN_FUNCPTR *_ptrc_glGenBuffers)(GLsizei n, GLuint * buffers); +#define glGenBuffers _ptrc_glGenBuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenQueries)(GLsizei n, GLuint * ids); +#define glGenQueries _ptrc_glGenQueries +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteriv)(GLenum target, GLenum pname, GLint * params); +#define glGetBufferParameteriv _ptrc_glGetBufferParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferPointerv)(GLenum target, GLenum pname, void ** params); +#define glGetBufferPointerv _ptrc_glGetBufferPointerv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, void * data); +#define glGetBufferSubData _ptrc_glGetBufferSubData +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectiv)(GLuint id, GLenum pname, GLint * params); +#define glGetQueryObjectiv _ptrc_glGetQueryObjectiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectuiv)(GLuint id, GLenum pname, GLuint * params); +#define glGetQueryObjectuiv _ptrc_glGetQueryObjectuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryiv)(GLenum target, GLenum pname, GLint * params); +#define glGetQueryiv _ptrc_glGetQueryiv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsBuffer)(GLuint buffer); +#define glIsBuffer _ptrc_glIsBuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsQuery)(GLuint id); +#define glIsQuery _ptrc_glIsQuery +extern void * (CODEGEN_FUNCPTR *_ptrc_glMapBuffer)(GLenum target, GLenum access); +#define glMapBuffer _ptrc_glMapBuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glUnmapBuffer)(GLenum target); +#define glUnmapBuffer _ptrc_glUnmapBuffer + +extern void (CODEGEN_FUNCPTR *_ptrc_glAttachShader)(GLuint program, GLuint shader); +#define glAttachShader _ptrc_glAttachShader +extern void (CODEGEN_FUNCPTR *_ptrc_glBindAttribLocation)(GLuint program, GLuint index, const GLchar * name); +#define glBindAttribLocation _ptrc_glBindAttribLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); +#define glBlendEquationSeparate _ptrc_glBlendEquationSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glCompileShader)(GLuint shader); +#define glCompileShader _ptrc_glCompileShader +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateProgram)(void); +#define glCreateProgram _ptrc_glCreateProgram +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glCreateShader)(GLenum type); +#define glCreateShader _ptrc_glCreateShader +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteProgram)(GLuint program); +#define glDeleteProgram _ptrc_glDeleteProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteShader)(GLuint shader); +#define glDeleteShader _ptrc_glDeleteShader +extern void (CODEGEN_FUNCPTR *_ptrc_glDetachShader)(GLuint program, GLuint shader); +#define glDetachShader _ptrc_glDetachShader +extern void (CODEGEN_FUNCPTR *_ptrc_glDisableVertexAttribArray)(GLuint index); +#define glDisableVertexAttribArray _ptrc_glDisableVertexAttribArray +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawBuffers)(GLsizei n, const GLenum * bufs); +#define glDrawBuffers _ptrc_glDrawBuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glEnableVertexAttribArray)(GLuint index); +#define glEnableVertexAttribArray _ptrc_glEnableVertexAttribArray +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); +#define glGetActiveAttrib _ptrc_glGetActiveAttrib +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, GLchar * name); +#define glGetActiveUniform _ptrc_glGetActiveUniform +extern void (CODEGEN_FUNCPTR *_ptrc_glGetAttachedShaders)(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders); +#define glGetAttachedShaders _ptrc_glGetAttachedShaders +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetAttribLocation)(GLuint program, const GLchar * name); +#define glGetAttribLocation _ptrc_glGetAttribLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramInfoLog)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog); +#define glGetProgramInfoLog _ptrc_glGetProgramInfoLog +extern void (CODEGEN_FUNCPTR *_ptrc_glGetProgramiv)(GLuint program, GLenum pname, GLint * params); +#define glGetProgramiv _ptrc_glGetProgramiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderInfoLog)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog); +#define glGetShaderInfoLog _ptrc_glGetShaderInfoLog +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderSource)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * source); +#define glGetShaderSource _ptrc_glGetShaderSource +extern void (CODEGEN_FUNCPTR *_ptrc_glGetShaderiv)(GLuint shader, GLenum pname, GLint * params); +#define glGetShaderiv _ptrc_glGetShaderiv +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetUniformLocation)(GLuint program, const GLchar * name); +#define glGetUniformLocation _ptrc_glGetUniformLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformfv)(GLuint program, GLint location, GLfloat * params); +#define glGetUniformfv _ptrc_glGetUniformfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformiv)(GLuint program, GLint location, GLint * params); +#define glGetUniformiv _ptrc_glGetUniformiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribPointerv)(GLuint index, GLenum pname, void ** pointer); +#define glGetVertexAttribPointerv _ptrc_glGetVertexAttribPointerv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribdv)(GLuint index, GLenum pname, GLdouble * params); +#define glGetVertexAttribdv _ptrc_glGetVertexAttribdv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat * params); +#define glGetVertexAttribfv _ptrc_glGetVertexAttribfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribiv)(GLuint index, GLenum pname, GLint * params); +#define glGetVertexAttribiv _ptrc_glGetVertexAttribiv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsProgram)(GLuint program); +#define glIsProgram _ptrc_glIsProgram +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsShader)(GLuint shader); +#define glIsShader _ptrc_glIsShader +extern void (CODEGEN_FUNCPTR *_ptrc_glLinkProgram)(GLuint program); +#define glLinkProgram _ptrc_glLinkProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glShaderSource)(GLuint shader, GLsizei count, const GLchar *const* string, const GLint * length); +#define glShaderSource _ptrc_glShaderSource +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask); +#define glStencilFuncSeparate _ptrc_glStencilFuncSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilMaskSeparate)(GLenum face, GLuint mask); +#define glStencilMaskSeparate _ptrc_glStencilMaskSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glStencilOpSeparate)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +#define glStencilOpSeparate _ptrc_glStencilOpSeparate +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1f)(GLint location, GLfloat v0); +#define glUniform1f _ptrc_glUniform1f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1fv)(GLint location, GLsizei count, const GLfloat * value); +#define glUniform1fv _ptrc_glUniform1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1i)(GLint location, GLint v0); +#define glUniform1i _ptrc_glUniform1i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1iv)(GLint location, GLsizei count, const GLint * value); +#define glUniform1iv _ptrc_glUniform1iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2f)(GLint location, GLfloat v0, GLfloat v1); +#define glUniform2f _ptrc_glUniform2f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2fv)(GLint location, GLsizei count, const GLfloat * value); +#define glUniform2fv _ptrc_glUniform2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2i)(GLint location, GLint v0, GLint v1); +#define glUniform2i _ptrc_glUniform2i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2iv)(GLint location, GLsizei count, const GLint * value); +#define glUniform2iv _ptrc_glUniform2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +#define glUniform3f _ptrc_glUniform3f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3fv)(GLint location, GLsizei count, const GLfloat * value); +#define glUniform3fv _ptrc_glUniform3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3i)(GLint location, GLint v0, GLint v1, GLint v2); +#define glUniform3i _ptrc_glUniform3i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3iv)(GLint location, GLsizei count, const GLint * value); +#define glUniform3iv _ptrc_glUniform3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4f)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +#define glUniform4f _ptrc_glUniform4f +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4fv)(GLint location, GLsizei count, const GLfloat * value); +#define glUniform4fv _ptrc_glUniform4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4i)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +#define glUniform4i _ptrc_glUniform4i +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4iv)(GLint location, GLsizei count, const GLint * value); +#define glUniform4iv _ptrc_glUniform4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define glUniformMatrix2fv _ptrc_glUniformMatrix2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define glUniformMatrix3fv _ptrc_glUniformMatrix3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define glUniformMatrix4fv _ptrc_glUniformMatrix4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUseProgram)(GLuint program); +#define glUseProgram _ptrc_glUseProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glValidateProgram)(GLuint program); +#define glValidateProgram _ptrc_glValidateProgram +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1d)(GLuint index, GLdouble x); +#define glVertexAttrib1d _ptrc_glVertexAttrib1d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1dv)(GLuint index, const GLdouble * v); +#define glVertexAttrib1dv _ptrc_glVertexAttrib1dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1f)(GLuint index, GLfloat x); +#define glVertexAttrib1f _ptrc_glVertexAttrib1f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1fv)(GLuint index, const GLfloat * v); +#define glVertexAttrib1fv _ptrc_glVertexAttrib1fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1s)(GLuint index, GLshort x); +#define glVertexAttrib1s _ptrc_glVertexAttrib1s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib1sv)(GLuint index, const GLshort * v); +#define glVertexAttrib1sv _ptrc_glVertexAttrib1sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2d)(GLuint index, GLdouble x, GLdouble y); +#define glVertexAttrib2d _ptrc_glVertexAttrib2d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2dv)(GLuint index, const GLdouble * v); +#define glVertexAttrib2dv _ptrc_glVertexAttrib2dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2f)(GLuint index, GLfloat x, GLfloat y); +#define glVertexAttrib2f _ptrc_glVertexAttrib2f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2fv)(GLuint index, const GLfloat * v); +#define glVertexAttrib2fv _ptrc_glVertexAttrib2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2s)(GLuint index, GLshort x, GLshort y); +#define glVertexAttrib2s _ptrc_glVertexAttrib2s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib2sv)(GLuint index, const GLshort * v); +#define glVertexAttrib2sv _ptrc_glVertexAttrib2sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3d)(GLuint index, GLdouble x, GLdouble y, GLdouble z); +#define glVertexAttrib3d _ptrc_glVertexAttrib3d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3dv)(GLuint index, const GLdouble * v); +#define glVertexAttrib3dv _ptrc_glVertexAttrib3dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3f)(GLuint index, GLfloat x, GLfloat y, GLfloat z); +#define glVertexAttrib3f _ptrc_glVertexAttrib3f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3fv)(GLuint index, const GLfloat * v); +#define glVertexAttrib3fv _ptrc_glVertexAttrib3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3s)(GLuint index, GLshort x, GLshort y, GLshort z); +#define glVertexAttrib3s _ptrc_glVertexAttrib3s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib3sv)(GLuint index, const GLshort * v); +#define glVertexAttrib3sv _ptrc_glVertexAttrib3sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nbv)(GLuint index, const GLbyte * v); +#define glVertexAttrib4Nbv _ptrc_glVertexAttrib4Nbv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Niv)(GLuint index, const GLint * v); +#define glVertexAttrib4Niv _ptrc_glVertexAttrib4Niv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nsv)(GLuint index, const GLshort * v); +#define glVertexAttrib4Nsv _ptrc_glVertexAttrib4Nsv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nub)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +#define glVertexAttrib4Nub _ptrc_glVertexAttrib4Nub +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nubv)(GLuint index, const GLubyte * v); +#define glVertexAttrib4Nubv _ptrc_glVertexAttrib4Nubv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nuiv)(GLuint index, const GLuint * v); +#define glVertexAttrib4Nuiv _ptrc_glVertexAttrib4Nuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4Nusv)(GLuint index, const GLushort * v); +#define glVertexAttrib4Nusv _ptrc_glVertexAttrib4Nusv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4bv)(GLuint index, const GLbyte * v); +#define glVertexAttrib4bv _ptrc_glVertexAttrib4bv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4d)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +#define glVertexAttrib4d _ptrc_glVertexAttrib4d +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4dv)(GLuint index, const GLdouble * v); +#define glVertexAttrib4dv _ptrc_glVertexAttrib4dv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4f)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +#define glVertexAttrib4f _ptrc_glVertexAttrib4f +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4fv)(GLuint index, const GLfloat * v); +#define glVertexAttrib4fv _ptrc_glVertexAttrib4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4iv)(GLuint index, const GLint * v); +#define glVertexAttrib4iv _ptrc_glVertexAttrib4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4s)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +#define glVertexAttrib4s _ptrc_glVertexAttrib4s +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4sv)(GLuint index, const GLshort * v); +#define glVertexAttrib4sv _ptrc_glVertexAttrib4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4ubv)(GLuint index, const GLubyte * v); +#define glVertexAttrib4ubv _ptrc_glVertexAttrib4ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4uiv)(GLuint index, const GLuint * v); +#define glVertexAttrib4uiv _ptrc_glVertexAttrib4uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttrib4usv)(GLuint index, const GLushort * v); +#define glVertexAttrib4usv _ptrc_glVertexAttrib4usv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribPointer)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void * pointer); +#define glVertexAttribPointer _ptrc_glVertexAttribPointer + +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define glUniformMatrix2x3fv _ptrc_glUniformMatrix2x3fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix2x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define glUniformMatrix2x4fv _ptrc_glUniformMatrix2x4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define glUniformMatrix3x2fv _ptrc_glUniformMatrix3x2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix3x4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define glUniformMatrix3x4fv _ptrc_glUniformMatrix3x4fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define glUniformMatrix4x2fv _ptrc_glUniformMatrix4x2fv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformMatrix4x3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +#define glUniformMatrix4x3fv _ptrc_glUniformMatrix4x3fv + +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginConditionalRender)(GLuint id, GLenum mode); +#define glBeginConditionalRender _ptrc_glBeginConditionalRender +extern void (CODEGEN_FUNCPTR *_ptrc_glBeginTransformFeedback)(GLenum primitiveMode); +#define glBeginTransformFeedback _ptrc_glBeginTransformFeedback +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferBase)(GLenum target, GLuint index, GLuint buffer); +#define glBindBufferBase _ptrc_glBindBufferBase +extern void (CODEGEN_FUNCPTR *_ptrc_glBindBufferRange)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +#define glBindBufferRange _ptrc_glBindBufferRange +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocation)(GLuint program, GLuint color, const GLchar * name); +#define glBindFragDataLocation _ptrc_glBindFragDataLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFramebuffer)(GLenum target, GLuint framebuffer); +#define glBindFramebuffer _ptrc_glBindFramebuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glBindRenderbuffer)(GLenum target, GLuint renderbuffer); +#define glBindRenderbuffer _ptrc_glBindRenderbuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glBindVertexArray)(GLuint ren_array); +#define glBindVertexArray _ptrc_glBindVertexArray +extern void (CODEGEN_FUNCPTR *_ptrc_glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#define glBlitFramebuffer _ptrc_glBlitFramebuffer +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glCheckFramebufferStatus)(GLenum target); +#define glCheckFramebufferStatus _ptrc_glCheckFramebufferStatus +extern void (CODEGEN_FUNCPTR *_ptrc_glClampColor)(GLenum target, GLenum clamp); +#define glClampColor _ptrc_glClampColor +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfi)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +#define glClearBufferfi _ptrc_glClearBufferfi +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferfv)(GLenum buffer, GLint drawbuffer, const GLfloat * value); +#define glClearBufferfv _ptrc_glClearBufferfv +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferiv)(GLenum buffer, GLint drawbuffer, const GLint * value); +#define glClearBufferiv _ptrc_glClearBufferiv +extern void (CODEGEN_FUNCPTR *_ptrc_glClearBufferuiv)(GLenum buffer, GLint drawbuffer, const GLuint * value); +#define glClearBufferuiv _ptrc_glClearBufferuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glColorMaski)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#define glColorMaski _ptrc_glColorMaski +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteFramebuffers)(GLsizei n, const GLuint * framebuffers); +#define glDeleteFramebuffers _ptrc_glDeleteFramebuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteRenderbuffers)(GLsizei n, const GLuint * renderbuffers); +#define glDeleteRenderbuffers _ptrc_glDeleteRenderbuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteVertexArrays)(GLsizei n, const GLuint * arrays); +#define glDeleteVertexArrays _ptrc_glDeleteVertexArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glDisablei)(GLenum target, GLuint index); +#define glDisablei _ptrc_glDisablei +extern void (CODEGEN_FUNCPTR *_ptrc_glEnablei)(GLenum target, GLuint index); +#define glEnablei _ptrc_glEnablei +extern void (CODEGEN_FUNCPTR *_ptrc_glEndConditionalRender)(void); +#define glEndConditionalRender _ptrc_glEndConditionalRender +extern void (CODEGEN_FUNCPTR *_ptrc_glEndTransformFeedback)(void); +#define glEndTransformFeedback _ptrc_glEndTransformFeedback +extern void (CODEGEN_FUNCPTR *_ptrc_glFlushMappedBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length); +#define glFlushMappedBufferRange _ptrc_glFlushMappedBufferRange +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +#define glFramebufferRenderbuffer _ptrc_glFramebufferRenderbuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture1D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +#define glFramebufferTexture1D _ptrc_glFramebufferTexture1D +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +#define glFramebufferTexture2D _ptrc_glFramebufferTexture2D +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture3D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#define glFramebufferTexture3D _ptrc_glFramebufferTexture3D +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTextureLayer)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#define glFramebufferTextureLayer _ptrc_glFramebufferTextureLayer +extern void (CODEGEN_FUNCPTR *_ptrc_glGenFramebuffers)(GLsizei n, GLuint * framebuffers); +#define glGenFramebuffers _ptrc_glGenFramebuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenRenderbuffers)(GLsizei n, GLuint * renderbuffers); +#define glGenRenderbuffers _ptrc_glGenRenderbuffers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenVertexArrays)(GLsizei n, GLuint * arrays); +#define glGenVertexArrays _ptrc_glGenVertexArrays +extern void (CODEGEN_FUNCPTR *_ptrc_glGenerateMipmap)(GLenum target); +#define glGenerateMipmap _ptrc_glGenerateMipmap +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBooleani_v)(GLenum target, GLuint index, GLboolean * data); +#define glGetBooleani_v _ptrc_glGetBooleani_v +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataLocation)(GLuint program, const GLchar * name); +#define glGetFragDataLocation _ptrc_glGetFragDataLocation +extern void (CODEGEN_FUNCPTR *_ptrc_glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint * params); +#define glGetFramebufferAttachmentParameteriv _ptrc_glGetFramebufferAttachmentParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetIntegeri_v)(GLenum target, GLuint index, GLint * data); +#define glGetIntegeri_v _ptrc_glGetIntegeri_v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint * params); +#define glGetRenderbufferParameteriv _ptrc_glGetRenderbufferParameteriv +extern const GLubyte * (CODEGEN_FUNCPTR *_ptrc_glGetStringi)(GLenum name, GLuint index); +#define glGetStringi _ptrc_glGetStringi +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIiv)(GLenum target, GLenum pname, GLint * params); +#define glGetTexParameterIiv _ptrc_glGetTexParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTexParameterIuiv)(GLenum target, GLenum pname, GLuint * params); +#define glGetTexParameterIuiv _ptrc_glGetTexParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetTransformFeedbackVarying)(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, GLchar * name); +#define glGetTransformFeedbackVarying _ptrc_glGetTransformFeedbackVarying +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformuiv)(GLuint program, GLint location, GLuint * params); +#define glGetUniformuiv _ptrc_glGetUniformuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIiv)(GLuint index, GLenum pname, GLint * params); +#define glGetVertexAttribIiv _ptrc_glGetVertexAttribIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetVertexAttribIuiv)(GLuint index, GLenum pname, GLuint * params); +#define glGetVertexAttribIuiv _ptrc_glGetVertexAttribIuiv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsEnabledi)(GLenum target, GLuint index); +#define glIsEnabledi _ptrc_glIsEnabledi +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsFramebuffer)(GLuint framebuffer); +#define glIsFramebuffer _ptrc_glIsFramebuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsRenderbuffer)(GLuint renderbuffer); +#define glIsRenderbuffer _ptrc_glIsRenderbuffer +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsVertexArray)(GLuint ren_array); +#define glIsVertexArray _ptrc_glIsVertexArray +extern void * (CODEGEN_FUNCPTR *_ptrc_glMapBufferRange)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +#define glMapBufferRange _ptrc_glMapBufferRange +extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +#define glRenderbufferStorage _ptrc_glRenderbufferStorage +extern void (CODEGEN_FUNCPTR *_ptrc_glRenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#define glRenderbufferStorageMultisample _ptrc_glRenderbufferStorageMultisample +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIiv)(GLenum target, GLenum pname, const GLint * params); +#define glTexParameterIiv _ptrc_glTexParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glTexParameterIuiv)(GLenum target, GLenum pname, const GLuint * params); +#define glTexParameterIuiv _ptrc_glTexParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glTransformFeedbackVaryings)(GLuint program, GLsizei count, const GLchar *const* varyings, GLenum bufferMode); +#define glTransformFeedbackVaryings _ptrc_glTransformFeedbackVaryings +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1ui)(GLint location, GLuint v0); +#define glUniform1ui _ptrc_glUniform1ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform1uiv)(GLint location, GLsizei count, const GLuint * value); +#define glUniform1uiv _ptrc_glUniform1uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2ui)(GLint location, GLuint v0, GLuint v1); +#define glUniform2ui _ptrc_glUniform2ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform2uiv)(GLint location, GLsizei count, const GLuint * value); +#define glUniform2uiv _ptrc_glUniform2uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3ui)(GLint location, GLuint v0, GLuint v1, GLuint v2); +#define glUniform3ui _ptrc_glUniform3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform3uiv)(GLint location, GLsizei count, const GLuint * value); +#define glUniform3uiv _ptrc_glUniform3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4ui)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +#define glUniform4ui _ptrc_glUniform4ui +extern void (CODEGEN_FUNCPTR *_ptrc_glUniform4uiv)(GLint location, GLsizei count, const GLuint * value); +#define glUniform4uiv _ptrc_glUniform4uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1i)(GLuint index, GLint x); +#define glVertexAttribI1i _ptrc_glVertexAttribI1i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1iv)(GLuint index, const GLint * v); +#define glVertexAttribI1iv _ptrc_glVertexAttribI1iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1ui)(GLuint index, GLuint x); +#define glVertexAttribI1ui _ptrc_glVertexAttribI1ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI1uiv)(GLuint index, const GLuint * v); +#define glVertexAttribI1uiv _ptrc_glVertexAttribI1uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2i)(GLuint index, GLint x, GLint y); +#define glVertexAttribI2i _ptrc_glVertexAttribI2i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2iv)(GLuint index, const GLint * v); +#define glVertexAttribI2iv _ptrc_glVertexAttribI2iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2ui)(GLuint index, GLuint x, GLuint y); +#define glVertexAttribI2ui _ptrc_glVertexAttribI2ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI2uiv)(GLuint index, const GLuint * v); +#define glVertexAttribI2uiv _ptrc_glVertexAttribI2uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3i)(GLuint index, GLint x, GLint y, GLint z); +#define glVertexAttribI3i _ptrc_glVertexAttribI3i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3iv)(GLuint index, const GLint * v); +#define glVertexAttribI3iv _ptrc_glVertexAttribI3iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3ui)(GLuint index, GLuint x, GLuint y, GLuint z); +#define glVertexAttribI3ui _ptrc_glVertexAttribI3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI3uiv)(GLuint index, const GLuint * v); +#define glVertexAttribI3uiv _ptrc_glVertexAttribI3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4bv)(GLuint index, const GLbyte * v); +#define glVertexAttribI4bv _ptrc_glVertexAttribI4bv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4i)(GLuint index, GLint x, GLint y, GLint z, GLint w); +#define glVertexAttribI4i _ptrc_glVertexAttribI4i +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4iv)(GLuint index, const GLint * v); +#define glVertexAttribI4iv _ptrc_glVertexAttribI4iv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4sv)(GLuint index, const GLshort * v); +#define glVertexAttribI4sv _ptrc_glVertexAttribI4sv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ubv)(GLuint index, const GLubyte * v); +#define glVertexAttribI4ubv _ptrc_glVertexAttribI4ubv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4ui)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +#define glVertexAttribI4ui _ptrc_glVertexAttribI4ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4uiv)(GLuint index, const GLuint * v); +#define glVertexAttribI4uiv _ptrc_glVertexAttribI4uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribI4usv)(GLuint index, const GLushort * v); +#define glVertexAttribI4usv _ptrc_glVertexAttribI4usv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribIPointer)(GLuint index, GLint size, GLenum type, GLsizei stride, const void * pointer); +#define glVertexAttribIPointer _ptrc_glVertexAttribIPointer + +extern void (CODEGEN_FUNCPTR *_ptrc_glCopyBufferSubData)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#define glCopyBufferSubData _ptrc_glCopyBufferSubData +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawArraysInstanced)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +#define glDrawArraysInstanced _ptrc_glDrawArraysInstanced +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstanced)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount); +#define glDrawElementsInstanced _ptrc_glDrawElementsInstanced +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockName)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformBlockName); +#define glGetActiveUniformBlockName _ptrc_glGetActiveUniformBlockName +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformBlockiv)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint * params); +#define glGetActiveUniformBlockiv _ptrc_glGetActiveUniformBlockiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformName)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, GLchar * uniformName); +#define glGetActiveUniformName _ptrc_glGetActiveUniformName +extern void (CODEGEN_FUNCPTR *_ptrc_glGetActiveUniformsiv)(GLuint program, GLsizei uniformCount, const GLuint * uniformIndices, GLenum pname, GLint * params); +#define glGetActiveUniformsiv _ptrc_glGetActiveUniformsiv +extern GLuint (CODEGEN_FUNCPTR *_ptrc_glGetUniformBlockIndex)(GLuint program, const GLchar * uniformBlockName); +#define glGetUniformBlockIndex _ptrc_glGetUniformBlockIndex +extern void (CODEGEN_FUNCPTR *_ptrc_glGetUniformIndices)(GLuint program, GLsizei uniformCount, const GLchar *const* uniformNames, GLuint * uniformIndices); +#define glGetUniformIndices _ptrc_glGetUniformIndices +extern void (CODEGEN_FUNCPTR *_ptrc_glPrimitiveRestartIndex)(GLuint index); +#define glPrimitiveRestartIndex _ptrc_glPrimitiveRestartIndex +extern void (CODEGEN_FUNCPTR *_ptrc_glTexBuffer)(GLenum target, GLenum internalformat, GLuint buffer); +#define glTexBuffer _ptrc_glTexBuffer +extern void (CODEGEN_FUNCPTR *_ptrc_glUniformBlockBinding)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#define glUniformBlockBinding _ptrc_glUniformBlockBinding + +extern GLenum (CODEGEN_FUNCPTR *_ptrc_glClientWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout); +#define glClientWaitSync _ptrc_glClientWaitSync +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSync)(GLsync sync); +#define glDeleteSync _ptrc_glDeleteSync +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex); +#define glDrawElementsBaseVertex _ptrc_glDrawElementsBaseVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawElementsInstancedBaseVertex)(GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei instancecount, GLint basevertex); +#define glDrawElementsInstancedBaseVertex _ptrc_glDrawElementsInstancedBaseVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glDrawRangeElementsBaseVertex)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void * indices, GLint basevertex); +#define glDrawRangeElementsBaseVertex _ptrc_glDrawRangeElementsBaseVertex +extern GLsync (CODEGEN_FUNCPTR *_ptrc_glFenceSync)(GLenum condition, GLbitfield flags); +#define glFenceSync _ptrc_glFenceSync +extern void (CODEGEN_FUNCPTR *_ptrc_glFramebufferTexture)(GLenum target, GLenum attachment, GLuint texture, GLint level); +#define glFramebufferTexture _ptrc_glFramebufferTexture +extern void (CODEGEN_FUNCPTR *_ptrc_glGetBufferParameteri64v)(GLenum target, GLenum pname, GLint64 * params); +#define glGetBufferParameteri64v _ptrc_glGetBufferParameteri64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64i_v)(GLenum target, GLuint index, GLint64 * data); +#define glGetInteger64i_v _ptrc_glGetInteger64i_v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetInteger64v)(GLenum pname, GLint64 * data); +#define glGetInteger64v _ptrc_glGetInteger64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetMultisamplefv)(GLenum pname, GLuint index, GLfloat * val); +#define glGetMultisamplefv _ptrc_glGetMultisamplefv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSynciv)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei * length, GLint * values); +#define glGetSynciv _ptrc_glGetSynciv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSync)(GLsync sync); +#define glIsSync _ptrc_glIsSync +extern void (CODEGEN_FUNCPTR *_ptrc_glMultiDrawElementsBaseVertex)(GLenum mode, const GLsizei * count, GLenum type, const void *const* indices, GLsizei drawcount, const GLint * basevertex); +#define glMultiDrawElementsBaseVertex _ptrc_glMultiDrawElementsBaseVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glProvokingVertex)(GLenum mode); +#define glProvokingVertex _ptrc_glProvokingVertex +extern void (CODEGEN_FUNCPTR *_ptrc_glSampleMaski)(GLuint maskNumber, GLbitfield mask); +#define glSampleMaski _ptrc_glSampleMaski +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage2DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +#define glTexImage2DMultisample _ptrc_glTexImage2DMultisample +extern void (CODEGEN_FUNCPTR *_ptrc_glTexImage3DMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#define glTexImage3DMultisample _ptrc_glTexImage3DMultisample +extern void (CODEGEN_FUNCPTR *_ptrc_glWaitSync)(GLsync sync, GLbitfield flags, GLuint64 timeout); +#define glWaitSync _ptrc_glWaitSync + +extern void (CODEGEN_FUNCPTR *_ptrc_glBindFragDataLocationIndexed)(GLuint program, GLuint colorNumber, GLuint index, const GLchar * name); +#define glBindFragDataLocationIndexed _ptrc_glBindFragDataLocationIndexed +extern void (CODEGEN_FUNCPTR *_ptrc_glBindSampler)(GLuint unit, GLuint sampler); +#define glBindSampler _ptrc_glBindSampler +extern void (CODEGEN_FUNCPTR *_ptrc_glDeleteSamplers)(GLsizei count, const GLuint * samplers); +#define glDeleteSamplers _ptrc_glDeleteSamplers +extern void (CODEGEN_FUNCPTR *_ptrc_glGenSamplers)(GLsizei count, GLuint * samplers); +#define glGenSamplers _ptrc_glGenSamplers +extern GLint (CODEGEN_FUNCPTR *_ptrc_glGetFragDataIndex)(GLuint program, const GLchar * name); +#define glGetFragDataIndex _ptrc_glGetFragDataIndex +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjecti64v)(GLuint id, GLenum pname, GLint64 * params); +#define glGetQueryObjecti64v _ptrc_glGetQueryObjecti64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetQueryObjectui64v)(GLuint id, GLenum pname, GLuint64 * params); +#define glGetQueryObjectui64v _ptrc_glGetQueryObjectui64v +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIiv)(GLuint sampler, GLenum pname, GLint * params); +#define glGetSamplerParameterIiv _ptrc_glGetSamplerParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterIuiv)(GLuint sampler, GLenum pname, GLuint * params); +#define glGetSamplerParameterIuiv _ptrc_glGetSamplerParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameterfv)(GLuint sampler, GLenum pname, GLfloat * params); +#define glGetSamplerParameterfv _ptrc_glGetSamplerParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glGetSamplerParameteriv)(GLuint sampler, GLenum pname, GLint * params); +#define glGetSamplerParameteriv _ptrc_glGetSamplerParameteriv +extern GLboolean (CODEGEN_FUNCPTR *_ptrc_glIsSampler)(GLuint sampler); +#define glIsSampler _ptrc_glIsSampler +extern void (CODEGEN_FUNCPTR *_ptrc_glQueryCounter)(GLuint id, GLenum target); +#define glQueryCounter _ptrc_glQueryCounter +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIiv)(GLuint sampler, GLenum pname, const GLint * param); +#define glSamplerParameterIiv _ptrc_glSamplerParameterIiv +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterIuiv)(GLuint sampler, GLenum pname, const GLuint * param); +#define glSamplerParameterIuiv _ptrc_glSamplerParameterIuiv +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterf)(GLuint sampler, GLenum pname, GLfloat param); +#define glSamplerParameterf _ptrc_glSamplerParameterf +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameterfv)(GLuint sampler, GLenum pname, const GLfloat * param); +#define glSamplerParameterfv _ptrc_glSamplerParameterfv +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteri)(GLuint sampler, GLenum pname, GLint param); +#define glSamplerParameteri _ptrc_glSamplerParameteri +extern void (CODEGEN_FUNCPTR *_ptrc_glSamplerParameteriv)(GLuint sampler, GLenum pname, const GLint * param); +#define glSamplerParameteriv _ptrc_glSamplerParameteriv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribDivisor)(GLuint index, GLuint divisor); +#define glVertexAttribDivisor _ptrc_glVertexAttribDivisor +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +#define glVertexAttribP1ui _ptrc_glVertexAttribP1ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP1uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); +#define glVertexAttribP1uiv _ptrc_glVertexAttribP1uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +#define glVertexAttribP2ui _ptrc_glVertexAttribP2ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP2uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); +#define glVertexAttribP2uiv _ptrc_glVertexAttribP2uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +#define glVertexAttribP3ui _ptrc_glVertexAttribP3ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP3uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); +#define glVertexAttribP3uiv _ptrc_glVertexAttribP3uiv +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4ui)(GLuint index, GLenum type, GLboolean normalized, GLuint value); +#define glVertexAttribP4ui _ptrc_glVertexAttribP4ui +extern void (CODEGEN_FUNCPTR *_ptrc_glVertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized, const GLuint * value); +#define glVertexAttribP4uiv _ptrc_glVertexAttribP4uiv + +enum ogl_LoadStatus +{ + ogl_LOAD_FAILED = 0, + ogl_LOAD_SUCCEEDED = 1, +}; + +int ogl_LoadFunctions(); + +int ogl_GetMinorVersion(void); +int ogl_GetMajorVersion(void); +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..e5abe2ec5 --- /dev/null +++ b/src/gl/system/gl_system.h @@ -0,0 +1,117 @@ +#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 _access(a,b) access(a,b) +#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..05d63f65d --- /dev/null +++ b/src/gl/system/gl_wipe.cpp @@ -0,0 +1,577 @@ +/* +** 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/renderer/gl_renderbuffers.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_cvars.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" +#include "gl/renderer/gl_2ddrawer.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(); + int MakeVBO(int ticks, OpenGLFrameBuffer *fb, bool &done); + 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; + } + + const auto &viewport = GLRenderer->mScreenViewport; + wipestartscreen = new FHardwareTexture(viewport.width, viewport.height, true); + wipestartscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen"); + GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); + GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE, -1); + glFinish(); + wipestartscreen->Bind(0, false, false); + + if (FGLRenderBuffers::IsEnabled()) + { + GLRenderer->mBuffers->BindCurrentFB(); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height); + } + else + { + GLint readbuffer = 0; + glGetIntegerv(GL_READ_BUFFER, &readbuffer); + glReadBuffer(GL_FRONT); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height); + glReadBuffer(readbuffer); + } + + 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() +{ + GLRenderer->m2DDrawer->Flush(); + + const auto &viewport = GLRenderer->mScreenViewport; + wipeendscreen = new FHardwareTexture(viewport.width, viewport.height, true); + wipeendscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen"); + GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); + glFinish(); + wipeendscreen->Bind(0, false, false); + + if (FGLRenderBuffers::IsEnabled()) + GLRenderer->mBuffers->BindCurrentFB(); + + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.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) +{ + bool done = true; + // Sanity checks. + if (wipestartscreen != nullptr && wipeendscreen != nullptr) + { + Lock(true); + + gl_RenderState.EnableTexture(true); + gl_RenderState.EnableFog(false); + glDisable(GL_DEPTH_TEST); + glDepthMask(false); + + if (FGLRenderBuffers::IsEnabled()) + { + GLRenderer->mBuffers->BindCurrentFB(); + const auto &bounds = GLRenderer->mScreenViewport; + glViewport(bounds.left, bounds.top, bounds.width, bounds.height); + } + + done = ScreenWipe->Run(ticks, this); + glDepthMask(true); + } + gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); + 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() +{ + mVertexBuf = new FSimpleVertexBuffer; +} + +OpenGLFrameBuffer::Wiper::~Wiper() +{ + delete mVertexBuf; +} + +void OpenGLFrameBuffer::Wiper::MakeVBO(OpenGLFrameBuffer *fb) +{ + FSimpleVertex make[4]; + FSimpleVertex *ptr = make; + + float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); + float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); + + 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); + mVertexBuf->set(make, 4); +} + +// 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; + + MakeVBO(fb); + + gl_RenderState.SetTextureMode(TM_OPAQUE); + gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f); + gl_RenderState.ResetColor(); + gl_RenderState.Apply(); + fb->wipestartscreen->Bind(0, 0, false); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + float a = clamp(Clock / 32.f, 0.f, 1.f); + gl_RenderState.SetColorAlpha(0xffffff, a); + gl_RenderState.Apply(); + fb->wipeendscreen->Bind(0, 0, false); + mVertexBuf->EnableColorArray(false); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + 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. +// +//========================================================================== + +int OpenGLFrameBuffer::Wiper_Melt::MakeVBO(int ticks, OpenGLFrameBuffer *fb, bool &done) +{ + FSimpleVertex *make = new FSimpleVertex[321*4]; + FSimpleVertex *ptr = make; + int dy; + + float ur = fb->GetWidth() / FHardwareTexture::GetTexDimension(fb->GetWidth()); + float vb = fb->GetHeight() / FHardwareTexture::GetTexDimension(fb->GetHeight()); + + 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++; + + // Copy the old screen in vertical strips on top of the new one. + while (ticks--) + { + done = true; + for (int 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->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++; + } + } + } + } + int numverts = int(ptr - make); + mVertexBuf->set(make, numverts); + delete[] make; + return numverts; +} + +bool OpenGLFrameBuffer::Wiper_Melt::Run(int ticks, OpenGLFrameBuffer *fb) +{ + bool done = false; + int maxvert = MakeVBO(ticks, fb, done); + + // Draw the new screen on the bottom. + gl_RenderState.SetTextureMode(TM_OPAQUE); + gl_RenderState.ResetColor(); + gl_RenderState.Apply(); + fb->wipeendscreen->Bind(0, 0, false); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + fb->wipestartscreen->Bind(0, 0, false); + gl_RenderState.SetTextureMode(TM_MODULATE); + for (int i = 4; i < maxvert; i += 4) + { + glDrawArrays(GL_TRIANGLE_STRIP, i, 4); + } + 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; + + MakeVBO(fb); + + 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); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + 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, "BurnTexture"); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + 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..0db901380 --- /dev/null +++ b/src/gl/textures/gl_bitmap.cpp @@ -0,0 +1,161 @@ +/* +** 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/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, BYTE tr, BYTE tg, BYTE tb) +{ + int i; + unsigned char a; + + for(i=0;i, + iCopyColors, + 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, int r, int g, int b) +{ + 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 && !alphatrans) + { + for (i = 0; i < 256; i++) + { + penew[i] = (ptrans[i] & 0xffffff) | (palette[i] & 0xff000000); + } + } + else if (ptrans) + { + memcpy(penew, ptrans, 256 * sizeof(PalEntry)); + } + } + 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..fe523c79d --- /dev/null +++ b/src/gl/textures/gl_hqresize.cpp @@ -0,0 +1,380 @@ +/* +** 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 +#include "gl/xbr/xbrz.h" +#include "gl/xbr/xbrz_old.h" + +CUSTOM_CVAR(Int, gl_texture_hqresize, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + if (self < 0 || self > 16) + { + self = 0; + } + #ifndef HAVE_MMX + // This is to allow the menu option to work properly so that these filters can be skipped while cycling through them. + if (self == 7) self = 10; + if (self == 8) self = 10; + if (self == 9) self = 6; + #endif + 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; +} + + + +static unsigned char *xbrzHelper( void (*xbrzFunction) ( size_t, const uint32_t*, uint32_t*, int, int, xbrz::ColorFormat, const xbrz::ScalerCfg&, 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]; + xbrzFunction(N, reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), inWidth, inHeight, xbrz::ARGB, xbrz::ScalerCfg(), 0, std::numeric_limits::max()); + delete[] inputBuffer; + return newBuffer; +} + +static unsigned char *xbrzoldHelper( void (*xbrzFunction) ( size_t factor, const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz_old::ScalerCfg& cfg, int yFirst, int yLast ), + 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]; + xbrzFunction(N, reinterpret_cast(inputBuffer), reinterpret_cast(newBuffer), inWidth, inHeight, xbrz_old::ScalerCfg(), 0, std::numeric_limits::max()); + 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; + + // [BB] Don't upsample non-shader handled warped textures. Needs too much memory and time + if (gl.legacyMode && inputTexture->bWarped) + return inputBuffer; + + // already scaled? + if (inputTexture->Scale.X >= 2 && inputTexture->Scale.Y >= 2) + 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) + { + int type = gl_texture_hqresize; + outWidth = inWidth; + outHeight = inHeight; +#ifdef HAVE_MMX + // hqNx MMX does not preserve the alpha channel so fall back to C-version for such textures + if (hasAlpha && type > 6 && type <= 9) + { + 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 + case 10: + case 11: + case 12: + return xbrzHelper(xbrz::scale, type - 8, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + + case 13: + case 14: + case 15: + return xbrzoldHelper(xbrz_old::scale, type - 11, inputBuffer, inWidth, inHeight, outWidth, outHeight ); + + } + } + return inputBuffer; +} diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp new file mode 100644 index 000000000..25dc989e7 --- /dev/null +++ b/src/gl/textures/gl_hwtexture.cpp @@ -0,0 +1,443 @@ +/* +** 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/system/gl_debug.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]; + +//=========================================================================== +// +// 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, const FString &name) +{ + 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); + FGLDebug::LabelObject(GL_TEXTURE, glTex->glTexID, name); + 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;i= 0; i--) + { + if (usedtranslations.CheckKey(glTex_Translated[i].translation) == nullptr) + { + glTex_Translated[i].Delete(); + glTex_Translated.Delete(i); + } + } +} + +//=========================================================================== +// +// Destroys the texture +// +//=========================================================================== +FHardwareTexture::~FHardwareTexture() +{ + Clean(true); +} + + +//=========================================================================== +// +// Gets a texture ID address and validates all required data +// +//=========================================================================== + +FHardwareTexture::TranslatedTexture *FHardwareTexture::GetTexID(int translation) +{ + if (translation == 0) + { + return &glDefTex; + } + + // normally there aren't more than very few different + // translations here so this isn't performance critical. + for (unsigned int i = 0; i < glTex_Translated.Size(); i++) + { + if (glTex_Translated[i].translation == translation) + { + return &glTex_Translated[i]; + } + } + + int add = glTex_Translated.Reserve(1); + glTex_Translated[add].translation = translation; + glTex_Translated[add].glTexID = 0; + glTex_Translated[add].mipmapped = false; + return &glTex_Translated[add]; +} + +//=========================================================================== +// +// Binds this patch +// +//=========================================================================== +unsigned int FHardwareTexture::Bind(int texunit, int translation, bool needmipmap) +{ + TranslatedTexture *pTex = GetTexID(translation); + + if (pTex->glTexID != 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_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_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..96eff0264 --- /dev/null +++ b/src/gl/textures/gl_hwtexture.h @@ -0,0 +1,91 @@ + +#ifndef __GLTEXTURE_H +#define __GLTEXTURE_H + +#ifdef LoadImage +#undef LoadImage +#endif + +#define SHADED_TEXTURE -1 +#define DIRECT_PALETTE -2 + +#include "tarray.h" +#include "gl/system/gl_interface.h" + +class FCanvasTexture; +class AActor; +typedef TMap SpriteHits; + +// 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 GetTexDimension(int value) + { + if (value > gl.max_texturesize) return gl.max_texturesize; + return value; + } + + static void InitGlobalState() { for (int i = 0; i < MAX_TEXTURES; i++) lastbound[i] = 0; } + +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, const FString &name); + + void Clean(bool all); + void CleanUnused(SpriteHits &usedtranslations); +}; + +#endif diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp new file mode 100644 index 000000000..bc9dc2f52 --- /dev/null +++ b/src/gl/textures/gl_material.cpp @@ -0,0 +1,902 @@ +/* +** 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 "textures/warpbuffer.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; + lastSampler = 254; + lastTranslation = -1; + 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 != nullptr) + { + if (!all) mHwTexture->Clean(false); + else + { + delete mHwTexture; + mHwTexture = nullptr; + } + + lastSampler = 253; + lastTranslation = -1; + } +} + + +void FGLTexture::CleanUnused(SpriteHits &usedtranslations) +{ + if (mHwTexture != nullptr) + { + mHwTexture->CleanUnused(usedtranslations); + lastSampler = 253; + lastTranslation = -1; + } +} + + +//=========================================================================== +// +// Initializes the buffer for the texture data +// +//=========================================================================== + +unsigned char * FGLTexture::CreateTexBuffer(int translation, int & w, int & h, FTexture *hirescheck, bool createexpanded, bool alphatrans) +{ + 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 && !alphatrans) + { + 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, alphatrans); + + 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; + bool alphatrans = false; + + if (translation <= 0) translation = -translation; + else + { + alphatrans = (gl.legacyMode && translation == TRANSLATION(TRANSLATION_Standard, 8)); + translation = GLTranslationPalette::GetInternalTranslation(translation); + } + + bool needmipmap = (clampmode <= CLAMP_XY); + + FHardwareTexture *hwtex = CreateHwTexture(); + + if (hwtex) + { + // Texture has become invalid + if ((!tex->bHasCanvas && (!tex->bWarped || gl.legacyMode)) && 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, true, alphatrans); + if (tex->bWarped && gl.legacyMode && w*h <= 256*256) // do not software-warp larger textures, especially on the old systems that still need this fallback. + { + // need to do software warping + FWarpTexture *wt = static_cast(tex); + unsigned char *warpbuffer = new unsigned char[w*h*4]; + WarpBuffer((DWORD*)warpbuffer, (const DWORD*)buffer, w, h, wt->WidthOffsetMultiplier, wt->HeightOffsetMultiplier, r_FrameTime, wt->Speed, tex->bWarped); + delete[] buffer; + buffer = warpbuffer; + wt->GenTime = r_FrameTime; + } + tex->ProcessData(buffer, w, h, false); + } + if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation, "FGLTexture.Bind")) + { + // could not create texture + delete[] buffer; + return NULL; + } + delete[] buffer; + } + if (tex->bHasCanvas) static_cast(tex)->NeedUpdate(); + if (translation != lastTranslation) lastSampler = 254; + if (lastSampler != clampmode) + lastSampler = GLRenderer->mSamplerManager->Bind(texunit, clampmode, lastSampler); + lastTranslation = translation; + return hwtex; + } + return NULL; +} + +//=========================================================================== +// +// +// +//=========================================================================== + +float FTexCoordInfo::RowOffset(float rowoffset) const +{ + if (mTempScale.Y == 1.f) + { + if (mScale.Y == 1.f || mWorldPanning) return rowoffset; + else return rowoffset / mScale.Y; + } + else + { + if (mWorldPanning) return rowoffset / mTempScale.Y; + else return rowoffset / mScale.Y; + } +} + +//=========================================================================== +// +// +// +//=========================================================================== + +float FTexCoordInfo::TextureOffset(float textureoffset) const +{ + if (mTempScale.X == 1.f) + { + if (mScale.X == 1.f || mWorldPanning) return textureoffset; + else return textureoffset / mScale.X; + } + else + { + if (mWorldPanning) return textureoffset / mTempScale.X; + else return textureoffset / mScale.X; + } +} + +//=========================================================================== +// +// Returns the size for which texture offset coordinates are used. +// +//=========================================================================== + +float FTexCoordInfo::TextureAdjustWidth() const +{ + if (mWorldPanning) + { + if (mTempScale.X == 1.f) return mRenderWidth; + else return mWidth / mTempScale.X; + } + 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->bWarped && gl.legacyMode)? tx : tx->GetRedirect(false); + // allow the redirect only if the textute is not expanded or the scale matches. + if (!expanded || (tx->Scale.X == basetex->Scale.X && tx->Scale.Y == basetex->Scale.Y)) + { + mBaseLayer = ValidateSysTexture(basetex, expanded); + } + + float fxScale = tx->Scale.X; + float fyScale = tx->Scale.Y; + + // 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::InitGlobalState() +{ + last = nullptr; + lastclamp = 0; + lasttrans = 0; +} + +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->Scale.X == 1 && tex->Scale.Y == 1 && 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); +} + +//=========================================================================== +// +// +// +//=========================================================================== +void FMaterial::PrecacheList(SpriteHits &translations) +{ + if (mBaseLayer != nullptr) mBaseLayer->CleanUnused(translations); + SpriteHits::Iterator it(translations); + SpriteHits::Pair *pair; + while(it.NextPair(pair)) Bind(0, pair->Key); +} + +//=========================================================================== +// +// Retrieve texture coordinate info for per-wall scaling +// +//=========================================================================== + +void FMaterial::GetTexCoordInfo(FTexCoordInfo *tci, float x, float y) const +{ + if (x == 1.f) + { + tci->mRenderWidth = mRenderWidth; + tci->mScale.X = tex->Scale.X; + tci->mTempScale.X = 1.f; + } + else + { + float scale_x = x * tex->Scale.X; + tci->mRenderWidth = xs_CeilToInt(mWidth / scale_x); + tci->mScale.X = scale_x; + tci->mTempScale.X = x; + } + + if (y == 1.f) + { + tci->mRenderHeight = mRenderHeight; + tci->mScale.Y = tex->Scale.Y; + tci->mTempScale.Y = 1.f; + } + else + { + float scale_y = y * tex->Scale.Y; + tci->mRenderHeight = xs_CeilToInt(mHeight / scale_y); + tci->mScale.Y = scale_y; + tci->mTempScale.Y = y; + } + if (tex->bHasCanvas) + { + tci->mScale.Y = -tci->mScale.Y; + 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..ee42a66d0 --- /dev/null +++ b/src/gl/textures/gl_material.h @@ -0,0 +1,271 @@ + +#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" +#include "r_defs.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; + FVector2 mScale; + FVector2 mTempScale; + bool mWorldPanning; + + float FloatToTexU(float v) const { return v / mRenderWidth; } + float FloatToTexV(float v) const { return v / mRenderHeight; } + float RowOffset(float ofs) const; + float TextureOffset(float ofs) const; + float 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; + BYTE lastSampler; + int lastTranslation; + + 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, bool alphatrans = false); + + void Clean(bool all); + void CleanUnused(SpriteHits &usedtranslations); + 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(); + void PrecacheList(SpriteHits &translations); + 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, float x, float y) const; + + void GetTexCoordInfo(FTexCoordInfo *tci, side_t *side, int texpos) const + { + GetTexCoordInfo(tci, (float)side->GetTextureXScale(texpos), (float)side->GetTextureYScale(texpos)); + } + + // 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 int(mLeftOffset / tex->Scale.X); + } + + int GetScaledTopOffset() const + { + return int(mTopOffset / tex->Scale.Y); + } + + float GetScaledLeftOffsetFloat() const + { + return float(mLeftOffset / tex->Scale.X); + } + + float GetScaledTopOffsetFloat() const + { + return float(mTopOffset/ tex->Scale.Y); + } + + // This is scaled size in floating point as needed by sprites + float GetScaledWidthFloat() const + { + return float(mWidth / tex->Scale.X); + } + + float GetScaledHeightFloat() const + { + return float(mHeight / tex->Scale.Y); + } + + // 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(); + + static void InitGlobalState(); +}; + +#endif + + diff --git a/src/gl/textures/gl_samplers.cpp b/src/gl/textures/gl_samplers.cpp new file mode 100644 index 000000000..64674e63c --- /dev/null +++ b/src/gl/textures/gl_samplers.cpp @@ -0,0 +1,212 @@ +/* +** 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/system/gl_debug.h" +#include "gl/renderer/gl_renderer.h" +#include "gl_samplers.h" +#include "gl_material.h" + +extern TexFilter_s TexFilter[]; + + +FSamplerManager::FSamplerManager() +{ + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + 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); + + for (int i = 0; i < 7; i++) + { + FString name; + name.Format("mSamplers[%d]", i); + FGLDebug::LabelObject(GL_SAMPLER, mSamplers[i], name); + } + } + +} + +FSamplerManager::~FSamplerManager() +{ + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + UnbindAll(); + glDeleteSamplers(7, mSamplers); + } +} + +void FSamplerManager::UnbindAll() +{ + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + for (int i = 0; i < FHardwareTexture::MAX_TEXTURES; i++) + { + glBindSampler(i, 0); + } + } +} + +BYTE FSamplerManager::Bind(int texunit, int num, int lastval) +{ + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + unsigned int samp = mSamplers[num]; + glBindSampler(texunit, samp); + return 255; + } + else + { + glActiveTexture(GL_TEXTURE0 + texunit); + switch (num) + { + case CLAMP_NONE: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + if (lastval >= CLAMP_XY_NOMIP) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + break; + + case CLAMP_X: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + if (lastval >= CLAMP_XY_NOMIP) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + break; + + case CLAMP_Y: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (lastval >= CLAMP_XY_NOMIP) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + break; + + case CLAMP_XY: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (lastval >= CLAMP_XY_NOMIP) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].minfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_texture_filter_anisotropic); + } + break; + + case CLAMP_XY_NOMIP: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1); + break; + + case CLAMP_NOFILTER: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1); + break; + + case CLAMP_CAMTEX: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, TexFilter[gl_texture_filter].magfilter); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1); + break; + } + glActiveTexture(GL_TEXTURE0); + return num; + } +} + + +void FSamplerManager::SetTextureFilterMode() +{ + if (gl.flags & RFL_SAMPLER_OBJECTS) + { + 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); + } + else + { + GLRenderer->FlushTextures(); + } +} + + diff --git a/src/gl/textures/gl_samplers.h b/src/gl/textures/gl_samplers.h new file mode 100644 index 000000000..b74d49a33 --- /dev/null +++ b/src/gl/textures/gl_samplers.h @@ -0,0 +1,27 @@ +#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]; + + void UnbindAll(); + +public: + + FSamplerManager(); + ~FSamplerManager(); + + BYTE Bind(int texunit, int num, int lastval); + 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..4e4a9c72f --- /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..eb14862c6 --- /dev/null +++ b/src/gl/textures/gl_texture.cpp @@ -0,0 +1,808 @@ +/* +** 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 > 6) 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}, + {GL_LINEAR_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(DMSG_NOTIFY, "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, int maxout) +{ + 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) + { + r = Scale(r, maxout, maxv); + g = Scale(g, maxout, maxv); + b = Scale(b, maxout, 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; + + 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;iGetTextureBuffer(this, w, h); + + if (buffer) + { + gl_info.GlowColor = averageColor((DWORD *) buffer, w*h, 153); + 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. + bool semitrans = false; + 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); + else if (l1[MSB]<255) semitrans=true; + 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..a1c471ea8 --- /dev/null +++ b/src/gl/textures/gl_texture.h @@ -0,0 +1,70 @@ +/* +** 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, int 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); + +#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/unused/gl_builddraw.cpp b/src/gl/unused/gl_builddraw.cpp new file mode 100644 index 000000000..82b93b4f3 --- /dev/null +++ b/src/gl/unused/gl_builddraw.cpp @@ -0,0 +1,598 @@ +/* +** gl_builddraw.cpp +** a build-like rendering algorithm +** Uses the sections created in gl_sections.cpp +** +** NOTE: Although this code generally works, it clearly shows the limitations +** of Build's algorithm. This requires constant sorting of the collected geometry +** and that causes extreme slowdowns on larger maps. +** +**--------------------------------------------------------------------------- +** 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/unused/gl_sections.cpp b/src/gl/unused/gl_sections.cpp new file mode 100644 index 000000000..34858bd3a --- /dev/null +++ b/src/gl/unused/gl_sections.cpp @@ -0,0 +1,845 @@ +/* +** gl_sections.cpp +** Splits sectors into continuous separate parts +** +**--------------------------------------------------------------------------- +** 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 +#include "i_system.h" +#include "p_local.h" +#include "c_dispatch.h" +#include "gl/data/gl_sections.h" + +typedef void (CALLBACK *tessFunc)(); + +TArray SectionLines; +TArray SectionLoops; +TArray Sections; +TArray SectionForSubsector; + +CVAR (Bool, dumpsections, false, 0) + +#define ISDONE(no, p) (p[(no)>>3] & (1 << ((no)&7))) +#define SETDONE(no, p) p[(no)>>3] |= (1 << ((no)&7)) + +inline vertex_t *V1(side_t *s) +{ + line_t *ln = s->linedef; + return s == ln->sidedef[0]? ln->v1: ln->v2; +} + +inline vertex_t *V2(side_t *s) +{ + line_t *ln = s->linedef; + return s == ln->sidedef[0]? ln->v2: ln->v1; +} + +//========================================================================== +// +// +// +//========================================================================== + +class FSectionCreator +{ + static FSectionCreator *creator; + + BYTE *processed_segs; + BYTE *processed_subsectors; + int *section_for_segs; + + vertex_t *v1_l1, *v2_l1; + + FGLSectionLoop *loop; + FGLSection *section; // current working section + +public: + //========================================================================== + // + // + // + //========================================================================== + + FSectionCreator() + { + processed_segs = new BYTE[(numsegs+7)/8]; + processed_subsectors = new BYTE[(numsubsectors+7)/8]; + + memset(processed_segs, 0, (numsegs+7)/8); + memset(processed_subsectors, 0, (numsubsectors+7)/8); + + section_for_segs = new int[numsegs]; + memset(section_for_segs, -1, numsegs * sizeof(int)); + } + + //========================================================================== + // + // + // + //========================================================================== + + ~FSectionCreator() + { + delete [] processed_segs; + delete [] processed_subsectors; + delete [] section_for_segs; + } + + //========================================================================== + // + // + // + //========================================================================== + + void NewLoop() + { + section->numloops++; + loop = &SectionLoops[SectionLoops.Reserve(1)]; + loop->startline = SectionLines.Size(); + loop->numlines = 0 ; + } + + void NewSection(sector_t *sec) + { + section = &Sections[Sections.Reserve(1)]; + section->sector = sec; + section->subsectors.Clear(); + section->numloops = 0; + section->startloop = SectionLoops.Size(); + section->validcount = -1; + NewLoop(); + } + + void FinalizeSection() + { + } + + //========================================================================== + // + // + // + //========================================================================== + + bool AddSeg(seg_t *seg) + { + FGLSectionLine &line = SectionLines[SectionLines.Reserve(1)]; + + + bool firstline = loop->numlines == 0; + + if (ISDONE(seg-segs, processed_segs)) + { + // should never happen! + DPrintf("Tried to add seg %d to Sections twice. Cannot create Sections.\n", seg-segs); + return false; + } + + SETDONE(seg-segs, processed_segs); + section_for_segs[seg-segs] = Sections.Size()-1; + + line.start = seg->v1; + line.end = seg->v2; + line.sidedef = seg->sidedef; + line.linedef = seg->linedef; + line.refseg = seg; + line.polysub = NULL; + line.otherside = -1; + + if (loop->numlines == 0) + { + v1_l1 = seg->v1; + v2_l1 = seg->v2; + } + loop->numlines++; + return true; + } + + //========================================================================== + // + // Utility stuff + // + //========================================================================== + + sector_t *FrontRenderSector(seg_t *seg) + { + return seg->Subsector->render_sector; + } + + sector_t *BackRenderSector(seg_t *seg) + { + if (seg->PartnerSeg == NULL) return NULL; + return seg->PartnerSeg->Subsector->render_sector; + } + + bool IntraSectorSeg(seg_t *seg) + { + return FrontRenderSector(seg) == BackRenderSector(seg); + } + + + //========================================================================== + // + // returns the seg whose partner seg determines where this + // section continues + // + //========================================================================== + bool AddSubSector(subsector_t *subsec, vertex_t *startpt, seg_t **pNextSeg) + { + unsigned i = 0; + if (startpt != NULL) + { + // find the seg in this subsector that starts at the given vertex + for(i = 0; i < subsec->numlines; i++) + { + if (subsec->firstline[i].v1 == startpt) break; + } + if (i == subsec->numlines) + { + DPrintf("Vertex not found in subsector %d. Cannot create Sections.\n", subsec-subsectors); + return false; // Nodes are bad + } + } + else + { + // Find the first unprocessed non-miniseg + for(i = 0; i < subsec->numlines; i++) + { + seg_t *seg = subsec->firstline + i; + + if (seg->sidedef == NULL) continue; + if (IntraSectorSeg(seg)) continue; + if (ISDONE(seg-segs, processed_segs)) continue; + break; + } + if (i == subsec->numlines) + { + DPrintf("Unable to find a start seg. Cannot create Sections.\n"); + return false; // Nodes are bad + } + + startpt = subsec->firstline[i].v1; + } + + seg_t *thisseg = subsec->firstline + i; + if (IntraSectorSeg(thisseg)) + { + SETDONE(thisseg-segs, processed_segs); + // continue with the loop in the adjoining subsector + *pNextSeg = thisseg; + return true; + } + + while(1) + { + if (loop->numlines > 0 && thisseg->v1 == v1_l1 && thisseg->v2 == v2_l1) + { + // This loop is complete + *pNextSeg = NULL; + return true; + } + + if (!AddSeg(thisseg)) return NULL; + + i = (i+1) % subsec->numlines; + seg_t *nextseg = subsec->firstline + i; + + if (thisseg->v2 != nextseg->v1) + { + DPrintf("Segs in subsector %d are not continuous. Cannot create Sections.\n", subsec-subsectors); + return false; // Nodes are bad + } + + if (IntraSectorSeg(nextseg)) + { + SETDONE(nextseg-segs, processed_segs); + // continue with the loop in the adjoining subsector + *pNextSeg = nextseg; + return true; + } + thisseg = nextseg; + } + } + + //============================================================================= + // + // + // + //============================================================================= + + bool FindNextSeg(seg_t **pSeg) + { + // find an unprocessed non-miniseg or a miniseg with an unprocessed + // partner subsector that belongs to the same rendersector + for (unsigned i = 0; i < section->subsectors.Size(); i++) + { + for(unsigned j = 0; j < section->subsectors[i]->numlines; j++) + { + seg_t *seg = section->subsectors[i]->firstline + j; + bool intra = IntraSectorSeg(seg); + + if (!intra && !ISDONE(seg-segs, processed_segs)) + { + *pSeg = seg; + return true; + } + else if (intra && + !ISDONE(seg->PartnerSeg->Subsector-subsectors, processed_subsectors)) + { + *pSeg = seg->PartnerSeg; + return true; + } + } + } + *pSeg = NULL; + return true; + } + + //============================================================================= + // + // all segs and subsectors must be grouped into Sections + // + //============================================================================= + bool CheckSections() + { + bool res = true; + for (int i = 0; i < numsegs; i++) + { + if (segs[i].sidedef != NULL && !ISDONE(i, processed_segs) && !IntraSectorSeg(&segs[i])) + { + Printf("Seg %d (Linedef %d) not processed during section creation\n", i, segs[i].linedef-lines); + res = false; + } + } + for (int i = 0; i < numsubsectors; i++) + { + if (!ISDONE(i, processed_subsectors)) + { + Printf("Subsector %d (Sector %d) not processed during section creation\n", i, subsectors[i].sector-sectors); + res = false; + } + } + return res; + } + + //============================================================================= + // + // + // + //============================================================================= + void DeleteLine(int i) + { + SectionLines.Delete(i); + for(int i = SectionLoops.Size() - 1; i >= 0; i--) + { + FGLSectionLoop *loop = &SectionLoops[i]; + if (loop->startline > i) loop->startline--; + } + } + + //============================================================================= + // + // + // + //============================================================================= + void MergeLines(FGLSectionLoop *loop) + { + int i; + int deleted = 0; + FGLSectionLine *ln1; + FGLSectionLine *ln2; + // Merge identical lines in the list + for(i = loop->numlines - 1; i > 0; i--) + { + ln1 = loop->GetLine(i); + ln2 = loop->GetLine(i-1); + + if (ln1->sidedef == ln2->sidedef && ln1->otherside == ln2->otherside) + { + // identical references. These 2 lines can be merged. + ln2->end = ln1->end; + SectionLines.Delete(loop->startline + i); + loop->numlines--; + deleted++; + } + } + + // If we started in the middle of a sidedef the first and last lines + // may reference the same sidedef. check that, too. + + int loopstart = 0; + + ln1 = loop->GetLine(0); + for(i = loop->numlines - 1; i > 0; i--) + { + ln2 = loop->GetLine(i); + if (ln1->sidedef != ln2->sidedef || ln1->otherside != ln2->otherside) + break; + } + if (i < loop->numlines-1) + { + i++; + ln2 = loop->GetLine(i); + ln1->start = ln2->start; + SectionLines.Delete(loop->startline + i, loop->numlines - i); + deleted += loop->numlines - i; + loop->numlines = i; + } + + // Adjust all following loops + for(unsigned ii = unsigned(loop - &SectionLoops[0]) + 1; ii < SectionLoops.Size(); ii++) + { + SectionLoops[ii].startline -= deleted; + } + } + + //============================================================================= + // + // + // + //============================================================================= + void SetReferences() + { + for(unsigned i = 0; i < SectionLines.Size(); i++) + { + FGLSectionLine *ln = &SectionLines[i]; + seg_t *seg = ln->refseg; + + if (seg != NULL) + { + seg_t *partner = seg->PartnerSeg; + + if (seg->PartnerSeg == NULL) + { + ln->otherside = -1; + } + else + { + ln->otherside = section_for_segs[partner-segs]; + } + } + else + { + ln->otherside = -1; + } + } + + for(unsigned i = 0; i < SectionLoops.Size(); i++) + { + MergeLines(&SectionLoops[i]); + } + } + + //============================================================================= + // + // cbTessBegin + // + // called when the tesselation of a new loop starts + // + //============================================================================= + + static void CALLBACK cbTessBegin(GLenum type, void *section) + { + FGLSection *sect = (FGLSection*)section; + sect->primitives.Push(type); + sect->primitives.Push(sect->vertices.Size()); + } + + //============================================================================= + // + // cbTessError + // + // called when the tesselation failed + // + //============================================================================= + + static void CALLBACK cbTessError(GLenum error, void *section) + { + } + + //============================================================================= + // + // cbTessCombine + // + // called when the two or more vertexes are on the same coordinate + // + //============================================================================= + + static void CALLBACK cbTessCombine( GLdouble coords[3], void *vert[4], GLfloat w[4], void **dataOut ) + { + *dataOut = vert[0]; + } + + //============================================================================= + // + // cbTessVertex + // + // called when a vertex is found + // + //============================================================================= + + static void CALLBACK cbTessVertex( void *vert, void *section ) + { + FGLSection *sect = (FGLSection*)section; + sect->vertices.Push(int(intptr_t(vert))); + } + + //============================================================================= + // + // cbTessEnd + // + // called when the tesselation of a the current loop ends + // + //============================================================================= + + static void CALLBACK cbTessEnd(void *section) + { + } + + //============================================================================= + // + // + // + //============================================================================= + void tesselateSections() + { + // init tesselator + GLUtesselator *tess = gluNewTess(); + if (!tess) + { + return; + } + // set callbacks + gluTessCallback(tess, GLU_TESS_BEGIN_DATA, (tessFunc)cbTessBegin); + gluTessCallback(tess, GLU_TESS_VERTEX_DATA, (tessFunc)cbTessVertex); + gluTessCallback(tess, GLU_TESS_ERROR_DATA, (tessFunc)cbTessError); + gluTessCallback(tess, GLU_TESS_COMBINE, (tessFunc)cbTessCombine); + gluTessCallback(tess, GLU_TESS_END_DATA, (tessFunc)cbTessEnd); + + for(unsigned int i=0;inumloops; j++) + { + gluTessBeginContour(tess); + FGLSectionLoop *loop = sect->GetLoop(j); + for(int k=0; knumlines; k++) + { + FGLSectionLine *line = loop->GetLine(k); + vertex_t *vert = line->start; + GLdouble v[3] = { + -(double)vert->x/(double)FRACUNIT, // negate to get proper winding + 0.0, + (double)vert->y/(double)FRACUNIT + }; + gluTessVertex(tess, v, (void*)(vert - vertexes)); + } + gluTessEndContour(tess); + } + gluTessEndPolygon(tess); + sect->vertices.Push(-1337); + sect->vertices.ShrinkToFit(); + } + gluDeleteTess(tess); + } + + + //============================================================================= + // + // First mark all subsectors that have no outside boundaries as processed + // No line in such a subsector will ever be part of a section's border + // + //============================================================================= + + void MarkInternalSubsectors() + { + for(int i=0; i < numsubsectors; i++) + { + subsector_t *sub = &subsectors[i]; + int j; + + for(j=0; j < sub->numlines; j++) + { + seg_t *seg = sub->firstline + j; + if (!IntraSectorSeg(seg)) break; + } + if (j==sub->numlines) + { + // All lines are intra-sector so mark this as processed + SETDONE(i, processed_subsectors); + for(j=0; j < sub->numlines; j++) + { + seg_t *seg = sub->firstline + j; + SETDONE((sub->firstline-segs)+j, processed_segs); + if (seg->PartnerSeg != NULL) + { + SETDONE(int(seg->PartnerSeg - segs), processed_segs); + } + } + } + } + } + + //============================================================================= + // + // + // + //============================================================================= + bool CreateSections() + { + int pick = 0; + + MarkInternalSubsectors(); + while (pick < numsubsectors) + { + if (ISDONE(pick, processed_subsectors)) + { + pick++; + continue; + } + + + subsector_t *subsector = &subsectors[pick]; + + seg_t *workseg = NULL; + vertex_t *startpt = NULL; + + NewSection(subsector->render_sector); + while (1) + { + if (!ISDONE(subsector-subsectors, processed_subsectors)) + { + SETDONE(subsector-subsectors, processed_subsectors); + section->subsectors.Push(subsector); + SectionForSubsector[subsector - subsectors] = int(section - &Sections[0]); + } + + bool result = AddSubSector(subsector, startpt, &workseg); + + if (!result) + { + return false; // couldn't create Sections + } + else if (workseg != NULL) + { + // crossing into another subsector + seg_t *partner = workseg->PartnerSeg; + if (workseg->v2 != partner->v1) + { + DPrintf("Inconsistent subsector references in seg %d. Cannot create Sections.\n", workseg-segs); + return false; + } + subsector = partner->Subsector; + startpt = workseg->v1; + } + else + { + // loop complete. Check adjoining subsectors for other loops to + // be added to this section + if (!FindNextSeg(&workseg)) + { + return false; + } + else if (workseg == NULL) + { + // No more subsectors found. This section is complete! + FinalizeSection(); + break; + } + else + { + subsector = workseg->Subsector; + // If this is a regular seg, start there, otherwise start + // at the subsector's first seg + startpt = workseg->sidedef == NULL? NULL : workseg->v1; + + NewLoop(); + } + } + } + } + + if (!CheckSections()) return false; + SetReferences(); + + Sections.ShrinkToFit(); + SectionLoops.ShrinkToFit(); + SectionLines.ShrinkToFit(); + + tesselateSections(); + + return true; + } +}; + +FSectionCreator *FSectionCreator::creator; + + +//============================================================================= +// +// +// +//============================================================================= + +void DumpSection(int no, FGLSection *sect) +{ + Printf(PRINT_LOG, "Section %d, sector %d\n{\n", no, sect->sector->sectornum); + + for(int i = 0; i < sect->numloops; i++) + { + Printf(PRINT_LOG, "\tLoop %d\n\t{\n", i); + + FGLSectionLoop *loop = sect->GetLoop(i); + + for(int i = 0; i < loop->numlines; i++) + { + FGLSectionLine *ln = loop->GetLine(i); + if (ln->sidedef != NULL) + { + vertex_t *v1 = V1(ln->sidedef); + vertex_t *v2 = V2(ln->sidedef); + double dx = FIXED2DBL(v2->x-v1->x); + double dy = FIXED2DBL(v2->y-v1->y); + double dx1 = FIXED2DBL(ln->start->x-v1->x); + double dy1 = FIXED2DBL(ln->start->y-v1->y); + double dx2 = FIXED2DBL(ln->end->x-v1->x); + double dy2 = FIXED2DBL(ln->end->y-v1->y); + double d = sqrt(dx*dx+dy*dy); + double d1 = sqrt(dx1*dx1+dy1*dy1); + double d2 = sqrt(dx2*dx2+dy2*dy2); + + Printf(PRINT_LOG, "\t\tLinedef %d, %s: Start (%1.2f, %1.2f), End (%1.2f, %1.2f)", + ln->linedef - lines, ln->sidedef == ln->linedef->sidedef[0]? "front":"back", + ln->start->x/65536.f, ln->start->y/65536.f, + ln->end->x/65536.f, ln->end->y/65536.f); + + if (ln->otherside != -1) + { + Printf (PRINT_LOG, ", other side = %d", ln->otherside); + } + if (d1 > 0.005 || d2 < 0.995) + { + Printf(PRINT_LOG, ", Range = %1.3f, %1.3f", d1/d, d2/d); + } + } + else + { + Printf(PRINT_LOG, "\t\tMiniseg: Start (%1.3f, %1.3f), End (%1.3f, %1.3f)\n", + ln->start->x/65536.f, ln->start->y/65536.f, ln->end->x/65536.f, ln->end->y/65536.f); + + if (ln->otherside != -1) + { + Printf (PRINT_LOG, ", other side = %d", ln->otherside); + } + } + Printf(PRINT_LOG, "\n"); + } + Printf(PRINT_LOG, "\t}\n"); + } + int prim = 1; + for(unsigned i = 0; i < sect->vertices.Size(); i++) + { + int v = sect->vertices[i]; + if (v < 0) + { + if (i > 0) + { + Printf(PRINT_LOG, "\t}\n"); + } + switch (v) + { + case -GL_TRIANGLE_FAN: + Printf(PRINT_LOG, "\t%d: Triangle fan\n\t{\n", prim); + break; + + case -GL_TRIANGLE_STRIP: + Printf(PRINT_LOG, "\t%d: Triangle strip\n\t{\n", prim); + break; + + case -GL_TRIANGLES: + Printf(PRINT_LOG, "\t%d: Triangles\n\t{\n", prim); + break; + + default: + break; + } + prim++; + } + else + { + Printf(PRINT_LOG, "\t\tVertex %d: (%1.2f, %1.2f)\n", + v, vertexes[v].x/65536.f, vertexes[v].y/65536.f); + } + } + Printf(PRINT_LOG, "}\n\n"); +} + +//============================================================================= +// +// +// +//============================================================================= + +void DumpSections() +{ + for(unsigned i = 0; i < Sections.Size(); i++) + { + DumpSection(i, &Sections[i]); + } +} + +//============================================================================= +// +// +// +//============================================================================= + +void gl_CreateSections() +{ + SectionLines.Clear(); + SectionLoops.Clear(); + Sections.Clear(); + SectionForSubsector.Resize(numsubsectors); + memset(&SectionForSubsector[0], -1, numsubsectors * sizeof(SectionForSubsector[0])); + FSectionCreator creat; + creat.CreateSections(); + if (dumpsections) DumpSections(); +} + diff --git a/src/gl/unused/gl_sections.h b/src/gl/unused/gl_sections.h new file mode 100644 index 000000000..1974fab46 --- /dev/null +++ b/src/gl/unused/gl_sections.h @@ -0,0 +1,57 @@ + +#ifndef __GL_SECTIONS_H +#define __GL_SECTIONS_H + +#include "tarray.h" +#include "r_defs.h" + +struct FGLSectionLine +{ + vertex_t *start; + vertex_t *end; + side_t *sidedef; + line_t *linedef; + seg_t *refseg; // we need to reference at least one seg for each line. + subsector_t *polysub; // If this is part of a polyobject we need a reference to the containing subsector + int otherside; +}; + +struct FGLSectionLoop +{ + int startline; + int numlines; + + FGLSectionLine *GetLine(int no); +}; + +struct FGLSection +{ + sector_t *sector; + TArray subsectors; + TArray primitives; // each primitive has 2 entries: Primitive type and vertex count + TArray vertices; + int startloop; + int numloops; + int validcount; + + FGLSectionLoop *GetLoop(int no); +}; + +extern TArray SectionLines; +extern TArray SectionLoops; +extern TArray Sections; +extern TArray SectionForSubsector; + +inline FGLSectionLine *FGLSectionLoop::GetLine(int no) +{ + return &SectionLines[startline + no]; +} + +inline FGLSectionLoop *FGLSection::GetLoop(int no) +{ + return &SectionLoops[startloop + no]; +} + +void gl_CreateSections(); + +#endif \ No newline at end of file diff --git a/src/gl/utility/gl_clock.cpp b/src/gl/utility/gl_clock.cpp new file mode 100644 index 000000000..0bb75cd52 --- /dev/null +++ b/src/gl/utility/gl_clock.cpp @@ -0,0 +1,231 @@ +#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; +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(); + 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(); + double clipwall = ClipWall.TimeMS() - SetupWall.TimeMS(); + double bsp = Bsp.TimeMS() - ClipWall.TimeMS() - SetupFlat.TimeMS() - SetupSprite.TimeMS(); + + str.AppendFormat("W: Render=%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(), 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(), ViewPos.X, ViewPos.Y, ViewPos.Z, ViewAngle.Degrees, ViewPitch.Degrees); + + 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..4d5163d86 --- /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; +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..61eede6b4 --- /dev/null +++ b/src/gl/utility/gl_convert.h @@ -0,0 +1,7 @@ + +#ifndef __GLC_CONVERT +#define __GLC_CONVERT + +#include "m_fixed.h" + +#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..15b01f254 --- /dev/null +++ b/src/gl/utility/gl_geometric.cpp @@ -0,0 +1,251 @@ + + +#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) +{ + m_normal.Set((float)plane.Normal().X, (float)plane.Normal().Z, (float)plane.Normal().Y); + //m_normal.Normalize(); the vector is already normalized + m_d = (float)plane.fD(); +} + + +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..f1053c430 --- /dev/null +++ b/src/gl/utility/gl_geometric.h @@ -0,0 +1,261 @@ +#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((float)v->fX()); + SetY((float)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; + } + + FVector3 operator *(const FVector3 &vec) + { + FVector3 result; + + result.X = vec.X*m[0][0] + vec.Y*m[0][1] + vec.Z*m[0][2] + m[0][3]; + result.Y = vec.X*m[1][0] + vec.Y*m[1][1] + vec.Z*m[1][2] + m[1][3]; + result.Z = 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;i +#include +#include +#include + +#if __cplusplus <= 199711 +#define static_assert(VAL, MSG) static_assertion(); +template struct static_assertion; +template<> struct static_assertion {}; +#endif // __cplusplus <= 199711 + +namespace +{ +template inline +unsigned char getByte(uint32_t val) { return static_cast((val >> (8 * N)) & 0xff); } + +inline unsigned char getAlpha(uint32_t pix) { return getByte<3>(pix); } +inline unsigned char getRed (uint32_t pix) { return getByte<2>(pix); } +inline unsigned char getGreen(uint32_t pix) { return getByte<1>(pix); } +inline unsigned char getBlue (uint32_t pix) { return getByte<0>(pix); } + +inline uint32_t makePixel( unsigned char r, unsigned char g, unsigned char b) { return (r << 16) | (g << 8) | b; } +inline uint32_t makePixel(unsigned char a, unsigned char r, unsigned char g, unsigned char b) { return (a << 24) | (r << 16) | (g << 8) | b; } + + +template inline +uint32_t gradientRGB(uint32_t pixFront, uint32_t pixBack) //blend front color with opacity M / N over opaque background: http://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending +{ + static_assert(0 < M && M < N && N <= 1000, ""); + +#define calcColor(colFront, colBack) \ + (((colFront) * M + (colBack) * (N - M)) / N) + + return makePixel(calcColor(getRed (pixFront), getRed (pixBack)), + calcColor(getGreen(pixFront), getGreen(pixBack)), + calcColor(getBlue (pixFront), getBlue (pixBack))); + +#undef calcColor +} + + +template inline +uint32_t gradientARGB(uint32_t pixFront, uint32_t pixBack) //find intermediate color between two colors with alpha channels (=> NO alpha blending!!!) +{ + static_assert(0 < M && M < N && N <= 1000, ""); + + const unsigned int weightFront = getAlpha(pixFront) * M; + const unsigned int weightBack = getAlpha(pixBack) * (N - M); + const unsigned int weightSum = weightFront + weightBack; + if (weightSum == 0) + return 0; + +#define calcColor(colFront, colBack) \ + static_cast(((colFront) * weightFront + (colBack) * weightBack) / weightSum) + + return makePixel(static_cast(weightSum / N), + calcColor(getRed (pixFront), getRed (pixBack)), + calcColor(getGreen(pixFront), getGreen(pixBack)), + calcColor(getBlue (pixFront), getBlue (pixBack))); + +#undef calcColor +} + + +//inline +//double fastSqrt(double n) +//{ +// __asm //speeds up xBRZ by about 9% compared to std::sqrt which internally uses the same assembler instructions but adds some "fluff" +// { +// fld n +// fsqrt +// } +//} +// + + +uint32_t* byteAdvance( uint32_t* ptr, int bytes) { return reinterpret_cast< uint32_t*>(reinterpret_cast< char*>(ptr) + bytes); } +const uint32_t* byteAdvance(const uint32_t* ptr, int bytes) { return reinterpret_cast(reinterpret_cast(ptr) + bytes); } + + +//fill block with the given color +inline +void fillBlock(uint32_t* trg, int pitch, uint32_t col, int blockWidth, int blockHeight) +{ + //for (int y = 0; y < blockHeight; ++y, trg = byteAdvance(trg, pitch)) + // std::fill(trg, trg + blockWidth, col); + + for (int y = 0; y < blockHeight; ++y, trg = byteAdvance(trg, pitch)) + for (int x = 0; x < blockWidth; ++x) + trg[x] = col; +} + +inline +void fillBlock(uint32_t* trg, int pitch, uint32_t col, int n) { fillBlock(trg, pitch, col, n, n); } + + +#ifdef _MSC_VER + #define FORCE_INLINE __forceinline +#elif defined __GNUC__ + #define FORCE_INLINE __attribute__((always_inline)) inline +#else + #define FORCE_INLINE inline +#endif + + +enum RotationDegree //clock-wise +{ + ROT_0, + ROT_90, + ROT_180, + ROT_270 +}; + +//calculate input matrix coordinates after rotation at compile time +template +struct MatrixRotation; + +template +struct MatrixRotation +{ + static const size_t I_old = I; + static const size_t J_old = J; +}; + +template //(i, j) = (row, col) indices, N = size of (square) matrix +struct MatrixRotation +{ + static const size_t I_old = N - 1 - MatrixRotation(rotDeg - 1), I, J, N>::J_old; //old coordinates before rotation! + static const size_t J_old = MatrixRotation(rotDeg - 1), I, J, N>::I_old; // +}; + + +template +class OutputMatrix +{ +public: + OutputMatrix(uint32_t* out, int outWidth) : //access matrix area, top-left at position "out" for image with given width + out_(out), + outWidth_(outWidth) {} + + template + uint32_t& ref() const + { + static const size_t I_old = MatrixRotation::I_old; + static const size_t J_old = MatrixRotation::J_old; + return *(out_ + J_old + I_old * outWidth_); + } + +private: + uint32_t* out_; + const int outWidth_; +}; + + +template inline +T square(T value) { return value * value; } + + + +inline +double distRGB(uint32_t pix1, uint32_t pix2) +{ + const double r_diff = static_cast(getRed (pix1)) - getRed (pix2); + const double g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); + const double b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); + + //euklidean RGB distance + return std::sqrt(square(r_diff) + square(g_diff) + square(b_diff)); +} + + +inline +double distYCbCr(uint32_t pix1, uint32_t pix2, double lumaWeight) +{ + //http://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion + //YCbCr conversion is a matrix multiplication => take advantage of linearity by subtracting first! + const int r_diff = static_cast(getRed (pix1)) - getRed (pix2); //we may delay division by 255 to after matrix multiplication + const int g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); // + const int b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); //substraction for int is noticeable faster than for double! + + //const double k_b = 0.0722; //ITU-R BT.709 conversion + //const double k_r = 0.2126; // + const double k_b = 0.0593; //ITU-R BT.2020 conversion + const double k_r = 0.2627; // + const double k_g = 1 - k_b - k_r; + + const double scale_b = 0.5 / (1 - k_b); + const double scale_r = 0.5 / (1 - k_r); + + const double y = k_r * r_diff + k_g * g_diff + k_b * b_diff; //[!], analog YCbCr! + const double c_b = scale_b * (b_diff - y); + const double c_r = scale_r * (r_diff - y); + + //we skip division by 255 to have similar range like other distance functions + return std::sqrt(square(lumaWeight * y) + square(c_b) + square(c_r)); +} + + +struct DistYCbCrBuffer //30% perf boost compared to distYCbCr()! +{ +public: + static double dist(uint32_t pix1, uint32_t pix2) + { +#if defined _MSC_VER && _MSC_VER < 1900 +#error function scope static initialization is not yet thread-safe! +#endif + static const DistYCbCrBuffer inst; + return inst.distImpl(pix1, pix2); + } + +private: + DistYCbCrBuffer() : buffer(256 * 256 * 256) + { + for (uint32_t i = 0; i < 256 * 256 * 256; ++i) //startup time: 114 ms on Intel Core i5 (four cores) + { + const int r_diff = getByte<2>(i) * 2 - 255; + const int g_diff = getByte<1>(i) * 2 - 255; + const int b_diff = getByte<0>(i) * 2 - 255; + + const double k_b = 0.0593; //ITU-R BT.2020 conversion + const double k_r = 0.2627; // + const double k_g = 1 - k_b - k_r; + + const double scale_b = 0.5 / (1 - k_b); + const double scale_r = 0.5 / (1 - k_r); + + const double y = k_r * r_diff + k_g * g_diff + k_b * b_diff; //[!], analog YCbCr! + const double c_b = scale_b * (b_diff - y); + const double c_r = scale_r * (r_diff - y); + + buffer[i] = static_cast(std::sqrt(square(y) + square(c_b) + square(c_r))); + } + } + + double distImpl(uint32_t pix1, uint32_t pix2) const + { + //if (pix1 == pix2) -> 8% perf degradation! + // return 0; + //if (pix1 > pix2) + // std::swap(pix1, pix2); -> 30% perf degradation!!! + + const int r_diff = static_cast(getRed (pix1)) - getRed (pix2); + const int g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); + const int b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); + + return buffer[(((r_diff + 255) / 2) << 16) | //slightly reduce precision (division by 2) to squeeze value into single byte + (((g_diff + 255) / 2) << 8) | + (( b_diff + 255) / 2)]; + } + + std::vector buffer; //consumes 64 MB memory; using double is only 2% faster, but takes 128 MB +}; + + +enum BlendType +{ + BLEND_NONE = 0, + BLEND_NORMAL, //a normal indication to blend + BLEND_DOMINANT, //a strong indication to blend + //attention: BlendType must fit into the value range of 2 bit!!! +}; + +struct BlendResult +{ + BlendType + /**/blend_f, blend_g, + /**/blend_j, blend_k; +}; + + +struct Kernel_4x4 //kernel for preprocessing step +{ + uint32_t + /**/a, b, c, d, + /**/e, f, g, h, + /**/i, j, k, l, + /**/m, n, o, p; +}; + +/* +input kernel area naming convention: +----------------- +| A | B | C | D | +----|---|---|---| +| E | F | G | H | //evaluate the four corners between F, G, J, K +----|---|---|---| //input pixel is at position F +| I | J | K | L | +----|---|---|---| +| M | N | O | P | +----------------- +*/ +template +FORCE_INLINE //detect blend direction +BlendResult preProcessCorners(const Kernel_4x4& ker, const xbrz::ScalerCfg& cfg) //result: F, G, J, K corners of "GradientType" +{ + BlendResult result = {}; + + if ((ker.f == ker.g && + ker.j == ker.k) || + (ker.f == ker.j && + ker.g == ker.k)) + return result; + +#define dist(pix1, pix2) \ + ColorDistance::dist((pix1), (pix2), cfg.luminanceWeight) + + const int weight = 4; + double jg = dist(ker.i, ker.f) + dist(ker.f, ker.c) + dist(ker.n, ker.k) + dist(ker.k, ker.h) + weight * dist(ker.j, ker.g); + double fk = dist(ker.e, ker.j) + dist(ker.j, ker.o) + dist(ker.b, ker.g) + dist(ker.g, ker.l) + weight * dist(ker.f, ker.k); + +#undef dist + + if (jg < fk) //test sample: 70% of values max(jg, fk) / min(jg, fk) are between 1.1 and 3.7 with median being 1.8 + { + const bool dominantGradient = cfg.dominantDirectionThreshold * jg < fk; + if (ker.f != ker.g && ker.f != ker.j) + result.blend_f = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + + if (ker.k != ker.j && ker.k != ker.g) + result.blend_k = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + } + else if (fk < jg) + { + const bool dominantGradient = cfg.dominantDirectionThreshold * fk < jg; + if (ker.j != ker.f && ker.j != ker.k) + result.blend_j = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + + if (ker.g != ker.f && ker.g != ker.k) + result.blend_g = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + } + return result; +} + +struct Kernel_3x3 +{ + uint32_t + /**/a, b, c, + /**/d, e, f, + /**/g, h, i; +}; + +#define DEF_GETTER(x) template uint32_t inline get_##x(const Kernel_3x3& ker) { return ker.x; } +//we cannot and NEED NOT write "ker.##x" since ## concatenates preprocessor tokens but "." is not a token +DEF_GETTER(a) DEF_GETTER(b) DEF_GETTER(c) +DEF_GETTER(d) DEF_GETTER(e) DEF_GETTER(f) +DEF_GETTER(g) DEF_GETTER(h) DEF_GETTER(i) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, g) DEF_GETTER(b, d) DEF_GETTER(c, a) +DEF_GETTER(d, h) DEF_GETTER(e, e) DEF_GETTER(f, b) +DEF_GETTER(g, i) DEF_GETTER(h, f) DEF_GETTER(i, c) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, i) DEF_GETTER(b, h) DEF_GETTER(c, g) +DEF_GETTER(d, f) DEF_GETTER(e, e) DEF_GETTER(f, d) +DEF_GETTER(g, c) DEF_GETTER(h, b) DEF_GETTER(i, a) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, c) DEF_GETTER(b, f) DEF_GETTER(c, i) +DEF_GETTER(d, b) DEF_GETTER(e, e) DEF_GETTER(f, h) +DEF_GETTER(g, a) DEF_GETTER(h, d) DEF_GETTER(i, g) +#undef DEF_GETTER + + +//compress four blend types into a single byte +inline BlendType getTopL (unsigned char b) { return static_cast(0x3 & b); } +inline BlendType getTopR (unsigned char b) { return static_cast(0x3 & (b >> 2)); } +inline BlendType getBottomR(unsigned char b) { return static_cast(0x3 & (b >> 4)); } +inline BlendType getBottomL(unsigned char b) { return static_cast(0x3 & (b >> 6)); } + +inline void setTopL (unsigned char& b, BlendType bt) { b |= bt; } //buffer is assumed to be initialized before preprocessing! +inline void setTopR (unsigned char& b, BlendType bt) { b |= (bt << 2); } +inline void setBottomR(unsigned char& b, BlendType bt) { b |= (bt << 4); } +inline void setBottomL(unsigned char& b, BlendType bt) { b |= (bt << 6); } + +inline bool blendingNeeded(unsigned char b) { return b != 0; } + +template inline +unsigned char rotateBlendInfo(unsigned char b) { return b; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 2) | (b >> 6)) & 0xff; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 4) | (b >> 4)) & 0xff; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 6) | (b >> 2)) & 0xff; } + + +/* +input kernel area naming convention: +------------- +| A | B | C | +----|---|---| +| D | E | F | //input pixel is at position E +----|---|---| +| G | H | I | +------------- +*/ +template +FORCE_INLINE //perf: quite worth it! +void blendPixel(const Kernel_3x3& ker, + uint32_t* target, int trgWidth, + unsigned char blendInfo, //result of preprocessing all four corners of pixel "e" + const xbrz::ScalerCfg& cfg) +{ +#define a get_a(ker) +#define b get_b(ker) +#define c get_c(ker) +#define d get_d(ker) +#define e get_e(ker) +#define f get_f(ker) +#define g get_g(ker) +#define h get_h(ker) +#define i get_i(ker) + + const unsigned char blend = rotateBlendInfo(blendInfo); + + if (getBottomR(blend) >= BLEND_NORMAL) + { + struct LineBlend + { + static bool Eval(const Kernel_3x3& ker, const xbrz::ScalerCfg& cfg, const unsigned char blend) + { + if (getBottomR(blend) >= BLEND_DOMINANT) + return true; + +#define eq(pix1, pix2) \ + (ColorDistance::dist((pix1), (pix2), cfg.luminanceWeight) < cfg.equalColorTolerance) + + //make sure there is no second blending in an adjacent rotation for this pixel: handles insular pixels, mario eyes + if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90 degree corners + return false; + if (getBottomL(blend) != BLEND_NONE && !eq(e, c)) + return false; + + //no full blending for L-shapes; blend corner only (handles "mario mushroom eyes") + if (!eq(e, i) && eq(g, h) && eq(h , i) && eq(i, f) && eq(f, c)) + return false; + +#undef eq + + return true; + } + }; + + const bool doLineBlend = LineBlend::Eval(ker, cfg, blend); + +#define dist(pix1, pix2) \ + ColorDistance::dist((pix1), (pix2), cfg.luminanceWeight) + + const uint32_t px = dist(e, f) <= dist(e, h) ? f : h; //choose most similar color + + OutputMatrix out(target, trgWidth); + + if (doLineBlend) + { + const double fg = dist(f, g); //test sample: 70% of values max(fg, hc) / min(fg, hc) are between 1.1 and 3.7 with median being 1.9 + const double hc = dist(h, c); // + + const bool haveShallowLine = cfg.steepDirectionThreshold * fg <= hc && e != g && d != g; + const bool haveSteepLine = cfg.steepDirectionThreshold * hc <= fg && e != c && b != c; + + if (haveShallowLine) + { + if (haveSteepLine) + Scaler::blendLineSteepAndShallow(px, out); + else + Scaler::blendLineShallow(px, out); + } + else + { + if (haveSteepLine) + Scaler::blendLineSteep(px, out); + else + Scaler::blendLineDiagonal(px,out); + } + } + else + Scaler::blendCorner(px, out); + } + +#undef dist + +#undef a +#undef b +#undef c +#undef d +#undef e +#undef f +#undef g +#undef h +#undef i +} + + +template //scaler policy: see "Scaler2x" reference implementation +void scaleImage(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz::ScalerCfg& cfg, int yFirst, int yLast) +{ + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, srcHeight); + if (yFirst >= yLast || srcWidth <= 0) + return; + + const int trgWidth = srcWidth * Scaler::scale; + + //"use" space at the end of the image as temporary buffer for "on the fly preprocessing": we even could use larger area of + //"sizeof(uint32_t) * srcWidth * (yLast - yFirst)" bytes without risk of accidental overwriting before accessing + const int bufferSize = srcWidth; + unsigned char* preProcBuffer = reinterpret_cast(trg + yLast * Scaler::scale * trgWidth) - bufferSize; + std::fill(preProcBuffer, preProcBuffer + bufferSize, 0); + static_assert(BLEND_NONE == 0, ""); + + //initialize preprocessing buffer for first row of current stripe: detect upper left and right corner blending + //this cannot be optimized for adjacent processing stripes; we must not allow for a memory race condition! + if (yFirst > 0) + { + const int y = yFirst - 1; + + const uint32_t* s_m1 = src + srcWidth * std::max(y - 1, 0); + const uint32_t* s_0 = src + srcWidth * y; //center line + const uint32_t* s_p1 = src + srcWidth * std::min(y + 1, srcHeight - 1); + const uint32_t* s_p2 = src + srcWidth * std::min(y + 2, srcHeight - 1); + + for (int x = 0; x < srcWidth; ++x) + { + const int x_m1 = std::max(x - 1, 0); + const int x_p1 = std::min(x + 1, srcWidth - 1); + const int x_p2 = std::min(x + 2, srcWidth - 1); + + Kernel_4x4 ker = {}; //perf: initialization is negligible + ker.a = s_m1[x_m1]; //read sequentially from memory as far as possible + ker.b = s_m1[x]; + ker.c = s_m1[x_p1]; + ker.d = s_m1[x_p2]; + + ker.e = s_0[x_m1]; + ker.f = s_0[x]; + ker.g = s_0[x_p1]; + ker.h = s_0[x_p2]; + + ker.i = s_p1[x_m1]; + ker.j = s_p1[x]; + ker.k = s_p1[x_p1]; + ker.l = s_p1[x_p2]; + + ker.m = s_p2[x_m1]; + ker.n = s_p2[x]; + ker.o = s_p2[x_p1]; + ker.p = s_p2[x_p2]; + + const BlendResult res = preProcessCorners(ker, cfg); + /* + preprocessing blend result: + --------- + | F | G | //evalute corner between F, G, J, K + ----|---| //input pixel is at position F + | J | K | + --------- + */ + setTopR(preProcBuffer[x], res.blend_j); + + if (x + 1 < bufferSize) + setTopL(preProcBuffer[x + 1], res.blend_k); + } + } + //------------------------------------------------------------------------------------ + + for (int y = yFirst; y < yLast; ++y) + { + uint32_t* out = trg + Scaler::scale * y * trgWidth; //consider MT "striped" access + + const uint32_t* s_m1 = src + srcWidth * std::max(y - 1, 0); + const uint32_t* s_0 = src + srcWidth * y; //center line + const uint32_t* s_p1 = src + srcWidth * std::min(y + 1, srcHeight - 1); + const uint32_t* s_p2 = src + srcWidth * std::min(y + 2, srcHeight - 1); + + unsigned char blend_xy1 = 0; //corner blending for current (x, y + 1) position + + for (int x = 0; x < srcWidth; ++x, out += Scaler::scale) + { + //all those bounds checks have only insignificant impact on performance! + const int x_m1 = std::max(x - 1, 0); //perf: prefer array indexing to additional pointers! + const int x_p1 = std::min(x + 1, srcWidth - 1); + const int x_p2 = std::min(x + 2, srcWidth - 1); + + Kernel_4x4 ker4 = {}; //perf: initialization is negligible + + ker4.a = s_m1[x_m1]; //read sequentially from memory as far as possible + ker4.b = s_m1[x]; + ker4.c = s_m1[x_p1]; + ker4.d = s_m1[x_p2]; + + ker4.e = s_0[x_m1]; + ker4.f = s_0[x]; + ker4.g = s_0[x_p1]; + ker4.h = s_0[x_p2]; + + ker4.i = s_p1[x_m1]; + ker4.j = s_p1[x]; + ker4.k = s_p1[x_p1]; + ker4.l = s_p1[x_p2]; + + ker4.m = s_p2[x_m1]; + ker4.n = s_p2[x]; + ker4.o = s_p2[x_p1]; + ker4.p = s_p2[x_p2]; + + //evaluate the four corners on bottom-right of current pixel + unsigned char blend_xy = 0; //for current (x, y) position + { + const BlendResult res = preProcessCorners(ker4, cfg); + /* + preprocessing blend result: + --------- + | F | G | //evalute corner between F, G, J, K + ----|---| //current input pixel is at position F + | J | K | + --------- + */ + blend_xy = preProcBuffer[x]; + setBottomR(blend_xy, res.blend_f); //all four corners of (x, y) have been determined at this point due to processing sequence! + + setTopR(blend_xy1, res.blend_j); //set 2nd known corner for (x, y + 1) + preProcBuffer[x] = blend_xy1; //store on current buffer position for use on next row + + blend_xy1 = 0; + setTopL(blend_xy1, res.blend_k); //set 1st known corner for (x + 1, y + 1) and buffer for use on next column + + if (x + 1 < bufferSize) //set 3rd known corner for (x + 1, y) + setBottomL(preProcBuffer[x + 1], res.blend_g); + } + + //fill block of size scale * scale with the given color + fillBlock(out, trgWidth * sizeof(uint32_t), ker4.f, Scaler::scale); //place *after* preprocessing step, to not overwrite the results while processing the the last pixel! + + //blend four corners of current pixel + if (blendingNeeded(blend_xy)) //good 5% perf-improvement + { + Kernel_3x3 ker3 = {}; //perf: initialization is negligible + + ker3.a = ker4.a; + ker3.b = ker4.b; + ker3.c = ker4.c; + + ker3.d = ker4.e; + ker3.e = ker4.f; + ker3.f = ker4.g; + + ker3.g = ker4.i; + ker3.h = ker4.j; + ker3.i = ker4.k; + + blendPixel(ker3, out, trgWidth, blend_xy, cfg); + blendPixel(ker3, out, trgWidth, blend_xy, cfg); + blendPixel(ker3, out, trgWidth, blend_xy, cfg); + blendPixel(ker3, out, trgWidth, blend_xy, cfg); + } + } + } +} + +//------------------------------------------------------------------------------------ + +template +struct Scaler2x : public ColorGradient +{ + static const int scale = 2; + + template //bring template function into scope for GCC + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) { ColorGradient::template alphaGrad(pixBack, pixFront); } + + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<1, 0>(), col); + alphaGrad<1, 4>(out.template ref<0, 1>(), col); + alphaGrad<5, 6>(out.template ref<1, 1>(), col); //[!] fixes 7/8 used in xBR + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 2>(out.template ref<1, 1>(), col); + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaGrad<21, 100>(out.template ref<1, 1>(), col); //exact: 1 - pi/4 = 0.2146018366 + } +}; + + +template +struct Scaler3x : public ColorGradient +{ + static const int scale = 3; + + template //bring template function into scope for GCC + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) { ColorGradient::template alphaGrad(pixBack, pixFront); } + + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + + alphaGrad<3, 4>(out.template ref(), col); + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + out.template ref<2, scale - 1>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<2, 0>(), col); + alphaGrad<1, 4>(out.template ref<0, 2>(), col); + alphaGrad<3, 4>(out.template ref<2, 1>(), col); + alphaGrad<3, 4>(out.template ref<1, 2>(), col); + out.template ref<2, 2>() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 8>(out.template ref<1, 2>(), col); //conflict with other rotations for this odd scale + alphaGrad<1, 8>(out.template ref<2, 1>(), col); + alphaGrad<7, 8>(out.template ref<2, 2>(), col); // + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaGrad<45, 100>(out.template ref<2, 2>(), col); //exact: 0.4545939598 + //alphaGrad<7, 256>(out.template ref<2, 1>(), col); //0.02826017254 -> negligible + avoid conflicts with other rotations for this odd scale + //alphaGrad<7, 256>(out.template ref<1, 2>(), col); //0.02826017254 + } +}; + + +template +struct Scaler4x : public ColorGradient +{ + static const int scale = 4; + + template //bring template function into scope for GCC + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) { ColorGradient::template alphaGrad(pixBack, pixFront); } + + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + + alphaGrad<3, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + alphaGrad<3, 4>(out.template ref<3, scale - 2>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<3, 4>(out.template ref<3, 1>(), col); + alphaGrad<3, 4>(out.template ref<1, 3>(), col); + alphaGrad<1, 4>(out.template ref<3, 0>(), col); + alphaGrad<1, 4>(out.template ref<0, 3>(), col); + + alphaGrad<1, 3>(out.template ref<2, 2>(), col); //[!] fixes 1/4 used in xBR + + out.template ref<3, 3>() = col; + out.template ref<3, 2>() = col; + out.template ref<2, 3>() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 2>(out.template ref(), col); + alphaGrad<1, 2>(out.template ref(), col); + out.template ref() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaGrad<68, 100>(out.template ref<3, 3>(), col); //exact: 0.6848532563 + alphaGrad< 9, 100>(out.template ref<3, 2>(), col); //0.08677704501 + alphaGrad< 9, 100>(out.template ref<2, 3>(), col); //0.08677704501 + } +}; + + +template +struct Scaler5x : public ColorGradient +{ + static const int scale = 5; + + template //bring template function into scope for GCC + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) { ColorGradient::template alphaGrad(pixBack, pixFront); } + + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + + alphaGrad<3, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + alphaGrad<1, 4>(out.template ref<4, scale - 3>(), col); + + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + alphaGrad<3, 4>(out.template ref<3, scale - 2>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<4, scale - 2>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + + alphaGrad<2, 3>(out.template ref<3, 3>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 8>(out.template ref(), col); //conflict with other rotations for this odd scale + alphaGrad<1, 8>(out.template ref(), col); + alphaGrad<1, 8>(out.template ref(), col); // + + alphaGrad<7, 8>(out.template ref<4, 3>(), col); + alphaGrad<7, 8>(out.template ref<3, 4>(), col); + + out.template ref<4, 4>() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaGrad<86, 100>(out.template ref<4, 4>(), col); //exact: 0.8631434088 + alphaGrad<23, 100>(out.template ref<4, 3>(), col); //0.2306749731 + alphaGrad<23, 100>(out.template ref<3, 4>(), col); //0.2306749731 + //alphaGrad<1, 64>(out.template ref<4, 2>(), col); //0.01676812367 -> negligible + avoid conflicts with other rotations for this odd scale + //alphaGrad<1, 64>(out.template ref<2, 4>(), col); //0.01676812367 + } +}; + + +template +struct Scaler6x : public ColorGradient +{ + static const int scale = 6; + + template //bring template function into scope for GCC + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) { ColorGradient::template alphaGrad(pixBack, pixFront); } + + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + + alphaGrad<3, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + alphaGrad<1, 4>(out.template ref<4, scale - 3>(), col); + + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + alphaGrad<3, 4>(out.template ref<3, scale - 2>(), col); + alphaGrad<3, 4>(out.template ref<5, scale - 3>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<5, scale - 1>() = col; + + out.template ref<4, scale - 2>() = col; + out.template ref<5, scale - 2>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 4>(out.template ref<0, scale - 1>(), col); + alphaGrad<1, 4>(out.template ref<2, scale - 2>(), col); + alphaGrad<3, 4>(out.template ref<1, scale - 1>(), col); + alphaGrad<3, 4>(out.template ref<3, scale - 2>(), col); + + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<1, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + alphaGrad<3, 4>(out.template ref(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<5, scale - 1>() = col; + + out.template ref<4, scale - 2>() = col; + out.template ref<5, scale - 2>() = col; + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaGrad<1, 2>(out.template ref(), col); + alphaGrad<1, 2>(out.template ref(), col); + alphaGrad<1, 2>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaGrad<97, 100>(out.template ref<5, 5>(), col); //exact: 0.9711013910 + alphaGrad<42, 100>(out.template ref<4, 5>(), col); //0.4236372243 + alphaGrad<42, 100>(out.template ref<5, 4>(), col); //0.4236372243 + alphaGrad< 6, 100>(out.template ref<5, 3>(), col); //0.05652034508 + alphaGrad< 6, 100>(out.template ref<3, 5>(), col); //0.05652034508 + } +}; + +//------------------------------------------------------------------------------------ + +struct ColorDistanceRGB +{ + static double dist(uint32_t pix1, uint32_t pix2, double luminanceWeight) + { + return DistYCbCrBuffer::dist(pix1, pix2); + + //if (pix1 == pix2) //about 4% perf boost + // return 0; + //return distYCbCr(pix1, pix2, luminanceWeight); + } +}; + +struct ColorDistanceARGB +{ + static double dist(uint32_t pix1, uint32_t pix2, double luminanceWeight) + { + const double a1 = getAlpha(pix1) / 255.0 ; + const double a2 = getAlpha(pix2) / 255.0 ; + /* + Requirements for a color distance handling alpha channel: with a1, a2 in [0, 1] + + 1. if a1 = a2, distance should be: a1 * distYCbCr() + 2. if a1 = 0, distance should be: a2 * distYCbCr(black, white) = a2 * 255 + 3. if a1 = 1, ??? maybe: 255 * (1 - a2) + a2 * distYCbCr() + */ + + //return std::min(a1, a2) * DistYCbCrBuffer::dist(pix1, pix2) + 255 * abs(a1 - a2); + //=> following code is 15% faster: + const double d = DistYCbCrBuffer::dist(pix1, pix2); + if (a1 < a2) + return a1 * d + 255 * (a2 - a1); + else + return a2 * d + 255 * (a1 - a2); + + //alternative? return std::sqrt(a1 * a2 * square(DistYCbCrBuffer::dist(pix1, pix2)) + square(255 * (a1 - a2))); + } +}; + + +struct ColorGradientRGB +{ + template + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) + { + pixBack = gradientRGB(pixFront, pixBack); + } +}; + +struct ColorGradientARGB +{ + template + static void alphaGrad(uint32_t& pixBack, uint32_t pixFront) + { + pixBack = gradientARGB(pixFront, pixBack); + } +}; +} + + +void xbrz::scale(size_t factor, const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, ColorFormat colFmt, const xbrz::ScalerCfg& cfg, int yFirst, int yLast) +{ + switch (colFmt) + { + case ARGB: + switch (factor) + { + case 2: + return scaleImage, ColorDistanceARGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 3: + return scaleImage, ColorDistanceARGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 4: + return scaleImage, ColorDistanceARGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 5: + return scaleImage, ColorDistanceARGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 6: + return scaleImage, ColorDistanceARGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + } + break; + + case RGB: + switch (factor) + { + case 2: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 3: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 4: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 5: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 6: + return scaleImage, ColorDistanceRGB>(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + } + break; + } + assert(false); +} + + +bool xbrz::equalColorTest(uint32_t col1, uint32_t col2, ColorFormat colFmt, double luminanceWeight, double equalColorTolerance) +{ + switch (colFmt) + { + case ARGB: + return ColorDistanceARGB::dist(col1, col2, luminanceWeight) < equalColorTolerance; + + case RGB: + return ColorDistanceRGB::dist(col1, col2, luminanceWeight) < equalColorTolerance; + } + assert(false); + return false; +} + + +void xbrz::nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, int srcPitch, + uint32_t* trg, int trgWidth, int trgHeight, int trgPitch, + SliceType st, int yFirst, int yLast) +{ + if (srcPitch < srcWidth * static_cast(sizeof(uint32_t)) || + trgPitch < trgWidth * static_cast(sizeof(uint32_t))) + { + assert(false); + return; + } + + switch (st) + { + case NN_SCALE_SLICE_SOURCE: + //nearest-neighbor (going over source image - fast for upscaling, since source is read only once + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, srcHeight); + if (yFirst >= yLast || trgWidth <= 0 || trgHeight <= 0) return; + + for (int y = yFirst; y < yLast; ++y) + { + //mathematically: ySrc = floor(srcHeight * yTrg / trgHeight) + // => search for integers in: [ySrc, ySrc + 1) * trgHeight / srcHeight + + //keep within for loop to support MT input slices! + const int yTrg_first = ( y * trgHeight + srcHeight - 1) / srcHeight; //=ceil(y * trgHeight / srcHeight) + const int yTrg_last = ((y + 1) * trgHeight + srcHeight - 1) / srcHeight; //=ceil(((y + 1) * trgHeight) / srcHeight) + const int blockHeight = yTrg_last - yTrg_first; + + if (blockHeight > 0) + { + const uint32_t* srcLine = byteAdvance(src, y * srcPitch); + uint32_t* trgLine = byteAdvance(trg, yTrg_first * trgPitch); + int xTrg_first = 0; + + for (int x = 0; x < srcWidth; ++x) + { + int xTrg_last = ((x + 1) * trgWidth + srcWidth - 1) / srcWidth; + const int blockWidth = xTrg_last - xTrg_first; + if (blockWidth > 0) + { + xTrg_first = xTrg_last; + fillBlock(trgLine, trgPitch, srcLine[x], blockWidth, blockHeight); + trgLine += blockWidth; + } + } + } + } + break; + + case NN_SCALE_SLICE_TARGET: + //nearest-neighbor (going over target image - slow for upscaling, since source is read multiple times missing out on cache! Fast for similar image sizes!) + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, trgHeight); + if (yFirst >= yLast || srcHeight <= 0 || srcWidth <= 0) return; + + for (int y = yFirst; y < yLast; ++y) + { + uint32_t* trgLine = byteAdvance(trg, y * trgPitch); + const int ySrc = srcHeight * y / trgHeight; + const uint32_t* srcLine = byteAdvance(src, ySrc * srcPitch); + for (int x = 0; x < trgWidth; ++x) + { + const int xSrc = srcWidth * x / trgWidth; + trgLine[x] = srcLine[xSrc]; + } + } + break; + } +} diff --git a/src/gl/xbr/xbrz.h b/src/gl/xbr/xbrz.h new file mode 100644 index 000000000..c641429e5 --- /dev/null +++ b/src/gl/xbr/xbrz.h @@ -0,0 +1,102 @@ +// **************************************************************************** +// * This file is part of the HqMAME project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// * * +// * Additionally and as a special exception, the author gives permission * +// * to link the code of this program with the MAME library (or with modified * +// * versions of MAME that use the same license as MAME), and distribute * +// * linked combinations including the two. You must obey the GNU General * +// * Public License in all respects for all of the code used other than MAME. * +// * If you modify this file, you may extend this exception to your version * +// * of the file, but you are not obligated to do so. If you do not wish to * +// * do so, delete this exception statement from your version. * +// * * +// * An explicit permission was granted to use xBRZ in combination with ZDoom * +// * and derived projects as long as it is used for non-commercial purposes. * +// * * +// * Backported to C++98 by Alexey Lysiuk * +// **************************************************************************** + +#ifndef XBRZ_HEADER_3847894708239054 +#define XBRZ_HEADER_3847894708239054 + +#include //size_t +#include //uint32_t +#include +#include "xbrz_config.h" + +namespace xbrz +{ +/* +------------------------------------------------------------------------- +| xBRZ: "Scale by rules" - high quality image upscaling filter by Zenju | +------------------------------------------------------------------------- +using a modified approach of xBR: +http://board.byuu.org/viewtopic.php?f=10&t=2248 +- new rule set preserving small image features +- highly optimized for performance +- support alpha channel +- support multithreading +- support 64-bit architectures +- support processing image slices +- support scaling up to 6xBRZ +*/ + +enum ColorFormat //from high bits -> low bits, 8 bit per channel +{ + RGB, //8 bit for each red, green, blue, upper 8 bits unused + ARGB, //including alpha channel, BGRA byte order on little-endian machines +}; + +/* +-> map source (srcWidth * srcHeight) to target (scale * width x scale * height) image, optionally processing a half-open slice of rows [yFirst, yLast) only +-> support for source/target pitch in bytes! +-> if your emulator changes only a few image slices during each cycle (e.g. DOSBox) then there's no need to run xBRZ on the complete image: + Just make sure you enlarge the source image slice by 2 rows on top and 2 on bottom (this is the additional range the xBRZ algorithm is using during analysis) + Caveat: If there are multiple changed slices, make sure they do not overlap after adding these additional rows in order to avoid a memory race condition + in the target image data if you are using multiple threads for processing each enlarged slice! + +THREAD-SAFETY: - parts of the same image may be scaled by multiple threads as long as the [yFirst, yLast) ranges do not overlap! + - there is a minor inefficiency for the first row of a slice, so avoid processing single rows only; suggestion: process 8-16 rows at least +*/ +#ifdef max +#undef max +#endif +void scale(size_t factor, //valid range: 2 - 6 + const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, + ColorFormat colFmt, + const ScalerCfg& cfg = ScalerCfg(), + int yFirst = 0, int yLast = std::numeric_limits::max()); //slice of source image + +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, + uint32_t* trg, int trgWidth, int trgHeight); + +enum SliceType +{ + NN_SCALE_SLICE_SOURCE, + NN_SCALE_SLICE_TARGET, +}; +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, int srcPitch, //pitch in bytes! + uint32_t* trg, int trgWidth, int trgHeight, int trgPitch, + SliceType st, int yFirst, int yLast); + +//parameter tuning +bool equalColorTest(uint32_t col1, uint32_t col2, ColorFormat colFmt, double luminanceWeight, double equalColorTolerance); + + + + + +//########################### implementation ########################### +inline +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, + uint32_t* trg, int trgWidth, int trgHeight) +{ + nearestNeighborScale(src, srcWidth, srcHeight, srcWidth * sizeof(uint32_t), + trg, trgWidth, trgHeight, trgWidth * sizeof(uint32_t), + NN_SCALE_SLICE_TARGET, 0, trgHeight); +} +} + +#endif diff --git a/src/gl/xbr/xbrz_config.h b/src/gl/xbr/xbrz_config.h new file mode 100644 index 000000000..28e9e9044 --- /dev/null +++ b/src/gl/xbr/xbrz_config.h @@ -0,0 +1,45 @@ +// **************************************************************************** +// * This file is part of the HqMAME project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// * * +// * Additionally and as a special exception, the author gives permission * +// * to link the code of this program with the MAME library (or with modified * +// * versions of MAME that use the same license as MAME), and distribute * +// * linked combinations including the two. You must obey the GNU General * +// * Public License in all respects for all of the code used other than MAME. * +// * If you modify this file, you may extend this exception to your version * +// * of the file, but you are not obligated to do so. If you do not wish to * +// * do so, delete this exception statement from your version. * +// * * +// * An explicit permission was granted to use xBRZ in combination with ZDoom * +// * and derived projects as long as it is used for non-commercial purposes. * +// * * +// * Backported to C++98 by Alexey Lysiuk * +// **************************************************************************** + +#ifndef XBRZ_CONFIG_HEADER_284578425345 +#define XBRZ_CONFIG_HEADER_284578425345 + +//do NOT include any headers here! used by xBRZ_dll!!! + +namespace xbrz +{ +struct ScalerCfg +{ + ScalerCfg() : + luminanceWeight(1), + equalColorTolerance(30), + dominantDirectionThreshold(3.6), + steepDirectionThreshold(2.2), + newTestAttribute(0) {} + + double luminanceWeight; + double equalColorTolerance; + double dominantDirectionThreshold; + double steepDirectionThreshold; + double newTestAttribute; //unused; test new parameters +}; +} + +#endif \ No newline at end of file diff --git a/src/gl/xbr/xbrz_config_old.h b/src/gl/xbr/xbrz_config_old.h new file mode 100644 index 000000000..480af7976 --- /dev/null +++ b/src/gl/xbr/xbrz_config_old.h @@ -0,0 +1,45 @@ +// **************************************************************************** +// * This file is part of the HqMAME project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// * * +// * Additionally and as a special exception, the author gives permission * +// * to link the code of this program with the MAME library (or with modified * +// * versions of MAME that use the same license as MAME), and distribute * +// * linked combinations including the two. You must obey the GNU General * +// * Public License in all respects for all of the code used other than MAME. * +// * If you modify this file, you may extend this exception to your version * +// * of the file, but you are not obligated to do so. If you do not wish to * +// * do so, delete this exception statement from your version. * +// * * +// * An explicit permission was granted to use xBRZ in combination with ZDoom * +// * and derived projects as long as it is used for non-commercial purposes. * +// * * +// * Backported to C++98 by Alexey Lysiuk * +// **************************************************************************** + +#ifndef __XBRZ_CONFIG_OLD_HEADER_INCLUDED__ +#define __XBRZ_CONFIG_OLD_HEADER_INCLUDED__ + +//do NOT include any headers here! used by xBRZ_dll!!! + +namespace xbrz_old +{ +struct ScalerCfg +{ + ScalerCfg() : + luminanceWeight_(1), + equalColorTolerance_(30), + dominantDirectionThreshold(3.6), + steepDirectionThreshold(2.2), + newTestAttribute_(0) {} + + double luminanceWeight_; + double equalColorTolerance_; + double dominantDirectionThreshold; + double steepDirectionThreshold; + double newTestAttribute_; //unused; test new parameters +}; +} + +#endif \ No newline at end of file diff --git a/src/gl/xbr/xbrz_old.cpp b/src/gl/xbr/xbrz_old.cpp new file mode 100644 index 000000000..07527cb95 --- /dev/null +++ b/src/gl/xbr/xbrz_old.cpp @@ -0,0 +1,1365 @@ +// **************************************************************************** +// * This file is part of the HqMAME project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// * * +// * Additionally and as a special exception, the author gives permission * +// * to link the code of this program with the MAME library (or with modified * +// * versions of MAME that use the same license as MAME), and distribute * +// * linked combinations including the two. You must obey the GNU General * +// * Public License in all respects for all of the code used other than MAME. * +// * If you modify this file, you may extend this exception to your version * +// * of the file, but you are not obligated to do so. If you do not wish to * +// * do so, delete this exception statement from your version. * +// * * +// * An explicit permission was granted to use xBRZ in combination with ZDoom * +// * and derived projects as long as it is used for non-commercial purposes. * +// * * +// * Backported to C++98 by Alexey Lysiuk * +// **************************************************************************** + +#include "xbrz_old.h" + +#include +#include +#include + +#if __cplusplus > 199711 +#define XBRZ_CXX11 +#endif // __cplusplus > 199711 + +namespace +{ +template inline +unsigned char getByte(uint32_t val) { return static_cast((val >> (8 * N)) & 0xff); } + +inline unsigned char getRed (uint32_t val) { return getByte<2>(val); } +inline unsigned char getGreen(uint32_t val) { return getByte<1>(val); } +inline unsigned char getBlue (uint32_t val) { return getByte<0>(val); } + +template inline +T abs(T value) +{ +#ifdef XBRZ_CXX11 + static_assert(std::numeric_limits::is_signed, ""); +#endif // XBRZ_CXX11 + return value < 0 ? -value : value; +} + +const uint32_t redMask = 0xff0000; +const uint32_t greenMask = 0x00ff00; +const uint32_t blueMask = 0x0000ff; + +template inline +void alphaBlend(uint32_t& dst, uint32_t col) //blend color over destination with opacity N / M +{ +#ifdef XBRZ_CXX11 + static_assert(N < 256, "possible overflow of (col & redMask) * N"); + static_assert(M < 256, "possible overflow of (col & redMask ) * N + (dst & redMask ) * (M - N)"); + static_assert(0 < N && N < M, ""); +#endif // XBRZ_CXX11 + + static const uint32_t ALPHA_MASK = 0xFF000000; + static const uint32_t ALPHA_SHIFT = 24; + + static const uint32_t FULL_OPAQUE = 0xFF; + + const uint32_t colAlpha = col >> ALPHA_SHIFT; + const uint32_t dstAlpha = dst >> ALPHA_SHIFT; + + // Overflow is ignored intentionally! + + const uint32_t alpha = (FULL_OPAQUE == colAlpha && FULL_OPAQUE == dstAlpha) + ? ALPHA_MASK + : ALPHA_MASK & ((colAlpha * N + dstAlpha * (M - N)) / M << ALPHA_SHIFT); + + dst = (redMask & ((col & redMask ) * N + (dst & redMask ) * (M - N)) / M) | //this works because 8 upper bits are free + (greenMask & ((col & greenMask) * N + (dst & greenMask) * (M - N)) / M) | + (blueMask & ((col & blueMask ) * N + (dst & blueMask ) * (M - N)) / M) | + alpha; +} + + +//inline +//double fastSqrt(double n) +//{ +// __asm //speeds up xBRZ by about 9% compared to std::sqrt +// { +// fld n +// fsqrt +// } +//} +// + + +inline +uint32_t alphaBlend2(uint32_t pix1, uint32_t pix2, double alpha) +{ + return (redMask & static_cast((pix1 & redMask ) * alpha + (pix2 & redMask ) * (1 - alpha))) | + (greenMask & static_cast((pix1 & greenMask) * alpha + (pix2 & greenMask) * (1 - alpha))) | + (blueMask & static_cast((pix1 & blueMask ) * alpha + (pix2 & blueMask ) * (1 - alpha))); +} + + +uint32_t* byteAdvance( uint32_t* ptr, int bytes) { return reinterpret_cast< uint32_t*>(reinterpret_cast< char*>(ptr) + bytes); } +const uint32_t* byteAdvance(const uint32_t* ptr, int bytes) { return reinterpret_cast(reinterpret_cast(ptr) + bytes); } + + +//fill block with the given color +inline +void fillBlock(uint32_t* trg, int pitch, uint32_t col, int blockWidth, int blockHeight) +{ + //for (int y = 0; y < blockHeight; ++y, trg = byteAdvance(trg, pitch)) + // std::fill(trg, trg + blockWidth, col); + + for (int y = 0; y < blockHeight; ++y, trg = byteAdvance(trg, pitch)) + for (int x = 0; x < blockWidth; ++x) + trg[x] = col; +} + +inline +void fillBlock(uint32_t* trg, int pitch, uint32_t col, int n) { fillBlock(trg, pitch, col, n, n); } + + +#ifdef _MSC_VER +#define FORCE_INLINE __forceinline +#elif defined __GNUC__ +#define FORCE_INLINE __attribute__((always_inline)) inline +#else +#define FORCE_INLINE inline +#endif + + +enum RotationDegree //clock-wise +{ + ROT_0, + ROT_90, + ROT_180, + ROT_270 +}; + +//calculate input matrix coordinates after rotation at compile time +template +struct MatrixRotation; + +template +struct MatrixRotation +{ + static const size_t I_old = I; + static const size_t J_old = J; +}; + +template //(i, j) = (row, col) indices, N = size of (square) matrix +struct MatrixRotation +{ + static const size_t I_old = N - 1 - MatrixRotation(rotDeg - 1), I, J, N>::J_old; //old coordinates before rotation! + static const size_t J_old = MatrixRotation(rotDeg - 1), I, J, N>::I_old; // +}; + + +template +class OutputMatrix +{ +public: + OutputMatrix(uint32_t* out, int outWidth) : //access matrix area, top-left at position "out" for image with given width + out_(out), + outWidth_(outWidth) {} + + template + uint32_t& ref() const + { + static const size_t I_old = MatrixRotation::I_old; + static const size_t J_old = MatrixRotation::J_old; + return *(out_ + J_old + I_old * outWidth_); + } + +private: + uint32_t* out_; + const int outWidth_; +}; + + +template inline +T square(T value) { return value * value; } + + +/* +inline +void rgbtoLuv(uint32_t c, double& L, double& u, double& v) +{ + //http://www.easyrgb.com/index.php?X=MATH&H=02#text2 + double r = getRed (c) / 255.0; + double g = getGreen(c) / 255.0; + double b = getBlue (c) / 255.0; + + if ( r > 0.04045 ) + r = std::pow(( ( r + 0.055 ) / 1.055 ) , 2.4); + else + r /= 12.92; + if ( g > 0.04045 ) + g = std::pow(( ( g + 0.055 ) / 1.055 ) , 2.4); + else + g /= 12.92; + if ( b > 0.04045 ) + b = std::pow(( ( b + 0.055 ) / 1.055 ) , 2.4); + else + b /= 12.92; + + r *= 100; + g *= 100; + b *= 100; + + double x = 0.4124564 * r + 0.3575761 * g + 0.1804375 * b; + double y = 0.2126729 * r + 0.7151522 * g + 0.0721750 * b; + double z = 0.0193339 * r + 0.1191920 * g + 0.9503041 * b; + //--------------------- + double var_U = 4 * x / ( x + 15 * y + 3 * z ); + double var_V = 9 * y / ( x + 15 * y + 3 * z ); + double var_Y = y / 100; + + if ( var_Y > 0.008856 ) var_Y = std::pow(var_Y , 1.0/3 ); + else var_Y = 7.787 * var_Y + 16.0 / 116; + + const double ref_X = 95.047; //Observer= 2 degree, Illuminant= D65 + const double ref_Y = 100.000; + const double ref_Z = 108.883; + + const double ref_U = ( 4 * ref_X ) / ( ref_X + ( 15 * ref_Y ) + ( 3 * ref_Z ) ); + const double ref_V = ( 9 * ref_Y ) / ( ref_X + ( 15 * ref_Y ) + ( 3 * ref_Z ) ); + + L = ( 116 * var_Y ) - 16; + u = 13 * L * ( var_U - ref_U ); + v = 13 * L * ( var_V - ref_V ); +} +*/ + +inline +void rgbtoLab(uint32_t c, unsigned char& L, signed char& A, signed char& B) +{ + //code: http://www.easyrgb.com/index.php?X=MATH + //test: http://www.workwithcolor.com/color-converter-01.htm + //------RGB to XYZ------ + double r = getRed (c) / 255.0; + double g = getGreen(c) / 255.0; + double b = getBlue (c) / 255.0; + + r = r > 0.04045 ? std::pow(( r + 0.055 ) / 1.055, 2.4) : r / 12.92; + r = g > 0.04045 ? std::pow(( g + 0.055 ) / 1.055, 2.4) : g / 12.92; + r = b > 0.04045 ? std::pow(( b + 0.055 ) / 1.055, 2.4) : b / 12.92; + + r *= 100; + g *= 100; + b *= 100; + + double x = 0.4124564 * r + 0.3575761 * g + 0.1804375 * b; + double y = 0.2126729 * r + 0.7151522 * g + 0.0721750 * b; + double z = 0.0193339 * r + 0.1191920 * g + 0.9503041 * b; + //------XYZ to Lab------ + const double refX = 95.047; // + const double refY = 100.000; //Observer= 2 degree, Illuminant= D65 + const double refZ = 108.883; // + double var_X = x / refX; + double var_Y = y / refY; + double var_Z = z / refZ; + + var_X = var_X > 0.008856 ? std::pow(var_X, 1.0 / 3) : 7.787 * var_X + 4.0 / 29; + var_Y = var_Y > 0.008856 ? std::pow(var_Y, 1.0 / 3) : 7.787 * var_Y + 4.0 / 29; + var_Z = var_Z > 0.008856 ? std::pow(var_Z, 1.0 / 3) : 7.787 * var_Z + 4.0 / 29; + + L = static_cast(116 * var_Y - 16); + A = static_cast< signed char>(500 * (var_X - var_Y)); + B = static_cast< signed char>(200 * (var_Y - var_Z)); +}; + + +inline +double distLAB(uint32_t pix1, uint32_t pix2) +{ + unsigned char L1 = 0; //[0, 100] + signed char a1 = 0; //[-128, 127] + signed char b1 = 0; //[-128, 127] + rgbtoLab(pix1, L1, a1, b1); + + unsigned char L2 = 0; + signed char a2 = 0; + signed char b2 = 0; + rgbtoLab(pix2, L2, a2, b2); + + //----------------------------- + //http://www.easyrgb.com/index.php?X=DELT + + //Delta E/CIE76 + return std::sqrt(square(1.0 * L1 - L2) + + square(1.0 * a1 - a2) + + square(1.0 * b1 - b2)); +} + + +/* +inline +void rgbtoHsl(uint32_t c, double& h, double& s, double& l) +{ + //http://www.easyrgb.com/index.php?X=MATH&H=18#text18 + const int r = getRed (c); + const int g = getGreen(c); + const int b = getBlue (c); + + const int varMin = numeric::min(r, g, b); + const int varMax = numeric::max(r, g, b); + const int delMax = varMax - varMin; + + l = (varMax + varMin) / 2.0 / 255.0; + + if (delMax == 0) //gray, no chroma... + { + h = 0; + s = 0; + } + else + { + s = l < 0.5 ? + delMax / (1.0 * varMax + varMin) : + delMax / (2.0 * 255 - varMax - varMin); + + double delR = ((varMax - r) / 6.0 + delMax / 2.0) / delMax; + double delG = ((varMax - g) / 6.0 + delMax / 2.0) / delMax; + double delB = ((varMax - b) / 6.0 + delMax / 2.0) / delMax; + + if (r == varMax) + h = delB - delG; + else if (g == varMax) + h = 1 / 3.0 + delR - delB; + else if (b == varMax) + h = 2 / 3.0 + delG - delR; + + if (h < 0) + h += 1; + if (h > 1) + h -= 1; + } +} + +inline +double distHSL(uint32_t pix1, uint32_t pix2, double lightningWeight) +{ + double h1 = 0; + double s1 = 0; + double l1 = 0; + rgbtoHsl(pix1, h1, s1, l1); + double h2 = 0; + double s2 = 0; + double l2 = 0; + rgbtoHsl(pix2, h2, s2, l2); + + //HSL is in cylindric coordinatates where L represents height, S radius, H angle, + //however we interpret the cylinder as a bi-conic solid with top/bottom radius 0, middle radius 1 + assert(0 <= h1 && h1 <= 1); + assert(0 <= h2 && h2 <= 1); + + double r1 = l1 < 0.5 ? + l1 * 2 : + 2 - l1 * 2; + + double x1 = r1 * s1 * std::cos(h1 * 2 * numeric::pi); + double y1 = r1 * s1 * std::sin(h1 * 2 * numeric::pi); + double z1 = l1; + + double r2 = l2 < 0.5 ? + l2 * 2 : + 2 - l2 * 2; + + double x2 = r2 * s2 * std::cos(h2 * 2 * numeric::pi); + double y2 = r2 * s2 * std::sin(h2 * 2 * numeric::pi); + double z2 = l2; + + return 255 * std::sqrt(square(x1 - x2) + square(y1 - y2) + square(lightningWeight * (z1 - z2))); +} +*/ + + +inline +double distRGB(uint32_t pix1, uint32_t pix2) +{ + const double r_diff = static_cast(getRed (pix1)) - getRed (pix2); + const double g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); + const double b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); + + //euklidean RGB distance + return std::sqrt(square(r_diff) + square(g_diff) + square(b_diff)); +} + + +inline +double distNonLinearRGB(uint32_t pix1, uint32_t pix2) +{ + //non-linear rgb: http://www.compuphase.com/cmetric.htm + const double r_diff = static_cast(getRed (pix1)) - getRed (pix2); + const double g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); + const double b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); + + const double r_avg = (static_cast(getRed(pix1)) + getRed(pix2)) / 2; + return std::sqrt((2 + r_avg / 255) * square(r_diff) + 4 * square(g_diff) + (2 + (255 - r_avg) / 255) * square(b_diff)); +} + + +inline +double distYCbCr(uint32_t pix1, uint32_t pix2, double lumaWeight) +{ + //http://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.601_conversion + //YCbCr conversion is a matrix multiplication => take advantage of linearity by subtracting first! + const int r_diff = static_cast(getRed (pix1)) - getRed (pix2); //we may delay division by 255 to after matrix multiplication + const int g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); // + const int b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); //substraction for int is noticeable faster than for double! + + const double k_b = 0.0722; //ITU-R BT.709 conversion + const double k_r = 0.2126; // + const double k_g = 1 - k_b - k_r; + + const double scale_b = 0.5 / (1 - k_b); + const double scale_r = 0.5 / (1 - k_r); + + const double y = k_r * r_diff + k_g * g_diff + k_b * b_diff; //[!], analog YCbCr! + const double c_b = scale_b * (b_diff - y); + const double c_r = scale_r * (r_diff - y); + + //we skip division by 255 to have similar range like other distance functions + return std::sqrt(square(lumaWeight * y) + square(c_b) + square(c_r)); +} + + +inline +double distYUV(uint32_t pix1, uint32_t pix2, double luminanceWeight) +{ + //perf: it's not worthwhile to buffer the YUV-conversion, the direct code is faster by ~ 6% + //since RGB -> YUV conversion is essentially a matrix multiplication, we can calculate the RGB diff before the conversion (distributive property) + const double r_diff = static_cast(getRed (pix1)) - getRed (pix2); + const double g_diff = static_cast(getGreen(pix1)) - getGreen(pix2); + const double b_diff = static_cast(getBlue (pix1)) - getBlue (pix2); + + //http://en.wikipedia.org/wiki/YUV#Conversion_to.2Ffrom_RGB + const double w_b = 0.114; + const double w_r = 0.299; + const double w_g = 1 - w_r - w_b; + + const double u_max = 0.436; + const double v_max = 0.615; + + const double scale_u = u_max / (1 - w_b); + const double scale_v = v_max / (1 - w_r); + + double y = w_r * r_diff + w_g * g_diff + w_b * b_diff;//value range: 255 * [-1, 1] + double u = scale_u * (b_diff - y); //value range: 255 * 2 * u_max * [-1, 1] + double v = scale_v * (r_diff - y); //value range: 255 * 2 * v_max * [-1, 1] + +#ifndef NDEBUG + const double eps = 0.5; +#endif + assert(std::abs(y) <= 255 + eps); + assert(std::abs(u) <= 255 * 2 * u_max + eps); + assert(std::abs(v) <= 255 * 2 * v_max + eps); + + return std::sqrt(square(luminanceWeight * y) + square(u) + square(v)); +} + + +inline +double colorDist(uint32_t pix1, uint32_t pix2, double luminanceWeight) +{ + if (pix1 == pix2) //about 8% perf boost + return 0; + + //return distHSL(pix1, pix2, luminanceWeight); + //return distRGB(pix1, pix2); + //return distLAB(pix1, pix2); + //return distNonLinearRGB(pix1, pix2); + //return distYUV(pix1, pix2, luminanceWeight); + + return distYCbCr(pix1, pix2, luminanceWeight); +} + + +enum BlendType +{ + BLEND_NONE = 0, + BLEND_NORMAL, //a normal indication to blend + BLEND_DOMINANT, //a strong indication to blend + //attention: BlendType must fit into the value range of 2 bit!!! +}; + +struct BlendResult +{ + BlendType + /**/blend_f, blend_g, + /**/blend_j, blend_k; +}; + + +struct Kernel_4x4 //kernel for preprocessing step +{ + uint32_t + /**/a, b, c, d, + /**/e, f, g, h, + /**/i, j, k, l, + /**/m, n, o, p; +}; + +/* +input kernel area naming convention: +----------------- +| A | B | C | D | +----|---|---|---| +| E | F | G | H | //evalute the four corners between F, G, J, K +----|---|---|---| //input pixel is at position F +| I | J | K | L | +----|---|---|---| +| M | N | O | P | +----------------- +*/ +FORCE_INLINE //detect blend direction +BlendResult preProcessCorners(const Kernel_4x4& ker, const xbrz_old::ScalerCfg& cfg) //result: F, G, J, K corners of "GradientType" +{ + BlendResult result = {}; + + if ((ker.f == ker.g && + ker.j == ker.k) || + (ker.f == ker.j && + ker.g == ker.k)) + return result; + +#ifdef XBRZ_CXX11 + auto dist = [&](uint32_t col1, uint32_t col2) { return colorDist(col1, col2, cfg.luminanceWeight_); }; +#else // !XBRZ_CXX11 +#define dist(C1, C2) colorDist((C1), (C2), cfg.luminanceWeight_) +#endif // XBRZ_CXX11 + + const int weight = 4; + double jg = dist(ker.i, ker.f) + dist(ker.f, ker.c) + dist(ker.n, ker.k) + dist(ker.k, ker.h) + weight * dist(ker.j, ker.g); + double fk = dist(ker.e, ker.j) + dist(ker.j, ker.o) + dist(ker.b, ker.g) + dist(ker.g, ker.l) + weight * dist(ker.f, ker.k); + +#ifndef XBRZ_CXX11 +#undef dist +#endif // !XBRZ_CXX11 + + if (jg < fk) //test sample: 70% of values max(jg, fk) / min(jg, fk) are between 1.1 and 3.7 with median being 1.8 + { + const bool dominantGradient = cfg.dominantDirectionThreshold * jg < fk; + if (ker.f != ker.g && ker.f != ker.j) + result.blend_f = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + + if (ker.k != ker.j && ker.k != ker.g) + result.blend_k = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + } + else if (fk < jg) + { + const bool dominantGradient = cfg.dominantDirectionThreshold * fk < jg; + if (ker.j != ker.f && ker.j != ker.k) + result.blend_j = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + + if (ker.g != ker.f && ker.g != ker.k) + result.blend_g = dominantGradient ? BLEND_DOMINANT : BLEND_NORMAL; + } + return result; +} + +struct Kernel_3x3 +{ + uint32_t + /**/a, b, c, + /**/d, e, f, + /**/g, h, i; +}; + +#define DEF_GETTER(x) template uint32_t inline get_##x(const Kernel_3x3& ker) { return ker.x; } +//we cannot and NEED NOT write "ker.##x" since ## concatenates preprocessor tokens but "." is not a token +DEF_GETTER(a) DEF_GETTER(b) DEF_GETTER(c) +DEF_GETTER(d) DEF_GETTER(e) DEF_GETTER(f) +DEF_GETTER(g) DEF_GETTER(h) DEF_GETTER(i) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, g) DEF_GETTER(b, d) DEF_GETTER(c, a) +DEF_GETTER(d, h) DEF_GETTER(e, e) DEF_GETTER(f, b) +DEF_GETTER(g, i) DEF_GETTER(h, f) DEF_GETTER(i, c) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, i) DEF_GETTER(b, h) DEF_GETTER(c, g) +DEF_GETTER(d, f) DEF_GETTER(e, e) DEF_GETTER(f, d) +DEF_GETTER(g, c) DEF_GETTER(h, b) DEF_GETTER(i, a) +#undef DEF_GETTER + +#define DEF_GETTER(x, y) template <> inline uint32_t get_##x(const Kernel_3x3& ker) { return ker.y; } +DEF_GETTER(a, c) DEF_GETTER(b, f) DEF_GETTER(c, i) +DEF_GETTER(d, b) DEF_GETTER(e, e) DEF_GETTER(f, h) +DEF_GETTER(g, a) DEF_GETTER(h, d) DEF_GETTER(i, g) +#undef DEF_GETTER + + +//compress four blend types into a single byte +inline BlendType getTopL (unsigned char b) { return static_cast(0x3 & b); } +inline BlendType getTopR (unsigned char b) { return static_cast(0x3 & (b >> 2)); } +inline BlendType getBottomR(unsigned char b) { return static_cast(0x3 & (b >> 4)); } +inline BlendType getBottomL(unsigned char b) { return static_cast(0x3 & (b >> 6)); } + +inline void setTopL (unsigned char& b, BlendType bt) { b |= bt; } //buffer is assumed to be initialized before preprocessing! +inline void setTopR (unsigned char& b, BlendType bt) { b |= (bt << 2); } +inline void setBottomR(unsigned char& b, BlendType bt) { b |= (bt << 4); } +inline void setBottomL(unsigned char& b, BlendType bt) { b |= (bt << 6); } + +inline bool blendingNeeded(unsigned char b) { return b != 0; } + +template inline +unsigned char rotateBlendInfo(unsigned char b) { return b; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 2) | (b >> 6)) & 0xff; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 4) | (b >> 4)) & 0xff; } +template <> inline unsigned char rotateBlendInfo(unsigned char b) { return ((b << 6) | (b >> 2)) & 0xff; } + + +#ifndef NDEBUG +int debugPixelX = -1; +int debugPixelY = 84; +bool breakIntoDebugger = false; +#endif + +#define a get_a(ker) +#define b get_b(ker) +#define c get_c(ker) +#define d get_d(ker) +#define e get_e(ker) +#define f get_f(ker) +#define g get_g(ker) +#define h get_h(ker) +#define i get_i(ker) + +#ifndef XBRZ_CXX11 + +template +bool doLineBlend(const Kernel_3x3& ker, const xbrz_old::ScalerCfg& cfg, const unsigned char blend) +{ + if (getBottomR(blend) >= BLEND_DOMINANT) + return true; + +#define eq(C1, C2) (colorDist((C1), (C2), cfg.luminanceWeight_) < cfg.equalColorTolerance_) + + //make sure there is no second blending in an adjacent rotation for this pixel: handles insular pixels, mario eyes + if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90 degree corners + return false; + if (getBottomL(blend) != BLEND_NONE && !eq(e, c)) + return false; + + //no full blending for L-shapes; blend corner only (handles "mario mushroom eyes") + if (eq(g, h) && eq(h , i) && eq(i, f) && eq(f, c) && !eq(e, i)) + return false; + +#undef eq + + return true; +}; + +#endif // !XBRZ_CXX11 + +/* +input kernel area naming convention: +------------- +| A | B | C | +----|---|---| +| D | E | F | //input pixel is at position E +----|---|---| +| G | H | I | +------------- +*/ +template +FORCE_INLINE //perf: quite worth it! +void scalePixel(const Kernel_3x3& ker, + uint32_t* target, int trgWidth, + unsigned char blendInfo, //result of preprocessing all four corners of pixel "e" + const xbrz_old::ScalerCfg& cfg) +{ +#ifndef NDEBUG + if (breakIntoDebugger) +#ifdef _MSC_VER + __debugbreak(); //__asm int 3; +#else // !_MSC_VER + __builtin_trap(); +#endif // _MSC_VER +#endif + + const unsigned char blend = rotateBlendInfo(blendInfo); + + if (getBottomR(blend) >= BLEND_NORMAL) + { +#ifdef XBRZ_CXX11 + auto eq = [&](uint32_t col1, uint32_t col2) { return colorDist(col1, col2, cfg.luminanceWeight_) < cfg.equalColorTolerance_; }; + auto dist = [&](uint32_t col1, uint32_t col2) { return colorDist(col1, col2, cfg.luminanceWeight_); }; + + const bool doLineBlend = [&]() -> bool + { + if (getBottomR(blend) >= BLEND_DOMINANT) + return true; + + //make sure there is no second blending in an adjacent rotation for this pixel: handles insular pixels, mario eyes + if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90 degree corners + return false; + if (getBottomL(blend) != BLEND_NONE && !eq(e, c)) + return false; + + //no full blending for L-shapes; blend corner only (handles "mario mushroom eyes") + if (eq(g, h) && eq(h , i) && eq(i, f) && eq(f, c) && !eq(e, i)) + return false; + + return true; + }(); +#else // !XBRZ_CXX11 +#define dist(C1, C2) colorDist((C1), (C2), cfg.luminanceWeight_) +#endif // XBRZ_CXX11 + + const uint32_t px = dist(e, f) <= dist(e, h) ? f : h; //choose most similar color + + OutputMatrix out(target, trgWidth); + +#ifdef XBRZ_CXX11 + if (doLineBlend) +#else // !XBRZ_CXX11 + if (doLineBlend(ker, cfg, blend)) +#endif // XBRZ_CXX11 + { + const double fg = dist(f, g); //test sample: 70% of values max(fg, hc) / min(fg, hc) are between 1.1 and 3.7 with median being 1.9 + const double hc = dist(h, c); // + + const bool haveShallowLine = cfg.steepDirectionThreshold * fg <= hc && e != g && d != g; + const bool haveSteepLine = cfg.steepDirectionThreshold * hc <= fg && e != c && b != c; + + if (haveShallowLine) + { + if (haveSteepLine) + Scaler::blendLineSteepAndShallow(px, out); + else + Scaler::blendLineShallow(px, out); + } + else + { + if (haveSteepLine) + Scaler::blendLineSteep(px, out); + else + Scaler::blendLineDiagonal(px,out); + } + } + else + Scaler::blendCorner(px, out); + } + +#ifndef XBRZ_CXX11 +#undef dist +#endif // XBRZ_CXX11 + +#undef a +#undef b +#undef c +#undef d +#undef e +#undef f +#undef g +#undef h +#undef i +} + + +template //scaler policy: see "Scaler2x" reference implementation +void scaleImage(const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz_old::ScalerCfg& cfg, int yFirst, int yLast) +{ + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, srcHeight); + if (yFirst >= yLast || srcWidth <= 0) + return; + + const int trgWidth = srcWidth * Scaler::scale; + + //"use" space at the end of the image as temporary buffer for "on the fly preprocessing": we even could use larger area of + //"sizeof(uint32_t) * srcWidth * (yLast - yFirst)" bytes without risk of accidental overwriting before accessing + const int bufferSize = srcWidth; + unsigned char* preProcBuffer = reinterpret_cast(trg + yLast * Scaler::scale * trgWidth) - bufferSize; + std::fill(preProcBuffer, preProcBuffer + bufferSize, 0); +#ifdef XBRZ_CXX11 + static_assert(BLEND_NONE == 0, ""); +#endif // XBRZ_CXX11 + + //initialize preprocessing buffer for first row: detect upper left and right corner blending + //this cannot be optimized for adjacent processing stripes; we must not allow for a memory race condition! + if (yFirst > 0) + { + const int y = yFirst - 1; + + const uint32_t* s_m1 = src + srcWidth * std::max(y - 1, 0); + const uint32_t* s_0 = src + srcWidth * y; //center line + const uint32_t* s_p1 = src + srcWidth * std::min(y + 1, srcHeight - 1); + const uint32_t* s_p2 = src + srcWidth * std::min(y + 2, srcHeight - 1); + + for (int x = 0; x < srcWidth; ++x) + { + const int x_m1 = std::max(x - 1, 0); + const int x_p1 = std::min(x + 1, srcWidth - 1); + const int x_p2 = std::min(x + 2, srcWidth - 1); + + Kernel_4x4 ker = {}; //perf: initialization is negligable + ker.a = s_m1[x_m1]; //read sequentially from memory as far as possible + ker.b = s_m1[x]; + ker.c = s_m1[x_p1]; + ker.d = s_m1[x_p2]; + + ker.e = s_0[x_m1]; + ker.f = s_0[x]; + ker.g = s_0[x_p1]; + ker.h = s_0[x_p2]; + + ker.i = s_p1[x_m1]; + ker.j = s_p1[x]; + ker.k = s_p1[x_p1]; + ker.l = s_p1[x_p2]; + + ker.m = s_p2[x_m1]; + ker.n = s_p2[x]; + ker.o = s_p2[x_p1]; + ker.p = s_p2[x_p2]; + + const BlendResult res = preProcessCorners(ker, cfg); + /* + preprocessing blend result: + --------- + | F | G | //evalute corner between F, G, J, K + ----|---| //input pixel is at position F + | J | K | + --------- + */ + setTopR(preProcBuffer[x], res.blend_j); + + if (x + 1 < srcWidth) + setTopL(preProcBuffer[x + 1], res.blend_k); + } + } + //------------------------------------------------------------------------------------ + + for (int y = yFirst; y < yLast; ++y) + { + uint32_t* out = trg + Scaler::scale * y * trgWidth; //consider MT "striped" access + + const uint32_t* s_m1 = src + srcWidth * std::max(y - 1, 0); + const uint32_t* s_0 = src + srcWidth * y; //center line + const uint32_t* s_p1 = src + srcWidth * std::min(y + 1, srcHeight - 1); + const uint32_t* s_p2 = src + srcWidth * std::min(y + 2, srcHeight - 1); + + unsigned char blend_xy1 = 0; //corner blending for current (x, y + 1) position + + for (int x = 0; x < srcWidth; ++x, out += Scaler::scale) + { +#ifndef NDEBUG + breakIntoDebugger = debugPixelX == x && debugPixelY == y; +#endif + //all those bounds checks have only insignificant impact on performance! + const int x_m1 = std::max(x - 1, 0); //perf: prefer array indexing to additional pointers! + const int x_p1 = std::min(x + 1, srcWidth - 1); + const int x_p2 = std::min(x + 2, srcWidth - 1); + + //evaluate the four corners on bottom-right of current pixel + unsigned char blend_xy = 0; //for current (x, y) position + { + Kernel_4x4 ker = {}; //perf: initialization is negligable + ker.a = s_m1[x_m1]; //read sequentially from memory as far as possible + ker.b = s_m1[x]; + ker.c = s_m1[x_p1]; + ker.d = s_m1[x_p2]; + + ker.e = s_0[x_m1]; + ker.f = s_0[x]; + ker.g = s_0[x_p1]; + ker.h = s_0[x_p2]; + + ker.i = s_p1[x_m1]; + ker.j = s_p1[x]; + ker.k = s_p1[x_p1]; + ker.l = s_p1[x_p2]; + + ker.m = s_p2[x_m1]; + ker.n = s_p2[x]; + ker.o = s_p2[x_p1]; + ker.p = s_p2[x_p2]; + + const BlendResult res = preProcessCorners(ker, cfg); + /* + preprocessing blend result: + --------- + | F | G | //evalute corner between F, G, J, K + ----|---| //current input pixel is at position F + | J | K | + --------- + */ + blend_xy = preProcBuffer[x]; + setBottomR(blend_xy, res.blend_f); //all four corners of (x, y) have been determined at this point due to processing sequence! + + setTopR(blend_xy1, res.blend_j); //set 2nd known corner for (x, y + 1) + preProcBuffer[x] = blend_xy1; //store on current buffer position for use on next row + + blend_xy1 = 0; + setTopL(blend_xy1, res.blend_k); //set 1st known corner for (x + 1, y + 1) and buffer for use on next column + + if (x + 1 < srcWidth) //set 3rd known corner for (x + 1, y) + setBottomL(preProcBuffer[x + 1], res.blend_g); + } + + //fill block of size scale * scale with the given color + fillBlock(out, trgWidth * sizeof(uint32_t), s_0[x], Scaler::scale); //place *after* preprocessing step, to not overwrite the results while processing the the last pixel! + + //blend four corners of current pixel + if (blendingNeeded(blend_xy)) //good 20% perf-improvement + { + Kernel_3x3 ker = {}; //perf: initialization is negligable + + ker.a = s_m1[x_m1]; //read sequentially from memory as far as possible + ker.b = s_m1[x]; + ker.c = s_m1[x_p1]; + + ker.d = s_0[x_m1]; + ker.e = s_0[x]; + ker.f = s_0[x_p1]; + + ker.g = s_p1[x_m1]; + ker.h = s_p1[x]; + ker.i = s_p1[x_p1]; + + scalePixel(ker, out, trgWidth, blend_xy, cfg); + scalePixel(ker, out, trgWidth, blend_xy, cfg); + scalePixel(ker, out, trgWidth, blend_xy, cfg); + scalePixel(ker, out, trgWidth, blend_xy, cfg); + } + } + } +} + + +struct Scaler2x +{ + static const int scale = 2; + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<1, 0>(), col); + alphaBlend<1, 4>(out.template ref<0, 1>(), col); + alphaBlend<5, 6>(out.template ref<1, 1>(), col); //[!] fixes 7/8 used in xBR + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 2>(out.template ref<1, 1>(), col); + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaBlend<21, 100>(out.template ref<1, 1>(), col); //exact: 1 - pi/4 = 0.2146018366 + } +}; + + +struct Scaler3x +{ + static const int scale = 3; + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + + alphaBlend<3, 4>(out.template ref(), col); + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + out.template ref<2, scale - 1>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<2, 0>(), col); + alphaBlend<1, 4>(out.template ref<0, 2>(), col); + alphaBlend<3, 4>(out.template ref<2, 1>(), col); + alphaBlend<3, 4>(out.template ref<1, 2>(), col); + out.template ref<2, 2>() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 8>(out.template ref<1, 2>(), col); + alphaBlend<1, 8>(out.template ref<2, 1>(), col); + alphaBlend<7, 8>(out.template ref<2, 2>(), col); + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaBlend<45, 100>(out.template ref<2, 2>(), col); //exact: 0.4545939598 + //alphaBlend<14, 1000>(out.template ref<2, 1>(), col); //0.01413008627 -> negligable + //alphaBlend<14, 1000>(out.template ref<1, 2>(), col); //0.01413008627 + } +}; + + +struct Scaler4x +{ + static const int scale = 4; + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + + alphaBlend<3, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + alphaBlend<3, 4>(out.template ref<3, scale - 2>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<3, 4>(out.template ref<3, 1>(), col); + alphaBlend<3, 4>(out.template ref<1, 3>(), col); + alphaBlend<1, 4>(out.template ref<3, 0>(), col); + alphaBlend<1, 4>(out.template ref<0, 3>(), col); + alphaBlend<1, 3>(out.template ref<2, 2>(), col); //[!] fixes 1/4 used in xBR + out.template ref<3, 3>() = out.template ref<3, 2>() = out.template ref<2, 3>() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 2>(out.template ref(), col); + alphaBlend<1, 2>(out.template ref(), col); + out.template ref() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaBlend<68, 100>(out.template ref<3, 3>(), col); //exact: 0.6848532563 + alphaBlend< 9, 100>(out.template ref<3, 2>(), col); //0.08677704501 + alphaBlend< 9, 100>(out.template ref<2, 3>(), col); //0.08677704501 + } +}; + + +struct Scaler5x +{ + static const int scale = 5; + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + + alphaBlend<3, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + alphaBlend<1, 4>(out.template ref<4, scale - 3>(), col); + + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + alphaBlend<3, 4>(out.template ref<3, scale - 2>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<4, scale - 2>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + + out.template ref() = col; + out.template ref() = col; + + out.template ref<4, scale - 1>() = col; + + alphaBlend<2, 3>(out.template ref<3, 3>(), col); + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 8>(out.template ref(), col); + alphaBlend<1, 8>(out.template ref(), col); + alphaBlend<1, 8>(out.template ref(), col); + + alphaBlend<7, 8>(out.template ref<4, 3>(), col); + alphaBlend<7, 8>(out.template ref<3, 4>(), col); + + out.template ref<4, 4>() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaBlend<86, 100>(out.template ref<4, 4>(), col); //exact: 0.8631434088 + alphaBlend<23, 100>(out.template ref<4, 3>(), col); //0.2306749731 + alphaBlend<23, 100>(out.template ref<3, 4>(), col); //0.2306749731 + //alphaBlend<8, 1000>(out.template ref<4, 2>(), col); //0.008384061834 -> negligable + //alphaBlend<8, 1000>(out.template ref<2, 4>(), col); //0.008384061834 + } +}; +} + + +struct Scaler6x +{ + static const int scale = 6; + + template + static void blendLineShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + + alphaBlend<3, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineSteep(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + alphaBlend<1, 4>(out.template ref<4, scale - 3>(), col); + + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + alphaBlend<3, 4>(out.template ref<3, scale - 2>(), col); + alphaBlend<3, 4>(out.template ref<5, scale - 3>(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<5, scale - 1>() = col; + + out.template ref<4, scale - 2>() = col; + out.template ref<5, scale - 2>() = col; + } + + template + static void blendLineSteepAndShallow(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 4>(out.template ref<0, scale - 1>(), col); + alphaBlend<1, 4>(out.template ref<2, scale - 2>(), col); + alphaBlend<3, 4>(out.template ref<1, scale - 1>(), col); + alphaBlend<3, 4>(out.template ref<3, scale - 2>(), col); + + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<1, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + alphaBlend<3, 4>(out.template ref(), col); + + out.template ref<2, scale - 1>() = col; + out.template ref<3, scale - 1>() = col; + out.template ref<4, scale - 1>() = col; + out.template ref<5, scale - 1>() = col; + + out.template ref<4, scale - 2>() = col; + out.template ref<5, scale - 2>() = col; + + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendLineDiagonal(uint32_t col, OutputMatrix& out) + { + alphaBlend<1, 2>(out.template ref(), col); + alphaBlend<1, 2>(out.template ref(), col); + alphaBlend<1, 2>(out.template ref(), col); + + out.template ref() = col; + out.template ref() = col; + out.template ref() = col; + } + + template + static void blendCorner(uint32_t col, OutputMatrix& out) + { + //model a round corner + alphaBlend<97, 100>(out.template ref<5, 5>(), col); //exact: 0.9711013910 + alphaBlend<42, 100>(out.template ref<4, 5>(), col); //0.4236372243 + alphaBlend<42, 100>(out.template ref<5, 4>(), col); //0.4236372243 + alphaBlend< 6, 100>(out.template ref<5, 3>(), col); //0.05652034508 + alphaBlend< 6, 100>(out.template ref<3, 5>(), col); //0.05652034508 + } +}; + + +void xbrz_old::scale(size_t factor, const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, const xbrz_old::ScalerCfg& cfg, int yFirst, int yLast) +{ + switch (factor) + { + case 2: + return scaleImage(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 3: + return scaleImage(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 4: + return scaleImage(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 5: + return scaleImage(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + case 6: + return scaleImage(src, trg, srcWidth, srcHeight, cfg, yFirst, yLast); + } + assert(false); +} + + +bool xbrz_old::equalColor(uint32_t col1, uint32_t col2, double luminanceWeight, double equalColorTolerance) +{ + return colorDist(col1, col2, luminanceWeight) < equalColorTolerance; +} + + +void xbrz_old::nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, int srcPitch, + uint32_t* trg, int trgWidth, int trgHeight, int trgPitch, + SliceType st, int yFirst, int yLast) +{ + if (srcPitch < srcWidth * static_cast(sizeof(uint32_t)) || + trgPitch < trgWidth * static_cast(sizeof(uint32_t))) + { + assert(false); + return; + } + + switch (st) + { + case NN_SCALE_SLICE_SOURCE: + //nearest-neighbor (going over source image - fast for upscaling, since source is read only once + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, srcHeight); + if (yFirst >= yLast || trgWidth <= 0 || trgHeight <= 0) return; + + for (int y = yFirst; y < yLast; ++y) + { + //mathematically: ySrc = floor(srcHeight * yTrg / trgHeight) + // => search for integers in: [ySrc, ySrc + 1) * trgHeight / srcHeight + + //keep within for loop to support MT input slices! + const int yTrg_first = ( y * trgHeight + srcHeight - 1) / srcHeight; //=ceil(y * trgHeight / srcHeight) + const int yTrg_last = ((y + 1) * trgHeight + srcHeight - 1) / srcHeight; //=ceil(((y + 1) * trgHeight) / srcHeight) + const int blockHeight = yTrg_last - yTrg_first; + + if (blockHeight > 0) + { + const uint32_t* srcLine = byteAdvance(src, y * srcPitch); + uint32_t* trgLine = byteAdvance(trg, yTrg_first * trgPitch); + int xTrg_first = 0; + + for (int x = 0; x < srcWidth; ++x) + { + int xTrg_last = ((x + 1) * trgWidth + srcWidth - 1) / srcWidth; + const int blockWidth = xTrg_last - xTrg_first; + if (blockWidth > 0) + { + xTrg_first = xTrg_last; + fillBlock(trgLine, trgPitch, srcLine[x], blockWidth, blockHeight); + trgLine += blockWidth; + } + } + } + } + break; + + case NN_SCALE_SLICE_TARGET: + //nearest-neighbor (going over target image - slow for upscaling, since source is read multiple times missing out on cache! Fast for similar image sizes!) + yFirst = std::max(yFirst, 0); + yLast = std::min(yLast, trgHeight); + if (yFirst >= yLast || srcHeight <= 0 || srcWidth <= 0) return; + + for (int y = yFirst; y < yLast; ++y) + { + uint32_t* trgLine = byteAdvance(trg, y * trgPitch); + const int ySrc = srcHeight * y / trgHeight; + const uint32_t* srcLine = byteAdvance(src, ySrc * srcPitch); + for (int x = 0; x < trgWidth; ++x) + { + const int xSrc = srcWidth * x / trgWidth; + trgLine[x] = srcLine[xSrc]; + } + } + break; + } +} diff --git a/src/gl/xbr/xbrz_old.h b/src/gl/xbr/xbrz_old.h new file mode 100644 index 000000000..c93a1480a --- /dev/null +++ b/src/gl/xbr/xbrz_old.h @@ -0,0 +1,92 @@ +// **************************************************************************** +// * This file is part of the HqMAME project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// * * +// * Additionally and as a special exception, the author gives permission * +// * to link the code of this program with the MAME library (or with modified * +// * versions of MAME that use the same license as MAME), and distribute * +// * linked combinations including the two. You must obey the GNU General * +// * Public License in all respects for all of the code used other than MAME. * +// * If you modify this file, you may extend this exception to your version * +// * of the file, but you are not obligated to do so. If you do not wish to * +// * do so, delete this exception statement from your version. * +// * * +// * An explicit permission was granted to use xBRZ in combination with ZDoom * +// * and derived projects as long as it is used for non-commercial purposes. * +// * * +// * Backported to C++98 by Alexey Lysiuk * +// **************************************************************************** + +#ifndef __XBRZ_OLD_HEADER_INCLUDED__ +#define __XBRZ_OLD_HEADER_INCLUDED__ + +#include //size_t +#include //uint32_t +#include +#include "xbrz_config_old.h" + +namespace xbrz_old +{ +/* +------------------------------------------------------------------------- +| xBRZ: "Scale by rules" - high quality image upscaling filter by Zenju | +------------------------------------------------------------------------- +using a modified approach of xBR: +http://board.byuu.org/viewtopic.php?f=10&t=2248 +- new rule set preserving small image features +- support multithreading +- support 64 bit architectures +- support processing image slices +*/ + +/* +-> map source (srcWidth * srcHeight) to target (scale * width x scale * height) image, optionally processing a half-open slice of rows [yFirst, yLast) only +-> color format: ARGB (BGRA byte order), alpha channel unused +-> support for source/target pitch in bytes! +-> if your emulator changes only a few image slices during each cycle (e.g. Dosbox) then there's no need to run xBRZ on the complete image: + Just make sure you enlarge the source image slice by 2 rows on top and 2 on bottom (this is the additional range the xBRZ algorithm is using during analysis) + Caveat: If there are multiple changed slices, make sure they do not overlap after adding these additional rows in order to avoid a memory race condition + if you are using multiple threads for processing each enlarged slice! + +THREAD-SAFETY: - parts of the same image may be scaled by multiple threads as long as the [yFirst, yLast) ranges do not overlap! + - there is a minor inefficiency for the first row of a slice, so avoid processing single rows only + + +*/ +void scale(size_t factor, //valid range: 2 - 5 + const uint32_t* src, uint32_t* trg, int srcWidth, int srcHeight, + const ScalerCfg& cfg = ScalerCfg(), + int yFirst = 0, int yLast = std::numeric_limits::max()); //slice of source image + +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, + uint32_t* trg, int trgWidth, int trgHeight); + +enum SliceType +{ + NN_SCALE_SLICE_SOURCE, + NN_SCALE_SLICE_TARGET, +}; +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, int srcPitch, //pitch in bytes! + uint32_t* trg, int trgWidth, int trgHeight, int trgPitch, + SliceType st, int yFirst, int yLast); + +//parameter tuning +bool equalColor(uint32_t col1, uint32_t col2, double luminanceWeight, double equalColorTolerance); + + + + + +//########################### implementation ########################### +inline +void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, + uint32_t* trg, int trgWidth, int trgHeight) +{ + nearestNeighborScale(src, srcWidth, srcHeight, srcWidth * sizeof(uint32_t), + trg, trgWidth, trgHeight, trgWidth * sizeof(uint32_t), + NN_SCALE_SLICE_TARGET, 0, trgHeight); +} +} + +#endif diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index d27ebe4d1..c2d011be9 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -202,7 +202,7 @@ static void P_Add3DFloor(sector_t* sec, sector_t* sec2, line_t* master, int flag // kg3D - software renderer only hack // this is really required because of ceilingclip and floorclip - if(flags & FF_BOTHPLANES) + if((vid_renderer == 0) && (flags & FF_BOTHPLANES)) { P_Add3DFloor(sec, sec2, master, FF_EXISTS | FF_THISINSIDE | FF_RENDERPLANES | FF_NOSHADE | FF_SEETHROUGH | FF_SHOOTTHROUGH | (flags & (FF_INVERTSECTOR | FF_TRANSLUCENT | FF_ADDITIVETRANS)), alpha); diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index c8c7db74d..cf50a1dfa 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -75,6 +75,9 @@ */ static const BYTE ChangeMap[8] = { 0, 1, 5, 3, 7, 2, 6, 0 }; +int LS_Sector_SetPlaneReflection(line_t *ln, AActor *it, bool backSide, int arg0, int arg1, int arg2, int arg3, int arg4); +int LS_SetGlobalFogParameter(line_t *ln, AActor *it, bool backSide, int arg0, int arg1, int arg2, int arg3, int arg4); + #define FUNC(a) static int a (line_t *ln, AActor *it, bool backSide, \ int arg0, int arg1, int arg2, int arg3, int arg4) @@ -3473,9 +3476,9 @@ static lnSpecFunc LineSpecials[] = /* 154 */ LS_Teleport_NoStop, /* 155 */ LS_NOP, /* 156 */ LS_NOP, - /* 157 */ LS_NOP, // SetGlobalFogParameter + /* 157 */ LS_SetGlobalFogParameter, /* 158 */ LS_FS_Execute, - /* 159 */ LS_NOP, // Sector_SetPlaneReflection + /* 159 */ LS_Sector_SetPlaneReflection, /* 160 */ LS_NOP, // Sector_Set3DFloor /* 161 */ LS_NOP, // Sector_SetContents /* 162 */ LS_NOP, // Reserved Doom64 branch diff --git a/src/p_portals.cpp b/src/p_portals.cpp new file mode 100644 index 000000000..92ecfd075 --- /dev/null +++ b/src/p_portals.cpp @@ -0,0 +1,35 @@ +/* +** p_portals.cpp +** +** portal stuff +** +**--------------------------------------------------------------------------- +** Copyright 2015 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. +**--------------------------------------------------------------------------- +** +*/ + diff --git a/src/p_pspr.h b/src/p_pspr.h index 41d258df8..f9d64aef1 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -73,6 +73,7 @@ public: int GetID() const { return ID; } int GetSprite() const { return Sprite; } int GetFrame() const { return Frame; } + int GetTics() const { return Tics; } FState* GetState() const { return State; } DPSprite* GetNext() { return Next; } AActor* GetCaller() { return Caller; } diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index a6c34857f..54046d6a4 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -401,6 +401,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 @@ -421,7 +424,9 @@ void P_SerializeWorld (FArchive &arc) } arc << li->args[1] << li->args[2] << li->args[3] << li->args[4]; - arc << li->portalindex; + arc << li->portalindex; + arc << li->portaltransferred; // GZDoom addition. + for (j = 0; j < 2; j++) { if (li->sidedef[j] == NULL) diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 4c3bdb488..f9b056939 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -969,6 +969,23 @@ static void CopyPortal(int sectortag, int plane, unsigned pnum, double alpha, bo } } } + if (tolines && lines[j].special == Sector_SetPortal && + lines[j].args[1] == 5 && + lines[j].args[3] == sectortag) + { + if (lines[j].args[0] == 0) + { + lines[j].portaltransferred = pnum; + } + else + { + FLineIdIterator itr(lines[j].args[0]); + while ((s = itr.Next()) >= 0) + { + lines[s].portaltransferred = pnum; + } + } + } } } @@ -1219,6 +1236,7 @@ void P_SpawnSpecials (void) // Init special SECTORs. sector = sectors; + for (i = 0; i < numsectors; i++, sector++) { if (sector->special == 0) diff --git a/src/posix/cocoa/i_common.h b/src/posix/cocoa/i_common.h index 4a558cf24..9cedb0262 100644 --- a/src/posix/cocoa/i_common.h +++ b/src/posix/cocoa/i_common.h @@ -190,6 +190,9 @@ typedef NSInteger NSApplicationActivationPolicy; static const NSWindowCollectionBehavior NSWindowCollectionBehaviorFullScreenAuxiliary = NSWindowCollectionBehavior(1 << 8); +static const NSOpenGLPixelFormatAttribute NSOpenGLPFAOpenGLProfile(96); +static const NSOpenGLPixelFormatAttribute NSOpenGLProfileVersion3_2Core(0x3200); + #endif // prior to 10.7 #endif // COCOA_I_COMMON_INCLUDED diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index ddfccaa57..7144dc137 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -31,10 +31,11 @@ ** */ +#include "gl/system/gl_load.h" + #include "i_common.h" #import -#import // Avoid collision between DObject class and Objective-C #define Class ObjectClass @@ -45,6 +46,7 @@ #include "hardware.h" #include "i_system.h" #include "m_argv.h" +#include "m_png.h" #include "r_renderer.h" #include "r_swrenderer.h" #include "st_console.h" @@ -56,6 +58,14 @@ #include "v_video.h" #include "version.h" +#include "gl/system/gl_system.h" +#include "gl/data/gl_vertexbuffer.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/system/gl_framebuffer.h" +#include "gl/system/gl_interface.h" +#include "gl/textures/gl_samplers.h" +#include "gl/utility/gl_clock.h" + #undef Class @@ -122,6 +132,36 @@ CUSTOM_CVAR(Bool, vid_autoswitch, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_ Printf("You must restart " GAMENAME " to apply graphics switching mode\n"); } +static int s_currentRenderer; + +CUSTOM_CVAR(Int, vid_renderer, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + // 0: Software renderer + // 1: OpenGL renderer + + if (self != s_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", + static_cast(vid_renderer)); + self = 0; + break; + } + + Printf("You must restart " GAMENAME " to switch the renderer\n"); + } +} + +EXTERN_CVAR(Bool, gl_smooth_rendered) + RenderBufferOptions rbOpts; @@ -135,7 +175,7 @@ namespace const NSInteger LEVEL_WINDOWED = NSNormalWindowLevel; const NSUInteger STYLE_MASK_FULLSCREEN = NSBorderlessWindowMask; - const NSUInteger STYLE_MASK_WINDOWED = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask; + const NSUInteger STYLE_MASK_WINDOWED = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask; } @@ -198,14 +238,13 @@ namespace @end - // --------------------------------------------------------------------------- class CocoaVideo : public IVideo { public: - explicit CocoaVideo(int multisample); + CocoaVideo(); virtual EDisplayType GetDisplayType() { return DISPLAY_Both; } virtual void SetWindowedScale(float scale); @@ -246,6 +285,9 @@ private: }; +// --------------------------------------------------------------------------- + + class CocoaFrameBuffer : public DFrameBuffer { public: @@ -428,23 +470,14 @@ CocoaWindow* CreateCocoaWindow(const NSUInteger styleMask) return window; } -} // unnamed namespace - - -// --------------------------------------------------------------------------- - - -CocoaVideo::CocoaVideo(const int multisample) -: m_window(CreateCocoaWindow(STYLE_MASK_WINDOWED)) -, m_width(-1) -, m_height(-1) -, m_fullscreen(false) -, m_hiDPI(false) +enum OpenGLProfile { - memset(&m_modeIterator, 0, sizeof m_modeIterator); - - // Set attributes for OpenGL context + Core, + Legacy +}; +NSOpenGLPixelFormat* CreatePixelFormat(const OpenGLProfile profile) +{ NSOpenGLPixelFormatAttribute attributes[16]; size_t i = 0; @@ -461,20 +494,59 @@ CocoaVideo::CocoaVideo(const int multisample) attributes[i++] = NSOpenGLPFAAllowOfflineRenderers; } - if (multisample) + if (NSAppKitVersionNumber >= AppKit10_7 && OpenGLProfile::Core == profile) { - attributes[i++] = NSOpenGLPFAMultisample; - attributes[i++] = NSOpenGLPFASampleBuffers; - attributes[i++] = NSOpenGLPixelFormatAttribute(1); - attributes[i++] = NSOpenGLPFASamples; - attributes[i++] = NSOpenGLPixelFormatAttribute(multisample); + NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersion3_2Core; + const char* const glversion = Args->CheckValue("-glversion"); + + if (nullptr != glversion) + { + const double version = strtod(glversion, nullptr) + 0.01; + if (version < 3.2) + { + profile = NSOpenGLProfileVersionLegacy; + } + } + + attributes[i++] = NSOpenGLPFAOpenGLProfile; + attributes[i++] = profile; } attributes[i] = NSOpenGLPixelFormatAttribute(0); - // Create OpenGL context and view + return [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; +} - NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; +} // unnamed namespace + + +// --------------------------------------------------------------------------- + + +CocoaVideo::CocoaVideo() +: m_window(CreateCocoaWindow(STYLE_MASK_WINDOWED)) +, m_width(-1) +, m_height(-1) +, m_fullscreen(false) +, m_hiDPI(false) +{ + memset(&m_modeIterator, 0, sizeof m_modeIterator); + + // Create OpenGL pixel format + + NSOpenGLPixelFormat* pixelFormat = CreatePixelFormat(OpenGLProfile::Core); + + if (nil == pixelFormat) + { + pixelFormat = CreatePixelFormat(OpenGLProfile::Legacy); + + if (nil == pixelFormat) + { + I_FatalError("Cannot OpenGL create pixel format, graphics hardware is not supported"); + } + } + + // Create OpenGL context and view const NSRect contentRect = [m_window contentRectForFrameRect:[m_window frame]]; NSOpenGLView* glView = [[CocoaView alloc] initWithFrame:contentRect @@ -553,7 +625,17 @@ DFrameBuffer* CocoaVideo::CreateFrameBuffer(const int width, const int height, c delete old; } - CocoaFrameBuffer* fb = new CocoaFrameBuffer(width, height, bgra, fullscreen); + DFrameBuffer* fb = NULL; + + if (1 == s_currentRenderer) + { + fb = new OpenGLFrameBuffer(NULL, width, height, 32, 60, fullscreen); + } + else + { + fb = new CocoaFrameBuffer(width, height, bgra, fullscreen); + } + fb->SetFlash(flashColor, flashAmount); SetMode(width, height, fullscreen, vid_hidpi); @@ -772,6 +854,9 @@ CocoaVideo* CocoaVideo::GetInstance() } +// --------------------------------------------------------------------------- + + CocoaFrameBuffer::CocoaFrameBuffer(int width, int height, bool bgra, bool fullscreen) : DFrameBuffer(width, height, bgra) , m_needPaletteUpdate(false) @@ -782,6 +867,14 @@ CocoaFrameBuffer::CocoaFrameBuffer(int width, int height, bool bgra, bool fullsc , m_pixelBuffer(new uint8_t[width * height * BYTES_PER_PIXEL]) , m_texture(0) { + static bool isOpenGLInitialized; + + if (!isOpenGLInitialized) + { + ogl_LoadFunctions(); + isOpenGLInitialized = true; + } + glEnable(GL_TEXTURE_RECTANGLE_ARB); glGenTextures(1, &m_texture); @@ -1030,6 +1123,153 @@ void CocoaFrameBuffer::Flip() } +// --------------------------------------------------------------------------- + + +SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool fullscreen) +: DFrameBuffer(width, height) +, m_lock(-1) +, m_isUpdatePending(false) +{ + CGGammaValue gammaTable[GAMMA_TABLE_SIZE]; + uint32_t actualChannelSize; + + const CGError result = CGGetDisplayTransferByTable(kCGDirectMainDisplay, GAMMA_CHANNEL_SIZE, + gammaTable, &gammaTable[GAMMA_CHANNEL_SIZE], &gammaTable[GAMMA_CHANNEL_SIZE * 2], &actualChannelSize); + m_supportsGamma = kCGErrorSuccess == result && GAMMA_CHANNEL_SIZE == actualChannelSize; + + if (m_supportsGamma) + { + for (uint32_t i = 0; i < GAMMA_TABLE_SIZE; ++i) + { + m_originalGamma[i] = static_cast(gammaTable[i] * 65535.0f); + } + } +} + +SDLGLFB::SDLGLFB() +{ +} + +SDLGLFB::~SDLGLFB() +{ +} + + +bool SDLGLFB::Lock(bool buffered) +{ + m_lock++; + + Buffer = MemBuffer; + + return true; +} + +void SDLGLFB::Unlock() +{ + if (m_isUpdatePending && 1 == m_lock) + { + Update(); + } + else if (--m_lock <= 0) + { + m_lock = 0; + } +} + +bool SDLGLFB::IsLocked() +{ + return m_lock > 0; +} + + +bool SDLGLFB::IsFullscreen() +{ + return CocoaVideo::IsFullscreen(); +} + +void SDLGLFB::SetVSync(bool vsync) +{ +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 + const long value = vsync ? 1 : 0; +#else // 10.5 or newer + const GLint value = vsync ? 1 : 0; +#endif // prior to 10.5 + + [[NSOpenGLContext currentContext] setValues:&value + forParameter:NSOpenGLCPSwapInterval]; +} + + +void SDLGLFB::InitializeState() +{ +} + +bool SDLGLFB::CanUpdate() +{ + if (m_lock != 1) + { + if (m_lock > 0) + { + m_isUpdatePending = true; + --m_lock; + } + + return false; + } + + return true; +} + +void SDLGLFB::SwapBuffers() +{ + [[NSOpenGLContext currentContext] flushBuffer]; +} + +void SDLGLFB::SetGammaTable(WORD* table) +{ + if (m_supportsGamma) + { + CGGammaValue gammaTable[GAMMA_TABLE_SIZE]; + + for (uint32_t i = 0; i < GAMMA_TABLE_SIZE; ++i) + { + gammaTable[i] = static_cast(table[i] / 65535.0f); + } + + CGSetDisplayTransferByTable(kCGDirectMainDisplay, GAMMA_CHANNEL_SIZE, + gammaTable, &gammaTable[GAMMA_CHANNEL_SIZE], &gammaTable[GAMMA_CHANNEL_SIZE * 2]); + } +} + +void SDLGLFB::ResetGammaTable() +{ + if (m_supportsGamma) + { + SetGammaTable(m_originalGamma); + } +} + +int SDLGLFB::GetClientWidth() +{ + NSView *view = [[NSOpenGLContext currentContext] view]; + NSRect backingBounds = [view convertRectToBacking: [view bounds]]; + int clientWidth = (int)backingBounds.size.width; + return clientWidth > 0 ? clientWidth : Width; +} + +int SDLGLFB::GetClientHeight() +{ + NSView *view = [[NSOpenGLContext currentContext] view]; + NSRect backingBounds = [view convertRectToBacking: [view bounds]]; + int clientHeight = (int)backingBounds.size.height; + return clientHeight > 0 ? clientHeight : Height; +} + + +// --------------------------------------------------------------------------- + + ADD_STAT(blit) { FString result; @@ -1041,6 +1281,9 @@ ADD_STAT(blit) IVideo* Video; +// --------------------------------------------------------------------------- + + void I_ShutdownGraphics() { if (NULL != screen) @@ -1061,7 +1304,7 @@ void I_InitGraphics() val.Bool = !!Args->CheckParm("-devparm"); ticker.SetGenericRepDefault(val, CVAR_Bool); - Video = new CocoaVideo(0); + Video = new CocoaVideo; atterm(I_ShutdownGraphics); } @@ -1074,9 +1317,15 @@ static void I_DeleteRenderer() void I_CreateRenderer() { + s_currentRenderer = vid_renderer; + if (NULL == Renderer) { - Renderer = new FSoftwareRenderer; + extern FRenderer* gl_CreateInterface(); + + Renderer = 1 == s_currentRenderer + ? gl_CreateInterface() + : new FSoftwareRenderer; atterm(I_DeleteRenderer); } } @@ -1148,6 +1397,9 @@ void I_ClosestResolution(int *width, int *height, int bits) } +// --------------------------------------------------------------------------- + + EXTERN_CVAR(Int, vid_maxfps); EXTERN_CVAR(Bool, cl_capfps); @@ -1186,6 +1438,9 @@ CUSTOM_CVAR(Bool, vid_hidpi, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) } +// --------------------------------------------------------------------------- + + CCMD(vid_listmodes) { if (Video == NULL) diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h new file mode 100644 index 000000000..fcbf23f2a --- /dev/null +++ b/src/posix/cocoa/sdlglvideo.h @@ -0,0 +1,90 @@ +/* + ** sdlglvideo.h + ** + **--------------------------------------------------------------------------- + ** Copyright 2012-2014 Alexey Lysiuk + ** 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. + **--------------------------------------------------------------------------- + ** + */ + + +// IMPORTANT NOTE! +// This file was intentially named sdlglvideo.h but it has nothing with SDL +// The name was selected to avoid spreding of changes over the project +// The same applies to SDLGLFB class +// See gl/system/gl_framebuffer.h for details about its usage + + +#ifndef COCOA_SDLGLVIDEO_H_INCLUDED +#define COCOA_SDLGLVIDEO_H_INCLUDED + +#include "v_video.h" + +#include "gl/shaders/gl_shader.h" +#include "gl/textures/gl_hwtexture.h" + + +class SDLGLFB : public 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(); + + virtual bool Lock(bool buffered = true); + virtual void Unlock(); + virtual bool IsLocked(); + + virtual bool IsFullscreen(); + virtual void SetVSync(bool vsync); + + int GetClientWidth(); + int GetClientHeight(); + +protected: + int m_lock; + bool m_isUpdatePending; + + static const uint32_t GAMMA_CHANNEL_SIZE = 256; + static const uint32_t GAMMA_CHANNEL_COUNT = 3; + static const uint32_t GAMMA_TABLE_SIZE = GAMMA_CHANNEL_SIZE * GAMMA_CHANNEL_COUNT; + + bool m_supportsGamma; + WORD m_originalGamma[GAMMA_TABLE_SIZE]; + + SDLGLFB(); + + void InitializeState(); + + bool CanUpdate(); + void SwapBuffers(); + + void SetGammaTable(WORD* table); + void ResetGammaTable(); +}; + +#endif // COCOA_SDLGLVIDEO_H_INCLUDED diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 221cca44a..2c0ba617e 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -36,6 +36,7 @@ #include #include +#include "version.h" #include "hardware.h" #include "i_video.h" #include "i_system.h" @@ -46,6 +47,7 @@ #include "v_text.h" #include "doomstat.h" #include "m_argv.h" +#include "sdlglvideo.h" #include "r_renderer.h" #include "r_swrenderer.h" @@ -56,6 +58,37 @@ 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) @@ -85,8 +118,11 @@ void I_InitGraphics () val.Bool = !!Args->CheckParm ("-devparm"); ticker.SetGenericRepDefault (val, CVAR_Bool); - - Video = new SDLVideo (0); + + //currentrenderer = vid_renderer; + if (currentrenderer==1) Video = new SDLGLVideo(0); + else Video = new SDLVideo (0); + if (Video == NULL) I_FatalError ("Failed to initialize display"); @@ -102,9 +138,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); } } diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp new file mode 100644 index 000000000..d8c00f236 --- /dev/null +++ b/src/posix/sdl/sdlglvideo.cpp @@ -0,0 +1,476 @@ + +// 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) +EXTERN_CVAR (Int, vid_maxfps) +EXTERN_CVAR (Bool, cl_capfps) + +// PUBLIC DATA DEFINITIONS ------------------------------------------------- + +CUSTOM_CVAR(Bool, gl_debug, false, 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 ); + } + if (gl_debug) + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); + 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) +{ + int i; + + m_Lock=0; + + UpdatePending = false; + + if (!static_cast(Video)->InitHardware(false, 0)) + { + 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) + { + ResetGammaTable(); + + 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) +{ + if (m_supportsGamma) + { + SDL_SetWindowGammaRamp(Screen, &tbl[0], &tbl[256], &tbl[512]); + } +} + +void SDLGLFB::ResetGammaTable() +{ + if (m_supportsGamma) + { + SDL_SetWindowGammaRamp(Screen, m_origGamma[0], m_origGamma[1], m_origGamma[2]); + } +} + +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() +{ +#ifndef __APPLE__ + if (vid_maxfps && !cl_capfps) + { + SEMAPHORE_WAIT(FPSLimitSemaphore) + } +#endif + + SDL_GL_SwapWindow (Screen); +} + +int SDLGLFB::GetClientWidth() +{ + int width = 0; + SDL_GL_GetDrawableSize(Screen, &width, nullptr); + return width; +} + +int SDLGLFB::GetClientHeight() +{ + int height = 0; + SDL_GL_GetDrawableSize(Screen, nullptr, &height); + return height; +} diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h new file mode 100644 index 000000000..d8ce9005d --- /dev/null +++ b/src/posix/sdl/sdlglvideo.h @@ -0,0 +1,84 @@ +#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; + + int GetClientWidth(); + int GetClientHeight(); + +protected: + bool CanUpdate(); + void SetGammaTable(WORD *tbl); + void ResetGammaTable(); + 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 4b826c56b..8a88abed2 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -240,9 +240,9 @@ void FInterpolator::RemoveInterpolation(DInterpolation *interp) if (interp->Prev != NULL) interp->Prev->Next = interp->Next; if (interp->Next != NULL) interp->Next->Prev = interp->Prev; } - interp->Next = NULL; - interp->Prev = NULL; - count--; + interp->Next = NULL; + interp->Prev = NULL; + count--; } //========================================================================== @@ -461,12 +461,12 @@ void DSectorPlaneInterpolation::Restore() if (!ceiling) { sector->floorplane.setD(bakheight); - sector->SetPlaneTexZ(sector_t::floor, baktexz); + sector->SetPlaneTexZ(sector_t::floor, baktexz, true); } else { sector->ceilingplane.setD(bakheight); - sector->SetPlaneTexZ(sector_t::ceiling, baktexz); + sector->SetPlaneTexZ(sector_t::ceiling, baktexz, true); } P_RecalculateAttached3DFloors(sector); sector->CheckPortalPlane(ceiling? sector_t::ceiling : sector_t::floor); @@ -504,8 +504,8 @@ void DSectorPlaneInterpolation::Interpolate(double smoothratio) else { pplane->setD(oldheight + (bakheight - oldheight) * smoothratio); - sector->SetPlaneTexZ(pos, oldtexz + (baktexz - oldtexz) * smoothratio); - P_RecalculateAttached3DFloors(sector); + sector->SetPlaneTexZ(pos, oldtexz + (baktexz - oldtexz) * smoothratio, true); + P_RecalculateAttached3DFloors(sector); sector->CheckPortalPlane(pos); } } diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index 37a3fb854..cc923f189 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 fbb01b24d..80c2d9488 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; @@ -985,6 +987,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 c0f878664..f95016fb4 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -36,6 +36,10 @@ // to handle sound origins in sectors. // SECTORS do store MObjs anyway. #include "actor.h" +struct FLightNode; +struct FGLSection; +struct FPortal; +struct seg_t; #include "dthinker.h" @@ -135,6 +139,25 @@ public: return { p.X, p.Y }; } + 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() + { + p = { 0,0 }; + angletime = 0; + viewangle = 0; + dirty = true; + numheights = numsectors = 0; + sectors = NULL; + heightlist = NULL; + } + bool operator== (const vertex_t &other) { return p == other.p; @@ -149,6 +172,8 @@ public: { p.Zero(); } + + angle_t GetClipAngle(); }; // Forward of LineDefs, for Sectors. @@ -275,7 +300,7 @@ struct secplane_t // the plane is defined as a*x + b*y + c*z + d = 0 // ic is 1/c, for faster Z calculations -private: +//private: DVector3 normal; double D, negiC; // negative iC because that also saves a negation in all methods using this. public: @@ -440,6 +465,11 @@ 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; + // Ceiling/floor flags enum { @@ -543,6 +573,8 @@ struct extsector_t TArray lightlist; // 3D light list TArray attached; // 3D floors attached to this sector } XFloor; + + TArray vertices; void Serialize(FArchive &arc); }; @@ -799,9 +831,10 @@ public: return planes[pos].TexZ; } - void SetPlaneTexZ(int pos, double val) + void SetPlaneTexZ(int pos, double 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, double val) @@ -889,6 +922,7 @@ public: void ClearPortal(int plane) { Portals[plane] = 0; + portals[plane] = nullptr; } FSectorPortal *GetPortal(int plane) @@ -916,6 +950,18 @@ public: return sectorPortals[Portals[plane]].mDestination->PortalGroup; } + 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(); + } + int GetTerrain(int pos) const; void TransferSpecial(sector_t *model); @@ -1030,6 +1076,37 @@ public: 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 + int subsectorcount; // list of subsectors + double transdoorheight; // for transparent door hacks + 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 + double 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); } + FPortal *GetGLPortal(int plane) { return portals[plane]; } + + enum + { + INVALIDATE_PLANES = 1, + INVALIDATE_OTHER = 2 + }; + }; FArchive &operator<< (FArchive &arc, sector_t::splane &p); @@ -1195,6 +1272,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); @@ -1216,6 +1300,7 @@ public: int validcount; // if == validcount, already checked int locknumber; // [Dusk] lock number for special unsigned portalindex; + unsigned portaltransferred; DVector2 Delta() const { @@ -1232,6 +1317,11 @@ public: alpha = a; } + FSectorPortal *GetTransferredPortal() + { + return portaltransferred >= sectorPortals.Size() ? (FSectorPortal*)NULL : §orPortals[portaltransferred]; + } + FLinePortal *getPortal() const { return portalindex >= linePortals.Size() ? (FLinePortal*)NULL : &linePortals[portalindex]; @@ -1316,6 +1406,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 @@ -1324,6 +1419,9 @@ struct glsegextra_t subsector_t *Subsector; }; +extern seg_t *segs; + + // // A SubSector. // References a Sector. @@ -1338,6 +1436,12 @@ enum SSECF_POLYORG = 4, }; +struct FPortalCoverage +{ + DWORD * subsectors; + int sscount; +}; + struct subsector_t { sector_t *sector; @@ -1349,6 +1453,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/r_sky.h b/src/r_sky.h index 6ece74d74..132817983 100644 --- a/src/r_sky.h +++ b/src/r_sky.h @@ -24,7 +24,6 @@ #include "textures/textures.h" - extern FTextureID skyflatnum; extern fixed_t sky1cyl, sky2cyl; extern FTextureID sky1texture, sky2texture; diff --git a/src/stats.h b/src/stats.h index 612cd2739..d90efa7e4 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/textures.h b/src/textures/textures.h index e5ecdc679..6b2737659 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -5,6 +5,27 @@ #include "vectors.h" #include +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; @@ -15,6 +36,8 @@ class FArchive; // Texture IDs class FTextureManager; class FTerrainTypeArray; +class FGLTexture; +class FMaterial; class FNullTextureID : public FTextureID { @@ -270,6 +293,9 @@ protected: CopySize(other); bNoDecals = other->bNoDecals; Rotations = other->Rotations; + gl_info = other->gl_info; + gl_info.Brightmap = NULL; + gl_info.areas = NULL; } std::vector PixelsBgra; @@ -289,8 +315,48 @@ 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; + 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; + + 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 @@ -503,12 +569,12 @@ public: FTexture *GetRedirect(bool wantwarped); DWORD GenTime; + float Speed; + int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd] protected: FTexture *SourcePic; BYTE *Pixels; Span **Spans; - float Speed; - int WidthOffsetMultiplier, HeightOffsetMultiplier; // [mxd] virtual void MakeTexture (DWORD time); int NextPo2 (int v); // [mxd] diff --git a/src/version.h b/src/version.h index 57dacaa00..0b2fa22e7 100644 --- a/src/version.h +++ b/src/version.h @@ -41,12 +41,12 @@ const char *GetVersionString(); /** Lots of different version numbers **/ -#define VERSIONSTR "2.9pre" +#define VERSIONSTR "2.2pre" // The version as seen in the Windows resource -#define RC_FILEVERSION 2,8,9999,0 -#define RC_PRODUCTVERSION 2,8,9999,0 -#define RC_PRODUCTVERSION2 "2.9pre" +#define RC_FILEVERSION 2,1,9999,0 +#define RC_PRODUCTVERSION 2,1,9999,0 +#define RC_PRODUCTVERSION2 "2.2pre" // 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/hardware.cpp b/src/win32/hardware.cpp index 49c970457..cc55dd400 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -63,6 +63,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) @@ -95,15 +134,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); } @@ -114,9 +156,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); } } @@ -149,12 +193,12 @@ DFrameBuffer *I_SetMode (int &width, int &height, DFrameBuffer *old) } DFrameBuffer *res = Video->CreateFrameBuffer (width, height, swtruecolor, 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; } @@ -256,7 +300,8 @@ void I_SaveWindowedPos () return; } // Make sure we only save the window position if it's not fullscreen. - if ((GetWindowLong (Window, GWL_STYLE) & WS_OVERLAPPEDWINDOW) == WS_OVERLAPPEDWINDOW) + static const int WINDOW_STYLE = WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX; + if ((GetWindowLong (Window, GWL_STYLE) & WINDOW_STYLE) == WINDOW_STYLE) { RECT wrect; @@ -323,7 +368,7 @@ CUSTOM_CVAR(Bool, swtruecolor, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINIT setmodeneeded = true; } -CUSTOM_CVAR (Bool, fullscreen, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) +CUSTOM_CVAR (Bool, fullscreen, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL) { NewWidth = screen->GetWidth(); NewHeight = screen->GetHeight(); @@ -343,7 +388,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 5ada51b69..52f484afc 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -1427,11 +1427,11 @@ static HCURSOR CreateBitmapCursor(int xhot, int yhot, HBITMAP and_mask, HBITMAP { ICONINFO iconinfo = { - FALSE, // fIcon + FALSE, // fIcon (DWORD)xhot, // xHotspot (DWORD)yhot, // yHotspot - and_mask, // hbmMask - color_mask // hbmColor + and_mask, // hbmMask + color_mask // hbmColor }; HCURSOR cursor = CreateIconIndirect(&iconinfo); 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..7ca001e1e --- /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(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL) +{ + Printf("This won't take effect until " GAMENAME " is restarted.\n"); +} + +EXTERN_CVAR(Bool, vr_enable_quadbuffered) +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 i; + int colorDepth; + HDC deskDC; + int attributes[28]; + 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; + + if (multisample > 0) + { + attributes[18] = WGL_SAMPLE_BUFFERS_ARB; + attributes[19] = true; + attributes[20] = WGL_SAMPLES_ARB; + attributes[21] = multisample; + i = 22; + } + else + { + i = 18; + } + + attributes[i++] = WGL_ACCELERATION_ARB; //required to be FULL_ACCELERATION_ARB + attributes[i++] = WGL_FULL_ACCELERATION_ARB; + + if (vr_enable_quadbuffered) + { + // [BB] Starting with driver version 314.07, NVIDIA GeForce cards support OpenGL quad buffered + // stereo rendering with 3D Vision hardware. Select the corresponding attribute here. + attributes[i++] = WGL_STEREO_ARB; + attributes[i++] = true; + } + + attributes[i++] = 0; + attributes[i++] = 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; +} + +//========================================================================== +// +// +// +//========================================================================== + +bool Win32GLVideo::InitHardware (HWND Window, int multisample) +{ + m_Window=Window; + m_hDC = GetDC(Window); + + if (!SetupPixelFormat(multisample)) + { + return false; + } + + int prof = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; + const char *version = Args->CheckValue("-glversion"); + + if (version != nullptr && strcmp(version, "3.0") < 0) prof = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; + + for (; 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) + { + m_hRC = wglCreateContext(m_hDC); + if (m_hRC == NULL) + { + I_Error("R_OPENGL: Unable to create an OpenGL render context.\n"); + return false; + } + } + + if (m_hRC != NULL) + { + wglMakeCurrent(m_hDC, m_hRC); + 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 render context. Insufficient driver support for context creation\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) +{ + 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; + 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 + { + RECT windowRect; + windowRect.left = r.left; + windowRect.top = r.top; + windowRect.right = windowRect.left + width; + windowRect.bottom = windowRect.top + height; + AdjustWindowRectEx(&windowRect, style, FALSE, exStyle); + MoveWindow(Window, windowRect.left, windowRect.top, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, FALSE); + + I_RestoreWindowedPos(); + } + + if (!static_cast(Video)->InitHardware(Window, 0)) + { + vid_renderer = 0; + return; + } + + vsyncfunc = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); + + HDC hDC = GetDC(Window); + m_supportsGamma = !!GetDeviceGammaRamp(hDC, (void *)m_origGamma); + ReleaseDC(Window, hDC); +} + +//========================================================================== +// +// +// +//========================================================================== + +Win32GLFrameBuffer::~Win32GLFrameBuffer() +{ + ResetGammaTable(); + 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::ResetGammaTable() +{ + if (m_supportsGamma) + { + HDC hDC = GetDC(Window); + SetDeviceGammaRamp(hDC, (void *)m_origGamma); + ReleaseDC(Window, hDC); + } +} + +void Win32GLFrameBuffer::SetGammaTable(WORD *tbl) +{ + if (m_supportsGamma) + { + 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 ? 1 : 0); +} + +void Win32GLFrameBuffer::SwapBuffers() +{ + // Limiting the frame rate is as simple as waiting for the timer to signal this event. + if (FPSLimitEvent != NULL) + { + WaitForSingleObject(FPSLimitEvent, 1000); + } + ::SwapBuffers(static_cast(Video)->m_hDC); +} + +//========================================================================== +// +// +// +//========================================================================== + +void Win32GLFrameBuffer::NewRefreshRate () +{ + if (m_Fullscreen) + { + setmodeneeded = true; + NewWidth = screen->GetWidth(); + NewHeight = screen->GetHeight(); + NewBits = DisplayBits; + } +} + +int Win32GLFrameBuffer::GetClientWidth() +{ + RECT rect = { 0 }; + GetClientRect(Window, &rect); + return rect.right - rect.left; +} + +int Win32GLFrameBuffer::GetClientHeight() +{ + RECT rect = { 0 }; + GetClientRect(Window, &rect); + return rect.bottom - rect.top; +} + +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..6320e2903 --- /dev/null +++ b/src/win32/win32gliface.h @@ -0,0 +1,156 @@ +#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(); +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 GetClientWidth(); + int GetClientHeight(); + + 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 ResetGammaTable(); + 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/wadsrc/CMakeLists.txt b/wadsrc/CMakeLists.txt index 4e661e7dd..80189a328 100644 --- a/wadsrc/CMakeLists.txt +++ b/wadsrc/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required( VERSION 2.8.7 ) -add_pk3(zdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) +add_pk3(gzdoom.pk3 ${CMAKE_CURRENT_SOURCE_DIR}/static) diff --git a/wadsrc/static/actors/doom/doomarmor.txt b/wadsrc/static/actors/doom/doomarmor.txt index c676f9131..578c4f0fe 100644 --- a/wadsrc/static/actors/doom/doomarmor.txt +++ b/wadsrc/static/actors/doom/doomarmor.txt @@ -6,7 +6,7 @@ Actor ArmorBonus : BasicArmorBonus Radius 20 Height 16 Inventory.Pickupmessage "$GOTARMBONUS" - Inventory.Icon "ARM1A0" + Inventory.Icon "BON2A0" Armor.Savepercent 33.335 Armor.Saveamount 1 Armor.Maxsaveamount 200 diff --git a/wadsrc/static/compatibility.txt b/wadsrc/static/compatibility.txt index d964cbf75..d8bfefc1b 100644 --- a/wadsrc/static/compatibility.txt +++ b/wadsrc/static/compatibility.txt @@ -452,3 +452,17 @@ D7F6E9F08C39A17026349A04F8C0B0BE // Return to Hadron, e1m9 { pointonline } + +712BB4CFBD0753178CA0C6814BE4C288 // map12 BTSX_E1 - patch some rendering glitches that are problematic to detect +{ + setsectortag 545 32000 + setsectortag 1618 32000 + setlinespecial 2853 Sector_Set3DFloor 32000 4 0 0 0 + setsectortag 439 32001 + setsectortag 458 32001 + setlinespecial 2182 Sector_Set3DFloor 32001 4 0 0 0 + setsectortag 454 32002 + setsectortag 910 32002 + setlinespecial 2410 Sector_Set3DFloor 32002 4 1 0 0 +} + diff --git a/wadsrc/static/decorate.z b/wadsrc/static/decorate.z new file mode 100644 index 000000000..4a2940be1 --- /dev/null +++ b/wadsrc/static/decorate.z @@ -0,0 +1,102 @@ +ACTOR DynamicLight native +{ + Height 0 + Radius 0.1 + FloatBobPhase 0 + +NOBLOCKMAP + +NOGRAVITY + +FIXMAPTHINGPOS + +INVISIBLE +} + + +ACTOR PointLight : DynamicLight +{ + DynamicLight.Type "Point" +} + +ACTOR PointLightPulse : PointLight +{ + DynamicLight.Type "Pulse" +} + +ACTOR PointLightFlicker : PointLight +{ + DynamicLight.Type "Flicker" +} + +ACTOR SectorPointLight : PointLight +{ + DynamicLight.Type "Sector" +} + +ACTOR PointLightFlickerRandom : PointLight +{ + DynamicLight.Type "RandomFlicker" +} + +// MISSILEMORE and MISSILEEVENMORE are used by the lights for additive and subtractive lights + +ACTOR PointLightAdditive : PointLight +{ + +MISSILEMORE +} + +ACTOR PointLightPulseAdditive : PointLightPulse +{ + +MISSILEMORE +} + +ACTOR PointLightFlickerAdditive : PointLightFlicker +{ + +MISSILEMORE +} + +ACTOR SectorPointLightAdditive : SectorPointLight +{ + +MISSILEMORE +} + +ACTOR PointLightFlickerRandomAdditive :PointLightFlickerRandom +{ + +MISSILEMORE +} + +ACTOR PointLightSubtractive : PointLight +{ + +MISSILEEVENMORE +} + +ACTOR PointLightPulseSubtractive : PointLightPulse +{ + +MISSILEEVENMORE +} + +ACTOR PointLightFlickerSubtractive : PointLightFlicker +{ + +MISSILEEVENMORE +} + +ACTOR SectorPointLightSubtractive : SectorPointLight +{ + +MISSILEEVENMORE +} + +ACTOR PointLightFlickerRandomSubtractive : PointLightFlickerRandom +{ + +MISSILEEVENMORE +} + + +ACTOR VavoomLight : DynamicLight native +{ +} + +ACTOR VavoomLightWhite : VavoomLight native +{ +} + +ACTOR VavoomLightColor : VavoomLight native +{ +} + diff --git a/wadsrc/static/glstuff/gllight.png b/wadsrc/static/glstuff/gllight.png new file mode 100644 index 000000000..a3a296b9f Binary files /dev/null and b/wadsrc/static/glstuff/gllight.png differ diff --git a/wadsrc/static/glstuff/glpart.png b/wadsrc/static/glstuff/glpart.png new file mode 100644 index 000000000..ddb0aea8e Binary files /dev/null and b/wadsrc/static/glstuff/glpart.png differ diff --git a/wadsrc/static/glstuff/glpart2.png b/wadsrc/static/glstuff/glpart2.png new file mode 100644 index 000000000..f95255ebf Binary files /dev/null and b/wadsrc/static/glstuff/glpart2.png differ diff --git a/wadsrc/static/glstuff/mirror.png b/wadsrc/static/glstuff/mirror.png new file mode 100644 index 000000000..08a6abcbe Binary files /dev/null and b/wadsrc/static/glstuff/mirror.png differ diff --git a/wadsrc/static/language.eng b/wadsrc/static/language.eng index ca27bf80a..bf0a0a91d 100644 --- a/wadsrc/static/language.eng +++ b/wadsrc/static/language.eng @@ -108,3 +108,5 @@ CMPTMNU_SECTORSOUNDS = "Sector sounds use centre as source"; OPTVAL_MAPDEFINEDCOLORSONLY = "Map defined colours only"; C_GRAY = "\ccgrey"; C_DARKGRAY = "\cudark grey"; + +OPTVAL_ANYFIXEDCOLORMAP = "Any fixed colourmap"; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 91459673a..e004620c7 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2299,6 +2299,7 @@ OPTVAL_ERRORS = "Errors"; OPTVAL_WARNINGS = "Warnings"; OPTVAL_NOTIFICATIONS = "Notifications"; OPTVAL_EVERYTHING = "Everything"; +OPTVAL_FULLSCREENONLY = "Fullscreen only"; // Colors C_BRICK = "\cabrick"; C_TAN = "\cbtan"; @@ -2574,3 +2575,137 @@ MUSIC_ULTIMA = "ultima"; MUSIC_READ_M = "read_m"; MUSIC_DM2TTL = "dm2ttl"; MUSIC_DM2INT = "dm2int"; + +// GZDoom exclusive: + +DSPLYMNU_GLOPT = "OpenGL Options"; +DSPLYMNU_GAMMA = "Gamma correction"; +DSPLYMNU_CONTRAST ="Contrast"; +DSPLYMNU_HWGAMMA = "Hardware Gamma"; + +// OpenGL Options +GLMNU_TITLE = "OPENGL OPTIONS"; +GLMNU_DYNLIGHT = "Dynamic Light Options"; +GLMNU_TEXOPT = "Texture Options"; +GLMNU_PREFS = "Preferences"; + +// Texture Options +GLTEXMNU_TITLE = "TEXTURE OPTIONS"; +GLTEXMNU_TEXENABLED = "Textures enabled"; +GLTEXMNU_TEXFILTER = "Texture Filter mode"; +GLTEXMNU_ANISOTROPIC = "Anisotropic filter"; +GLTEXMNU_TEXFORMAT = "Texture Format"; +GLTEXMNU_ENABLEHIRES = "Enable hires textures"; +GLTEXMNU_HQRESIZE = "High Quality Resize mode"; +GLTEXMNU_RESIZETEX = "Resize textures"; +GLTEXMNU_RESIZESPR = "Resize sprites"; +GLTEXMNU_RESIZEFNT = "Resize fonts"; +GLTEXMNU_PRECACHETEX = "Precache GL textures"; +GLTEXMNU_TRIMSPREDGE = "Trim sprite edges"; +GLTEXMNU_SORTDRAWLIST = "Sort draw lists by texture"; + +// Dynamic Light Options +GLLIGHTMNU_TITLE = "DYNAMIC LIGHTS"; +GLLIGHTMNU_LIGHTSENABLED = "Dynamic Lights enabled"; +GLLIGHTMNU_LIGHTDEFS = "Enable light definitions"; +GLLIGHTMNU_CLIPLIGHTS = "Clip lights"; +GLLIGHTMNU_LIGHTSPRITES = "Lights affect sprites"; +GLLIGHTMNU_LIGHTPARTICLES = "Lights affect particles"; + +// OpenGL Preferences +GLPREFMNU_TITLE = "OPENGL PREFERENCES"; +GLPREFMNU_SECLIGHTMODE = "Sector light mode"; +GLPREFMNU_FOGMODE = "Fog mode"; +GLPREFMNU_FOGFORCEFULLBRIGHT = "Fog forces fullbright"; +GLPREFMNU_WPNLIGHTSTR = "Weapon light strength"; +GLPREFMNU_ENVIRONMENTMAPMIRROR = "Environment map on mirrors"; +GLPREFMNU_ENV = "Enhanced night vision mode"; +GLPREFMNU_ENVSTEALTH = "ENV shows stealth monsters"; +GLPREFMNU_SPRBRIGHTFOG = "Force brightness in fog"; +GLPREFMNU_SPRCLIP = "Adjust sprite clipping"; +GLPREFMNU_SPRBLEND = "Smooth sprite edges"; +GLPREFMNU_FUZZSTYLE = "Fuzz Style"; +GLPREFMNU_SPRBILLBOARD = "Sprite billboard"; +GLPREFMNU_SPRBILLFACECAMERA = "Sprites face camera"; +GLPREFMNU_PARTICLESTYLE = "Particle style"; +GLPREFMNU_AMBLIGHT = "Ambient light level"; +GLPREFMNU_RENDERQUALITY = "Rendering quality"; +GLPREFMNU_VRMODE = "Stereo 3D VR"; +GLPREFMNU_VRQUADSTEREO = "Enable Quad Stereo"; +GLPREFMNU_MULTISAMPLE = "Multisample"; +GLPREFMNU_TONEMAP = "Tonemap Mode"; +GLPREFMNU_BLOOM = "Bloom effect"; +GLPREFMNU_LENS = "Lens distortion effect"; + +// Option Values +OPTVAL_SMART = "Smart"; +OPTVAL_SMARTER = "Smarter"; +OPTVAL_INFRAREDONLY = "Infrared only"; +OPTVAL_INFRAREDANDTORCH = "Infrared and torch"; +OPTVAL_ANYFIXEDCOLORMAP = "Any fixed colormap"; +OPTVAL_NONENEARESTMIPMAP = "None (nearest mipmap)"; +OPTVAL_NONELINEARMIPMAP = "None (linear mipmap)"; +OPTVAL_NONETRILINEAR = "None (trilinear)"; +OPTVAL_BILINEAR = "Bilinear"; +OPTVAL_TRILINEAR = "Trilinear"; +OPTVAL_RGBA8 = "RGBA8"; +OPTVAL_RGB5A1 = "RGB5_A1"; +OPTVAL_RGBA4 = "RGBA4"; +OPTVAL_RGBA2 = "RGBA2"; +OPTVAL_COMPRRGBA = "COMPR_RGBA"; +OPTVAL_S3TCDXT1 = "S3TC_DXT1"; +OPTVAL_S3TCDXT3 = "S3TC_DXT3"; +OPTVAL_S3TCDXT5 = "S3TC_DXT5"; +OPTVAL_2X = "2x"; +OPTVAL_4X = "4x"; +OPTVAL_8X = "8x"; +OPTVAL_16X = "16x"; +OPTVAL_32X = "32x"; +OPTVAL_USEASPALETTE = "Use as palette"; +OPTVAL_BLEND = "Blend"; +OPTVAL_STANDARD = "Standard"; +OPTVAL_BRIGHT = "Bright"; +OPTVAL_DARK = "Dark"; +OPTVAL_LEGACY = "Legacy"; +OPTVAL_SOFTWARE = "Software"; +OPTVAL_SPEED = "Speed"; +OPTVAL_QUALITY = "Quality"; +OPTVAL_OPTIMAL = "Optimal"; +OPTVAL_60 = "60"; +OPTVAL_70 = "70"; +OPTVAL_72 = "72"; +OPTVAL_75 = "75"; +OPTVAL_85 = "85"; +OPTVAL_100 = "100"; +OPTVAL_YAXIS = "Y Axis"; +OPTVAL_XYAXIS = "X/Y Axis"; +OPTVAL_SQUARE = "Square"; +OPTVAL_ROUND = "Round"; +OPTVAL_SCALE2X = "Scale2x"; +OPTVAL_SCALE3X = "Scale3x"; +OPTVAL_SCALE4X = "Scale4x"; +OPTVAL_HQ2X = "hq2x"; +OPTVAL_HQ3X = "hq3x"; +OPTVAL_HQ4X = "hq4x"; +OPTVAL_HQ2XMMX = "hq2x MMX"; +OPTVAL_HQ3XMMX = "hq3x MMX"; +OPTVAL_HQ4XMMX = "hq4x MMX"; +OPTVAL_RADIAL = "Radial"; +OPTVAL_PIXELFUZZ = "Pixel fuzz"; +OPTVAL_SMOOTHFUZZ = "Smooth fuzz"; +OPTVAL_SWIRLYFUZZ = "Swirly fuzz"; +OPTVAL_TRANSLUCENTFUZZ = "Translucent fuzz"; +OPTVAL_NOISE = "Noise"; +OPTVAL_SMOOTHNOISE = "Smooth Noise"; +OPTVAL_JAGGEDFUZZ = "Jagged fuzz"; +OPTVAL_NORMAL = "Normal"; +OPTVAL_GREENMAGENTA = "Green/Magenta"; +OPTVAL_REDCYAN = "Red/Cyan"; +OPTVAL_AMBERBLUE = "Amber/Blue"; +OPTVAL_LEFTEYE = "Left Eye"; +OPTVAL_RIGHTEYE = "Right Eye"; +OPTVAL_QUADBUFFERED = "Quad-buffered"; +OPTVAL_UNCHARTED2 = "Uncharted 2"; +OPTVAL_HEJLDAWSON = "Hejl Dawson"; +OPTVAL_REINHARD = "Reinhard"; +OPTVAL_PALETTE = "Palette"; \ No newline at end of file diff --git a/wadsrc/static/mapinfo/common.txt b/wadsrc/static/mapinfo/common.txt index 347f424f9..5e69a3ef9 100644 --- a/wadsrc/static/mapinfo/common.txt +++ b/wadsrc/static/mapinfo/common.txt @@ -30,8 +30,8 @@ DoomEdNums 1411 = "$SSeqOverride" 1500 = "$VavoomFloor" 1501 = "$VavoomCeiling" - 1502 = none - 1503 = none + 1502 = VavoomLightWhite + 1503 = VavoomLightColor 1504 = "$VertexFloorZ" 1505 = "$VertexCeilingZ" 5001 = PointPusher @@ -88,22 +88,22 @@ DoomEdNums 9503 = "$SetCeilingSlope" 9510 = "$CopyFloorPlane" 9511 = "$CopyCeilingPlane" - 9800 = none - 9801 = none - 9802 = none - 9803 = none - 9804 = none - 9810 = none - 9811 = none - 9812 = none - 9813 = none - 9814 = none - 9820 = none - 9821 = none - 9822 = none - 9823 = none - 9824 = none - 9825 = none + 9800 = PointLight + 9801 = PointLightPulse + 9802 = PointLightFlicker + 9803 = SectorPointLight + 9804 = PointLightFlickerRandom + 9810 = PointLightAdditive + 9811 = PointLightPulseAdditive + 9812 = PointLightFlickerAdditive + 9813 = SectorPointLightAdditive + 9814 = PointLightFlickerRandomAdditive + 9820 = PointLightSubtractive + 9821 = PointLightPulseSubtractive + 9822 = PointLightFlickerSubtractive + 9823 = SectorPointLightSubtractive + 9824 = PointLightFlickerRandomSubtractive + 9825 = VavoomLight 9982 = SecActEyesAboveC 9983 = SecActEyesBelowC 9988 = CustomSprite diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 0202a40e6..94a929080 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -650,17 +650,30 @@ OptionValue Fuzziness 2.0, "$OPTVAL_SHADOW" } +OptionMenu "OpenGLOptions" +{ + Title "$GLMNU_TITLE" + Submenu "$GLMNU_DYNLIGHT", "GLLightOptions" + Submenu "$GLMNU_TEXOPT", "GLTextureGLOptions" + Submenu "$GLMNU_PREFS", "GLPrefOptions" +} + OptionMenu "VideoOptions" { Title "$DSPLYMNU_TITLE" + Submenu "$DSPLYMNU_GLOPT", "OpenGLOptions" Submenu "$DSPLYMNU_SCOREBOARD", "ScoreboardOptions" StaticText " " Slider "$DSPLYMNU_SCREENSIZE", "screenblocks", 3.0, 12.0, 1.0, 0 - Slider "$DSPLYMNU_BRIGHTNESS", "Gamma", 0.75, 3.0, 0.05, 2 + + Slider "$DSPLYMNU_GAMMA", "Gamma", 0.75, 3.0, 0.05, 2 + Slider "$DSPLYMNU_BRIGHTNESS", "vid_brightness", -0.8,0.8, 0.05 + Slider "$DSPLYMNU_CONTRAST", "vid_contrast", 0.1, 3.0, 0.1 + Option "$DSPLYMNU_HWGAMMA", "vid_hwgamma", "HWGammaModes" + Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff" Option "$DSPLYMNU_CAPFPS", "cl_capfps", "OffOn" - Option "$DSPLYMNU_COLUMNMETHOD", "r_columnmethod", "ColumnMethods" Option "$DSPLYMNU_TRUECOLOR", "swtruecolor", "OnOff" Option "$DSPLYMNU_MINFILTER", "r_minfilter", "OnOff" Option "$DSPLYMNU_MAGFILTER", "r_magfilter", "OnOff" diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z new file mode 100644 index 000000000..980cdacc3 --- /dev/null +++ b/wadsrc/static/menudef.z @@ -0,0 +1,227 @@ +OptionValue "SpriteclipModes" +{ + 0, "$OPTVAL_NEVER" + 1, "$OPTVAL_SMART" + 2, "$OPTVAL_ALWAYS" + 3, "$OPTVAL_SMARTER" +} + +OptionValue "EnhancedStealth" +{ + 0, "$OPTVAL_NEVER" + 1, "$OPTVAL_INFRAREDONLY" + 2, "$OPTVAL_INFRAREDANDTORCH" + 3, "$OPTVAL_ANYFIXEDCOLORMAP" +} + +OptionValue "FilterModes" +{ + 0, "$OPTVAL_NONE" + 1, "$OPTVAL_NONENEARESTMIPMAP" + 5, "$OPTVAL_NONELINEARMIPMAP" + 6, "$OPTVAL_NONETRILINEAR" + 2, "$OPTVAL_LINEAR" + 3, "$OPTVAL_BILINEAR" + 4, "$OPTVAL_TRILINEAR" +} + +OptionValue "HWGammaModes" +{ + 0, "$OPTVAL_ON" + 1, "$OPTVAL_OFF" + 2, "$OPTVAL_FULLSCREENONLY" +} + +OptionValue "TonemapModes" +{ + 0, "$OPTVAL_OFF" + 1, "$OPTVAL_UNCHARTED2" + 2, "$OPTVAL_HEJLDAWSON" + 3, "$OPTVAL_REINHARD" + 4, "$OPTVAL_LINEAR" + 5, "$OPTVAL_PALETTE" +} + +OptionValue "TextureFormats" +{ + 0, "$OPTVAL_RGBA8" + 1, "$OPTVAL_RGB5A1" + 2, "$OPTVAL_RGBA4" + 3, "$OPTVAL_RGBA2" + // [BB] Added modes for texture compression. + 4, "$OPTVAL_COMPRRGBA" + 5, "$OPTVAL_S3TCDXT1" + 6, "$OPTVAL_S3TCDXT3" + 7, "$OPTVAL_S3TCDXT5" +} + +OptionValue "Anisotropy" +{ + 1, "$OPTVAL_OFF" + 2, "$OPTVAL_2X" + 4, "$OPTVAL_4X" + 8, "$OPTVAL_8X" + 16, "$OPTVAL_16X" +} + +OptionValue "Multisample" +{ + 1, "$OPTVAL_OFF" + 2, "$OPTVAL_2X" + 4, "$OPTVAL_4X" + 8, "$OPTVAL_8X" + 16, "$OPTVAL_16X" + 32, "$OPTVAL_32X" +} + +OptionValue "Colormaps" +{ + 0, "$OPTVAL_USEASPALETTE" + 1, "$OPTVAL_BLEND" +} + +OptionValue "LightingModes" +{ + 0, "$OPTVAL_STANDARD" + 1, "$OPTVAL_BRIGHT" + 2, "$OPTVAL_DOOM" + 3, "$OPTVAL_DARK" + 4, "$OPTVAL_LEGACY" + 8, "$OPTVAL_SOFTWARE" +} + +OptionValue "Precision" +{ + 0, "$OPTVAL_SPEED" + 1, "$OPTVAL_QUALITY" +} + + +OptionValue "Hz" +{ + 0, "$OPTVAL_OPTIMAL" + 60, "$OPTVAL_60" + 70, "$OPTVAL_70" + 72, "$OPTVAL_72" + 75, "$OPTVAL_75" + 85, "$OPTVAL_85" + 100, "$OPTVAL_100" +} + +OptionValue "BillboardModes" +{ + 0, "$OPTVAL_YAXIS" + 1, "$OPTVAL_XYAXIS" +} + + +OptionValue "Particles" +{ + 0, "$OPTVAL_SQUARE" + 1, "$OPTVAL_ROUND" + 2, "$OPTVAL_SMOOTH" +} + +OptionValue "HqResizeModes" +{ + 0, "$OPTVAL_OFF" + 1, "$OPTVAL_SCALE2X" + 2, "$OPTVAL_SCALE3X" + 3, "$OPTVAL_SCALE4X" + 4, "$OPTVAL_HQ2X" + 5, "$OPTVAL_HQ3X" + 6, "$OPTVAL_HQ4X" + 7, "$OPTVAL_HQ2XMMX" + 8, "$OPTVAL_HQ3XMMX" + 9, "$OPTVAL_HQ4XMMX" + 10, "xBRZ 2x" + 11, "xBRZ 3x" + 12, "xBRZ 4x" + 13, "xBRZ_old 2x" + 14, "xBRZ_old 3x" + 15, "xBRZ_old 4x" +} + +OptionValue "FogMode" +{ + 0, "$OPTVAL_OFF" + 1, "$OPTVAL_STANDARD" + 2, "$OPTVAL_RADIAL" +} + +OptionValue "FuzzStyle" +{ + 0, "$OPTVAL_SHADOW" + 1, "$OPTVAL_PIXELFUZZ" + 2, "$OPTVAL_SMOOTHFUZZ" + 3, "$OPTVAL_SWIRLYFUZZ" + 4, "$OPTVAL_TRANSLUCENTFUZZ" + 6, "$OPTVAL_NOISE" + 7, "$OPTVAL_SMOOTHNOISE" + //5, "$OPTVAL_JAGGEDFUZZ" I can't see any difference between this and 4 so it's disabled for now. +} + +OptionValue VRMode +{ + 0, "$OPTVAL_NORMAL" + 1, "$OPTVAL_GREENMAGENTA" + 2, "$OPTVAL_REDCYAN" + 9, "$OPTVAL_AMBERBLUE" + 5, "$OPTVAL_LEFTEYE" + 6, "$OPTVAL_RIGHTEYE" + 7, "$OPTVAL_QUADBUFFERED" +} + +OptionMenu "GLTextureGLOptions" +{ + Title "$GLTEXMNU_TITLE" + Option "$GLTEXMNU_TEXENABLED", gl_texture, "YesNo" + Option "$GLTEXMNU_TEXFILTER", gl_texture_filter, "FilterModes" + Option "$GLTEXMNU_ANISOTROPIC", gl_texture_filter_anisotropic, "Anisotropy" + Option "$GLTEXMNU_TEXFORMAT", gl_texture_format, "TextureFormats" + Option "$GLTEXMNU_ENABLEHIRES", gl_texture_usehires, "YesNo" + Option "$GLTEXMNU_HQRESIZE", gl_texture_hqresize, "HqResizeModes" + Option "$GLTEXMNU_RESIZETEX", gl_texture_hqresize_textures, "OnOff" + Option "$GLTEXMNU_RESIZESPR", gl_texture_hqresize_sprites, "OnOff" + Option "$GLTEXMNU_RESIZEFNT", gl_texture_hqresize_fonts, "OnOff" + Option "$GLTEXMNU_PRECACHETEX", gl_precache, "YesNo" + Option "$GLTEXMNU_TRIMSPREDGE", gl_trimsprites, "OnOff" + Option "$GLTEXMNU_SORTDRAWLIST", gl_sort_textures, "YesNo" +} + +OptionMenu "GLLightOptions" +{ + Title "$GLLIGHTMNU_TITLE" + Option "$GLLIGHTMNU_LIGHTSENABLED", gl_lights, "YesNo" + Option "$GLLIGHTMNU_LIGHTDEFS", gl_attachedlights, "YesNo" + Option "$GLLIGHTMNU_CLIPLIGHTS", gl_lights_checkside, "YesNo" + Option "$GLLIGHTMNU_LIGHTSPRITES", gl_light_sprites, "YesNo" + Option "$GLLIGHTMNU_LIGHTPARTICLES", gl_light_particles, "YesNo" +} + +OptionMenu "GLPrefOptions" +{ + Title "$GLPREFMNU_TITLE" + Option "$GLPREFMNU_SECLIGHTMODE", gl_lightmode, "LightingModes" + Option "$GLPREFMNU_FOGMODE", gl_fogmode, "FogMode" + Option "$GLPREFMNU_FOGFORCEFULLBRIGHT", gl_brightfog, "YesNo" + Slider "$GLPREFMNU_WPNLIGHTSTR", gl_weaponlight, 0,32, 2 + Option "$GLPREFMNU_ENVIRONMENTMAPMIRROR", gl_mirror_envmap, "OnOff" + Option "$GLPREFMNU_ENV", gl_enhanced_nightvision, "OnOff" + Option "$GLPREFMNU_ENVSTEALTH", gl_enhanced_nv_stealth, "EnhancedStealth" + Option "$GLPREFMNU_SPRBRIGHTFOG", gl_spritebrightfog, "OnOff" + Option "$GLPREFMNU_SPRCLIP", gl_spriteclip, "SpriteclipModes" + Option "$GLPREFMNU_SPRBLEND", gl_sprite_blend, "OnOff" + Option "$GLPREFMNU_FUZZSTYLE", gl_fuzztype, "FuzzStyle" + Option "$GLPREFMNU_SPRBILLBOARD", gl_billboard_mode, "BillboardModes" + Option "$GLPREFMNU_SPRBILLFACECAMERA", gl_billboard_faces_camera, "OnOff" + Option "$GLPREFMNU_PARTICLESTYLE", gl_particles_style, "Particles" + Slider "$GLPREFMNU_AMBLIGHT", gl_light_ambient, 1.0, 255.0, 5.0 + Option "$GLPREFMNU_RENDERQUALITY", gl_render_precise, "Precision" + Option "$GLPREFMNU_VRMODE", vr_mode, "VRMode" + Option "$GLPREFMNU_VRQUADSTEREO", vr_enable_quadbuffered, "OnOff" + Option "$GLPREFMNU_MULTISAMPLE", gl_multisample, "Multisample" + Option "$GLPREFMNU_TONEMAP", gl_tonemap, "TonemapModes" + Option "$GLPREFMNU_BLOOM", gl_bloom, "OnOff" + Option "$GLPREFMNU_LENS", gl_lens, "OnOff" +} diff --git a/wadsrc/static/shaders/glsl/bloomcombine.fp b/wadsrc/static/shaders/glsl/bloomcombine.fp new file mode 100644 index 000000000..57496771c --- /dev/null +++ b/wadsrc/static/shaders/glsl/bloomcombine.fp @@ -0,0 +1,10 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D Bloom; + +void main() +{ + FragColor = vec4(texture(Bloom, TexCoord).rgb, 0.0); +} diff --git a/wadsrc/static/shaders/glsl/bloomextract.fp b/wadsrc/static/shaders/glsl/bloomextract.fp new file mode 100644 index 000000000..bc94c3c0e --- /dev/null +++ b/wadsrc/static/shaders/glsl/bloomextract.fp @@ -0,0 +1,14 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D SceneTexture; +uniform float ExposureAdjustment; +uniform vec2 Scale; +uniform vec2 Offset; + +void main() +{ + vec4 color = texture(SceneTexture, Offset + TexCoord * Scale); + FragColor = max(vec4(color.rgb * ExposureAdjustment - 1, 1), vec4(0)); +} diff --git a/wadsrc/static/shaders/glsl/burn.fp b/wadsrc/static/shaders/glsl/burn.fp new file mode 100644 index 000000000..f928fd8db --- /dev/null +++ b/wadsrc/static/shaders/glsl/burn.fp @@ -0,0 +1,15 @@ +uniform sampler2D tex; +uniform sampler2D texture2; +in vec4 vTexCoord; +in vec4 vColor; +out vec4 FragColor; + +void main() +{ + vec4 frag = vColor; + + vec4 t1 = texture(tex, vTexCoord.xy); + vec4 t2 = texture(texture2, vec2(vTexCoord.x, 1.0-vTexCoord.y)); + + FragColor = frag * vec4(t1.r, t1.g, t1.b, t2.a); +} diff --git a/wadsrc/static/shaders/glsl/colormap.fp b/wadsrc/static/shaders/glsl/colormap.fp new file mode 100644 index 000000000..e86429c37 --- /dev/null +++ b/wadsrc/static/shaders/glsl/colormap.fp @@ -0,0 +1,16 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D tex; +uniform vec4 uFixedColormapStart; +uniform vec4 uFixedColormapRange; + +void main() +{ + vec4 frag = texture(tex, TexCoord); + float gray = (frag.r * 0.3 + frag.g * 0.56 + frag.b * 0.14); + vec4 cm = uFixedColormapStart + gray * uFixedColormapRange; + FragColor = vec4(clamp(cm.rgb, 0.0, 1.0), frag.a); +} + diff --git a/wadsrc/static/shaders/glsl/fogboundary.fp b/wadsrc/static/shaders/glsl/fogboundary.fp new file mode 100644 index 000000000..d8259c845 --- /dev/null +++ b/wadsrc/static/shaders/glsl/fogboundary.fp @@ -0,0 +1,30 @@ +in vec4 pixelpos; +in vec2 glowdist; +out vec4 FragColor; + +//=========================================================================== +// +// Main shader routine +// +//=========================================================================== + +void main() +{ + float fogdist; + float fogfactor; + + // + // calculate fog factor + // + if (uFogEnabled == -1) + { + fogdist = pixelpos.w; + } + else + { + fogdist = max(16.0, distance(pixelpos.xyz, uCameraPos.xyz)); + } + fogfactor = exp2 (uFogDensity * fogdist); + FragColor = vec4(uFogColor.rgb, 1.0 - fogfactor); +} + diff --git a/wadsrc/static/shaders/glsl/func_brightmap.fp b/wadsrc/static/shaders/glsl/func_brightmap.fp new file mode 100644 index 000000000..8e5f44d04 --- /dev/null +++ b/wadsrc/static/shaders/glsl/func_brightmap.fp @@ -0,0 +1,12 @@ +uniform sampler2D texture2; + +vec4 ProcessTexel() +{ + return getTexel(vTexCoord.st); +} + +vec4 ProcessLight(vec4 color) +{ + vec4 brightpix = desaturate(texture(texture2, vTexCoord.st)); + return vec4(min (color.rgb + brightpix.rgb, 1.0), color.a); +} diff --git a/wadsrc/static/shaders/glsl/func_defaultlight.fp b/wadsrc/static/shaders/glsl/func_defaultlight.fp new file mode 100644 index 000000000..227d38c6a --- /dev/null +++ b/wadsrc/static/shaders/glsl/func_defaultlight.fp @@ -0,0 +1,5 @@ + +vec4 ProcessLight(vec4 color) +{ + return color; +} diff --git a/wadsrc/static/shaders/glsl/func_normal.fp b/wadsrc/static/shaders/glsl/func_normal.fp new file mode 100644 index 000000000..184c14851 --- /dev/null +++ b/wadsrc/static/shaders/glsl/func_normal.fp @@ -0,0 +1,6 @@ + +vec4 ProcessTexel() +{ + return getTexel(vTexCoord.st); +} + diff --git a/wadsrc/static/shaders/glsl/func_notexture.fp b/wadsrc/static/shaders/glsl/func_notexture.fp new file mode 100644 index 000000000..9337ad6b1 --- /dev/null +++ b/wadsrc/static/shaders/glsl/func_notexture.fp @@ -0,0 +1,6 @@ + +vec4 ProcessTexel() +{ + return desaturate(uObjectColor); +} + diff --git a/wadsrc/static/shaders/glsl/func_warp1.fp b/wadsrc/static/shaders/glsl/func_warp1.fp new file mode 100644 index 000000000..891eaa936 --- /dev/null +++ b/wadsrc/static/shaders/glsl/func_warp1.fp @@ -0,0 +1,17 @@ +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + + const float pi = 3.14159265358979323846; + vec2 offset = vec2(0,0); + + offset.y = sin(pi * 2.0 * (texCoord.x + timer * 0.125)) * 0.1; + offset.x = sin(pi * 2.0 * (texCoord.y + timer * 0.125)) * 0.1; + + texCoord += offset; + + return getTexel(texCoord); +} + diff --git a/wadsrc/static/shaders/glsl/func_warp2.fp b/wadsrc/static/shaders/glsl/func_warp2.fp new file mode 100644 index 000000000..ee712593d --- /dev/null +++ b/wadsrc/static/shaders/glsl/func_warp2.fp @@ -0,0 +1,17 @@ +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + + const float pi = 3.14159265358979323846; + vec2 offset = vec2(0.0,0.0); + + offset.y = 0.5 + sin(pi * 2.0 * (texCoord.y + timer * 0.61 + 900.0/8192.0)) + sin(pi * 2.0 * (texCoord.x * 2.0 + timer * 0.36 + 300.0/8192.0)); + offset.x = 0.5 + sin(pi * 2.0 * (texCoord.y + timer * 0.49 + 700.0/8192.0)) + sin(pi * 2.0 * (texCoord.x * 2.0 + timer * 0.49 + 1200.0/8192.0)); + + texCoord += offset * 0.025; + + return getTexel(texCoord); +} + diff --git a/wadsrc/static/shaders/glsl/func_warp3.fp b/wadsrc/static/shaders/glsl/func_warp3.fp new file mode 100644 index 000000000..a81969ca6 --- /dev/null +++ b/wadsrc/static/shaders/glsl/func_warp3.fp @@ -0,0 +1,18 @@ +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + + const float pi = 3.14159265358979323846; + vec2 offset = vec2(0.0,0.0); + + float siny = sin(pi * 2.0 * (texCoord.y * 2.0 + timer * 0.75)) * 0.03; + offset.y = siny + sin(pi * 2.0 * (texCoord.x + timer * 0.75)) * 0.03; + offset.x = siny + sin(pi * 2.0 * (texCoord.x + timer * 0.45)) * 0.02; + + texCoord += offset; + + return getTexel(texCoord); +} + diff --git a/wadsrc/static/shaders/glsl/func_wavex.fp b/wadsrc/static/shaders/glsl/func_wavex.fp new file mode 100644 index 000000000..e4230ae87 --- /dev/null +++ b/wadsrc/static/shaders/glsl/func_wavex.fp @@ -0,0 +1,13 @@ +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + + const float pi = 3.14159265358979323846; + + texCoord.x += sin(pi * 2.0 * (texCoord.y + timer * 0.125)) * 0.1; + + return getTexel(texCoord); +} + diff --git a/wadsrc/static/shaders/glsl/fuzz_jagged.fp b/wadsrc/static/shaders/glsl/fuzz_jagged.fp new file mode 100644 index 000000000..c088c7b30 --- /dev/null +++ b/wadsrc/static/shaders/glsl/fuzz_jagged.fp @@ -0,0 +1,25 @@ +//created by Evil Space Tomato +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + + vec2 texSplat; + const float pi = 3.14159265358979323846; + texSplat.x = texCoord.x + mod(sin(pi * 2.0 * (texCoord.y + timer * 2.0)),0.1) * 0.1; + texSplat.y = texCoord.y + mod(cos(pi * 2.0 * (texCoord.x + timer * 2.0)),0.1) * 0.1; + + vec4 basicColor = getTexel(texSplat); + + float texX = sin(texCoord.x * 100.0 + timer*5.0); + float texY = cos(texCoord.x * 100.0 + timer*5.0); + float vX = (texX/texY)*21.0; + float vY = (texY/texX)*13.0; + + float test = mod(timer*2.0+(vX + vY), 0.5); + + basicColor.a = basicColor.a * test; + + return basicColor; +} diff --git a/wadsrc/static/shaders/glsl/fuzz_noise.fp b/wadsrc/static/shaders/glsl/fuzz_noise.fp new file mode 100644 index 000000000..9f5da5f25 --- /dev/null +++ b/wadsrc/static/shaders/glsl/fuzz_noise.fp @@ -0,0 +1,21 @@ +//created by Evil Space Tomato +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + vec4 basicColor = getTexel(texCoord); + + texCoord.x = float( int(texCoord.x * 128.0) ) / 128.0; + texCoord.y = float( int(texCoord.y * 128.0) ) / 128.0; + + float texX = sin(mod(texCoord.x * 100.0 + timer*5.0, 3.489)) + texCoord.x / 4.0; + float texY = cos(mod(texCoord.y * 100.0 + timer*5.0, 3.489)) + texCoord.y / 4.0; + float vX = (texX/texY)*21.0; + float vY = (texY/texX)*13.0; + + float test = mod(timer*2.0+(vX + vY), 0.5); + basicColor.a = basicColor.a * test; + basicColor.rgb = vec3(0.0,0.0,0.0); + return basicColor; +} diff --git a/wadsrc/static/shaders/glsl/fuzz_smooth.fp b/wadsrc/static/shaders/glsl/fuzz_smooth.fp new file mode 100644 index 000000000..4261d5415 --- /dev/null +++ b/wadsrc/static/shaders/glsl/fuzz_smooth.fp @@ -0,0 +1,19 @@ +//created by Evil Space Tomato +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + vec4 basicColor = getTexel(texCoord); + + float texX = texCoord.x / 3.0 + 0.66; + float texY = 0.34 - texCoord.y / 3.0; + float vX = (texX/texY)*21.0; + float vY = (texY/texX)*13.0; + float test = mod(timer*2.0+(vX + vY), 0.5); + + basicColor.a = basicColor.a * test; + basicColor.r = basicColor.g = basicColor.b = 0.0; + + return basicColor; +} diff --git a/wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp b/wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp new file mode 100644 index 000000000..bfe04ec16 --- /dev/null +++ b/wadsrc/static/shaders/glsl/fuzz_smoothnoise.fp @@ -0,0 +1,20 @@ +//created by Evil Space Tomato +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + vec4 basicColor = getTexel(texCoord); + + float texX = sin(mod(texCoord.x * 100.0 + timer*5.0, 3.489)) + texCoord.x / 4.0; + float texY = cos(mod(texCoord.y * 100.0 + timer*5.0, 3.489)) + texCoord.y / 4.0; + float vX = (texX/texY)*21.0; + float vY = (texY/texX)*13.0; + + + float test = mod(timer*2.0+(vX + vY), 0.5); + basicColor.a = basicColor.a * test; + + basicColor.rgb = vec3(0.0,0.0,0.0); + return basicColor; +} diff --git a/wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp b/wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp new file mode 100644 index 000000000..75bee0330 --- /dev/null +++ b/wadsrc/static/shaders/glsl/fuzz_smoothtranslucent.fp @@ -0,0 +1,19 @@ +//created by Evil Space Tomato +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + vec4 basicColor = getTexel(texCoord); + + float texX = sin(texCoord.x * 100.0 + timer*5.0); + float texY = cos(texCoord.x * 100.0 + timer*5.0); + float vX = (texX/texY)*21.0; + float vY = (texY/texX)*13.0; + + float test = mod(timer*2.0+(vX + vY), 0.5); + + basicColor.a = basicColor.a * test; + + return basicColor; +} diff --git a/wadsrc/static/shaders/glsl/fuzz_standard.fp b/wadsrc/static/shaders/glsl/fuzz_standard.fp new file mode 100644 index 000000000..fd87eaa46 --- /dev/null +++ b/wadsrc/static/shaders/glsl/fuzz_standard.fp @@ -0,0 +1,22 @@ +//created by Evil Space Tomato +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + vec4 basicColor = getTexel(texCoord); + + texCoord.x = float( int(texCoord.x * 128.0) ) / 128.0; + texCoord.y = float( int(texCoord.y * 128.0) ) / 128.0; + + float texX = texCoord.x / 3.0 + 0.66; + float texY = 0.34 - texCoord.y / 3.0; + float vX = (texX/texY)*21.0; + float vY = (texY/texX)*13.0; + float test = mod(timer*2.0+(vX + vY), 0.5); + + basicColor.a = basicColor.a * test; + basicColor.r = basicColor.g = basicColor.b = 0.0; + + return basicColor; +} diff --git a/wadsrc/static/shaders/glsl/fuzz_swirly.fp b/wadsrc/static/shaders/glsl/fuzz_swirly.fp new file mode 100644 index 000000000..86a66ac8e --- /dev/null +++ b/wadsrc/static/shaders/glsl/fuzz_swirly.fp @@ -0,0 +1,19 @@ +//created by Evil Space Tomato +uniform float timer; + +vec4 ProcessTexel() +{ + vec2 texCoord = vTexCoord.st; + vec4 basicColor = getTexel(texCoord); + + float texX = sin(texCoord.x * 100.0 + timer*5.0); + float texY = cos(texCoord.x * 100.0 + timer*5.0); + float vX = (texX/texY)*21.0; + float vY = (texY/texX)*13.0; + float test = mod(timer*2.0+(vX + vY), 0.5); + + basicColor.a = basicColor.a * test; + basicColor.r = basicColor.g = basicColor.b = 0.0; + + return basicColor; +} diff --git a/wadsrc/static/shaders/glsl/lensdistortion.fp b/wadsrc/static/shaders/glsl/lensdistortion.fp new file mode 100644 index 000000000..7facf5a80 --- /dev/null +++ b/wadsrc/static/shaders/glsl/lensdistortion.fp @@ -0,0 +1,58 @@ +/* + Original Lens Distortion Algorithm from SSontech + http://www.ssontech.com/content/lensalg.htm + + If (u,v) are the coordinates of a feature in the undistorted perfect + image plane, then (u', v') are the coordinates of the feature on the + distorted image plate, ie the scanned or captured image from the + camera. The distortion occurs radially away from the image center, + with correction for the image aspect ratio (image_aspect = physical + image width/height), as follows: + + r2 = image_aspect*image_aspect*u*u + v*v + f = 1 + r2*(k + kcube*sqrt(r2)) + u' = f*u + v' = f*v + + The constant k is the distortion coefficient that appears on the lens + panel and through Sizzle. It is generally a small positive or negative + number under 1%. The constant kcube is the cubic distortion value found + on the image preprocessor's lens panel: it can be used to undistort or + redistort images, but it does not affect or get computed by the solver. + When no cubic distortion is needed, neither is the square root, saving + time. + + Chromatic Aberration example, + using red distord channel with green and blue undistord channel: + + k = vec3(-0.15, 0.0, 0.0); + kcube = vec3(0.15, 0.0, 0.0); +*/ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D InputTexture; +uniform float Aspect; // image width/height +uniform float Scale; // 1/max(f) +uniform vec4 k; // lens distortion coefficient +uniform vec4 kcube; // cubic distortion value + +void main() +{ + vec2 position = (TexCoord - vec2(0.5)); + + vec2 p = vec2(position.x * Aspect, position.y); + float r2 = dot(p, p); + vec3 f = vec3(1.0) + r2 * (k.rgb + kcube.rgb * sqrt(r2)); + + vec3 x = f * position.x * Scale + 0.5; + vec3 y = f * position.y * Scale + 0.5; + + vec3 c; + c.r = texture(InputTexture, vec2(x.r, y.r)).r; + c.g = texture(InputTexture, vec2(x.g, y.g)).g; + c.b = texture(InputTexture, vec2(x.b, y.b)).b; + + FragColor = vec4(c, 1.0); +} diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp new file mode 100644 index 000000000..95ac874b7 --- /dev/null +++ b/wadsrc/static/shaders/glsl/main.fp @@ -0,0 +1,349 @@ +in vec4 pixelpos; +in vec2 glowdist; + +in vec4 vTexCoord; +in vec4 vColor; + +out vec4 FragColor; + +#ifdef SHADER_STORAGE_LIGHTS + layout(std430, binding = 1) buffer LightBufferSSO + { + vec4 lights[]; + }; +#elif defined NUM_UBO_LIGHTS + /*layout(std140)*/ uniform LightBufferUBO + { + vec4 lights[NUM_UBO_LIGHTS]; + }; +#endif + + +uniform sampler2D tex; + +vec4 Process(vec4 color); +vec4 ProcessTexel(); +vec4 ProcessLight(vec4 color); + + +//=========================================================================== +// +// Desaturate a color +// +//=========================================================================== + +vec4 desaturate(vec4 texel) +{ + if (uDesaturationFactor > 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 exactly as calculated by zdoom. +// +//=========================================================================== +float R_DoomLightingEquation(float light) +{ + // Calculated from r_visibility. It differs between walls, floor and sprites. + // + // Wall: globVis = r_WallVisibility + // Floor: r_FloorVisibility / abs(plane.Zat0 - ViewPos.Z) + // Sprite: same as wall + // All are calculated in R_SetVisibility and seem to be decided by the + // aspect ratio amongst other things. + // + // 1706 is the value for walls on 1080p 16:9 displays. + float globVis = 1706.0; + + /* L is the integer light level used in the game */ + float L = light * 255.0; + + /* z is the depth in view/eye space, positive going into the screen */ + float z = pixelpos.w; + + /* The zdoom light equation */ + float vis = globVis / z; + float shade = 64.0 - (L + 12.0) * 32.0/128.0; + float lightscale = clamp((shade - min(24.0, vis)) / 32.0, 0.0, 31.0/32.0); + + // Result is the normalized colormap index (0 bright .. 1 dark) + return lightscale; +} + +//=========================================================================== +// +// 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); + color.rgb *= newlightlevel; + } + else if (uFogEnabled > 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 defined NUM_UBO_LIGHTS || defined SHADER_STORAGE_LIGHTS + 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 -1000000.0) // and for line portals - this will never be active at the same time as the reflective planes clipping so it can use the same hardware clip plane. + { + gl_ClipDistance[0] = -( (worldcoord.z - uClipLine.y) * uClipLine.z + (uClipLine.x - worldcoord.x) * uClipLine.w ) + 1.0/32768.0; // allow a tiny bit of imprecisions for colinear linedefs. + } + + // clip planes used for translucency splitting + gl_ClipDistance[1] = worldcoord.y - uClipSplit.x; + gl_ClipDistance[2] = uClipSplit.y - worldcoord.y; + +} diff --git a/wadsrc/static/shaders/glsl/present.fp b/wadsrc/static/shaders/glsl/present.fp new file mode 100644 index 000000000..53fc007b6 --- /dev/null +++ b/wadsrc/static/shaders/glsl/present.fp @@ -0,0 +1,21 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D InputTexture; +uniform float InvGamma; +uniform float Contrast; +uniform float Brightness; + +vec4 ApplyGamma(vec4 c) +{ + vec3 val = max(c.rgb * Contrast - (Contrast - 1.0) * 0.5, vec3(0.0)); + val = pow(val, vec3(InvGamma)); + val += Brightness * 0.5; + return vec4(val, c.a); +} + +void main() +{ + FragColor = ApplyGamma(texture(InputTexture, TexCoord)); +} diff --git a/wadsrc/static/shaders/glsl/screenquad.vp b/wadsrc/static/shaders/glsl/screenquad.vp new file mode 100644 index 000000000..fea7e25ad --- /dev/null +++ b/wadsrc/static/shaders/glsl/screenquad.vp @@ -0,0 +1,10 @@ + +in vec4 PositionInProjection; +in vec2 UV; +out vec2 TexCoord; + +void main() +{ + gl_Position = PositionInProjection; + TexCoord = UV; +} diff --git a/wadsrc/static/shaders/glsl/screenquadscale.vp b/wadsrc/static/shaders/glsl/screenquadscale.vp new file mode 100644 index 000000000..2d7f505b4 --- /dev/null +++ b/wadsrc/static/shaders/glsl/screenquadscale.vp @@ -0,0 +1,11 @@ + +in vec4 PositionInProjection; +in vec2 UV; +uniform vec2 UVScale; +out vec2 TexCoord; + +void main() +{ + gl_Position = PositionInProjection; + TexCoord = UV * UVScale; +} diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i new file mode 100644 index 000000000..3701694bc --- /dev/null +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -0,0 +1,60 @@ +// This file contains common data definitions for both vertex and fragment shader + +// these settings are actually pointless but there seem to be some old ATI drivers that fail to compile the shader without setting the precision here. +precision highp int; +precision highp float; + +uniform vec4 uCameraPos; +uniform int uTextureMode; +uniform float uClipHeight, uClipHeightDirection; +uniform vec2 uClipSplit; +uniform vec4 uClipLine; + +uniform float uAlphaThreshold; + + +// colors +uniform vec4 uObjectColor; +uniform vec4 uDynLightColor; +uniform vec4 uFogColor; +uniform float uDesaturationFactor; +uniform float uInterpolationFactor; + +// Fixed colormap stuff +uniform int uFixedColormap; // 0, when no fixed colormap, 1 for a light value, 2 for a color blend, 3 for a fog layer +uniform vec4 uFixedColormapStart; +uniform vec4 uFixedColormapRange; + +// Glowing walls stuff +uniform vec4 uGlowTopPlane; +uniform vec4 uGlowTopColor; +uniform vec4 uGlowBottomPlane; +uniform vec4 uGlowBottomColor; + +uniform vec4 uSplitTopPlane; +uniform vec4 uSplitBottomPlane; + +// Lighting + Fog +uniform vec4 uLightAttr; +#define uLightLevel uLightAttr.a +#define uFogDensity uLightAttr.b +#define uLightFactor uLightAttr.g +#define uLightDist uLightAttr.r +uniform int uFogEnabled; + +// dynamic lights +uniform int uLightIndex; + +// quad drawer stuff +#ifdef USE_QUAD_DRAWER +uniform mat4 uQuadVertices; +uniform mat4 uQuadTexCoords; +uniform int uQuadMode; +#endif + +// matrices +uniform mat4 ProjectionMatrix; +uniform mat4 ViewMatrix; +uniform mat4 ModelMatrix; +uniform mat4 TextureMatrix; + diff --git a/wadsrc/static/shaders/glsl/stencil.fp b/wadsrc/static/shaders/glsl/stencil.fp new file mode 100644 index 000000000..d1b8745f6 --- /dev/null +++ b/wadsrc/static/shaders/glsl/stencil.fp @@ -0,0 +1,8 @@ +in vec4 pixelpos; +out vec4 FragColor; + +void main() +{ + FragColor = vec4(1.0); +} + diff --git a/wadsrc/static/shaders/glsl/tonemap.fp b/wadsrc/static/shaders/glsl/tonemap.fp new file mode 100644 index 000000000..d6574b295 --- /dev/null +++ b/wadsrc/static/shaders/glsl/tonemap.fp @@ -0,0 +1,91 @@ + +in vec2 TexCoord; +out vec4 FragColor; + +uniform sampler2D InputTexture; +uniform float ExposureAdjustment; + +vec3 Linear(vec3 c) +{ + //c = max(c, vec3(0.0)); + //return pow(c, 2.2); + return c * c; // cheaper, but assuming gamma of 2.0 instead of 2.2 +} + +vec3 sRGB(vec3 c) +{ + c = max(c, vec3(0.0)); + //return pow(c, vec3(1.0 / 2.2)); + return sqrt(c); // cheaper, but assuming gamma of 2.0 instead of 2.2 +} + +#if defined(LINEAR) + +vec3 Tonemap(vec3 color) +{ + return sRGB(color); +} + +#elif defined(REINHARD) + +vec3 Tonemap(vec3 color) +{ + color = color / (1 + color); + return sRGB(color); +} + +#elif defined(HEJLDAWSON) + +vec3 Tonemap(vec3 color) +{ + vec3 x = max(vec3(0), color - 0.004); + return (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06); // no sRGB needed +} + +#elif defined(UNCHARTED2) + +vec3 Uncharted2Tonemap(vec3 x) +{ + float A = 0.15; + float B = 0.50; + float C = 0.10; + float D = 0.20; + float E = 0.02; + float F = 0.30; + return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F; +} + +vec3 Tonemap(vec3 color) +{ + float W = 11.2; + vec3 curr = Uncharted2Tonemap(color); + vec3 whiteScale = vec3(1) / Uncharted2Tonemap(vec3(W)); + return sRGB(curr * whiteScale); +} + +#elif defined(PALETTE) + +uniform sampler2D PaletteLUT; + +vec3 Tonemap(vec3 color) +{ + ivec3 c = ivec3(clamp(color.rgb, vec3(0.0), vec3(1.0)) * 63.0 + 0.5); + int index = (c.r * 64 + c.g) * 64 + c.b; + int tx = index % 512; + int ty = index / 512; + return texelFetch(PaletteLUT, ivec2(tx, ty), 0).rgb; +} + +#else +#error Tonemap mode define is missing +#endif + +void main() +{ + vec3 color = texture(InputTexture, TexCoord).rgb; +#ifndef PALETTE + color = color * ExposureAdjustment; + color = Linear(color); // needed because gzdoom's scene texture is not linear at the moment +#endif + FragColor = vec4(Tonemap(color), 1.0); +} 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