Merge branch 'master' into clientserver

This commit is contained in:
Magnus Norddahl 2020-06-05 00:20:44 +02:00
commit f09fe7babc
547 changed files with 11258 additions and 9764 deletions

View file

@ -156,6 +156,7 @@ macro( use_fast_math )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ZD_FASTMATH_FLAG}" ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ZD_FASTMATH_FLAG}" )
endmacro() endmacro()
include( CheckFunctionExists ) include( CheckFunctionExists )
macro( require_stricmp ) macro( require_stricmp )
@ -203,9 +204,9 @@ if( MSVC )
# Function-level linking # Function-level linking
# Disable run-time type information # Disable run-time type information
if ( HAVE_VULKAN ) if ( HAVE_VULKAN )
set( ALL_C_FLAGS "/GF /Gy /permissive- /DHAVE_VULKAN" ) set( ALL_C_FLAGS "/GF /Gy /permissive- /DHAVE_VULKAN /DHAVE_SOFTPOLY" )
else() else()
set( ALL_C_FLAGS "/GF /Gy /permissive-" ) set( ALL_C_FLAGS "/GF /Gy /permissive- /DHAVE_SOFTPOLY" )
endif() endif()
# Use SSE 2 as minimum always as the true color drawers needs it for __vectorcall # Use SSE 2 as minimum always as the true color drawers needs it for __vectorcall
@ -241,9 +242,9 @@ if( MSVC )
else() else()
set( REL_LINKER_FLAGS "" ) set( REL_LINKER_FLAGS "" )
if ( HAVE_VULKAN ) if ( HAVE_VULKAN )
set( ALL_C_FLAGS "-ffp-contract=off -DHAVE_VULKAN" ) set( ALL_C_FLAGS "-ffp-contract=off -DHAVE_VULKAN -DHAVE_SOFTPOLY" )
else() else()
set( ALL_C_FLAGS "-ffp-contract=off" ) set( ALL_C_FLAGS "-ffp-contract=off -DHAVE_SOFTPOLY" )
endif() endif()
if ( UNIX ) if ( UNIX )

View file

@ -159,6 +159,11 @@ else()
endif() endif()
endif() endif()
option( NO_SDL_JOYSTICK "Disable SDL joystick support (Not applicable to Windows)" OFF )
if ( NO_SDL_JOYSTICK )
add_definitions( -DNO_SDL_JOYSTICK=1 )
endif ( NO_SDL_JOYSTICK )
if( NO_GTK ) if( NO_GTK )
add_definitions( -DNO_GTK ) add_definitions( -DNO_GTK )
elseif( DYN_GTK ) elseif( DYN_GTK )
@ -438,82 +443,83 @@ endif()
# Start defining source files for ZDoom # Start defining source files for ZDoom
set( PLAT_WIN32_SOURCES set( PLAT_WIN32_SOURCES
win32/hardware.cpp win32/i_steam.cpp
win32/i_crash.cpp common/platform/win32/hardware.cpp
win32/i_input.cpp common/platform/win32/i_crash.cpp
win32/i_keyboard.cpp common/platform/win32/i_input.cpp
win32/i_mouse.cpp common/platform/win32/i_keyboard.cpp
win32/i_dijoy.cpp common/platform/win32/i_mouse.cpp
win32/i_rawps2.cpp common/platform/win32/i_dijoy.cpp
win32/i_xinput.cpp common/platform/win32/i_rawps2.cpp
win32/i_main.cpp common/platform/win32/i_xinput.cpp
win32/i_system.cpp common/platform/win32/i_main.cpp
win32/i_specialpaths.cpp common/platform/win32/i_system.cpp
win32/st_start.cpp common/platform/win32/i_specialpaths.cpp
win32/st_start_util.cpp common/platform/win32/st_start.cpp
win32/gl_sysfb.cpp common/platform/win32/st_start_util.cpp
win32/base_sysfb.cpp common/platform/win32/gl_sysfb.cpp
win32/win32basevideo.cpp common/platform/win32/base_sysfb.cpp
win32/win32glvideo.cpp common/platform/win32/win32basevideo.cpp
win32/win32polyvideo.cpp) common/platform/win32/win32glvideo.cpp
common/platform/win32/win32polyvideo.cpp)
if (HAVE_VULKAN) if (HAVE_VULKAN)
set (PLAT_WIN32_SOURCES ${PLAT_WIN32_SOURCES} win32/win32vulkanvideo.cpp ) set (PLAT_WIN32_SOURCES ${PLAT_WIN32_SOURCES} common/platform/win32/win32vulkanvideo.cpp )
endif() endif()
set( PLAT_POSIX_SOURCES set( PLAT_POSIX_SOURCES
posix/i_steam.cpp posix/i_steam.cpp
posix/i_system_posix.cpp ) common/platform/posix/i_system_posix.cpp )
set( PLAT_SDL_SOURCES set( PLAT_SDL_SOURCES
posix/sdl/crashcatcher.c common/platform/posix/sdl/crashcatcher.c
posix/sdl/hardware.cpp common/platform/posix/sdl/hardware.cpp
posix/sdl/i_gui.cpp common/platform/posix/sdl/i_gui.cpp
posix/sdl/i_input.cpp common/platform/posix/sdl/i_input.cpp
posix/sdl/i_joystick.cpp common/platform/posix/sdl/i_joystick.cpp
posix/sdl/i_main.cpp common/platform/posix/sdl/i_main.cpp
posix/sdl/i_system.cpp common/platform/posix/sdl/i_system.cpp
posix/sdl/sdlglvideo.cpp common/platform/posix/sdl/sdlglvideo.cpp
posix/sdl/st_start.cpp ) common/platform/posix/sdl/st_start.cpp )
set( PLAT_UNIX_SOURCES set( PLAT_UNIX_SOURCES
posix/unix/i_specialpaths.cpp common/platform/posix/unix/i_specialpaths.cpp
posix/unix/gtk_dialogs.cpp ) common/platform/posix/unix/gtk_dialogs.cpp )
set( PLAT_OSX_SOURCES set( PLAT_OSX_SOURCES
posix/osx/iwadpicker_cocoa.mm common/platform/posix/osx/iwadpicker_cocoa.mm
posix/osx/i_specialpaths.mm common/platform/posix/osx/i_specialpaths.mm
posix/osx/zdoom.icns ) posix/osx/zdoom.icns )
set( PLAT_COCOA_SOURCES set( PLAT_COCOA_SOURCES
posix/cocoa/i_input.mm common/platform/posix/cocoa/i_input.mm
posix/cocoa/i_joystick.cpp common/platform/posix/cocoa/i_joystick.cpp
posix/cocoa/i_main.mm common/platform/posix/cocoa/i_main.mm
posix/cocoa/i_system.mm common/platform/posix/cocoa/i_system.mm
posix/cocoa/i_video.mm common/platform/posix/cocoa/i_video.mm
posix/cocoa/st_console.mm common/platform/posix/cocoa/st_console.mm
posix/cocoa/st_start.mm ) common/platform/posix/cocoa/st_start.mm )
if( WIN32 ) if( WIN32 )
set( SYSTEM_SOURCES_DIR win32 ) set( SYSTEM_SOURCES_DIR common/platform/win32 )
set( SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ) set( SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} )
set( OTHER_SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} ${PLAT_UNIX_SOURCES} ) set( OTHER_SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} ${PLAT_UNIX_SOURCES} )
set( SYSTEM_SOURCES ${SYSTEM_SOURCES} win32/zdoom.rc ) set( SYSTEM_SOURCES ${SYSTEM_SOURCES} win32/zdoom.rc )
elseif( APPLE ) elseif( APPLE )
if( OSX_COCOA_BACKEND ) if( OSX_COCOA_BACKEND )
set( SYSTEM_SOURCES_DIR posix posix/cocoa ) set( SYSTEM_SOURCES_DIR common/platform/posix common/platform/posix/cocoa )
set( SYSTEM_SOURCES ${PLAT_COCOA_SOURCES} ) set( SYSTEM_SOURCES ${PLAT_COCOA_SOURCES} )
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_UNIX_SOURCES} ) set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_UNIX_SOURCES} )
else() else()
set( SYSTEM_SOURCES_DIR posix posix/sdl ) set( SYSTEM_SOURCES_DIR common/platform/posix common/platform/posix/sdl )
set( SYSTEM_SOURCES ${PLAT_SDL_SOURCES} ) set( SYSTEM_SOURCES ${PLAT_SDL_SOURCES} )
set( PLAT_OSX_SOURCES ${PLAT_OSX_SOURCES} posix/sdl/i_system.mm ) set( PLAT_OSX_SOURCES ${PLAT_OSX_SOURCES} common/platform/posix/sdl/i_system.mm )
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_COCOA_SOURCES} ${PLAT_UNIX_SOURCES} ) set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_COCOA_SOURCES} ${PLAT_UNIX_SOURCES} )
endif() endif()
set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_POSIX_SOURCES} ${PLAT_OSX_SOURCES} ) set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_POSIX_SOURCES} ${PLAT_OSX_SOURCES} )
set_source_files_properties( posix/osx/zdoom.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources ) set_source_files_properties( posix/osx/zdoom.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
set_source_files_properties( posix/osx/iwadpicker_cocoa.mm PROPERTIES COMPILE_FLAGS -fobjc-exceptions ) set_source_files_properties( common/platform/posix/osx/iwadpicker_cocoa.mm PROPERTIES COMPILE_FLAGS -fobjc-exceptions )
else() else()
set( SYSTEM_SOURCES_DIR posix posix/sdl ) set( SYSTEM_SOURCES_DIR common/platform/posix common/platform/posix/sdl )
set( SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_UNIX_SOURCES} ) set( SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_UNIX_SOURCES} )
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} ) set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} )
endif() endif()
@ -593,11 +599,7 @@ file( GLOB HEADER_FILES
sound/*.h sound/*.h
sound/backend/*.h* sound/backend/*.h*
posix/*.h posix/*.h
posix/cocoa/*.h
posix/sdl/*.h
win32/*.h
r_data/*.h r_data/*.h
r_data/models/*.h
common/audio/sound/thirdparty/*.h common/audio/sound/thirdparty/*.h
common/audio/sound/*.h common/audio/sound/*.h
common/audio/music/*.h* common/audio/music/*.h*
@ -605,9 +607,14 @@ file( GLOB HEADER_FILES
common/console/*.h common/console/*.h
common/utility/*.h common/utility/*.h
common/engine/*.h common/engine/*.h
common/menu/*.h
common/fonts/*.h common/fonts/*.h
common/objects/*.h common/objects/*.h
common/filesystem/*.h common/filesystem/*.h
common/platform/posix/cocoa/*.h
common/platform/posix/sdl/*.h
common/platform/win32/*.h
common/models/*.h
common/textures/*.h common/textures/*.h
common/textures/hires/hqnx/*.h common/textures/hires/hqnx/*.h
common/textures/hires/hqnx_asm/*.h common/textures/hires/hqnx_asm/*.h
@ -615,7 +622,18 @@ file( GLOB HEADER_FILES
common/thirdparty/*.h common/thirdparty/*.h
common/thirdparty/rapidjson/*.h common/thirdparty/rapidjson/*.h
common/thirdparty/math/*h common/thirdparty/math/*h
common/rendering/*.h
common/rendering/gl_load/*.h common/rendering/gl_load/*.h
common/rendering/hwrenderer/data/*.h
common/rendering/polyrenderer/*.h
common/rendering/polyrenderer/math/*.h
common/rendering/polyrenderer/drawers/*.h
common/rendering/polyrenderer/backend/*.h
common/rendering/vulkan/*.h
common/rendering/vulkan/system/*.h
common/rendering/vulkan/renderer/*.h
common/rendering/vulkan/shaders/*.h
common/rendering/vulkan/textures/*.h
common/scripting/core/*h common/scripting/core/*h
common/scripting/vm/*h common/scripting/vm/*h
common/scripting/jit/*h common/scripting/jit/*h
@ -639,41 +657,18 @@ file( GLOB HEADER_FILES
rendering/swrenderer/plane/*.h rendering/swrenderer/plane/*.h
rendering/swrenderer/things/*.h rendering/swrenderer/things/*.h
rendering/swrenderer/viewport/*.h rendering/swrenderer/viewport/*.h
rendering/polyrenderer/*.h rendering/hwrenderer/*.h
rendering/polyrenderer/math/*.h
rendering/polyrenderer/drawers/*.h
rendering/polyrenderer/backend/*.h
rendering/hwrenderer/data/*.h
rendering/hwrenderer/dynlights/*.h
rendering/hwrenderer/models/*.h
rendering/hwrenderer/postprocessing/*.h
rendering/hwrenderer/scene/*.h rendering/hwrenderer/scene/*.h
rendering/hwrenderer/textures/*.h
rendering/hwrenderer/utility/*.h
rendering/vulkan/*.h
rendering/vulkan/system/*.h
rendering/vulkan/renderer/*.h
rendering/vulkan/shaders/*.h
rendering/vulkan/textures/*.h
rendering/gl/*.h
rendering/gl/models/*.h
rendering/gl/renderer/*.h
rendering/gl/scene/*.h
rendering/gl/shaders/*.h
rendering/gl/system/*.h
rendering/gl/textures/*.h
*.h *.h
) )
set ( SWRENDER_SOURCES set ( SWRENDER_SOURCES
rendering/swrenderer/r_swcolormaps.cpp rendering/swrenderer/r_swcolormaps.cpp
rendering/swrenderer/r_swrenderer.cpp rendering/swrenderer/r_swrenderer.cpp
rendering/swrenderer/r_memory.cpp
rendering/swrenderer/r_renderthread.cpp rendering/swrenderer/r_renderthread.cpp
rendering/swrenderer/drawers/r_draw.cpp rendering/swrenderer/drawers/r_draw.cpp
rendering/swrenderer/drawers/r_draw_pal.cpp rendering/swrenderer/drawers/r_draw_pal.cpp
rendering/swrenderer/drawers/r_draw_rgba.cpp rendering/swrenderer/drawers/r_draw_rgba.cpp
rendering/swrenderer/drawers/r_thread.cpp
rendering/swrenderer/scene/r_3dfloors.cpp rendering/swrenderer/scene/r_3dfloors.cpp
rendering/swrenderer/scene/r_light.cpp rendering/swrenderer/scene/r_light.cpp
rendering/swrenderer/scene/r_opaque_pass.cpp rendering/swrenderer/scene/r_opaque_pass.cpp
@ -713,12 +708,12 @@ set ( SWRENDER_SOURCES
) )
set( POLYRENDER_SOURCES set( POLYRENDER_SOURCES
rendering/polyrenderer/drawers/poly_triangle.cpp common/rendering/polyrenderer/drawers/poly_triangle.cpp
rendering/polyrenderer/drawers/poly_thread.cpp common/rendering/polyrenderer/drawers/poly_thread.cpp
rendering/polyrenderer/drawers/screen_triangle.cpp common/rendering/polyrenderer/drawers/screen_triangle.cpp
rendering/polyrenderer/drawers/screen_scanline_setup.cpp common/rendering/polyrenderer/drawers/screen_scanline_setup.cpp
rendering/polyrenderer/drawers/screen_shader.cpp common/rendering/polyrenderer/drawers/screen_shader.cpp
rendering/polyrenderer/drawers/screen_blend.cpp common/rendering/polyrenderer/drawers/screen_blend.cpp
) )
# These files will be flagged as "headers" so that they appear in project files # These files will be flagged as "headers" so that they appear in project files
@ -736,7 +731,7 @@ set( NOT_COMPILED_SOURCE_FILES
common/scripting/frontend/zcc-parse.lemon common/scripting/frontend/zcc-parse.lemon
zcc-parse.c zcc-parse.c
zcc-parse.h zcc-parse.h
win32/zdoom.natvis common/platform/win32/zutil.natvis
) )
set( VM_JIT_SOURCES set( VM_JIT_SOURCES
@ -758,7 +753,7 @@ set( VM_JIT_SOURCES
set( FASTMATH_SOURCES set( FASTMATH_SOURCES
rendering/swrenderer/r_all.cpp rendering/swrenderer/r_all.cpp
rendering/swrenderer/r_swscene.cpp rendering/swrenderer/r_swscene.cpp
rendering/polyrenderer/poly_all.cpp common/rendering/polyrenderer/poly_all.cpp
common/textures/hires/hqnx/init.cpp common/textures/hires/hqnx/init.cpp
common/textures/hires/hqnx/hq2x.cpp common/textures/hires/hqnx/hq2x.cpp
common/textures/hires/hqnx/hq3x.cpp common/textures/hires/hqnx/hq3x.cpp
@ -766,9 +761,7 @@ set( FASTMATH_SOURCES
common/textures/hires/xbr/xbrz.cpp common/textures/hires/xbr/xbrz.cpp
common/textures/hires/xbr/xbrz_old.cpp common/textures/hires/xbr/xbrz_old.cpp
common/rendering/gl_load/gl_load.c common/rendering/gl_load/gl_load.c
rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp rendering/hwrenderer/hw_dynlightdata.cpp
rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp
rendering/hwrenderer/dynlights/hw_dynlightdata.cpp
rendering/hwrenderer/scene/hw_bsp.cpp rendering/hwrenderer/scene/hw_bsp.cpp
rendering/hwrenderer/scene/hw_fakeflat.cpp rendering/hwrenderer/scene/hw_fakeflat.cpp
rendering/hwrenderer/scene/hw_decal.cpp rendering/hwrenderer/scene/hw_decal.cpp
@ -785,28 +778,27 @@ set( FASTMATH_SOURCES
rendering/hwrenderer/scene/hw_walls.cpp rendering/hwrenderer/scene/hw_walls.cpp
rendering/hwrenderer/scene/hw_walls_vertex.cpp rendering/hwrenderer/scene/hw_walls_vertex.cpp
rendering/hwrenderer/scene/hw_weapon.cpp rendering/hwrenderer/scene/hw_weapon.cpp
r_data/models/models.cpp
common/utility/matrix.cpp common/utility/matrix.cpp
) )
#Vulkan stuff must go into a separate list later because it needs to be disabled for some platforms #Vulkan stuff must go into a separate list because it needs to be disabled for some platforms
set (VULKAN_SOURCES set (VULKAN_SOURCES
rendering/vulkan/system/vk_device.cpp common/rendering/vulkan/system/vk_device.cpp
rendering/vulkan/system/vk_swapchain.cpp common/rendering/vulkan/system/vk_swapchain.cpp
rendering/vulkan/system/vk_builders.cpp common/rendering/vulkan/system/vk_builders.cpp
rendering/vulkan/system/vk_framebuffer.cpp common/rendering/vulkan/system/vk_framebuffer.cpp
rendering/vulkan/system/vk_buffers.cpp common/rendering/vulkan/system/vk_buffers.cpp
rendering/vulkan/renderer/vk_renderstate.cpp common/rendering/vulkan/renderer/vk_renderstate.cpp
rendering/vulkan/renderer/vk_renderpass.cpp common/rendering/vulkan/renderer/vk_renderpass.cpp
rendering/vulkan/renderer/vk_streambuffer.cpp common/rendering/vulkan/renderer/vk_streambuffer.cpp
rendering/vulkan/renderer/vk_postprocess.cpp common/rendering/vulkan/renderer/vk_postprocess.cpp
rendering/vulkan/renderer/vk_renderbuffers.cpp common/rendering/vulkan/renderer/vk_renderbuffers.cpp
rendering/vulkan/shaders/vk_shader.cpp common/rendering/vulkan/shaders/vk_shader.cpp
rendering/vulkan/textures/vk_samplers.cpp common/rendering/vulkan/textures/vk_samplers.cpp
rendering/vulkan/textures/vk_hwtexture.cpp common/rendering/vulkan/textures/vk_hwtexture.cpp
rendering/vulkan/textures/vk_imagetransition.cpp common/rendering/vulkan/textures/vk_imagetransition.cpp
rendering/vulkan/thirdparty/volk/volk.c common/rendering/vulkan/thirdparty/volk/volk.c
rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.cpp
) )
if (HAVE_VULKAN) if (HAVE_VULKAN)
@ -814,10 +806,10 @@ if (HAVE_VULKAN)
endif() endif()
set (POLYBACKEND_SOURCES set (POLYBACKEND_SOURCES
rendering/polyrenderer/backend/poly_framebuffer.cpp common/rendering/polyrenderer/backend/poly_framebuffer.cpp
rendering/polyrenderer/backend/poly_buffers.cpp common/rendering/polyrenderer/backend/poly_buffers.cpp
rendering/polyrenderer/backend/poly_hwtexture.cpp common/rendering/polyrenderer/backend/poly_hwtexture.cpp
rendering/polyrenderer/backend/poly_renderstate.cpp common/rendering/polyrenderer/backend/poly_renderstate.cpp
) )
set (FASTMATH_SOURCES ${FASTMATH_SOURCES} ${POLYBACKEND_SOURCES}) set (FASTMATH_SOURCES ${FASTMATH_SOURCES} ${POLYBACKEND_SOURCES})
@ -880,7 +872,6 @@ set (PCH_SOURCES
playsim/p_user.cpp playsim/p_user.cpp
rendering/r_utility.cpp rendering/r_utility.cpp
rendering/r_sky.cpp rendering/r_sky.cpp
rendering/r_videoscale.cpp
sound/s_advsound.cpp sound/s_advsound.cpp
sound/s_reverbedit.cpp sound/s_reverbedit.cpp
sound/s_sndseq.cpp sound/s_sndseq.cpp
@ -888,9 +879,7 @@ set (PCH_SOURCES
serializer_doom.cpp serializer_doom.cpp
scriptutil.cpp scriptutil.cpp
st_stuff.cpp st_stuff.cpp
rendering/v_framebuffer.cpp
r_data/v_palette.cpp r_data/v_palette.cpp
rendering/v_video.cpp
wi_stuff.cpp wi_stuff.cpp
gamedata/a_keys.cpp gamedata/a_keys.cpp
gamedata/a_weapons.cpp gamedata/a_weapons.cpp
@ -948,40 +937,15 @@ set (PCH_SOURCES
g_statusbar/shared_sbar.cpp g_statusbar/shared_sbar.cpp
rendering/2d/f_wipe.cpp rendering/2d/f_wipe.cpp
rendering/2d/v_blend.cpp rendering/2d/v_blend.cpp
rendering/gl/renderer/gl_renderer.cpp rendering/hwrenderer/hw_entrypoint.cpp
rendering/gl/renderer/gl_renderstate.cpp rendering/hwrenderer/hw_vertexbuilder.cpp
rendering/gl/renderer/gl_renderbuffers.cpp rendering/hwrenderer/doom_aabbtree.cpp
rendering/gl/renderer/gl_postprocess.cpp rendering/hwrenderer/hw_models.cpp
rendering/gl/renderer/gl_postprocessstate.cpp rendering/hwrenderer/hw_postprocessshader.cpp
rendering/gl/renderer/gl_stereo3d.cpp rendering/hwrenderer/hw_precache.cpp
rendering/gl/renderer/gl_scene.cpp rendering/hwrenderer/scene/hw_lighting.cpp
rendering/gl/shaders/gl_shader.cpp
rendering/gl/shaders/gl_shaderprogram.cpp
rendering/gl/system/gl_framebuffer.cpp
rendering/gl/system/gl_debug.cpp
rendering/gl/system/gl_buffers.cpp
rendering/gl/textures/gl_hwtexture.cpp
rendering/gl/textures/gl_samplers.cpp
rendering/hwrenderer/data/hw_vertexbuilder.cpp
rendering/hwrenderer/data/flatvertices.cpp
rendering/hwrenderer/data/hw_viewpointbuffer.cpp
rendering/hwrenderer/dynlights/hw_aabbtree.cpp
rendering/hwrenderer/dynlights/hw_shadowmap.cpp
rendering/hwrenderer/dynlights/hw_lightbuffer.cpp
rendering/hwrenderer/models/hw_models.cpp
rendering/hwrenderer/scene/hw_skydome.cpp
rendering/hwrenderer/scene/hw_drawlistadd.cpp rendering/hwrenderer/scene/hw_drawlistadd.cpp
rendering/hwrenderer/scene/hw_renderstate.cpp rendering/hwrenderer/scene/hw_setcolor.cpp
rendering/hwrenderer/postprocessing/hw_postprocess.cpp
rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp
rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp
rendering/hwrenderer/textures/hw_precache.cpp
rendering/hwrenderer/utility/hw_clock.cpp
rendering/hwrenderer/utility/hw_cvars.cpp
rendering/hwrenderer/utility/hw_draw2d.cpp
rendering/hwrenderer/utility/hw_lighting.cpp
rendering/hwrenderer/utility/hw_shaderpatcher.cpp
rendering/hwrenderer/utility/hw_vrmodes.cpp
maploader/edata.cpp maploader/edata.cpp
maploader/specials.cpp maploader/specials.cpp
maploader/maploader.cpp maploader/maploader.cpp
@ -1020,22 +984,17 @@ set (PCH_SOURCES
intermission/intermission.cpp intermission/intermission.cpp
intermission/intermission_parse.cpp intermission/intermission_parse.cpp
r_data/colormaps.cpp r_data/colormaps.cpp
r_data/cycler.cpp
r_data/gldefs.cpp r_data/gldefs.cpp
r_data/a_dynlightdata.cpp r_data/a_dynlightdata.cpp
r_data/r_translate.cpp r_data/r_translate.cpp
r_data/sprites.cpp r_data/sprites.cpp
r_data/portalgroups.cpp r_data/portalgroups.cpp
r_data/voxels.cpp r_data/voxeldef.cpp
r_data/r_canvastexture.cpp r_data/r_canvastexture.cpp
r_data/r_interpolate.cpp r_data/r_interpolate.cpp
r_data/r_vanillatrans.cpp r_data/r_vanillatrans.cpp
r_data/r_sections.cpp r_data/r_sections.cpp
r_data/models/models_md3.cpp r_data/models.cpp
r_data/models/models_md2.cpp
r_data/models/models_voxel.cpp
r_data/models/models_ue1.cpp
r_data/models/models_obj.cpp
scripting/vmiterators.cpp scripting/vmiterators.cpp
scripting/vmthunks.cpp scripting/vmthunks.cpp
scripting/vmthunks_actors.cpp scripting/vmthunks_actors.cpp
@ -1077,12 +1036,14 @@ set (PCH_SOURCES
common/textures/bitmap.cpp common/textures/bitmap.cpp
common/textures/m_png.cpp common/textures/m_png.cpp
common/textures/texture.cpp common/textures/texture.cpp
common/textures/gametexture.cpp
common/textures/image.cpp common/textures/image.cpp
common/textures/imagetexture.cpp common/textures/imagetexture.cpp
common/textures/texturemanager.cpp common/textures/texturemanager.cpp
common/textures/multipatchtexturebuilder.cpp common/textures/multipatchtexturebuilder.cpp
common/textures/skyboxtexture.cpp common/textures/skyboxtexture.cpp
common/textures/animtexture.cpp common/textures/animtexture.cpp
common/textures/v_collection.cpp
common/textures/formats/automaptexture.cpp common/textures/formats/automaptexture.cpp
common/textures/formats/brightmaptexture.cpp common/textures/formats/brightmaptexture.cpp
common/textures/formats/buildtexture.cpp common/textures/formats/buildtexture.cpp
@ -1102,6 +1063,13 @@ set (PCH_SOURCES
common/textures/formats/tgatexture.cpp common/textures/formats/tgatexture.cpp
common/textures/formats/stbtexture.cpp common/textures/formats/stbtexture.cpp
common/textures/hires/hqresize.cpp common/textures/hires/hqresize.cpp
common/models/models_md3.cpp
common/models/models_md2.cpp
common/models/models_voxel.cpp
common/models/models_ue1.cpp
common/models/models_obj.cpp
common/models/model.cpp
common/models/voxels.cpp
common/console/c_commandline.cpp common/console/c_commandline.cpp
common/console/c_buttons.cpp common/console/c_buttons.cpp
common/console/c_bind.cpp common/console/c_bind.cpp
@ -1125,6 +1093,7 @@ set (PCH_SOURCES
common/utility/s_playlist.cpp common/utility/s_playlist.cpp
common/utility/zstrformat.cpp common/utility/zstrformat.cpp
common/utility/name.cpp common/utility/name.cpp
common/utility/r_memory.cpp
common/thirdparty/md5.cpp common/thirdparty/md5.cpp
common/thirdparty/superfasthash.cpp common/thirdparty/superfasthash.cpp
common/filesystem/filesystem.cpp common/filesystem/filesystem.cpp
@ -1139,6 +1108,7 @@ set (PCH_SOURCES
common/filesystem/file_whres.cpp common/filesystem/file_whres.cpp
common/filesystem/file_directory.cpp common/filesystem/file_directory.cpp
common/filesystem/resourcefile.cpp common/filesystem/resourcefile.cpp
common/engine/cycler.cpp
common/engine/stats.cpp common/engine/stats.cpp
common/engine/sc_man.cpp common/engine/sc_man.cpp
common/engine/palettecontainer.cpp common/engine/palettecontainer.cpp
@ -1151,7 +1121,38 @@ set (PCH_SOURCES
common/objects/dobject.cpp common/objects/dobject.cpp
common/objects/dobjgc.cpp common/objects/dobjgc.cpp
common/objects/dobjtype.cpp common/objects/dobjtype.cpp
common/rendering/v_framebuffer.cpp
common/rendering/v_video.cpp
common/rendering/r_thread.cpp
common/rendering/r_videoscale.cpp
common/rendering/hwrenderer/hw_draw2d.cpp
common/rendering/hwrenderer/data/hw_clock.cpp
common/rendering/hwrenderer/data/hw_skydome.cpp
common/rendering/hwrenderer/data/flatvertices.cpp
common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp
common/rendering/hwrenderer/data/hw_modelvertexbuffer.cpp
common/rendering/hwrenderer/data/hw_cvars.cpp
common/rendering/hwrenderer/data/hw_vrmodes.cpp
common/rendering/hwrenderer/data/hw_lightbuffer.cpp
common/rendering/hwrenderer/data/hw_aabbtree.cpp
common/rendering/hwrenderer/data/hw_shadowmap.cpp
common/rendering/hwrenderer/data/hw_shaderpatcher.cpp
common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp
common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp
common/rendering/gl_load/gl_interface.cpp common/rendering/gl_load/gl_interface.cpp
common/rendering/gl/gl_renderer.cpp
common/rendering/gl/gl_stereo3d.cpp
common/rendering/gl/gl_framebuffer.cpp
common/rendering/gl/gl_renderstate.cpp
common/rendering/gl/gl_renderbuffers.cpp
common/rendering/gl/gl_postprocess.cpp
common/rendering/gl/gl_postprocessstate.cpp
common/rendering/gl/gl_debug.cpp
common/rendering/gl/gl_buffers.cpp
common/rendering/gl/gl_hwtexture.cpp
common/rendering/gl/gl_samplers.cpp
common/rendering/gl/gl_shader.cpp
common/rendering/gl/gl_shaderprogram.cpp
common/scripting/core/dictionary.cpp common/scripting/core/dictionary.cpp
common/scripting/core/dynarrays.cpp common/scripting/core/dynarrays.cpp
common/scripting/core/symbols.cpp common/scripting/core/symbols.cpp
@ -1175,8 +1176,6 @@ set (PCH_SOURCES
utility/nodebuilder/nodebuild_extract.cpp utility/nodebuilder/nodebuild_extract.cpp
utility/nodebuilder/nodebuild_gl.cpp utility/nodebuilder/nodebuild_gl.cpp
utility/nodebuilder/nodebuild_utility.cpp utility/nodebuilder/nodebuild_utility.cpp
utility/m_bbox.cpp
utility/v_collection.cpp
) )
if( ${HAVE_VM_JIT} ) if( ${HAVE_VM_JIT} )
@ -1253,14 +1252,21 @@ include_directories( .
common/textures/formats common/textures/formats
common/textures/hires common/textures/hires
common/textures common/textures
common/models
common/filesystem common/filesystem
common/utility common/utility
common/console common/console
common/engine common/engine
common/menu
common/fonts common/fonts
common/objects common/objects
common/rendering common/rendering
common/rendering/hwrenderer/data
common/rendering/gl_load common/rendering/gl_load
common/rendering/gl
common/rendering/vulkan/thirdparty
common/rendering/polyrenderer/backend
common/rendering/polyrenderer/drawers
common/scripting/vm common/scripting/vm
common/scripting/jit common/scripting/jit
common/scripting/core common/scripting/core
@ -1276,6 +1282,7 @@ include_directories( .
gamedata/textures gamedata/textures
gamedata/fonts gamedata/fonts
rendering rendering
rendering/hwrenderer
rendering/2d rendering/2d
r_data r_data
sound sound
@ -1286,12 +1293,12 @@ include_directories( .
scripting scripting
scripting/zscript scripting/zscript
rendering rendering
rendering/vulkan/thirdparty
../libraries/gdtoa ../libraries/gdtoa
../libraries/glslang/glslang/Public ../libraries/glslang/glslang/Public
../libraries/glslang/spirv ../libraries/glslang/spirv
${CMAKE_BINARY_DIR}/libraries/gdtoa ${CMAKE_BINARY_DIR}/libraries/gdtoa
${SYSTEM_SOURCES_DIR} ) ${SYSTEM_SOURCES_DIR}
)
add_dependencies( zdoom revision_check ) add_dependencies( zdoom revision_check )
@ -1324,7 +1331,7 @@ if( MSVC )
set_target_properties(zdoom PROPERTIES LINK_FLAGS ${LINKERSTUFF}) set_target_properties(zdoom PROPERTIES LINK_FLAGS ${LINKERSTUFF})
add_custom_command(TARGET zdoom POST_BUILD add_custom_command(TARGET zdoom POST_BUILD
COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\win32\\zdoom.exe.manifest\" -outputresource:\"$<TARGET_FILE:zdoom>\"\;\#1 COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\common\\platform\\win32\\manifest.xml\" -outputresource:\"$<TARGET_FILE:zdoom>\"\;\#1
COMMENT "Adding manifest..." COMMENT "Adding manifest..."
) )
@ -1354,7 +1361,7 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
# Need to enable intrinsics for these files. # Need to enable intrinsics for these files.
if( SSE_MATTERS ) if( SSE_MATTERS )
set_property( SOURCE set_property( SOURCE
rendering/polyrenderer/poly_all.cpp common/rendering/polyrenderer/poly_all.cpp
rendering/swrenderer/r_all.cpp rendering/swrenderer/r_all.cpp
utility/palette.cpp utility/palette.cpp
utility/x86.cpp utility/x86.cpp
@ -1402,32 +1409,7 @@ source_group("Playsim\\Map Thinkers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE
source_group("Rendering" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/.+") source_group("Rendering" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/.+")
source_group("Rendering\\2D" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/2d/.+") source_group("Rendering\\2D" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/2d/.+")
source_group("Rendering\\Hardware Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/.+") source_group("Rendering\\Hardware Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gl/.+")
source_group("Rendering\\Hardware Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/hwrenderer/data/.+")
source_group("Rendering\\Hardware Renderer\\Dynamic Lights" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/hwrenderer/dynlights/.+")
source_group("Rendering\\Hardware Renderer\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/hwrenderer/models/.+")
source_group("Rendering\\Hardware Renderer\\Postprocessing" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/hwrenderer/postprocessing/.+")
source_group("Rendering\\Hardware Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/hwrenderer/renderer/.+")
source_group("Rendering\\Hardware Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/hwrenderer/scene/.+") source_group("Rendering\\Hardware Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/hwrenderer/scene/.+")
source_group("Rendering\\Hardware Renderer\\Shaders" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/hwrenderer/shaders/.+")
source_group("Rendering\\Hardware Renderer\\System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/hwrenderer/system/.+")
source_group("Rendering\\Hardware Renderer\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/hwrenderer/textures/.+")
source_group("Rendering\\Hardware Renderer\\Utilities" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/hwrenderer/utility/.+")
source_group("Rendering\\Vulkan Renderer\\System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/vulkan/system/.+")
source_group("Rendering\\Vulkan Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/vulkan/renderer/.+")
source_group("Rendering\\Vulkan Renderer\\Shaders" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/vulkan/shaders/.+")
source_group("Rendering\\Vulkan Renderer\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/vulkan/textures/.+")
source_group("Rendering\\Vulkan Renderer\\Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/vulkan/thirdparty/.+")
source_group("Rendering\\Vulkan Renderer\\Third Party\\Volk" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/vulkan/thirdparty/volk/.+")
source_group("Rendering\\Vulkan Renderer\\Third Party\\Vk_Mem_Alloc" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/vulkan/thirdparty/vk_mem_alloc.+")
source_group("Rendering\\OpenGL Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/gl/.+")
source_group("Rendering\\OpenGL Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/gl/data/.+")
source_group("Rendering\\OpenGL Renderer\\Dynamic Lights" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/gl/dynlights/.+")
source_group("Rendering\\OpenGL Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/gl/renderer/.+")
source_group("Rendering\\OpenGL Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/gl/scene/.+")
source_group("Rendering\\OpenGL Renderer\\Shaders" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/gl/shaders/.+")
source_group("Rendering\\OpenGL Renderer\\System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/gl/system/.+")
source_group("Rendering\\OpenGL Renderer\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/gl/textures/.+")
source_group("Rendering\\OpenGL Renderer\\Utilities" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/gl/utility/.+")
source_group("Rendering\\Software Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/.+") source_group("Rendering\\Software Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/.+")
source_group("Rendering\\Software Renderer\\Drawers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/drawers/.+") source_group("Rendering\\Software Renderer\\Drawers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/drawers/.+")
source_group("Rendering\\Software Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/scene/.+") source_group("Rendering\\Software Renderer\\Scene" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/scene/.+")
@ -1436,18 +1418,9 @@ source_group("Rendering\\Software Renderer\\Line" REGULAR_EXPRESSION "^${CMAKE_C
source_group("Rendering\\Software Renderer\\Plane" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/plane/.+") source_group("Rendering\\Software Renderer\\Plane" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/plane/.+")
source_group("Rendering\\Software Renderer\\Things" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/things/.+") source_group("Rendering\\Software Renderer\\Things" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/things/.+")
source_group("Rendering\\Software Renderer\\Viewport" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/viewport/.+") source_group("Rendering\\Software Renderer\\Viewport" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/swrenderer/viewport/.+")
source_group("Rendering\\Poly Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/polyrenderer/.+")
source_group("Rendering\\Poly Renderer\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/polyrenderer/math/.+")
source_group("Rendering\\Poly Renderer\\Drawers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/polyrenderer/drawers/.+")
source_group("Rendering\\Poly Renderer\\Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/polyrenderer/backend/.+")
source_group("Render Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/.+") source_group("Render Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/.+")
source_group("Render Data\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/r_data/models/.+")
source_group("Render Interface" FILES r_defs.h r_renderer.h r_sky.cpp r_sky.h r_state.h r_utility.cpp r_utility.h) source_group("Render Interface" FILES r_defs.h r_renderer.h r_sky.cpp r_sky.h r_state.h r_utility.cpp r_utility.h)
source_group("Platforms\\POSIX Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/posix/.+") source_group("Platforms\\POSIX Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/posix/.+")
source_group("Platforms\\Cocoa Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/posix/cocoa/.+")
source_group("Platforms\\OS X Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/.+")
source_group("Platforms\\Unix Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/posix/unix/.+")
source_group("Platforms\\SDL Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/posix/sdl/.+")
source_group("Platforms\\Win32 Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/win32/.+") source_group("Platforms\\Win32 Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/win32/.+")
source_group("Scripting\\Decorate frontend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/decorate/.+") source_group("Scripting\\Decorate frontend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/decorate/.+")
source_group("Scripting\\ZScript frontend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/zscript/.+") source_group("Scripting\\ZScript frontend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/zscript/.+")
@ -1464,6 +1437,7 @@ source_group("Common\\Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/
source_group("Common\\Engine" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/engine/.+") source_group("Common\\Engine" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/engine/.+")
source_group("Common\\2D" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/2d/.+") source_group("Common\\2D" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/2d/.+")
source_group("Common\\Objects" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/objects/.+") source_group("Common\\Objects" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/objects/.+")
source_group("Common\\Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/menu/.+")
source_group("Common\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/fonts/.+") source_group("Common\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/fonts/.+")
source_group("Common\\File System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/.+") source_group("Common\\File System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/.+")
source_group("Common\\Scripting" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/.+") source_group("Common\\Scripting" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/.+")
@ -1473,8 +1447,28 @@ source_group("Common\\Scripting\\Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_S
source_group("Common\\Scripting\\Core" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/core/.+") source_group("Common\\Scripting\\Core" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/core/.+")
source_group("Common\\Scripting\\JIT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/jit/.+") source_group("Common\\Scripting\\JIT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/jit/.+")
source_group("Common\\Scripting\\VM" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/vm/.+") source_group("Common\\Scripting\\VM" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/vm/.+")
source_group("Common\\Rendering" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/.+") source_group("Common\\Platforms\\Cocoa Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/platform/posix/cocoa/.+")
source_group("Common\\Rendering\\OpenGL Loader" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rendering/gl_load/.+") source_group("Common\\Platforms\\OS X Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/platform/posix/osx/.+")
source_group("Common\\Platforms\\Unix Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/platform/posix/unix/.+")
source_group("Common\\Platforms\\SDL Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/platform/posix/sdl/.+")
source_group("Common\\Platforms\\Win32 Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/platform/win32/.+")
source_group("Common\\Rendering" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/.+")
source_group("Common\\Rendering\\Hardware Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/hwrenderer/.+")
source_group("Common\\Rendering\\Hardware Renderer\\Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/hwrenderer/data/.+")
source_group("Common\\Rendering\\Hardware Renderer\\Postprocessing" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/hwrenderer/postprocessing/.+")
source_group("Common\\Rendering\\OpenGL Loader" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/gl_load/.+")
source_group("Common\\Rendering\\OpenGL Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/gl/.+")
source_group("Common\\Rendering\\Vulkan Renderer\\System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/vulkan/system/.+")
source_group("Common\\Rendering\\Vulkan Renderer\\Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/vulkan/renderer/.+")
source_group("Common\\Rendering\\Vulkan Renderer\\Shaders" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/vulkan/shaders/.+")
source_group("Common\\Rendering\\Vulkan Renderer\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/vulkan/textures/.+")
source_group("Common\\Rendering\\Vulkan Renderer\\Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/vulkan/thirdparty/.+")
source_group("Common\\Rendering\\Vulkan Renderer\\Third Party\\Volk" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/vulkan/thirdparty/volk/.+")
source_group("Common\\Rendering\\Vulkan Renderer\\Third Party\\Vk_Mem_Alloc" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/vulkan/thirdparty/vk_mem_alloc.+")
source_group("Common\\Rendering\\Poly Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/polyrenderer/.+")
source_group("Common\\Rendering\\Poly Renderer\\Drawers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/polyrenderer/drawers/.+")
source_group("Common\\Rendering\\Poly Renderer\\Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/polyrenderer/backend/.+")
source_group("Common\\Models" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/models/.+")
source_group("Common\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/.+") source_group("Common\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/.+")
source_group("Common\\Textures\\Hires" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/.+") source_group("Common\\Textures\\Hires" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/.+")
source_group("Common\\Textures\\Hires\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/hqnx/.+") source_group("Common\\Textures\\Hires\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/hqnx/.+")

View file

@ -47,6 +47,8 @@
#include "p_blockmap.h" #include "p_blockmap.h"
#include "g_game.h" #include "g_game.h"
#include "v_video.h" #include "v_video.h"
#include "d_main.h"
#include "v_draw.h"
#include "m_cheat.h" #include "m_cheat.h"
#include "c_dispatch.h" #include "c_dispatch.h"
@ -988,7 +990,7 @@ class DAutomap :public DAutomapBase
void calcMinMaxMtoF(); void calcMinMaxMtoF();
void DrawMarker(FTexture *tex, double x, double y, int yadjust, void DrawMarker(FGameTexture *tex, double x, double y, int yadjust,
INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle); INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle);
void rotatePoint(double *x, double *y); void rotatePoint(double *x, double *y);
@ -1235,12 +1237,12 @@ void DAutomap::ScrollParchment (double dmapx, double dmapy)
if (mapback.isValid()) if (mapback.isValid())
{ {
FTexture *backtex = TexMan.GetTexture(mapback); auto backtex = TexMan.GetGameTexture(mapback);
if (backtex != nullptr) if (backtex != nullptr)
{ {
int pwidth = backtex->GetDisplayWidth(); int pwidth = int(backtex->GetDisplayWidth() * CleanXfac);
int pheight = backtex->GetDisplayHeight(); int pheight = int(backtex->GetDisplayHeight() * CleanYfac);
while(mapxstart > 0) while(mapxstart > 0)
mapxstart -= pwidth; mapxstart -= pwidth;
@ -1588,11 +1590,11 @@ void DAutomap::clearFB (const AMColor &color)
} }
else else
{ {
FTexture *backtex = TexMan.GetTexture(mapback); auto backtex = TexMan.GetGameTexture(mapback);
if (backtex != nullptr) if (backtex != nullptr)
{ {
int pwidth = backtex->GetDisplayWidth(); int pwidth = int(backtex->GetDisplayWidth() * CleanXfac);
int pheight = backtex->GetDisplayHeight(); int pheight = int(backtex->GetDisplayHeight() * CleanYfac);
int x, y; int x, y;
//blit the automap background to the screen. //blit the automap background to the screen.
@ -1600,7 +1602,7 @@ void DAutomap::clearFB (const AMColor &color)
{ {
for (x = int(mapxstart); x < f_w; x += pwidth) for (x = int(mapxstart); x < f_w; x += pwidth)
{ {
DrawTexture(twod, backtex, x, y, DTA_ClipBottom, f_h, DTA_TopOffset, 0, DTA_LeftOffset, 0, TAG_DONE); DrawTexture(twod, backtex, x, y, DTA_ClipBottom, f_h, DTA_TopOffset, 0, DTA_LeftOffset, 0, DTA_DestWidth, pwidth, DTA_DestHeight, pheight, TAG_DONE);
} }
} }
} }
@ -2139,7 +2141,7 @@ void DAutomap::drawSubsectors()
// is necessary in order to best reproduce Doom's original lighting. // is necessary in order to best reproduce Doom's original lighting.
double fadelevel; double fadelevel;
if (vid_rendermode != 4 || primaryLevel->lightMode == ELightMode::Doom || primaryLevel->lightMode == ELightMode::ZDoomSoftware || primaryLevel->lightMode == ELightMode::DoomSoftware) if (!V_IsHardwareRenderer() || primaryLevel->lightMode == ELightMode::Doom || primaryLevel->lightMode == ELightMode::ZDoomSoftware || primaryLevel->lightMode == ELightMode::DoomSoftware)
{ {
double map = (NUMCOLORMAPS * 2.) - ((floorlight + 12) * (NUMCOLORMAPS / 128.)); double map = (NUMCOLORMAPS * 2.) - ((floorlight + 12) * (NUMCOLORMAPS / 128.));
fadelevel = clamp((map - 12) / NUMCOLORMAPS, 0.0, 1.0); fadelevel = clamp((map - 12) / NUMCOLORMAPS, 0.0, 1.0);
@ -2150,7 +2152,7 @@ void DAutomap::drawSubsectors()
fadelevel = 1. - clamp(floorlight, 0, 255) / 255.f; fadelevel = 1. - clamp(floorlight, 0, 255) / 255.f;
} }
twod->AddPoly(TexMan.GetTexture(maptex, true), twod->AddPoly(TexMan.GetGameTexture(maptex, true),
&points[0], points.Size(), &points[0], points.Size(),
originx, originy, originx, originy,
scale / scalex, scale / scalex,
@ -2908,7 +2910,7 @@ void DAutomap::drawThings ()
if (am_showthingsprites > 0 && t->sprite > 0) if (am_showthingsprites > 0 && t->sprite > 0)
{ {
FTexture *texture = nullptr; FGameTexture *texture = nullptr;
spriteframe_t *frame; spriteframe_t *frame;
int rotation = 0; int rotation = 0;
@ -2928,7 +2930,7 @@ void DAutomap::drawThings ()
rotation = int((angle.Normalized360() * (16. / 360.)).Degrees); rotation = int((angle.Normalized360() * (16. / 360.)).Degrees);
const FTextureID textureID = frame->Texture[show > 2 ? rotation : 0]; const FTextureID textureID = frame->Texture[show > 2 ? rotation : 0];
texture = TexMan.GetTexture(textureID, true); texture = TexMan.GetGameTexture(textureID, true);
} }
if (texture == nullptr) goto drawTriangle; // fall back to standard display if no sprite can be found. if (texture == nullptr) goto drawTriangle; // fall back to standard display if no sprite can be found.
@ -3023,7 +3025,7 @@ void DAutomap::drawThings ()
// //
//============================================================================= //=============================================================================
void DAutomap::DrawMarker (FTexture *tex, double x, double y, int yadjust, void DAutomap::DrawMarker (FGameTexture *tex, double x, double y, int yadjust,
INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle) INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle)
{ {
if (tex == nullptr || !tex->isValid()) if (tex == nullptr || !tex->isValid())
@ -3035,8 +3037,8 @@ void DAutomap::DrawMarker (FTexture *tex, double x, double y, int yadjust,
rotatePoint (&x, &y); rotatePoint (&x, &y);
} }
DrawTexture(twod, tex, CXMTOF(x) + f_x, CYMTOF(y) + yadjust + f_y, DrawTexture(twod, tex, CXMTOF(x) + f_x, CYMTOF(y) + yadjust + f_y,
DTA_DestWidthF, tex->GetDisplayWidthDouble() * CleanXfac * xscale, DTA_DestWidthF, tex->GetDisplayWidth() * CleanXfac * xscale,
DTA_DestHeightF, tex->GetDisplayHeightDouble() * CleanYfac * yscale, DTA_DestHeightF, tex->GetDisplayHeight() * CleanYfac * yscale,
DTA_ClipTop, f_y, DTA_ClipTop, f_y,
DTA_ClipBottom, f_y + f_h, DTA_ClipBottom, f_y + f_h,
DTA_ClipLeft, f_x, DTA_ClipLeft, f_x,
@ -3072,7 +3074,7 @@ void DAutomap::drawMarks ()
if (font == nullptr) if (font == nullptr)
{ {
DrawMarker(TexMan.GetTexture(marknums[i], true), markpoints[i].x, markpoints[i].y, -3, 0, DrawMarker(TexMan.GetGameTexture(marknums[i], true), markpoints[i].x, markpoints[i].y, -3, 0,
1, 1, 0, 1, 0, LegacyRenderStyles[STYLE_Normal]); 1, 1, 0, 1, 0, LegacyRenderStyles[STYLE_Normal]);
} }
else else
@ -3114,18 +3116,18 @@ void DAutomap::drawAuthorMarkers ()
} }
FTextureID picnum; FTextureID picnum;
FTexture *tex; FGameTexture *tex;
uint16_t flip = 0; uint16_t flip = 0;
if (mark->picnum.isValid()) if (mark->picnum.isValid())
{ {
tex = TexMan.GetTexture(mark->picnum, true); tex = TexMan.GetGameTexture(mark->picnum, true);
if (tex->GetRotations() != 0xFFFF) if (tex->GetRotations() != 0xFFFF)
{ {
spriteframe_t *sprframe = &SpriteFrames[tex->GetRotations()]; spriteframe_t *sprframe = &SpriteFrames[tex->GetRotations()];
picnum = sprframe->Texture[0]; picnum = sprframe->Texture[0];
flip = sprframe->Flip & 1; flip = sprframe->Flip & 1;
tex = TexMan.GetTexture(picnum); tex = TexMan.GetGameTexture(picnum);
} }
} }
else else
@ -3140,7 +3142,7 @@ void DAutomap::drawAuthorMarkers ()
spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + mark->frame]; spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + mark->frame];
picnum = sprframe->Texture[0]; picnum = sprframe->Texture[0];
flip = sprframe->Flip & 1; flip = sprframe->Flip & 1;
tex = TexMan.GetTexture(picnum); tex = TexMan.GetGameTexture(picnum);
} }
} }
auto it = Level->GetActorIterator(mark->args[0]); auto it = Level->GetActorIterator(mark->args[0]);

View file

@ -37,11 +37,15 @@
#include "vm.h" #include "vm.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "v_draw.h" #include "v_draw.h"
#include "v_video.h"
#include "fcolormap.h" #include "fcolormap.h"
F2DDrawer* twod; static F2DDrawer drawer;
F2DDrawer* twod = &drawer;
EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Float, transsouls)
CVAR(Float, classic_scaling_factor, 1.0, CVAR_ARCHIVE)
CVAR(Float, classic_scaling_pixelaspect, 1.2f, CVAR_ARCHIVE)
IMPLEMENT_CLASS(DShape2DTransform, false, false) IMPLEMENT_CLASS(DShape2DTransform, false, false)
@ -234,7 +238,7 @@ void F2DDrawer::AddIndices(int firstvert, TArray<int> &v)
// //
//========================================================================== //==========================================================================
bool F2DDrawer::SetStyle(FTexture *tex, DrawParms &parms, PalEntry &vertexcolor, RenderCommand &quad) bool F2DDrawer::SetStyle(FGameTexture *tex, DrawParms &parms, PalEntry &vertexcolor, RenderCommand &quad)
{ {
FRenderStyle style = parms.style; FRenderStyle style = parms.style;
float alpha; float alpha;
@ -390,9 +394,10 @@ void F2DDrawer::SetColorOverlay(PalEntry color, float alpha, PalEntry &vertexcol
// //
//========================================================================== //==========================================================================
void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms) void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms)
{ {
if (parms.style.BlendOp == STYLEOP_None) return; // not supposed to be drawn. if (parms.style.BlendOp == STYLEOP_None) return; // not supposed to be drawn.
assert(img && img->isValid());
double xscale = parms.destwidth / parms.texwidth; double xscale = parms.destwidth / parms.texwidth;
double yscale = parms.destheight / parms.texheight; double yscale = parms.destheight / parms.texheight;
@ -472,7 +477,7 @@ void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms)
// //
//========================================================================== //==========================================================================
void F2DDrawer::AddShape( FTexture *img, DShape2D *shape, DrawParms &parms ) void F2DDrawer::AddShape(FGameTexture* img, DShape2D* shape, DrawParms& parms)
{ {
// [MK] bail out if vertex/coord array sizes are mismatched // [MK] bail out if vertex/coord array sizes are mismatched
if ( shape->mVertices.Size() != shape->mCoords.Size() ) if ( shape->mVertices.Size() != shape->mCoords.Size() )
@ -550,12 +555,11 @@ void F2DDrawer::AddShape( FTexture *img, DShape2D *shape, DrawParms &parms )
// //
//========================================================================== //==========================================================================
void F2DDrawer::AddPoly(FTexture *texture, FVector2 *points, int npoints, void F2DDrawer::AddPoly(FGameTexture *texture, FVector2 *points, int npoints,
double originx, double originy, double scalex, double scaley, double originx, double originy, double scalex, double scaley,
DAngle rotation, const FColormap &colormap, PalEntry flatcolor, double fadelevel, DAngle rotation, const FColormap &colormap, PalEntry flatcolor, double fadelevel,
uint32_t *indices, size_t indexcount) uint32_t *indices, size_t indexcount)
{ {
RenderCommand poly; RenderCommand poly;
poly.mType = DrawTypeTriangles; poly.mType = DrawTypeTriangles;
@ -630,7 +634,7 @@ void F2DDrawer::AddPoly(FTexture *texture, FVector2 *points, int npoints,
// //
//========================================================================== //==========================================================================
void F2DDrawer::AddPoly(FTexture* img, FVector4* vt, size_t vtcount, unsigned int* ind, size_t idxcount, int translation, PalEntry color, FRenderStyle style, int clipx1, int clipy1, int clipx2, int clipy2) void F2DDrawer::AddPoly(FGameTexture* img, FVector4* vt, size_t vtcount, unsigned int* ind, size_t idxcount, int translation, PalEntry color, FRenderStyle style, int clipx1, int clipy1, int clipx2, int clipy2)
{ {
RenderCommand dg = {}; RenderCommand dg = {};
int method = 0; int method = 0;
@ -677,7 +681,20 @@ void F2DDrawer::AddPoly(FTexture* img, FVector4* vt, size_t vtcount, unsigned in
// //
//========================================================================== //==========================================================================
void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin) float F2DDrawer::GetClassicFlatScalarWidth()
{
float ar = 4.f / 3.f / (float)ActiveRatio((float)screen->GetWidth(), (float)screen->GetHeight());
float sw = 320.f * classic_scaling_factor / (float)screen->GetWidth() / ar;
return sw;
}
float F2DDrawer::GetClassicFlatScalarHeight()
{
float sh = 240.f / classic_scaling_pixelaspect * classic_scaling_factor / (float)screen->GetHeight();
return sh;
}
void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FGameTexture *src, int local_origin, double flatscale)
{ {
float fU1, fU2, fV1, fV2; float fU1, fU2, fV1, fV2;
@ -690,27 +707,100 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FTexture *
dg.mTexture = src; dg.mTexture = src;
dg.mFlags = DTF_Wrap; dg.mFlags = DTF_Wrap;
// scaling is not used here. float fs = 1.f / float(flatscale);
if (!local_origin) bool flipc = false;
{
fU1 = float(left) / src->GetDisplayWidth(); float sw = GetClassicFlatScalarWidth();
fV1 = float(top) / src->GetDisplayHeight(); float sh = GetClassicFlatScalarHeight();
fU2 = float(right) / src->GetDisplayWidth();
fV2 = float(bottom) / src->GetDisplayHeight(); switch (local_origin)
}
else
{ {
case 0:
fU1 = float(left) / (float)src->GetDisplayWidth() * fs;
fV1 = float(top) / (float)src->GetDisplayHeight() * fs;
fU2 = float(right) / (float)src->GetDisplayWidth() * fs;
fV2 = float(bottom) / (float)src->GetDisplayHeight() * fs;
break;
case 1:
fU1 = 0; fU1 = 0;
fV1 = 0; fV1 = 0;
fU2 = float(right - left) / src->GetDisplayWidth(); fU2 = float(right - left) / (float)src->GetDisplayWidth() * fs;
fV2 = float(bottom - top) / src->GetDisplayHeight(); fV2 = float(bottom - top) / (float)src->GetDisplayHeight() * fs;
break;
// The following are for drawing frames with elements of pnly one orientation
case 2: // flip vertically
fU1 = 0;
fV2 = 0;
fU2 = float(right - left) / (float)src->GetDisplayWidth() * fs;
fV1 = float(bottom - top) / (float)src->GetDisplayHeight() * fs;
break;
case 3: // flip horizontally
fU2 = 0;
fV1 = 0;
fU1 = float(right - left) / (float)src->GetDisplayWidth() * fs;
fV2 = float(bottom - top) / (float)src->GetDisplayHeight() * fs;
break;
case 4: // flip vertically and horizontally
fU2 = 0;
fV2 = 0;
fU1 = float(right - left) / (float)src->GetDisplayWidth() * fs;
fV1 = float(bottom - top) / (float)src->GetDisplayHeight() * fs;
break;
case 5: // flip coordinates
fU1 = 0;
fV1 = 0;
fU2 = float(bottom - top) / (float)src->GetDisplayWidth() * fs;
fV2 = float(right - left) / (float)src->GetDisplayHeight() * fs;
break;
case 6: // flip coordinates and vertically
fU2 = 0;
fV1 = 0;
fU1 = float(bottom - top) / (float)src->GetDisplayWidth() * fs;
fV2 = float(right - left) / (float)src->GetDisplayHeight() * fs;
break;
case 7: // flip coordinates and horizontally
fU1 = 0;
fV2 = 0;
fU2 = float(bottom - top) / (float)src->GetDisplayWidth() * fs;
fV1 = float(right - left) / (float)src->GetDisplayHeight() * fs;
break;
case -1: // classic flat scaling
fU1 = float(left) / (float)src->GetDisplayWidth() * fs * sw;
fV1 = float(top) / (float)src->GetDisplayHeight() * fs * sh;
fU2 = float(right) / (float)src->GetDisplayWidth() * fs * sw;
fV2 = float(bottom) / (float)src->GetDisplayHeight() * fs * sh;
break;
case -2: // classic scaling for screen bevel
fU1 = 0;
fV1 = 0;
fU2 = float(right - left) / (float)src->GetDisplayWidth() * fs * sw;
fV2 = float(bottom - top) / (float)src->GetDisplayHeight() * fs * sh;
break;
} }
dg.mVertIndex = (int)mVertices.Reserve(4); dg.mVertIndex = (int)mVertices.Reserve(4);
auto ptr = &mVertices[dg.mVertIndex]; auto ptr = &mVertices[dg.mVertIndex];
ptr->Set(left, top, 0, fU1, fV1, 0xffffffff); ptr++; ptr->Set(left, top, 0, fU1, fV1, 0xffffffff); ptr++;
ptr->Set(left, bottom, 0, fU1, fV2, 0xffffffff); ptr++; if (local_origin < 4)
ptr->Set(right, top, 0, fU2, fV1, 0xffffffff); ptr++; {
ptr->Set(left, bottom, 0, fU1, fV2, 0xffffffff); ptr++;
ptr->Set(right, top, 0, fU2, fV1, 0xffffffff); ptr++;
}
else
{
ptr->Set(left, bottom, 0, fU2, fV1, 0xffffffff); ptr++;
ptr->Set(right, top, 0, fU1, fV2, 0xffffffff); ptr++;
}
ptr->Set(right, bottom, 0, fU2, fV2, 0xffffffff); ptr++; ptr->Set(right, bottom, 0, fU2, fV2, 0xffffffff); ptr++;
dg.mIndexIndex = mIndices.Size(); dg.mIndexIndex = mIndices.Size();
dg.mIndexCount += 6; dg.mIndexCount += 6;
@ -721,11 +811,11 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FTexture *
//=========================================================================== //===========================================================================
// //
// //
// //
//=========================================================================== //===========================================================================
void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, FRenderStyle *style) void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, FRenderStyle *style, bool prepend)
{ {
RenderCommand dg; RenderCommand dg;
@ -741,7 +831,13 @@ void F2DDrawer::AddColorOnlyQuad(int x1, int y1, int w, int h, PalEntry color, F
dg.mIndexIndex = mIndices.Size(); dg.mIndexIndex = mIndices.Size();
dg.mIndexCount += 6; dg.mIndexCount += 6;
AddIndices(dg.mVertIndex, 6, 0, 1, 2, 1, 3, 2); AddIndices(dg.mVertIndex, 6, 0, 1, 2, 1, 3, 2);
AddCommand(&dg); if (!prepend) AddCommand(&dg);
else
{
// Only needed by Raze's fullscreen blends because they are being calculated late when half of the 2D content has already been submitted,
// This ensures they are below the HUD, not above it.
mData.Insert(0, dg);
}
} }
void F2DDrawer::ClearScreen(PalEntry color) void F2DDrawer::ClearScreen(PalEntry color)
@ -755,7 +851,7 @@ void F2DDrawer::ClearScreen(PalEntry color)
// //
//========================================================================== //==========================================================================
void F2DDrawer::AddLine(float x1, float y1, float x2, float y2, int clipx1, int clipy1, int clipx2, int clipy2, uint32_t color, uint8_t alpha) void F2DDrawer::AddLine(double x1, double y1, double x2, double y2, int clipx1, int clipy1, int clipx2, int clipy2, uint32_t color, uint8_t alpha)
{ {
PalEntry p = (PalEntry)color; PalEntry p = (PalEntry)color;
p.a = alpha; p.a = alpha;

View file

@ -124,7 +124,7 @@ public:
int mIndexIndex; int mIndexIndex;
int mIndexCount; int mIndexCount;
FTexture *mTexture; FGameTexture *mTexture;
int mTranslationId; int mTranslationId;
PalEntry mSpecialColormap[2]; PalEntry mSpecialColormap[2];
int mScissor[4]; int mScissor[4];
@ -170,27 +170,29 @@ public:
void AddIndices(int firstvert, int count, ...); void AddIndices(int firstvert, int count, ...);
private: private:
void AddIndices(int firstvert, TArray<int> &v); void AddIndices(int firstvert, TArray<int> &v);
bool SetStyle(FTexture *tex, DrawParms &parms, PalEntry &color0, RenderCommand &quad); bool SetStyle(FGameTexture *tex, DrawParms &parms, PalEntry &color0, RenderCommand &quad);
void SetColorOverlay(PalEntry color, float alpha, PalEntry &vertexcolor, PalEntry &overlaycolor); void SetColorOverlay(PalEntry color, float alpha, PalEntry &vertexcolor, PalEntry &overlaycolor);
public: public:
void AddTexture(FTexture *img, DrawParms &parms); float GetClassicFlatScalarWidth();
void AddShape(FTexture *img, DShape2D *shape, DrawParms &parms); float GetClassicFlatScalarHeight();
void AddPoly(FTexture *texture, FVector2 *points, int npoints, void AddTexture(FGameTexture* img, DrawParms& parms);
void AddShape(FGameTexture *img, DShape2D *shape, DrawParms &parms);
void AddPoly(FGameTexture *texture, FVector2 *points, int npoints,
double originx, double originy, double scalex, double scaley, double originx, double originy, double scalex, double scaley,
DAngle rotation, const FColormap &colormap, PalEntry flatcolor, double lightlevel, uint32_t *indices, size_t indexcount); DAngle rotation, const FColormap &colormap, PalEntry flatcolor, double lightlevel, uint32_t *indices, size_t indexcount);
void AddPoly(FTexture* img, FVector4 *vt, size_t vtcount, unsigned int *ind, size_t idxcount, int translation, PalEntry color, FRenderStyle style, int clipx1, int clipy1, int clipx2, int clipy2); void AddPoly(FGameTexture* img, FVector4 *vt, size_t vtcount, unsigned int *ind, size_t idxcount, int translation, PalEntry color, FRenderStyle style, int clipx1, int clipy1, int clipx2, int clipy2);
void FillPolygon(int* rx1, int* ry1, int* xb1, int32_t npoints, int picnum, int palette, int shade, int props, const FVector2& xtex, const FVector2& ytex, const FVector2& otex, void FillPolygon(int* rx1, int* ry1, int* xb1, int32_t npoints, int picnum, int palette, int shade, int props, const FVector2& xtex, const FVector2& ytex, const FVector2& otex,
int clipx1, int clipy1, int clipx2, int clipy2); int clipx1, int clipy1, int clipx2, int clipy2);
void AddFlatFill(int left, int top, int right, int bottom, FTexture *src, bool local_origin = false); void AddFlatFill(int left, int top, int right, int bottom, FGameTexture *src, int local_origin = false, double flatscale = 1.0);
void AddColorOnlyQuad(int left, int top, int width, int height, PalEntry color, FRenderStyle *style = nullptr); void AddColorOnlyQuad(int left, int top, int width, int height, PalEntry color, FRenderStyle *style = nullptr, bool prepend = false);
void ClearScreen(PalEntry color = 0xff000000); void ClearScreen(PalEntry color = 0xff000000);
void AddDim(PalEntry color, float damount, int x1, int y1, int w, int h); 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_t color); void AddClear(int left, int top, int right, int bottom, int palcolor, uint32_t color);
void AddLine(float x1, float y1, float x2, float y2, int cx, int cy, int cx2, int cy2, uint32_t color, uint8_t alpha = 255); void AddLine(double x1, double y1, double x2, double y2, int cx, int cy, int cx2, int cy2, uint32_t color, uint8_t alpha = 255);
void AddThickLine(int x1, int y1, int x2, int y2, double thickness, uint32_t color, uint8_t alpha = 255); void AddThickLine(int x1, int y1, int x2, int y2, double thickness, uint32_t color, uint8_t alpha = 255);
void AddPixel(int x1, int y1, uint32_t color); void AddPixel(int x1, int y1, uint32_t color);
@ -198,7 +200,7 @@ public:
int GetWidth() const { return Width; } int GetWidth() const { return Width; }
int GetHeight() const { return Height; } int GetHeight() const { return Height; }
void SetSize(int w, int h) { Width = w; Height = h; } void SetSize(int w, int h) { Width = w; Height = h; }
void Begin() { isIn2D = true; } void Begin(int w, int h) { isIn2D = true; Width = w; Height = h; }
void End() { isIn2D = false; } void End() { isIn2D = false; }
bool HasBegun2D() { return isIn2D; } bool HasBegun2D() { return isIn2D; }

View file

@ -43,6 +43,7 @@
EXTERN_CVAR(Int, vid_aspect) EXTERN_CVAR(Int, vid_aspect)
EXTERN_CVAR(Int, uiscale) EXTERN_CVAR(Int, uiscale)
CVAR(Bool, ui_screenborder_classic_scaling, true, CVAR_ARCHIVE)
// Helper for ActiveRatio and CheckRatio. Returns the forced ratio type, or -1 if none. // Helper for ActiveRatio and CheckRatio. Returns the forced ratio type, or -1 if none.
int ActiveFakeRatio(int width, int height) int ActiveFakeRatio(int width, int height)
@ -180,7 +181,7 @@ int CleanXfac_1, CleanYfac_1, CleanWidth_1, CleanHeight_1;
// //
//========================================================================== //==========================================================================
void DrawTexture(F2DDrawer *drawer, FTexture* img, double x, double y, int tags_first, ...) void DrawTexture(F2DDrawer *drawer, FGameTexture* img, double x, double y, int tags_first, ...)
{ {
Va_List tags; Va_List tags;
va_start(tags.list, tags_first); va_start(tags.list, tags_first);
@ -203,7 +204,7 @@ void DrawTexture(F2DDrawer *drawer, FTexture* img, double x, double y, int tags_
int ListGetInt(VMVa_List &tags); int ListGetInt(VMVa_List &tags);
static void DrawTexture(F2DDrawer *drawer, FTexture *img, double x, double y, VMVa_List &args) static void DrawTexture(F2DDrawer *drawer, FGameTexture *img, double x, double y, VMVa_List &args)
{ {
DrawParms parms; DrawParms parms;
uint32_t tag = ListGetInt(args); uint32_t tag = ListGetInt(args);
@ -224,7 +225,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawTexture)
if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
FTexture *tex = TexMan.ByIndex(texid, animate); auto tex = TexMan.GameByIndex(texid, animate);
VMVa_List args = { param + 4, 0, numparam - 5, va_reginfo + 4 }; VMVa_List args = { param + 4, 0, numparam - 5, va_reginfo + 4 };
DrawTexture(twod, tex, x, y, args); DrawTexture(twod, tex, x, y, args);
return 0; return 0;
@ -236,7 +237,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawTexture)
// //
//========================================================================== //==========================================================================
void DrawShape(F2DDrawer *drawer, FTexture *img, DShape2D *shape, int tags_first, ...) void DrawShape(F2DDrawer *drawer, FGameTexture *img, DShape2D *shape, int tags_first, ...)
{ {
Va_List tags; Va_List tags;
va_start(tags.list, tags_first); va_start(tags.list, tags_first);
@ -248,7 +249,7 @@ void DrawShape(F2DDrawer *drawer, FTexture *img, DShape2D *shape, int tags_first
drawer->AddShape(img, shape, parms); drawer->AddShape(img, shape, parms);
} }
void DrawShape(F2DDrawer *drawer, FTexture *img, DShape2D *shape, VMVa_List &args) void DrawShape(F2DDrawer *drawer, FGameTexture *img, DShape2D *shape, VMVa_List &args)
{ {
DrawParms parms; DrawParms parms;
uint32_t tag = ListGetInt(args); uint32_t tag = ListGetInt(args);
@ -269,7 +270,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawShape)
if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function");
FTexture *tex = TexMan.ByIndex(texid, animate); auto tex = TexMan.GameByIndex(texid, animate);
VMVa_List args = { param + 3, 0, numparam - 4, va_reginfo + 3 }; VMVa_List args = { param + 3, 0, numparam - 4, va_reginfo + 3 };
DrawShape(twod, tex, shape, args); DrawShape(twod, tex, shape, args);
@ -334,7 +335,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetClipRect)
// //
//========================================================================== //==========================================================================
bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FTexture *img, double xx, double yy) bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FGameTexture *img, double xx, double yy)
{ {
auto GetWidth = [=]() { return drawer->GetWidth(); }; auto GetWidth = [=]() { return drawer->GetWidth(); };
auto GetHeight = [=]() {return drawer->GetHeight(); }; auto GetHeight = [=]() {return drawer->GetHeight(); };
@ -342,8 +343,8 @@ bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FTexture *img, double
{ {
parms->x = xx; parms->x = xx;
parms->y = yy; parms->y = yy;
parms->texwidth = img->GetDisplayWidthDouble(); parms->texwidth = img->GetDisplayWidth();
parms->texheight = img->GetDisplayHeightDouble(); parms->texheight = img->GetDisplayHeight();
if (parms->top == INT_MAX || parms->fortext) if (parms->top == INT_MAX || parms->fortext)
{ {
parms->top = img->GetDisplayTopOffset(); parms->top = img->GetDisplayTopOffset();
@ -354,11 +355,11 @@ bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FTexture *img, double
} }
if (parms->destwidth == INT_MAX || parms->fortext) if (parms->destwidth == INT_MAX || parms->fortext)
{ {
parms->destwidth = img->GetDisplayWidthDouble(); parms->destwidth = img->GetDisplayWidth();
} }
if (parms->destheight == INT_MAX || parms->fortext) if (parms->destheight == INT_MAX || parms->fortext)
{ {
parms->destheight = img->GetDisplayHeightDouble(); parms->destheight = img->GetDisplayHeight();
} }
switch (parms->cleanmode) switch (parms->cleanmode)
@ -387,8 +388,8 @@ bool SetTextureParms(F2DDrawer * drawer, DrawParms *parms, FTexture *img, double
case DTA_FullscreenEx: case DTA_FullscreenEx:
{ {
double aspect; double aspect;
double srcwidth = img->GetDisplayWidthDouble(); double srcwidth = img->GetDisplayWidth();
double srcheight = img->GetDisplayHeightDouble(); double srcheight = img->GetDisplayHeight();
int autoaspect = parms->fsscalemode; int autoaspect = parms->fsscalemode;
if (srcheight == 200) aspect = srcwidth / 240.; if (srcheight == 200) aspect = srcwidth / 240.;
else if (srcheight == 400) aspect = srcwidth / 480; else if (srcheight == 400) aspect = srcwidth / 480;
@ -533,7 +534,7 @@ static inline FSpecialColormap * ListGetSpecialColormap(VMVa_List &tags)
//========================================================================== //==========================================================================
template<class T> template<class T>
bool ParseDrawTextureTags(F2DDrawer *drawer, FTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, bool fortext) bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double y, uint32_t tag, T& tags, DrawParms *parms, bool fortext)
{ {
INTBOOL boolval; INTBOOL boolval;
int intval; int intval;
@ -726,8 +727,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FTexture *img, double x, double y,
if (img == NULL) return false; if (img == NULL) return false;
parms->cleanmode = DTA_Fullscreen; parms->cleanmode = DTA_Fullscreen;
parms->fsscalemode = (uint8_t)twod->fullscreenautoaspect; parms->fsscalemode = (uint8_t)twod->fullscreenautoaspect;
parms->virtWidth = img->GetDisplayWidthDouble(); parms->virtWidth = img->GetDisplayWidth();
parms->virtHeight = img->GetDisplayHeightDouble(); parms->virtHeight = img->GetDisplayHeight();
} }
break; break;
@ -740,8 +741,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FTexture *img, double x, double y,
if (img == NULL) return false; if (img == NULL) return false;
parms->cleanmode = DTA_Fullscreen; parms->cleanmode = DTA_Fullscreen;
parms->fsscalemode = (uint8_t)intval; parms->fsscalemode = (uint8_t)intval;
parms->virtWidth = img->GetDisplayWidthDouble(); parms->virtWidth = img->GetDisplayWidth();
parms->virtHeight = img->GetDisplayHeightDouble(); parms->virtHeight = img->GetDisplayHeight();
} }
break; break;
@ -787,19 +788,19 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FTexture *img, double x, double y,
break; break;
case DTA_SrcX: case DTA_SrcX:
parms->srcx = ListGetDouble(tags) / img->GetDisplayWidthDouble(); parms->srcx = ListGetDouble(tags) / img->GetDisplayWidth();
break; break;
case DTA_SrcY: case DTA_SrcY:
parms->srcy = ListGetDouble(tags) / img->GetDisplayHeightDouble(); parms->srcy = ListGetDouble(tags) / img->GetDisplayHeight();
break; break;
case DTA_SrcWidth: case DTA_SrcWidth:
parms->srcwidth = ListGetDouble(tags) / img->GetDisplayWidthDouble(); parms->srcwidth = ListGetDouble(tags) / img->GetDisplayWidth();
break; break;
case DTA_SrcHeight: case DTA_SrcHeight:
parms->srcheight = ListGetDouble(tags) / img->GetDisplayHeightDouble(); parms->srcheight = ListGetDouble(tags) / img->GetDisplayHeight();
break; break;
case DTA_TopOffset: case DTA_TopOffset:
@ -831,8 +832,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FTexture *img, double x, double y,
if (fortext) return false; if (fortext) return false;
if (ListGetInt(tags)) if (ListGetInt(tags))
{ {
parms->left = img->GetDisplayWidthDouble() * 0.5; parms->left = img->GetDisplayWidth() * 0.5;
parms->top = img->GetDisplayHeightDouble() * 0.5; parms->top = img->GetDisplayHeight() * 0.5;
} }
break; break;
@ -841,8 +842,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FTexture *img, double x, double y,
if (fortext) return false; if (fortext) return false;
if (ListGetInt(tags)) if (ListGetInt(tags))
{ {
parms->left = img->GetDisplayWidthDouble() * 0.5; parms->left = img->GetDisplayWidth() * 0.5;
parms->top = img->GetDisplayHeightDouble(); parms->top = img->GetDisplayHeight();
} }
break; break;
@ -1040,8 +1041,8 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FTexture *img, double x, double y,
} }
// explicitly instantiate both versions for v_text.cpp. // explicitly instantiate both versions for v_text.cpp.
template bool ParseDrawTextureTags<Va_List>(F2DDrawer* drawer, FTexture *img, double x, double y, uint32_t tag, Va_List& tags, DrawParms *parms, bool fortext); template bool ParseDrawTextureTags<Va_List>(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, Va_List& tags, DrawParms *parms, bool fortext);
template bool ParseDrawTextureTags<VMVa_List>(F2DDrawer* drawer, FTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, bool fortext); template bool ParseDrawTextureTags<VMVa_List>(F2DDrawer* drawer, FGameTexture *img, double x, double y, uint32_t tag, VMVa_List& tags, DrawParms *parms, bool fortext);
//========================================================================== //==========================================================================
// //
@ -1133,7 +1134,7 @@ void VirtualToRealCoordsInt(F2DDrawer *drawer, int &x, int &y, int &w, int &h,
// //
//========================================================================== //==========================================================================
void FillBorder (F2DDrawer *drawer, FTexture *img) void FillBorder (F2DDrawer *drawer, FGameTexture *img)
{ {
auto Width = drawer->GetWidth(); auto Width = drawer->GetWidth();
auto Height = drawer->GetHeight(); auto Height = drawer->GetHeight();
@ -1161,10 +1162,11 @@ void FillBorder (F2DDrawer *drawer, FTexture *img)
if (img != NULL) if (img != NULL)
{ {
drawer->AddFlatFill(0, 0, Width, bordtop, img); // Top int filltype = (ui_screenborder_classic_scaling) ? -1 : 0;
drawer->AddFlatFill(0, bordtop, bordleft, Height - bordbottom, img); // Left drawer->AddFlatFill(0, 0, Width, bordtop, img, filltype); // Top
drawer->AddFlatFill(Width - bordright, bordtop, Width, Height - bordbottom, img); // Right drawer->AddFlatFill(0, bordtop, bordleft, Height - bordbottom, img, filltype); // Left
drawer->AddFlatFill(0, Height - bordbottom, Width, Height, img); // Bottom drawer->AddFlatFill(Width - bordright, bordtop, Width, Height - bordbottom, img, filltype); // Right
drawer->AddFlatFill(0, Height - bordbottom, Width, Height, img, filltype); // Bottom
} }
else else
{ {
@ -1222,7 +1224,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Screen, DrawThickLine, DrawThickLine)
//========================================================================== //==========================================================================
// //
// DCanvas :: Clear // ClearRect
// //
// Set an area to a specified color. // Set an area to a specified color.
// //
@ -1281,7 +1283,7 @@ DEFINE_ACTION_FUNCTION(_Screen, Clear)
//========================================================================== //==========================================================================
// //
// DCanvas :: Dim // DoDim
// //
// Applies a colored overlay to an area of the screen. // Applies a colored overlay to an area of the screen.
// //
@ -1351,9 +1353,10 @@ DEFINE_ACTION_FUNCTION(_Screen, Dim)
void DrawBorder (F2DDrawer *drawer, FTextureID picnum, int x1, int y1, int x2, int y2) void DrawBorder (F2DDrawer *drawer, FTextureID picnum, int x1, int y1, int x2, int y2)
{ {
int filltype = (ui_screenborder_classic_scaling) ? -1 : 0;
if (picnum.isValid()) if (picnum.isValid())
{ {
drawer->AddFlatFill (x1, y1, x2, y2, TexMan.GetTexture(picnum, false)); drawer->AddFlatFill (x1, y1, x2, y2, TexMan.GetGameTexture(picnum, false), filltype);
} }
else else
{ {
@ -1384,3 +1387,9 @@ void DrawFrame(F2DDrawer* twod, PalEntry color, int left, int top, int width, in
twod->AddColorOnlyQuad(right, top - offset, offset, height + 2 * offset, color); twod->AddColorOnlyQuad(right, top - offset, offset, height + 2 * offset, color);
} }
void V_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany, int* _cx1, int* _cx2)
{
if (designheight < 240 && realheight >= 480) designheight = 240;
*cleanx = *cleany = std::min(realwidth / designwidth, realheight / designheight);
}

View file

@ -203,22 +203,22 @@ inline int active_con_scale(F2DDrawer *drawer)
#endif #endif
template<class T> template<class T>
bool ParseDrawTextureTags(F2DDrawer *drawer, FTexture* img, double x, double y, uint32_t tag, T& tags, DrawParms* parms, bool fortext); bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture* img, double x, double y, uint32_t tag, T& tags, DrawParms* parms, bool fortext);
template<class T> template<class T>
void DrawTextCommon(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double y, const T* string, DrawParms& parms); void DrawTextCommon(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double y, const T* string, DrawParms& parms);
bool SetTextureParms(F2DDrawer *drawer, DrawParms* parms, FTexture* img, double x, double y); bool SetTextureParms(F2DDrawer *drawer, DrawParms* parms, FGameTexture* img, double x, double y);
void DrawText(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, const char* string, int tag_first, ...); void DrawText(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, const char* string, int tag_first, ...);
void DrawText(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, const char32_t* string, int tag_first, ...); void DrawText(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, const char32_t* string, int tag_first, ...);
void DrawChar(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, int character, int tag_first, ...); void DrawChar(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, int character, int tag_first, ...);
void DrawTexture(F2DDrawer* drawer, FTexture* img, double x, double y, int tags_first, ...);
void DrawTexture(F2DDrawer* drawer, FGameTexture* img, double x, double y, int tags_first, ...);
void DoDim(F2DDrawer* drawer, PalEntry color, float amount, int x1, int y1, int w, int h, FRenderStyle* style = nullptr); void DoDim(F2DDrawer* drawer, PalEntry color, float amount, int x1, int y1, int w, int h, FRenderStyle* style = nullptr);
void Dim(F2DDrawer* drawer, PalEntry color, float damount, int x1, int y1, int w, int h, FRenderStyle* style = nullptr); void Dim(F2DDrawer* drawer, PalEntry color, float damount, int x1, int y1, int w, int h, FRenderStyle* style = nullptr);
void FillBorder(F2DDrawer *drawer, FTexture* img); // Fills the border around a 4:3 part of the screen on non-4:3 displays void FillBorder(F2DDrawer *drawer, FGameTexture* img); // Fills the border around a 4:3 part of the screen on non-4:3 displays
void DrawFrame(F2DDrawer* drawer, int left, int top, int width, int height);
void DrawBorder(F2DDrawer* drawer, FTextureID, int x1, int y1, int x2, int y2); void DrawBorder(F2DDrawer* drawer, FTextureID, int x1, int y1, int x2, int y2);
void DrawFrame(F2DDrawer* twod, PalEntry color, int left, int top, int width, int height, int thickness); void DrawFrame(F2DDrawer* twod, PalEntry color, int left, int top, int width, int height, int thickness);
@ -232,3 +232,39 @@ void VirtualToRealCoordsInt(F2DDrawer* drawer, int& x, int& y, int& w, int& h, i
extern int CleanWidth, CleanHeight, CleanXfac, CleanYfac; extern int CleanWidth, CleanHeight, CleanXfac, CleanYfac;
extern int CleanWidth_1, CleanHeight_1, CleanXfac_1, CleanYfac_1; extern int CleanWidth_1, CleanHeight_1, CleanXfac_1, CleanYfac_1;
void V_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany, int* cx1 = NULL, int* cx2 = NULL);
class ScaleOverrider
{
int savedxfac, savedyfac, savedwidth, savedheight;
public:
// This is to allow certain elements to use an optimal fullscreen scale which for the menu would be too large.
// The old code contained far too much mess to compensate for the menus which negatively affected everything else.
// However, for compatibility reasons the currently used variables cannot be changed so they have to be overridden temporarily.
// This class provides a safe interface for this because it ensures that the values get restored afterward.
// Currently, the intermission and the level summary screen use this.
ScaleOverrider(F2DDrawer *drawer)
{
savedxfac = CleanXfac;
savedyfac = CleanYfac;
savedwidth = CleanWidth;
savedheight = CleanHeight;
if (drawer)
{
V_CalcCleanFacs(320, 200, drawer->GetWidth(), drawer->GetHeight(), &CleanXfac, &CleanYfac);
CleanWidth = drawer->GetWidth() / CleanXfac;
CleanHeight = drawer->GetHeight() / CleanYfac;
}
}
~ScaleOverrider()
{
CleanXfac = savedxfac;
CleanYfac = savedyfac;
CleanWidth = savedwidth;
CleanHeight = savedheight;
}
};

View file

@ -53,7 +53,7 @@ int ListGetInt(VMVa_List &tags);
// //
//========================================================================== //==========================================================================
#if 0 #if 0
FTexture * BuildTextTexture(FFont *font, const char *string, int textcolor) FGameTexture * BuildTextTexture(FFont *font, const char *string, int textcolor)
{ {
int w; int w;
const uint8_t *ch; const uint8_t *ch;
@ -61,7 +61,7 @@ FTexture * BuildTextTexture(FFont *font, const char *string, int textcolor)
int cy; int cy;
int trans = -1; int trans = -1;
int kerning; int kerning;
FTexture *pic; FGameTexture *pic;
kerning = font->GetDefaultKerning(); kerning = font->GetDefaultKerning();
@ -170,7 +170,7 @@ void DrawChar(F2DDrawer *drawer, FFont* font, int normalcolor, double x, double
if (normalcolor >= NumTextColors) if (normalcolor >= NumTextColors)
normalcolor = CR_UNTRANSLATED; normalcolor = CR_UNTRANSLATED;
FTexture* pic; FGameTexture* pic;
int dummy; int dummy;
bool redirected; bool redirected;
@ -200,7 +200,7 @@ void DrawChar(F2DDrawer *drawer, FFont *font, int normalcolor, double x, double
if (normalcolor >= NumTextColors) if (normalcolor >= NumTextColors)
normalcolor = CR_UNTRANSLATED; normalcolor = CR_UNTRANSLATED;
FTexture *pic; FGameTexture *pic;
int dummy; int dummy;
bool redirected; bool redirected;
@ -256,7 +256,7 @@ void DrawTextCommon(F2DDrawer *drawer, FFont *font, int normalcolor, double x, d
int boldcolor; int boldcolor;
int trans = -1; int trans = -1;
int kerning; int kerning;
FTexture *pic; FGameTexture *pic;
if (parms.celly == 0) parms.celly = font->GetHeight() + 1; if (parms.celly == 0) parms.celly = font->GetHeight() + 1;
parms.celly *= parms.scaley; parms.celly *= parms.scaley;

View file

@ -37,7 +37,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdexcept>
#include "i_sound.h" #include "i_sound.h"
#include "i_music.h" #include "i_music.h"
@ -166,9 +166,9 @@ static bool S_StartMusicPlaying(ZMusic_MusicStream song, bool loop, float rel_vo
//========================================================================== //==========================================================================
// //
// S_PauseSound // S_PauseMusic
// //
// Stop music and sound effects, during game PAUSE. // Stop music, during game PAUSE.
//========================================================================== //==========================================================================
void S_PauseMusic () void S_PauseMusic ()
@ -183,9 +183,9 @@ void S_PauseMusic ()
//========================================================================== //==========================================================================
// //
// S_ResumeSound // S_ResumeMusic
// //
// Resume music and sound effects, after game PAUSE. // Resume music, after game PAUSE.
//========================================================================== //==========================================================================
void S_ResumeMusic () void S_ResumeMusic ()

View file

@ -486,3 +486,4 @@ SoundHandle SoundRenderer::LoadSoundVoc(uint8_t *sfxdata, int length)
if (data) delete[] data; if (data) delete[] data;
return retval; return retval;
} }

View file

@ -144,7 +144,7 @@ struct FISoundChannel
class SoundStream; class SoundStream;
void S_SetSoundPaused(int state);
#endif #endif

View file

@ -1420,7 +1420,10 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener
if(!reuse_chan || reuse_chan->StartTime == 0) if(!reuse_chan || reuse_chan->StartTime == 0)
{ {
float st = (chanflags & SNDF_LOOP) ? fmod(startTime, (float)GetMSLength(sfx) / 1000.f) : clamp<float>(startTime, 0.f, (float)GetMSLength(sfx) / 1000.f); float sfxlength = (float)GetMSLength(sfx) / 1000.f;
float st = (chanflags & SNDF_LOOP)
? (sfxlength > 0 ? fmod(startTime, sfxlength) : 0)
: clamp<float>(startTime, 0.f, sfxlength);
alSourcef(source, AL_SEC_OFFSET, st); alSourcef(source, AL_SEC_OFFSET, st);
} }
else else

View file

@ -494,26 +494,9 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
int seen = 0; int seen = 0;
if (source != NULL && channel == CHAN_AUTO) if (source != NULL && channel == CHAN_AUTO)
{ {
// Select a channel that isn't already playing something. // In the old sound system, 'AUTO' hijacked one of the other channels.
// Try channel 0 first, then travel from channel 7 down. // Now, with CHANF_OVERLAP at our disposal that isn't needed anymore. Just set the flag and let all sounds play on channel 0.
if (!IsChannelUsed(type, source, 0, &seen)) chanflags |= CHANF_OVERLAP;
{
channel = 0;
}
else
{
for (channel = 7; channel > 0; --channel)
{
if (!IsChannelUsed(type, source, channel, &seen))
{
break;
}
}
if (channel == 0)
{ // Crap. No free channels.
return NULL;
}
}
} }
// If this actor is already playing something on the selected channel, stop it. // If this actor is already playing something on the selected channel, stop it.
@ -564,9 +547,10 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
if (chanflags & (CHANF_UI|CHANF_NOPAUSE)) startflags |= SNDF_NOPAUSE; if (chanflags & (CHANF_UI|CHANF_NOPAUSE)) startflags |= SNDF_NOPAUSE;
if (chanflags & CHANF_UI) startflags |= SNDF_NOREVERB; if (chanflags & CHANF_UI) startflags |= SNDF_NOREVERB;
float sfxlength = (float)GSnd->GetMSLength(sfx->data) / 1000.f;
startTime = (startflags & SNDF_LOOP) startTime = (startflags & SNDF_LOOP)
? fmod(startTime, (float)GSnd->GetMSLength(sfx->data) / 1000.f) ? (sfxlength > 0 ? fmod(startTime, sfxlength) : 0)
: clamp<float>(startTime, 0.f, (float)GSnd->GetMSLength(sfx->data) / 1000.f); : clamp<float>(startTime, 0.f, sfxlength);
if (attenuation > 0 && type != SOURCE_None) if (attenuation > 0 && type != SOURCE_None)
{ {

View file

@ -171,7 +171,7 @@ public:
static void ListVars (const char *filter, bool plain); static void ListVars (const char *filter, bool plain);
const char *GetDescription() const { return Description; }; const FString &GetDescription() const { return Description; };
protected: protected:
virtual void DoSet (UCVarValue value, ECVarType type) = 0; virtual void DoSet (UCVarValue value, ECVarType type) = 0;

View file

@ -301,6 +301,7 @@ void C_DoCommand (const char *cmd, int keynum)
} }
else else
{ // Get the variable's value { // Get the variable's value
if (var->GetDescription().Len()) Printf("%s\n", var->GetDescription().GetChars());
Printf ("\"%s\" is \"%s\"\n", var->GetName(), var->GetHumanString()); Printf ("\"%s\" is \"%s\"\n", var->GetName(), var->GetHumanString());
} }
} }

View file

@ -1,3 +1,8 @@
#include "i_interface.h" #include "i_interface.h"
// Some global engine variables taken out of the backend code.
SystemCallbacks *sysCallbacks; SystemCallbacks *sysCallbacks;
double refreshfreq;
FString endoomName;
bool batchrun;

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include "zstring.h"
#include "intrect.h"
struct SystemCallbacks struct SystemCallbacks
{ {
@ -8,6 +10,23 @@ struct SystemCallbacks
bool (*NetGame)(); bool (*NetGame)();
bool (*WantNativeMouse)(); bool (*WantNativeMouse)();
bool (*CaptureModeInGame)(); bool (*CaptureModeInGame)();
void (*CrashInfo)(char* buffer, size_t bufflen, const char* lfstr);
void (*PlayStartupSound)(const char* name);
bool (*IsSpecialUI)();
bool (*DisableTextureFilter)();
void (*OnScreenSizeChanged)();
IntRect(*GetSceneRect)();
FString(*GetLocationDescription)();
}; };
extern SystemCallbacks *sysCallbacks; extern SystemCallbacks *sysCallbacks;
struct WadStuff
{
FString Path;
FString Name;
};
extern FString endoomName;
extern bool batchrun;

View file

@ -0,0 +1,22 @@
#pragma once
#include "zstring.h"
#ifdef __unix__
FString GetUserFile (const char *path);
#endif
FString M_GetAppDataPath(bool create);
FString M_GetCachePath(bool create);
FString M_GetAutoexecPath();
FString M_GetConfigPath(bool for_reading);
FString M_GetScreenshotsPath();
FString M_GetSavegamesPath();
FString M_GetDocumentsPath();
FString M_GetDemoPath();
FString M_GetNormalizedPath(const char* path);
#ifdef __APPLE__
FString M_GetMacAppSupportPath(const bool create = true);
void M_GetMacSearchDirectories(FString& user_docs, FString& user_app_support, FString& local_app_support);
#endif // __APPLE__

View file

@ -462,6 +462,7 @@ xx(Friend)
xx(Strifeally) xx(Strifeally)
xx(Standing) xx(Standing)
xx(Countsecret) xx(Countsecret)
xx(NoCount)
xx(Score) xx(Score)
xx(Roll) xx(Roll)
xx(Scale) xx(Scale)
@ -809,6 +810,7 @@ xx(MoveBob)
xx(StillBob) xx(StillBob)
xx(ClassicFlight) xx(ClassicFlight)
xx(WBobSpeed) xx(WBobSpeed)
xx(WBobFire)
xx(PlayerClass) xx(PlayerClass)
xx(MonsterClass) xx(MonsterClass)
xx(MorphedMonster) xx(MorphedMonster)

View file

@ -34,6 +34,7 @@ struct FRemapTable
int Index; int Index;
int NumEntries; // # of elements in this table (usually 256) int NumEntries; // # of elements in this table (usually 256)
bool Inactive = false; // This table is inactive and should be treated as if it was passed as NULL bool Inactive = false; // This table is inactive and should be treated as if it was passed as NULL
bool TwodOnly = false; // Only used for 2D rendering
bool ForFont = false; // Mark font translations because they may require different handling than the ones for sprites- bool ForFont = false; // Mark font translations because they may require different handling than the ones for sprites-
private: private:

View file

@ -1119,7 +1119,7 @@ void FScanner::CheckOpen()
{ {
if (ScriptOpen == false) if (ScriptOpen == false)
{ {
I_FatalError ("SC_ call before SC_Open()."); I_Error ("SC_ call before SC_Open().");
} }
} }

View file

@ -1081,16 +1081,17 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FTextureID &value, FTe
} }
FTextureID chk = value; FTextureID chk = value;
if (chk.GetIndex() >= TexMan.NumTextures()) chk.SetNull(); if (chk.GetIndex() >= TexMan.NumTextures()) chk.SetNull();
FTexture *pic = TexMan.GetTexture(chk); auto pic = TexMan.GetGameTexture(chk);
const char *name; const char *name;
auto lump = pic->GetSourceLump();
if (fileSystem.GetLinkedTexture(pic->SourceLump) == pic) if (fileSystem.GetLinkedTexture(lump) == pic)
{ {
name = fileSystem.GetFileFullName(pic->SourceLump); name = fileSystem.GetFileFullName(lump);
} }
else else
{ {
name = pic->Name; name = pic->GetName();
} }
arc.WriteKey(key); arc.WriteKey(key);
arc.w->StartArray(); arc.w->StartArray();
@ -1503,7 +1504,7 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, Dictionary
{ {
if (arc.isWriting()) if (arc.isWriting())
{ {
FString contents { dict ? DictionaryToString(*dict) : "null" }; FString contents { dict ? DictionaryToString(*dict) : FString("null") };
return arc(key, contents); return arc(key, contents);
} }
else else

View file

@ -0,0 +1,207 @@
#pragma once
/*
** st_start.h
** Interface for the startup screen.
**
**---------------------------------------------------------------------------
** Copyright 2006-2007 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
** The startup screen interface is based on a mix of Heretic and Hexen.
** Actual implementation is system-specific.
*/
#include <stdint.h>
class FStartupScreen
{
public:
static FStartupScreen *CreateInstance(int max_progress);
FStartupScreen(int max_progress)
{
MaxPos = max_progress;
CurPos = 0;
NotchPos = 0;
}
virtual ~FStartupScreen() = default;
virtual void Progress() {}
virtual void NetInit(const char *message, int num_players) {}
virtual void NetProgress(int count) {}
virtual void NetMessage(const char *format, ...) {} // cover for printf
virtual void NetDone() {}
virtual bool NetLoop(bool (*timer_callback)(void *), void *userdata) { return false; }
protected:
int MaxPos, CurPos, NotchPos;
};
class FBasicStartupScreen : public FStartupScreen
{
public:
FBasicStartupScreen(int max_progress, bool show_bar);
~FBasicStartupScreen();
void Progress();
void NetInit(const char* message, int num_players);
void NetProgress(int count);
void NetMessage(const char* format, ...); // cover for printf
void NetDone();
bool NetLoop(bool (*timer_callback)(void*), void* userdata);
protected:
long long NetMarqueeMode;
int NetMaxPos, NetCurPos;
};
class FGraphicalStartupScreen : public FBasicStartupScreen
{
public:
FGraphicalStartupScreen(int max_progress);
~FGraphicalStartupScreen();
};
class FHereticStartupScreen : public FGraphicalStartupScreen
{
public:
FHereticStartupScreen(int max_progress, long &hr);
void Progress();
void LoadingStatus(const char *message, int colors);
void AppendStatusLine(const char *status);
protected:
void SetWindowSize();
int ThermX, ThermY, ThermWidth, ThermHeight;
int HMsgY, SMsgX;
};
class FHexenStartupScreen : public FGraphicalStartupScreen
{
public:
FHexenStartupScreen(int max_progress, long &hr);
~FHexenStartupScreen();
void Progress();
void NetProgress(int count);
void NetDone();
void SetWindowSize();
// Hexen's notch graphics, converted to chunky pixels.
uint8_t * NotchBits;
uint8_t * NetNotchBits;
};
class FStrifeStartupScreen : public FGraphicalStartupScreen
{
public:
FStrifeStartupScreen(int max_progress, long &hr);
~FStrifeStartupScreen();
void Progress();
protected:
void DrawStuff(int old_laser, int new_laser);
void SetWindowSize();
uint8_t *StartupPics[4+2+1];
};
extern FStartupScreen *StartScreen;
void DeleteStartupScreen();
extern void ST_Endoom();
// The entire set of functions here uses native Windows types. These are recreations of those types so that the code doesn't need to be changed more than necessary
struct BitmapInfoHeader
{
uint32_t biSize;
int32_t biWidth;
int32_t biHeight;
uint16_t biPlanes;
uint16_t biBitCount;
uint32_t biCompression;
uint32_t biSizeImage;
int32_t biXPelsPerMeter;
int32_t biYPelsPerMeter;
uint32_t biClrUsed;
uint32_t biClrImportant;
};
struct RgbQuad
{
uint8_t rgbBlue;
uint8_t rgbGreen;
uint8_t rgbRed;
uint8_t rgbReserved;
};
struct BitmapInfo
{
BitmapInfoHeader bmiHeader;
RgbQuad bmiColors[1];
};
extern BitmapInfo* StartupBitmap;
void ST_Util_PlanarToChunky4(uint8_t* dest, const uint8_t* src, int width, int height);
void ST_Util_DrawBlock(BitmapInfo* bitmap_info, const uint8_t* src, int x, int y, int bytewidth, int height);
void ST_Util_ClearBlock(BitmapInfo* bitmap_info, uint8_t fill, int x, int y, int bytewidth, int height);
BitmapInfo* ST_Util_CreateBitmap(int width, int height, int color_bits);
uint8_t* ST_Util_BitsForBitmap(BitmapInfo* bitmap_info);
void ST_Util_FreeBitmap(BitmapInfo* bitmap_info);
void ST_Util_BitmapColorsFromPlaypal(BitmapInfo* bitmap_info);
uint8_t* ST_Util_LoadFont(const char* filename);
void ST_Util_FreeFont(uint8_t* font);
BitmapInfo* ST_Util_AllocTextBitmap(const uint8_t* font);
void ST_Util_DrawTextScreen(BitmapInfo* bitmap_info, const uint8_t* text_screen, const uint8_t* font);
void ST_Util_DrawChar(BitmapInfo* screen, const uint8_t* font, int x, int y, uint8_t charnum, uint8_t attrib);
void ST_Util_UpdateTextBlink(BitmapInfo* bitmap_info, const uint8_t* text_screen, const uint8_t* font, bool on);
//===========================================================================
//
// DeleteStartupScreen
//
// Makes sure the startup screen has been deleted before quitting.
//
//===========================================================================
inline void DeleteStartupScreen()
{
if (StartScreen != nullptr)
{
delete StartScreen;
StartScreen = nullptr;
}
}

View file

@ -0,0 +1,28 @@
#pragma once
#include <stdint.h>
#include "zstring.h"
struct FStartupInfo
{
FString Name;
uint32_t FgColor; // Foreground color for title banner
uint32_t BkColor; // Background color for title banner
FString Song;
int Type;
int LoadLights = -1;
int LoadBrightmaps = -1;
int modern = 0;
enum
{
DefaultStartup,
DoomStartup,
HereticStartup,
HexenStartup,
StrifeStartup,
};
};
extern FStartupInfo GameStartupInfo;

View file

@ -57,7 +57,7 @@ extern FILE* hashfile;
struct FileSystem::LumpRecord struct FileSystem::LumpRecord
{ {
FResourceLump *lump; FResourceLump *lump;
FTexture* linkedTexture; FGameTexture* linkedTexture;
LumpShortName shortName; LumpShortName shortName;
FString longName; FString longName;
int rfnum; int rfnum;
@ -725,7 +725,7 @@ int FileSystem::GetResource (int resid, const char *type, int filenum) const
// //
//========================================================================== //==========================================================================
void FileSystem::SetLinkedTexture(int lump, FTexture *tex) void FileSystem::SetLinkedTexture(int lump, FGameTexture *tex)
{ {
if ((size_t)lump < NumEntries) if ((size_t)lump < NumEntries)
{ {
@ -739,7 +739,7 @@ void FileSystem::SetLinkedTexture(int lump, FTexture *tex)
// //
//========================================================================== //==========================================================================
FTexture *FileSystem::GetLinkedTexture(int lump) FGameTexture *FileSystem::GetLinkedTexture(int lump)
{ {
if ((size_t)lump < NumEntries) if ((size_t)lump < NumEntries)
{ {

View file

@ -16,7 +16,7 @@
class FResourceFile; class FResourceFile;
struct FResourceLump; struct FResourceLump;
class FTexture; class FGameTexture;
union LumpShortName union LumpShortName
{ {
@ -38,7 +38,7 @@ public:
~FileData (); ~FileData ();
void *GetMem () { return Block.Len() == 0 ? NULL : (void *)Block.GetChars(); } void *GetMem () { return Block.Len() == 0 ? NULL : (void *)Block.GetChars(); }
size_t GetSize () { return Block.Len(); } size_t GetSize () { return Block.Len(); }
FString GetString () { return Block; } const FString &GetString () const { return Block; }
private: private:
FileData (const FString &source); FileData (const FString &source);
@ -124,8 +124,8 @@ public:
inline int CheckNumForFullName (const FString &name, int wadfile) { return CheckNumForFullName(name.GetChars(), wadfile); } inline int CheckNumForFullName (const FString &name, int wadfile) { return CheckNumForFullName(name.GetChars(), wadfile); }
inline int GetNumForFullName (const FString &name) { return GetNumForFullName(name.GetChars()); } inline int GetNumForFullName (const FString &name) { return GetNumForFullName(name.GetChars()); }
void SetLinkedTexture(int lump, FTexture *tex); void SetLinkedTexture(int lump, FGameTexture *tex);
FTexture *GetLinkedTexture(int lump); FGameTexture *GetLinkedTexture(int lump);
void ReadFile (int lump, void *dest); void ReadFile (int lump, void *dest);

View file

@ -19,7 +19,6 @@ struct LumpFilterInfo
}; };
class FResourceFile; class FResourceFile;
class FTexture;
// [RH] Namespaces from BOOM. // [RH] Namespaces from BOOM.
// These are needed here in the low level part so that WAD files can be properly set up. // These are needed here in the low level part so that WAD files can be properly set up.

View file

@ -73,7 +73,6 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
int i; int i;
FTextureID lump; FTextureID lump;
char buffer[12]; char buffer[12];
int maxyoffs;
DVector2 Scale = { 1, 1 }; DVector2 Scale = { 1, 1 };
noTranslate = notranslate; noTranslate = notranslate;
@ -91,9 +90,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
translateUntranslated = false; translateUntranslated = false;
int FixedWidth = 0; int FixedWidth = 0;
maxyoffs = 0; TMap<int, FGameTexture*> charMap;
TMap<int, FTexture*> charMap;
int minchar = INT_MAX; int minchar = INT_MAX;
int maxchar = INT_MIN; int maxchar = INT_MIN;
@ -231,13 +228,13 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
Type = Multilump; Type = Multilump;
if (position < minchar) minchar = position; if (position < minchar) minchar = position;
if (position > maxchar) maxchar = position; if (position > maxchar) maxchar = position;
charMap.Insert(position, TexMan.GetTexture(lump)); charMap.Insert(position, TexMan.GetGameTexture(lump));
} }
} }
} }
else else
{ {
FTexture *texs[256] = {}; FGameTexture *texs[256] = {};
if (lcount > 256 - start) lcount = 256 - start; if (lcount > 256 - start) lcount = 256 - start;
for (i = 0; i < lcount; i++) for (i = 0; i < lcount; i++)
{ {
@ -247,8 +244,8 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
TexMan.ListTextures(buffer, array, true); TexMan.ListTextures(buffer, array, true);
for (auto entry : array) for (auto entry : array)
{ {
FTexture *tex = TexMan.GetTexture(entry, false); auto tex = TexMan.GetGameTexture(entry, false);
if (tex && tex->GetSourceLump() >= 0 && fileSystem.GetFileContainer(tex->GetSourceLump()) <= fileSystem.GetMaxIwadNum() && tex->GetUseType() == ETextureType::MiscPatch) if (tex && !tex->isUserContent() && tex->GetUseType() == ETextureType::MiscPatch)
{ {
texs[i] = tex; texs[i] = tex;
} }
@ -292,8 +289,8 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
{ {
if ((int)position < minchar) minchar = (int)position; if ((int)position < minchar) minchar = (int)position;
if ((int)position > maxchar) maxchar = (int)position; if ((int)position > maxchar) maxchar = (int)position;
auto tex = TexMan.GetTexture(lump); auto tex = TexMan.GetGameTexture(lump);
tex->SetScale(Scale); tex->SetScale((float)Scale.X, (float)Scale.Y);
charMap.Insert((int)position, tex); charMap.Insert((int)position, tex);
Type = Folder; Type = Folder;
} }
@ -312,17 +309,13 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
auto lump = charMap.CheckKey(FirstChar + i); auto lump = charMap.CheckKey(FirstChar + i);
if (lump != nullptr) if (lump != nullptr)
{ {
FTexture *pic = *lump; auto pic = *lump;
if (pic != nullptr) if (pic != nullptr)
{ {
int height = pic->GetDisplayHeight(); double fheight = pic->GetDisplayHeight();
int yoffs = pic->GetDisplayTopOffset(); double yoffs = pic->GetDisplayTopOffset();
if (yoffs > maxyoffs) int height = int(fheight + abs(yoffs) + 0.5);
{
maxyoffs = yoffs;
}
height += abs(yoffs);
if (height > fontheight) if (height > fontheight)
{ {
fontheight = height; fontheight = height;
@ -333,24 +326,24 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
} }
} }
Chars[i].OriginalPic = new FImageTexture(pic->GetImage(), ""); auto orig = pic->GetTexture();
Chars[i].OriginalPic->SetUseType(ETextureType::FontChar); auto tex = MakeGameTexture(orig, nullptr, ETextureType::FontChar);
Chars[i].OriginalPic->CopySize(pic); tex->CopySize(pic);
TexMan.AddTexture(Chars[i].OriginalPic); TexMan.AddGameTexture(tex);
Chars[i].OriginalPic = tex;
if (!noTranslate) if (!noTranslate)
{ {
Chars[i].TranslatedPic = new FImageTexture(new FFontChar1(pic->GetImage()), ""); Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1(orig->GetImage())), nullptr, ETextureType::FontChar);
Chars[i].TranslatedPic->CopySize(pic); Chars[i].TranslatedPic->CopySize(pic);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); TexMan.AddGameTexture(Chars[i].TranslatedPic);
TexMan.AddTexture(Chars[i].TranslatedPic);
} }
else else
{ {
Chars[i].TranslatedPic = Chars[i].OriginalPic; Chars[i].TranslatedPic = tex;
} }
Chars[i].XMove = Chars[i].TranslatedPic->GetDisplayWidth(); Chars[i].XMove = (int)Chars[i].TranslatedPic->GetDisplayWidth();
} }
else else
{ {
@ -379,17 +372,13 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
FixXMoves(); FixXMoves();
} }
if (!noTranslate) LoadTranslations();
} }
void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height, const DVector2 &Scale) void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height, const DVector2 &Scale)
{ {
// all valid lumps must be named with a hex number that represents the Unicode character index for its first character, // all valid lumps must be named with a hex number that represents the Unicode character index for its first character,
TArray<TexPart> part(1, true); TArray<TexPartBuild> part(1, true);
TMap<int, FTexture*> charMap; TMap<int, FGameTexture*> charMap;
int minchar = INT_MAX; int minchar = INT_MAX;
int maxchar = INT_MIN; int maxchar = INT_MIN;
for (auto &entry : folderdata) for (auto &entry : folderdata)
@ -402,7 +391,7 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
auto lump = TexMan.CheckForTexture(entry.name, ETextureType::MiscPatch); auto lump = TexMan.CheckForTexture(entry.name, ETextureType::MiscPatch);
if (lump.isValid()) if (lump.isValid())
{ {
auto tex = TexMan.GetTexture(lump); auto tex = TexMan.GetGameTexture(lump);
int numtex_x = tex->GetTexelWidth() / width; int numtex_x = tex->GetTexelWidth() / width;
int numtex_y = tex->GetTexelHeight() / height; int numtex_y = tex->GetTexelHeight() / height;
int maxinsheet = int(position) + numtex_x * numtex_y - 1; int maxinsheet = int(position) + numtex_x * numtex_y - 1;
@ -415,25 +404,16 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
{ {
part[0].OriginX = -width * x; part[0].OriginX = -width * x;
part[0].OriginY = -height * y; part[0].OriginY = -height * y;
part[0].Image = tex->GetImage(); part[0].TexImage = static_cast<FImageTexture*>(tex->GetTexture());
FMultiPatchTexture *image = new FMultiPatchTexture(width, height, part, false, false); FMultiPatchTexture *image = new FMultiPatchTexture(width, height, part, false, false);
FImageTexture *tex = new FImageTexture(image, ""); FImageTexture *tex = new FImageTexture(image);
tex->SetUseType(ETextureType::FontChar); auto gtex = MakeGameTexture(tex, nullptr, ETextureType::FontChar);
tex->bMultiPatch = true; gtex->SetWorldPanning(true);
tex->Width = width; gtex->SetOffsets(0, 0, 0);
tex->Height = height; gtex->SetOffsets(1, 0, 0);
tex->_LeftOffset[0] = gtex->SetScale((float)Scale.X, (float)Scale.Y);
tex->_LeftOffset[1] = TexMan.AddGameTexture(gtex);
tex->_TopOffset[0] = charMap.Insert(int(position) + x + y * numtex_x, gtex);
tex->_TopOffset[1] = 0;
tex->Scale = Scale;
tex->bMasked = true;
tex->bTranslucent = -1;
tex->bWorldPanning = true;
tex->bNoDecals = false;
tex->SourceLump = -1; // We do not really care.
TexMan.AddTexture(tex);
charMap.Insert(int(position) + x + y * numtex_x, tex);
} }
} }
} }
@ -458,18 +438,15 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
auto lump = charMap.CheckKey(FirstChar + i); auto lump = charMap.CheckKey(FirstChar + i);
if (lump != nullptr) if (lump != nullptr)
{ {
FTexture *pic = *lump; auto pic = (*lump)->GetTexture();
Chars[i].OriginalPic = (*lump)->GetUseType() == ETextureType::FontChar? (*lump) : MakeGameTexture(pic, nullptr, ETextureType::FontChar);
auto b = pic->Get8BitPixels(false);
Chars[i].OriginalPic = new FImageTexture(pic->GetImage(), "");
Chars[i].OriginalPic->SetUseType(ETextureType::FontChar); Chars[i].OriginalPic->SetUseType(ETextureType::FontChar);
Chars[i].OriginalPic->CopySize(pic); Chars[i].OriginalPic->CopySize(*lump);
Chars[i].TranslatedPic = new FImageTexture(new FFontChar1(pic->GetImage()), ""); Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1(pic->GetImage())), nullptr, ETextureType::FontChar);
Chars[i].TranslatedPic->CopySize(pic); Chars[i].TranslatedPic->CopySize(*lump);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar);
TexMan.AddTexture(Chars[i].OriginalPic); if (Chars[i].OriginalPic != *lump) TexMan.AddGameTexture(Chars[i].OriginalPic);
TexMan.AddTexture(Chars[i].TranslatedPic); TexMan.AddGameTexture(Chars[i].TranslatedPic);
} }
Chars[i].XMove = width; Chars[i].XMove = width;
} }
@ -619,7 +596,7 @@ void FFont::RecordAllTextureColors(uint32_t *usedcolors)
{ {
if (Chars[i].TranslatedPic) if (Chars[i].TranslatedPic)
{ {
FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetImage()); FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetTexture()->GetImage());
if (pic) if (pic)
{ {
// The remap must be temporarily reset here because this can be called on an initialized font. // The remap must be temporarily reset here because this can be called on an initialized font.
@ -982,7 +959,7 @@ int FFont::GetCharCode(int code, bool needpic) const
// //
//========================================================================== //==========================================================================
FTexture *FFont::GetChar (int code, int translation, int *const width, bool *redirected) const FGameTexture *FFont::GetChar (int code, int translation, int *const width, bool *redirected) const
{ {
code = GetCharCode(code, true); code = GetCharCode(code, true);
int xmove = SpaceWidth; int xmove = SpaceWidth;
@ -1006,12 +983,12 @@ FTexture *FFont::GetChar (int code, int translation, int *const width, bool *red
if (redirected) *redirected = redirect; if (redirected) *redirected = redirect;
if (redirect) if (redirect)
{ {
assert(Chars[code].OriginalPic->UseType == ETextureType::FontChar); assert(Chars[code].OriginalPic->GetUseType() == ETextureType::FontChar);
return Chars[code].OriginalPic; return Chars[code].OriginalPic;
} }
} }
if (redirected) *redirected = false; if (redirected) *redirected = false;
assert(Chars[code].TranslatedPic->UseType == ETextureType::FontChar); assert(Chars[code].TranslatedPic->GetUseType() == ETextureType::FontChar);
return Chars[code].TranslatedPic; return Chars[code].TranslatedPic;
} }
@ -1037,11 +1014,11 @@ int FFont::GetCharWidth (int code) const
double GetBottomAlignOffset(FFont *font, int c) double GetBottomAlignOffset(FFont *font, int c)
{ {
int w; int w;
FTexture *tex_zero = font->GetChar('0', CR_UNDEFINED, &w); auto tex_zero = font->GetChar('0', CR_UNDEFINED, &w);
FTexture *texc = font->GetChar(c, CR_UNDEFINED, &w); auto texc = font->GetChar(c, CR_UNDEFINED, &w);
double offset = 0; double offset = 0;
if (texc) offset += texc->GetDisplayTopOffsetDouble(); if (texc) offset += texc->GetDisplayTopOffset();
if (tex_zero) offset += -tex_zero->GetDisplayTopOffsetDouble() + tex_zero->GetDisplayHeightDouble(); if (tex_zero) offset += -tex_zero->GetDisplayTopOffset() + tex_zero->GetDisplayHeight();
return offset; return offset;
} }
@ -1200,7 +1177,7 @@ void FFont::LoadTranslations()
{ {
if (Chars[i].TranslatedPic) if (Chars[i].TranslatedPic)
{ {
FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetImage()); FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetTexture()->GetImage());
if (pic) if (pic)
{ {
pic->SetSourceRemap(nullptr); // Force the FFontChar1 to return the same pixels as the base texture pic->SetSourceRemap(nullptr); // Force the FFontChar1 to return the same pixels as the base texture
@ -1214,7 +1191,7 @@ void FFont::LoadTranslations()
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if(Chars[i].TranslatedPic) if(Chars[i].TranslatedPic)
static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetImage())->SetSourceRemap(PatchRemap); static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetTexture()->GetImage())->SetSourceRemap(PatchRemap);
} }
BuildTranslations (Luminosity.Data(), identity, &TranslationParms[TranslationType][0], ActiveColors, nullptr); BuildTranslations (Luminosity.Data(), identity, &TranslationParms[TranslationType][0], ActiveColors, nullptr);
@ -1290,7 +1267,7 @@ void FFont::FixXMoves()
} }
if (Chars[i].OriginalPic) if (Chars[i].OriginalPic)
{ {
int ofs = Chars[i].OriginalPic->GetDisplayTopOffset(); int ofs = (int)Chars[i].OriginalPic->GetDisplayTopOffset();
if (ofs > Displacement) Displacement = ofs; if (ofs > Displacement) Displacement = ofs;
} }
} }

View file

@ -245,6 +245,7 @@ public:
FHexFont (const char *fontname, int lump) FHexFont (const char *fontname, int lump)
: FFont(lump) : FFont(lump)
{ {
const int spacing = 9;
assert(lump >= 0); assert(lump >= 0);
FontName = fontname; FontName = fontname;
@ -258,8 +259,22 @@ public:
SpaceWidth = 9; SpaceWidth = 9;
GlobalKerning = 0; GlobalKerning = 0;
translateUntranslated = true; translateUntranslated = true;
LoadTranslations(); Chars.Resize(LastChar - FirstChar + 1);
for (int i = FirstChar; i <= LastChar; i++)
{
if (hexdata.glyphmap[i] > 0)
{
auto offset = hexdata.glyphmap[i];
int size = hexdata.glyphdata[offset] / 16;
Chars[i - FirstChar].TranslatedPic = MakeGameTexture(new FImageTexture(new FHexFontChar(&hexdata.glyphdata[offset + 1], size, size * 9, 16)), nullptr, ETextureType::FontChar);
Chars[i - FirstChar].OriginalPic = Chars[i - FirstChar].TranslatedPic;
Chars[i - FirstChar].XMove = size * spacing;
TexMan.AddGameTexture(Chars[i - FirstChar].TranslatedPic);
}
else Chars[i - FirstChar].XMove = spacing;
}
} }
//========================================================================== //==========================================================================
@ -270,7 +285,6 @@ public:
void LoadTranslations() void LoadTranslations()
{ {
const int spacing = 9;
double luminosity[256]; double luminosity[256];
memset (PatchRemap, 0, 256); memset (PatchRemap, 0, 256);
@ -282,21 +296,6 @@ public:
} }
ActiveColors = 18; ActiveColors = 18;
Chars.Resize(LastChar - FirstChar + 1);
for (int i = FirstChar; i <= LastChar; i++)
{
if (hexdata.glyphmap[i] > 0)
{
auto offset = hexdata.glyphmap[i];
int size = hexdata.glyphdata[offset] / 16;
Chars[i - FirstChar].TranslatedPic = new FImageTexture(new FHexFontChar (&hexdata.glyphdata[offset+1], size, size * 9, 16));
Chars[i - FirstChar].TranslatedPic->SetUseType(ETextureType::FontChar);
Chars[i - FirstChar].XMove = size * spacing;
TexMan.AddTexture(Chars[i - FirstChar].TranslatedPic);
}
else Chars[i - FirstChar].XMove = spacing;
}
BuildTranslations (luminosity, nullptr, &TranslationParms[1][0], ActiveColors, nullptr); BuildTranslations (luminosity, nullptr, &TranslationParms[1][0], ActiveColors, nullptr);
} }
@ -318,6 +317,7 @@ public:
FHexFont2(const char *fontname, int lump) FHexFont2(const char *fontname, int lump)
: FFont(lump) : FFont(lump)
{ {
const int spacing = 9;
assert(lump >= 0); assert(lump >= 0);
FontName = fontname; FontName = fontname;
@ -331,8 +331,21 @@ public:
SpaceWidth = 9; SpaceWidth = 9;
GlobalKerning = -1; GlobalKerning = -1;
translateUntranslated = true; translateUntranslated = true;
Chars.Resize(LastChar - FirstChar + 1);
for (int i = FirstChar; i <= LastChar; i++)
{
if (hexdata.glyphmap[i] > 0)
{
auto offset = hexdata.glyphmap[i];
int size = hexdata.glyphdata[offset] / 16;
Chars[i - FirstChar].TranslatedPic = MakeGameTexture(new FImageTexture(new FHexFontChar2(&hexdata.glyphdata[offset + 1], size, 2 + size * 8, 18)), nullptr, ETextureType::FontChar);
Chars[i - FirstChar].OriginalPic = Chars[i - FirstChar].TranslatedPic;
Chars[i - FirstChar].XMove = size * spacing;
TexMan.AddGameTexture(Chars[i - FirstChar].TranslatedPic);
}
else Chars[i - FirstChar].XMove = spacing;
LoadTranslations(); }
} }
//========================================================================== //==========================================================================
@ -343,7 +356,6 @@ public:
void LoadTranslations() override void LoadTranslations() override
{ {
const int spacing = 9;
double luminosity[256]; double luminosity[256];
memset(PatchRemap, 0, 256); memset(PatchRemap, 0, 256);
@ -355,21 +367,6 @@ public:
} }
ActiveColors = 18; ActiveColors = 18;
Chars.Resize(LastChar - FirstChar + 1);
for (int i = FirstChar; i <= LastChar; i++)
{
if (hexdata.glyphmap[i] > 0)
{
auto offset = hexdata.glyphmap[i];
int size = hexdata.glyphdata[offset] / 16;
Chars[i - FirstChar].TranslatedPic = new FImageTexture(new FHexFontChar2(&hexdata.glyphdata[offset + 1], size, 2 + size * 8, 18));
Chars[i - FirstChar].TranslatedPic->SetUseType(ETextureType::FontChar);
Chars[i - FirstChar].XMove = size * spacing;
TexMan.AddTexture(Chars[i - FirstChar].TranslatedPic);
}
else Chars[i - FirstChar].XMove = spacing;
}
BuildTranslations(luminosity, nullptr, &TranslationParms[0][0], ActiveColors, nullptr); BuildTranslations(luminosity, nullptr, &TranslationParms[0][0], ActiveColors, nullptr);
} }

View file

@ -167,15 +167,16 @@ FSingleLumpFont::FSingleLumpFont (const char *name, int lump) : FFont(lump)
void FSingleLumpFont::CreateFontFromPic (FTextureID picnum) void FSingleLumpFont::CreateFontFromPic (FTextureID picnum)
{ {
FTexture *pic = TexMan.GetTexture(picnum); auto pic = TexMan.GetGameTexture(picnum);
FontHeight = pic->GetDisplayHeight (); FontHeight = (int)pic->GetDisplayHeight ();
SpaceWidth = pic->GetDisplayWidth (); SpaceWidth = (int)pic->GetDisplayWidth ();
GlobalKerning = 0; GlobalKerning = 0;
FirstChar = LastChar = 'A'; FirstChar = LastChar = 'A';
Chars.Resize(1); Chars.Resize(1);
Chars[0].TranslatedPic = pic; Chars[0].TranslatedPic = pic;
Chars[0].OriginalPic = pic;
// Only one color range. Don't bother with the others. // Only one color range. Don't bother with the others.
ActiveColors = 0; ActiveColors = 0;
@ -222,7 +223,7 @@ void FSingleLumpFont::LoadTranslations()
for(unsigned int i = 0;i < count;++i) for(unsigned int i = 0;i < count;++i)
{ {
if(Chars[i].TranslatedPic) if(Chars[i].TranslatedPic)
static_cast<FFontChar2*>(Chars[i].TranslatedPic->GetImage())->SetSourceRemap(PatchRemap); static_cast<FFontChar2*>(Chars[i].TranslatedPic->GetTexture()->GetImage())->SetSourceRemap(PatchRemap);
} }
BuildTranslations (luminosity, useidentity ? identity : nullptr, ranges, ActiveColors, usepalette ? local_palette : nullptr); BuildTranslations (luminosity, useidentity ? identity : nullptr, ranges, ActiveColors, usepalette ? local_palette : nullptr);
@ -255,7 +256,6 @@ void FSingleLumpFont::LoadFON1 (int lump, const uint8_t *data)
LastChar = 255; // This is to allow LoadTranslations to function. The way this is all set up really needs to be changed. LastChar = 255; // This is to allow LoadTranslations to function. The way this is all set up really needs to be changed.
GlobalKerning = 0; GlobalKerning = 0;
translateUntranslated = true; translateUntranslated = true;
LoadTranslations();
LastChar = 0x2122; LastChar = 0x2122;
// Move the Windows-1252 characters to their proper place. // Move the Windows-1252 characters to their proper place.
@ -350,12 +350,13 @@ void FSingleLumpFont::LoadFON2 (int lump, const uint8_t *data)
if (destSize <= 0) if (destSize <= 0)
{ {
Chars[i].TranslatedPic = nullptr; Chars[i].TranslatedPic = nullptr;
Chars[i].OriginalPic = nullptr;
} }
else else
{ {
Chars[i].TranslatedPic = new FImageTexture(new FFontChar2 (lump, int(data_p - data), widths2[i], FontHeight)); Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar2 (lump, int(data_p - data), widths2[i], FontHeight)), nullptr, ETextureType::FontChar);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i].OriginalPic = Chars[i].TranslatedPic;
TexMan.AddTexture(Chars[i].TranslatedPic); TexMan.AddGameTexture(Chars[i].TranslatedPic);
do do
{ {
int8_t code = *data_p++; int8_t code = *data_p++;
@ -377,8 +378,6 @@ void FSingleLumpFont::LoadFON2 (int lump, const uint8_t *data)
I_Error ("Overflow decompressing char %d (%c) of %s", i, i, FontName.GetChars()); I_Error ("Overflow decompressing char %d (%c) of %s", i, i, FontName.GetChars());
} }
} }
LoadTranslations();
} }
//========================================================================== //==========================================================================
@ -483,15 +482,15 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data)
{ // Empty character: skip it. { // Empty character: skip it.
continue; continue;
} }
auto tex = new FImageTexture(new FFontChar2(lump, int(chardata + chari + 6 - data), auto tex = MakeGameTexture(new FImageTexture(new FFontChar2(lump, int(chardata + chari + 6 - data),
chardata[chari+1], // width chardata[chari+1], // width
chardata[chari+2], // height chardata[chari+2], // height
-(int8_t)chardata[chari+3], // x offset -(int8_t)chardata[chari+3], // x offset
-(int8_t)chardata[chari+4] // y offset -(int8_t)chardata[chari+4] // y offset
)); )), nullptr, ETextureType::FontChar);
tex->SetUseType(ETextureType::FontChar);
Chars[chardata[chari] - FirstChar].TranslatedPic = tex; Chars[chardata[chari] - FirstChar].TranslatedPic = tex;
TexMan.AddTexture(tex); Chars[chardata[chari] - FirstChar].OriginalPic = tex;
TexMan.AddGameTexture(tex);
} }
// If the font did not define a space character, determine a suitable space width now. // If the font did not define a space character, determine a suitable space width now.
@ -508,7 +507,6 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data)
} }
FixXMoves(); FixXMoves();
LoadTranslations();
} }
//========================================================================== //==========================================================================
@ -556,10 +554,10 @@ void FSingleLumpFont::CheckFON1Chars (double *luminosity)
if(!Chars[i].TranslatedPic) if(!Chars[i].TranslatedPic)
{ {
Chars[i].TranslatedPic = new FImageTexture(new FFontChar2 (Lump, int(data_p - data), SpaceWidth, FontHeight)); Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar2 (Lump, int(data_p - data), SpaceWidth, FontHeight)), nullptr, ETextureType::FontChar);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i].OriginalPic = Chars[i].TranslatedPic;
Chars[i].XMove = SpaceWidth; Chars[i].XMove = SpaceWidth;
TexMan.AddTexture(Chars[i].TranslatedPic); TexMan.AddGameTexture(Chars[i].TranslatedPic);
} }
// Advance to next char's data and count the used colors. // Advance to next char's data and count the used colors.

View file

@ -45,7 +45,7 @@ public:
FSinglePicFont(const char *picname); FSinglePicFont(const char *picname);
// FFont interface // FFont interface
FTexture *GetChar(int code, int translation, int *const width, bool *redirected = nullptr) const override; FGameTexture *GetChar(int code, int translation, int *const width, bool *redirected = nullptr) const override;
int GetCharWidth (int code) const; int GetCharWidth (int code) const;
protected: protected:
@ -72,11 +72,11 @@ FSinglePicFont::FSinglePicFont(const char *picname) :
I_FatalError ("%s is not a font or texture", picname); I_FatalError ("%s is not a font or texture", picname);
} }
FTexture *pic = TexMan.GetTexture(picnum); auto pic = TexMan.GetGameTexture(picnum);
FontName = picname; FontName = picname;
FontHeight = pic->GetDisplayHeight(); FontHeight = (int)pic->GetDisplayHeight();
SpaceWidth = pic->GetDisplayWidth(); SpaceWidth = (int)pic->GetDisplayWidth();
GlobalKerning = 0; GlobalKerning = 0;
FirstChar = LastChar = 'A'; FirstChar = LastChar = 'A';
ActiveColors = 0; ActiveColors = 0;
@ -94,13 +94,13 @@ FSinglePicFont::FSinglePicFont(const char *picname) :
// //
//========================================================================== //==========================================================================
FTexture *FSinglePicFont::GetChar (int code, int translation, int *const width, bool *redirected) const FGameTexture *FSinglePicFont::GetChar (int code, int translation, int *const width, bool *redirected) const
{ {
*width = SpaceWidth; *width = SpaceWidth;
if (redirected) *redirected = false; if (redirected) *redirected = false;
if (code == 'a' || code == 'A') if (code == 'a' || code == 'A')
{ {
return TexMan.GetPalettedTexture(PicNum, true); return TexMan.GetGameTexture(PicNum, true);
} }
else else
{ {

View file

@ -45,7 +45,7 @@
class FSpecialFont : public FFont class FSpecialFont : public FFont
{ {
public: public:
FSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate, int lump, bool donttranslate); FSpecialFont (const char *name, int first, int count, FGameTexture **lumplist, const bool *notranslate, int lump, bool donttranslate);
void LoadTranslations(); void LoadTranslations();
@ -60,13 +60,13 @@ protected:
// //
//========================================================================== //==========================================================================
FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate, int lump, bool donttranslate) FSpecialFont::FSpecialFont (const char *name, int first, int count, FGameTexture **lumplist, const bool *notranslate, int lump, bool donttranslate)
: FFont(lump) : FFont(lump)
{ {
int i; int i;
TArray<FTexture *> charlumps(count, true); TArray<FGameTexture *> charlumps(count, true);
int maxyoffs; int maxyoffs;
FTexture *pic; FGameTexture *pic;
memcpy(this->notranslate, notranslate, 256*sizeof(bool)); memcpy(this->notranslate, notranslate, 256*sizeof(bool));
@ -87,8 +87,8 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l
pic = charlumps[i] = lumplist[i]; pic = charlumps[i] = lumplist[i];
if (pic != nullptr) if (pic != nullptr)
{ {
int height = pic->GetDisplayHeight(); int height = (int)pic->GetDisplayHeight();
int yoffs = pic->GetDisplayTopOffset(); int yoffs = (int)pic->GetDisplayTopOffset();
if (yoffs > maxyoffs) if (yoffs > maxyoffs)
{ {
@ -104,20 +104,18 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l
if (charlumps[i] != nullptr) if (charlumps[i] != nullptr)
{ {
auto pic = charlumps[i]; auto pic = charlumps[i];
Chars[i].OriginalPic = new FImageTexture(pic->GetImage(), ""); Chars[i].OriginalPic = MakeGameTexture(pic->GetTexture(), nullptr, ETextureType::FontChar);
Chars[i].OriginalPic->SetUseType(ETextureType::FontChar);
Chars[i].OriginalPic->CopySize(pic); Chars[i].OriginalPic->CopySize(pic);
TexMan.AddTexture(Chars[i].OriginalPic); TexMan.AddGameTexture(Chars[i].OriginalPic);
if (!noTranslate) if (!noTranslate)
{ {
Chars[i].TranslatedPic = new FImageTexture(new FFontChar1 (charlumps[i]->GetImage()), ""); Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1 (charlumps[i]->GetTexture()->GetImage())), nullptr, ETextureType::FontChar);
Chars[i].TranslatedPic->CopySize(charlumps[i]); Chars[i].TranslatedPic->CopySize(charlumps[i]);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); TexMan.AddGameTexture(Chars[i].TranslatedPic);
TexMan.AddTexture(Chars[i].TranslatedPic);
} }
else Chars[i].TranslatedPic = Chars[i].OriginalPic; else Chars[i].TranslatedPic = Chars[i].OriginalPic;
Chars[i].XMove = Chars[i].TranslatedPic->GetDisplayWidth(); Chars[i].XMove = (int)Chars[i].TranslatedPic->GetDisplayWidth();
} }
else else
{ {
@ -142,10 +140,6 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l
{ {
ActiveColors = 0; ActiveColors = 0;
} }
else
{
LoadTranslations();
}
} }
//========================================================================== //==========================================================================
@ -167,7 +161,7 @@ void FSpecialFont::LoadTranslations()
{ {
if (Chars[i].TranslatedPic) if (Chars[i].TranslatedPic)
{ {
FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetImage()); FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetTexture()->GetImage());
if (pic) if (pic)
{ {
pic->SetSourceRemap(nullptr); // Force the FFontChar1 to return the same pixels as the base texture pic->SetSourceRemap(nullptr); // Force the FFontChar1 to return the same pixels as the base texture
@ -197,7 +191,7 @@ void FSpecialFont::LoadTranslations()
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
if(Chars[i].TranslatedPic) if(Chars[i].TranslatedPic)
static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetImage())->SetSourceRemap(PatchRemap); static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetTexture()->GetImage())->SetSourceRemap(PatchRemap);
} }
BuildTranslations(Luminosity.Data(), identity, &TranslationParms[0][0], TotalColors, nullptr, [=](FRemapTable* remap) BuildTranslations(Luminosity.Data(), identity, &TranslationParms[0][0], TotalColors, nullptr, [=](FRemapTable* remap)
@ -217,7 +211,7 @@ void FSpecialFont::LoadTranslations()
ActiveColors = TotalColors; ActiveColors = TotalColors;
} }
FFont *CreateSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate, int lump, bool donttranslate) FFont *CreateSpecialFont (const char *name, int first, int count, FGameTexture **lumplist, const bool *notranslate, int lump, bool donttranslate)
{ {
return new FSpecialFont(name, first, count, lumplist, notranslate, lump, donttranslate); return new FSpecialFont(name, first, count, lumplist, notranslate, lump, donttranslate);
} }

View file

@ -89,6 +89,7 @@ FFont* SmallFont, * SmallFont2, * BigFont, * BigUpper, * ConFont, * Intermission
FFont *FFont::FirstFont = nullptr; FFont *FFont::FirstFont = nullptr;
int NumTextColors; int NumTextColors;
static bool translationsLoaded;
// PRIVATE DATA DEFINITIONS ------------------------------------------------ // PRIVATE DATA DEFINITIONS ------------------------------------------------
@ -138,22 +139,27 @@ FFont *V_GetFont(const char *name, const char *fontlumpname)
head == MAKE_ID(0xE1,0xE6,0xD5,0x1A)) head == MAKE_ID(0xE1,0xE6,0xD5,0x1A))
{ {
FFont *CreateSingleLumpFont (const char *fontname, int lump); FFont *CreateSingleLumpFont (const char *fontname, int lump);
return CreateSingleLumpFont (name, lump); font = CreateSingleLumpFont (name, lump);
if (translationsLoaded) font->LoadTranslations();
return font;
} }
} }
FTextureID picnum = TexMan.CheckForTexture (name, ETextureType::Any); FTextureID picnum = TexMan.CheckForTexture (name, ETextureType::Any);
if (picnum.isValid()) if (picnum.isValid())
{ {
FTexture *tex = TexMan.GetTexture(picnum); auto tex = TexMan.GetGameTexture(picnum);
if (tex && tex->GetSourceLump() >= folderfile) if (tex && tex->GetSourceLump() >= folderfile)
{ {
FFont *CreateSinglePicFont(const char *name); FFont *CreateSinglePicFont(const char *name);
return CreateSinglePicFont (name); font = CreateSinglePicFont (name);
return font;
} }
} }
if (folderdata.Size() > 0) if (folderdata.Size() > 0)
{ {
return new FFont(name, nullptr, name, HU_FONTSTART, HU_FONTSIZE, 1, -1); font = new FFont(name, nullptr, name, HU_FONTSTART, HU_FONTSIZE, 1, -1);
if (translationsLoaded) font->LoadTranslations();
return font;
} }
} }
return font; return font;
@ -170,7 +176,7 @@ FFont *V_GetFont(const char *name, const char *fontlumpname)
void V_InitCustomFonts() void V_InitCustomFonts()
{ {
FScanner sc; FScanner sc;
FTexture *lumplist[256]; FGameTexture *lumplist[256];
bool notranslate[256]; bool notranslate[256];
bool donttranslate; bool donttranslate;
FString namebuffer, templatebuf; FString namebuffer, templatebuf;
@ -266,12 +272,12 @@ void V_InitCustomFonts()
else else
{ {
if (format == 1) goto wrong; if (format == 1) goto wrong;
FTexture **p = &lumplist[*(unsigned char*)sc.String]; FGameTexture **p = &lumplist[*(unsigned char*)sc.String];
sc.MustGetString(); sc.MustGetString();
FTextureID texid = TexMan.CheckForTexture(sc.String, ETextureType::MiscPatch); FTextureID texid = TexMan.CheckForTexture(sc.String, ETextureType::MiscPatch);
if (texid.Exists()) if (texid.Exists())
{ {
*p = TexMan.GetTexture(texid); *p = TexMan.GetGameTexture(texid);
} }
else if (fileSystem.GetFileContainer(sc.LumpNum) >= fileSystem.GetIwadNum()) else if (fileSystem.GetFileContainer(sc.LumpNum) >= fileSystem.GetIwadNum())
{ {
@ -307,7 +313,7 @@ void V_InitCustomFonts()
} }
if (count > 0) if (count > 0)
{ {
FFont *CreateSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate, int lump, bool donttranslate); FFont *CreateSpecialFont (const char *name, int first, int count, FGameTexture **lumplist, const bool *notranslate, int lump, bool donttranslate);
FFont *fnt = CreateSpecialFont (namebuffer, first, count, &lumplist[first], notranslate, llump, donttranslate); FFont *fnt = CreateSpecialFont (namebuffer, first, count, &lumplist[first], notranslate, llump, donttranslate);
fnt->SetCursor(cursor); fnt->SetCursor(cursor);
fnt->SetKerning(kerning); fnt->SetKerning(kerning);
@ -728,13 +734,6 @@ void V_InitFonts()
OriginalSmallFont = new FFont("OriginalSmallFont", "STCFN%.3d", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1, -1, false, true); OriginalSmallFont = new FFont("OriginalSmallFont", "STCFN%.3d", "defsmallfont", HU_FONTSTART, HU_FONTSIZE, HU_FONTSTART, -1, -1, false, true);
} }
if (SmallFont)
{
uint32_t colors[256] = {};
SmallFont->RecordAllTextureColors(colors);
if (OriginalSmallFont != nullptr) OriginalSmallFont->SetDefaultTranslation(colors);
NewSmallFont->SetDefaultTranslation(colors);
}
if (!(SmallFont2 = V_GetFont("SmallFont2"))) // Only used by Strife if (!(SmallFont2 = V_GetFont("SmallFont2"))) // Only used by Strife
{ {
@ -770,13 +769,6 @@ void V_InitFonts()
OriginalBigFont = new FFont("OriginalBigFont", nullptr, "bigfont", HU_FONTSTART, HU_FONTSIZE, 1, -1, -1, false, true); OriginalBigFont = new FFont("OriginalBigFont", nullptr, "bigfont", HU_FONTSTART, HU_FONTSIZE, 1, -1, -1, false, true);
} }
if (BigFont)
{
uint32_t colors[256] = {};
BigFont->RecordAllTextureColors(colors);
if (OriginalBigFont != nullptr) OriginalBigFont->SetDefaultTranslation(colors);
}
// let PWAD BIGFONTs override the stock BIGUPPER font. (This check needs to be made smarter.) // let PWAD BIGFONTs override the stock BIGUPPER font. (This check needs to be made smarter.)
if (BigUpper && BigFont->Type != FFont::Folder && BigUpper->Type == FFont::Folder) if (BigUpper && BigFont->Type != FFont::Folder && BigUpper->Type == FFont::Folder)
{ {
@ -828,6 +820,29 @@ void V_InitFonts()
AlternativeSmallFont = OriginalSmallFont; AlternativeSmallFont = OriginalSmallFont;
} }
void V_LoadTranslations()
{
for (auto font = FFont::FirstFont; font; font = font->Next)
{
if (!font->noTranslate) font->LoadTranslations();
else font->ActiveColors = 0;
}
if (BigFont)
{
uint32_t colors[256] = {};
BigFont->RecordAllTextureColors(colors);
if (OriginalBigFont != nullptr) OriginalBigFont->SetDefaultTranslation(colors);
}
if (SmallFont)
{
uint32_t colors[256] = {};
SmallFont->RecordAllTextureColors(colors);
if (OriginalSmallFont != nullptr) OriginalSmallFont->SetDefaultTranslation(colors);
NewSmallFont->SetDefaultTranslation(colors);
}
translationsLoaded = true;
}
void V_ClearFonts() void V_ClearFonts()
{ {
while (FFont::FirstFont != nullptr) while (FFont::FirstFont != nullptr)

View file

@ -38,8 +38,7 @@
#include "palentry.h" #include "palentry.h"
#include "name.h" #include "name.h"
class DCanvas; class FGameTexture;
class FTexture;
struct FRemapTable; struct FRemapTable;
enum EColorRange : int enum EColorRange : int
@ -77,10 +76,11 @@ enum EColorRange : int
extern int NumTextColors; extern int NumTextColors;
using GlyphSet = TMap<int, FTexture*>; using GlyphSet = TMap<int, FGameTexture*>;
class FFont class FFont
{ {
friend void V_LoadTranslations();
public: public:
enum EFontType enum EFontType
@ -97,7 +97,7 @@ public:
FFont (const char *fontname, const char *nametemplate, const char *filetemplate, int first, int count, int base, int fdlump, int spacewidth=-1, bool notranslate = false, bool iwadonly = false, bool doomtemplate = false, GlyphSet *baseGlpyphs = nullptr); FFont (const char *fontname, const char *nametemplate, const char *filetemplate, int first, int count, int base, int fdlump, int spacewidth=-1, bool notranslate = false, bool iwadonly = false, bool doomtemplate = false, GlyphSet *baseGlpyphs = nullptr);
virtual ~FFont (); virtual ~FFont ();
virtual FTexture *GetChar (int code, int translation, int *const width, bool *redirected = nullptr) const; virtual FGameTexture *GetChar (int code, int translation, int *const width, bool *redirected = nullptr) const;
virtual int GetCharWidth (int code) const; virtual int GetCharWidth (int code) const;
int GetColorTranslation (EColorRange range, PalEntry *color = nullptr) const; int GetColorTranslation (EColorRange range, PalEntry *color = nullptr) const;
int GetLump() const { return Lump; } int GetLump() const { return Lump; }
@ -155,18 +155,18 @@ protected:
int TranslationType = 0; int TranslationType = 0;
int Displacement = 0; int Displacement = 0;
char Cursor; char Cursor;
bool noTranslate; bool noTranslate = false;
bool translateUntranslated; bool translateUntranslated;
bool MixedCase = false; bool MixedCase = false;
bool forceremap = false; bool forceremap = false;
struct CharData struct CharData
{ {
FTexture *TranslatedPic = nullptr; // Texture for use with font translations. FGameTexture *TranslatedPic = nullptr; // Texture for use with font translations.
FTexture *OriginalPic = nullptr; // Texture for use with CR_UNTRANSLATED or font colorization. FGameTexture *OriginalPic = nullptr; // Texture for use with CR_UNTRANSLATED or font colorization.
int XMove = INT_MIN; int XMove = INT_MIN;
}; };
TArray<CharData> Chars; TArray<CharData> Chars;
int ActiveColors; int ActiveColors = -1;
TArray<int> Translations; TArray<int> Translations;
uint8_t PatchRemap[256]; uint8_t PatchRemap[256];
@ -192,5 +192,6 @@ EColorRange V_ParseFontColor (const uint8_t *&color_value, int normalcolor, int
FFont *V_GetFont(const char *fontname, const char *fontlumpname = nullptr); FFont *V_GetFont(const char *fontname, const char *fontlumpname = nullptr);
void V_InitFontColors(); void V_InitFontColors();
char* CleanseString(char* str); char* CleanseString(char* str);
void V_LoadTranslations();

View file

@ -0,0 +1,10 @@
#pragma once
enum EMenuState : int
{
MENU_Off, // Menu is closed
MENU_On, // Menu is opened
MENU_WaitKey, // Menu is opened and waiting for a key in the controls menu
MENU_OnNoPause, // Menu is opened but does not pause the game
};
extern EMenuState menuactive; // Menu overlayed?

236
src/common/models/model.cpp Normal file
View file

@ -0,0 +1,236 @@
//
//---------------------------------------------------------------------------
//
// Copyright(C) 2005-2016 Christoph Oelckers
// All rights reserved.
//
// 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 3 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, see http://www.gnu.org/licenses/
//
//--------------------------------------------------------------------------
//
/*
** gl_models.cpp
**
** General model handling code
**
**/
#include "filesystem.h"
#include "cmdlib.h"
#include "sc_man.h"
#include "m_crc32.h"
#include "printf.h"
#include "model_ue1.h"
#include "model_obj.h"
#include "model_md2.h"
#include "model_md3.h"
#include "model_kvx.h"
#include "i_time.h"
#include "voxels.h"
#include "texturemanager.h"
#include "modelrenderer.h"
TDeletingArray<FModel*> Models;
TArray<FSpriteModelFrame> SpriteModelFrames;
/////////////////////////////////////////////////////////////////////////////
void FlushModels()
{
for (int i = Models.Size() - 1; i >= 0; i--)
{
Models[i]->DestroyVertexBuffer();
}
}
/////////////////////////////////////////////////////////////////////////////
FModel::FModel()
{
for (int i = 0; i < NumModelRendererTypes; i++)
mVBuf[i] = nullptr;
}
FModel::~FModel()
{
DestroyVertexBuffer();
}
void FModel::DestroyVertexBuffer()
{
for (int i = 0; i < NumModelRendererTypes; i++)
{
delete mVBuf[i];
mVBuf[i] = nullptr;
}
}
//===========================================================================
//
// FindGFXFile
//
//===========================================================================
static int FindGFXFile(FString & fn)
{
int lump = fileSystem.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 = fileSystem.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);
const char * const texname = texlump < 0 ? fn : fileSystem.GetFileFullName(texlump);
return TexMan.CheckForTexture(texname, ETextureType::Any, FTextureManager::TEXMAN_TryAny);
}
//===========================================================================
//
// ModelFrameHash
//
//===========================================================================
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 (; s<se; s++)
{
hash = CRC1 (hash, *s, table);
}
return hash ^ 0xffffffff;
}
//===========================================================================
//
// FindModel
//
//===========================================================================
unsigned FindModel(const char * path, const char * modelfile)
{
FModel * model = nullptr;
FString fullname;
fullname.Format("%s%s", path, modelfile);
int lump = fileSystem.CheckNumForFullName(fullname);
if (lump<0)
{
Printf("FindModel: '%s' not found\n", fullname.GetChars());
return -1;
}
for(unsigned i = 0; i< Models.Size(); i++)
{
if (!Models[i]->mFileName.CompareNoCase(fullname)) return i;
}
int len = fileSystem.FileLength(lump);
FileData lumpd = fileSystem.ReadFile(lump);
char * buffer = (char*)lumpd.GetMem();
if ( (size_t)fullname.LastIndexOf("_d.3d") == fullname.Len()-5 )
{
FString anivfile = fullname.GetChars();
anivfile.Substitute("_d.3d","_a.3d");
if ( fileSystem.CheckNumForFullName(anivfile) > 0 )
{
model = new FUE1Model;
}
}
else if ( (size_t)fullname.LastIndexOf("_a.3d") == fullname.Len()-5 )
{
FString datafile = fullname.GetChars();
datafile.Substitute("_a.3d","_d.3d");
if ( fileSystem.CheckNumForFullName(datafile) > 0 )
{
model = new FUE1Model;
}
}
else if ( (size_t)fullname.LastIndexOf(".obj") == fullname.Len() - 4 )
{
model = new FOBJModel;
}
else 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);
}

83
src/common/models/model.h Normal file
View file

@ -0,0 +1,83 @@
#pragma once
#include <stdint.h>
#include "textureid.h"
#include "i_modelvertexbuffer.h"
class FModelRenderer;
class FGameTexture;
class IModelVertexBuffer;
class FModel;
struct FSpriteModelFrame;
FTextureID LoadSkin(const char* path, const char* fn);
void FlushModels();
extern TDeletingArray<FModel*> Models;
extern TArray<FSpriteModelFrame> SpriteModelFrames;
#define MAX_MODELS_PER_FRAME 4
#define MD3_MAX_SURFACES 32
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 void* type; // used for hashing, must point to something usable as identifier for the model's owner.
short sprite;
short frame;
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.
bool isVoxel;
};
enum ModelRendererType
{
GLModelRendererType,
SWModelRendererType,
PolyModelRendererType,
NumModelRendererTypes
};
class FModel
{
public:
FModel();
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(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation=0) = 0;
virtual void BuildVertexBuffer(FModelRenderer *renderer) = 0;
virtual void AddSkins(uint8_t *hitlist) = 0;
virtual float getAspectFactor(float vscale) { return 1.f; }
void SetVertexBuffer(int type, IModelVertexBuffer *buffer) { mVBuf[type] = buffer; }
IModelVertexBuffer *GetVertexBuffer(int type) const { return mVBuf[type]; }
void DestroyVertexBuffer();
const FSpriteModelFrame *curSpriteMDLFrame;
int curMDLIndex;
void PushSpriteMDLFrame(const FSpriteModelFrame *smf, int index) { curSpriteMDLFrame = smf; curMDLIndex = index; };
FString mFileName;
private:
IModelVertexBuffer *mVBuf[NumModelRendererTypes];
};
int ModelFrameHash(FSpriteModelFrame* smf);
unsigned FindModel(const char* path, const char* modelfile);

View file

@ -0,0 +1,69 @@
#pragma once
#include "model.h"
#include "i_modelvertexbuffer.h"
#include "tarray.h"
#include "xs_Float.h"
struct FVoxel;
struct kvxslab_t;
class FModelRenderer;
class FGameTexture;
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<FModelVertex, unsigned int, FVoxelVertexHash, FIndexInit> 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<FModelVertex> mVertices;
TArray<unsigned int> 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, uint8_t 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(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation=0);
virtual void AddSkins(uint8_t *hitlist);
FTextureID GetPaletteTexture() const { return mPalette; }
void BuildVertexBuffer(FModelRenderer *renderer);
float getAspectFactor(float vscale) override;
};

View file

@ -0,0 +1,137 @@
#pragma once
#include "model.h"
#define MD2_MAGIC 0x32504449
#define DMD_MAGIC 0x4D444D44
#define MAX_LODS 4
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(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation=0);
virtual void LoadGeometry();
virtual void AddSkins(uint8_t *hitlist);
void UnloadGeometry();
void BuildVertexBuffer(FModelRenderer *renderer);
};
// 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();
};

View file

@ -0,0 +1,75 @@
#pragma once
#include "model.h"
#define MD3_MAGIC 0x33504449
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
{
unsigned numVertices;
unsigned numTriangles;
unsigned numSkins;
TArray<FTextureID> Skins;
TArray<MD3Triangle> Tris;
TArray<MD3TexCoord> Texcoords;
TArray<MD3Vertex> Vertices;
unsigned int vindex = UINT_MAX; // contains numframes arrays of vertices
unsigned int iindex = UINT_MAX;
void UnloadGeometry()
{
Tris.Reset();
Vertices.Reset();
Texcoords.Reset();
}
};
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 numTags;
int mLumpNum;
TArray<MD3Frame> Frames;
TArray<MD3Surface> Surfaces;
public:
FMD3Model() = default;
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length);
virtual int FindFrame(const char * name);
virtual void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation=0);
void LoadGeometry();
void BuildVertexBuffer(FModelRenderer *renderer);
virtual void AddSkins(uint8_t *hitlist);
};

View file

@ -23,8 +23,10 @@
#ifndef __GL_MODELS_OBJ_H__ #ifndef __GL_MODELS_OBJ_H__
#define __GL_MODELS_OBJ_H__ #define __GL_MODELS_OBJ_H__
#include "models.h" #include "model.h"
#include "sc_man.h" #include "sc_man.h"
#include "tarray.h"
#include "vectors.h"
class FOBJModel : public FModel class FOBJModel : public FModel
{ {
@ -96,7 +98,7 @@ public:
~FOBJModel(); ~FOBJModel();
bool Load(const char* fn, int lumpnum, const char* buffer, int length) override; bool Load(const char* fn, int lumpnum, const char* buffer, int length) override;
int FindFrame(const char* name) override; int FindFrame(const char* name) override;
void RenderFrame(FModelRenderer* renderer, FTexture* skin, int frame, int frame2, double inter, int translation=0) override; void RenderFrame(FModelRenderer* renderer, FGameTexture* skin, int frame, int frame2, double inter, int translation=0) override;
void BuildVertexBuffer(FModelRenderer* renderer) override; void BuildVertexBuffer(FModelRenderer* renderer) override;
void AddSkins(uint8_t* hitlist) override; void AddSkins(uint8_t* hitlist) override;
}; };

View file

@ -1,6 +1,8 @@
#pragma once #pragma once
#include "models.h" #include <stdint.h>
#include "model.h"
#include "vectors.h"
class FUE1Model : public FModel class FUE1Model : public FModel
{ {
@ -24,7 +26,7 @@ public:
bool Load(const char * fn, int lumpnum, const char * buffer, int length) override; bool Load(const char * fn, int lumpnum, const char * buffer, int length) override;
int FindFrame(const char * name) override; int FindFrame(const char * name) override;
void RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation=0) override; void RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation=0) override;
void BuildVertexBuffer(FModelRenderer *renderer) override; void BuildVertexBuffer(FModelRenderer *renderer) override;
void AddSkins(uint8_t *hitlist) override; void AddSkins(uint8_t *hitlist) override;
void LoadGeometry(); void LoadGeometry();

View file

@ -0,0 +1,29 @@
#pragma once
#include "renderstyle.h"
#include "matrix.h"
#include "model.h"
class FModelRenderer
{
public:
virtual ~FModelRenderer() = default;
virtual ModelRendererType GetType() const = 0;
virtual void BeginDrawModel(FRenderStyle style, FSpriteModelFrame *smf, const VSMatrix &objectToWorldMatrix, bool mirrored) = 0;
virtual void EndDrawModel(FRenderStyle style, FSpriteModelFrame *smf) = 0;
virtual IModelVertexBuffer *CreateVertexBuffer(bool needindex, bool singleframe) = 0;
virtual VSMatrix GetViewToWorldMatrix() = 0;
virtual void BeginDrawHUDModel(FRenderStyle style, const VSMatrix &objectToWorldMatrix, bool mirrored) = 0;
virtual void EndDrawHUDModel(FRenderStyle style) = 0;
virtual void SetInterpolation(double interpolation) = 0;
virtual void SetMaterial(FGameTexture *skin, bool clampNoFilter, int translation) = 0;
virtual void DrawArrays(int start, int count) = 0;
virtual void DrawElements(int numIndices, size_t offset) = 0;
virtual void SetupFrame(FModel *model, unsigned int frame1, unsigned int frame2, unsigned int size) = 0;
};

View file

@ -27,13 +27,18 @@
**/ **/
#include "filesystem.h" #include "filesystem.h"
#include "r_data/models/models.h" #include "model_md2.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "modelrenderer.h"
#include "printf.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data #pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data
#endif #endif
enum { VX, VZ, VY };
#define NUMVERTEXNORMALS 162
static float avertexnormals[NUMVERTEXNORMALS][3] = { static float avertexnormals[NUMVERTEXNORMALS][3] = {
#include "tab_anorms.h" #include "tab_anorms.h"
}; };
@ -280,7 +285,7 @@ FDMDModel::~FDMDModel()
void FDMDModel::BuildVertexBuffer(FModelRenderer *renderer) void FDMDModel::BuildVertexBuffer(FModelRenderer *renderer)
{ {
if (!GetVertexBuffer(renderer)) if (!GetVertexBuffer(renderer->GetType()))
{ {
LoadGeometry(); LoadGeometry();
@ -288,7 +293,7 @@ void FDMDModel::BuildVertexBuffer(FModelRenderer *renderer)
unsigned int vindex = 0; unsigned int vindex = 0;
auto vbuf = renderer->CreateVertexBuffer(false, info.numFrames == 1); auto vbuf = renderer->CreateVertexBuffer(false, info.numFrames == 1);
SetVertexBuffer(renderer, vbuf); SetVertexBuffer(renderer->GetType(), vbuf);
FModelVertex *vertptr = vbuf->LockVertexBuffer(VertexBufferSize); FModelVertex *vertptr = vbuf->LockVertexBuffer(VertexBufferSize);
@ -358,20 +363,20 @@ int FDMDModel::FindFrame(const char * name)
// //
//=========================================================================== //===========================================================================
void FDMDModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frameno, int frameno2, double inter, int translation) void FDMDModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, int translation)
{ {
if (frameno >= info.numFrames || frameno2 >= info.numFrames) return; if (frameno >= info.numFrames || frameno2 >= info.numFrames) return;
if (!skin) if (!skin)
{ {
if (info.numSkins == 0 || !skins[0].isValid()) return; if (info.numSkins == 0 || !skins[0].isValid()) return;
skin = TexMan.GetTexture(skins[0], true); skin = TexMan.GetGameTexture(skins[0], true);
if (!skin) return; if (!skin) return;
} }
renderer->SetInterpolation(inter); renderer->SetInterpolation(inter);
renderer->SetMaterial(skin, false, translation); renderer->SetMaterial(skin, false, translation);
GetVertexBuffer(renderer)->SetupFrame(renderer, frames[frameno].vindex, frames[frameno2].vindex, lodInfo[0].numTriangles * 3); renderer->SetupFrame(this, frames[frameno].vindex, frames[frameno2].vindex, lodInfo[0].numTriangles * 3);
renderer->DrawArrays(0, lodInfo[0].numTriangles * 3); renderer->DrawArrays(0, lodInfo[0].numTriangles * 3);
renderer->SetInterpolation(0.f); renderer->SetInterpolation(0.f);
} }

View file

@ -22,8 +22,9 @@
#include "filesystem.h" #include "filesystem.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "r_data/models/models.h" #include "model_md3.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "modelrenderer.h"
#define MAX_QPATH 64 #define MAX_QPATH 64
@ -239,7 +240,7 @@ void FMD3Model::LoadGeometry()
void FMD3Model::BuildVertexBuffer(FModelRenderer *renderer) void FMD3Model::BuildVertexBuffer(FModelRenderer *renderer)
{ {
if (!GetVertexBuffer(renderer)) if (!GetVertexBuffer(renderer->GetType()))
{ {
LoadGeometry(); LoadGeometry();
@ -254,7 +255,7 @@ void FMD3Model::BuildVertexBuffer(FModelRenderer *renderer)
} }
auto vbuf = renderer->CreateVertexBuffer(true, Frames.Size() == 1); auto vbuf = renderer->CreateVertexBuffer(true, Frames.Size() == 1);
SetVertexBuffer(renderer, vbuf); SetVertexBuffer(renderer->GetType(), vbuf);
FModelVertex *vertptr = vbuf->LockVertexBuffer(vbufsize); FModelVertex *vertptr = vbuf->LockVertexBuffer(vbufsize);
unsigned int *indxptr = vbuf->LockIndexBuffer(ibufsize); unsigned int *indxptr = vbuf->LockIndexBuffer(ibufsize);
@ -342,7 +343,7 @@ int FMD3Model::FindFrame(const char * name)
// //
//=========================================================================== //===========================================================================
void FMD3Model::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frameno, int frameno2, double inter, int translation) void FMD3Model::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, int translation)
{ {
if ((unsigned)frameno >= Frames.Size() || (unsigned)frameno2 >= Frames.Size()) return; if ((unsigned)frameno >= Frames.Size() || (unsigned)frameno2 >= Frames.Size()) return;
@ -353,16 +354,16 @@ void FMD3Model::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
// [BB] In case no skin is specified via MODELDEF, check if the MD3 has a skin for the current surface. // [BB] In case no skin is specified via MODELDEF, check if the MD3 has a skin for the current surface.
// Note: Each surface may have a different skin. // Note: Each surface may have a different skin.
FTexture *surfaceSkin = skin; FGameTexture *surfaceSkin = skin;
if (!surfaceSkin) if (!surfaceSkin)
{ {
if (curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid()) if (curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid())
{ {
surfaceSkin = TexMan.GetTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i], true); surfaceSkin = TexMan.GetGameTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i], true);
} }
else if (surf->numSkins > 0 && surf->Skins[0].isValid()) else if (surf->numSkins > 0 && surf->Skins[0].isValid())
{ {
surfaceSkin = TexMan.GetTexture(surf->Skins[0], true); surfaceSkin = TexMan.GetGameTexture(surf->Skins[0], true);
} }
if (!surfaceSkin) if (!surfaceSkin)
@ -372,7 +373,7 @@ void FMD3Model::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
} }
renderer->SetMaterial(surfaceSkin, false, translation); renderer->SetMaterial(surfaceSkin, false, translation);
GetVertexBuffer(renderer)->SetupFrame(renderer, surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices, surf->numVertices); renderer->SetupFrame(this, surf->vindex + frameno * surf->numVertices, surf->vindex + frameno2 * surf->numVertices, surf->numVertices);
renderer->DrawElements(surf->numTriangles * 3, surf->iindex * sizeof(unsigned int)); renderer->DrawElements(surf->numTriangles * 3, surf->iindex * sizeof(unsigned int));
} }
renderer->SetInterpolation(0.f); renderer->SetInterpolation(0.f);

View file

@ -20,8 +20,11 @@
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
#include "filesystem.h" #include "filesystem.h"
#include "r_data/models/models_obj.h" #include "model_obj.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "modelrenderer.h"
#include "printf.h"
#include "textureid.h"
/** /**
* Load an OBJ model * Load an OBJ model
@ -355,7 +358,7 @@ int FOBJModel::ResolveIndex(int origIndex, FaceElement el)
*/ */
void FOBJModel::BuildVertexBuffer(FModelRenderer *renderer) void FOBJModel::BuildVertexBuffer(FModelRenderer *renderer)
{ {
if (GetVertexBuffer(renderer)) if (GetVertexBuffer(renderer->GetType()))
{ {
return; return;
} }
@ -375,7 +378,7 @@ void FOBJModel::BuildVertexBuffer(FModelRenderer *renderer)
} }
auto vbuf = renderer->CreateVertexBuffer(false,true); auto vbuf = renderer->CreateVertexBuffer(false,true);
SetVertexBuffer(renderer, vbuf); SetVertexBuffer(renderer->GetType(), vbuf);
FModelVertex *vertptr = vbuf->LockVertexBuffer(vbufsize); FModelVertex *vertptr = vbuf->LockVertexBuffer(vbufsize);
@ -626,22 +629,22 @@ int FOBJModel::FindFrame(const char* name)
* @param inter Unused * @param inter Unused
* @param translation The translation for the skin * @param translation The translation for the skin
*/ */
void FOBJModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frameno, int frameno2, double inter, int translation) void FOBJModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frameno, int frameno2, double inter, int translation)
{ {
for (unsigned int i = 0; i < surfaces.Size(); i++) for (unsigned int i = 0; i < surfaces.Size(); i++)
{ {
OBJSurface *surf = &surfaces[i]; OBJSurface *surf = &surfaces[i];
FTexture *userSkin = skin; FGameTexture *userSkin = skin;
if (!userSkin) if (!userSkin)
{ {
if (i < MD3_MAX_SURFACES && curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid()) if (i < MD3_MAX_SURFACES && curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid())
{ {
userSkin = TexMan.GetTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i], true); userSkin = TexMan.GetGameTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i], true);
} }
else if (surf->skin.isValid()) else if (surf->skin.isValid())
{ {
userSkin = TexMan.GetTexture(surf->skin, true); userSkin = TexMan.GetGameTexture(surf->skin, true);
} }
} }
@ -652,7 +655,7 @@ void FOBJModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
} }
renderer->SetMaterial(userSkin, false, translation); renderer->SetMaterial(userSkin, false, translation);
GetVertexBuffer(renderer)->SetupFrame(renderer, surf->vbStart, surf->vbStart, surf->numTris * 3); renderer->SetupFrame(this, surf->vbStart, surf->vbStart, surf->numTris * 3);
renderer->DrawArrays(0, surf->numTris * 3); renderer->DrawArrays(0, surf->numTris * 3);
} }
} }

View file

@ -22,8 +22,9 @@
#include "filesystem.h" #include "filesystem.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "r_data/models/models_ue1.h" #include "model_ue1.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "modelrenderer.h"
float unpackuvert( uint32_t n, int c ) float unpackuvert( uint32_t n, int c )
{ {
@ -216,7 +217,7 @@ int FUE1Model::FindFrame( const char *name )
return -1; return -1;
} }
void FUE1Model::RenderFrame( FModelRenderer *renderer, FTexture *skin, int frame, int frame2, double inter, int translation ) void FUE1Model::RenderFrame( FModelRenderer *renderer, FGameTexture *skin, int frame, int frame2, double inter, int translation )
{ {
// the moment of magic // the moment of magic
if ( (frame >= numFrames) || (frame2 >= numFrames) ) return; if ( (frame >= numFrames) || (frame2 >= numFrames) ) return;
@ -232,11 +233,11 @@ void FUE1Model::RenderFrame( FModelRenderer *renderer, FTexture *skin, int frame
vofs += vsize; vofs += vsize;
continue; continue;
} }
FTexture *sskin = skin; FGameTexture *sskin = skin;
if ( !sskin ) if ( !sskin )
{ {
if ( curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum].isValid() ) if ( curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum].isValid() )
sskin = TexMan.GetTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum], true); sskin = TexMan.GetGameTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum], true);
if ( !sskin ) if ( !sskin )
{ {
vofs += vsize; vofs += vsize;
@ -246,7 +247,7 @@ void FUE1Model::RenderFrame( FModelRenderer *renderer, FTexture *skin, int frame
// TODO: Handle per-group render styles and other flags once functions for it are implemented // TODO: Handle per-group render styles and other flags once functions for it are implemented
// Future note: poly renderstyles should always be enforced unless the actor itself has a style other than Normal // Future note: poly renderstyles should always be enforced unless the actor itself has a style other than Normal
renderer->SetMaterial(sskin,false,translation); renderer->SetMaterial(sskin,false,translation);
GetVertexBuffer(renderer)->SetupFrame(renderer,vofs+frame*fsize,vofs+frame2*fsize,vsize); renderer->SetupFrame(this, vofs+frame*fsize,vofs+frame2*fsize,vsize);
renderer->DrawArrays(0,vsize); renderer->DrawArrays(0,vsize);
vofs += vsize; vofs += vsize;
} }
@ -255,7 +256,7 @@ void FUE1Model::RenderFrame( FModelRenderer *renderer, FTexture *skin, int frame
void FUE1Model::BuildVertexBuffer( FModelRenderer *renderer ) void FUE1Model::BuildVertexBuffer( FModelRenderer *renderer )
{ {
if (GetVertexBuffer(renderer)) if (GetVertexBuffer(renderer->GetType()))
return; return;
if ( !mDataLoaded ) if ( !mDataLoaded )
LoadGeometry(); LoadGeometry();
@ -264,7 +265,7 @@ void FUE1Model::BuildVertexBuffer( FModelRenderer *renderer )
vsize += groups[i].numPolys*3; vsize += groups[i].numPolys*3;
vsize *= numFrames; vsize *= numFrames;
auto vbuf = renderer->CreateVertexBuffer(false,numFrames==1); auto vbuf = renderer->CreateVertexBuffer(false,numFrames==1);
SetVertexBuffer(renderer, vbuf); SetVertexBuffer(renderer->GetType(), vbuf);
FModelVertex *vptr = vbuf->LockVertexBuffer(vsize); FModelVertex *vptr = vbuf->LockVertexBuffer(vsize);
int vidx = 0; int vidx = 0;
for ( int i=0; i<numFrames; i++ ) for ( int i=0; i<numFrames; i++ )

View file

@ -27,13 +27,16 @@
**/ **/
#include "filesystem.h" #include "filesystem.h"
#include "g_level.h"
#include "colormatcher.h" #include "colormatcher.h"
#include "bitmap.h" #include "bitmap.h"
#include "g_levellocals.h" #include "model_kvx.h"
#include "models.h"
#include "image.h" #include "image.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "modelrenderer.h"
#include "voxels.h"
#include "texturemanager.h"
#include "palettecontainer.h"
#include "textures.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data #pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data
@ -157,7 +160,7 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned)
{ {
mVoxel = voxel; mVoxel = voxel;
mOwningVoxel = owned; mOwningVoxel = owned;
mPalette = TexMan.AddTexture(new FImageTexture(new FVoxelTexture(voxel))); mPalette = TexMan.AddGameTexture(MakeGameTexture(new FImageTexture(new FVoxelTexture(voxel)), nullptr, ETextureType::Override));
} }
//=========================================================================== //===========================================================================
@ -319,12 +322,12 @@ void FVoxelModel::Initialize()
void FVoxelModel::BuildVertexBuffer(FModelRenderer *renderer) void FVoxelModel::BuildVertexBuffer(FModelRenderer *renderer)
{ {
if (!GetVertexBuffer(renderer)) if (!GetVertexBuffer(renderer->GetType()))
{ {
Initialize(); Initialize();
auto vbuf = renderer->CreateVertexBuffer(true, true); auto vbuf = renderer->CreateVertexBuffer(true, true);
SetVertexBuffer(renderer, vbuf); SetVertexBuffer(renderer->GetType(), vbuf);
FModelVertex *vertptr = vbuf->LockVertexBuffer(mVertices.Size()); FModelVertex *vertptr = vbuf->LockVertexBuffer(mVertices.Size());
unsigned int *indxptr = vbuf->LockIndexBuffer(mIndices.Size()); unsigned int *indxptr = vbuf->LockIndexBuffer(mIndices.Size());
@ -384,9 +387,9 @@ int FVoxelModel::FindFrame(const char * name)
// //
//=========================================================================== //===========================================================================
float FVoxelModel::getAspectFactor(FLevelLocals *Level) float FVoxelModel::getAspectFactor(float stretch)
{ {
return Level->info->pixelstretch; return stretch;
} }
//=========================================================================== //===========================================================================
@ -395,10 +398,10 @@ float FVoxelModel::getAspectFactor(FLevelLocals *Level)
// //
//=========================================================================== //===========================================================================
void FVoxelModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame, int frame2, double inter, int translation) void FVoxelModel::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int frame, int frame2, double inter, int translation)
{ {
renderer->SetMaterial(skin, true, translation); renderer->SetMaterial(skin, true, translation);
GetVertexBuffer(renderer)->SetupFrame(renderer, 0, 0, 0); renderer->SetupFrame(this, 0, 0, 0);
renderer->DrawElements(mNumIndices, 0); renderer->DrawElements(mNumIndices, 0);
} }

View file

@ -42,31 +42,14 @@
#include "filesystem.h" #include "filesystem.h"
#include "v_video.h" #include "v_video.h"
#include "sc_man.h" #include "sc_man.h"
#include "s_sound.h"
#include "sbar.h"
#include "g_level.h"
#include "r_data/sprites.h"
#include "voxels.h" #include "voxels.h"
#include "info.h" #include "printf.h"
void VOX_AddVoxel(int sprnum, int frame, FVoxelDef *def); void VOX_AddVoxel(int sprnum, int frame, FVoxelDef *def);
TDeletingArray<FVoxel *> Voxels; // used only to auto-delete voxels on exit. TDeletingArray<FVoxel *> Voxels; // used only to auto-delete voxels on exit.
TDeletingArray<FVoxelDef *> VoxelDefs; TDeletingArray<FVoxelDef *> VoxelDefs;
struct VoxelOptions
{
VoxelOptions()
: DroppedSpin(0), PlacedSpin(0), Scale(1.), AngleOffset(90.), OverridePalette(false)
{}
int DroppedSpin;
int PlacedSpin;
double Scale;
DAngle AngleOffset;
bool OverridePalette;
};
//========================================================================== //==========================================================================
// //
// GetVoxelRemap // GetVoxelRemap
@ -476,134 +459,6 @@ void FVoxel::RemovePalette()
} }
//==========================================================================
//
// VOX_ReadSpriteNames
//
// Reads a list of sprite names from a VOXELDEF lump.
//
//==========================================================================
static bool VOX_ReadSpriteNames(FScanner &sc, TArray<uint32_t> &vsprites)
{
vsprites.Clear();
while (sc.GetString())
{
// A sprite name list is terminated by an '=' character.
if (sc.String[0] == '=')
{
if (vsprites.Size() == 0)
{
sc.ScriptMessage("No sprites specified for voxel.\n");
}
return true;
}
if (sc.StringLen != 4 && sc.StringLen != 5)
{
sc.ScriptMessage("Sprite name \"%s\" is wrong size.\n", sc.String);
}
else if (sc.StringLen == 5 && (sc.String[4] = toupper(sc.String[4]), sc.String[4] < 'A' || sc.String[4] >= 'A' + MAX_SPRITE_FRAMES))
{
sc.ScriptMessage("Sprite frame %c is invalid.\n", sc.String[4]);
}
else
{
int frame = (sc.StringLen == 4) ? 255 : sc.String[4] - 'A';
int i = GetSpriteIndex(sc.String, false);
if (i != -1)
{
vsprites.Push((frame << 24) | i);
}
}
}
if (vsprites.Size() != 0)
{
sc.ScriptMessage("Unexpected end of file\n");
}
return false;
}
//==========================================================================
//
// VOX_ReadOptions
//
// Reads a list of options from a VOXELDEF lump, terminated with a '}'
// character. The leading '{' must already be consumed
//
//==========================================================================
static void VOX_ReadOptions(FScanner &sc, VoxelOptions &opts)
{
while (sc.GetToken())
{
if (sc.TokenType == '}')
{
return;
}
sc.TokenMustBe(TK_Identifier);
if (sc.Compare("scale"))
{
sc.MustGetToken('=');
sc.MustGetToken(TK_FloatConst);
opts.Scale = sc.Float;
}
else if (sc.Compare("spin"))
{
int mul = 1;
sc.MustGetToken('=');
if (sc.CheckToken('-')) mul = -1;
sc.MustGetToken(TK_IntConst);
opts.DroppedSpin = opts.PlacedSpin = sc.Number*mul;
}
else if (sc.Compare("placedspin"))
{
int mul = 1;
sc.MustGetToken('=');
if (sc.CheckToken('-')) mul = -1;
sc.MustGetToken(TK_IntConst);
opts.PlacedSpin = sc.Number*mul;
}
else if (sc.Compare("droppedspin"))
{
int mul = 1;
sc.MustGetToken('=');
if (sc.CheckToken('-')) mul = -1;
sc.MustGetToken(TK_IntConst);
opts.DroppedSpin = sc.Number*mul;
}
else if (sc.Compare("angleoffset"))
{
int mul = 1;
sc.MustGetToken('=');
if (sc.CheckToken('-')) mul = -1;
sc.MustGetAnyToken();
if (sc.TokenType == TK_IntConst)
{
sc.Float = sc.Number;
}
else
{
sc.TokenMustBe(TK_FloatConst);
}
opts.AngleOffset = mul * sc.Float + 90.;
}
else if (sc.Compare("overridepalette"))
{
opts.OverridePalette = true;
}
else
{
sc.ScriptMessage("Unknown voxel option '%s'\n", sc.String);
if (sc.CheckToken('='))
{
sc.MustGetAnyToken();
}
}
}
sc.ScriptMessage("Unterminated voxel option block\n");
}
//========================================================================== //==========================================================================
// //
// VOX_GetVoxel // VOX_GetVoxel
@ -613,7 +468,7 @@ static void VOX_ReadOptions(FScanner &sc, VoxelOptions &opts)
// //
//========================================================================== //==========================================================================
static FVoxel *VOX_GetVoxel(int lumpnum) FVoxel* VOX_GetVoxel(int lumpnum)
{ {
// Is this voxel already loaded? If so, return it. // Is this voxel already loaded? If so, return it.
for (unsigned i = 0; i < Voxels.Size(); ++i) for (unsigned i = 0; i < Voxels.Size(); ++i)
@ -623,7 +478,7 @@ static FVoxel *VOX_GetVoxel(int lumpnum)
return Voxels[i]; return Voxels[i];
} }
} }
FVoxel *vox = R_LoadKVX(lumpnum); FVoxel* vox = R_LoadKVX(lumpnum);
if (vox != NULL) if (vox != NULL)
{ {
Voxels.Push(vox); Voxels.Push(vox);
@ -631,83 +486,4 @@ static FVoxel *VOX_GetVoxel(int lumpnum)
return vox; return vox;
} }
//==========================================================================
//
// R_InitVoxels
//
// Process VOXELDEF lumps for defining voxel options that cannot be
// condensed neatly into a sprite name format.
//
//==========================================================================
void R_InitVoxels()
{
int lump, lastlump = 0;
while ((lump = fileSystem.FindLump("VOXELDEF", &lastlump)) != -1)
{
FScanner sc(lump);
TArray<uint32_t> vsprites;
while (VOX_ReadSpriteNames(sc, vsprites))
{
FVoxel *voxeldata = NULL;
int voxelfile;
VoxelOptions opts;
sc.SetCMode(true);
sc.MustGetToken(TK_StringConst);
voxelfile = fileSystem.CheckNumForFullName(sc.String, true, ns_voxels);
if (voxelfile < 0)
{
sc.ScriptMessage("Voxel \"%s\" not found.\n", sc.String);
}
else
{
voxeldata = VOX_GetVoxel(voxelfile);
if (voxeldata == NULL)
{
sc.ScriptMessage("\"%s\" is not a valid voxel file.\n", sc.String);
}
}
if (sc.CheckToken('{'))
{
VOX_ReadOptions(sc, opts);
}
sc.SetCMode(false);
if (voxeldata != NULL && vsprites.Size() != 0)
{
if (opts.OverridePalette)
{
voxeldata->RemovePalette();
}
FVoxelDef *def = new FVoxelDef;
def->Voxel = voxeldata;
def->Scale = opts.Scale;
def->DroppedSpin = opts.DroppedSpin;
def->PlacedSpin = opts.PlacedSpin;
def->AngleOffset = opts.AngleOffset;
VoxelDefs.Push(def);
for (unsigned i = 0; i < vsprites.Size(); ++i)
{
int sprnum = int(vsprites[i] & 0xFFFFFF);
int frame = int(vsprites[i] >> 24);
if (frame == 255)
{ // Apply voxel to all frames.
for (int j = MAX_SPRITE_FRAMES - 1; j >= 0; --j)
{
VOX_AddVoxel(sprnum, j, def);
}
}
else
{ // Apply voxel to only one frame.
VOX_AddVoxel(sprnum, frame, def);
}
}
}
}
}
}

View file

@ -1,8 +1,7 @@
#ifndef __RES_VOXEL_H #ifndef __RES_VOXEL_H
#define __RES_VOXEL_H #define __RES_VOXEL_H
#include "doomdef.h" #include <stdint.h>
// [RH] Voxels from Build // [RH] Voxels from Build
#define MAXVOXMIPS 5 #define MAXVOXMIPS 5
@ -76,8 +75,9 @@ struct FVoxelDef
extern TDeletingArray<FVoxel *> Voxels; // used only to auto-delete voxels on exit. extern TDeletingArray<FVoxel *> Voxels; // used only to auto-delete voxels on exit.
extern TDeletingArray<FVoxelDef *> VoxelDefs; extern TDeletingArray<FVoxelDef *> VoxelDefs;
FVoxel* VOX_GetVoxel(int lumpnum);
FVoxel *R_LoadKVX(int lumpnum); FVoxel *R_LoadKVX(int lumpnum);
FVoxelDef *R_LoadVoxelDef(int lumpnum, int spin); FVoxelDef *R_LoadVoxelDef(int lumpnum, int spin);
void R_InitVoxels();
#endif #endif

View file

@ -110,7 +110,7 @@ enum EInPlace { EC_InPlace };
#define DECLARE_ABSTRACT_CLASS(cls,parent) \ #define DECLARE_ABSTRACT_CLASS(cls,parent) \
public: \ public: \
virtual PClass *StaticType() const; \ PClass *StaticType() const override; \
static ClassReg RegistrationInfo, * const RegistrationInfoPtr; \ static ClassReg RegistrationInfo, * const RegistrationInfoPtr; \
typedef parent Super; \ typedef parent Super; \
private: \ private: \

View file

@ -35,20 +35,18 @@
#import <Carbon/Carbon.h> #import <Carbon/Carbon.h>
#include "c_buttons.h"
#include "c_console.h" #include "c_console.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "d_event.h" #include "d_event.h"
#include "c_buttons.h"
#include "d_gui.h" #include "d_gui.h"
#include "dikeys.h" #include "dikeys.h"
#include "doomdef.h"
#include "doomstat.h"
#include "v_video.h" #include "v_video.h"
#include "events.h"
#include "g_game.h"
#include "g_levellocals.h"
#include "i_interface.h" #include "i_interface.h"
#include "menustate.h"
#include "engineerrors.h"
#include "keydef.h"
EXTERN_CVAR(Int, m_use_mouse) EXTERN_CVAR(Int, m_use_mouse)
@ -61,7 +59,7 @@ CVAR(Bool, k_allowfullscreentoggle, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
extern int paused, chatmodeon; extern int paused, chatmodeon;
extern constate_e ConsoleState; extern constate_e ConsoleState;
extern bool ToggleFullscreen;
bool GUICapture; bool GUICapture;
@ -77,22 +75,17 @@ size_t s_skipMouseMoves;
void CheckGUICapture() void CheckGUICapture()
{ {
bool wantCapture = (MENU_Off == menuactive) bool wantCapt = sysCallbacks && sysCallbacks->WantGuiCapture && sysCallbacks->WantGuiCapture();
? (c_down == ConsoleState || c_falling == ConsoleState || chatmodeon)
: (MENU_On == menuactive || MENU_OnNoPause == menuactive);
// [ZZ] check active event handlers that want the UI processing if (wantCapt != GUICapture)
if (!wantCapture && primaryLevel->localEventManager->CheckUiProcessors())
{ {
wantCapture = true; GUICapture = wantCapt;
if (wantCapt)
{
buttonMap.ResetButtonStates();
}
} }
if (wantCapture != GUICapture)
{
GUICapture = wantCapture;
buttonMap.ResetButtonStates();
}
} }
void SetCursorPosition(const NSPoint position) void SetCursorPosition(const NSPoint position)
@ -160,7 +153,7 @@ void CheckNativeMouse()
{ {
bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame(); bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame();
wantNative = (!m_use_mouse || MENU_WaitKey != menuactive) wantNative = (!m_use_mouse || MENU_WaitKey != menuactive)
&& (!captureModeInGame || GUICapture || paused || demoplayback); && (!captureModeInGame || GUICapture);
} }
} }
else else
@ -170,7 +163,7 @@ void CheckNativeMouse()
&& (MENU_On == menuactive || MENU_OnNoPause == menuactive); && (MENU_On == menuactive || MENU_OnNoPause == menuactive);
} }
if (!wantNative && primaryLevel->localEventManager->CheckRequireMouse()) if (!wantNative && sysCallbacks && sysCallbacks->WantNativeMouse && sysCallbacks->WantNativeMouse())
wantNative = true; wantNative = true;
I_SetNativeMouse(wantNative); I_SetNativeMouse(wantNative);

View file

@ -36,12 +36,13 @@
#include <IOKit/hid/IOHIDLib.h> #include <IOKit/hid/IOHIDLib.h>
#include "d_event.h" #include "d_event.h"
#include "doomdef.h"
#include "i_system.h" #include "i_system.h"
#include "m_argv.h" #include "m_argv.h"
#include "m_joy.h" #include "m_joy.h"
#include "templates.h" #include "templates.h"
#include "v_text.h" #include "v_text.h"
#include "printf.h"
#include "keydef.h"
EXTERN_CVAR(Bool, joy_axespolling) EXTERN_CVAR(Bool, joy_axespolling)

View file

@ -32,20 +32,20 @@
*/ */
#include "i_common.h" #include "i_common.h"
#include "s_sound.h" #include "s_soundinternal.h"
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include "c_console.h" #include "c_console.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "d_main.h"
#include "i_system.h" #include "i_system.h"
#include "m_argv.h" #include "m_argv.h"
#include "st_console.h" #include "st_console.h"
#include "version.h" #include "version.h"
#include "engineerrors.h" #include "printf.h"
#include "s_music.h" #include "s_music.h"
#include "engineerrors.h"
#define ZD_UNUSED(VARIABLE) ((void)(VARIABLE)) #define ZD_UNUSED(VARIABLE) ((void)(VARIABLE))
@ -59,7 +59,7 @@ EXTERN_CVAR(Int, vid_defwidth )
EXTERN_CVAR(Int, vid_defheight) EXTERN_CVAR(Int, vid_defheight)
EXTERN_CVAR(Bool, vid_vsync ) EXTERN_CVAR(Bool, vid_vsync )
int GameMain();
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -169,7 +169,7 @@ int DoMain(int argc, char** argv)
progdir = [[exePath stringByDeletingLastPathComponent] UTF8String]; progdir = [[exePath stringByDeletingLastPathComponent] UTF8String];
progdir += "/"; progdir += "/";
auto ret = D_DoomMain(); auto ret = GameMain();
FConsoleWindow::DeleteInstance(); FConsoleWindow::DeleteInstance();
return ret; return ret;
} }

View file

@ -33,6 +33,7 @@
#include "i_common.h" #include "i_common.h"
#include <fnmatch.h>
#include <sys/sysctl.h> #include <sys/sysctl.h>
#include "i_system.h" #include "i_system.h"

View file

@ -44,21 +44,24 @@
#include "v_video.h" #include "v_video.h"
#include "bitmap.h" #include "bitmap.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "doomstat.h"
#include "hardware.h" #include "hardware.h"
#include "i_system.h" #include "i_system.h"
#include "m_argv.h" #include "m_argv.h"
#include "m_png.h" #include "m_png.h"
#include "swrenderer/r_swrenderer.h"
#include "st_console.h" #include "st_console.h"
#include "v_text.h" #include "v_text.h"
#include "version.h" #include "version.h"
#include "engineerrors.h" #include "printf.h"
#include "gl/system/gl_framebuffer.h" #include "gl_framebuffer.h"
#ifdef HAVE_VULKAN
#include "vulkan/system/vk_framebuffer.h" #include "vulkan/system/vk_framebuffer.h"
#include "rendering/polyrenderer/backend/poly_framebuffer.h" #endif
#ifdef HAVE_SOFTPOLY
#include "poly_framebuffer.h"
#endif
extern bool ToggleFullscreen;
@implementation NSWindow(ExitAppOnClose) @implementation NSWindow(ExitAppOnClose)
@ -441,6 +444,8 @@ public:
} }
else else
#endif #endif
#ifdef HAVE_SOFTPOLY
if (vid_preferbackend == 2) if (vid_preferbackend == 2)
{ {
SetupOpenGLView(ms_window, OpenGLProfile::Legacy); SetupOpenGLView(ms_window, OpenGLProfile::Legacy);
@ -448,6 +453,7 @@ public:
fb = new PolyFrameBuffer(nullptr, vid_fullscreen); fb = new PolyFrameBuffer(nullptr, vid_fullscreen);
} }
else else
#endif
{ {
SetupOpenGLView(ms_window, OpenGLProfile::Core); SetupOpenGLView(ms_window, OpenGLProfile::Core);
} }
@ -461,6 +467,7 @@ public:
fb->SetMode(vid_fullscreen, vid_hidpi); fb->SetMode(vid_fullscreen, vid_hidpi);
fb->SetSize(fb->GetClientWidth(), fb->GetClientHeight()); fb->SetSize(fb->GetClientWidth(), fb->GetClientHeight());
#ifdef HAVE_VULKAN
// This lame hack is a temporary workaround for strange performance issues // This lame hack is a temporary workaround for strange performance issues
// with fullscreen window and Core Animation's Metal layer // with fullscreen window and Core Animation's Metal layer
// It is somehow related to initial window level and flags // It is somehow related to initial window level and flags
@ -470,6 +477,7 @@ public:
fb->SetMode(false, vid_hidpi); fb->SetMode(false, vid_hidpi);
fb->SetMode(true, vid_hidpi); fb->SetMode(true, vid_hidpi);
} }
#endif
return fb; return fb;
} }
@ -480,8 +488,9 @@ public:
} }
private: private:
#ifdef HAVE_VULKAN
VulkanDevice *m_vulkanDevice = nullptr; VulkanDevice *m_vulkanDevice = nullptr;
#endif
static CocoaWindow* ms_window; static CocoaWindow* ms_window;
static bool ms_isVulkanEnabled; static bool ms_isVulkanEnabled;
@ -798,7 +807,7 @@ CUSTOM_CVAR(Bool, vid_hidpi, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINI
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
bool I_SetCursor(FTexture *cursorpic) bool I_SetCursor(FGameTexture *cursorpic)
{ {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSCursor* cursor = nil; NSCursor* cursor = nil;
@ -807,7 +816,7 @@ bool I_SetCursor(FTexture *cursorpic)
{ {
// Create bitmap image representation // Create bitmap image representation
auto sbuffer = cursorpic->CreateTexBuffer(0); auto sbuffer = cursorpic->GetTexture()->CreateTexBuffer(0);
const NSInteger imageWidth = sbuffer.mWidth; const NSInteger imageWidth = sbuffer.mWidth;
const NSInteger imageHeight = sbuffer.mHeight; const NSInteger imageHeight = sbuffer.mHeight;

View file

@ -32,12 +32,13 @@
*/ */
#include "i_common.h" #include "i_common.h"
#include "startupinfo.h"
#include "d_main.h"
#include "st_console.h" #include "st_console.h"
#include "v_text.h" #include "v_text.h"
#include "version.h" #include "version.h"
#include "palentry.h"
#include "v_video.h"
#include "v_font.h"
static NSColor* RGB(const uint8_t red, const uint8_t green, const uint8_t blue) static NSColor* RGB(const uint8_t red, const uint8_t green, const uint8_t blue)
{ {
@ -339,17 +340,17 @@ void FConsoleWindow::SetTitleText()
// It's used in graphical startup screen, with Hexen style in particular // It's used in graphical startup screen, with Hexen style in particular
// Native OS X backend doesn't implement this yet // Native OS X backend doesn't implement this yet
if (DoomStartupInfo.FgColor == DoomStartupInfo.BkColor) if (GameStartupInfo.FgColor == GameStartupInfo.BkColor)
{ {
DoomStartupInfo.FgColor = ~DoomStartupInfo.FgColor; GameStartupInfo.FgColor = ~GameStartupInfo.FgColor;
} }
NSTextField* titleText = [[NSTextField alloc] initWithFrame:titleTextRect]; NSTextField* titleText = [[NSTextField alloc] initWithFrame:titleTextRect];
[titleText setStringValue:[NSString stringWithCString:DoomStartupInfo.Name [titleText setStringValue:[NSString stringWithCString:GameStartupInfo.Name.GetChars()
encoding:NSISOLatin1StringEncoding]]; encoding:NSISOLatin1StringEncoding]];
[titleText setAlignment:NSCenterTextAlignment]; [titleText setAlignment:NSCenterTextAlignment];
[titleText setTextColor:RGB(DoomStartupInfo.FgColor)]; [titleText setTextColor:RGB(GameStartupInfo.FgColor)];
[titleText setBackgroundColor:RGB(DoomStartupInfo.BkColor)]; [titleText setBackgroundColor:RGB(GameStartupInfo.BkColor)];
[titleText setFont:[NSFont fontWithName:@"Trebuchet MS Bold" size:18.0f]]; [titleText setFont:[NSFont fontWithName:@"Trebuchet MS Bold" size:18.0f]];
[titleText setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin]; [titleText setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin];
[titleText setSelectable:NO]; [titleText setSelectable:NO];

View file

@ -36,9 +36,9 @@
#import <Foundation/NSRunLoop.h> #import <Foundation/NSRunLoop.h>
#include "c_cvars.h" #include "c_cvars.h"
#include "doomtype.h"
#include "st_console.h" #include "st_console.h"
#include "st_start.h" #include "st_start.h"
#include "printf.h"
#include "engineerrors.h" #include "engineerrors.h"

View file

@ -0,0 +1,70 @@
#ifndef __I_SYSTEM__
#define __I_SYSTEM__
#include <dirent.h>
#include <ctype.h>
#if defined(__sun) || defined(__sun__) || defined(__SRV4) || defined(__srv4__)
#define __solaris__ 1
#endif
#include <thread>
#include <algorithm>
#include "tarray.h"
#include "zstring.h"
struct ticcmd_t;
struct WadStuff;
#ifndef SHARE_DIR
#define SHARE_DIR "/usr/local/share/"
#endif
void CalculateCPUSpeed(void);
// Return a seed value for the RNG.
unsigned int I_MakeRNGSeed();
void I_StartFrame (void);
void I_StartTic (void);
// Print a console string
void I_PrintStr (const char *str);
// Set the title string of the startup window
void I_SetIWADInfo ();
// Pick from multiple IWADs to use
int I_PickIWad (WadStuff *wads, int numwads, bool queryiwad, int defaultiwad);
// [RH] Checks the registry for Steam's install path, so we can scan its
// directories for IWADs if the user purchased any through Steam.
TArray<FString> I_GetSteamPath();
TArray<FString> I_GetGogPaths();
// The ini could not be saved at exit
bool I_WriteIniFailed ();
class FGameTexture;
bool I_SetCursor(FGameTexture *);
static inline char *strlwr(char *str)
{
char *ptr = str;
while(*ptr)
{
*ptr = tolower(*ptr);
++ptr;
}
return str;
}
inline int I_GetNumaNodeCount() { return 1; }
inline int I_GetNumaNodeThreadCount(int numaNode) { return std::max<int>(std::thread::hardware_concurrency(), 1); }
inline void I_SetThreadNumaNode(std::thread &thread, int numaNode) { }
#endif

View file

@ -0,0 +1,53 @@
/*
**---------------------------------------------------------------------------
** Copyright 2016 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include <fnmatch.h>
#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif // __APPLE__
#include "cmdlib.h"
#include "i_system.h"
#include "gameconfigfile.h"
#include "x86.h"
bool I_WriteIniFailed()
{
printf("The config file %s could not be saved:\n%s\n", GameConfig->GetPathName(), strerror(errno));
return false; // return true to retry
}
TArray<FString> I_GetGogPaths()
{
// GOG's Doom games are Windows only at the moment
return TArray<FString>();
}

View file

@ -36,9 +36,10 @@
#import <Foundation/NSFileManager.h> #import <Foundation/NSFileManager.h>
#include "cmdlib.h" #include "cmdlib.h"
#include "m_misc.h"
#include "version.h" // for GAMENAME #include "version.h" // for GAMENAME
#include "i_specialpaths.h"
FString M_GetMacAppSupportPath(const bool create);
static FString GetSpecialPath(const NSSearchPathDirectory kind, const BOOL create = YES, const NSSearchPathDomainMask domain = NSUserDomainMask) static FString GetSpecialPath(const NSSearchPathDirectory kind, const BOOL create = YES, const NSSearchPathDomainMask domain = NSUserDomainMask)
{ {
@ -199,7 +200,7 @@ FString M_GetScreenshotsPath()
{ {
path += "/" GAME_DIR "/Screenshots/"; path += "/" GAME_DIR "/Screenshots/";
} }
CreatePath(path);
return path; return path;
} }
@ -240,5 +241,45 @@ FString M_GetDocumentsPath()
path += "/" GAME_DIR "/"; path += "/" GAME_DIR "/";
} }
CreatePath(path);
return path;
}
//===========================================================================
//
// M_GetDemoPath macOS
//
// Returns the path to the default demo directory.
//
//===========================================================================
FString M_GetDemoPath()
{
FString path = GetSpecialPath(NSDocumentDirectory);
if (path.IsNotEmpty())
{
path += "/" GAME_DIR "/Demos/";
}
return path;
}
//===========================================================================
//
// M_NormalizedPath
//
// Normalizes the given path and returns the result.
//
//===========================================================================
FString M_GetNormalizedPath(const char* path)
{
NSString *str = [NSString stringWithUTF8String:path];
NSString *out;
if ([str completePathIntoString:&out caseSensitive:NO matchesIntoArray:nil filterTypes:nil])
{
return out.UTF8String;
}
return path; return path;
} }

View file

@ -34,13 +34,12 @@
*/ */
#include "cmdlib.h" #include "cmdlib.h"
#include "d_main.h"
#include "version.h" #include "version.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "m_argv.h" #include "m_argv.h"
#include "m_misc.h"
#include "gameconfigfile.h" #include "gameconfigfile.h"
#include "engineerrors.h" #include "engineerrors.h"
#include "i_interface.h"
#include <Cocoa/Cocoa.h> #include <Cocoa/Cocoa.h>
#include <wordexp.h> #include <wordexp.h>
@ -385,8 +384,10 @@ static void RestartWithParameters(const WadStuff& wad, NSString* parameters)
defaultiwad = wad.Name; defaultiwad = wad.Name;
GameConfig->DoGameSetup("Doom"); GameConfig->ArchiveGlobalData();
M_SaveDefaults(NULL); GameConfig->WriteConfigFile();
delete GameConfig;
GameConfig = nullptr;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

View file

@ -11,7 +11,7 @@
#ifndef PR_SET_PTRACER #ifndef PR_SET_PTRACER
#define PR_SET_PTRACER 0x59616d61 #define PR_SET_PTRACER 0x59616d61
#endif #endif
#elif defined (__APPLE__) || defined (__FreeBSD__) || defined(__OpenBSD__) #elif defined (__APPLE__) || defined (BSD)
#include <signal.h> #include <signal.h>
#endif #endif

View file

@ -39,10 +39,9 @@
#include "hardware.h" #include "hardware.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "v_text.h" #include "v_text.h"
#include "doomstat.h"
#include "m_argv.h" #include "m_argv.h"
#include "engineerrors.h" #include "c_console.h"
#include "swrenderer/r_swrenderer.h" #include "printf.h"
IVideo *Video; IVideo *Video;

View file

@ -36,17 +36,16 @@
#include <SDL.h> #include <SDL.h>
#include "bitmap.h" #include "bitmap.h"
#include "v_palette.h"
#include "textures.h" #include "textures.h"
bool I_SetCursor(FTexture *cursorpic) bool I_SetCursor(FGameTexture *cursorpic)
{ {
static SDL_Cursor *cursor; static SDL_Cursor *cursor;
static SDL_Surface *cursorSurface; static SDL_Surface *cursorSurface;
if (cursorpic != NULL && cursorpic->isValid()) if (cursorpic != NULL && cursorpic->isValid())
{ {
auto src = cursorpic->GetBgraBitmap(nullptr); auto src = cursorpic->GetTexture()->GetBgraBitmap(nullptr);
// Must be no larger than 32x32. // Must be no larger than 32x32.
if (src.GetWidth() > 32 || src.GetHeight() > 32) if (src.GetWidth() > 32 || src.GetHeight() > 32)
{ {

View file

@ -31,23 +31,18 @@
** **
*/ */
#include <SDL.h> #include <SDL.h>
#include "doomtype.h"
#include "doomdef.h"
#include "doomstat.h"
#include "m_argv.h" #include "m_argv.h"
#include "v_video.h" #include "v_video.h"
#include "d_main.h"
#include "d_event.h" #include "d_event.h"
#include "d_gui.h" #include "d_gui.h"
#include "c_buttons.h" #include "c_buttons.h"
#include "c_console.h" #include "c_console.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "dikeys.h" #include "dikeys.h"
#include "events.h"
#include "g_game.h"
#include "g_levellocals.h"
#include "utf8.h" #include "utf8.h"
#include "keydef.h"
#include "i_interface.h"
#include "engineerrors.h" #include "engineerrors.h"
#include "i_interface.h" #include "i_interface.h"
@ -58,8 +53,6 @@ static void I_CheckNativeMouse ();
bool GUICapture; bool GUICapture;
static bool NativeMouse = true; static bool NativeMouse = true;
extern int paused;
CVAR (Bool, use_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (Bool, use_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (Bool, m_noprescale, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (Bool, m_noprescale, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR (Bool, m_filter, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR (Bool, m_filter, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
@ -174,25 +167,15 @@ static const TMap<SDL_Scancode, uint8_t> KeyScanToDIK(InitKeyScanMap());
static void I_CheckGUICapture () static void I_CheckGUICapture ()
{ {
bool wantCapt; bool wantCapt = sysCallbacks && sysCallbacks->WantGuiCapture && sysCallbacks->WantGuiCapture();
if (menuactive == MENU_Off)
{
wantCapt = ConsoleState == c_down || ConsoleState == c_falling || chatmodeon;
}
else
{
wantCapt = (menuactive == MENU_On || menuactive == MENU_OnNoPause);
}
// [ZZ] check active event handlers that want the UI processing
if (!wantCapt && primaryLevel->localEventManager->CheckUiProcessors())
wantCapt = true;
if (wantCapt != GUICapture) if (wantCapt != GUICapture)
{ {
GUICapture = wantCapt; GUICapture = wantCapt;
buttonMap.ResetButtonStates(); if (wantCapt)
{
buttonMap.ResetButtonStates();
}
} }
} }
@ -256,10 +239,12 @@ static void MouseRead ()
static void I_CheckNativeMouse () static void I_CheckNativeMouse ()
{ {
bool focus = SDL_GetKeyboardFocus() != NULL; bool focus = SDL_GetKeyboardFocus() != NULL;
bool fs = screen->IsFullscreen();
bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame(); bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame();
bool wantNative = !focus || (!use_mouse || GUICapture || paused || demoplayback || !captureModeInGame); bool wantNative = !focus || (!use_mouse || GUICapture || !captureModeInGame);
if (!wantNative && sysCallbacks && sysCallbacks->WantNativeMouse && sysCallbacks->WantNativeMouse())
wantNative = true;
if (wantNative != NativeMouse) if (wantNative != NativeMouse)
{ {

View file

@ -33,6 +33,7 @@
#include <SDL.h> #include <SDL.h>
#include "basics.h" #include "basics.h"
#include "cmdlib.h"
#include "templates.h" #include "templates.h"
#include "m_joy.h" #include "m_joy.h"
#include "keydef.h" #include "keydef.h"
@ -299,8 +300,10 @@ static SDLInputJoystickManager *JoystickManager;
void I_StartupJoysticks() void I_StartupJoysticks()
{ {
#ifndef NO_SDL_JOYSTICK
if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0) if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0)
JoystickManager = new SDLInputJoystickManager(); JoystickManager = new SDLInputJoystickManager();
#endif
} }
void I_ShutdownInput() void I_ShutdownInput()
{ {
@ -315,7 +318,8 @@ void I_GetJoysticks(TArray<IJoystickConfig *> &sticks)
{ {
sticks.Clear(); sticks.Clear();
JoystickManager->GetDevices(sticks); if (JoystickManager)
JoystickManager->GetDevices(sticks);
} }
void I_GetAxes(float axes[NUM_JOYAXIS]) void I_GetAxes(float axes[NUM_JOYAXIS])
@ -324,7 +328,7 @@ void I_GetAxes(float axes[NUM_JOYAXIS])
{ {
axes[i] = 0; axes[i] = 0;
} }
if (use_joystick) if (use_joystick && JoystickManager)
{ {
JoystickManager->AddAxes(axes); JoystickManager->AddAxes(axes);
} }
@ -332,7 +336,7 @@ void I_GetAxes(float axes[NUM_JOYAXIS])
void I_ProcessJoysticks() void I_ProcessJoysticks()
{ {
if (use_joystick) if (use_joystick && JoystickManager)
JoystickManager->ProcessInput(); JoystickManager->ProcessInput();
} }

View file

@ -43,19 +43,12 @@
#include "engineerrors.h" #include "engineerrors.h"
#include "m_argv.h" #include "m_argv.h"
#include "d_main.h"
#include "c_console.h" #include "c_console.h"
#include "version.h" #include "version.h"
#include "filesystem.h"
#include "g_level.h"
#include "g_levellocals.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "r_utility.h"
#include "doomstat.h"
#include "vm.h"
#include "engineerrors.h" #include "engineerrors.h"
#include "i_system.h" #include "i_system.h"
#include "g_game.h" #include "i_interface.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -74,6 +67,7 @@ void Linux_I_FatalError(const char* errortext);
#endif #endif
// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
int GameMain();
// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
@ -91,62 +85,10 @@ FArgs *Args;
static int DoomSpecificInfo (char *buffer, char *end) static int GetCrashInfo (char *buffer, char *end)
{ {
const char *arg; if (sysCallbacks && sysCallbacks->CrashInfo) sysCallbacks->CrashInfo(buffer, end - buffer, "\n");
int size = end-buffer-2; return strlen(buffer);
int i, p;
p = 0;
p += snprintf (buffer+p, size-p, GAMENAME" version %s (%s)\n", GetVersionString(), GetGitHash());
#ifdef __VERSION__
p += snprintf (buffer+p, size-p, "Compiler version: %s\n", __VERSION__);
#endif
// If Args is nullptr, then execution is at either
// * early stage of initialization, additional info contains only default values
// * late stage of shutdown, most likely main() was done, and accessing global variables is no longer safe
if (Args)
{
p += snprintf(buffer + p, size - p, "\nCommand line:");
for (i = 0; i < Args->NumArgs(); ++i)
{
p += snprintf(buffer + p, size - p, " %s", Args->GetArg(i));
}
p += snprintf(buffer + p, size - p, "\n");
for (i = 0; (arg = fileSystem.GetResourceFileName(i)) != NULL; ++i)
{
p += snprintf(buffer + p, size - p, "\nWad %d: %s", i, arg);
}
if (gamestate != GS_LEVEL && gamestate != GS_TITLELEVEL)
{
p += snprintf(buffer + p, size - p, "\n\nNot in a level.");
}
else
{
p += snprintf(buffer + p, size - p, "\n\nCurrent map: %s", primaryLevel->MapName.GetChars());
if (!viewactive)
{
p += snprintf(buffer + p, size - p, "\n\nView not active.");
}
else
{
auto& vp = r_viewpoint;
p += snprintf(buffer + p, size - p, "\n\nviewx = %f", vp.Pos.X);
p += snprintf(buffer + p, size - p, "\nviewy = %f", vp.Pos.Y);
p += snprintf(buffer + p, size - p, "\nviewz = %f", vp.Pos.Z);
p += snprintf(buffer + p, size - p, "\nviewangle = %f", vp.Angles.Yaw.Degrees);
}
}
}
buffer[p++] = '\n';
buffer[p++] = '\0';
return p;
} }
void I_DetectOS() void I_DetectOS()
@ -161,7 +103,7 @@ int main (int argc, char **argv)
#if !defined (__APPLE__) #if !defined (__APPLE__)
{ {
int s[4] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS }; int s[4] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS };
cc_install_handlers(argc, argv, 4, s, GAMENAMELOWERCASE "-crash.log", DoomSpecificInfo); cc_install_handlers(argc, argv, 4, s, GAMENAMELOWERCASE "-crash.log", GetCrashInfo);
} }
#endif // !__APPLE__ #endif // !__APPLE__
@ -203,7 +145,7 @@ int main (int argc, char **argv)
I_StartupJoysticks(); I_StartupJoysticks();
const int result = D_DoomMain(); const int result = GameMain();
SDL_Quit(); SDL_Quit();

View file

@ -1,35 +1,60 @@
//----------------------------------------------------------------------------- /*
// ** i_system.cpp
// Copyright 1993-1996 id Software ** Main startup code
// Copyright 1999-2016 Randy Heit **
// **---------------------------------------------------------------------------
// This program is free software: you can redistribute it and/or modify ** Copyright 1999-2016 Randy Heit
// it under the terms of the GNU General Public License as published by ** Copyright 2019-2020 Christoph Oelckers
// the Free Software Foundation, either version 3 of the License, or ** All rights reserved.
// (at your option) any later version. **
// ** Redistribution and use in source and binary forms, with or without
// This program is distributed in the hope that it will be useful, ** modification, are permitted provided that the following conditions
// but WITHOUT ANY WARRANTY; without even the implied warranty of ** are met:
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
// GNU General Public License for more details. ** 1. Redistributions of source code must retain the above copyright
// ** notice, this list of conditions and the following disclaimer.
// You should have received a copy of the GNU General Public License ** 2. Redistributions in binary form must reproduce the above copyright
// along with this program. If not, see http://www.gnu.org/licenses/ ** 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 <dirent.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fnmatch.h>
#include <unistd.h>
#include <stdarg.h>
#include <fcntl.h> #include <fcntl.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <SDL.h> #include <SDL.h>
#include "d_main.h"
#include "i_system.h"
#include "version.h"
#include "x86.h" #include "x86.h"
#include "version.h"
#include "cmdlib.h"
#include "m_argv.h"
#include "i_sound.h"
#include "i_interface.h"
#ifndef NO_GTK #ifndef NO_GTK
bool I_GtkAvailable (); bool I_GtkAvailable ();
int I_PickIWad_Gtk (WadStuff *wads, int numwads, bool showwin, int defaultiwad); int I_PickIWad_Gtk (WadStuff *wads, int numwads, bool showwin, int defaultiwad);
@ -52,8 +77,8 @@ void I_SetIWADInfo()
void Mac_I_FatalError(const char* errortext); void Mac_I_FatalError(const char* errortext);
#endif #endif
#ifdef __linux__ #ifdef __unix__
void Linux_I_FatalError(const char* errortext) void Unix_I_FatalError(const char* errortext)
{ {
// Close window or exit fullscreen and release mouse capture // Close window or exit fullscreen and release mouse capture
SDL_Quit(); SDL_Quit();
@ -90,8 +115,8 @@ void I_ShowFatalError(const char *message)
{ {
#ifdef __APPLE__ #ifdef __APPLE__
Mac_I_FatalError(message); Mac_I_FatalError(message);
#elif defined __linux__ #elif defined __unix__
Linux_I_FatalError(message); Unix_I_FatalError(message);
#else #else
// ??? // ???
#endif #endif

View file

@ -33,9 +33,8 @@
// HEADER FILES ------------------------------------------------------------ // HEADER FILES ------------------------------------------------------------
#include "doomtype.h"
#include "i_module.h" #include "i_module.h"
#include "i_soundinternal.h"
#include "i_system.h" #include "i_system.h"
#include "i_video.h" #include "i_video.h"
#include "m_argv.h" #include "m_argv.h"
@ -43,22 +42,22 @@
#include "version.h" #include "version.h"
#include "c_console.h" #include "c_console.h"
#include "c_dispatch.h" #include "c_dispatch.h"
#include "s_sound.h" #include "printf.h"
#include "hardware.h" #include "hardware.h"
#include "gl_sysfb.h" #include "gl_sysfb.h"
#include "gl_system.h" #include "gl_system.h"
#include "r_defs.h"
#include "gl/renderer/gl_renderer.h" #include "gl_renderer.h"
#include "gl/system/gl_framebuffer.h" #include "gl_framebuffer.h"
#include "gl/shaders/gl_shader.h"
#ifdef HAVE_VULKAN #ifdef HAVE_VULKAN
#include "rendering/vulkan/system/vk_framebuffer.h" #include "vulkan/system/vk_framebuffer.h"
#endif #endif
#include "rendering/polyrenderer/backend/poly_framebuffer.h" #ifdef HAVE_SOFTPOLY
#include "poly_framebuffer.h"
#endif
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -76,7 +75,7 @@
// PRIVATE FUNCTION PROTOTYPES --------------------------------------------- // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
// EXTERNAL DATA DECLARATIONS ---------------------------------------------- // EXTERNAL DATA DECLARATIONS ----------------------------------------------
extern double refreshfreq;
extern IVideo *Video; extern IVideo *Video;
EXTERN_CVAR (Int, vid_adapter) EXTERN_CVAR (Int, vid_adapter)
@ -261,6 +260,7 @@ bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
} }
#endif #endif
#ifdef HAVE_SOFTPOLY
namespace namespace
{ {
SDL_Renderer* polyrendertarget = nullptr; SDL_Renderer* polyrendertarget = nullptr;
@ -409,7 +409,7 @@ void I_PolyPresentDeinit()
polyrendertarget = nullptr; polyrendertarget = nullptr;
} }
} }
#endif
SDLVideo::SDLVideo () SDLVideo::SDLVideo ()
@ -428,7 +428,9 @@ SDLVideo::SDLVideo ()
} }
#endif // !SDL2_STATIC_LIBRARY #endif // !SDL2_STATIC_LIBRARY
#ifdef HAVE_SOFTPOLY
Priv::softpolyEnabled = vid_preferbackend == 2; Priv::softpolyEnabled = vid_preferbackend == 2;
#endif
#ifdef HAVE_VULKAN #ifdef HAVE_VULKAN
Priv::vulkanEnabled = vid_preferbackend == 1 Priv::vulkanEnabled = vid_preferbackend == 1
&& Priv::Vulkan_GetDrawableSize && Priv::Vulkan_GetInstanceExtensions && Priv::Vulkan_CreateSurface; && Priv::Vulkan_GetDrawableSize && Priv::Vulkan_GetInstanceExtensions && Priv::Vulkan_CreateSurface;
@ -443,10 +445,25 @@ SDLVideo::SDLVideo ()
} }
} }
#endif #endif
#ifdef HAVE_SOFTPOLY
if (Priv::softpolyEnabled) if (Priv::softpolyEnabled)
{ {
Priv::CreateWindow(SDL_WINDOW_HIDDEN); Priv::CreateWindow(SDL_WINDOW_HIDDEN);
} }
#endif
// Get refresh rate for current display.
SDL_DisplayMode display;
if(SDL_GetCurrentDisplayMode(vid_adapter, &display) == 0)
{
refreshfreq = display.refresh_rate;
}
else
{
fprintf(stderr, "Failed to get refresh rate: %s\n", SDL_GetError());
return;
}
} }
SDLVideo::~SDLVideo () SDLVideo::~SDLVideo ()
@ -482,11 +499,12 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer ()
} }
#endif #endif
#ifdef HAVE_SOFTPOLY
if (Priv::softpolyEnabled) if (Priv::softpolyEnabled)
{ {
fb = new PolyFrameBuffer(nullptr, vid_fullscreen); fb = new PolyFrameBuffer(nullptr, vid_fullscreen);
} }
#endif
if (fb == nullptr) if (fb == nullptr)
{ {
fb = new OpenGLRenderer::OpenGLFrameBuffer(0, vid_fullscreen); fb = new OpenGLRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
@ -518,6 +536,7 @@ int SystemBaseFrameBuffer::GetClientWidth()
{ {
int width = 0; int width = 0;
#ifdef HAVE_SOFTPOLY
if (Priv::softpolyEnabled) if (Priv::softpolyEnabled)
{ {
if (polyrendertarget) if (polyrendertarget)
@ -526,6 +545,7 @@ int SystemBaseFrameBuffer::GetClientWidth()
SDL_GetWindowSize(Priv::window, &width, nullptr); SDL_GetWindowSize(Priv::window, &width, nullptr);
return width; return width;
} }
#endif
#ifdef HAVE_VULKAN #ifdef HAVE_VULKAN
assert(Priv::vulkanEnabled); assert(Priv::vulkanEnabled);
@ -538,7 +558,8 @@ int SystemBaseFrameBuffer::GetClientWidth()
int SystemBaseFrameBuffer::GetClientHeight() int SystemBaseFrameBuffer::GetClientHeight()
{ {
int height = 0; int height = 0;
#ifdef HAVE_SOFTPOLY
if (Priv::softpolyEnabled) if (Priv::softpolyEnabled)
{ {
if (polyrendertarget) if (polyrendertarget)
@ -547,6 +568,7 @@ int SystemBaseFrameBuffer::GetClientHeight()
SDL_GetWindowSize(Priv::window, nullptr, &height); SDL_GetWindowSize(Priv::window, nullptr, &height);
return height; return height;
} }
#endif
#ifdef HAVE_VULKAN #ifdef HAVE_VULKAN
assert(Priv::vulkanEnabled); assert(Priv::vulkanEnabled);
@ -588,7 +610,7 @@ void SystemBaseFrameBuffer::SetWindowSize(int w, int h)
} }
win_w = w; win_w = w;
win_h = h; win_h = h;
if (vid_fullscreen ) if (vid_fullscreen)
{ {
vid_fullscreen = false; vid_fullscreen = false;
} }

View file

@ -40,7 +40,6 @@
#include <functional> #include <functional>
#include "st_start.h" #include "st_start.h"
#include "doomdef.h"
#include "i_system.h" #include "i_system.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "engineerrors.h" #include "engineerrors.h"

View file

@ -55,10 +55,13 @@ typedef enum
#endif #endif
#include "c_cvars.h" #include "c_cvars.h"
#include "d_main.h"
#include "i_module.h" #include "i_module.h"
#include "i_system.h" #include "i_system.h"
#include "version.h" #include "version.h"
#include "startupinfo.h"
#include "cmdlib.h"
#include "i_interface.h"
#include "printf.h"
EXTERN_CVAR (Bool, queryiwad); EXTERN_CVAR (Bool, queryiwad);

View file

@ -44,7 +44,9 @@
#include "version.h" #include "version.h"
#include "printf.h" #include "printf.h"
#include "win32glvideo.h" #include "win32glvideo.h"
#ifdef HAVE_SOFTPOLY
#include "win32polyvideo.h" #include "win32polyvideo.h"
#endif
#ifdef HAVE_VULKAN #ifdef HAVE_VULKAN
#include "win32vulkanvideo.h" #include "win32vulkanvideo.h"
#endif #endif
@ -129,12 +131,15 @@ void I_InitGraphics ()
// are the active app. Huh? // are the active app. Huh?
} }
#ifdef HAVE_SOFTPOLY
if (vid_preferbackend == 2) if (vid_preferbackend == 2)
{ {
Video = new Win32PolyVideo(); Video = new Win32PolyVideo();
} }
else
#endif
#ifdef HAVE_VULKAN #ifdef HAVE_VULKAN
else if (vid_preferbackend == 1) if (vid_preferbackend == 1)
{ {
// first try Vulkan, if that fails OpenGL // first try Vulkan, if that fails OpenGL
try try
@ -147,15 +152,16 @@ void I_InitGraphics ()
Video = new Win32GLVideo(); Video = new Win32GLVideo();
} }
} }
#endif
else else
#endif
{ {
Video = new Win32GLVideo(); Video = new Win32GLVideo();
} }
#ifdef HAVE_SOFTPOLY
if (Video == NULL) if (Video == NULL)
Video = new Win32PolyVideo(); Video = new Win32PolyVideo();
#endif
// we somehow STILL don't have a display!! // we somehow STILL don't have a display!!
if (Video == NULL) if (Video == NULL)
I_FatalError ("Failed to initialize display"); I_FatalError ("Failed to initialize display");

View file

@ -74,7 +74,7 @@
#include "i_sound.h" #include "i_sound.h"
#include "d_gui.h" #include "d_gui.h"
#include "c_console.h" #include "c_console.h"
#include "s_sound.h" #include "s_soundinternal.h"
#include "gameconfigfile.h" #include "gameconfigfile.h"
#include "hardware.h" #include "hardware.h"
#include "d_event.h" #include "d_event.h"
@ -87,8 +87,6 @@
#include "c_buttons.h" #include "c_buttons.h"
#include "cmdlib.h" #include "cmdlib.h"
int32_t refreshfreq = -1;
// Compensate for w32api's lack // Compensate for w32api's lack
#ifndef GET_XBUTTON_WPARAM #ifndef GET_XBUTTON_WPARAM
#define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam)) #define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
@ -138,6 +136,7 @@ extern bool AppActive;
int SessionState = 0; int SessionState = 0;
int BlockMouseMove; int BlockMouseMove;
extern double refreshfreq;
static bool EventHandlerResultForNativeMouse; static bool EventHandlerResultForNativeMouse;

View file

@ -59,17 +59,13 @@
#include "hardware.h" #include "hardware.h"
#include "m_argv.h" #include "m_argv.h"
#include "d_main.h"
#include "i_module.h" #include "i_module.h"
#include "c_console.h" #include "c_console.h"
#include "version.h" #include "version.h"
#include "i_input.h" #include "i_input.h"
#include "filesystem.h" #include "filesystem.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "g_game.h" #include "s_soundinternal.h"
#include "r_utility.h"
#include "g_levellocals.h"
#include "s_sound.h"
#include "vm.h" #include "vm.h"
#include "i_system.h" #include "i_system.h"
#include "gstrings.h" #include "gstrings.h"
@ -77,6 +73,9 @@
#include "stats.h" #include "stats.h"
#include "st_start.h" #include "st_start.h"
#include "i_interface.h"
#include "startupinfo.h"
#include "printf.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -96,6 +95,7 @@ void CreateCrashLog (const char *custominfo, DWORD customsize, HWND richedit);
void DisplayCrashLog (); void DisplayCrashLog ();
void I_FlushBufferedConsoleStuff(); void I_FlushBufferedConsoleStuff();
void DestroyCustomCursor(); void DestroyCustomCursor();
int GameMain();
// PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
@ -268,7 +268,7 @@ void LayoutMainWindow (HWND hWnd, HWND pane)
w = rect.right; w = rect.right;
h = rect.bottom; h = rect.bottom;
if (DoomStartupInfo.Name.IsNotEmpty() && GameTitleWindow != NULL) if (GameStartupInfo.Name.IsNotEmpty() && GameTitleWindow != NULL)
{ {
bannerheight = GameTitleFontHeight + 5; bannerheight = GameTitleFontHeight + 5;
MoveWindow (GameTitleWindow, 0, 0, w, bannerheight, TRUE); MoveWindow (GameTitleWindow, 0, 0, w, bannerheight, TRUE);
@ -426,7 +426,7 @@ LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_DRAWITEM: case WM_DRAWITEM:
// Draw title banner. // Draw title banner.
if (wParam == IDC_STATIC_TITLE && DoomStartupInfo.Name.IsNotEmpty()) if (wParam == IDC_STATIC_TITLE && GameStartupInfo.Name.IsNotEmpty())
{ {
const PalEntry *c; const PalEntry *c;
@ -436,7 +436,7 @@ LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
// Draw the background. // Draw the background.
rect = drawitem->rcItem; rect = drawitem->rcItem;
rect.bottom -= 1; rect.bottom -= 1;
c = (const PalEntry *)&DoomStartupInfo.BkColor; c = (const PalEntry *)&GameStartupInfo.BkColor;
hbr = CreateSolidBrush (RGB(c->r,c->g,c->b)); hbr = CreateSolidBrush (RGB(c->r,c->g,c->b));
FillRect (drawitem->hDC, &drawitem->rcItem, hbr); FillRect (drawitem->hDC, &drawitem->rcItem, hbr);
DeleteObject (hbr); DeleteObject (hbr);
@ -444,11 +444,11 @@ LRESULT CALLBACK LConProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
// Calculate width of the title string. // Calculate width of the title string.
SetTextAlign (drawitem->hDC, TA_TOP); SetTextAlign (drawitem->hDC, TA_TOP);
oldfont = SelectObject (drawitem->hDC, GameTitleFont != NULL ? GameTitleFont : (HFONT)GetStockObject (DEFAULT_GUI_FONT)); oldfont = SelectObject (drawitem->hDC, GameTitleFont != NULL ? GameTitleFont : (HFONT)GetStockObject (DEFAULT_GUI_FONT));
auto widename = DoomStartupInfo.Name.WideString(); auto widename = GameStartupInfo.Name.WideString();
GetTextExtentPoint32W (drawitem->hDC, widename.c_str(), (int)widename.length(), &size); GetTextExtentPoint32W (drawitem->hDC, widename.c_str(), (int)widename.length(), &size);
// Draw the title. // Draw the title.
c = (const PalEntry *)&DoomStartupInfo.FgColor; c = (const PalEntry *)&GameStartupInfo.FgColor;
SetTextColor (drawitem->hDC, RGB(c->r,c->g,c->b)); SetTextColor (drawitem->hDC, RGB(c->r,c->g,c->b));
SetBkMode (drawitem->hDC, TRANSPARENT); SetBkMode (drawitem->hDC, TRANSPARENT);
TextOutW (drawitem->hDC, rect.left + (rect.right - rect.left - size.cx) / 2, 2, widename.c_str(), (int)widename.length()); TextOutW (drawitem->hDC, rect.left + (rect.right - rect.left - size.cx) / 2, 2, widename.c_str(), (int)widename.length());
@ -950,7 +950,7 @@ int DoMain (HINSTANCE hInstance)
CoInitialize (NULL); CoInitialize (NULL);
atexit (UnCOM); atexit (UnCOM);
int ret = D_DoomMain (); int ret = GameMain ();
DestroyCustomCursor(); DestroyCustomCursor();
if (ret == 1337) // special exit code for 'norun'. if (ret == 1337) // special exit code for 'norun'.
{ {
@ -998,55 +998,6 @@ void I_ShowFatalError(const char *msg)
} }
} }
//==========================================================================
//
// DoomSpecificInfo
//
// Called by the crash logger to get application-specific information.
//
//==========================================================================
void DoomSpecificInfo (char *buffer, size_t bufflen)
{
const char *arg;
char *const buffend = buffer + bufflen - 2; // -2 for CRLF at end
int i;
buffer += mysnprintf (buffer, buffend - buffer, GAMENAME " version %s (%s)", GetVersionString(), GetGitHash());
FString cmdline(GetCommandLineW());
buffer += mysnprintf (buffer, buffend - buffer, "\r\nCommand line: %s\r\n", cmdline.GetChars() );
for (i = 0; (arg = fileSystem.GetResourceFileName (i)) != NULL; ++i)
{
buffer += mysnprintf (buffer, buffend - buffer, "\r\nWad %d: %s", i, arg);
}
if (gamestate != GS_LEVEL && gamestate != GS_TITLELEVEL)
{
buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nNot in a level.");
}
else
{
buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nCurrent map: %s", primaryLevel->MapName.GetChars());
if (!viewactive)
{
buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nView not active.");
}
else
{
auto &vp = r_viewpoint;
buffer += mysnprintf (buffer, buffend - buffer, "\r\n\r\nviewx = %f", vp.Pos.X);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewy = %f", vp.Pos.Y);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewz = %f", vp.Pos.Z);
buffer += mysnprintf (buffer, buffend - buffer, "\r\nviewangle = %f", vp.Angles.Yaw);
}
}
*buffer++ = '\r';
*buffer++ = '\n';
*buffer++ = '\0';
}
// Here is how the error logging system works. // Here is how the error logging system works.
// //
// To catch exceptions that occur in secondary threads, CatchAllExceptions is // To catch exceptions that occur in secondary threads, CatchAllExceptions is
@ -1139,7 +1090,7 @@ LONG WINAPI CatchAllExceptions (LPEXCEPTION_POINTERS info)
char *custominfo = (char *)HeapAlloc (GetProcessHeap(), 0, 16384); char *custominfo = (char *)HeapAlloc (GetProcessHeap(), 0, 16384);
CrashPointers = *info; CrashPointers = *info;
DoomSpecificInfo (custominfo, 16384); if (sysCallbacks && sysCallbacks->CrashInfo && custominfo) sysCallbacks->CrashInfo(custominfo, 16384, "\r\n");
CreateCrashLog (custominfo, (DWORD)strlen(custominfo), ConWindow); CreateCrashLog (custominfo, (DWORD)strlen(custominfo), ConWindow);
// If the main thread crashed, then make it clean up after itself. // If the main thread crashed, then make it clean up after itself.

View file

@ -268,9 +268,10 @@ void I_CheckNativeMouse(bool preferNative, bool eventhandlerresult)
} }
else else
{ {
bool pauseState = false;
bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame(); bool captureModeInGame = sysCallbacks && sysCallbacks->CaptureModeInGame && sysCallbacks->CaptureModeInGame();
want_native = ((!m_use_mouse || menuactive != MENU_WaitKey) && want_native = ((!m_use_mouse || menuactive != MENU_WaitKey) &&
(!captureModeInGame || GUICapture ||paused || demoplayback)); (!captureModeInGame || GUICapture));
} }
} }

Some files were not shown because too many files have changed in this diff Show more