Initial commit of update to Raze mazter

All prior changes can be found on the (will be published in the future) RazeXR repo
This commit is contained in:
Simon 2023-01-13 23:41:22 +00:00
parent b991af2dbc
commit 91ede1126f
100 changed files with 28368 additions and 98 deletions

12
android/Android.mk Normal file
View file

@ -0,0 +1,12 @@
GZDOOM_TOP_PATH := $(call my-dir)/../
include $(GZDOOM_TOP_PATH)/android/Android_lzma.mk
include $(GZDOOM_TOP_PATH)/android/Android_zlib.mk
include $(GZDOOM_TOP_PATH)/android/Android_gdtoa.mk
include $(GZDOOM_TOP_PATH)/android/Android_bzip2.mk
include $(GZDOOM_TOP_PATH)/android/Android_vpx.mk
include $(GZDOOM_TOP_PATH)/android/Android_tess.mk
include $(GZDOOM_TOP_PATH)/android/Android_src.mk

37
android/Android_bzip2.mk Normal file
View file

@ -0,0 +1,37 @@
LOCAL_PATH := $(call my-dir)/../libraries/bzip2
include $(CLEAR_VARS)
LOCAL_MODULE := bzip2_gl3
LOCAL_CFLAGS :=
LOCAL_LDLIBS += -llog
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
LOCAL_SRC_FILES = \
blocksort.c \
bzlib.c \
compress.c \
crctable.c \
decompress.c \
huffman.c \
randtable.c \
include $(BUILD_STATIC_LIBRARY)

68
android/Android_gdtoa.mk Normal file
View file

@ -0,0 +1,68 @@
LOCAL_PATH := $(call my-dir)/../libraries/gdtoa
include $(CLEAR_VARS)
LOCAL_MODULE := gdtoa_gl3
LOCAL_CFLAGS :=
LOCAL_LDLIBS += -llog
LOCAL_C_INCLUDES := . $(GZDOOM_TOP_PATH)/android/src/extrafiles
LOCAL_SRC_FILES = \
dmisc.c \
dtoa.c \
g_Qfmt.c \
g__fmt.c \
g_ddfmt.c \
g_dfmt.c \
g_ffmt.c \
g_xLfmt.c \
g_xfmt.c \
gdtoa.c \
gethex.c \
gmisc.c \
hd_init.c \
hexnan.c \
misc.c \
smisc.c \
strtoIQ.c \
strtoId.c \
strtoIdd.c \
strtoIf.c \
strtoIg.c \
strtoIx.c \
strtoIxL.c \
strtod.c \
strtodI.c \
strtodg.c \
strtopQ.c \
strtopd.c \
strtopdd.c \
strtopf.c \
strtopx.c \
strtopxL.c \
strtorQ.c \
strtord.c \
strtordd.c \
strtorf.c \
strtorx.c \
strtorxL.c \
sum.c \
ulp.c \
include $(BUILD_STATIC_LIBRARY)

46
android/Android_lzma.mk Normal file
View file

@ -0,0 +1,46 @@
LOCAL_PATH := $(call my-dir)/../libraries/lzma
include $(CLEAR_VARS)
LOCAL_MODULE := lzma_gl3
LOCAL_CFLAGS = -Wall -fomit-frame-pointer -D_7ZIP_ST
LOCAL_LDLIBS += -llog
LOCAL_C_INCLUDES :=
LOCAL_SRC_FILES = \
C/7zBuf.c \
C/7zCrc.c \
C/7zCrcOpt.c \
C/7zDec.c \
C/7zArcIn.c \
C/7zStream.c \
C/7zDec.c \
C/Delta.c \
C/Bcj2.c \
C/Bra.c \
C/Bra86.c \
C/BraIA64.c \
C/CpuArch.c \
C/LzFind.c \
C/Lzma2Dec.c \
C/LzmaDec.c \
C/LzmaEnc.c \
include $(BUILD_STATIC_LIBRARY)

499
android/Android_src.mk Normal file
View file

@ -0,0 +1,499 @@
LOCAL_PATH := $(call my-dir)/../source
include $(CLEAR_VARS)
# Uncomment for the correct headset - slight changes required in OpenXR implementation
OPENXR_HMD = -DMETA_QUEST
#OPENXR_HMD = -DPICO_XR
LOCAL_SHORT_COMMANDS := true
APP_SHORT_COMMANDS := true
LOCAL_MODULE := raze
LOCAL_CFLAGS := $(OPENXR_HMD) -funsigned-char -DHAVE_GLES2 -DUSE_OPENGL -DNO_CLOCK_GETTIME -DUSE_GL_HW_BUFFERS -fvisibility=hidden -frtti -D__MOBILE__ -DOPNMIDI_DISABLE_GX_EMULATOR -DGZDOOM -DGZDOOM_GL3 -D__STDINT_LIMITS -DENGINE_NAME=\"gzdoom_dev\"
#-DNO_PIX_BUFF
#-DUSE_GL_HW_BUFFERS
#-DHAVE_VULKAN
#-DUSE_GL_HW_BUFFERS
LOCAL_CPPFLAGS := $(OPENXR_HMD) -include g_pch.h -DHAVE_FLUIDSYNTH -DHAVE_MPG123 -DHAVE_SNDFILE -std=c++17 -Wno-inconsistent-missing-override -Werror=format-security -fexceptions -fpermissive -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D__forceinline=inline -DNO_GTK -DNO_SSE
LOCAL_CFLAGS += -DNO_SEND_STATS
LOCAL_CFLAGS += -DOPNMIDI_USE_LEGACY_EMULATOR
LOCAL_CFLAGS += -DADLMIDI_DISABLE_MUS_SUPPORT -DADLMIDI_DISABLE_XMI_SUPPORT -DADLMIDI_DISABLE_MIDI_SEQUENCER
LOCAL_CFLAGS += -DOPNMIDI_DISABLE_MUS_SUPPORT -DOPNMIDI_DISABLE_XMI_SUPPORT -DOPNMIDI_DISABLE_MIDI_SEQUENCER
ifeq ($(BUILD_SERIAL),1)
LOCAL_CPPFLAGS += -DANTI_HACK
endif
LOCAL_C_INCLUDES := \
$(TOP_DIR)/../../../../../3rdParty/khronos/openxr/OpenXR-SDK/include \
$(TOP_DIR)/../../../../../3rdParty/khronos/openxr/OpenXR-SDK/src/common \
$(TOP_DIR)/../../../../../OpenXR/Include \
$(TOP_DIR)/ \ \
$(SUPPORT_LIBS)/fluidsynth-lite/include \
$(GZDOOM_TOP_PATH)/source/ \
$(GZDOOM_TOP_PATH)/source/core \
$(GZDOOM_TOP_PATH)/source/core/2d \
$(GZDOOM_TOP_PATH)/source/core/fonts \
$(GZDOOM_TOP_PATH)/source/core/utility \
$(GZDOOM_TOP_PATH)/source/core/console \
$(GZDOOM_TOP_PATH)/source/core/textures \
$(GZDOOM_TOP_PATH)/source/core/music \
$(GZDOOM_TOP_PATH)/source/core/dobject \
$(GZDOOM_TOP_PATH)/source/core/menu \
$(GZDOOM_TOP_PATH)/source/core/input \
$(GZDOOM_TOP_PATH)/source/platform \
$(GZDOOM_TOP_PATH)/source/common/cutscenes \
$(GZDOOM_TOP_PATH)/source/common/audio/sound \
$(GZDOOM_TOP_PATH)/source/common/audio/music \
$(GZDOOM_TOP_PATH)/source/common/2d \
$(GZDOOM_TOP_PATH)/source/common/thirdparty \
$(GZDOOM_TOP_PATH)/source/common/textures \
$(GZDOOM_TOP_PATH)/source/common/textures/formats \
$(GZDOOM_TOP_PATH)/source/common/textures/hires \
$(GZDOOM_TOP_PATH)/source/common/textures \
$(GZDOOM_TOP_PATH)/source/common/models \
$(GZDOOM_TOP_PATH)/source/common/filesystem \
$(GZDOOM_TOP_PATH)/source/common/utility \
$(GZDOOM_TOP_PATH)/source/common/console \
$(GZDOOM_TOP_PATH)/source/common/engine \
$(GZDOOM_TOP_PATH)/source/common/menu \
$(GZDOOM_TOP_PATH)/source/common/statusbar \
$(GZDOOM_TOP_PATH)/source/common/fonts \
$(GZDOOM_TOP_PATH)/source/common/objects \
$(GZDOOM_TOP_PATH)/source/common/startscreen \
$(GZDOOM_TOP_PATH)/source/common/rendering \
$(GZDOOM_TOP_PATH)/source/common/rendering/hwrenderer \
$(GZDOOM_TOP_PATH)/source/common/rendering/hwrenderer/data \
$(GZDOOM_TOP_PATH)/source/common/rendering/gl_load \
$(GZDOOM_TOP_PATH)/source/common/rendering/gl \
$(GZDOOM_TOP_PATH)/source/common/rendering/gles \
$(GZDOOM_TOP_PATH)/source/common/rendering/vulkan/thirdparty \
$(GZDOOM_TOP_PATH)/source/common/rendering/polyrenderer/backend \
$(GZDOOM_TOP_PATH)/source/common/rendering/polyrenderer/drawers \
$(GZDOOM_TOP_PATH)/source/common/scripting/vm \
$(GZDOOM_TOP_PATH)/source/common/scripting/jit \
$(GZDOOM_TOP_PATH)/source/common/scripting/core \
$(GZDOOM_TOP_PATH)/source/common/scripting/interface \
$(GZDOOM_TOP_PATH)/source/common/scripting/frontend \
$(GZDOOM_TOP_PATH)/source/common/scripting/backend \
$(GZDOOM_TOP_PATH)/source/common/platform/posix \
$(GZDOOM_TOP_PATH)/source/common/platform/posix/nosdl \
$(GZDOOM_TOP_PATH)/source/core/rendering \
$(GZDOOM_TOP_PATH)/source/core/rendering/scene \
$(GZDOOM_TOP_PATH)/source/common/thirdparty/libsmackerdec/include \
$(GZDOOM_TOP_PATH)/source/thirdparty/include \
$(GZDOOM_TOP_PATH)/source/build/include \
$(GZDOOM_TOP_PATH)/libraries/lzma/C \
$(GZDOOM_TOP_PATH)/libraries/bzip2 \
$(GZDOOM_TOP_PATH)/libraries/gdtoa \
$(GZDOOM_TOP_PATH)/libraries/libtess/Include \
$(GZDOOM_TOP_PATH)/libraries/discordrpc/include \
$(GZDOOM_TOP_PATH)/android/src/vpx/include \
$(GZDOOM_TOP_PATH)/source/common/rendering/gles/glad/include \
$(SUPPORT_LIBS)/openal/include/AL \
$(SUPPORT_LIBS)/jpeg8d \
$(SUPPORT_LIBS) \
$(SUPPORT_LIBS)/ZMusic/include \
$(GZDOOM_TOP_PATH)/android/src/extrafiles \
$(GZDOOM_TOP_PATH)/android/src
#############################################################################
# CLIENT/SERVER
#############################################################################
ANDROID_SRC_FILES = \
../android/src/i_specialpaths_android.cpp
PLAT_POSIX_SOURCES = \
platform/posix/i_steam.cpp \
common/platform/posix/i_system_posix.cpp \
PLAT_SDL_SOURCES = \
common/platform/posix/nosdl/crashcatcher.c \
common/platform/posix/nosdl/hardware.cpp \
common/platform/posix/nosdl/i_gui.cpp \
common/platform/posix/nosdl/i_main.cpp \
common/platform/posix/nosdl/i_system.cpp \
common/platform/posix/nosdl/i_input.cpp \
common/platform/posix/nosdl/i_joystick.cpp \
common/platform/posix/nosdl/glvideo.cpp \
common/platform/posix/nosdl/st_start.cpp \
FASTMATH_SOURCES = \
../android/src/android_gl_load.c \
common/textures/hires/hqnx/init.cpp \
common/textures/hires/hqnx/hq2x.cpp \
common/textures/hires/hqnx/hq3x.cpp \
common/textures/hires/hqnx/hq4x.cpp \
common/textures/hires/xbr/xbrz.cpp \
common/textures/hires/xbr/xbrz_old.cpp \
common/utility/matrix.cpp
PCH_SOURCES = \
common/thirdparty/richpresence.cpp \
thirdparty/src/md4.cpp \
build/src/clip.cpp \
core/actorinfo.cpp \
core/zcc_compile_raze.cpp \
core/vmexports.cpp \
core/thingdef_data.cpp \
core/thingdef_properties.cpp \
core/actorlist.cpp \
core/automap.cpp \
core/cheats.cpp \
core/cheathandler.cpp \
core/rts.cpp \
core/ct_chat.cpp \
core/d_net.cpp \
core/d_protocol.cpp \
core/mainloop.cpp \
core/gameconfigfile.cpp \
core/gamecvars.cpp \
core/gamecontrol.cpp \
core/gamehud.cpp \
core/gamefuncs.cpp \
core/gameinput.cpp \
core/g_mapinfo.cpp \
core/interpolate.cpp \
core/inputstate.cpp \
core/maphack.cpp \
core/mapinfo.cpp \
core/maploader.cpp \
core/postprocessor.cpp \
core/searchpaths.cpp \
core/screenjob.cpp \
core/initfs.cpp \
core/statistics.cpp \
core/secrets.cpp \
core/savegamehelp.cpp \
core/precache.cpp \
core/psky.cpp \
core/quotes.cpp \
core/screenshot.cpp \
core/sectorgeometry.cpp \
core/razefont.cpp \
core/raze_music.cpp \
core/raze_sound.cpp \
core/palette.cpp \
core/zcompile.cpp \
core/statusbar2.cpp \
core/shared_hud.cpp \
core/gi.cpp \
core/defparser.cpp \
core/rendering/hw_entrypoint.cpp \
core/rendering/hw_models.cpp \
core/rendering/hw_voxels.cpp \
core/rendering/hw_palmanager.cpp \
core/rendering/hw_sections.cpp \
core/rendering/hw_vertexmap.cpp \
core/rendering/scene/hw_clipper.cpp \
core/rendering/scene/hw_walls.cpp \
core/rendering/scene/hw_walls_vertex.cpp \
core/rendering/scene/hw_flats.cpp \
core/rendering/scene/hw_sprites.cpp \
core/rendering/scene/hw_drawlistadd.cpp \
core/rendering/scene/hw_drawlist.cpp \
core/rendering/scene/hw_drawinfo.cpp \
core/rendering/scene/hw_bunchdrawer.cpp \
core/rendering/scene/hw_portal.cpp \
core/rendering/scene/hw_skyportal.cpp \
core/rendering/scene/hw_sky.cpp \
core/rendering/scene/hw_setcolor.cpp \
core/rendering/scene/hw_lighting.cpp \
core/r_data/gldefs.cpp \
core/models/modeldata.cpp \
core/console/c_notifybuffer.cpp \
core/console/d_event.cpp \
common/audio/sound/i_sound.cpp \
common/audio/sound/oalsound.cpp \
common/audio/sound/s_environment.cpp \
common/audio/sound/s_sound.cpp \
common/audio/sound/s_reverbedit.cpp \
common/audio/music/music_midi_base.cpp \
common/audio/music/music.cpp \
common/audio/music/i_music.cpp \
common/audio/music/i_soundfont.cpp \
common/audio/music/music_config.cpp \
common/2d/v_2ddrawer.cpp \
common/2d/v_drawtext.cpp \
common/2d/v_draw.cpp \
common/2d/wipe.cpp \
common/thirdparty/gain_analysis.cpp \
common/thirdparty/sfmt/SFMT.cpp \
common/startscreen/startscreen.cpp \
common/startscreen/startscreen_heretic.cpp \
common/startscreen/startscreen_hexen.cpp \
common/startscreen/startscreen_strife.cpp \
common/startscreen/startscreen_generic.cpp \
common/startscreen/endoom.cpp \
common/fonts/singlelumpfont.cpp \
common/fonts/singlepicfont.cpp \
common/fonts/specialfont.cpp \
common/fonts/font.cpp \
common/fonts/hexfont.cpp \
common/fonts/v_font.cpp \
common/fonts/v_text.cpp \
common/textures/hw_ihwtexture.cpp \
common/textures/hw_material.cpp \
common/textures/bitmap.cpp \
common/textures/m_png.cpp \
common/textures/texture.cpp \
common/textures/gametexture.cpp \
common/textures/image.cpp \
common/textures/imagetexture.cpp \
common/textures/texturemanager.cpp \
common/textures/multipatchtexturebuilder.cpp \
common/textures/skyboxtexture.cpp \
common/textures/animtexture.cpp \
common/textures/v_collection.cpp \
common/textures/animlib.cpp \
common/textures/formats/automaptexture.cpp \
common/textures/formats/brightmaptexture.cpp \
common/textures/formats/buildtexture.cpp \
common/textures/formats/ddstexture.cpp \
common/textures/formats/flattexture.cpp \
common/textures/formats/fontchars.cpp \
common/textures/formats/imgztexture.cpp \
common/textures/formats/jpegtexture.cpp \
common/textures/formats/md5check.cpp \
common/textures/formats/multipatchtexture.cpp \
common/textures/formats/patchtexture.cpp \
common/textures/formats/pcxtexture.cpp \
common/textures/formats/pngtexture.cpp \
common/textures/formats/rawpagetexture.cpp \
common/textures/formats/startuptexture.cpp \
common/textures/formats/emptytexture.cpp \
common/textures/formats/shadertexture.cpp \
common/textures/formats/tgatexture.cpp \
common/textures/formats/stbtexture.cpp \
common/textures/formats/anmtexture.cpp \
common/textures/formats/startscreentexture.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/models_iqm.cpp \
common/models/model.cpp \
common/models/voxels.cpp \
common/console/c_commandline.cpp \
common/console/c_buttons.cpp \
common/console/c_bind.cpp \
common/console/c_enginecmds.cpp \
common/console/c_consolebuffer.cpp \
common/console/c_cvars.cpp \
common/console/c_dispatch.cpp \
common/console/c_commandbuffer.cpp \
common/console/c_console.cpp \
common/console/c_notifybufferbase.cpp \
common/console/c_tabcomplete.cpp \
common/console/c_expr.cpp \
common/cutscenes/playmve.cpp \
common/cutscenes/movieplayer.cpp \
common/cutscenes/screenjob.cpp \
common/utility/engineerrors.cpp \
common/utility/i_module.cpp \
common/utility/gitinfo.cpp \
common/utility/m_alloc.cpp \
common/utility/utf8.cpp \
common/utility/palette.cpp \
common/utility/files.cpp \
common/utility/files_decompress.cpp \
common/utility/memarena.cpp \
common/utility/cmdlib.cpp \
common/utility/configfile.cpp \
common/utility/i_time.cpp \
common/utility/m_argv.cpp \
common/utility/s_playlist.cpp \
common/utility/zstrformat.cpp \
common/utility/name.cpp \
common/utility/r_memory.cpp \
common/thirdparty/base64.cpp \
common/thirdparty/md5.cpp \
common/thirdparty/superfasthash.cpp \
common/thirdparty/libsmackerdec/src/BitReader.cpp \
common/thirdparty/libsmackerdec/src/FileStream.cpp \
common/thirdparty/libsmackerdec/src/HuffmanVLC.cpp \
common/thirdparty/libsmackerdec/src/LogError.cpp \
common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp \
common/filesystem/filesystem.cpp \
common/filesystem/ancientzip.cpp \
common/filesystem/file_7z.cpp \
common/filesystem/file_grp.cpp \
common/filesystem/file_lump.cpp \
common/filesystem/file_rff.cpp \
common/filesystem/file_wad.cpp \
common/filesystem/file_zip.cpp \
common/filesystem/file_pak.cpp \
common/filesystem/file_whres.cpp \
common/filesystem/file_ssi.cpp \
common/filesystem/file_directory.cpp \
common/filesystem/resourcefile.cpp \
common/engine/cycler.cpp \
common/engine/d_event.cpp \
common/engine/date.cpp \
common/engine/stats.cpp \
common/engine/sc_man.cpp \
common/engine/palettecontainer.cpp \
common/engine/stringtable.cpp \
common/engine/i_net.cpp \
common/engine/i_interface.cpp \
common/engine/renderstyle.cpp \
common/engine/v_colortables.cpp \
common/engine/serializer.cpp \
common/engine/m_joy.cpp \
common/engine/m_random.cpp \
common/objects/autosegs.cpp \
common/objects/dobject.cpp \
common/objects/dobjgc.cpp \
common/objects/dobjtype.cpp \
common/menu/joystickmenu.cpp \
common/menu/menu.cpp \
common/menu/messagebox.cpp \
common/menu/optionmenu.cpp \
common/menu/resolutionmenu.cpp \
common/menu/menudef.cpp \
common/menu/savegamemanager.cpp \
common/statusbar/base_sbar.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_bonebuffer.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_postprocessshader.cpp \
common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp \
common/rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp \
common/rendering/hwrenderer/postprocessing/hw_postprocessshader_ccmds.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/dynarrays.cpp \
common/scripting/core/symbols.cpp \
common/scripting/core/types.cpp \
common/scripting/core/scopebarrier.cpp \
common/scripting/core/vmdisasm.cpp \
common/scripting/core/imports.cpp \
common/scripting/vm/vmexec.cpp \
common/scripting/vm/vmframe.cpp \
common/scripting/interface/stringformat.cpp \
common/scripting/interface/vmnatives.cpp \
common/scripting/frontend/ast.cpp \
common/scripting/frontend/zcc_compile.cpp \
common/scripting/frontend/zcc_parser.cpp \
common/scripting/backend/vmbuilder.cpp \
common/scripting/backend/codegen.cpp \
core/textures/tiletexture.cpp \
core/textures/texinfo.cpp \
core/textures/tilesetbuilder.cpp \
core/textures/skytexture.cpp \
core/textures/hightile.cpp \
core/music/s_advsound.cpp \
core/menu/loadsavemenu.cpp \
core/menu/usermap.cpp \
core/menu/razemenu.cpp \
games/duke/all.cpp \
games/duke/all_d.cpp \
games/duke/all_r.cpp \
games/exhumed/all.cpp \
games/blood/all.cpp \
games/sw/all.cpp
RAZEXR_SRC_FILES := ${TOP_DIR}/RazeXR/RazeXR_OpenXR.cpp \
${TOP_DIR}/RazeXR/TBXR_Common.cpp \
${TOP_DIR}/RazeXR/VrInputCommon.cpp \
${TOP_DIR}/RazeXR/VrInputDefault.cpp \
${TOP_DIR}/RazeXR/mathlib.c \
${TOP_DIR}/RazeXR/matrixlib.c \
${TOP_DIR}/RazeXR/argtable3.c \
${TOP_DIR}/RazeXR/OpenXRInput_MetaQuest.cpp \
${TOP_DIR}/RazeXR/OpenXRInput_PicoXR.cpp
SYSTEM_SOURCES = ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_UNIX_SOURCES}
#$(ANDROID_SRC_FILES) \
LOCAL_SRC_FILES = \
${ANDROID_SRC_FILES} \
${RAZEXR_SRC_FILES} \
${SYSTEM_SOURCES} \
${FASTMATH_SOURCES} \
${PCH_SOURCES} \
common/utility/x86.cpp \
common/thirdparty/strnatcmp.c \
common/utility/zstring.cpp \
common/utility/findfile.cpp \
common/thirdparty/math/asin.c \
common/thirdparty/math/atan.c \
common/thirdparty/math/const.c \
common/thirdparty/math/cosh.c \
common/thirdparty/math/exp.c \
common/thirdparty/math/isnan.c \
common/thirdparty/math/log.c \
common/thirdparty/math/log10.c \
common/thirdparty/math/mtherr.c \
common/thirdparty/math/polevl.c \
common/thirdparty/math/pow.c \
common/thirdparty/math/powi.c \
common/thirdparty/math/sin.c \
common/thirdparty/math/sinh.c \
common/thirdparty/math/sqrt.c \
common/thirdparty/math/tan.c \
common/thirdparty/math/tanh.c \
common/thirdparty/math/fastsin.cpp \
LOCAL_LDLIBS := -ldl -llog -lOpenSLES -landroid
LOCAL_LDLIBS += -lEGL -lGLESv3
LOCAL_STATIC_LIBRARIES := zlib_gl3 lzma_gl3 gdtoa_gl3 bzip2_gl3 jpeg vpx tess_gl3
LOCAL_SHARED_LIBRARIES := openxr_loader openal zmusic
include $(BUILD_SHARED_LIBRARY)
$(call import-module,OpenXR/Projects/AndroidPrebuilt/jni)

35
android/Android_tess.mk Normal file
View file

@ -0,0 +1,35 @@
LOCAL_PATH := $(call my-dir)/../libraries/libtess
include $(CLEAR_VARS)
LOCAL_MODULE := tess_gl3
LOCAL_CFLAGS :=
LOCAL_LDLIBS += -llog
LOCAL_C_INCLUDES := . $(GZDOOM_TOP_PATH)/android/src/extrafiles \
$(GZDOOM_TOP_PATH)/libraries/libtess/Include
LOCAL_SRC_FILES = \
Source/bucketalloc.c \
Source/dict.c \
Source/geom.c \
Source/mesh.c \
Source/priorityq.c \
Source/sweep.c \
Source/tess.c \
include $(BUILD_STATIC_LIBRARY)

8
android/Android_vpx.mk Normal file
View file

@ -0,0 +1,8 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := vpx
LOCAL_SRC_FILES := src/vpx/$(TARGET_ARCH_ABI)/lib/libvpx.a
include $(PREBUILT_STATIC_LIBRARY)

40
android/Android_zlib.mk Normal file
View file

@ -0,0 +1,40 @@
LOCAL_PATH := $(call my-dir)/../libraries/zlib
include $(CLEAR_VARS)
LOCAL_MODULE := zlib_gl3
LOCAL_CFLAGS = -Wall
LOCAL_LDLIBS += -llog
LOCAL_C_INCLUDES :=
LOCAL_SRC_FILES = \
adler32.c \
compress.c \
crc32.c \
deflate.c \
inflate.c \
infback.c \
inftrees.c \
inffast.c \
trees.c \
uncompr.c \
zutil.c \
include $(BUILD_STATIC_LIBRARY)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,2 @@
#define IEEE_8087
#define Arith_Kind_ASL 1

View file

@ -0,0 +1,671 @@
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "etc1.h"
#include <string.h>
/* From http://www.khronos.org/registry/gles/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt
The number of bits that represent a 4x4 texel block is 64 bits if
<internalformat> is given by ETC1_RGB8_OES.
The data for a block is a number of bytes,
{q0, q1, q2, q3, q4, q5, q6, q7}
where byte q0 is located at the lowest memory address and q7 at
the highest. The 64 bits specifying the block is then represented
by the following 64 bit integer:
int64bit = 256*(256*(256*(256*(256*(256*(256*q0+q1)+q2)+q3)+q4)+q5)+q6)+q7;
ETC1_RGB8_OES:
a) bit layout in bits 63 through 32 if diffbit = 0
63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48
-----------------------------------------------
| base col1 | base col2 | base col1 | base col2 |
| R1 (4bits)| R2 (4bits)| G1 (4bits)| G2 (4bits)|
-----------------------------------------------
47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32
---------------------------------------------------
| base col1 | base col2 | table | table |diff|flip|
| B1 (4bits)| B2 (4bits)| cw 1 | cw 2 |bit |bit |
---------------------------------------------------
b) bit layout in bits 63 through 32 if diffbit = 1
63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48
-----------------------------------------------
| base col1 | dcol 2 | base col1 | dcol 2 |
| R1' (5 bits) | dR2 | G1' (5 bits) | dG2 |
-----------------------------------------------
47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32
---------------------------------------------------
| base col 1 | dcol 2 | table | table |diff|flip|
| B1' (5 bits) | dB2 | cw 1 | cw 2 |bit |bit |
---------------------------------------------------
c) bit layout in bits 31 through 0 (in both cases)
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
-----------------------------------------------
| most significant pixel index bits |
| p| o| n| m| l| k| j| i| h| g| f| e| d| c| b| a|
-----------------------------------------------
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
--------------------------------------------------
| least significant pixel index bits |
| p| o| n| m| l| k| j| i| h| g| f| e| d| c | b | a |
--------------------------------------------------
Add table 3.17.2: Intensity modifier sets for ETC1 compressed textures:
table codeword modifier table
------------------ ----------------------
0 -8 -2 2 8
1 -17 -5 5 17
2 -29 -9 9 29
3 -42 -13 13 42
4 -60 -18 18 60
5 -80 -24 24 80
6 -106 -33 33 106
7 -183 -47 47 183
Add table 3.17.3 Mapping from pixel index values to modifier values for
ETC1 compressed textures:
pixel index value
---------------
msb lsb resulting modifier value
----- ----- -------------------------
1 1 -b (large negative value)
1 0 -a (small negative value)
0 0 a (small positive value)
0 1 b (large positive value)
*/
static const int kModifierTable[] = {
/* 0 */2, 8, -2, -8,
/* 1 */5, 17, -5, -17,
/* 2 */9, 29, -9, -29,
/* 3 */13, 42, -13, -42,
/* 4 */18, 60, -18, -60,
/* 5 */24, 80, -24, -80,
/* 6 */33, 106, -33, -106,
/* 7 */47, 183, -47, -183 };
static const int kLookup[8] = { 0, 1, 2, 3, -4, -3, -2, -1 };
static inline etc1_byte clamp(int x) {
return (etc1_byte) (x >= 0 ? (x < 255 ? x : 255) : 0);
}
static
inline int convert4To8(int b) {
int c = b & 0xf;
return (c << 4) | c;
}
static
inline int convert5To8(int b) {
int c = b & 0x1f;
return (c << 3) | (c >> 2);
}
static
inline int convert6To8(int b) {
int c = b & 0x3f;
return (c << 2) | (c >> 4);
}
static
inline int divideBy255(int d) {
return (d + 128 + (d >> 8)) >> 8;
}
static
inline int convert8To4(int b) {
int c = b & 0xff;
return divideBy255(c * 15);
}
static
inline int convert8To5(int b) {
int c = b & 0xff;
return divideBy255(c * 31);
}
static
inline int convertDiff(int base, int diff) {
return convert5To8((0x1f & base) + kLookup[0x7 & diff]);
}
static
void decode_subblock(etc1_byte* pOut, int r, int g, int b, const int* table,
etc1_uint32 low, bool second, bool flipped) {
int baseX = 0;
int baseY = 0;
if (second) {
if (flipped) {
baseY = 2;
} else {
baseX = 2;
}
}
for (int i = 0; i < 8; i++) {
int x, y;
if (flipped) {
x = baseX + (i >> 1);
y = baseY + (i & 1);
} else {
x = baseX + (i >> 2);
y = baseY + (i & 3);
}
int k = y + (x * 4);
int offset = ((low >> k) & 1) | ((low >> (k + 15)) & 2);
int delta = table[offset];
etc1_byte* q = pOut + 3 * (x + 4 * y);
*q++ = clamp(r + delta);
*q++ = clamp(g + delta);
*q++ = clamp(b + delta);
}
}
// Input is an ETC1 compressed version of the data.
// Output is a 4 x 4 square of 3-byte pixels in form R, G, B
void etc1_decode_block(const etc1_byte* pIn, etc1_byte* pOut) {
etc1_uint32 high = (pIn[0] << 24) | (pIn[1] << 16) | (pIn[2] << 8) | pIn[3];
etc1_uint32 low = (pIn[4] << 24) | (pIn[5] << 16) | (pIn[6] << 8) | pIn[7];
int r1, r2, g1, g2, b1, b2;
if (high & 2) {
// differential
int rBase = high >> 27;
int gBase = high >> 19;
int bBase = high >> 11;
r1 = convert5To8(rBase);
r2 = convertDiff(rBase, high >> 24);
g1 = convert5To8(gBase);
g2 = convertDiff(gBase, high >> 16);
b1 = convert5To8(bBase);
b2 = convertDiff(bBase, high >> 8);
} else {
// not differential
r1 = convert4To8(high >> 28);
r2 = convert4To8(high >> 24);
g1 = convert4To8(high >> 20);
g2 = convert4To8(high >> 16);
b1 = convert4To8(high >> 12);
b2 = convert4To8(high >> 8);
}
int tableIndexA = 7 & (high >> 5);
int tableIndexB = 7 & (high >> 2);
const int* tableA = kModifierTable + tableIndexA * 4;
const int* tableB = kModifierTable + tableIndexB * 4;
bool flipped = (high & 1) != 0;
decode_subblock(pOut, r1, g1, b1, tableA, low, false, flipped);
decode_subblock(pOut, r2, g2, b2, tableB, low, true, flipped);
}
typedef struct {
etc1_uint32 high;
etc1_uint32 low;
etc1_uint32 score; // Lower is more accurate
} etc_compressed;
static
inline void take_best(etc_compressed* a, const etc_compressed* b) {
if (a->score > b->score) {
*a = *b;
}
}
static
void etc_average_colors_subblock(const etc1_byte* pIn, etc1_uint32 inMask,
etc1_byte* pColors, bool flipped, bool second) {
int r = 0;
int g = 0;
int b = 0;
if (flipped) {
int by = 0;
if (second) {
by = 2;
}
for (int y = 0; y < 2; y++) {
int yy = by + y;
for (int x = 0; x < 4; x++) {
int i = x + 4 * yy;
if (inMask & (1 << i)) {
const etc1_byte* p = pIn + i * 3;
r += *(p++);
g += *(p++);
b += *(p++);
}
}
}
} else {
int bx = 0;
if (second) {
bx = 2;
}
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 2; x++) {
int xx = bx + x;
int i = xx + 4 * y;
if (inMask & (1 << i)) {
const etc1_byte* p = pIn + i * 3;
r += *(p++);
g += *(p++);
b += *(p++);
}
}
}
}
pColors[0] = (etc1_byte)((r + 4) >> 3);
pColors[1] = (etc1_byte)((g + 4) >> 3);
pColors[2] = (etc1_byte)((b + 4) >> 3);
}
static
inline int square(int x) {
return x * x;
}
static etc1_uint32 chooseModifier(const etc1_byte* pBaseColors,
const etc1_byte* pIn, etc1_uint32 *pLow, int bitIndex,
const int* pModifierTable) {
etc1_uint32 bestScore = ~0;
int bestIndex = 0;
int pixelR = pIn[0];
int pixelG = pIn[1];
int pixelB = pIn[2];
int r = pBaseColors[0];
int g = pBaseColors[1];
int b = pBaseColors[2];
for (int i = 0; i < 4; i++) {
int modifier = pModifierTable[i];
int decodedG = clamp(g + modifier);
etc1_uint32 score = (etc1_uint32) (6 * square(decodedG - pixelG));
if (score >= bestScore) {
continue;
}
int decodedR = clamp(r + modifier);
score += (etc1_uint32) (3 * square(decodedR - pixelR));
if (score >= bestScore) {
continue;
}
int decodedB = clamp(b + modifier);
score += (etc1_uint32) square(decodedB - pixelB);
if (score < bestScore) {
bestScore = score;
bestIndex = i;
}
}
etc1_uint32 lowMask = (((bestIndex >> 1) << 16) | (bestIndex & 1))
<< bitIndex;
*pLow |= lowMask;
return bestScore;
}
static
void etc_encode_subblock_helper(const etc1_byte* pIn, etc1_uint32 inMask,
etc_compressed* pCompressed, bool flipped, bool second,
const etc1_byte* pBaseColors, const int* pModifierTable) {
int score = pCompressed->score;
if (flipped) {
int by = 0;
if (second) {
by = 2;
}
for (int y = 0; y < 2; y++) {
int yy = by + y;
for (int x = 0; x < 4; x++) {
int i = x + 4 * yy;
if (inMask & (1 << i)) {
score += chooseModifier(pBaseColors, pIn + i * 3,
&pCompressed->low, yy + x * 4, pModifierTable);
}
}
}
} else {
int bx = 0;
if (second) {
bx = 2;
}
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 2; x++) {
int xx = bx + x;
int i = xx + 4 * y;
if (inMask & (1 << i)) {
score += chooseModifier(pBaseColors, pIn + i * 3,
&pCompressed->low, y + xx * 4, pModifierTable);
}
}
}
}
pCompressed->score = score;
}
static bool inRange4bitSigned(int color) {
return color >= -4 && color <= 3;
}
static void etc_encodeBaseColors(etc1_byte* pBaseColors,
const etc1_byte* pColors, etc_compressed* pCompressed) {
int r1, g1, b1, r2, g2, b2; // 8 bit base colors for sub-blocks
bool differential;
{
int r51 = convert8To5(pColors[0]);
int g51 = convert8To5(pColors[1]);
int b51 = convert8To5(pColors[2]);
int r52 = convert8To5(pColors[3]);
int g52 = convert8To5(pColors[4]);
int b52 = convert8To5(pColors[5]);
r1 = convert5To8(r51);
g1 = convert5To8(g51);
b1 = convert5To8(b51);
int dr = r52 - r51;
int dg = g52 - g51;
int db = b52 - b51;
differential = inRange4bitSigned(dr) && inRange4bitSigned(dg)
&& inRange4bitSigned(db);
if (differential) {
r2 = convert5To8(r51 + dr);
g2 = convert5To8(g51 + dg);
b2 = convert5To8(b51 + db);
pCompressed->high |= (r51 << 27) | ((7 & dr) << 24) | (g51 << 19)
| ((7 & dg) << 16) | (b51 << 11) | ((7 & db) << 8) | 2;
}
}
if (!differential) {
int r41 = convert8To4(pColors[0]);
int g41 = convert8To4(pColors[1]);
int b41 = convert8To4(pColors[2]);
int r42 = convert8To4(pColors[3]);
int g42 = convert8To4(pColors[4]);
int b42 = convert8To4(pColors[5]);
r1 = convert4To8(r41);
g1 = convert4To8(g41);
b1 = convert4To8(b41);
r2 = convert4To8(r42);
g2 = convert4To8(g42);
b2 = convert4To8(b42);
pCompressed->high |= (r41 << 28) | (r42 << 24) | (g41 << 20) | (g42
<< 16) | (b41 << 12) | (b42 << 8);
}
pBaseColors[0] = r1;
pBaseColors[1] = g1;
pBaseColors[2] = b1;
pBaseColors[3] = r2;
pBaseColors[4] = g2;
pBaseColors[5] = b2;
}
static
void etc_encode_block_helper(const etc1_byte* pIn, etc1_uint32 inMask,
const etc1_byte* pColors, etc_compressed* pCompressed, bool flipped) {
pCompressed->score = ~0;
pCompressed->high = (flipped ? 1 : 0);
pCompressed->low = 0;
etc1_byte pBaseColors[6];
etc_encodeBaseColors(pBaseColors, pColors, pCompressed);
int originalHigh = pCompressed->high;
const int* pModifierTable = kModifierTable;
for (int i = 0; i < 8; i++, pModifierTable += 4) {
etc_compressed temp;
temp.score = 0;
temp.high = originalHigh | (i << 5);
temp.low = 0;
etc_encode_subblock_helper(pIn, inMask, &temp, flipped, false,
pBaseColors, pModifierTable);
take_best(pCompressed, &temp);
}
pModifierTable = kModifierTable;
etc_compressed firstHalf = *pCompressed;
for (int i = 0; i < 8; i++, pModifierTable += 4) {
etc_compressed temp;
temp.score = firstHalf.score;
temp.high = firstHalf.high | (i << 2);
temp.low = firstHalf.low;
etc_encode_subblock_helper(pIn, inMask, &temp, flipped, true,
pBaseColors + 3, pModifierTable);
if (i == 0) {
*pCompressed = temp;
} else {
take_best(pCompressed, &temp);
}
}
}
static void writeBigEndian(etc1_byte* pOut, etc1_uint32 d) {
pOut[0] = (etc1_byte)(d >> 24);
pOut[1] = (etc1_byte)(d >> 16);
pOut[2] = (etc1_byte)(d >> 8);
pOut[3] = (etc1_byte) d;
}
// Input is a 4 x 4 square of 3-byte pixels in form R, G, B
// inmask is a 16-bit mask where bit (1 << (x + y * 4)) tells whether the corresponding (x,y)
// pixel is valid or not. Invalid pixel color values are ignored when compressing.
// Output is an ETC1 compressed version of the data.
void etc1_encode_block(const etc1_byte* pIn, etc1_uint32 inMask,
etc1_byte* pOut) {
etc1_byte colors[6];
etc1_byte flippedColors[6];
etc_average_colors_subblock(pIn, inMask, colors, false, false);
etc_average_colors_subblock(pIn, inMask, colors + 3, false, true);
etc_average_colors_subblock(pIn, inMask, flippedColors, true, false);
etc_average_colors_subblock(pIn, inMask, flippedColors + 3, true, true);
etc_compressed a, b;
etc_encode_block_helper(pIn, inMask, colors, &a, false);
etc_encode_block_helper(pIn, inMask, flippedColors, &b, true);
take_best(&a, &b);
writeBigEndian(pOut, a.high);
writeBigEndian(pOut + 4, a.low);
}
// Return the size of the encoded image data (does not include size of PKM header).
etc1_uint32 etc1_get_encoded_data_size(etc1_uint32 width, etc1_uint32 height) {
return (((width + 3) & ~3) * ((height + 3) & ~3)) >> 1;
}
// Encode an entire image.
// pIn - pointer to the image data. Formatted such that the Red component of
// pixel (x,y) is at pIn + pixelSize * x + stride * y + redOffset;
// pOut - pointer to encoded data. Must be large enough to store entire encoded image.
int etc1_encode_image(const etc1_byte* pIn, etc1_uint32 width, etc1_uint32 height,
etc1_uint32 pixelSize, etc1_uint32 stride, etc1_byte* pOut) {
if (pixelSize < 2 || pixelSize > 3) {
return -1;
}
static const unsigned short kYMask[] = { 0x0, 0xf, 0xff, 0xfff, 0xffff };
static const unsigned short kXMask[] = { 0x0, 0x1111, 0x3333, 0x7777,
0xffff };
etc1_byte block[ETC1_DECODED_BLOCK_SIZE];
etc1_byte encoded[ETC1_ENCODED_BLOCK_SIZE];
etc1_uint32 encodedWidth = (width + 3) & ~3;
etc1_uint32 encodedHeight = (height + 3) & ~3;
for (etc1_uint32 y = 0; y < encodedHeight; y += 4) {
etc1_uint32 yEnd = height - y;
if (yEnd > 4) {
yEnd = 4;
}
int ymask = kYMask[yEnd];
for (etc1_uint32 x = 0; x < encodedWidth; x += 4) {
etc1_uint32 xEnd = width - x;
if (xEnd > 4) {
xEnd = 4;
}
int mask = ymask & kXMask[xEnd];
for (etc1_uint32 cy = 0; cy < yEnd; cy++) {
etc1_byte* q = block + (cy * 4) * 3;
const etc1_byte* p = pIn + pixelSize * x + stride * (y + cy);
if (pixelSize == 3) {
memcpy(q, p, xEnd * 3);
} else {
for (etc1_uint32 cx = 0; cx < xEnd; cx++) {
int pixel = (p[1] << 8) | p[0];
*q++ = convert5To8(pixel >> 11);
*q++ = convert6To8(pixel >> 5);
*q++ = convert5To8(pixel);
p += pixelSize;
}
}
}
etc1_encode_block(block, mask, encoded);
memcpy(pOut, encoded, sizeof(encoded));
pOut += sizeof(encoded);
}
}
return 0;
}
// Decode an entire image.
// pIn - pointer to encoded data.
// pOut - pointer to the image data. Will be written such that the Red component of
// pixel (x,y) is at pIn + pixelSize * x + stride * y + redOffset. Must be
// large enough to store entire image.
int etc1_decode_image(const etc1_byte* pIn, etc1_byte* pOut,
etc1_uint32 width, etc1_uint32 height,
etc1_uint32 pixelSize, etc1_uint32 stride) {
if (pixelSize < 2 || pixelSize > 3) {
return -1;
}
etc1_byte block[ETC1_DECODED_BLOCK_SIZE];
etc1_uint32 encodedWidth = (width + 3) & ~3;
etc1_uint32 encodedHeight = (height + 3) & ~3;
for (etc1_uint32 y = 0; y < encodedHeight; y += 4) {
etc1_uint32 yEnd = height - y;
if (yEnd > 4) {
yEnd = 4;
}
for (etc1_uint32 x = 0; x < encodedWidth; x += 4) {
etc1_uint32 xEnd = width - x;
if (xEnd > 4) {
xEnd = 4;
}
etc1_decode_block(pIn, block);
pIn += ETC1_ENCODED_BLOCK_SIZE;
for (etc1_uint32 cy = 0; cy < yEnd; cy++) {
const etc1_byte* q = block + (cy * 4) * 3;
etc1_byte* p = pOut + pixelSize * x + stride * (y + cy);
if (pixelSize == 3) {
memcpy(p, q, xEnd * 3);
}
else {
for (etc1_uint32 cx = 0; cx < xEnd; cx++) {
etc1_byte r = *q++;
etc1_byte g = *q++;
etc1_byte b = *q++;
etc1_uint32 pixel = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
*p++ = (etc1_byte) pixel;
*p++ = (etc1_byte) (pixel >> 8);
}
}
}
}
}
return 0;
}
static const char kMagic[] = { 'P', 'K', 'M', ' ', '1', '0' };
static const etc1_uint32 ETC1_PKM_FORMAT_OFFSET = 6;
static const etc1_uint32 ETC1_PKM_ENCODED_WIDTH_OFFSET = 8;
static const etc1_uint32 ETC1_PKM_ENCODED_HEIGHT_OFFSET = 10;
static const etc1_uint32 ETC1_PKM_WIDTH_OFFSET = 12;
static const etc1_uint32 ETC1_PKM_HEIGHT_OFFSET = 14;
static const etc1_uint32 ETC1_RGB_NO_MIPMAPS = 0;
static void writeBEUint16(etc1_byte* pOut, etc1_uint32 data) {
pOut[0] = (etc1_byte) (data >> 8);
pOut[1] = (etc1_byte) data;
}
static etc1_uint32 readBEUint16(const etc1_byte* pIn) {
return (pIn[0] << 8) | pIn[1];
}
// Format a PKM header
void etc1_pkm_format_header(etc1_byte* pHeader, etc1_uint32 width, etc1_uint32 height) {
memcpy(pHeader, kMagic, sizeof(kMagic));
etc1_uint32 encodedWidth = (width + 3) & ~3;
etc1_uint32 encodedHeight = (height + 3) & ~3;
writeBEUint16(pHeader + ETC1_PKM_FORMAT_OFFSET, ETC1_RGB_NO_MIPMAPS);
writeBEUint16(pHeader + ETC1_PKM_ENCODED_WIDTH_OFFSET, encodedWidth);
writeBEUint16(pHeader + ETC1_PKM_ENCODED_HEIGHT_OFFSET, encodedHeight);
writeBEUint16(pHeader + ETC1_PKM_WIDTH_OFFSET, width);
writeBEUint16(pHeader + ETC1_PKM_HEIGHT_OFFSET, height);
}
// Check if a PKM header is correctly formatted.
etc1_bool etc1_pkm_is_valid(const etc1_byte* pHeader) {
if (memcmp(pHeader, kMagic, sizeof(kMagic))) {
return false;
}
etc1_uint32 format = readBEUint16(pHeader + ETC1_PKM_FORMAT_OFFSET);
etc1_uint32 encodedWidth = readBEUint16(pHeader + ETC1_PKM_ENCODED_WIDTH_OFFSET);
etc1_uint32 encodedHeight = readBEUint16(pHeader + ETC1_PKM_ENCODED_HEIGHT_OFFSET);
etc1_uint32 width = readBEUint16(pHeader + ETC1_PKM_WIDTH_OFFSET);
etc1_uint32 height = readBEUint16(pHeader + ETC1_PKM_HEIGHT_OFFSET);
return format == ETC1_RGB_NO_MIPMAPS &&
encodedWidth >= width && encodedWidth - width < 4 &&
encodedHeight >= height && encodedHeight - height < 4;
}
// Read the image width from a PKM header
etc1_uint32 etc1_pkm_get_width(const etc1_byte* pHeader) {
return readBEUint16(pHeader + ETC1_PKM_WIDTH_OFFSET);
}
// Read the image height from a PKM header
etc1_uint32 etc1_pkm_get_height(const etc1_byte* pHeader){
return readBEUint16(pHeader + ETC1_PKM_HEIGHT_OFFSET);
}

View file

@ -0,0 +1,106 @@
// Copyright 2009 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef __etc1_h__
#define __etc1_h__
#define ETC1_ENCODED_BLOCK_SIZE 8
#define ETC1_DECODED_BLOCK_SIZE 48
#ifndef ETC1_RGB8_OES
#define ETC1_RGB8_OES 0x8D64
#endif
typedef unsigned char etc1_byte;
typedef int etc1_bool;
typedef unsigned int etc1_uint32;
#ifdef __cplusplus
extern "C" {
#endif
// Encode a block of pixels.
//
// pIn is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a
// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R
// value of pixel (x, y).
//
// validPixelMask is a 16-bit mask where bit (1 << (x + y * 4)) indicates whether
// the corresponding (x,y) pixel is valid. Invalid pixel color values are ignored when compressing.
//
// pOut is an ETC1 compressed version of the data.
void etc1_encode_block(const etc1_byte* pIn, etc1_uint32 validPixelMask, etc1_byte* pOut);
// Decode a block of pixels.
//
// pIn is an ETC1 compressed version of the data.
//
// pOut is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a
// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R
// value of pixel (x, y).
void etc1_decode_block(const etc1_byte* pIn, etc1_byte* pOut);
// Return the size of the encoded image data (does not include size of PKM header).
etc1_uint32 etc1_get_encoded_data_size(etc1_uint32 width, etc1_uint32 height);
// Encode an entire image.
// pIn - pointer to the image data. Formatted such that
// pixel (x,y) is at pIn + pixelSize * x + stride * y;
// pOut - pointer to encoded data. Must be large enough to store entire encoded image.
// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
// returns non-zero if there is an error.
int etc1_encode_image(const etc1_byte* pIn, etc1_uint32 width, etc1_uint32 height,
etc1_uint32 pixelSize, etc1_uint32 stride, etc1_byte* pOut);
// Decode an entire image.
// pIn - pointer to encoded data.
// pOut - pointer to the image data. Will be written such that
// pixel (x,y) is at pIn + pixelSize * x + stride * y. Must be
// large enough to store entire image.
// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
// returns non-zero if there is an error.
int etc1_decode_image(const etc1_byte* pIn, etc1_byte* pOut,
etc1_uint32 width, etc1_uint32 height,
etc1_uint32 pixelSize, etc1_uint32 stride);
// Size of a PKM header, in bytes.
#define ETC_PKM_HEADER_SIZE 16
// Format a PKM header
void etc1_pkm_format_header(etc1_byte* pHeader, etc1_uint32 width, etc1_uint32 height);
// Check if a PKM header is correctly formatted.
etc1_bool etc1_pkm_is_valid(const etc1_byte* pHeader);
// Read the image width from a PKM header
etc1_uint32 etc1_pkm_get_width(const etc1_byte* pHeader);
// Read the image height from a PKM header
etc1_uint32 etc1_pkm_get_height(const etc1_byte* pHeader);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,12 @@
#define f_QNAN 0x7fc00000
#define d_QNAN0 0x0
#define d_QNAN1 0x7ff80000
#define ld_QNAN0 0x0
#define ld_QNAN1 0xc0000000
#define ld_QNAN2 0x7fff
#define ld_QNAN3 0x0
#define ldus_QNAN0 0x0
#define ldus_QNAN1 0x0
#define ldus_QNAN2 0x0
#define ldus_QNAN3 0xc000
#define ldus_QNAN4 0x7fff

View file

@ -0,0 +1,3 @@
#define GIT_DESCRIPTION ""
#define GIT_HASH ""
#define GIT_TIME ""

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,228 @@
/*
** i_specialpaths.cpp
** Gets special system folders where data should be stored. (Unix version)
**
**---------------------------------------------------------------------------
** Copyright 2013-2016 Randy Heit
** Copyright 2016 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** 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 <sys/stat.h>
#include <sys/types.h>
#include "i_system.h"
#include "cmdlib.h"
#include "doomerrors.h"
#include "version.h" // for GAMENAME
FString GetUserFile (const char *file)
{
FString path;
struct stat info;
path = NicePath("$HOME/" GAME_DIR "/");
if (stat (path, &info) == -1)
{
struct stat extrainfo;
// Sanity check for $HOME/.config
FString configPath = NicePath("$HOME/.config/");
if (stat (configPath, &extrainfo) == -1)
{
if (mkdir (configPath, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
{
I_FatalError ("Failed to create $HOME/.config directory:\n%s", strerror(errno));
}
}
else if (!S_ISDIR(extrainfo.st_mode))
{
I_FatalError ("$HOME/.config must be a directory");
}
// This can be removed after a release or two
// Transfer the old zdoom directory to the new location
bool moved = false;
FString oldpath = NicePath("$HOME/." GAMENAMELOWERCASE "/");
if (stat (oldpath, &extrainfo) != -1)
{
if (rename(oldpath, path) == -1)
{
I_Error ("Failed to move old " GAMENAMELOWERCASE " directory (%s) to new location (%s).",
oldpath.GetChars(), path.GetChars());
}
else
moved = true;
}
if (!moved && mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR) == -1)
{
I_FatalError ("Failed to create %s directory:\n%s",
path.GetChars(), strerror (errno));
}
}
else
{
if (!S_ISDIR(info.st_mode))
{
I_FatalError ("%s must be a directory", path.GetChars());
}
}
path += file;
return path;
}
//===========================================================================
//
// M_GetAppDataPath Unix
//
// Returns the path for the AppData folder.
//
//===========================================================================
FString M_GetAppDataPath(bool create)
{
// Don't use GAME_DIR and such so that ZDoom and its child ports can
// share the node cache.
FString path = NicePath("$HOME/.config/" GAMENAMELOWERCASE);
if (create)
{
CreatePath(path);
}
return path;
}
//===========================================================================
//
// M_GetCachePath Unix
//
// Returns the path for cache GL nodes.
//
//===========================================================================
FString M_GetCachePath(bool create)
{
// Don't use GAME_DIR and such so that ZDoom and its child ports can
// share the node cache.
FString path = NicePath("$HOME/.config/zdoom/cache");
if (create)
{
CreatePath(path);
}
return path;
}
//===========================================================================
//
// M_GetAutoexecPath Unix
//
// Returns the expected location of autoexec.cfg.
//
//===========================================================================
FString M_GetAutoexecPath()
{
return GetUserFile("autoexec.cfg");
}
//===========================================================================
//
// M_GetCajunPath Unix
//
// Returns the location of the Cajun Bot definitions.
//
//===========================================================================
FString M_GetCajunPath(const char *botfilename)
{
FString path = NicePath("./user_files/bots/");
path << botfilename;
if (!FileExists(path))
{
path = "";
}
return path;
}
//===========================================================================
//
// M_GetConfigPath Unix
//
// Returns the path to the config file. On Windows, this can vary for reading
// vs writing. i.e. If $PROGDIR/zdoom-<user>.ini does not exist, it will try
// to read from $PROGDIR/zdoom.ini, but it will never write to zdoom.ini.
//
//===========================================================================
FString M_GetConfigPath(bool for_reading)
{
return GetUserFile(GAMENAMELOWERCASE ".ini");
}
//===========================================================================
//
// M_GetScreenshotsPath Unix
//
// Returns the path to the default screenshots directory.
//
//===========================================================================
FString M_GetScreenshotsPath()
{
return NicePath("$HOME/" GAME_DIR "/screenshots/");
}
//===========================================================================
//
// M_GetSavegamesPath Unix
//
// Returns the path to the default save games directory.
//
//===========================================================================
FString M_GetSavegamesPath()
{
return NicePath("$HOME/" GAME_DIR);
}
//===========================================================================
//
// M_GetDocumentsPath Unix
//
// Returns the path to the default documents directory.
//
//===========================================================================
FString M_GetDocumentsPath()
{
return NicePath("$HOME/" GAME_DIR);
}

View file

@ -0,0 +1,191 @@
/*
** i_specialpaths.cpp
** Gets special system folders where data should be stored. (Unix version)
**
**---------------------------------------------------------------------------
** Copyright 2013-2016 Randy Heit
** Copyright 2016 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** 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 <sys/stat.h>
#include <sys/types.h>
#include "i_system.h"
#include "cmdlib.h"
#include "version.h" // for GAMENAME
const char *userFilesPath_c = "/sdcard/RazeXR";
FString M_GetAppDataPath(bool create)
{
// Don't use GAME_DIR and such so that ZDoom and its child ports can
// share the node cache.
FString path = NicePath(FStringf("%s/%s", userFilesPath_c, GAMENAMELOWERCASE));
if (create)
{
CreatePath(path);
}
return path;
}
FString GetUserFile (const char *file)
{
FString path;
struct stat info;
path = NicePath(FStringf("%s/raze/config/", userFilesPath_c));
if (stat (path, &info) == -1)
{
CreatePath(path);
}
mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR);
path += file;
return path;
}
//===========================================================================
//
// M_GetCachePath Unix
//
// Returns the path for cache GL nodes.
//
//===========================================================================
FString M_GetCachePath(bool create)
{
// Don't use GAME_DIR and such so that ZDoom and its child ports can
// share the node cache.
FString path = NicePath(FStringf("%s/raze/cache/", userFilesPath_c));
if (create)
{
CreatePath(path);
}
return path;
}
//===========================================================================
//
// M_GetAutoexecPath Unix
//
// Returns the expected location of autoexec.cfg.
//
//===========================================================================
FString M_GetAutoexecPath()
{
return GetUserFile("autoexec.cfg");
}
//===========================================================================
//
// M_GetConfigPath Unix
//
// Returns the path to the config file. On Windows, this can vary for reading
// vs writing. i.e. If $PROGDIR/zdoom-<user>.ini does not exist, it will try
// to read from $PROGDIR/zdoom.ini, but it will never write to zdoom.ini.
//
//===========================================================================
FString M_GetConfigPath(bool for_reading)
{
return GetUserFile(GAMENAMELOWERCASE ".ini");
}
//===========================================================================
//
// M_GetScreenshotsPath Unix
//
// Returns the path to the default screenshots directory.
//
//===========================================================================
FString M_GetScreenshotsPath()
{
return NicePath(FStringf("%s/raze/screenshots/", userFilesPath_c));
}
//===========================================================================
//
// M_GetSavegamesPath Unix
//
// Returns the path to the default save games directory.
//
//===========================================================================
FString M_GetSavegamesPath()
{
return NicePath(FStringf("%s/raze/saves/", userFilesPath_c));
}
//===========================================================================
//
// M_GetDocumentsPath Unix
//
// Returns the path to the default documents directory.
//
//===========================================================================
FString M_GetDocumentsPath()
{
return NicePath(FStringf("%s/raze/", userFilesPath_c));
}
//===========================================================================
//
// M_GetDemoPath Unix
//
// Returns the path to the default demo directory.
//
//===========================================================================
FString M_GetDemoPath()
{
return NicePath(FStringf("%s/raze/demos", userFilesPath_c));
}
//===========================================================================
//
// M_NormalizedPath
//
// Normalizes the given path and returns the result.
//
//===========================================================================
FString M_GetNormalizedPath(const char* path)
{
char *actualpath;
actualpath = realpath(path, NULL);
if (!actualpath) // error ?
return nullptr;
FString fullpath = actualpath;
return fullpath;
}

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,136 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*!\defgroup vp8 VP8
* \ingroup codecs
* VP8 is a video compression algorithm that uses motion
* compensated prediction, Discrete Cosine Transform (DCT) coding of the
* prediction error signal and context dependent entropy coding techniques
* based on arithmetic principles. It features:
* - YUV 4:2:0 image format
* - Macro-block based coding (16x16 luma plus two 8x8 chroma)
* - 1/4 (1/8) pixel accuracy motion compensated prediction
* - 4x4 DCT transform
* - 128 level linear quantizer
* - In loop deblocking filter
* - Context-based entropy coding
*
* @{
*/
/*!\file
* \brief Provides controls common to both the VP8 encoder and decoder.
*/
#ifndef VPX_VPX_VP8_H_
#define VPX_VPX_VP8_H_
#include "./vpx_codec.h"
#include "./vpx_image.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!\brief Control functions
*
* The set of macros define the control functions of VP8 interface
*/
enum vp8_com_control_id {
/*!\brief pass in an external frame into decoder to be used as reference frame
*/
VP8_SET_REFERENCE = 1,
VP8_COPY_REFERENCE = 2, /**< get a copy of reference frame from the decoder */
VP8_SET_POSTPROC = 3, /**< set the decoder's post processing settings */
/* TODO(jkoleszar): The encoder incorrectly reuses some of these values (5+)
* for its control ids. These should be migrated to something like the
* VP8_DECODER_CTRL_ID_START range next time we're ready to break the ABI.
*/
VP9_GET_REFERENCE = 128, /**< get a pointer to a reference frame */
VP8_COMMON_CTRL_ID_MAX,
VP8_DECODER_CTRL_ID_START = 256
};
/*!\brief post process flags
*
* The set of macros define VP8 decoder post processing flags
*/
enum vp8_postproc_level {
VP8_NOFILTERING = 0,
VP8_DEBLOCK = 1 << 0,
VP8_DEMACROBLOCK = 1 << 1,
VP8_ADDNOISE = 1 << 2,
VP8_MFQE = 1 << 3
};
/*!\brief post process flags
*
* This define a structure that describe the post processing settings. For
* the best objective measure (using the PSNR metric) set post_proc_flag
* to VP8_DEBLOCK and deblocking_level to 1.
*/
typedef struct vp8_postproc_cfg {
/*!\brief the types of post processing to be done, should be combination of
* "vp8_postproc_level" */
int post_proc_flag;
int deblocking_level; /**< the strength of deblocking, valid range [0, 16] */
int noise_level; /**< the strength of additive noise, valid range [0, 16] */
} vp8_postproc_cfg_t;
/*!\brief reference frame type
*
* The set of macros define the type of VP8 reference frames
*/
typedef enum vpx_ref_frame_type {
VP8_LAST_FRAME = 1,
VP8_GOLD_FRAME = 2,
VP8_ALTR_FRAME = 4
} vpx_ref_frame_type_t;
/*!\brief reference frame data struct
*
* Define the data struct to access vp8 reference frames.
*/
typedef struct vpx_ref_frame {
vpx_ref_frame_type_t frame_type; /**< which reference frame */
vpx_image_t img; /**< reference frame data in image format */
} vpx_ref_frame_t;
/*!\brief VP9 specific reference frame data struct
*
* Define the data struct to access vp9 reference frames.
*/
typedef struct vp9_ref_frame {
int idx; /**< frame index to get (input) */
vpx_image_t img; /**< img structure to populate (output) */
} vp9_ref_frame_t;
/*!\cond */
/*!\brief vp8 decoder control function parameter type
*
* defines the data type for each of VP8 decoder control function requires
*/
VPX_CTRL_USE_TYPE(VP8_SET_REFERENCE, vpx_ref_frame_t *)
#define VPX_CTRL_VP8_SET_REFERENCE
VPX_CTRL_USE_TYPE(VP8_COPY_REFERENCE, vpx_ref_frame_t *)
#define VPX_CTRL_VP8_COPY_REFERENCE
VPX_CTRL_USE_TYPE(VP8_SET_POSTPROC, vp8_postproc_cfg_t *)
#define VPX_CTRL_VP8_SET_POSTPROC
VPX_CTRL_USE_TYPE(VP9_GET_REFERENCE, vp9_ref_frame_t *)
#define VPX_CTRL_VP9_GET_REFERENCE
/*!\endcond */
/*! @} - end defgroup vp8 */
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VPX_VPX_VP8_H_

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,210 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*!\defgroup vp8_decoder WebM VP8/VP9 Decoder
* \ingroup vp8
*
* @{
*/
/*!\file
* \brief Provides definitions for using VP8 or VP9 within the vpx Decoder
* interface.
*/
#ifndef VPX_VPX_VP8DX_H_
#define VPX_VPX_VP8DX_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Include controls common to both the encoder and decoder */
#include "./vp8.h"
/*!\name Algorithm interface for VP8
*
* This interface provides the capability to decode VP8 streams.
* @{
*/
extern vpx_codec_iface_t vpx_codec_vp8_dx_algo;
extern vpx_codec_iface_t *vpx_codec_vp8_dx(void);
/*!@} - end algorithm interface member group*/
/*!\name Algorithm interface for VP9
*
* This interface provides the capability to decode VP9 streams.
* @{
*/
extern vpx_codec_iface_t vpx_codec_vp9_dx_algo;
extern vpx_codec_iface_t *vpx_codec_vp9_dx(void);
/*!@} - end algorithm interface member group*/
/*!\enum vp8_dec_control_id
* \brief VP8 decoder control functions
*
* This set of macros define the control functions available for the VP8
* decoder interface.
*
* \sa #vpx_codec_control
*/
enum vp8_dec_control_id {
/** control function to get info on which reference frames were updated
* by the last decode
*/
VP8D_GET_LAST_REF_UPDATES = VP8_DECODER_CTRL_ID_START,
/** check if the indicated frame is corrupted */
VP8D_GET_FRAME_CORRUPTED,
/** control function to get info on which reference frames were used
* by the last decode
*/
VP8D_GET_LAST_REF_USED,
/** decryption function to decrypt encoded buffer data immediately
* before decoding. Takes a vpx_decrypt_init, which contains
* a callback function and opaque context pointer.
*/
VPXD_SET_DECRYPTOR,
VP8D_SET_DECRYPTOR = VPXD_SET_DECRYPTOR,
/** control function to get the dimensions that the current frame is decoded
* at. This may be different to the intended display size for the frame as
* specified in the wrapper or frame header (see VP9D_GET_DISPLAY_SIZE). */
VP9D_GET_FRAME_SIZE,
/** control function to get the current frame's intended display dimensions
* (as specified in the wrapper or frame header). This may be different to
* the decoded dimensions of this frame (see VP9D_GET_FRAME_SIZE). */
VP9D_GET_DISPLAY_SIZE,
/** control function to get the bit depth of the stream. */
VP9D_GET_BIT_DEPTH,
/** control function to set the byte alignment of the planes in the reference
* buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
* legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
* follows Y plane, and V plane directly follows U plane. Default value is 0.
*/
VP9_SET_BYTE_ALIGNMENT,
/** control function to invert the decoding order to from right to left. The
* function is used in a test to confirm the decoding independence of tile
* columns. The function may be used in application where this order
* of decoding is desired.
*
* TODO(yaowu): Rework the unit test that uses this control, and in a future
* release, this test-only control shall be removed.
*/
VP9_INVERT_TILE_DECODE_ORDER,
/** control function to set the skip loop filter flag. Valid values are
* integers. The decoder will skip the loop filter when its value is set to
* nonzero. If the loop filter is skipped the decoder may accumulate decode
* artifacts. The default value is 0.
*/
VP9_SET_SKIP_LOOP_FILTER,
/** control function to decode SVC stream up to the x spatial layers,
* where x is passed in through the control, and is 0 for base layer.
*/
VP9_DECODE_SVC_SPATIAL_LAYER,
/*!\brief Codec control function to get last decoded frame quantizer.
*
* Return value uses internal quantizer scale defined by the codec.
*
* Supported in codecs: VP8, VP9
*/
VPXD_GET_LAST_QUANTIZER,
/*!\brief Codec control function to set row level multi-threading.
*
* 0 : off, 1 : on
*
* Supported in codecs: VP9
*/
VP9D_SET_ROW_MT,
/*!\brief Codec control function to set loopfilter optimization.
*
* 0 : off, Loop filter is done after all tiles have been decoded
* 1 : on, Loop filter is done immediately after decode without
* waiting for all threads to sync.
*
* Supported in codecs: VP9
*/
VP9D_SET_LOOP_FILTER_OPT,
VP8_DECODER_CTRL_ID_MAX
};
/** Decrypt n bytes of data from input -> output, using the decrypt_state
* passed in VPXD_SET_DECRYPTOR.
*/
typedef void (*vpx_decrypt_cb)(void *decrypt_state, const unsigned char *input,
unsigned char *output, int count);
/*!\brief Structure to hold decryption state
*
* Defines a structure to hold the decryption state and access function.
*/
typedef struct vpx_decrypt_init {
/*! Decrypt callback. */
vpx_decrypt_cb decrypt_cb;
/*! Decryption state. */
void *decrypt_state;
} vpx_decrypt_init;
/*!\cond */
/*!\brief VP8 decoder control function parameter type
*
* Defines the data types that VP8D control functions take. Note that
* additional common controls are defined in vp8.h
*
*/
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_UPDATES, int *)
#define VPX_CTRL_VP8D_GET_LAST_REF_UPDATES
VPX_CTRL_USE_TYPE(VP8D_GET_FRAME_CORRUPTED, int *)
#define VPX_CTRL_VP8D_GET_FRAME_CORRUPTED
VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *)
#define VPX_CTRL_VP8D_GET_LAST_REF_USED
VPX_CTRL_USE_TYPE(VPXD_GET_LAST_QUANTIZER, int *)
#define VPX_CTRL_VPXD_GET_LAST_QUANTIZER
VPX_CTRL_USE_TYPE(VPXD_SET_DECRYPTOR, vpx_decrypt_init *)
#define VPX_CTRL_VPXD_SET_DECRYPTOR
VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vpx_decrypt_init *)
#define VPX_CTRL_VP8D_SET_DECRYPTOR
VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *)
#define VPX_CTRL_VP9D_GET_DISPLAY_SIZE
VPX_CTRL_USE_TYPE(VP9D_GET_BIT_DEPTH, unsigned int *)
#define VPX_CTRL_VP9D_GET_BIT_DEPTH
VPX_CTRL_USE_TYPE(VP9D_GET_FRAME_SIZE, int *)
#define VPX_CTRL_VP9D_GET_FRAME_SIZE
VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int)
#define VPX_CTRL_VP9_INVERT_TILE_DECODE_ORDER
#define VPX_CTRL_VP9_DECODE_SVC_SPATIAL_LAYER
VPX_CTRL_USE_TYPE(VP9_DECODE_SVC_SPATIAL_LAYER, int)
#define VPX_CTRL_VP9_SET_SKIP_LOOP_FILTER
VPX_CTRL_USE_TYPE(VP9_SET_SKIP_LOOP_FILTER, int)
#define VPX_CTRL_VP9_DECODE_SET_ROW_MT
VPX_CTRL_USE_TYPE(VP9D_SET_ROW_MT, int)
#define VPX_CTRL_VP9_SET_LOOP_FILTER_OPT
VPX_CTRL_USE_TYPE(VP9D_SET_LOOP_FILTER_OPT, int)
/*!\endcond */
/*! @} - end defgroup vp8_decoder */
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VPX_VPX_VP8DX_H_

View file

@ -0,0 +1,468 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*!\defgroup codec Common Algorithm Interface
* This abstraction allows applications to easily support multiple video
* formats with minimal code duplication. This section describes the interface
* common to all codecs (both encoders and decoders).
* @{
*/
/*!\file
* \brief Describes the codec algorithm interface to applications.
*
* This file describes the interface between an application and a
* video codec algorithm.
*
* An application instantiates a specific codec instance by using
* vpx_codec_init() and a pointer to the algorithm's interface structure:
* <pre>
* my_app.c:
* extern vpx_codec_iface_t my_codec;
* {
* vpx_codec_ctx_t algo;
* res = vpx_codec_init(&algo, &my_codec);
* }
* </pre>
*
* Once initialized, the instance is manged using other functions from
* the vpx_codec_* family.
*/
#ifndef VPX_VPX_VPX_CODEC_H_
#define VPX_VPX_VPX_CODEC_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "./vpx_image.h"
#include "./vpx_integer.h"
/*!\brief Decorator indicating a function is deprecated */
#ifndef VPX_DEPRECATED
#if defined(__GNUC__) && __GNUC__
#define VPX_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#define VPX_DEPRECATED
#else
#define VPX_DEPRECATED
#endif
#endif /* VPX_DEPRECATED */
#ifndef VPX_DECLSPEC_DEPRECATED
#if defined(__GNUC__) && __GNUC__
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
#elif defined(_MSC_VER)
/*!\brief \copydoc #VPX_DEPRECATED */
#define VPX_DECLSPEC_DEPRECATED __declspec(deprecated)
#else
#define VPX_DECLSPEC_DEPRECATED /**< \copydoc #VPX_DEPRECATED */
#endif
#endif /* VPX_DECLSPEC_DEPRECATED */
/*!\brief Decorator indicating a function is potentially unused */
#ifndef VPX_UNUSED
#if defined(__GNUC__) || defined(__clang__)
#define VPX_UNUSED __attribute__((unused))
#else
#define VPX_UNUSED
#endif
#endif /* VPX_UNUSED */
/*!\brief Current ABI version number
*
* \internal
* If this file is altered in any way that changes the ABI, this value
* must be bumped. Examples include, but are not limited to, changing
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define VPX_CODEC_ABI_VERSION (4 + VPX_IMAGE_ABI_VERSION) /**<\hideinitializer*/
/*!\brief Algorithm return codes */
typedef enum {
/*!\brief Operation completed without error */
VPX_CODEC_OK,
/*!\brief Unspecified error */
VPX_CODEC_ERROR,
/*!\brief Memory operation failed */
VPX_CODEC_MEM_ERROR,
/*!\brief ABI version mismatch */
VPX_CODEC_ABI_MISMATCH,
/*!\brief Algorithm does not have required capability */
VPX_CODEC_INCAPABLE,
/*!\brief The given bitstream is not supported.
*
* The bitstream was unable to be parsed at the highest level. The decoder
* is unable to proceed. This error \ref SHOULD be treated as fatal to the
* stream. */
VPX_CODEC_UNSUP_BITSTREAM,
/*!\brief Encoded bitstream uses an unsupported feature
*
* The decoder does not implement a feature required by the encoder. This
* return code should only be used for features that prevent future
* pictures from being properly decoded. This error \ref MAY be treated as
* fatal to the stream or \ref MAY be treated as fatal to the current GOP.
*/
VPX_CODEC_UNSUP_FEATURE,
/*!\brief The coded data for this stream is corrupt or incomplete
*
* There was a problem decoding the current frame. This return code
* should only be used for failures that prevent future pictures from
* being properly decoded. This error \ref MAY be treated as fatal to the
* stream or \ref MAY be treated as fatal to the current GOP. If decoding
* is continued for the current GOP, artifacts may be present.
*/
VPX_CODEC_CORRUPT_FRAME,
/*!\brief An application-supplied parameter is not valid.
*
*/
VPX_CODEC_INVALID_PARAM,
/*!\brief An iterator reached the end of list.
*
*/
VPX_CODEC_LIST_END
} vpx_codec_err_t;
/*! \brief Codec capabilities bitfield
*
* Each codec advertises the capabilities it supports as part of its
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
* or functionality, and are not required to be supported.
*
* The available flags are specified by VPX_CODEC_CAP_* defines.
*/
typedef long vpx_codec_caps_t;
#define VPX_CODEC_CAP_DECODER 0x1 /**< Is a decoder */
#define VPX_CODEC_CAP_ENCODER 0x2 /**< Is an encoder */
/*! Can support images at greater than 8 bitdepth.
*/
#define VPX_CODEC_CAP_HIGHBITDEPTH 0x4
/*! \brief Initialization-time Feature Enabling
*
* Certain codec features must be known at initialization time, to allow for
* proper memory allocation.
*
* The available flags are specified by VPX_CODEC_USE_* defines.
*/
typedef long vpx_codec_flags_t;
/*!\brief Codec interface structure.
*
* Contains function pointers and other data private to the codec
* implementation. This structure is opaque to the application.
*/
typedef const struct vpx_codec_iface vpx_codec_iface_t;
/*!\brief Codec private data structure.
*
* Contains data private to the codec implementation. This structure is opaque
* to the application.
*/
typedef struct vpx_codec_priv vpx_codec_priv_t;
/*!\brief Iterator
*
* Opaque storage used for iterating over lists.
*/
typedef const void *vpx_codec_iter_t;
/*!\brief Codec context structure
*
* All codecs \ref MUST support this context structure fully. In general,
* this data should be considered private to the codec algorithm, and
* not be manipulated or examined by the calling application. Applications
* may reference the 'name' member to get a printable description of the
* algorithm.
*/
typedef struct vpx_codec_ctx {
const char *name; /**< Printable interface name */
vpx_codec_iface_t *iface; /**< Interface pointers */
vpx_codec_err_t err; /**< Last returned error */
const char *err_detail; /**< Detailed info, if available */
vpx_codec_flags_t init_flags; /**< Flags passed at init time */
union {
/**< Decoder Configuration Pointer */
const struct vpx_codec_dec_cfg *dec;
/**< Encoder Configuration Pointer */
const struct vpx_codec_enc_cfg *enc;
const void *raw;
} config; /**< Configuration pointer aliasing union */
vpx_codec_priv_t *priv; /**< Algorithm private storage */
} vpx_codec_ctx_t;
/*!\brief Bit depth for codec
* *
* This enumeration determines the bit depth of the codec.
*/
typedef enum vpx_bit_depth {
VPX_BITS_8 = 8, /**< 8 bits */
VPX_BITS_10 = 10, /**< 10 bits */
VPX_BITS_12 = 12, /**< 12 bits */
} vpx_bit_depth_t;
/*
* Library Version Number Interface
*
* For example, see the following sample return values:
* vpx_codec_version() (1<<16 | 2<<8 | 3)
* vpx_codec_version_str() "v1.2.3-rc1-16-gec6a1ba"
* vpx_codec_version_extra_str() "rc1-16-gec6a1ba"
*/
/*!\brief Return the version information (as an integer)
*
* Returns a packed encoding of the library version number. This will only
* include
* the major.minor.patch component of the version number. Note that this encoded
* value should be accessed through the macros provided, as the encoding may
* change
* in the future.
*
*/
int vpx_codec_version(void);
#define VPX_VERSION_MAJOR(v) \
(((v) >> 16) & 0xff) /**< extract major from packed version */
#define VPX_VERSION_MINOR(v) \
(((v) >> 8) & 0xff) /**< extract minor from packed version */
#define VPX_VERSION_PATCH(v) \
(((v) >> 0) & 0xff) /**< extract patch from packed version */
/*!\brief Return the version major number */
#define vpx_codec_version_major() ((vpx_codec_version() >> 16) & 0xff)
/*!\brief Return the version minor number */
#define vpx_codec_version_minor() ((vpx_codec_version() >> 8) & 0xff)
/*!\brief Return the version patch number */
#define vpx_codec_version_patch() ((vpx_codec_version() >> 0) & 0xff)
/*!\brief Return the version information (as a string)
*
* Returns a printable string containing the full library version number. This
* may
* contain additional text following the three digit version number, as to
* indicate
* release candidates, prerelease versions, etc.
*
*/
const char *vpx_codec_version_str(void);
/*!\brief Return the version information (as a string)
*
* Returns a printable "extra string". This is the component of the string
* returned
* by vpx_codec_version_str() following the three digit version number.
*
*/
const char *vpx_codec_version_extra_str(void);
/*!\brief Return the build configuration
*
* Returns a printable string containing an encoded version of the build
* configuration. This may be useful to vpx support.
*
*/
const char *vpx_codec_build_config(void);
/*!\brief Return the name for a given interface
*
* Returns a human readable string for name of the given codec interface.
*
* \param[in] iface Interface pointer
*
*/
const char *vpx_codec_iface_name(vpx_codec_iface_t *iface);
/*!\brief Convert error number to printable string
*
* Returns a human readable string for the last error returned by the
* algorithm. The returned error will be one line and will not contain
* any newline characters.
*
*
* \param[in] err Error number.
*
*/
const char *vpx_codec_err_to_string(vpx_codec_err_t err);
/*!\brief Retrieve error synopsis for codec context
*
* Returns a human readable string for the last error returned by the
* algorithm. The returned error will be one line and will not contain
* any newline characters.
*
*
* \param[in] ctx Pointer to this instance's context.
*
*/
const char *vpx_codec_error(vpx_codec_ctx_t *ctx);
/*!\brief Retrieve detailed error information for codec context
*
* Returns a human readable string providing detailed information about
* the last error.
*
* \param[in] ctx Pointer to this instance's context.
*
* \retval NULL
* No detailed information is available.
*/
const char *vpx_codec_error_detail(vpx_codec_ctx_t *ctx);
/* REQUIRED FUNCTIONS
*
* The following functions are required to be implemented for all codecs.
* They represent the base case functionality expected of all codecs.
*/
/*!\brief Destroy a codec instance
*
* Destroys a codec context, freeing any associated memory buffers.
*
* \param[in] ctx Pointer to this instance's context
*
* \retval #VPX_CODEC_OK
* The codec algorithm initialized.
* \retval #VPX_CODEC_MEM_ERROR
* Memory allocation failed.
*/
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx);
/*!\brief Get the capabilities of an algorithm.
*
* Retrieves the capabilities bitfield from the algorithm's interface.
*
* \param[in] iface Pointer to the algorithm interface
*
*/
vpx_codec_caps_t vpx_codec_get_caps(vpx_codec_iface_t *iface);
/*!\brief Control algorithm
*
* This function is used to exchange algorithm specific data with the codec
* instance. This can be used to implement features specific to a particular
* algorithm.
*
* This wrapper function dispatches the request to the helper function
* associated with the given ctrl_id. It tries to call this function
* transparently, but will return #VPX_CODEC_ERROR if the request could not
* be dispatched.
*
* Note that this function should not be used directly. Call the
* #vpx_codec_control wrapper macro instead.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] ctrl_id Algorithm specific control identifier
*
* \retval #VPX_CODEC_OK
* The control request was processed.
* \retval #VPX_CODEC_ERROR
* The control request was not processed.
* \retval #VPX_CODEC_INVALID_PARAM
* The data was not valid.
*/
vpx_codec_err_t vpx_codec_control_(vpx_codec_ctx_t *ctx, int ctrl_id, ...);
#if defined(VPX_DISABLE_CTRL_TYPECHECKS) && VPX_DISABLE_CTRL_TYPECHECKS
#define vpx_codec_control(ctx, id, data) vpx_codec_control_(ctx, id, data)
#define VPX_CTRL_USE_TYPE(id, typ)
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ)
#define VPX_CTRL_VOID(id, typ)
#else
/*!\brief vpx_codec_control wrapper macro
*
* This macro allows for type safe conversions across the variadic parameter
* to vpx_codec_control_().
*
* \internal
* It works by dispatching the call to the control function through a wrapper
* function named with the id parameter.
*/
#define vpx_codec_control(ctx, id, data) \
vpx_codec_control_##id(ctx, id, data) /**<\hideinitializer*/
/*!\brief vpx_codec_control type definition macro
*
* This macro allows for type safe conversions across the variadic parameter
* to vpx_codec_control_(). It defines the type of the argument for a given
* control identifier.
*
* \internal
* It defines a static function with
* the correctly typed arguments as a wrapper to the type-unsafe internal
* function.
*/
#define VPX_CTRL_USE_TYPE(id, typ) \
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int, typ) \
VPX_UNUSED; \
\
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
int ctrl_id, typ data) { \
return vpx_codec_control_(ctx, ctrl_id, data); \
} /**<\hideinitializer*/
/*!\brief vpx_codec_control deprecated type definition macro
*
* Like #VPX_CTRL_USE_TYPE, but indicates that the specified control is
* deprecated and should not be used. Consult the documentation for your
* codec for more information.
*
* \internal
* It defines a static function with the correctly typed arguments as a
* wrapper to the type-unsafe internal function.
*/
#define VPX_CTRL_USE_TYPE_DEPRECATED(id, typ) \
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
vpx_codec_ctx_t *, int, typ) VPX_DEPRECATED VPX_UNUSED; \
\
VPX_DECLSPEC_DEPRECATED static vpx_codec_err_t vpx_codec_control_##id( \
vpx_codec_ctx_t *ctx, int ctrl_id, typ data) { \
return vpx_codec_control_(ctx, ctrl_id, data); \
} /**<\hideinitializer*/
/*!\brief vpx_codec_control void type definition macro
*
* This macro allows for type safe conversions across the variadic parameter
* to vpx_codec_control_(). It indicates that a given control identifier takes
* no argument.
*
* \internal
* It defines a static function without a data argument as a wrapper to the
* type-unsafe internal function.
*/
#define VPX_CTRL_VOID(id) \
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *, int) \
VPX_UNUSED; \
\
static vpx_codec_err_t vpx_codec_control_##id(vpx_codec_ctx_t *ctx, \
int ctrl_id) { \
return vpx_codec_control_(ctx, ctrl_id); \
} /**<\hideinitializer*/
#endif
/*!@} - end defgroup codec*/
#ifdef __cplusplus
}
#endif
#endif // VPX_VPX_VPX_CODEC_H_

View file

@ -0,0 +1,365 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VPX_VPX_VPX_DECODER_H_
#define VPX_VPX_VPX_DECODER_H_
/*!\defgroup decoder Decoder Algorithm Interface
* \ingroup codec
* This abstraction allows applications using this decoder to easily support
* multiple video formats with minimal code duplication. This section describes
* the interface common to all decoders.
* @{
*/
/*!\file
* \brief Describes the decoder algorithm interface to applications.
*
* This file describes the interface between an application and a
* video decoder algorithm.
*
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "./vpx_codec.h"
#include "./vpx_frame_buffer.h"
/*!\brief Current ABI version number
*
* \internal
* If this file is altered in any way that changes the ABI, this value
* must be bumped. Examples include, but are not limited to, changing
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define VPX_DECODER_ABI_VERSION \
(3 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
/*! \brief Decoder capabilities bitfield
*
* Each decoder advertises the capabilities it supports as part of its
* ::vpx_codec_iface_t interface structure. Capabilities are extra interfaces
* or functionality, and are not required to be supported by a decoder.
*
* The available flags are specified by VPX_CODEC_CAP_* defines.
*/
#define VPX_CODEC_CAP_PUT_SLICE 0x10000 /**< Will issue put_slice callbacks */
#define VPX_CODEC_CAP_PUT_FRAME 0x20000 /**< Will issue put_frame callbacks */
#define VPX_CODEC_CAP_POSTPROC 0x40000 /**< Can postprocess decoded frame */
/*!\brief Can conceal errors due to packet loss */
#define VPX_CODEC_CAP_ERROR_CONCEALMENT 0x80000
/*!\brief Can receive encoded frames one fragment at a time */
#define VPX_CODEC_CAP_INPUT_FRAGMENTS 0x100000
/*! \brief Initialization-time Feature Enabling
*
* Certain codec features must be known at initialization time, to allow for
* proper memory allocation.
*
* The available flags are specified by VPX_CODEC_USE_* defines.
*/
/*!\brief Can support frame-based multi-threading */
#define VPX_CODEC_CAP_FRAME_THREADING 0x200000
/*!brief Can support external frame buffers */
#define VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000
#define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */
/*!\brief Conceal errors in decoded frames */
#define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000
/*!\brief The input frame should be passed to the decoder one fragment at a
* time */
#define VPX_CODEC_USE_INPUT_FRAGMENTS 0x40000
/*!\brief Enable frame-based multi-threading */
#define VPX_CODEC_USE_FRAME_THREADING 0x80000
/*!\brief Stream properties
*
* This structure is used to query or set properties of the decoded
* stream. Algorithms may extend this structure with data specific
* to their bitstream by setting the sz member appropriately.
*/
typedef struct vpx_codec_stream_info {
unsigned int sz; /**< Size of this structure */
unsigned int w; /**< Width (or 0 for unknown/default) */
unsigned int h; /**< Height (or 0 for unknown/default) */
unsigned int is_kf; /**< Current frame is a keyframe */
} vpx_codec_stream_info_t;
/* REQUIRED FUNCTIONS
*
* The following functions are required to be implemented for all decoders.
* They represent the base case functionality expected of all decoders.
*/
/*!\brief Initialization Configurations
*
* This structure is used to pass init time configuration options to the
* decoder.
*/
typedef struct vpx_codec_dec_cfg {
unsigned int threads; /**< Maximum number of threads to use, default 1 */
unsigned int w; /**< Width */
unsigned int h; /**< Height */
} vpx_codec_dec_cfg_t; /**< alias for struct vpx_codec_dec_cfg */
/*!\brief Initialize a decoder instance
*
* Initializes a decoder context using the given interface. Applications
* should call the vpx_codec_dec_init convenience macro instead of this
* function directly, to ensure that the ABI version number parameter
* is properly initialized.
*
* If the library was configured with --disable-multithread, this call
* is not thread safe and should be guarded with a lock if being used
* in a multithreaded context.
*
* \param[in] ctx Pointer to this instance's context.
* \param[in] iface Pointer to the algorithm interface to use.
* \param[in] cfg Configuration to use, if known. May be NULL.
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
* \param[in] ver ABI version number. Must be set to
* VPX_DECODER_ABI_VERSION
* \retval #VPX_CODEC_OK
* The decoder algorithm initialized.
* \retval #VPX_CODEC_MEM_ERROR
* Memory allocation failed.
*/
vpx_codec_err_t vpx_codec_dec_init_ver(vpx_codec_ctx_t *ctx,
vpx_codec_iface_t *iface,
const vpx_codec_dec_cfg_t *cfg,
vpx_codec_flags_t flags, int ver);
/*!\brief Convenience macro for vpx_codec_dec_init_ver()
*
* Ensures the ABI version parameter is properly set.
*/
#define vpx_codec_dec_init(ctx, iface, cfg, flags) \
vpx_codec_dec_init_ver(ctx, iface, cfg, flags, VPX_DECODER_ABI_VERSION)
/*!\brief Parse stream info from a buffer
*
* Performs high level parsing of the bitstream. Construction of a decoder
* context is not necessary. Can be used to determine if the bitstream is
* of the proper format, and to extract information from the stream.
*
* \param[in] iface Pointer to the algorithm interface
* \param[in] data Pointer to a block of data to parse
* \param[in] data_sz Size of the data buffer
* \param[in,out] si Pointer to stream info to update. The size member
* \ref MUST be properly initialized, but \ref MAY be
* clobbered by the algorithm. This parameter \ref MAY
* be NULL.
*
* \retval #VPX_CODEC_OK
* Bitstream is parsable and stream information updated
*/
vpx_codec_err_t vpx_codec_peek_stream_info(vpx_codec_iface_t *iface,
const uint8_t *data,
unsigned int data_sz,
vpx_codec_stream_info_t *si);
/*!\brief Return information about the current stream.
*
* Returns information about the stream that has been parsed during decoding.
*
* \param[in] ctx Pointer to this instance's context
* \param[in,out] si Pointer to stream info to update. The size member
* \ref MUST be properly initialized, but \ref MAY be
* clobbered by the algorithm. This parameter \ref MAY
* be NULL.
*
* \retval #VPX_CODEC_OK
* Bitstream is parsable and stream information updated
*/
vpx_codec_err_t vpx_codec_get_stream_info(vpx_codec_ctx_t *ctx,
vpx_codec_stream_info_t *si);
/*!\brief Decode data
*
* Processes a buffer of coded data. If the processing results in a new
* decoded frame becoming available, PUT_SLICE and PUT_FRAME events may be
* generated, as appropriate. Encoded data \ref MUST be passed in DTS (decode
* time stamp) order. Frames produced will always be in PTS (presentation
* time stamp) order.
* If the decoder is configured with VPX_CODEC_USE_INPUT_FRAGMENTS enabled,
* data and data_sz can contain a fragment of the encoded frame. Fragment
* \#n must contain at least partition \#n, but can also contain subsequent
* partitions (\#n+1 - \#n+i), and if so, fragments \#n+1, .., \#n+i must
* be empty. When no more data is available, this function should be called
* with NULL as data and 0 as data_sz. The memory passed to this function
* must be available until the frame has been decoded.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] data Pointer to this block of new coded data. If
* NULL, a VPX_CODEC_CB_PUT_FRAME event is posted
* for the previously decoded frame.
* \param[in] data_sz Size of the coded data, in bytes.
* \param[in] user_priv Application specific data to associate with
* this frame.
* \param[in] deadline Soft deadline the decoder should attempt to meet,
* in us. Set to zero for unlimited.
*
* \return Returns #VPX_CODEC_OK if the coded data was processed completely
* and future pictures can be decoded without error. Otherwise,
* see the descriptions of the other error codes in ::vpx_codec_err_t
* for recoverability capabilities.
*/
vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, const uint8_t *data,
unsigned int data_sz, void *user_priv,
long deadline);
/*!\brief Decoded frames iterator
*
* Iterates over a list of the frames available for display. The iterator
* storage should be initialized to NULL to start the iteration. Iteration is
* complete when this function returns NULL.
*
* The list of available frames becomes valid upon completion of the
* vpx_codec_decode call, and remains valid until the next call to
* vpx_codec_decode.
*
* \param[in] ctx Pointer to this instance's context
* \param[in,out] iter Iterator storage, initialized to NULL
*
* \return Returns a pointer to an image, if one is ready for display. Frames
* produced will always be in PTS (presentation time stamp) order.
*/
vpx_image_t *vpx_codec_get_frame(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter);
/*!\defgroup cap_put_frame Frame-Based Decoding Functions
*
* The following functions are required to be implemented for all decoders
* that advertise the VPX_CODEC_CAP_PUT_FRAME capability. Calling these
* functions
* for codecs that don't advertise this capability will result in an error
* code being returned, usually VPX_CODEC_ERROR
* @{
*/
/*!\brief put frame callback prototype
*
* This callback is invoked by the decoder to notify the application of
* the availability of decoded image data.
*/
typedef void (*vpx_codec_put_frame_cb_fn_t)(void *user_priv,
const vpx_image_t *img);
/*!\brief Register for notification of frame completion.
*
* Registers a given function to be called when a decoded frame is
* available.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] cb Pointer to the callback function
* \param[in] user_priv User's private data
*
* \retval #VPX_CODEC_OK
* Callback successfully registered.
* \retval #VPX_CODEC_ERROR
* Decoder context not initialized, or algorithm not capable of
* posting slice completion.
*/
vpx_codec_err_t vpx_codec_register_put_frame_cb(vpx_codec_ctx_t *ctx,
vpx_codec_put_frame_cb_fn_t cb,
void *user_priv);
/*!@} - end defgroup cap_put_frame */
/*!\defgroup cap_put_slice Slice-Based Decoding Functions
*
* The following functions are required to be implemented for all decoders
* that advertise the VPX_CODEC_CAP_PUT_SLICE capability. Calling these
* functions
* for codecs that don't advertise this capability will result in an error
* code being returned, usually VPX_CODEC_ERROR
* @{
*/
/*!\brief put slice callback prototype
*
* This callback is invoked by the decoder to notify the application of
* the availability of partially decoded image data. The
*/
typedef void (*vpx_codec_put_slice_cb_fn_t)(void *user_priv,
const vpx_image_t *img,
const vpx_image_rect_t *valid,
const vpx_image_rect_t *update);
/*!\brief Register for notification of slice completion.
*
* Registers a given function to be called when a decoded slice is
* available.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] cb Pointer to the callback function
* \param[in] user_priv User's private data
*
* \retval #VPX_CODEC_OK
* Callback successfully registered.
* \retval #VPX_CODEC_ERROR
* Decoder context not initialized, or algorithm not capable of
* posting slice completion.
*/
vpx_codec_err_t vpx_codec_register_put_slice_cb(vpx_codec_ctx_t *ctx,
vpx_codec_put_slice_cb_fn_t cb,
void *user_priv);
/*!@} - end defgroup cap_put_slice*/
/*!\defgroup cap_external_frame_buffer External Frame Buffer Functions
*
* The following section is required to be implemented for all decoders
* that advertise the VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability.
* Calling this function for codecs that don't advertise this capability
* will result in an error code being returned, usually VPX_CODEC_ERROR.
*
* \note
* Currently this only works with VP9.
* @{
*/
/*!\brief Pass in external frame buffers for the decoder to use.
*
* Registers functions to be called when libvpx needs a frame buffer
* to decode the current frame and a function to be called when libvpx does
* not internally reference the frame buffer. This set function must
* be called before the first call to decode or libvpx will assume the
* default behavior of allocating frame buffers internally.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] cb_get Pointer to the get callback function
* \param[in] cb_release Pointer to the release callback function
* \param[in] cb_priv Callback's private data
*
* \retval #VPX_CODEC_OK
* External frame buffers will be used by libvpx.
* \retval #VPX_CODEC_INVALID_PARAM
* One or more of the callbacks were NULL.
* \retval #VPX_CODEC_ERROR
* Decoder context not initialized, or algorithm not capable of
* using external frame buffers.
*
* \note
* When decoding VP9, the application may be required to pass in at least
* #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
* buffers.
*/
vpx_codec_err_t vpx_codec_set_frame_buffer_functions(
vpx_codec_ctx_t *ctx, vpx_get_frame_buffer_cb_fn_t cb_get,
vpx_release_frame_buffer_cb_fn_t cb_release, void *cb_priv);
/*!@} - end defgroup cap_external_frame_buffer */
/*!@} - end defgroup decoder*/
#ifdef __cplusplus
}
#endif
#endif // VPX_VPX_VPX_DECODER_H_

View file

@ -0,0 +1,968 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VPX_VPX_VPX_ENCODER_H_
#define VPX_VPX_VPX_ENCODER_H_
/*!\defgroup encoder Encoder Algorithm Interface
* \ingroup codec
* This abstraction allows applications using this encoder to easily support
* multiple video formats with minimal code duplication. This section describes
* the interface common to all encoders.
* @{
*/
/*!\file
* \brief Describes the encoder algorithm interface to applications.
*
* This file describes the interface between an application and a
* video encoder algorithm.
*
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "./vpx_codec.h"
/*! Temporal Scalability: Maximum length of the sequence defining frame
* layer membership
*/
#define VPX_TS_MAX_PERIODICITY 16
/*! Temporal Scalability: Maximum number of coding layers */
#define VPX_TS_MAX_LAYERS 5
/*! Temporal+Spatial Scalability: Maximum number of coding layers */
#define VPX_MAX_LAYERS 12 // 3 temporal + 4 spatial layers are allowed.
/*! Spatial Scalability: Maximum number of coding layers */
#define VPX_SS_MAX_LAYERS 5
/*! Spatial Scalability: Default number of coding layers */
#define VPX_SS_DEFAULT_LAYERS 1
/*!\brief Current ABI version number
*
* \internal
* If this file is altered in any way that changes the ABI, this value
* must be bumped. Examples include, but are not limited to, changing
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define VPX_ENCODER_ABI_VERSION \
(14 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/
/*! \brief Encoder capabilities bitfield
*
* Each encoder advertises the capabilities it supports as part of its
* ::vpx_codec_iface_t interface structure. Capabilities are extra
* interfaces or functionality, and are not required to be supported
* by an encoder.
*
* The available flags are specified by VPX_CODEC_CAP_* defines.
*/
#define VPX_CODEC_CAP_PSNR 0x10000 /**< Can issue PSNR packets */
/*! Can output one partition at a time. Each partition is returned in its
* own VPX_CODEC_CX_FRAME_PKT, with the FRAME_IS_FRAGMENT flag set for
* every partition but the last. In this mode all frames are always
* returned partition by partition.
*/
#define VPX_CODEC_CAP_OUTPUT_PARTITION 0x20000
/*! \brief Initialization-time Feature Enabling
*
* Certain codec features must be known at initialization time, to allow
* for proper memory allocation.
*
* The available flags are specified by VPX_CODEC_USE_* defines.
*/
#define VPX_CODEC_USE_PSNR 0x10000 /**< Calculate PSNR on each frame */
/*!\brief Make the encoder output one partition at a time. */
#define VPX_CODEC_USE_OUTPUT_PARTITION 0x20000
#define VPX_CODEC_USE_HIGHBITDEPTH 0x40000 /**< Use high bitdepth */
/*!\brief Generic fixed size buffer structure
*
* This structure is able to hold a reference to any fixed size buffer.
*/
typedef struct vpx_fixed_buf {
void *buf; /**< Pointer to the data */
size_t sz; /**< Length of the buffer, in chars */
} vpx_fixed_buf_t; /**< alias for struct vpx_fixed_buf */
/*!\brief Time Stamp Type
*
* An integer, which when multiplied by the stream's time base, provides
* the absolute time of a sample.
*/
typedef int64_t vpx_codec_pts_t;
/*!\brief Compressed Frame Flags
*
* This type represents a bitfield containing information about a compressed
* frame that may be useful to an application. The most significant 16 bits
* can be used by an algorithm to provide additional detail, for example to
* support frame types that are codec specific (MPEG-1 D-frames for example)
*/
typedef uint32_t vpx_codec_frame_flags_t;
#define VPX_FRAME_IS_KEY 0x1 /**< frame is the start of a GOP */
/*!\brief frame can be dropped without affecting the stream (no future frame
* depends on this one) */
#define VPX_FRAME_IS_DROPPABLE 0x2
/*!\brief frame should be decoded but will not be shown */
#define VPX_FRAME_IS_INVISIBLE 0x4
/*!\brief this is a fragment of the encoded frame */
#define VPX_FRAME_IS_FRAGMENT 0x8
/*!\brief Error Resilient flags
*
* These flags define which error resilient features to enable in the
* encoder. The flags are specified through the
* vpx_codec_enc_cfg::g_error_resilient variable.
*/
typedef uint32_t vpx_codec_er_flags_t;
/*!\brief Improve resiliency against losses of whole frames */
#define VPX_ERROR_RESILIENT_DEFAULT 0x1
/*!\brief The frame partitions are independently decodable by the bool decoder,
* meaning that partitions can be decoded even though earlier partitions have
* been lost. Note that intra prediction is still done over the partition
* boundary. */
#define VPX_ERROR_RESILIENT_PARTITIONS 0x2
/*!\brief Encoder output packet variants
*
* This enumeration lists the different kinds of data packets that can be
* returned by calls to vpx_codec_get_cx_data(). Algorithms \ref MAY
* extend this list to provide additional functionality.
*/
enum vpx_codec_cx_pkt_kind {
VPX_CODEC_CX_FRAME_PKT, /**< Compressed video frame */
VPX_CODEC_STATS_PKT, /**< Two-pass statistics for this frame */
VPX_CODEC_FPMB_STATS_PKT, /**< first pass mb statistics for this frame */
VPX_CODEC_PSNR_PKT, /**< PSNR statistics for this frame */
VPX_CODEC_CUSTOM_PKT = 256 /**< Algorithm extensions */
};
/*!\brief Encoder output packet
*
* This structure contains the different kinds of output data the encoder
* may produce while compressing a frame.
*/
typedef struct vpx_codec_cx_pkt {
enum vpx_codec_cx_pkt_kind kind; /**< packet variant */
union {
struct {
void *buf; /**< compressed data buffer */
size_t sz; /**< length of compressed data */
/*!\brief time stamp to show frame (in timebase units) */
vpx_codec_pts_t pts;
/*!\brief duration to show frame (in timebase units) */
unsigned long duration;
vpx_codec_frame_flags_t flags; /**< flags for this frame */
/*!\brief the partition id defines the decoding order of the partitions.
* Only applicable when "output partition" mode is enabled. First
* partition has id 0.*/
int partition_id;
/*!\brief Width and height of frames in this packet. VP8 will only use the
* first one.*/
unsigned int width[VPX_SS_MAX_LAYERS]; /**< frame width */
unsigned int height[VPX_SS_MAX_LAYERS]; /**< frame height */
/*!\brief Flag to indicate if spatial layer frame in this packet is
* encoded or dropped. VP8 will always be set to 1.*/
uint8_t spatial_layer_encoded[VPX_SS_MAX_LAYERS];
} frame; /**< data for compressed frame packet */
vpx_fixed_buf_t twopass_stats; /**< data for two-pass packet */
vpx_fixed_buf_t firstpass_mb_stats; /**< first pass mb packet */
struct vpx_psnr_pkt {
unsigned int samples[4]; /**< Number of samples, total/y/u/v */
uint64_t sse[4]; /**< sum squared error, total/y/u/v */
double psnr[4]; /**< PSNR, total/y/u/v */
} psnr; /**< data for PSNR packet */
vpx_fixed_buf_t raw; /**< data for arbitrary packets */
/* This packet size is fixed to allow codecs to extend this
* interface without having to manage storage for raw packets,
* i.e., if it's smaller than 128 bytes, you can store in the
* packet list directly.
*/
char pad[128 - sizeof(enum vpx_codec_cx_pkt_kind)]; /**< fixed sz */
} data; /**< packet data */
} vpx_codec_cx_pkt_t; /**< alias for struct vpx_codec_cx_pkt */
/*!\brief Encoder return output buffer callback
*
* This callback function, when registered, returns with packets when each
* spatial layer is encoded.
*/
typedef void (*vpx_codec_enc_output_cx_pkt_cb_fn_t)(vpx_codec_cx_pkt_t *pkt,
void *user_data);
/*!\brief Callback function pointer / user data pair storage */
typedef struct vpx_codec_enc_output_cx_cb_pair {
vpx_codec_enc_output_cx_pkt_cb_fn_t output_cx_pkt; /**< Callback function */
void *user_priv; /**< Pointer to private data */
} vpx_codec_priv_output_cx_pkt_cb_pair_t;
/*!\brief Rational Number
*
* This structure holds a fractional value.
*/
typedef struct vpx_rational {
int num; /**< fraction numerator */
int den; /**< fraction denominator */
} vpx_rational_t; /**< alias for struct vpx_rational */
/*!\brief Multi-pass Encoding Pass */
typedef enum vpx_enc_pass {
VPX_RC_ONE_PASS, /**< Single pass mode */
VPX_RC_FIRST_PASS, /**< First pass of multi-pass mode */
VPX_RC_LAST_PASS /**< Final pass of multi-pass mode */
} vpx_enc_pass;
/*!\brief Rate control mode */
enum vpx_rc_mode {
VPX_VBR, /**< Variable Bit Rate (VBR) mode */
VPX_CBR, /**< Constant Bit Rate (CBR) mode */
VPX_CQ, /**< Constrained Quality (CQ) mode */
VPX_Q, /**< Constant Quality (Q) mode */
};
/*!\brief Keyframe placement mode.
*
* This enumeration determines whether keyframes are placed automatically by
* the encoder or whether this behavior is disabled. Older releases of this
* SDK were implemented such that VPX_KF_FIXED meant keyframes were disabled.
* This name is confusing for this behavior, so the new symbols to be used
* are VPX_KF_AUTO and VPX_KF_DISABLED.
*/
enum vpx_kf_mode {
VPX_KF_FIXED, /**< deprecated, implies VPX_KF_DISABLED */
VPX_KF_AUTO, /**< Encoder determines optimal placement automatically */
VPX_KF_DISABLED = 0 /**< Encoder does not place keyframes. */
};
/*!\brief Encoded Frame Flags
*
* This type indicates a bitfield to be passed to vpx_codec_encode(), defining
* per-frame boolean values. By convention, bits common to all codecs will be
* named VPX_EFLAG_*, and bits specific to an algorithm will be named
* /algo/_eflag_*. The lower order 16 bits are reserved for common use.
*/
typedef long vpx_enc_frame_flags_t;
#define VPX_EFLAG_FORCE_KF (1 << 0) /**< Force this frame to be a keyframe */
/*!\brief Encoder configuration structure
*
* This structure contains the encoder settings that have common representations
* across all codecs. This doesn't imply that all codecs support all features,
* however.
*/
typedef struct vpx_codec_enc_cfg {
/*
* generic settings (g)
*/
/*!\brief Deprecated: Algorithm specific "usage" value
*
* This value must be zero.
*/
unsigned int g_usage;
/*!\brief Maximum number of threads to use
*
* For multi-threaded implementations, use no more than this number of
* threads. The codec may use fewer threads than allowed. The value
* 0 is equivalent to the value 1.
*/
unsigned int g_threads;
/*!\brief Bitstream profile to use
*
* Some codecs support a notion of multiple bitstream profiles. Typically
* this maps to a set of features that are turned on or off. Often the
* profile to use is determined by the features of the intended decoder.
* Consult the documentation for the codec to determine the valid values
* for this parameter, or set to zero for a sane default.
*/
unsigned int g_profile; /**< profile of bitstream to use */
/*!\brief Width of the frame
*
* This value identifies the presentation resolution of the frame,
* in pixels. Note that the frames passed as input to the encoder must
* have this resolution. Frames will be presented by the decoder in this
* resolution, independent of any spatial resampling the encoder may do.
*/
unsigned int g_w;
/*!\brief Height of the frame
*
* This value identifies the presentation resolution of the frame,
* in pixels. Note that the frames passed as input to the encoder must
* have this resolution. Frames will be presented by the decoder in this
* resolution, independent of any spatial resampling the encoder may do.
*/
unsigned int g_h;
/*!\brief Bit-depth of the codec
*
* This value identifies the bit_depth of the codec,
* Only certain bit-depths are supported as identified in the
* vpx_bit_depth_t enum.
*/
vpx_bit_depth_t g_bit_depth;
/*!\brief Bit-depth of the input frames
*
* This value identifies the bit_depth of the input frames in bits.
* Note that the frames passed as input to the encoder must have
* this bit-depth.
*/
unsigned int g_input_bit_depth;
/*!\brief Stream timebase units
*
* Indicates the smallest interval of time, in seconds, used by the stream.
* For fixed frame rate material, or variable frame rate material where
* frames are timed at a multiple of a given clock (ex: video capture),
* the \ref RECOMMENDED method is to set the timebase to the reciprocal
* of the frame rate (ex: 1001/30000 for 29.970 Hz NTSC). This allows the
* pts to correspond to the frame number, which can be handy. For
* re-encoding video from containers with absolute time timestamps, the
* \ref RECOMMENDED method is to set the timebase to that of the parent
* container or multimedia framework (ex: 1/1000 for ms, as in FLV).
*/
struct vpx_rational g_timebase;
/*!\brief Enable error resilient modes.
*
* The error resilient bitfield indicates to the encoder which features
* it should enable to take measures for streaming over lossy or noisy
* links.
*/
vpx_codec_er_flags_t g_error_resilient;
/*!\brief Multi-pass Encoding Mode
*
* This value should be set to the current phase for multi-pass encoding.
* For single pass, set to #VPX_RC_ONE_PASS.
*/
enum vpx_enc_pass g_pass;
/*!\brief Allow lagged encoding
*
* If set, this value allows the encoder to consume a number of input
* frames before producing output frames. This allows the encoder to
* base decisions for the current frame on future frames. This does
* increase the latency of the encoding pipeline, so it is not appropriate
* in all situations (ex: realtime encoding).
*
* Note that this is a maximum value -- the encoder may produce frames
* sooner than the given limit. Set this value to 0 to disable this
* feature.
*/
unsigned int g_lag_in_frames;
/*
* rate control settings (rc)
*/
/*!\brief Temporal resampling configuration, if supported by the codec.
*
* Temporal resampling allows the codec to "drop" frames as a strategy to
* meet its target data rate. This can cause temporal discontinuities in
* the encoded video, which may appear as stuttering during playback. This
* trade-off is often acceptable, but for many applications is not. It can
* be disabled in these cases.
*
* This threshold is described as a percentage of the target data buffer.
* When the data buffer falls below this percentage of fullness, a
* dropped frame is indicated. Set the threshold to zero (0) to disable
* this feature.
*/
unsigned int rc_dropframe_thresh;
/*!\brief Enable/disable spatial resampling, if supported by the codec.
*
* Spatial resampling allows the codec to compress a lower resolution
* version of the frame, which is then upscaled by the encoder to the
* correct presentation resolution. This increases visual quality at
* low data rates, at the expense of CPU time on the encoder/decoder.
*/
unsigned int rc_resize_allowed;
/*!\brief Internal coded frame width.
*
* If spatial resampling is enabled this specifies the width of the
* encoded frame.
*/
unsigned int rc_scaled_width;
/*!\brief Internal coded frame height.
*
* If spatial resampling is enabled this specifies the height of the
* encoded frame.
*/
unsigned int rc_scaled_height;
/*!\brief Spatial resampling up watermark.
*
* This threshold is described as a percentage of the target data buffer.
* When the data buffer rises above this percentage of fullness, the
* encoder will step up to a higher resolution version of the frame.
*/
unsigned int rc_resize_up_thresh;
/*!\brief Spatial resampling down watermark.
*
* This threshold is described as a percentage of the target data buffer.
* When the data buffer falls below this percentage of fullness, the
* encoder will step down to a lower resolution version of the frame.
*/
unsigned int rc_resize_down_thresh;
/*!\brief Rate control algorithm to use.
*
* Indicates whether the end usage of this stream is to be streamed over
* a bandwidth constrained link, indicating that Constant Bit Rate (CBR)
* mode should be used, or whether it will be played back on a high
* bandwidth link, as from a local disk, where higher variations in
* bitrate are acceptable.
*/
enum vpx_rc_mode rc_end_usage;
/*!\brief Two-pass stats buffer.
*
* A buffer containing all of the stats packets produced in the first
* pass, concatenated.
*/
vpx_fixed_buf_t rc_twopass_stats_in;
/*!\brief first pass mb stats buffer.
*
* A buffer containing all of the first pass mb stats packets produced
* in the first pass, concatenated.
*/
vpx_fixed_buf_t rc_firstpass_mb_stats_in;
/*!\brief Target data rate
*
* Target bandwidth to use for this stream, in kilobits per second.
*/
unsigned int rc_target_bitrate;
/*
* quantizer settings
*/
/*!\brief Minimum (Best Quality) Quantizer
*
* The quantizer is the most direct control over the quality of the
* encoded image. The range of valid values for the quantizer is codec
* specific. Consult the documentation for the codec to determine the
* values to use.
*/
unsigned int rc_min_quantizer;
/*!\brief Maximum (Worst Quality) Quantizer
*
* The quantizer is the most direct control over the quality of the
* encoded image. The range of valid values for the quantizer is codec
* specific. Consult the documentation for the codec to determine the
* values to use.
*/
unsigned int rc_max_quantizer;
/*
* bitrate tolerance
*/
/*!\brief Rate control adaptation undershoot control
*
* VP8: Expressed as a percentage of the target bitrate,
* controls the maximum allowed adaptation speed of the codec.
* This factor controls the maximum amount of bits that can
* be subtracted from the target bitrate in order to compensate
* for prior overshoot.
* VP9: Expressed as a percentage of the target bitrate, a threshold
* undershoot level (current rate vs target) beyond which more aggressive
* corrective measures are taken.
* *
* Valid values in the range VP8:0-1000 VP9: 0-100.
*/
unsigned int rc_undershoot_pct;
/*!\brief Rate control adaptation overshoot control
*
* VP8: Expressed as a percentage of the target bitrate,
* controls the maximum allowed adaptation speed of the codec.
* This factor controls the maximum amount of bits that can
* be added to the target bitrate in order to compensate for
* prior undershoot.
* VP9: Expressed as a percentage of the target bitrate, a threshold
* overshoot level (current rate vs target) beyond which more aggressive
* corrective measures are taken.
*
* Valid values in the range VP8:0-1000 VP9: 0-100.
*/
unsigned int rc_overshoot_pct;
/*
* decoder buffer model parameters
*/
/*!\brief Decoder Buffer Size
*
* This value indicates the amount of data that may be buffered by the
* decoding application. Note that this value is expressed in units of
* time (milliseconds). For example, a value of 5000 indicates that the
* client will buffer (at least) 5000ms worth of encoded data. Use the
* target bitrate (#rc_target_bitrate) to convert to bits/bytes, if
* necessary.
*/
unsigned int rc_buf_sz;
/*!\brief Decoder Buffer Initial Size
*
* This value indicates the amount of data that will be buffered by the
* decoding application prior to beginning playback. This value is
* expressed in units of time (milliseconds). Use the target bitrate
* (#rc_target_bitrate) to convert to bits/bytes, if necessary.
*/
unsigned int rc_buf_initial_sz;
/*!\brief Decoder Buffer Optimal Size
*
* This value indicates the amount of data that the encoder should try
* to maintain in the decoder's buffer. This value is expressed in units
* of time (milliseconds). Use the target bitrate (#rc_target_bitrate)
* to convert to bits/bytes, if necessary.
*/
unsigned int rc_buf_optimal_sz;
/*
* 2 pass rate control parameters
*/
/*!\brief Two-pass mode CBR/VBR bias
*
* Bias, expressed on a scale of 0 to 100, for determining target size
* for the current frame. The value 0 indicates the optimal CBR mode
* value should be used. The value 100 indicates the optimal VBR mode
* value should be used. Values in between indicate which way the
* encoder should "lean."
*/
unsigned int rc_2pass_vbr_bias_pct;
/*!\brief Two-pass mode per-GOP minimum bitrate
*
* This value, expressed as a percentage of the target bitrate, indicates
* the minimum bitrate to be used for a single GOP (aka "section")
*/
unsigned int rc_2pass_vbr_minsection_pct;
/*!\brief Two-pass mode per-GOP maximum bitrate
*
* This value, expressed as a percentage of the target bitrate, indicates
* the maximum bitrate to be used for a single GOP (aka "section")
*/
unsigned int rc_2pass_vbr_maxsection_pct;
/*!\brief Two-pass corpus vbr mode complexity control
* Used only in VP9: A value representing the corpus midpoint complexity
* for corpus vbr mode. This value defaults to 0 which disables corpus vbr
* mode in favour of normal vbr mode.
*/
unsigned int rc_2pass_vbr_corpus_complexity;
/*
* keyframing settings (kf)
*/
/*!\brief Keyframe placement mode
*
* This value indicates whether the encoder should place keyframes at a
* fixed interval, or determine the optimal placement automatically
* (as governed by the #kf_min_dist and #kf_max_dist parameters)
*/
enum vpx_kf_mode kf_mode;
/*!\brief Keyframe minimum interval
*
* This value, expressed as a number of frames, prevents the encoder from
* placing a keyframe nearer than kf_min_dist to the previous keyframe. At
* least kf_min_dist frames non-keyframes will be coded before the next
* keyframe. Set kf_min_dist equal to kf_max_dist for a fixed interval.
*/
unsigned int kf_min_dist;
/*!\brief Keyframe maximum interval
*
* This value, expressed as a number of frames, forces the encoder to code
* a keyframe if one has not been coded in the last kf_max_dist frames.
* A value of 0 implies all frames will be keyframes. Set kf_min_dist
* equal to kf_max_dist for a fixed interval.
*/
unsigned int kf_max_dist;
/*
* Spatial scalability settings (ss)
*/
/*!\brief Number of spatial coding layers.
*
* This value specifies the number of spatial coding layers to be used.
*/
unsigned int ss_number_layers;
/*!\brief Enable auto alt reference flags for each spatial layer.
*
* These values specify if auto alt reference frame is enabled for each
* spatial layer.
*/
int ss_enable_auto_alt_ref[VPX_SS_MAX_LAYERS];
/*!\brief Target bitrate for each spatial layer.
*
* These values specify the target coding bitrate to be used for each
* spatial layer.
*/
unsigned int ss_target_bitrate[VPX_SS_MAX_LAYERS];
/*!\brief Number of temporal coding layers.
*
* This value specifies the number of temporal layers to be used.
*/
unsigned int ts_number_layers;
/*!\brief Target bitrate for each temporal layer.
*
* These values specify the target coding bitrate to be used for each
* temporal layer.
*/
unsigned int ts_target_bitrate[VPX_TS_MAX_LAYERS];
/*!\brief Frame rate decimation factor for each temporal layer.
*
* These values specify the frame rate decimation factors to apply
* to each temporal layer.
*/
unsigned int ts_rate_decimator[VPX_TS_MAX_LAYERS];
/*!\brief Length of the sequence defining frame temporal layer membership.
*
* This value specifies the length of the sequence that defines the
* membership of frames to temporal layers. For example, if the
* ts_periodicity = 8, then the frames are assigned to coding layers with a
* repeated sequence of length 8.
*/
unsigned int ts_periodicity;
/*!\brief Template defining the membership of frames to temporal layers.
*
* This array defines the membership of frames to temporal coding layers.
* For a 2-layer encoding that assigns even numbered frames to one temporal
* layer (0) and odd numbered frames to a second temporal layer (1) with
* ts_periodicity=8, then ts_layer_id = (0,1,0,1,0,1,0,1).
*/
unsigned int ts_layer_id[VPX_TS_MAX_PERIODICITY];
/*!\brief Target bitrate for each spatial/temporal layer.
*
* These values specify the target coding bitrate to be used for each
* spatial/temporal layer.
*
*/
unsigned int layer_target_bitrate[VPX_MAX_LAYERS];
/*!\brief Temporal layering mode indicating which temporal layering scheme to
* use.
*
* The value (refer to VP9E_TEMPORAL_LAYERING_MODE) specifies the
* temporal layering mode to use.
*
*/
int temporal_layering_mode;
} vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */
/*!\brief vp9 svc extra configure parameters
*
* This defines max/min quantizers and scale factors for each layer
*
*/
typedef struct vpx_svc_parameters {
int max_quantizers[VPX_MAX_LAYERS]; /**< Max Q for each layer */
int min_quantizers[VPX_MAX_LAYERS]; /**< Min Q for each layer */
int scaling_factor_num[VPX_MAX_LAYERS]; /**< Scaling factor-numerator */
int scaling_factor_den[VPX_MAX_LAYERS]; /**< Scaling factor-denominator */
int speed_per_layer[VPX_MAX_LAYERS]; /**< Speed setting for each sl */
int temporal_layering_mode; /**< Temporal layering mode */
} vpx_svc_extra_cfg_t;
/*!\brief Initialize an encoder instance
*
* Initializes a encoder context using the given interface. Applications
* should call the vpx_codec_enc_init convenience macro instead of this
* function directly, to ensure that the ABI version number parameter
* is properly initialized.
*
* If the library was configured with --disable-multithread, this call
* is not thread safe and should be guarded with a lock if being used
* in a multithreaded context.
*
* \param[in] ctx Pointer to this instance's context.
* \param[in] iface Pointer to the algorithm interface to use.
* \param[in] cfg Configuration to use, if known. May be NULL.
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
* \param[in] ver ABI version number. Must be set to
* VPX_ENCODER_ABI_VERSION
* \retval #VPX_CODEC_OK
* The decoder algorithm initialized.
* \retval #VPX_CODEC_MEM_ERROR
* Memory allocation failed.
*/
vpx_codec_err_t vpx_codec_enc_init_ver(vpx_codec_ctx_t *ctx,
vpx_codec_iface_t *iface,
const vpx_codec_enc_cfg_t *cfg,
vpx_codec_flags_t flags, int ver);
/*!\brief Convenience macro for vpx_codec_enc_init_ver()
*
* Ensures the ABI version parameter is properly set.
*/
#define vpx_codec_enc_init(ctx, iface, cfg, flags) \
vpx_codec_enc_init_ver(ctx, iface, cfg, flags, VPX_ENCODER_ABI_VERSION)
/*!\brief Initialize multi-encoder instance
*
* Initializes multi-encoder context using the given interface.
* Applications should call the vpx_codec_enc_init_multi convenience macro
* instead of this function directly, to ensure that the ABI version number
* parameter is properly initialized.
*
* \param[in] ctx Pointer to this instance's context.
* \param[in] iface Pointer to the algorithm interface to use.
* \param[in] cfg Configuration to use, if known. May be NULL.
* \param[in] num_enc Total number of encoders.
* \param[in] flags Bitfield of VPX_CODEC_USE_* flags
* \param[in] dsf Pointer to down-sampling factors.
* \param[in] ver ABI version number. Must be set to
* VPX_ENCODER_ABI_VERSION
* \retval #VPX_CODEC_OK
* The decoder algorithm initialized.
* \retval #VPX_CODEC_MEM_ERROR
* Memory allocation failed.
*/
vpx_codec_err_t vpx_codec_enc_init_multi_ver(
vpx_codec_ctx_t *ctx, vpx_codec_iface_t *iface, vpx_codec_enc_cfg_t *cfg,
int num_enc, vpx_codec_flags_t flags, vpx_rational_t *dsf, int ver);
/*!\brief Convenience macro for vpx_codec_enc_init_multi_ver()
*
* Ensures the ABI version parameter is properly set.
*/
#define vpx_codec_enc_init_multi(ctx, iface, cfg, num_enc, flags, dsf) \
vpx_codec_enc_init_multi_ver(ctx, iface, cfg, num_enc, flags, dsf, \
VPX_ENCODER_ABI_VERSION)
/*!\brief Get a default configuration
*
* Initializes a encoder configuration structure with default values. Supports
* the notion of "usages" so that an algorithm may offer different default
* settings depending on the user's intended goal. This function \ref SHOULD
* be called by all applications to initialize the configuration structure
* before specializing the configuration with application specific values.
*
* \param[in] iface Pointer to the algorithm interface to use.
* \param[out] cfg Configuration buffer to populate.
* \param[in] usage Must be set to 0.
*
* \retval #VPX_CODEC_OK
* The configuration was populated.
* \retval #VPX_CODEC_INCAPABLE
* Interface is not an encoder interface.
* \retval #VPX_CODEC_INVALID_PARAM
* A parameter was NULL, or the usage value was not recognized.
*/
vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
vpx_codec_enc_cfg_t *cfg,
unsigned int usage);
/*!\brief Set or change configuration
*
* Reconfigures an encoder instance according to the given configuration.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] cfg Configuration buffer to use
*
* \retval #VPX_CODEC_OK
* The configuration was populated.
* \retval #VPX_CODEC_INCAPABLE
* Interface is not an encoder interface.
* \retval #VPX_CODEC_INVALID_PARAM
* A parameter was NULL, or the usage value was not recognized.
*/
vpx_codec_err_t vpx_codec_enc_config_set(vpx_codec_ctx_t *ctx,
const vpx_codec_enc_cfg_t *cfg);
/*!\brief Get global stream headers
*
* Retrieves a stream level global header packet, if supported by the codec.
*
* \param[in] ctx Pointer to this instance's context
*
* \retval NULL
* Encoder does not support global header
* \retval Non-NULL
* Pointer to buffer containing global header packet
*/
vpx_fixed_buf_t *vpx_codec_get_global_headers(vpx_codec_ctx_t *ctx);
/*!\brief deadline parameter analogous to VPx REALTIME mode. */
#define VPX_DL_REALTIME (1)
/*!\brief deadline parameter analogous to VPx GOOD QUALITY mode. */
#define VPX_DL_GOOD_QUALITY (1000000)
/*!\brief deadline parameter analogous to VPx BEST QUALITY mode. */
#define VPX_DL_BEST_QUALITY (0)
/*!\brief Encode a frame
*
* Encodes a video frame at the given "presentation time." The presentation
* time stamp (PTS) \ref MUST be strictly increasing.
*
* The encoder supports the notion of a soft real-time deadline. Given a
* non-zero value to the deadline parameter, the encoder will make a "best
* effort" guarantee to return before the given time slice expires. It is
* implicit that limiting the available time to encode will degrade the
* output quality. The encoder can be given an unlimited time to produce the
* best possible frame by specifying a deadline of '0'. This deadline
* supersedes the VPx notion of "best quality, good quality, realtime".
* Applications that wish to map these former settings to the new deadline
* based system can use the symbols #VPX_DL_REALTIME, #VPX_DL_GOOD_QUALITY,
* and #VPX_DL_BEST_QUALITY.
*
* When the last frame has been passed to the encoder, this function should
* continue to be called, with the img parameter set to NULL. This will
* signal the end-of-stream condition to the encoder and allow it to encode
* any held buffers. Encoding is complete when vpx_codec_encode() is called
* and vpx_codec_get_cx_data() returns no data.
*
* \param[in] ctx Pointer to this instance's context
* \param[in] img Image data to encode, NULL to flush.
* \param[in] pts Presentation time stamp, in timebase units.
* \param[in] duration Duration to show frame, in timebase units.
* \param[in] flags Flags to use for encoding this frame.
* \param[in] deadline Time to spend encoding, in microseconds. (0=infinite)
*
* \retval #VPX_CODEC_OK
* The configuration was populated.
* \retval #VPX_CODEC_INCAPABLE
* Interface is not an encoder interface.
* \retval #VPX_CODEC_INVALID_PARAM
* A parameter was NULL, the image format is unsupported, etc.
*/
vpx_codec_err_t vpx_codec_encode(vpx_codec_ctx_t *ctx, const vpx_image_t *img,
vpx_codec_pts_t pts, unsigned long duration,
vpx_enc_frame_flags_t flags,
unsigned long deadline);
/*!\brief Set compressed data output buffer
*
* Sets the buffer that the codec should output the compressed data
* into. This call effectively sets the buffer pointer returned in the
* next VPX_CODEC_CX_FRAME_PKT packet. Subsequent packets will be
* appended into this buffer. The buffer is preserved across frames,
* so applications must periodically call this function after flushing
* the accumulated compressed data to disk or to the network to reset
* the pointer to the buffer's head.
*
* `pad_before` bytes will be skipped before writing the compressed
* data, and `pad_after` bytes will be appended to the packet. The size
* of the packet will be the sum of the size of the actual compressed
* data, pad_before, and pad_after. The padding bytes will be preserved
* (not overwritten).
*
* Note that calling this function does not guarantee that the returned
* compressed data will be placed into the specified buffer. In the
* event that the encoded data will not fit into the buffer provided,
* the returned packet \ref MAY point to an internal buffer, as it would
* if this call were never used. In this event, the output packet will
* NOT have any padding, and the application must free space and copy it
* to the proper place. This is of particular note in configurations
* that may output multiple packets for a single encoded frame (e.g., lagged
* encoding) or if the application does not reset the buffer periodically.
*
* Applications may restore the default behavior of the codec providing
* the compressed data buffer by calling this function with a NULL
* buffer.
*
* Applications \ref MUSTNOT call this function during iteration of
* vpx_codec_get_cx_data().
*
* \param[in] ctx Pointer to this instance's context
* \param[in] buf Buffer to store compressed data into
* \param[in] pad_before Bytes to skip before writing compressed data
* \param[in] pad_after Bytes to skip after writing compressed data
*
* \retval #VPX_CODEC_OK
* The buffer was set successfully.
* \retval #VPX_CODEC_INVALID_PARAM
* A parameter was NULL, the image format is unsupported, etc.
*/
vpx_codec_err_t vpx_codec_set_cx_data_buf(vpx_codec_ctx_t *ctx,
const vpx_fixed_buf_t *buf,
unsigned int pad_before,
unsigned int pad_after);
/*!\brief Encoded data iterator
*
* Iterates over a list of data packets to be passed from the encoder to the
* application. The different kinds of packets available are enumerated in
* #vpx_codec_cx_pkt_kind.
*
* #VPX_CODEC_CX_FRAME_PKT packets should be passed to the application's
* muxer. Multiple compressed frames may be in the list.
* #VPX_CODEC_STATS_PKT packets should be appended to a global buffer.
*
* The application \ref MUST silently ignore any packet kinds that it does
* not recognize or support.
*
* The data buffers returned from this function are only guaranteed to be
* valid until the application makes another call to any vpx_codec_* function.
*
* \param[in] ctx Pointer to this instance's context
* \param[in,out] iter Iterator storage, initialized to NULL
*
* \return Returns a pointer to an output data packet (compressed frame data,
* two-pass statistics, etc.) or NULL to signal end-of-list.
*
*/
const vpx_codec_cx_pkt_t *vpx_codec_get_cx_data(vpx_codec_ctx_t *ctx,
vpx_codec_iter_t *iter);
/*!\brief Get Preview Frame
*
* Returns an image that can be used as a preview. Shows the image as it would
* exist at the decompressor. The application \ref MUST NOT write into this
* image buffer.
*
* \param[in] ctx Pointer to this instance's context
*
* \return Returns a pointer to a preview image, or NULL if no image is
* available.
*
*/
const vpx_image_t *vpx_codec_get_preview_frame(vpx_codec_ctx_t *ctx);
/*!@} - end defgroup encoder*/
#ifdef __cplusplus
}
#endif
#endif // VPX_VPX_VPX_ENCODER_H_

View file

@ -0,0 +1,83 @@
/*
* Copyright (c) 2014 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VPX_VPX_VPX_FRAME_BUFFER_H_
#define VPX_VPX_VPX_FRAME_BUFFER_H_
/*!\file
* \brief Describes the decoder external frame buffer interface.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include "./vpx_integer.h"
/*!\brief The maximum number of work buffers used by libvpx.
* Support maximum 4 threads to decode video in parallel.
* Each thread will use one work buffer.
* TODO(hkuang): Add support to set number of worker threads dynamically.
*/
#define VPX_MAXIMUM_WORK_BUFFERS 8
/*!\brief The maximum number of reference buffers that a VP9 encoder may use.
*/
#define VP9_MAXIMUM_REF_BUFFERS 8
/*!\brief External frame buffer
*
* This structure holds allocated frame buffers used by the decoder.
*/
typedef struct vpx_codec_frame_buffer {
uint8_t *data; /**< Pointer to the data buffer */
size_t size; /**< Size of data in bytes */
void *priv; /**< Frame's private data */
} vpx_codec_frame_buffer_t;
/*!\brief get frame buffer callback prototype
*
* This callback is invoked by the decoder to retrieve data for the frame
* buffer in order for the decode call to complete. The callback must
* allocate at least min_size in bytes and assign it to fb->data. The callback
* must zero out all the data allocated. Then the callback must set fb->size
* to the allocated size. The application does not need to align the allocated
* data. The callback is triggered when the decoder needs a frame buffer to
* decode a compressed image into. This function may be called more than once
* for every call to vpx_codec_decode. The application may set fb->priv to
* some data which will be passed back in the vpx_image_t and the release
* function call. |fb| is guaranteed to not be NULL. On success the callback
* must return 0. Any failure the callback must return a value less than 0.
*
* \param[in] priv Callback's private data
* \param[in] min_size Size in bytes needed by the buffer
* \param[in,out] fb Pointer to vpx_codec_frame_buffer_t
*/
typedef int (*vpx_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size,
vpx_codec_frame_buffer_t *fb);
/*!\brief release frame buffer callback prototype
*
* This callback is invoked by the decoder when the frame buffer is not
* referenced by any other buffers. |fb| is guaranteed to not be NULL. On
* success the callback must return 0. Any failure the callback must return
* a value less than 0.
*
* \param[in] priv Callback's private data
* \param[in] fb Pointer to vpx_codec_frame_buffer_t
*/
typedef int (*vpx_release_frame_buffer_cb_fn_t)(void *priv,
vpx_codec_frame_buffer_t *fb);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VPX_VPX_VPX_FRAME_BUFFER_H_

View file

@ -0,0 +1,207 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
/*!\file
* \brief Describes the vpx image descriptor and associated operations
*
*/
#ifndef VPX_VPX_VPX_IMAGE_H_
#define VPX_VPX_VPX_IMAGE_H_
#ifdef __cplusplus
extern "C" {
#endif
/*!\brief Current ABI version number
*
* \internal
* If this file is altered in any way that changes the ABI, this value
* must be bumped. Examples include, but are not limited to, changing
* types, removing or reassigning enums, adding/removing/rearranging
* fields to structures
*/
#define VPX_IMAGE_ABI_VERSION (5) /**<\hideinitializer*/
#define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
#define VPX_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
#define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */
#define VPX_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
/*!\brief List of supported image formats */
typedef enum vpx_img_fmt {
VPX_IMG_FMT_NONE,
VPX_IMG_FMT_YV12 =
VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
VPX_IMG_FMT_I422 = VPX_IMG_FMT_PLANAR | 5,
VPX_IMG_FMT_I444 = VPX_IMG_FMT_PLANAR | 6,
VPX_IMG_FMT_I440 = VPX_IMG_FMT_PLANAR | 7,
VPX_IMG_FMT_I42016 = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH,
VPX_IMG_FMT_I42216 = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH,
VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH,
VPX_IMG_FMT_I44016 = VPX_IMG_FMT_I440 | VPX_IMG_FMT_HIGHBITDEPTH
} vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
/*!\brief List of supported color spaces */
typedef enum vpx_color_space {
VPX_CS_UNKNOWN = 0, /**< Unknown */
VPX_CS_BT_601 = 1, /**< BT.601 */
VPX_CS_BT_709 = 2, /**< BT.709 */
VPX_CS_SMPTE_170 = 3, /**< SMPTE.170 */
VPX_CS_SMPTE_240 = 4, /**< SMPTE.240 */
VPX_CS_BT_2020 = 5, /**< BT.2020 */
VPX_CS_RESERVED = 6, /**< Reserved */
VPX_CS_SRGB = 7 /**< sRGB */
} vpx_color_space_t; /**< alias for enum vpx_color_space */
/*!\brief List of supported color range */
typedef enum vpx_color_range {
VPX_CR_STUDIO_RANGE = 0, /**< Y [16..235], UV [16..240] */
VPX_CR_FULL_RANGE = 1 /**< YUV/RGB [0..255] */
} vpx_color_range_t; /**< alias for enum vpx_color_range */
/**\brief Image Descriptor */
typedef struct vpx_image {
vpx_img_fmt_t fmt; /**< Image Format */
vpx_color_space_t cs; /**< Color Space */
vpx_color_range_t range; /**< Color Range */
/* Image storage dimensions */
unsigned int w; /**< Stored image width */
unsigned int h; /**< Stored image height */
unsigned int bit_depth; /**< Stored image bit-depth */
/* Image display dimensions */
unsigned int d_w; /**< Displayed image width */
unsigned int d_h; /**< Displayed image height */
/* Image intended rendering dimensions */
unsigned int r_w; /**< Intended rendering image width */
unsigned int r_h; /**< Intended rendering image height */
/* Chroma subsampling info */
unsigned int x_chroma_shift; /**< subsampling order, X */
unsigned int y_chroma_shift; /**< subsampling order, Y */
/* Image data pointers. */
#define VPX_PLANE_PACKED 0 /**< To be used for all packed formats */
#define VPX_PLANE_Y 0 /**< Y (Luminance) plane */
#define VPX_PLANE_U 1 /**< U (Chroma) plane */
#define VPX_PLANE_V 2 /**< V (Chroma) plane */
#define VPX_PLANE_ALPHA 3 /**< A (Transparency) plane */
unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
int stride[4]; /**< stride between rows for each plane */
int bps; /**< bits per sample (for packed formats) */
/*!\brief The following member may be set by the application to associate
* data with this image.
*/
void *user_priv;
/* The following members should be treated as private. */
unsigned char *img_data; /**< private */
int img_data_owner; /**< private */
int self_allocd; /**< private */
void *fb_priv; /**< Frame buffer data associated with the image. */
} vpx_image_t; /**< alias for struct vpx_image */
/**\brief Representation of a rectangle on a surface */
typedef struct vpx_image_rect {
unsigned int x; /**< leftmost column */
unsigned int y; /**< topmost row */
unsigned int w; /**< width */
unsigned int h; /**< height */
} vpx_image_rect_t; /**< alias for struct vpx_image_rect */
/*!\brief Open a descriptor, allocating storage for the underlying image
*
* Returns a descriptor for storing an image of the given format. The
* storage for the descriptor is allocated on the heap.
*
* \param[in] img Pointer to storage for descriptor. If this parameter
* is NULL, the storage for the descriptor will be
* allocated on the heap.
* \param[in] fmt Format for the image
* \param[in] d_w Width of the image
* \param[in] d_h Height of the image
* \param[in] align Alignment, in bytes, of the image buffer and
* each row in the image(stride).
*
* \return Returns a pointer to the initialized image descriptor. If the img
* parameter is non-null, the value of the img parameter will be
* returned.
*/
vpx_image_t *vpx_img_alloc(vpx_image_t *img, vpx_img_fmt_t fmt,
unsigned int d_w, unsigned int d_h,
unsigned int align);
/*!\brief Open a descriptor, using existing storage for the underlying image
*
* Returns a descriptor for storing an image of the given format. The
* storage for descriptor has been allocated elsewhere, and a descriptor is
* desired to "wrap" that storage.
*
* \param[in] img Pointer to storage for descriptor. If this
* parameter is NULL, the storage for the descriptor
* will be allocated on the heap.
* \param[in] fmt Format for the image
* \param[in] d_w Width of the image
* \param[in] d_h Height of the image
* \param[in] stride_align Alignment, in bytes, of each row in the image.
* \param[in] img_data Storage to use for the image
*
* \return Returns a pointer to the initialized image descriptor. If the img
* parameter is non-null, the value of the img parameter will be
* returned.
*/
vpx_image_t *vpx_img_wrap(vpx_image_t *img, vpx_img_fmt_t fmt, unsigned int d_w,
unsigned int d_h, unsigned int stride_align,
unsigned char *img_data);
/*!\brief Set the rectangle identifying the displayed portion of the image
*
* Updates the displayed rectangle (aka viewport) on the image surface to
* match the specified coordinates and size.
*
* \param[in] img Image descriptor
* \param[in] x leftmost column
* \param[in] y topmost row
* \param[in] w width
* \param[in] h height
*
* \return 0 if the requested rectangle is valid, nonzero otherwise.
*/
int vpx_img_set_rect(vpx_image_t *img, unsigned int x, unsigned int y,
unsigned int w, unsigned int h);
/*!\brief Flip the image vertically (top for bottom)
*
* Adjusts the image descriptor's pointers and strides to make the image
* be referenced upside-down.
*
* \param[in] img Image descriptor
*/
void vpx_img_flip(vpx_image_t *img);
/*!\brief Close an image descriptor
*
* Frees all allocated storage associated with an image descriptor.
*
* \param[in] img Image descriptor
*/
void vpx_img_free(vpx_image_t *img);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VPX_VPX_VPX_IMAGE_H_

View file

@ -0,0 +1,40 @@
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VPX_VPX_VPX_INTEGER_H_
#define VPX_VPX_VPX_INTEGER_H_
/* get ptrdiff_t, size_t, wchar_t, NULL */
#include <stddef.h>
#if defined(_MSC_VER)
#define VPX_FORCE_INLINE __forceinline
#define VPX_INLINE __inline
#else
#define VPX_FORCE_INLINE __inline__ __attribute__((always_inline))
// TODO(jbb): Allow a way to force inline off for older compilers.
#define VPX_INLINE inline
#endif
/* Assume platforms have the C99 standard integer types. */
#if defined(__cplusplus)
#if !defined(__STDC_FORMAT_MACROS)
#define __STDC_FORMAT_MACROS
#endif
#if !defined(__STDC_LIMIT_MACROS)
#define __STDC_LIMIT_MACROS
#endif
#endif // __cplusplus
#include <inttypes.h>
#include <stdint.h>
#endif // VPX_VPX_VPX_INTEGER_H_

View file

@ -84,9 +84,9 @@ UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const U
#elif (defined(__clang__) && (__clang_major__ >= 3)) \
|| (defined(__GNUC__) && (__GNUC__ > 4))
#if !defined(__ARM_FEATURE_CRC32)
#define __ARM_FEATURE_CRC32 1
//#define __ARM_FEATURE_CRC32 1
#if (!defined(__clang__) || (__clang_major__ > 3)) // fix these numbers
#define ATTRIB_CRC __attribute__((__target__("arch=armv8-a+crc")))
//#define ATTRIB_CRC __attribute__((__target__("arch=armv8-a+crc")))
#endif
#endif
#if defined(__ARM_FEATURE_CRC32)

View file

@ -387,6 +387,9 @@ void FSoundFontManager::ProcessOneFile(const FString &fn)
//
//
//==========================================================================
#ifdef __MOBILE__
static const char *resFilePath_c = "/sdcard/RazeXR";
#endif
void FSoundFontManager::CollectSoundfonts()
{
@ -428,6 +431,12 @@ void FSoundFontManager::CollectSoundfonts()
}
}
#ifdef __MOBILE__
FStringf sf2path("%s/%s", resFilePath_c, "raze.sf2");
ProcessOneFile(NicePath(sf2path));
return;
#endif
if (soundfonts.Size() == 0)
{
ProcessOneFile(NicePath("$PROGDIR/soundfonts/" GAMENAMELOWERCASE ".sf2"));

View file

@ -106,7 +106,7 @@ union UCVarValue
};
template <ECVarType t> constexpr UCVarValue CVarValue(bool v) { static_assert(t == CVAR_Bool); return v; }
template <ECVarType t> constexpr UCVarValue CVarValue(int v) { static_assert(t == CVAR_Int || t == CVAR_Color); return v; }
template <ECVarType t> constexpr UCVarValue CVarValue(int v) { /*static_assert(t == CVAR_Int || t == CVAR_Color);*/ return v; }
template <ECVarType t> constexpr UCVarValue CVarValue(float v) { static_assert(t == CVAR_Float); return v; }
template <ECVarType t> constexpr UCVarValue CVarValue(double v) { static_assert(t == CVAR_Float); return v; }
template <ECVarType t> constexpr UCVarValue CVarValue(const char* v) { static_assert(t == CVAR_String); return v; }

View file

@ -0,0 +1,425 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/param.h>
#include <string.h>
#include <errno.h>
#ifdef __linux__
#include <sys/prctl.h>
#ifndef PR_SET_PTRACER
#define PR_SET_PTRACER 0x59616d61
#endif
#elif defined (__APPLE__) || defined (BSD)
#include <signal.h>
#endif
static const char crash_switch[] = "--cc-handle-crash";
static const char fatal_err[] = "\n\n*** Fatal Error ***\n";
static const char pipe_err[] = "!!! Failed to create pipe\n";
static const char fork_err[] = "!!! Failed to fork debug process\n";
static const char exec_err[] = "!!! Failed to exec debug process\n";
static char argv0[PATH_MAX];
static char altstack[SIGSTKSZ];
static struct {
int signum;
pid_t pid;
int has_siginfo;
siginfo_t siginfo;
char buf[4096];
} crash_info;
static const struct {
const char *name;
int signum;
} signals[] = {
{ "Segmentation fault", SIGSEGV },
{ "Illegal instruction", SIGILL },
{ "FPU exception", SIGFPE },
{ "System BUS error", SIGBUS },
{ NULL, 0 }
};
static const struct {
int code;
const char *name;
} sigill_codes[] = {
#ifndef __FreeBSD__
{ ILL_ILLOPC, "Illegal opcode" },
{ ILL_ILLOPN, "Illegal operand" },
{ ILL_ILLADR, "Illegal addressing mode" },
{ ILL_ILLTRP, "Illegal trap" },
{ ILL_PRVOPC, "Privileged opcode" },
{ ILL_PRVREG, "Privileged register" },
{ ILL_COPROC, "Coprocessor error" },
{ ILL_BADSTK, "Internal stack error" },
#endif
{ 0, NULL }
};
static const struct {
int code;
const char *name;
} sigfpe_codes[] = {
{ FPE_INTDIV, "Integer divide by zero" },
{ FPE_INTOVF, "Integer overflow" },
{ FPE_FLTDIV, "Floating point divide by zero" },
{ FPE_FLTOVF, "Floating point overflow" },
{ FPE_FLTUND, "Floating point underflow" },
{ FPE_FLTRES, "Floating point inexact result" },
{ FPE_FLTINV, "Floating point invalid operation" },
{ FPE_FLTSUB, "Subscript out of range" },
{ 0, NULL }
};
static const struct {
int code;
const char *name;
} sigsegv_codes[] = {
#ifndef __FreeBSD__
{ SEGV_MAPERR, "Address not mapped to object" },
{ SEGV_ACCERR, "Invalid permissions for mapped object" },
#endif
{ 0, NULL }
};
static const struct {
int code;
const char *name;
} sigbus_codes[] = {
#ifndef __FreeBSD__
{ BUS_ADRALN, "Invalid address alignment" },
{ BUS_ADRERR, "Non-existent physical address" },
{ BUS_OBJERR, "Object specific hardware error" },
#endif
{ 0, NULL }
};
static int (*cc_user_info)(char*, char*);
static void gdb_info(pid_t pid)
{
char respfile[64];
char cmd_buf[128];
FILE *f;
int fd;
/* Create a temp file to put gdb commands into */
strcpy(respfile, "gdb-respfile-XXXXXX");
if((fd=mkstemp(respfile)) >= 0 && (f=fdopen(fd, "w")) != NULL)
{
fprintf(f, "attach %d\n"
"shell echo \"\"\n"
"shell echo \"* Loaded Libraries\"\n"
"info sharedlibrary\n"
"shell echo \"\"\n"
"shell echo \"* Threads\"\n"
"info threads\n"
"shell echo \"\"\n"
"shell echo \"* FPU Status\"\n"
"info float\n"
"shell echo \"\"\n"
"shell echo \"* Registers\"\n"
"info registers\n"
"shell echo \"\"\n"
"shell echo \"* Backtrace\"\n"
"thread apply all backtrace full\n"
"detach\n"
"quit\n", pid);
fclose(f);
/* Run gdb and print process info. */
snprintf(cmd_buf, sizeof(cmd_buf), "gdb --quiet --batch --command=%s", respfile);
printf("Executing: %s\n", cmd_buf);
fflush(stdout);
system(cmd_buf);
/* Clean up */
remove(respfile);
}
else
{
/* Error creating temp file */
if(fd >= 0)
{
close(fd);
remove(respfile);
}
printf("!!! Could not create gdb command file\n");
}
fflush(stdout);
}
static void sys_info(void)
{
#ifdef __unix__
system("echo \"System: `uname -a`\"");
putchar('\n');
fflush(stdout);
#endif
}
static size_t safe_write(int fd, const void *buf, size_t len)
{
size_t ret = 0;
while(ret < len)
{
ssize_t rem;
if((rem=write(fd, (const char*)buf+ret, len-ret)) == -1)
{
if(errno == EINTR)
continue;
break;
}
ret += rem;
}
return ret;
}
static void crash_catcher(int signum, siginfo_t *siginfo, void *context)
{
//ucontext_t *ucontext = (ucontext_t*)context;
pid_t dbg_pid;
int fd[2];
/* Make sure the effective uid is the real uid */
if(getuid() != geteuid())
{
raise(signum);
return;
}
safe_write(STDERR_FILENO, fatal_err, sizeof(fatal_err)-1);
if(pipe(fd) == -1)
{
safe_write(STDERR_FILENO, pipe_err, sizeof(pipe_err)-1);
raise(signum);
return;
}
crash_info.signum = signum;
crash_info.pid = getpid();
crash_info.has_siginfo = !!siginfo;
if(siginfo)
crash_info.siginfo = *siginfo;
if(cc_user_info)
cc_user_info(crash_info.buf, crash_info.buf+sizeof(crash_info.buf));
/* Fork off to start a crash handler */
switch((dbg_pid=fork()))
{
/* Error */
case -1:
safe_write(STDERR_FILENO, fork_err, sizeof(fork_err)-1);
raise(signum);
return;
case 0:
dup2(fd[0], STDIN_FILENO);
close(fd[0]);
close(fd[1]);
execl(argv0, argv0, crash_switch, NULL);
safe_write(STDERR_FILENO, exec_err, sizeof(exec_err)-1);
_exit(1);
default:
#ifdef __linux__
prctl(PR_SET_PTRACER, dbg_pid, 0, 0, 0);
#endif
safe_write(fd[1], &crash_info, sizeof(crash_info));
close(fd[0]);
close(fd[1]);
/* Wait; we'll be killed when gdb is done */
do {
int status;
if(waitpid(dbg_pid, &status, 0) == dbg_pid &&
(WIFEXITED(status) || WIFSIGNALED(status)))
{
/* The debug process died before it could kill us */
raise(signum);
break;
}
} while(1);
}
}
static void crash_handler(const char *logfile)
{
const char *sigdesc = "";
int i;
if(fread(&crash_info, sizeof(crash_info), 1, stdin) != 1)
{
fprintf(stderr, "!!! Failed to retrieve info from crashed process\n");
exit(1);
}
/* Get the signal description */
for(i = 0;signals[i].name;++i)
{
if(signals[i].signum == crash_info.signum)
{
sigdesc = signals[i].name;
break;
}
}
if(crash_info.has_siginfo)
{
switch(crash_info.signum)
{
case SIGSEGV:
for(i = 0;sigsegv_codes[i].name;++i)
{
if(sigsegv_codes[i].code == crash_info.siginfo.si_code)
{
sigdesc = sigsegv_codes[i].name;
break;
}
}
break;
case SIGFPE:
for(i = 0;sigfpe_codes[i].name;++i)
{
if(sigfpe_codes[i].code == crash_info.siginfo.si_code)
{
sigdesc = sigfpe_codes[i].name;
break;
}
}
break;
case SIGILL:
for(i = 0;sigill_codes[i].name;++i)
{
if(sigill_codes[i].code == crash_info.siginfo.si_code)
{
sigdesc = sigill_codes[i].name;
break;
}
}
break;
case SIGBUS:
for(i = 0;sigbus_codes[i].name;++i)
{
if(sigbus_codes[i].code == crash_info.siginfo.si_code)
{
sigdesc = sigbus_codes[i].name;
break;
}
}
break;
}
}
fprintf(stderr, "%s (signal %i)\n", sigdesc, crash_info.signum);
if(crash_info.has_siginfo)
fprintf(stderr, "Address: %p\n", crash_info.siginfo.si_addr);
fputc('\n', stderr);
if(logfile)
{
/* Create crash log file and redirect shell output to it */
if(freopen(logfile, "wa", stdout) != stdout)
{
fprintf(stderr, "!!! Could not create %s following signal\n", logfile);
exit(1);
}
fprintf(stderr, "Generating %s and killing process %d, please wait... ", logfile, crash_info.pid);
printf("*** Fatal Error ***\n"
"%s (signal %i)\n", sigdesc, crash_info.signum);
if(crash_info.has_siginfo)
printf("Address: %p\n", crash_info.siginfo.si_addr);
fputc('\n', stdout);
fflush(stdout);
}
sys_info();
crash_info.buf[sizeof(crash_info.buf)-1] = '\0';
printf("%s\n", crash_info.buf);
fflush(stdout);
if(crash_info.pid > 0)
{
gdb_info(crash_info.pid);
kill(crash_info.pid, SIGKILL);
}
if(logfile)
{
const char *str;
char buf[512];
if((str=getenv("KDE_FULL_SESSION")) && strcmp(str, "true") == 0)
snprintf(buf, sizeof(buf), "kdialog --title \"Very Fatal Error\" --textbox \"%s\" 800 600", logfile);
else if((str=getenv("GNOME_DESKTOP_SESSION_ID")) && str[0] != '\0')
snprintf(buf, sizeof(buf), "gxmessage -buttons \"Okay:0\" -geometry 800x600 -title \"Very Fatal Error\" -center -file \"%s\"", logfile);
else
snprintf(buf, sizeof(buf), "xmessage -buttons \"Okay:0\" -center -file \"%s\"", logfile);
system(buf);
}
exit(0);
}
int cc_install_handlers(int argc, char **argv, int num_signals, int *signals, const char *logfile, int (*user_info)(char*, char*))
{
struct sigaction sa;
stack_t altss;
int retval;
if(argc == 2 && strcmp(argv[1], crash_switch) == 0)
crash_handler(logfile);
cc_user_info = user_info;
if(argv[0][0] == '/')
snprintf(argv0, sizeof(argv0), "%s", argv[0]);
else
{
getcwd(argv0, sizeof(argv0));
retval = strlen(argv0);
snprintf(argv0+retval, sizeof(argv0)-retval, "/%s", argv[0]);
}
/* Set an alternate signal stack so SIGSEGVs caused by stack overflows
* still run */
altss.ss_sp = altstack;
altss.ss_flags = 0;
altss.ss_size = sizeof(altstack);
sigaltstack(&altss, NULL);
memset(&sa, 0, sizeof(sa));
sa.sa_sigaction = crash_catcher;
sa.sa_flags = SA_RESETHAND | SA_NODEFER | SA_SIGINFO | SA_ONSTACK;
sigemptyset(&sa.sa_mask);
retval = 0;
while(num_signals--)
{
if((*signals != SIGSEGV && *signals != SIGILL && *signals != SIGFPE &&
*signals != SIGBUS) || sigaction(*signals, &sa, NULL) == -1)
{
*signals = 0;
retval = -1;
}
++signals;
}
return retval;
}

View file

@ -0,0 +1,45 @@
#ifndef __POSIX_SDL_GL_SYSFB_H__
#define __POSIX_SDL_GL_SYSFB_H__
#include "v_video.h"
class SystemBaseFrameBuffer : public DFrameBuffer
{
typedef DFrameBuffer Super;
public:
// this must have the same parameters as the Windows version, even if they are not used!
SystemBaseFrameBuffer (void *hMonitor, bool fullscreen);
bool IsFullscreen() override;
int GetClientWidth() override;
int GetClientHeight() override;
void ToggleFullscreen(bool yes) override;
void SetWindowSize(int client_w, int client_h) override;
protected:
SystemBaseFrameBuffer () {}
};
class SystemGLFrameBuffer : public SystemBaseFrameBuffer
{
typedef SystemBaseFrameBuffer Super;
public:
SystemGLFrameBuffer(void *hMonitor, bool fullscreen);
~SystemGLFrameBuffer();
int GetClientWidth() override;
int GetClientHeight() override;
virtual void SetVSync(bool vsync) override;
void SwapBuffers();
protected:
SystemGLFrameBuffer() {}
};
#endif // __POSIX_SDL_GL_SYSFB_H__

View file

@ -0,0 +1,481 @@
/*
** sdlglvideo.cpp
**
**---------------------------------------------------------------------------
** Copyright 2005-2016 Christoph Oelckers et.al.
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
// HEADER FILES ------------------------------------------------------------
#include "i_module.h"
#include "i_soundinternal.h"
#include "i_system.h"
#include "i_video.h"
#include "m_argv.h"
#include "v_video.h"
#include "version.h"
#include "c_console.h"
#include "c_dispatch.h"
#include "printf.h"
#include "hardware.h"
#include "gl_sysfb.h"
#include "gl_system.h"
#include "gl_renderer.h"
#include "gl_framebuffer.h"
#ifdef HAVE_GLES2
#include "gles_framebuffer.h"
#endif
#ifdef HAVE_VULKAN
#include "vulkan/system/vk_framebuffer.h"
#endif
#ifdef HAVE_SOFTPOLY
#include "poly_framebuffer.h"
#endif
void RazeXR_GetScreenRes(uint32_t *width, uint32_t *height);
// MACROS ------------------------------------------------------------------
#if defined HAVE_VULKAN
#include <SDL_vulkan.h>
#endif // HAVE_VULKAN
// TYPES -------------------------------------------------------------------
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
extern IVideo *Video;
EXTERN_CVAR (Int, vid_adapter)
EXTERN_CVAR (Int, vid_displaybits)
EXTERN_CVAR (Int, vid_defwidth)
EXTERN_CVAR (Int, vid_defheight)
EXTERN_CVAR (Int, vid_preferbackend)
EXTERN_CVAR (Bool, cl_capfps)
// PUBLIC DATA DEFINITIONS -------------------------------------------------
CUSTOM_CVAR(Bool, gl_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
Printf("This won't take effect until " GAMENAME " is restarted.\n");
}
CUSTOM_CVAR(Bool, gl_es, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
Printf("This won't take effect until " GAMENAME " is restarted.\n");
}
CVAR (Int, vid_adapter, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CUSTOM_CVAR(String, vid_sdl_render_driver, "", CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
{
Printf("This won't take effect until " GAMENAME " is restarted.\n");
}
CCMD(vid_list_sdl_render_drivers)
{
}
// PRIVATE DATA DEFINITIONS ------------------------------------------------
class GLVideo : public IVideo
{
public:
GLVideo ();
~GLVideo ();
DFrameBuffer *CreateFrameBuffer ();
private:
#ifdef HAVE_VULKAN
VulkanDevice *device = nullptr;
#endif
};
// CODE --------------------------------------------------------------------
#ifdef HAVE_VULKAN
void I_GetVulkanDrawableSize(int *width, int *height)
{
assert(Priv::vulkanEnabled);
assert(Priv::window != nullptr);
SDL_Vulkan_GetDrawableSize(Priv::window, width, height);
}
bool I_GetVulkanPlatformExtensions(unsigned int *count, const char **names)
{
assert(Priv::vulkanEnabled);
assert(Priv::window != nullptr);
return SDL_Vulkan_GetInstanceExtensions(Priv::window, count, names) == SDL_TRUE;
}
bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
{
assert(Priv::vulkanEnabled);
assert(Priv::window != nullptr);
return SDL_Vulkan_CreateSurface(Priv::window, instance, surface) == SDL_TRUE;
}
#endif
#ifdef HAVE_SOFTPOLY
namespace
{
SDL_Renderer* polyrendertarget = nullptr;
SDL_Texture* polytexture = nullptr;
int polytexturew = 0;
int polytextureh = 0;
bool polyvsync = false;
bool polyfirstinit = true;
}
void I_PolyPresentInit()
{
assert(Priv::softpolyEnabled);
assert(Priv::window != nullptr);
if (strcmp(vid_sdl_render_driver, "") != 0)
{
SDL_SetHint(SDL_HINT_RENDER_DRIVER, vid_sdl_render_driver);
}
}
uint8_t *I_PolyPresentLock(int w, int h, bool vsync, int &pitch)
{
// When vsync changes we need to reinitialize
if (polyrendertarget && polyvsync != vsync)
{
I_PolyPresentDeinit();
}
if (!polyrendertarget)
{
polyvsync = vsync;
polyrendertarget = SDL_CreateRenderer(Priv::window, -1, vsync ? SDL_RENDERER_PRESENTVSYNC : 0);
if (!polyrendertarget)
{
I_FatalError("Could not create render target for softpoly: %s\n", SDL_GetError());
}
// Tell the user which render driver is being used, but don't repeat
// outselves if we're just changing vsync.
if (polyfirstinit)
{
polyfirstinit = false;
SDL_RendererInfo rendererInfo;
if (SDL_GetRendererInfo(polyrendertarget, &rendererInfo) == 0)
{
Printf("Using render driver %s\n", rendererInfo.name);
}
else
{
Printf("Failed to query render driver\n");
}
}
// Mask color
SDL_SetRenderDrawColor(polyrendertarget, 0, 0, 0, 255);
}
if (!polytexture || polytexturew != w || polytextureh != h)
{
if (polytexture)
{
SDL_DestroyTexture(polytexture);
polytexture = nullptr;
polytexturew = polytextureh = 0;
}
if ((polytexture = SDL_CreateTexture(polyrendertarget, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h)) == nullptr)
I_Error("Failed to create %dx%d render target texture.", w, h);
polytexturew = w;
polytextureh = h;
}
uint8_t* pixels;
SDL_LockTexture(polytexture, nullptr, (void**)&pixels, &pitch);
return pixels;
}
void I_PolyPresentUnlock(int x, int y, int width, int height)
{
SDL_UnlockTexture(polytexture);
int ClientWidth, ClientHeight;
SDL_GetRendererOutputSize(polyrendertarget, &ClientWidth, &ClientHeight);
SDL_Rect clearrects[4];
int count = 0;
if (y > 0)
{
clearrects[count].x = 0;
clearrects[count].y = 0;
clearrects[count].w = ClientWidth;
clearrects[count].h = y;
count++;
}
if (y + height < ClientHeight)
{
clearrects[count].x = 0;
clearrects[count].y = y + height;
clearrects[count].w = ClientWidth;
clearrects[count].h = ClientHeight - clearrects[count].y;
count++;
}
if (x > 0)
{
clearrects[count].x = 0;
clearrects[count].y = y;
clearrects[count].w = x;
clearrects[count].h = height;
count++;
}
if (x + width < ClientWidth)
{
clearrects[count].x = x + width;
clearrects[count].y = y;
clearrects[count].w = ClientWidth - clearrects[count].x;
clearrects[count].h = height;
count++;
}
if (count > 0)
SDL_RenderFillRects(polyrendertarget, clearrects, count);
SDL_Rect dstrect;
#ifdef __MOBILE__ // Make it fit the screen properly
dstrect.x = 0;
dstrect.y = 0;
dstrect.w = ClientWidth;
dstrect.h = ClientHeight;
#else
dstrect.x = x;
dstrect.y = y;
dstrect.w = width;
dstrect.h = height;
#endif
SDL_RenderCopy(polyrendertarget, polytexture, nullptr, &dstrect);
SDL_RenderPresent(polyrendertarget);
}
void I_PolyPresentDeinit()
{
if (polytexture)
{
SDL_DestroyTexture(polytexture);
polytexture = nullptr;
}
if (polyrendertarget)
{
SDL_DestroyRenderer(polyrendertarget);
polyrendertarget = nullptr;
}
}
#endif
GLVideo::GLVideo ()
{
#ifdef HAVE_SOFTPOLY
Priv::softpolyEnabled = vid_preferbackend == 2;
#endif
#ifdef HAVE_VULKAN
Priv::vulkanEnabled = vid_preferbackend == 1;
if (Priv::vulkanEnabled)
{
Priv::CreateWindow(SDL_WINDOW_VULKAN | SDL_WINDOW_HIDDEN | (vid_fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0));
if (Priv::window == nullptr)
{
Priv::vulkanEnabled = false;
}
}
#endif
#ifdef HAVE_SOFTPOLY
if (Priv::softpolyEnabled)
{
Priv::CreateWindow(SDL_WINDOW_HIDDEN);
if (Priv::window == nullptr)
{
I_FatalError("Could not create SoftPoly window:\n%s\n",SDL_GetError());
}
}
#endif
}
GLVideo::~GLVideo ()
{
#ifdef HAVE_VULKAN
delete device;
#endif
}
DFrameBuffer *GLVideo::CreateFrameBuffer ()
{
SystemBaseFrameBuffer *fb = nullptr;
// first try Vulkan, if that fails OpenGL
#ifdef HAVE_VULKAN
if (Priv::vulkanEnabled)
{
try
{
assert(device == nullptr);
device = new VulkanDevice();
fb = new VulkanFrameBuffer(nullptr, vid_fullscreen, device);
}
catch (CVulkanError const &error)
{
if (Priv::window != nullptr)
{
Priv::DestroyWindow();
}
Printf(TEXTCOLOR_RED "Initialization of Vulkan failed: %s\n", error.what());
Priv::vulkanEnabled = false;
}
}
#endif
#ifdef HAVE_SOFTPOLY
if (Priv::softpolyEnabled)
{
fb = new PolyFrameBuffer(nullptr, vid_fullscreen);
}
#endif
if (fb == nullptr)
{
fb = new OpenGLRenderer::OpenGLFrameBuffer(0, vid_fullscreen);
}
return fb;
}
IVideo *gl_CreateVideo()
{
return new GLVideo();
}
// FrameBuffer Implementation -----------------------------------------------
SystemBaseFrameBuffer::SystemBaseFrameBuffer (void *, bool fullscreen)
: DFrameBuffer (vid_defwidth, vid_defheight)
{
}
int SystemBaseFrameBuffer::GetClientWidth()
{
uint32_t w, h;
RazeXR_GetScreenRes(&w, &h);
int width = w;
return width;
}
int SystemBaseFrameBuffer::GetClientHeight()
{
uint32_t w, h;
RazeXR_GetScreenRes(&w, &h);
int height = h;
return height;
}
bool SystemBaseFrameBuffer::IsFullscreen ()
{
return true;
}
void SystemBaseFrameBuffer::ToggleFullscreen(bool yes)
{
}
void SystemBaseFrameBuffer::SetWindowSize(int w, int h)
{
}
SystemGLFrameBuffer::SystemGLFrameBuffer(void *hMonitor, bool fullscreen)
: SystemBaseFrameBuffer(hMonitor, fullscreen)
{
}
SystemGLFrameBuffer::~SystemGLFrameBuffer ()
{
}
int SystemGLFrameBuffer::GetClientWidth()
{
uint32_t w, h;
RazeXR_GetScreenRes(&w, &h);
int width = w;
return width;
}
int SystemGLFrameBuffer::GetClientHeight()
{
uint32_t w, h;
RazeXR_GetScreenRes(&w, &h);
int height = h;
return height;
}
void SystemGLFrameBuffer::SetVSync( bool vsync )
{
}
void SystemGLFrameBuffer::SwapBuffers()
{
}
// each platform has its own specific version of this function.
void I_SetWindowTitle(const char* caption)
{
}

View file

@ -0,0 +1,74 @@
/*
** hardware.cpp
** Somewhat OS-independant interface to the screen, mouse, keyboard, and stick
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include <signal.h>
#include "i_system.h"
#include "hardware.h"
#include "c_dispatch.h"
#include "v_text.h"
#include "m_argv.h"
#include "c_console.h"
#include "printf.h"
IVideo *Video;
void I_RestartRenderer();
void I_ShutdownGraphics ()
{
if (screen)
{
DFrameBuffer *s = screen;
screen = NULL;
delete s;
}
if (Video)
delete Video, Video = NULL;
}
void I_InitGraphics ()
{
#ifdef __APPLE__
SDL_SetHint(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, "0");
#endif // __APPLE__
extern IVideo *gl_CreateVideo();
Video = gl_CreateVideo();
if (Video == NULL)
I_FatalError ("Failed to initialize display");
}

View file

@ -0,0 +1,44 @@
/*
** i_gui.cpp
**
**---------------------------------------------------------------------------
** Copyright 2008 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 <string.h>
#include "bitmap.h"
#include "textures.h"
bool I_SetCursor(FGameTexture *cursorpic)
{
return true;
}

View file

@ -0,0 +1,92 @@
/*
** i_input.cpp
**
**---------------------------------------------------------------------------
** Copyright 2005-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 "m_argv.h"
#include "v_video.h"
#include "d_eventbase.h"
#include "d_gui.h"
#include "c_buttons.h"
#include "c_console.h"
#include "c_dispatch.h"
#include "dikeys.h"
#include "utf8.h"
#include "keydef.h"
#include "i_interface.h"
#include "engineerrors.h"
#include "i_interface.h"
static void I_CheckGUICapture ();
static void I_CheckNativeMouse ();
bool GUICapture;
static bool NativeMouse = true;
CVAR (Bool, use_mouse, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
extern int WaitingForKey, chatmodeon;
extern uint8_t ConsoleState;
static void I_CheckGUICapture ()
{
}
void I_SetMouseCapture()
{
}
void I_ReleaseMouseCapture()
{
}
static void I_CheckNativeMouse ()
{
}
void I_GetEvent ()
{
}
void I_StartTic ()
{
I_CheckGUICapture ();
I_CheckNativeMouse ();
I_GetEvent ();
}
void TBXR_FrameSetup();
void I_StartFrame ()
{
TBXR_FrameSetup();
}

View file

@ -0,0 +1,60 @@
/*
** i_joystick.cpp
**
**---------------------------------------------------------------------------
** Copyright 2005-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 "basics.h"
#include "cmdlib.h"
#include "m_joy.h"
#include "keydef.h"
void I_ShutdownInput()
{
}
void I_GetJoysticks(TArray<IJoystickConfig *> &sticks)
{
}
void I_GetAxes(float axes[NUM_JOYAXIS])
{
}
void I_ProcessJoysticks()
{
}
IJoystickConfig *I_UpdateDeviceList()
{
return NULL;
}

View file

@ -0,0 +1,192 @@
/*
** i_main.cpp
** System-specific startup code. Eventually calls D_DoomMain.
**
**---------------------------------------------------------------------------
** Copyright 1998-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.
**---------------------------------------------------------------------------
**
*/
// HEADER FILES ------------------------------------------------------------
#include <unistd.h>
#include <signal.h>
#include <new>
#include <sys/param.h>
#include <locale.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include "engineerrors.h"
#include "m_argv.h"
#include "c_console.h"
#include "version.h"
#include "cmdlib.h"
#include "engineerrors.h"
#include "i_system.h"
#include "i_interface.h"
#include "printf.h"
// MACROS ------------------------------------------------------------------
// TYPES -------------------------------------------------------------------
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
extern "C" int cc_install_handlers(int, char**, int, int*, const char*, int(*)(char*, char*));
#ifdef __APPLE__
void Mac_I_FatalError(const char* errortext);
#endif
#ifdef __linux__
void Linux_I_FatalError(const char* errortext);
#endif
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
int GameMain();
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
// PUBLIC DATA DEFINITIONS -------------------------------------------------
// The command line arguments.
FArgs *Args;
// PRIVATE DATA DEFINITIONS ------------------------------------------------
// CODE --------------------------------------------------------------------
static int GetCrashInfo (char *buffer, char *end)
{
if (sysCallbacks.CrashInfo) sysCallbacks.CrashInfo(buffer, end - buffer, "\n");
return strlen(buffer);
}
void I_DetectOS()
{
FString operatingSystem;
const char *paths[] = {"/etc/os-release", "/usr/lib/os-release"};
for (const char *path : paths)
{
struct stat dummy;
if (stat(path, &dummy) != 0)
continue;
char cmdline[256];
snprintf(cmdline, sizeof cmdline, ". %s && echo ${PRETTY_NAME}", path);
FILE *proc = popen(cmdline, "r");
if (proc == nullptr)
continue;
char distribution[256] = {};
fread(distribution, sizeof distribution - 1, 1, proc);
const size_t length = strlen(distribution);
if (length > 1)
{
distribution[length - 1] = '\0';
operatingSystem = distribution;
}
pclose(proc);
break;
}
utsname unameInfo;
if (uname(&unameInfo) == 0)
{
const char* const separator = operatingSystem.Len() > 0 ? ", " : "";
operatingSystem.AppendFormat("%s%s %s on %s", separator, unameInfo.sysname, unameInfo.release, unameInfo.machine);
}
if (operatingSystem.Len() > 0)
Printf("OS: %s\n", operatingSystem.GetChars());
}
int raze_main (int argc, char **argv)
{
#if !defined (__APPLE__)
{
int s[4] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS };
cc_install_handlers(argc, argv, 4, s, GAMENAMELOWERCASE "-crash.log", GetCrashInfo);
}
#endif // !__APPLE__
printf(GAMENAME" %s - %s - version\nCompiled on %s\n",
GetVersionString(), GetGitTime(), __DATE__);
seteuid (getuid ());
// Set LC_NUMERIC environment variable in case some library decides to
// clear the setlocale call at least this will be correct.
// Note that the LANG environment variable is overridden by LC_*
setenv ("LC_NUMERIC", "C", 1);
setlocale (LC_ALL, "C");
printf("\n");
Args = new FArgs(argc, argv);
// Should we even be doing anything with progdir on Unix systems?
char program[PATH_MAX];
if (realpath (argv[0], program) == NULL)
strcpy (program, argv[0]);
char *slash = strrchr (program, '/');
if (slash != NULL)
{
*(slash + 1) = '\0';
progdir = program;
}
else
{
progdir = "./";
}
const int result = GameMain();
#ifdef __ANDROID__
usleep(500* 1000);
exit(0);
#endif
return result;
}

View file

@ -0,0 +1,451 @@
/*
** i_system.cpp
** Main startup code
**
**---------------------------------------------------------------------------
** Copyright 1999-2016 Randy Heit
** Copyright 2019-2020 Christoph Oelckers
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include <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 <time.h>
#include <unistd.h>
#include <sys/ioctl.h>
#ifdef __linux__
#include <asm/unistd.h>
#include <linux/perf_event.h>
#include <sys/mman.h>
#include "printf.h"
#endif
#include "version.h"
#include "cmdlib.h"
#include "m_argv.h"
#include "i_sound.h"
#include "i_interface.h"
#include "v_font.h"
#include "c_cvars.h"
#include "palutil.h"
#include "st_start.h"
#ifndef NO_GTK
bool I_GtkAvailable ();
int I_PickIWad_Gtk (WadStuff *wads, int numwads, bool showwin, int defaultiwad);
void I_ShowFatalError_Gtk(const char* errortext);
#elif defined(__APPLE__)
int I_PickIWad_Cocoa (WadStuff *wads, int numwads, bool showwin, int defaultiwad);
#endif
double PerfToSec, PerfToMillisec;
CVAR(Bool, con_printansi, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE);
CVAR(Bool, con_4bitansi, false, CVAR_GLOBALCONFIG|CVAR_ARCHIVE);
extern FStartupScreen *StartWindow;
void I_SetIWADInfo()
{
}
extern "C" int I_FileAvailable(const char* filename)
{
FString cmd = "which {0} >/dev/null 2>&1";
cmd.Substitute("{0}", filename);
if (FILE* f = popen(cmd.GetChars(), "r"))
{
int status = pclose(f);
return WIFEXITED(status) && WEXITSTATUS(status) == 0;
}
return 0;
}
//
// I_Error
//
#ifdef __APPLE__
void Mac_I_FatalError(const char* errortext);
#endif
#ifdef __unix__
void Unix_I_FatalError(const char* errortext)
{
// Close window or exit fullscreen and release mouse capture
//SDL_QuitSubSystem(SDL_INIT_VIDEO);
if(I_FileAvailable("kdialog"))
{
FString cmd;
cmd << "kdialog --title \"" GAMENAME " " << GetVersionString()
<< "\" --msgbox \"" << errortext << "\"";
popen(cmd, "r");
}
#ifndef NO_GTK
else if (I_GtkAvailable())
{
I_ShowFatalError_Gtk(errortext);
}
#endif
else
{
FString title;
title << GAMENAME " " << GetVersionString();
//if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, errortext, NULL) < 0)
{
printf("\n%s\n", errortext);
}
}
}
#endif
void I_ShowFatalError(const char *message)
{
#ifdef __APPLE__
Mac_I_FatalError(message);
#elif defined __unix__
Unix_I_FatalError(message);
#else
// ???
#endif
}
bool PerfAvailable;
void CalculateCPUSpeed()
{
PerfAvailable = false;
PerfToMillisec = PerfToSec = 0.;
#ifdef __aarch64__
// [MK] on aarch64 rather than having to calculate cpu speed, there is
// already an independent frequency for the perf timer
uint64_t frq;
asm volatile("mrs %0, cntfrq_el0":"=r"(frq));
PerfAvailable = true;
PerfToSec = 1./frq;
PerfToMillisec = PerfToSec*1000.;
#elif defined(__linux__)
// [MK] read from perf values if we can
struct perf_event_attr pe;
memset(&pe,0,sizeof(struct perf_event_attr));
pe.type = PERF_TYPE_HARDWARE;
pe.size = sizeof(struct perf_event_attr);
pe.config = PERF_COUNT_HW_INSTRUCTIONS;
pe.disabled = 1;
pe.exclude_kernel = 1;
pe.exclude_hv = 1;
int fd = syscall(__NR_perf_event_open, &pe, 0, -1, -1, 0);
if (fd == -1)
{
return;
}
void *addr = mmap(nullptr, 4096, PROT_READ, MAP_SHARED, fd, 0);
if (addr == nullptr)
{
close(fd);
return;
}
struct perf_event_mmap_page *pc = (struct perf_event_mmap_page *)addr;
if (pc->cap_user_time != 1)
{
close(fd);
return;
}
double mhz = (1000LU << pc->time_shift) / (double)pc->time_mult;
PerfAvailable = true;
PerfToSec = .000001/mhz;
PerfToMillisec = PerfToSec*1000.;
if (!batchrun) Printf("CPU speed: %.0f MHz\n", mhz);
close(fd);
#endif
}
void CleanProgressBar()
{
if (!isatty(STDOUT_FILENO)) return;
struct winsize sizeOfWindow;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &sizeOfWindow);
fprintf(stdout,"\0337\033[%d;%dH\033[0J\0338",sizeOfWindow.ws_row, 0);
fflush(stdout);
}
static int ProgressBarCurPos, ProgressBarMaxPos;
void RedrawProgressBar(int CurPos, int MaxPos)
{
if (!isatty(STDOUT_FILENO)) return;
CleanProgressBar();
struct winsize sizeOfWindow;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &sizeOfWindow);
double progVal = std::clamp((double)CurPos / (double)MaxPos,0.0,1.0);
int curProgVal = std::clamp(int(sizeOfWindow.ws_col * progVal),0,(int)sizeOfWindow.ws_col);
char progressBuffer[512];
memset(progressBuffer,'.',512);
progressBuffer[sizeOfWindow.ws_col - 1] = 0;
int lengthOfStr = 0;
while (curProgVal-- > 0)
{
progressBuffer[lengthOfStr++] = '=';
if (lengthOfStr >= sizeOfWindow.ws_col - 1) break;
}
fprintf(stdout, "\0337\033[%d;%dH\033[2K[%s\033[%d;%dH]\0338", sizeOfWindow.ws_row, 0, progressBuffer, sizeOfWindow.ws_row, sizeOfWindow.ws_col);
fflush(stdout);
ProgressBarCurPos = CurPos;
ProgressBarMaxPos = MaxPos;
}
void I_PrintStr(const char *cp)
{
const char * srcp = cp;
FString printData = "";
bool terminal = isatty(STDOUT_FILENO);
while (*srcp != 0)
{
if (*srcp == 0x1c && con_printansi && terminal)
{
srcp += 1;
const uint8_t* scratch = (const uint8_t*)srcp; // GCC does not like direct casting of the parameter.
EColorRange range = V_ParseFontColor(scratch, CR_UNTRANSLATED, CR_YELLOW);
srcp = (char*)scratch;
if (range != CR_UNDEFINED)
{
PalEntry color = V_LogColorFromColorRange(range);
if (con_4bitansi)
{
float h, s, v, r, g, b;
int attrib = 0;
RGBtoHSV(color.r / 255.f, color.g / 255.f, color.b / 255.f, &h, &s, &v);
if (s != 0)
{ // color
HSVtoRGB(&r, &g, &b, h, 1, 1);
if (r == 1) attrib = 0x1;
if (g == 1) attrib |= 0x2;
if (b == 1) attrib |= 0x4;
if (v > 0.6) attrib |= 0x8;
}
else
{ // gray
if (v < 0.33) attrib = 0x8;
else if (v < 0.90) attrib = 0x7;
else attrib = 0xF;
}
printData.AppendFormat("\033[%um",((attrib & 0x8) ? 90 : 30) + (attrib & 0x7));
}
else printData.AppendFormat("\033[38;2;%u;%u;%um",color.r,color.g,color.b);
}
}
else if (*srcp != 0x1c && *srcp != 0x1d && *srcp != 0x1e && *srcp != 0x1f)
{
printData += *srcp++;
}
else
{
if (srcp[1] != 0) srcp += 2;
else break;
}
}
if (StartWindow) CleanProgressBar();
fputs(printData.GetChars(),stdout);
if (terminal) fputs("\033[0m",stdout);
if (StartWindow) RedrawProgressBar(ProgressBarCurPos,ProgressBarMaxPos);
}
int I_PickIWad (WadStuff *wads, int numwads, bool showwin, int defaultiwad, int&)
{
int i;
if (!showwin)
{
return defaultiwad;
}
#ifndef __APPLE__
if(I_FileAvailable("kdialog"))
{
FString cmd("kdialog --title \"" GAMENAME " ");
cmd << GetVersionString() << ": Select an IWAD to use\""
" --menu \"" GAMENAME " found more than one IWAD\n"
"Select from the list below to determine which one to use:\"";
for(i = 0; i < numwads; ++i)
{
const char *filepart = strrchr(wads[i].Path, '/');
if(filepart == NULL)
filepart = wads[i].Path;
else
filepart++;
// Menu entries are specified in "tag" "item" pairs, where when a
// particular item is selected (and the Okay button clicked), its
// corresponding tag is printed to stdout for identification.
cmd.AppendFormat(" \"%d\" \"%s (%s)\"", i, wads[i].Name.GetChars(), filepart);
}
if(defaultiwad >= 0 && defaultiwad < numwads)
{
const char *filepart = strrchr(wads[defaultiwad].Path, '/');
if(filepart == NULL)
filepart = wads[defaultiwad].Path;
else
filepart++;
cmd.AppendFormat(" --default \"%s (%s)\"", wads[defaultiwad].Name.GetChars(), filepart);
}
FILE *f = popen(cmd, "r");
if(f != NULL)
{
char gotstr[16];
if(fgets(gotstr, sizeof(gotstr), f) == NULL ||
sscanf(gotstr, "%d", &i) != 1)
i = -1;
// Exit status = 1 means the selection was canceled (either by
// Cancel/Esc or the X button), not that there was an error running
// the program. In that case, nothing was printed so fgets will
// have failed. Other values can indicate an error running the app,
// so fall back to whatever else can be used.
int status = pclose(f);
if(WIFEXITED(status) && (WEXITSTATUS(status) == 0 || WEXITSTATUS(status) == 1))
return i;
}
}
#endif
#ifndef NO_GTK
if (I_GtkAvailable())
{
return I_PickIWad_Gtk (wads, numwads, showwin, defaultiwad);
}
#endif
#ifdef __APPLE__
return I_PickIWad_Cocoa (wads, numwads, showwin, defaultiwad);
#endif
if (!isatty(fileno(stdin)))
{
return defaultiwad;
}
printf ("Please select a game wad (or 0 to exit):\n");
for (i = 0; i < numwads; ++i)
{
const char *filepart = strrchr (wads[i].Path, '/');
if (filepart == NULL)
filepart = wads[i].Path;
else
filepart++;
printf ("%d. %s (%s)\n", i+1, wads[i].Name.GetChars(), filepart);
}
printf ("Which one? ");
if (scanf ("%d", &i) != 1 || i > numwads)
return -1;
return i-1;
}
void I_PutInClipboard (const char *str)
{
}
FString I_GetFromClipboard (bool use_primary_selection)
{
return "";
}
FString I_GetCWD()
{
char curdir[512];
getcwd (curdir, sizeof(curdir));
FString ret(curdir);
return ret;
}
bool I_ChDir(const char* path)
{
return chdir(path) == 0;
}
// Return a random seed, preferably one with lots of entropy.
unsigned int I_MakeRNGSeed()
{
unsigned int seed;
int file;
// Try reading from /dev/urandom first, then /dev/random, then
// if all else fails, use a crappy seed from time().
seed = time(NULL);
file = open("/dev/urandom", O_RDONLY);
if (file < 0)
{
file = open("/dev/random", O_RDONLY);
}
if (file >= 0)
{
read(file, &seed, sizeof(seed));
close(file);
}
return seed;
}
void I_OpenShellFolder(const char* infolder)
{
char curdir[512];
getcwd (curdir, sizeof(curdir));
if (!chdir(infolder))
{
Printf("Opening folder: %s\n", infolder);
std::system("xdg-open .");
chdir(curdir);
}
else
{
Printf("Unable to open directory '%s\n", infolder);
}
}

View file

@ -0,0 +1,19 @@
#include <CoreFoundation/CoreFoundation.h>
#include "SDL.h"
void Mac_I_FatalError(const char* errortext)
{
// Close window or exit fullscreen and release mouse capture
SDL_Quit();
const CFStringRef errorString = CFStringCreateWithCStringNoCopy( kCFAllocatorDefault,
errortext, kCFStringEncodingASCII, kCFAllocatorNull );
if ( NULL != errorString )
{
CFOptionFlags dummy;
CFUserNotificationDisplayAlert( 0, kCFUserNotificationStopAlertLevel, NULL, NULL, NULL,
CFSTR( "Fatal Error" ), errorString, CFSTR( "Exit" ), NULL, NULL, &dummy );
CFRelease( errorString );
}
}

View file

@ -0,0 +1,295 @@
/*
** st_start.cpp
** Handles 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.
**---------------------------------------------------------------------------
**
*/
// HEADER FILES ------------------------------------------------------------
#include <unistd.h>
#include <sys/time.h>
#include <termios.h>
#include "st_start.h"
#include "i_system.h"
#include "c_cvars.h"
#include "engineerrors.h"
// MACROS ------------------------------------------------------------------
// TYPES -------------------------------------------------------------------
class FTTYStartupScreen : public FStartupScreen
{
public:
FTTYStartupScreen(int max_progress);
~FTTYStartupScreen();
void Progress();
void NetInit(const char *message, int num_players);
void NetProgress(int count);
void NetDone();
bool NetLoop(bool (*timer_callback)(void *), void *userdata);
protected:
bool DidNetInit;
int NetMaxPos, NetCurPos;
const char *TheNetMessage;
termios OldTermIOS;
};
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
extern void RedrawProgressBar(int CurPos, int MaxPos);
extern void CleanProgressBar();
// PRIVATE DATA DEFINITIONS ------------------------------------------------
static const char SpinnyProgressChars[4] = { '|', '/', '-', '\\' };
// CODE --------------------------------------------------------------------
//==========================================================================
//
// FStartupScreen :: CreateInstance
//
// Initializes the startup screen for the detected game.
// Sets the size of the progress bar and displays the startup screen.
//
//==========================================================================
FStartupScreen *FStartupScreen::CreateInstance(int max_progress, bool)
{
return new FTTYStartupScreen(max_progress);
}
//===========================================================================
//
// FTTYStartupScreen Constructor
//
// Sets the size of the progress bar and displays the startup screen.
//
//===========================================================================
FTTYStartupScreen::FTTYStartupScreen(int max_progress)
: FStartupScreen(max_progress)
{
DidNetInit = false;
NetMaxPos = 0;
NetCurPos = 0;
TheNetMessage = NULL;
}
//===========================================================================
//
// FTTYStartupScreen Destructor
//
// Called just before entering graphics mode to deconstruct the startup
// screen.
//
//===========================================================================
FTTYStartupScreen::~FTTYStartupScreen()
{
NetDone(); // Just in case it wasn't called yet and needs to be.
}
//===========================================================================
//
// FTTYStartupScreen :: Progress
//
//===========================================================================
void FTTYStartupScreen::Progress()
{
if (CurPos < MaxPos)
{
++CurPos;
}
RedrawProgressBar(CurPos, MaxPos);
}
//===========================================================================
//
// FTTYStartupScreen :: NetInit
//
// Sets stdin for unbuffered I/O, displays the given message, and shows
// a progress meter.
//
//===========================================================================
void FTTYStartupScreen::NetInit(const char *message, int numplayers)
{
if (!DidNetInit)
{
termios rawtermios;
CleanProgressBar();
fprintf (stderr, "Press 'Q' to abort network game synchronization.");
// Set stdin to raw mode so we can get keypresses in ST_CheckNetAbort()
// immediately without waiting for an EOL.
tcgetattr (STDIN_FILENO, &OldTermIOS);
rawtermios = OldTermIOS;
rawtermios.c_lflag &= ~(ICANON | ECHO);
tcsetattr (STDIN_FILENO, TCSANOW, &rawtermios);
DidNetInit = true;
}
if (numplayers == 1)
{
// Status message without any real progress info.
fprintf (stderr, "\n%s.", message);
}
else
{
fprintf (stderr, "\n%s: ", message);
}
fflush (stderr);
TheNetMessage = message;
NetMaxPos = numplayers;
NetCurPos = 0;
NetProgress(1); // You always know about yourself
}
//===========================================================================
//
// FTTYStartupScreen :: NetDone
//
// Restores the old stdin tty settings.
//
//===========================================================================
void FTTYStartupScreen::NetDone()
{
CleanProgressBar();
// Restore stdin settings
if (DidNetInit)
{
tcsetattr (STDIN_FILENO, TCSANOW, &OldTermIOS);
printf ("\n");
DidNetInit = false;
}
}
//===========================================================================
//
// FTTYStartupScreen :: NetProgress
//
// Sets the network progress meter. If count is 0, it gets bumped by 1.
// Otherwise, it is set to count.
//
//===========================================================================
void FTTYStartupScreen::NetProgress(int count)
{
int i;
if (count == 0)
{
NetCurPos++;
}
else if (count > 0)
{
NetCurPos = count;
}
if (NetMaxPos == 0)
{
// Spinny-type progress meter, because we're a guest waiting for the host.
fprintf (stderr, "\r%s: %c", TheNetMessage, SpinnyProgressChars[NetCurPos & 3]);
fflush (stderr);
}
else if (NetMaxPos > 1)
{
// Dotty-type progress meter.
fprintf (stderr, "\r%s: ", TheNetMessage);
for (i = 0; i < NetCurPos; ++i)
{
fputc ('.', stderr);
}
fprintf (stderr, "%*c[%2d/%2d]", NetMaxPos + 1 - NetCurPos, ' ', NetCurPos, NetMaxPos);
fflush (stderr);
}
}
//===========================================================================
//
// FTTYStartupScreen :: NetLoop
//
// The timer_callback function is called at least two times per second
// and passed the userdata value. It should return true to stop the loop and
// return control to the caller or false to continue the loop.
//
// ST_NetLoop will return true if the loop was halted by the callback and
// false if the loop was halted because the user wants to abort the
// network synchronization.
//
//===========================================================================
bool FTTYStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata)
{
fd_set rfds;
struct timeval tv;
int retval;
char k;
for (;;)
{
// Don't flood the network with packets on startup.
tv.tv_sec = 0;
tv.tv_usec = 500000;
FD_ZERO (&rfds);
FD_SET (STDIN_FILENO, &rfds);
retval = select (1, &rfds, NULL, NULL, &tv);
if (retval == -1)
{
// Error
}
else if (retval == 0)
{
if (timer_callback (userdata))
{
fputc ('\n', stderr);
return true;
}
}
else if (read (STDIN_FILENO, &k, 1) == 1)
{
// Check input on stdin
if (k == 'q' || k == 'Q')
{
fprintf (stderr, "\nNetwork game synchronization aborted.");
return false;
}
}
}
}

View file

@ -33,7 +33,7 @@
**/
#include <algorithm>
#include "gl_load.h"
#include "android_gl_load.h"
#include "gl_buffers.h"
#include "gl_renderstate.h"
#include "v_video.h"

View file

@ -1,7 +1,7 @@
#pragma once
#include "buffers.h"
#include "gl_load.h"
#include "android_gl_load.h"
#ifdef _MSC_VER
// silence bogus warning C4250: 'GLVertexBuffer': inherits 'GLBuffer::GLBuffer::SetData' via dominance

View file

@ -73,6 +73,8 @@ void gl_PrintStartupLog();
extern bool vid_hdr_active;
void DrawVersionString ();
namespace OpenGLRenderer
{
FGLRenderer *GLRenderer;
@ -195,6 +197,7 @@ void OpenGLFrameBuffer::Update()
Flush3D.Reset();
Flush3D.Clock();
DrawVersionString();
GLRenderer->Flush();
Flush3D.Unclock();
@ -202,6 +205,18 @@ void OpenGLFrameBuffer::Update()
Super::Update();
}
#ifdef __MOBILE__
uint8_t * gles_convertRGB(uint8_t* src, uint8_t * dst, int width, int height)
{
for (int i=0; i<width*height; i++) {
for (int j=0; j<3; j++)
*(dst++) = *(src++);
src++;
}
return dst;
}
#endif
void OpenGLFrameBuffer::CopyScreenToBuffer(int width, int height, uint8_t* scr)
{
IntRect bounds;
@ -213,7 +228,14 @@ void OpenGLFrameBuffer::CopyScreenToBuffer(int width, int height, uint8_t* scr)
// strictly speaking not needed as the glReadPixels should block until the scene is rendered, but this is to safeguard against shitty drivers
glFinish();
#ifdef __MOBILE__
uint8_t* tmp = (uint8_t *)M_Malloc(width * height * 4);
glReadPixels(0, 0, width, height, GL_RGBA,GL_UNSIGNED_BYTE, tmp);
gles_convertRGB( tmp, scr, width, height);
M_Free(tmp);
#else
glReadPixels(0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, scr);
#endif
}
//===========================================================================
@ -282,6 +304,11 @@ void OpenGLFrameBuffer::Swap()
RenderState()->SetVertexBuffer(screen->mVertexData); // Needed for Raze because it does not reset it
}
#ifdef __MOBILE__
GLRenderer->mShaderManager->SetActiveShader(0);
#endif
Finish.Unclock();
camtexcount = 0;
FHardwareTexture::UnbindAll();

View file

@ -149,6 +149,22 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
sourcetype = GL_BGRA;
}
#ifdef __MOBILE__
texformat = sourcetype = GL_BGRA;
if (glTextureBytes == 1)
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
sourcetype = GL_RED;
texformat = GL_RED;
}
else
{
sourcetype = GL_BGRA;
texformat = GL_BGRA;
}
#endif
if (!firstCall && glBufferID > 0)
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rw, rh, sourcetype, GL_UNSIGNED_BYTE, buffer);
else
@ -191,6 +207,9 @@ void FHardwareTexture::AllocateBuffer(int w, int h, int texelsize)
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, glBufferID);
glBufferData(GL_PIXEL_UNPACK_BUFFER, w*h*texelsize, nullptr, GL_STREAM_DRAW);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
#ifdef __MOBILE__
size = w*h*texelsize;
#endif
}
}
@ -198,7 +217,11 @@ void FHardwareTexture::AllocateBuffer(int w, int h, int texelsize)
uint8_t *FHardwareTexture::MapBuffer()
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, glBufferID);
#ifdef __MOBILE__
return (uint8_t*)glMapBufferRange (GL_PIXEL_UNPACK_BUFFER, 0, size, GL_MAP_WRITE_BIT );
#else
return (uint8_t*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
#endif
}
//===========================================================================

View file

@ -45,6 +45,9 @@ private:
unsigned int glBufferID = 0;
int glTextureBytes;
bool mipmapped = false;
#ifdef __MOBILE__
int size;
#endif
int GetDepthBuffer(int w, int h);

View file

@ -36,6 +36,8 @@
#include "hw_vrmodes.h"
#include "v_draw.h"
#include "gamestate.h"
#include "menustate.h"
extern bool vid_hdr_active;
@ -120,6 +122,7 @@ void FGLRenderer::Flush()
int eyeCount = vrmode->mEyeCount;
for (int eye_ix = 0; eye_ix < eyeCount; ++eye_ix)
{
screen->RenderState()->SetEye(eye_ix); // tell render state which eye's 2D we are drawing
screen->Draw2D();
if (eyeCount - eye_ix > 1)
mBuffers->NextEye(eyeCount);

View file

@ -311,6 +311,15 @@ PPGLTexture FGLRenderBuffers::Create2DTexture(const char *name, GLuint format, i
default: I_FatalError("Unknown format passed to FGLRenderBuffers.Create2DTexture");
}
#ifdef __MOBILE__ // FIXME
if( format == GL_RGBA16F )
{
format = GL_RGBA;
dataformat = GL_RGBA;
datatype = GL_UNSIGNED_BYTE;
}
#endif
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, dataformat, datatype, data);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@ -480,7 +489,13 @@ void FGLRenderBuffers::ClearFrameBuffer(bool stencil, bool depth)
GLdouble depthValue;
glGetBooleanv(GL_SCISSOR_TEST, &scissorEnabled);
glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilValue);
#ifdef __MOBILE__
GLfloat t;
glGetFloatv(GL_DEPTH_CLEAR_VALUE, &t);
depthValue = t;
#else
glGetDoublev(GL_DEPTH_CLEAR_VALUE, &depthValue);
#endif
glDisable(GL_SCISSOR_TEST);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClearDepth(0.0);

View file

@ -99,7 +99,7 @@ private:
void PresentRowInterleaved();
void PresentCheckerInterleaved();
void PresentQuadStereo();
void PresentOpenXR();
};
struct TexFilter_s

View file

@ -578,7 +578,7 @@ void FGLRenderState::ClearScreen()
{
bool multi = !!glIsEnabled(GL_MULTISAMPLE);
screen->mViewpoints->Set2D(*this, SCREENWIDTH, SCREENHEIGHT);
screen->mViewpoints->Set2D(nullptr, *this, SCREENWIDTH, SCREENHEIGHT);
SetColor(0, 0, 0);
Apply();

View file

@ -67,6 +67,9 @@ static std::map<FString, std::unique_ptr<ProgramBinary>> ShaderCache; // Not a T
bool IsShaderCacheActive()
{
#ifdef __MOBILE__
return true;
#endif
static bool active = true;
static bool firstcall = true;
@ -219,6 +222,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
// these settings are actually pointless but there seem to be some old ATI drivers that fail to compile the shader without setting the precision here.
precision highp int;
precision highp float;
precision highp sampler2DArray;
// This must match the HWViewpointUniforms struct
layout(std140) uniform ViewpointUBO {
@ -392,7 +396,12 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
unsigned int lightbuffersize = screen->mLights->GetBlockSize();
if (!lightbuffertype)
{
#ifdef __MOBILE__
vp_comb.Format("#version 310 es\n#define NO_CLIPDISTANCE_SUPPORT\n#define NUM_UBO_LIGHTS %d\n#define NUM_UBO_BONES %d\n", lightbuffersize, screen->mBones->GetBlockSize());
#else
vp_comb.Format("#version 330 core\n#define NUM_UBO_LIGHTS %d\n#define NUM_UBO_BONES %d\n", lightbuffersize, screen->mBones->GetBlockSize());
#endif
}
else
{

View file

@ -264,13 +264,26 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const
// If we have 4.2, always use it because it adds important new syntax.
if (maxGlslVersion < 420 && gl.glslversion >= 4.2f) maxGlslVersion = 420;
int shaderVersion = min((int)round(gl.glslversion * 10) * 10, maxGlslVersion);
#ifdef __MOBILE__
patchedCode.AppendFormat("#version 310 es\n#define NO_CLIPDISTANCE_SUPPORT\n");
#else
patchedCode.AppendFormat("#version %d\n", shaderVersion);
#endif
// TODO: Find some way to add extension requirements to the patching
//
// #extension GL_ARB_uniform_buffer_object : require
// #extension GL_ARB_shader_storage_buffer_object : require
#ifdef __MOBILE__ // Actually this is needed before the defines
patchedCode << "precision highp int;\n";
patchedCode << "precision highp float;\n";
patchedCode << "precision highp sampler2D;\n";
patchedCode << "precision highp samplerCube;\n";
patchedCode << "precision highp sampler2DMS;\n";
#endif
if (defines)
patchedCode << defines;

View file

@ -46,6 +46,10 @@
#include "gl_buffers.h"
#include "menu.h"
bool TBXR_IsFrameSetup();
void TBXR_prepareEyeBuffer(int eye );
void TBXR_finishEyeBuffer(int eye );
void TBXR_submitFrame();
EXTERN_CVAR(Int, vr_mode)
EXTERN_CVAR(Float, vid_saturation)
@ -375,6 +379,27 @@ bool FGLRenderer::QuadStereoCheckInitialRenderContextState()
//
//==========================================================================
void FGLRenderer::PresentOpenXR()
{
if (!TBXR_IsFrameSetup())
{
return;
}
for (int eye = 0; eye < 2; ++eye)
{
TBXR_prepareEyeBuffer(eye);
ClearBorders();
mBuffers->BindEyeTexture(eye, 0);
DrawPresentTexture(screen->mOutputLetterbox, true);
TBXR_finishEyeBuffer(eye);
}
TBXR_submitFrame();
}
void FGLRenderer::PresentQuadStereo()
{
if (QuadStereoCheckInitialRenderContextState())
@ -453,6 +478,10 @@ void FGLRenderer::PresentStereo()
case VR_QUADSTEREO:
PresentQuadStereo();
break;
case VR_OPENXR:
PresentOpenXR();
break;
}
}

View file

@ -113,6 +113,12 @@ void gl_LoadExtensions()
const char *glversion = (const char*)glGetString(GL_VERSION);
#ifdef __MOBILE__
glversion = "3.3";
gl.flags |= RFL_NO_CLIP_PLANES;
gl.flags |= RFL_INVALIDATE_BUFFER;
#endif
const char *version = Args->CheckValue("-glversion");
realglversion = strtod(glversion, NULL);

View file

@ -24,7 +24,7 @@
#include <fcntl.h>
//GL headers
#include "gl_load/gl_load.h"
#include "android_gl_load.h"
#if defined(__APPLE__)
#include <OpenGL/OpenGL.h>

View file

@ -120,7 +120,11 @@ CUSTOM_CVARD(Float, gl_texture_filter_anisotropic, 8.f, CVAR_ARCHIVE | CVAR_GLOB
screen->SetTextureFilterMode();
}
#ifdef __MOBILE__ // Default to Nearest mipmap
CUSTOM_CVARD(Int, gl_texture_filter, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL, "changes the texture filtering settings")
#else
CUSTOM_CVARD(Int, gl_texture_filter, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL, "changes the texture filtering settings")
#endif
{
if (self < 0 || self > 6) self=4;
screen->SetTextureFilterMode();

View file

@ -216,6 +216,7 @@ protected:
uint8_t mSplitEnabled : 1;
uint8_t mBrightmapEnabled : 1;
int mEye;
int mLightIndex;
int mBoneIndexBase;
int mSpecialEffect;
@ -256,6 +257,7 @@ public:
void Reset()
{
mEye = 0;
mTextureEnabled = true;
mBrightmapEnabled = mGradientEnabled = mFogEnabled = mGlowEnabled = false;
mFogColor = 0xffffffff;
@ -312,6 +314,11 @@ public:
ClearClipSplit();
}
void SetEye(int eye)
{
mEye = eye;
}
void SetNormal(FVector3 norm)
{
mStreamData.uVertexNormal = { norm.X, norm.Y, norm.Z, 0.f };
@ -609,6 +616,11 @@ public:
mBias.mUnits = 0;
}
int GetEye()
{
return mEye;
}
private:
void SetMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader)
{

View file

@ -66,12 +66,13 @@
//-----------------------------------------------------------------------------
//
// Shamelessly lifted from Doomsday (written by Jaakko Keränen)
// Shamelessly lifted from Doomsday (written by Jaakko Ker<EFBFBD>nen)
// also shamelessly lifted from ZDoomGL! ;)
//
//-----------------------------------------------------------------------------
CVAR(Float, skyoffset, 0.f, 0) // for testing
CVAR(Bool, draw_sky, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Int, skydome_columns, 8, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
struct SkyColor
{
@ -303,7 +304,7 @@ void FSkyVertexBuffer::CreateDome()
mVertices[10].Set(-1.0f, 0.0f, -1.0f);
mVertices[11].Set(0.0f, 0.0f, 1.0f);
mColumns = 128;
mColumns = skydome_columns;
mRows = 4;
CreateSkyHemisphereDoom(SKYHEMI_UPPER);
CreateSkyHemisphereDoom(SKYHEMI_LOWER);
@ -458,6 +459,11 @@ void FSkyVertexBuffer::RenderRow(FRenderState& state, EDrawType prim, int row, T
void FSkyVertexBuffer::DoRenderDome(FRenderState& state, FGameTexture* tex, int mode, bool which, PalEntry color)
{
if (!draw_sky)
{
return;
}
auto& primStart = which ? mPrimStartBuild : mPrimStartDoom;
if (tex && tex->isValid())
{

View file

@ -30,6 +30,9 @@
#include "hw_renderstate.h"
#include "hw_viewpointbuffer.h"
#include "hw_cvars.h"
#include "menustate.h" // Hack?!
#include "gamestate.h" // Hack?!
#include "hw_vrmodes.h"
static const int INITIAL_BUFFER_SIZE = 100; // 100 viewpoints per frame should nearly always be enough
@ -80,9 +83,12 @@ int HWViewpointBuffer::Bind(FRenderState &di, unsigned int index)
return index;
}
void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll)
void HWViewpointBuffer::Set2D(F2DDrawer *drawer, FRenderState &di, int width, int height, int pll)
{
HWViewpointUniforms matrices;
const bool isIn2D = drawer == nullptr || drawer->isIn2D;
const bool isDrawingFullscreen = (gamestate != GS_LEVEL) || menuactive != MENU_Off;
{
HWViewpointUniforms matrices;
matrices.mViewMatrix.loadIdentity();
matrices.mNormalViewMatrix.loadIdentity();
@ -92,16 +98,34 @@ void HWViewpointBuffer::Set2D(FRenderState &di, int width, int height, int pll)
matrices.mClipLine.X = -10000000.0f;
matrices.mShadowmapFilter = gl_shadowmap_filter;
matrices.mProjectionMatrix.ortho(0, (float)width, (float)height, 0, -1.0f, 1.0f);
matrices.CalcDependencies();
if (isDrawingFullscreen && isIn2D) //fullscreen 2D
{
matrices.mProjectionMatrix.ortho(0, (float) width, (float) height, 0, -1.0f, 1.0f);
}
else if (isIn2D) // HUD
{
auto vrmode = VRMode::GetVRMode(true);
matrices.mProjectionMatrix = vrmode->mEyes[di.GetEye()].GetHUDProjection(width, height);
}
else //Player Sprite
{
auto vrmode = VRMode::GetVRMode(true);
matrices.mProjectionMatrix = vrmode->mEyes[di.GetEye()].GetPlayerSpriteProjection(width, height);
}
matrices.CalcDependencies();
SetViewpoint(di, &matrices);
return;
mBuffer->Map();
memcpy(((char*)mBuffer->Memory()) + mUploadIndex * mBlockAlign, &matrices, sizeof(matrices));
mBuffer->Unmap();
for (int n = 0; n < mPipelineNbr; n++)
{
mBufferPipeline[n]->Map();
memcpy(mBufferPipeline[n]->Memory(), &matrices, sizeof(matrices));
mBufferPipeline[n]->Unmap();
}
mClipPlaneInfo.Push(0);
Bind(di, mUploadIndex++);
mLastMappedIndex = -1;
}
Bind(di, 0);
}
int HWViewpointBuffer::SetViewpoint(FRenderState &di, HWViewpointUniforms *vp)

View file

@ -29,7 +29,7 @@ public:
~HWViewpointBuffer();
void Clear();
int Bind(FRenderState &di, unsigned int index);
void Set2D(FRenderState &di, int width, int height, int pll = 0);
void Set2D(F2DDrawer *drawer, FRenderState &di, int width, int height, int pll = 0);
int SetViewpoint(FRenderState &di, HWViewpointUniforms *vp);
unsigned int GetBlockSize() const { return mBlockSize; }
};

View file

@ -38,24 +38,72 @@
#include "hw_cvars.h"
#include "hw_vrmodes.h"
#include "v_video.h"
#include "v_draw.h"
#include "version.h"
#include "i_interface.h"
#include "RazeXR/mathlib.h"
extern vec3_t hmdPosition;
extern vec3_t hmdOrigin;
extern vec3_t hmdorientation;
float RazeXR_GetFOV();
void VR_GetMove(float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up,
float *yaw, float *pitch, float *roll);
// Set up 3D-specific console variables:
CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
CVAR(Int, vr_mode, 15, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
// switch left and right eye views
CVAR(Bool, vr_swap_eyes, false, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
// intraocular distance in meters
CVAR(Float, vr_ipd, 0.062f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS
// distance between viewer and the display screen
CVAR(Float, vr_screendist, 0.80f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS
// default conversion between (vertical) DOOM units and meters
CVAR(Float, vr_hunits_per_meter, 41.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS
CVAR(Float, vr_hunits_per_meter, 24.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS
CVAR(Float, vr_height_adjust, 0.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS
CVAR(Int, vr_control_scheme, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)
CVAR(Bool, vr_move_use_offhand, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, vr_teleport, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_weaponRotate, -30, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_weaponScale, 1.02f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_snapTurn, 45.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Int, vr_move_speed, 19, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_run_multiplier, 1.5, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, vr_switch_sticks, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, vr_secondary_button_mappings, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, vr_two_handed_weapons, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, vr_positional_tracking, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, vr_crouch_use_button, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_pickup_haptic_level, 0.2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_quake_haptic_level, 0.8, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
//HUD control
CVAR(Float, vr_hud_scale, 0.5f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_hud_stereo, 2.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_hud_rotate, 0.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, vr_hud_fixed_pitch, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, vr_hud_fixed_roll, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
int playerHeight = 0;
float getHmdAdjustedHeightInMapUnit()
{
if (playerHeight != 0)
{
return ((hmdPosition[1] + vr_height_adjust) * vr_hunits_per_meter) -
playerHeight;
}
//Just use offset from origin
return ((hmdPosition[1] - hmdOrigin[1]) * vr_hunits_per_meter);
}
#define isqrt2 0.7071067812f
static VRMode vrmi_mono = { 1, 1.f, 1.f, 1.f,{ { 0.f, 1.f },{ 0.f, 0.f } } };
@ -82,6 +130,7 @@ const VRMode *VRMode::GetVRMode(bool toscreen)
case VR_QUADSTEREO:
case VR_AMBERBLUE:
case VR_SIDEBYSIDELETTERBOX:
case VR_OPENXR:
return &vrmi_stereo;
case VR_SIDEBYSIDESQUISHED:
@ -119,23 +168,133 @@ void VRMode::AdjustViewport(DFrameBuffer *screen) const
screen->mScreenViewport.left = (int)(screen->mScreenViewport.left * mHorizontalViewportScale);
}
VSMatrix VRMode::GetHUDSpriteProjection() const
extern float gameYaw;
float getViewpointYaw()
{
VSMatrix mat;
int w = screen->GetWidth();
int h = screen->GetHeight();
float scaled_w = w / mWeaponProjectionScale;
float left_ofs = (w - scaled_w) / 2.f;
mat.ortho(left_ofs, left_ofs + scaled_w, (float)h, 0, -1.0f, 1.0f);
return mat;
return gameYaw;
}
VSMatrix VREyeInfo::GetHUDProjection(int width, int height) const
{
// now render the main view
float fovratio;
float ratio = ActiveRatio(width, height);
if (ratio >= 1.33f)
{
fovratio = 1.33f;
}
else
{
fovratio = ratio;
}
VSMatrix new_projection;
new_projection.loadIdentity();
float stereo_separation = (vr_ipd * 0.5) * vr_hunits_per_meter * vr_hud_stereo * (getEye() == 1 ? 1.0 : -1.0);
new_projection.translate(stereo_separation, 0, 0);
// doom_units from meters
new_projection.scale(
-vr_hunits_per_meter,
vr_hunits_per_meter,
-vr_hunits_per_meter);
if (vr_hud_fixed_roll)
{
new_projection.rotate(-hmdorientation[ROLL], 0, 0, 1);
}
new_projection.rotate(vr_hud_rotate, 1, 0, 0);
if (vr_hud_fixed_pitch)
{
new_projection.rotate(-hmdorientation[PITCH], 1, 0, 0);
}
// hmd coordinates (meters) from ndc coordinates
// const float weapon_distance_meters = 0.55f;
// const float weapon_width_meters = 0.3f;
new_projection.translate(0.0, 0.0, 1.0);
new_projection.scale(
-vr_hud_scale,
vr_hud_scale,
-vr_hud_scale);
// ndc coordinates from pixel coordinates
new_projection.translate(-1.0, 1.0, 0);
new_projection.scale(2.0 / width, -2.0 / height, -1.0);
VSMatrix proj = GetProjection(RazeXR_GetFOV(), ratio, fovratio);
proj.multMatrix(new_projection);
new_projection = proj;
return new_projection;
}
VSMatrix VREyeInfo::GetPlayerSpriteProjection(int width, int height) const
{
// now render the main view
float fovratio;
float ratio = ActiveRatio(width, height);
if (ratio >= 1.33f)
{
fovratio = 1.33f;
}
else
{
fovratio = ratio;
}
VSMatrix new_projection;
new_projection.loadIdentity();
float weapon_stereo_effect = 2.8f;
float stereo_separation = (vr_ipd * 0.5) * vr_hunits_per_meter * weapon_stereo_effect * (getEye() == 1 ? -1.0 : 1.0);
new_projection.translate(stereo_separation, 0, 0);
// doom_units from meters
new_projection.scale(
-vr_hunits_per_meter,
vr_hunits_per_meter,
-vr_hunits_per_meter);
new_projection.rotate(-hmdorientation[ROLL], 0, 0, 1);
// hmd coordinates (meters) from ndc coordinates
// const float weapon_distance_meters = 0.55f;
// const float weapon_width_meters = 0.3f;
new_projection.translate(0.0, 0.0, 1.0);
float weapon_scale = 0.7f;
new_projection.scale(
-weapon_scale,
weapon_scale,
-weapon_scale);
// ndc coordinates from pixel coordinates
new_projection.translate(-1.0, 1.0, 0);
new_projection.scale(2.0 / width, -2.0 / height, -1.0);
VSMatrix proj = GetProjection(RazeXR_GetFOV(), ratio, fovratio);
proj.multMatrix(new_projection);
new_projection = proj;
return new_projection;
}
float VREyeInfo::getShift() const
{
auto res = mShiftFactor * vr_ipd;
return vr_swap_eyes ? -res : res;
return mShiftFactor * vr_ipd * vr_hunits_per_meter;
}
int VREyeInfo::getEye() const
{
return mShiftFactor < 0 ? 0 : 1;
}
bool VR_GetVRProjection(int eye, float zNear, float zFar, float* projection);
VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio) const
{
VSMatrix result;
@ -151,6 +310,7 @@ VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio)
double zNear = screen->GetZNear();
double zFar = screen->GetZFar();
// For stereo 3D, use asymmetric frustum shift in projection matrix
// Q: shouldn't shift vary with roll angle, at least for desktop display?
// A: No. (lab) roll is not measured on desktop display (yet)
@ -163,16 +323,19 @@ VSMatrix VREyeInfo::GetProjection(float fov, float aspectRatio, float fovRatio)
double bottom = -fH;
double top = fH;
VSMatrix fmat(1);
fmat.frustum((float)left, (float)right, (float)bottom, (float)top, (float)zNear, (float)zFar);
return fmat;
VSMatrix result(1);
result.frustum((float)left, (float)right, (float)bottom, (float)top, (float)zNear, (float)zFar);
float m[16];
VR_GetVRProjection(getEye(), zNear, zFar, m);
result.loadMatrix(m);
return result;
}
}
/* virtual */
DVector3 VREyeInfo::GetViewShift(float yaw) const
DVector3 VREyeInfo::GetViewShift(FRotator viewAngles) const
{
if (mShiftFactor == 0)
{
@ -181,9 +344,29 @@ DVector3 VREyeInfo::GetViewShift(float yaw) const
}
else
{
double dx = -cos(DEG2RAD(yaw)) * vr_hunits_per_meter * getShift();
double dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * getShift();
return { dx, dy, 0 };
vec3_t angles;
VectorSet(angles, viewAngles.Pitch.Degrees(), viewAngles.Yaw.Degrees(), viewAngles.Roll.Degrees());
vec3_t v_forward, v_right, v_up;
AngleVectors(angles, v_forward, v_right, v_up);
vec3_t tmp;
VectorScale(v_right, getShift(), tmp);
float posforward=0;
float posside=0;
float dummy=0;
VR_GetMove(&dummy, &dummy, &posforward, &posside, &dummy, &dummy, &dummy, &dummy);
DVector3 eyeOffset(tmp[0], tmp[1], tmp[2]);
if (vr_positional_tracking)
{
eyeOffset[1] += -posforward * vr_hunits_per_meter;
eyeOffset[0] += posside * vr_hunits_per_meter;
eyeOffset[2] += getHmdAdjustedHeightInMapUnit();
}
return {eyeOffset[1], eyeOffset[0], eyeOffset[2]};
}
}

View file

@ -19,7 +19,8 @@ enum
VR_TOPBOTTOM = 11,
VR_ROWINTERLEAVED = 12,
VR_COLUMNINTERLEAVED = 13,
VR_CHECKERINTERLEAVED = 14
VR_CHECKERINTERLEAVED = 14,
VR_OPENXR = 15
};
struct VREyeInfo
@ -28,10 +29,13 @@ struct VREyeInfo
float mScaleFactor;
VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const;
DVector3 GetViewShift(float yaw) const;
DVector3 GetViewShift(FRotator angles) const;
VSMatrix GetHUDProjection(int width, int height) const;
VSMatrix GetPlayerSpriteProjection(int width, int height) const;
private:
float getShift() const;
int getEye() const;
};
struct VRMode
@ -44,5 +48,4 @@ struct VRMode
static const VRMode *GetVRMode(bool toscreen = true);
void AdjustViewport(DFrameBuffer *fb) const;
VSMatrix GetHUDSpriteProjection() const;
};

View file

@ -62,7 +62,7 @@ void Draw2D(F2DDrawer* drawer, FRenderState& state, int x, int y, int width, int
twoD.Clock();
state.SetViewport(x, y, width, height);
screen->mViewpoints->Set2D(state, drawer->GetWidth(), drawer->GetHeight());
screen->mViewpoints->Set2D(drawer, state, drawer->GetWidth(), drawer->GetHeight());
state.EnableStencil(false);
state.SetStencil(0, SOP_Keep, SF_AllOn);

View file

@ -35,7 +35,11 @@ CUSTOM_CVAR(Float, gl_bloom_amount, 1.4f, CVAR_ARCHIVE)
CVAR(Float, gl_exposure_scale, 1.3f, CVAR_ARCHIVE)
CVAR(Float, gl_exposure_min, 0.35f, CVAR_ARCHIVE)
#ifdef __MOBILE__
CVAR(Float, gl_exposure_base, 0.1f, CVAR_ARCHIVE)
#else
CVAR(Float, gl_exposure_base, 0.35f, CVAR_ARCHIVE)
#endif
CVAR(Float, gl_exposure_speed, 0.05f, CVAR_ARCHIVE)
CUSTOM_CVAR(Int, gl_tonemap, 0, CVAR_ARCHIVE)

View file

@ -49,7 +49,7 @@ VkRenderState::VkRenderState(VulkanRenderDevice* fb) : fb(fb), mStreamBufferWrit
void VkRenderState::ClearScreen()
{
screen->mViewpoints->Set2D(*this, SCREENWIDTH, SCREENHEIGHT);
screen->mViewpoints->Set2D(nullptr, *this, SCREENWIDTH, SCREENHEIGHT);
SetColor(0, 0, 0);
Apply(DT_TriangleStrip);
mCommandBuffer->draw(4, 1, FFlatVertexBuffer::FULLSCREEN_INDEX, 0);

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,158 @@
#define ZCC_EQ 1
#define ZCC_MULEQ 2
#define ZCC_DIVEQ 3
#define ZCC_MODEQ 4
#define ZCC_ADDEQ 5
#define ZCC_SUBEQ 6
#define ZCC_LSHEQ 7
#define ZCC_RSHEQ 8
#define ZCC_ANDEQ 9
#define ZCC_OREQ 10
#define ZCC_XOREQ 11
#define ZCC_URSHEQ 12
#define ZCC_QUESTION 13
#define ZCC_COLON 14
#define ZCC_OROR 15
#define ZCC_ANDAND 16
#define ZCC_EQEQ 17
#define ZCC_NEQ 18
#define ZCC_APPROXEQ 19
#define ZCC_LT 20
#define ZCC_GT 21
#define ZCC_LTEQ 22
#define ZCC_GTEQ 23
#define ZCC_LTGTEQ 24
#define ZCC_IS 25
#define ZCC_DOTDOT 26
#define ZCC_OR 27
#define ZCC_XOR 28
#define ZCC_AND 29
#define ZCC_LSH 30
#define ZCC_RSH 31
#define ZCC_URSH 32
#define ZCC_SUB 33
#define ZCC_ADD 34
#define ZCC_MUL 35
#define ZCC_DIV 36
#define ZCC_MOD 37
#define ZCC_CROSSPROD 38
#define ZCC_DOTPROD 39
#define ZCC_POW 40
#define ZCC_UNARY 41
#define ZCC_ADDADD 42
#define ZCC_SUBSUB 43
#define ZCC_DOT 44
#define ZCC_LPAREN 45
#define ZCC_LBRACKET 46
#define ZCC_SCOPE 47
#define ZCC_EOF 48
#define ZCC_SEMICOLON 49
#define ZCC_COMMA 50
#define ZCC_INCLUDE 51
#define ZCC_EXTEND 52
#define ZCC_CLASS 53
#define ZCC_IDENTIFIER 54
#define ZCC_ABSTRACT 55
#define ZCC_NATIVE 56
#define ZCC_UI 57
#define ZCC_PLAY 58
#define ZCC_REPLACES 59
#define ZCC_VERSION 60
#define ZCC_STRCONST 61
#define ZCC_RPAREN 62
#define ZCC_DEFAULT 63
#define ZCC_COLOR 64
#define ZCC_LBRACE 65
#define ZCC_RBRACE 66
#define ZCC_MIXIN 67
#define ZCC_PROPERTY 68
#define ZCC_FLAGDEF 69
#define ZCC_INTCONST 70
#define ZCC_STRUCT 71
#define ZCC_CLEARSCOPE 72
#define ZCC_CONST 73
#define ZCC_ENUM 74
#define ZCC_STATES 75
#define ZCC_NWS 76
#define ZCC_STOP 77
#define ZCC_WAIT 78
#define ZCC_FAIL 79
#define ZCC_LOOP 80
#define ZCC_GOTO 81
#define ZCC_SUPER 82
#define ZCC_BRIGHT 83
#define ZCC_FAST 84
#define ZCC_SLOW 85
#define ZCC_NODELAY 86
#define ZCC_CANRAISE 87
#define ZCC_OFFSET 88
#define ZCC_LIGHT 89
#define ZCC_SBYTE 90
#define ZCC_BYTE 91
#define ZCC_SHORT 92
#define ZCC_USHORT 93
#define ZCC_INT 94
#define ZCC_UINT 95
#define ZCC_BOOL 96
#define ZCC_FLOAT 97
#define ZCC_DOUBLE 98
#define ZCC_VECTOR2 99
#define ZCC_VECTOR3 100
#define ZCC_VECTOR4 101
#define ZCC_NAME 102
#define ZCC_SOUND 103
#define ZCC_STATE 104
#define ZCC_LET 105
#define ZCC_ATSIGN 106
#define ZCC_READONLY 107
#define ZCC_STRING 108
#define ZCC_MAP 109
#define ZCC_MAPITERATOR 110
#define ZCC_ARRAY 111
#define ZCC_VOID 112
#define ZCC_UINT8 113
#define ZCC_INT8 114
#define ZCC_UINT16 115
#define ZCC_INT16 116
#define ZCC_RBRACKET 117
#define ZCC_ACTION 118
#define ZCC_DEPRECATED 119
#define ZCC_STATIC 120
#define ZCC_PRIVATE 121
#define ZCC_PROTECTED 122
#define ZCC_LATENT 123
#define ZCC_FINAL 124
#define ZCC_META 125
#define ZCC_TRANSIENT 126
#define ZCC_INTERNAL 127
#define ZCC_VIRTUAL 128
#define ZCC_OVERRIDE 129
#define ZCC_VARARG 130
#define ZCC_VIRTUALSCOPE 131
#define ZCC_ELLIPSIS 132
#define ZCC_IN 133
#define ZCC_OUT 134
#define ZCC_OPTIONAL 135
#define ZCC_TILDE 136
#define ZCC_BANG 137
#define ZCC_SIZEOF 138
#define ZCC_ALIGNOF 139
#define ZCC_UINTCONST 140
#define ZCC_FLOATCONST 141
#define ZCC_NAMECONST 142
#define ZCC_FALSE 143
#define ZCC_TRUE 144
#define ZCC_NULLPTR 145
#define ZCC_STATICCONST 146
#define ZCC_CONTINUE 147
#define ZCC_BREAK 148
#define ZCC_RETURN 149
#define ZCC_DO 150
#define ZCC_FOR 151
#define ZCC_FOREACH 152
#define ZCC_WHILE 153
#define ZCC_UNTIL 154
#define ZCC_IF 155
#define ZCC_ELSE 156
#define ZCC_SWITCH 157
#define ZCC_CASE 158

View file

@ -170,7 +170,7 @@ int RunEndoom()
auto endoom = new FEndoomScreen(endoom_lump);
endoom->Render(true);
while(true)
/* while(true)
{
I_GetEvent();
endoom->Update();
@ -188,7 +188,7 @@ int RunEndoom()
return 0;
}
}
}
}*/
return 0;
}

View file

@ -85,6 +85,7 @@ static void handleDiscordJoinRequest(const DiscordUser* request)
void I_UpdateDiscordPresence(bool SendPresence, const char* curstatus, const char* appid, const char* steamappid)
{
#ifdef USE_DISCORD
const char* curappid = DEFAULT_DISCORD_APP_ID;
if (appid && appid[0] != '\0')
@ -124,5 +125,6 @@ void I_UpdateDiscordPresence(bool SendPresence, const char* curstatus, const cha
{
Discord_ClearPresence();
}
#endif
}

View file

@ -65,8 +65,18 @@ void I_DebugPrintf(const char *fmt,...)
}
}
#else
#if defined(__ANDROID__)
#include <android/log.h>
#define ALOGE(...) __android_log_print( ANDROID_LOG_ERROR, "RazeXR", __VA_ARGS__ )
#endif
void I_DebugPrint(const char *cp)
{
#if defined(__ANDROID__)
ALOGE("%s", cp);
#endif
}
void I_DebugPrintf(const char *fmt,...)

View file

@ -38,7 +38,7 @@
#elif defined(__APPLE__)
#include <stdlib.h>
#include <malloc/malloc.h>
#elif defined(__OpenBSD__) || defined(__DragonFly__)
#elif defined(__OpenBSD__) || defined(__DragonFly__) || defined(__ANDROID__)
#include <stdlib.h>
#else
#include <malloc.h>
@ -54,7 +54,7 @@
#endif
#ifndef _DEBUG
#if !defined(__solaris__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
#if !defined(__solaris__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__ANDROID__)
void *M_Malloc(size_t size)
{
void *block = malloc(size);
@ -118,7 +118,7 @@ void *M_Realloc(void *memblock, size_t size)
#include <crtdbg.h>
#endif
#if !defined(__solaris__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
#if !defined(__solaris__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__ANDROID__)
void *M_Malloc_Dbg(size_t size, const char *file, int lineno)
{
void *block = _malloc_dbg(size, _NORMAL_BLOCK, file, lineno);
@ -185,7 +185,7 @@ void M_Free (void *block)
if (block != nullptr)
{
GC::ReportDealloc(_msize(block));
#if !defined(__solaris__) && !defined(__OpenBSD__) && !defined(__DragonFly__)
#if !defined(__solaris__) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__ANDROID__)
free(block);
#else
free(((size_t*) block)-1);

View file

@ -1043,7 +1043,8 @@ void NetUpdate (void)
svel += localcmds[modp].ucmd.svel;
fvel += localcmds[modp].ucmd.fvel;
avel += localcmds[modp].ucmd.avel;
horz += localcmds[modp].ucmd.horz;
//Take latest pitch
horz = localcmds[modp].ucmd.horz;
}
svel /= ticdup;

View file

@ -47,9 +47,9 @@
#include "gamestruct.h"
#include "statusbar.h"
CVARD(Bool, cl_crosshair, true, CVAR_ARCHIVE, "enable/disable crosshair");
CVARD(Bool, cl_crosshair, false, CVAR_ARCHIVE, "enable/disable crosshair");
CVARD(Bool, cl_automsg, false, CVAR_ARCHIVE, "enable/disable automatically sending messages to all players") // Not implemented for Blood
CVARD(Bool, cl_autorun, true, CVAR_ARCHIVE, "enable/disable autorun")
CVARD(Bool, cl_autorun, false, CVAR_ARCHIVE, "enable/disable autorun")
CVARD(Bool, cl_runmode, false, CVAR_ARCHIVE, "enable/disable modernized run key operation")
@ -68,9 +68,9 @@ CVARD(Bool, cl_idplayers, true, CVAR_ARCHIVE, "enable/disable name display when
CVARD(Bool, cl_weaponsway, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable player weapon swaying")
// Todo: Consolidate these to be consistent across games?
CVARD(Bool, cl_viewbob, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable player head bobbing")
CVARD(Bool, cl_viewhbob, true, CVAR_ARCHIVE, "enable/disable view horizontal bobbing") // Only implemented in Blood
CVARD(Bool, cl_viewvbob, true, CVAR_ARCHIVE, "enable/disable view vertical bobbing") // Only implemented in Blood
CVARD(Bool, cl_viewbob, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable player head bobbing")
CVARD(Bool, cl_viewhbob, false, CVAR_ARCHIVE, "enable/disable view horizontal bobbing") // Only implemented in Blood
CVARD(Bool, cl_viewvbob, false, CVAR_ARCHIVE, "enable/disable view vertical bobbing") // Only implemented in Blood
CVARD(Bool, cl_interpolate, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable view interpolation")
CVARD(Bool, cl_slopetilting, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG, "enable/disable slope tilting")
@ -125,7 +125,7 @@ CUSTOM_CVARD(Int, snd_speech, 1, CVAR_ARCHIVE, "enables/disables player speech")
// HUD
CUSTOM_CVARD(Int, hud_size, Hud_Stbar, CVAR_ARCHIVE, "Defines the HUD size and style")
CUSTOM_CVARD(Int, hud_size, Hud_Full, CVAR_ARCHIVE, "Defines the HUD size and style")
{
if (self < 0) self = 0;
else if (self > Hud_Nothing) self = Hud_Nothing;

View file

@ -46,11 +46,12 @@
#include "v_font.h"
#include "gamestruct.h"
#include "gamefuncs.h"
#include "gamestate.h"
#include "version.h"
#include "texinfo.h"
#include "buildtiles.h"
F2DDrawer twodpsp;
@ -131,9 +132,9 @@ void DrawRateStuff()
FString fpsbuff = statFPS();
int textScale = active_con_scale(twod);
int rate_x = screen->GetWidth() / textScale - NewConsoleFont->StringWidth(&fpsbuff[0]);
int rate_x = (screen->GetWidth() / 2) / textScale - (NewConsoleFont->StringWidth(&fpsbuff[0]) / 2);
twod->AddColorOnlyQuad(rate_x * textScale, 0, screen->GetWidth(), NewConsoleFont->GetHeight() * textScale, MAKEARGB(255, 0, 0, 0));
DrawText(twod, NewConsoleFont, CR_WHITE, rate_x, 0, (char*)&fpsbuff[0],
DrawText(twod, NewConsoleFont, CR_WHITE, rate_x, screen->GetHeight() / 2, (char*)&fpsbuff[0],
DTA_VirtualWidth, screen->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
@ -141,3 +142,26 @@ void DrawRateStuff()
}
}
void DrawVersionString ()
{
static uint64_t first = screen->FrameTime;
//Only show version string for 5 seconds
if ((screen->FrameTime - first) > 15000)
{
return;
}
if (gamestate == GS_STARTUP ||
gamestate == GS_DEMOSCREEN) {
char buff[60];
int textScale = active_con_scale(twod) * 3;
mysnprintf(buff, countof(buff), "Team Beef Presents - %s", RAZEXR_VERSIONSTR);
DrawText(twod, ConFont, CR_WHITE, 0, 0, (char *) &buff[0],
DTA_VirtualWidth, screen->GetWidth() / textScale,
DTA_VirtualHeight, screen->GetHeight() / textScale,
DTA_KeepRatio, true, TAG_DONE);
}
}

View file

@ -104,6 +104,9 @@ void resetTurnHeldAmt()
turnheldtime = 0;
}
void VR_GetMove(float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up,
float *yaw, float *pitch, float *roll);
extern int resetGameYaw;
//---------------------------------------------------------------------------
//
@ -150,6 +153,20 @@ void processMovement(InputPacket* const currInput, InputPacket* const inputBuffe
if (isRR() && drink_amt >= 66 && drink_amt <= 87)
currInput->svel += drink_amt & 1 ? -currInput->fvel : currInput->fvel;
float joyforward=0;
float joyside=0;
float yaw=0;
float pitch=0;
float dummy=0;
static float last_yaw = 0;
VR_GetMove(&joyforward, &joyside, &dummy, &dummy, &dummy, &yaw, &pitch, &dummy);
currInput->fvel += joyforward * keymove;
currInput->svel += joyside * keymove;
currInput->avel += last_yaw;
currInput->avel -= yaw;
last_yaw = yaw;
currInput->horz = pitch;
// add collected input to game's local input accumulation packet.
inputBuffer->fvel = clamp(inputBuffer->fvel + currInput->fvel, -(float)keymove, (float)keymove);
inputBuffer->svel = clamp(inputBuffer->svel + currInput->svel, -(float)keymove, (float)keymove);
@ -290,6 +307,12 @@ void PlayerAngles::doViewPitch(const DVector2& pos, DAngle const ang, bool const
void PlayerAngles::doViewYaw(const ESyncBits actions)
{
if (ViewAngles.Yaw.Degrees() != 0.0f ||
ViewAngles.Roll.Degrees() != 0.0f)
{
resetGameYaw = 1;
}
// Process angle return to zeros.
scaletozero(ViewAngles.Yaw, YAW_LOOKRETURN);
scaletozero(ViewAngles.Roll, YAW_LOOKRETURN);

View file

@ -91,6 +91,9 @@
#include "i_interface.h"
#include "texinfo.h"
#include "texturemanager.h"
#include "menustate.h"
void RazeXR_setUseScreenLayer(bool use);
CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, r_ticstability, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
@ -162,7 +165,7 @@ void NewGame(MapRecord* map, int skill, bool ns = false)
//
//
//==========================================================================
void VR_Init();
static void GameTicker()
{
int i;
@ -192,6 +195,7 @@ static void GameTicker()
NewGame(g_nextmap, -1);
BackupSaveGame = "";
}
VR_Init();
break;
case ga_completed:
@ -206,10 +210,12 @@ static void GameTicker()
gi->NextLevel(g_nextmap, g_nextskill);
ResetStatusBar();
Net_ClearFifo();
VR_Init();
break;
case ga_newgame:
FX_StopAllSounds();
VR_Init();
[[fallthrough]];
case ga_newgamenostopsound:
DeleteScreenJob();
@ -219,6 +225,7 @@ static void GameTicker()
gameaction = ga_level;
BackupSaveGame = "";
NewGame(g_nextmap, g_nextskill, ga == ga_newgamenostopsound);
VR_Init();
break;
case ga_startup:
@ -259,6 +266,7 @@ static void GameTicker()
case ga_loadgamehidecon:
//case ga_autoloadgame:
G_DoLoadGame();
VR_Init(); // reset VR stuff
break;
case ga_autosave:
@ -422,6 +430,15 @@ void Display()
//twod->SetSize(screen->GetWidth(), screen->GetHeight());
twod->Begin(screen->GetWidth(), screen->GetHeight());
twod->ClearClipRect();
if (gamestate == GS_LEVEL && menuactive == MENU_Off) {
RazeXR_setUseScreenLayer(false);
}
else {
//Ensure we are drawing on virtual screen
RazeXR_setUseScreenLayer(true);
}
switch (gamestate)
{
case GS_MENUSCREEN:

View file

@ -25,6 +25,8 @@
**
*/
#include <gamestate.h>
#include <menustate.h>
#include "gi.h"
#include "build.h"
#include "v_draw.h"
@ -54,6 +56,9 @@
EXTERN_CVAR(Bool, cl_capfps)
extern int resetGameYaw;
extern float gameYaw;
PalEntry GlobalMapFog;
float GlobalFogDensity = 350.f;
TArray<PortalDesc> allPortals;
@ -101,6 +106,9 @@ void CollectLights(FLevelLocals* Level)
}
#endif
float RazeXR_GetFOV();
void VR_GetMove(float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up,
float *yaw, float *pitch, float *roll);
//-----------------------------------------------------------------------------
//
@ -135,6 +143,8 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
const auto& eye = vrmode->mEyes[eye_ix];
screen->SetViewportRects(bounds);
screen->RenderState()->SetEye(eye_ix);
if (mainview) // Bind the scene frame buffer and turn on draw buffers used by ssao
{
bool useSSAO = (gl_ssao != 0);
@ -145,6 +155,7 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
auto di = HWDrawInfo::StartDrawInfo(nullptr, mainvp, nullptr);
di->SetVisibility();
di->eye = eye_ix;
auto& vp = di->Viewpoint;
vp = mainvp;
@ -155,7 +166,7 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
// Stereo mode specific perspective projection
di->VPUniforms.mProjectionMatrix = eye.GetProjection(fov, ratio, fovratio);
// Stereo mode specific viewpoint adjustment
vp.Pos += eye.GetViewShift(vp.HWAngles.Yaw.Degrees());
vp.Pos += eye.GetViewShift(vp.HWAngles);
di->SetupView(RenderState, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, false, false);
di->ProcessScene(toscreen);
@ -194,15 +205,50 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
FRenderViewpoint SetupViewpoint(DCoreActor* cam, const DVector3& position, int sectnum, const DRotator& angles, float fov = -1)
{
float dummy, yaw, pitch, roll;
VR_GetMove(&dummy, &dummy, &dummy, &dummy, &dummy, &yaw, &pitch, &roll);
//Don't do the following if rendering a camera tex
if (!(cam->spr.cstat & CSTAT_SPRITE_INVISIBLE))
{
//Yaw
float hmdYawDeltaDegrees;
{
static float previousHmdYaw = yaw;
hmdYawDeltaDegrees = yaw - previousHmdYaw;
previousHmdYaw = yaw;
}
if (gamestate == GS_LEVEL)
{
gameYaw -= hmdYawDeltaDegrees;
}
if (gamestate == GS_LEVEL && resetGameYaw)
{
if (resetGameYaw > 0)
gameYaw = (float) (-90.f + angles.Yaw.Degrees());
resetGameYaw--;
}
}
FRenderViewpoint r_viewpoint{};
r_viewpoint.CameraActor = cam;
r_viewpoint.SectNums = nullptr;
r_viewpoint.SectCount = sectnum;
r_viewpoint.Pos = { position.X, -position.Y, -position.Z };
r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(-90.f + (float)angles.Yaw.Degrees());
r_viewpoint.HWAngles.Pitch = FAngle::fromDeg(ClampViewPitch(angles.Pitch).Degrees());
r_viewpoint.HWAngles.Roll = FAngle::fromDeg((float)angles.Roll.Degrees());
r_viewpoint.FieldOfView = FAngle::fromDeg(fov > 0? fov : (float)r_fov);
if (cam->spr.cstat & CSTAT_SPRITE_INVISIBLE)
{
r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(-90.f + (float)angles.Yaw.Degrees());
}
else
{
r_viewpoint.HWAngles.Yaw = FAngle::fromDeg(gameYaw);
}
r_viewpoint.HWAngles.Pitch = FAngle::fromDeg(pitch);
r_viewpoint.HWAngles.Roll = FAngle::fromDeg(roll);
r_viewpoint.FieldOfView = FAngle::fromDeg((float)RazeXR_GetFOV());
r_viewpoint.RotAngle = angles.Yaw.BAMs();
double FocalTangent = tan(r_viewpoint.FieldOfView.Radians() / 2);
DAngle an = DAngle::fromDeg(270. - r_viewpoint.HWAngles.Yaw.Degrees());

View file

@ -624,6 +624,7 @@ void HWDrawInfo::RenderPortal(HWPortal *p, FRenderState &state, bool usestencil)
auto gp = static_cast<HWPortal *>(p);
gp->SetupStencil(this, state, usestencil);
auto new_di = StartDrawInfo(this, Viewpoint, &VPUniforms);
new_di->eye = eye;
new_di->visibility = visibility;
new_di->rellight = rellight;
new_di->mCurrentPortal = gp;

View file

@ -100,6 +100,7 @@ struct HWDrawInfo
HWDrawList drawlists[GLDL_TYPES];
int vpIndex;
//ELightMode lightmode;
int eye;
HWDrawInfo * outer = nullptr;
int FullbrightFlags;

View file

@ -91,7 +91,7 @@ void FPortalSceneState::EndFrame(HWDrawInfo *di, FRenderState &state)
{
Printf("%sProcessing %s, depth = %d\n", indent.GetChars(), p->GetName(), renderdepth);
}
if (p->lines.Size() > 0)
if (p->lines.Size() > 0 && !p->IsSky())
{
RenderPortal(p, state, true, di);
}

View file

@ -67,12 +67,54 @@ void AddSearchPath(TArray<FString>& searchpaths, const char* path)
#ifndef _WIN32
#ifdef __MOBILE__
static void AddBothPath(FString path, TArray<FString> &result)
{
result.Push(path);
auto v = Args->CheckValue("-secondary_path");
if (v)
{
result.Push(FString(v) + "/" + path);
}
}
void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
{
TArray<FString> result;
auto v = Args->CheckValue("-secondary_path");
if (v)
{
result.Push(FString(v) + "/");
}
//Duke
AddBothPath("addons/nw", result);
AddBothPath("addons/dc", result);
AddBothPath("addons/vacation", result);
// Blood
AddBothPath("./addons/cryptic", result);
AddBothPath("./cryptic", result);
// SW
AddBothPath("./addons/td", result);
AddBothPath("./addons/wt", result);
searchpaths.Append(result);
}
#else
void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
{
searchpaths.Append(I_GetSteamPath());
searchpaths.Append(I_GetGogPaths());
}
#endif
#else
//-------------------------------------------------------------------------
@ -248,6 +290,10 @@ TArray<FString> CollectSearchPaths()
}
}
}
#ifdef __MOBILE__
G_AddExternalSearchPaths(searchpaths);
#endif
// Unify and remove trailing slashes
for (auto &str : searchpaths)
{

View file

@ -41,8 +41,11 @@ const char *GetVersionString();
/** Lots of different version numbers **/
#define VERSIONSTR "1.7pre"
#define RAZEXR_VERSIONSTR "RazeXR 0.1.0"
// The version as seen in the Windows resource
#define RC_FILEVERSION 1,6,9999,0
#define RC_PRODUCTVERSION 1,6,9999,0

View file

@ -60,7 +60,8 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
if (pPlayer->actor->xspr.health != 0)
{
pPlayer->Angles.RenderAngles.Yaw += DAngle::fromDeg(input.avel);
pPlayer->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz);
//Set the pitch directly
pPlayer->Angles.RenderAngles.Pitch = DAngle::fromDeg(input.horz);
}
}

View file

@ -1714,7 +1714,8 @@ void ProcessInput(PLAYER* pPlayer)
if (SyncInput())
{
pPlayer->actor->spr.Angles.Pitch += DAngle::fromDeg(pInput->horz);
//Set pitch directly
pPlayer->actor->spr.Angles.Pitch = DAngle::fromDeg(pInput->horz);
}
pPlayer->Angles.doPitchKeys(&pInput->actions, pInput->horz);

View file

@ -30,6 +30,8 @@ Prepared for public release, 03/21/2003 - Charlie Wiederhold, 3D Realms
#include "global.h"
#include "names_r.h"
extern int playerHeight;
BEGIN_DUKE_NS
void initactorflags_r()

View file

@ -50,6 +50,8 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
extern TArray<TPointer<MapRecord>> mapList;
extern int playerHeight;
BEGIN_DUKE_NS
enum { VERSIONCHECK = 41 };
@ -3188,7 +3190,7 @@ void loadcons()
gs.gravity = 0.6875;
gs.tripbombblastradius = 3880;
gs.gutsscale = 0.5;
gs.playerheight = 40;
playerHeight = gs.playerheight = 40;
gs.displayflags = DUKE3D_NO_WIDESCREEN_PINNING;

View file

@ -110,9 +110,18 @@ void hud_input(int plnum)
if (!PlayerInputBits(plnum, SB_INTERFACE_BITS))
p->interface_toggle_flag = 0;
#ifndef __MOBILE__
else if (p->interface_toggle_flag == 0)
{
p->interface_toggle_flag = 1;
#else
//Without the following, it seems weapon swtich doesn't work in RazeXR?!
else
{
if (p->interface_toggle_flag == 0)
{
p->interface_toggle_flag = 1;
}
#endif
// Don't go on if paused or dead.
if (paused) return;
@ -835,7 +844,8 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
{
// Do these in the same order as the old code.
p->Angles.RenderAngles.Yaw += p->adjustavel(input.avel);
p->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz);
//Set pitch directly
p->Angles.RenderAngles.Pitch = DAngle::fromDeg(input.horz);
}
}

View file

@ -39,6 +39,8 @@ source as it is released.
#include "names_d.h"
#include "dukeactor.h"
void get_weapon_pos_and_angle(float &x, float &y, float &z, float &pitch, float &yaw);
BEGIN_DUKE_NS
void fireweapon_ww(int snum);
@ -1022,6 +1024,35 @@ static void shootshrinker(DDukeActor* actor, int p, const DVector3& pos, DAngle
//
//---------------------------------------------------------------------------
void shoot_d(DDukeActor* actor, int atwith, PClass *cls);
void shoot_d_override(DDukeActor* actor, int atwith, PClass *cls)
{
int l, j;
int sx, sy, sz, sa, p, vel, zvel, x, dal;
player_struct backup;
if (actor->isPlayer())
{
/* p = actor->PlayerIndex();
{
float ax, y, z, pitch, yaw;
get_weapon_pos_and_angle(ax, y, z, pitch, yaw);
backup = ps[p];
ps[p].pos.X += (ax * 16.0f);
ps[p].pos.Y += (y * -16.0f);;
ps[p].pos.Z += (z * -256);
ps[p].angle.ang = degang(-yaw);
ps[p].horizon.horiz = pitchhoriz(-pitch);
}
*/
}
shoot_d(actor, atwith, cls);
/* if (actor->isPlayer())
{
ps[p] = backup;
}
*/
}
void shoot_d(DDukeActor* actor, int atwith, PClass *cls)
{
int p;

View file

@ -760,6 +760,35 @@ static void shootmortar(DDukeActor* actor, int p, const DVector3& pos, DAngle an
//
//---------------------------------------------------------------------------
void shoot_r(DDukeActor* actor, int atwith, PClass *cls);
void shoot_r_override(DDukeActor* actor, int atwith, PClass *cls)
{
int l, j;
int sx, sy, sz, sa, p, vel, zvel, x, dal;
player_struct backup;
if (actor->isPlayer())
{
/* p = actor->PlayerIndex();
{
float ax, y, z, pitch, yaw;
get_weapon_pos_and_angle(ax, y, z, pitch, yaw);
backup = ps[p];
ps[p].pos.X += (ax * 16.0f);
ps[p].pos.Y += (y * -16.0f);;
ps[p].pos.Z += (z * -256);
ps[p].angle.ang = degang(-yaw);
ps[p].horizon.horiz = pitchhoriz(-pitch);
}
*/
}
shoot_r(actor, atwith, cls);
/* if (actor->isPlayer())
{
ps[p] = backup;
}
*/
}
void shoot_r(DDukeActor* actor, int atwith, PClass* cls)
{
int p;

View file

@ -87,7 +87,8 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju
if (!nFreeze)
{
pPlayer->Angles.RenderAngles.Yaw += DAngle::fromDeg(input.avel);
pPlayer->Angles.RenderAngles.Pitch += DAngle::fromDeg(input.horz);
//Set pitch directly
pPlayer->Angles.RenderAngles.Pitch = DAngle::fromDeg(input.horz);
if (input.horz)
{

View file

@ -2160,7 +2160,8 @@ void DoPlayerMove(PLAYER* pp)
}
else
{
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
//Set pitch directly
pp->actor->spr.Angles.Pitch = DAngle::fromDeg(pp->input.horz);
}
pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz);
@ -2747,7 +2748,8 @@ void DoPlayerMoveVehicle(PLAYER* pp)
}
else
{
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
//Set pitch directly
pp->actor->spr.Angles.Pitch = DAngle::fromDeg(pp->input.horz);
}
pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz);
@ -2793,7 +2795,8 @@ void DoPlayerMoveTurret(PLAYER* pp)
}
else
{
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
//Set pitch directly
pp->actor->spr.Angles.Pitch = DAngle::fromDeg(pp->input.horz);
}
pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz);
@ -3395,7 +3398,8 @@ void DoPlayerClimb(PLAYER* pp)
}
else
{
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pp->input.horz);
//Set pitch directly
pp->actor->spr.Angles.Pitch = DAngle::fromDeg(pp->input.horz);
}
pp->Angles.doPitchKeys(&pp->input.actions, pp->input.horz);

View file

@ -15,7 +15,7 @@ LISTMENU "MainMenu"
Size 320, 200
ifgame(Duke, Nam, WW2GI, Redneck, RedneckRides)
{
position 160, 55
position 160, 35
Linespacing 20
animatedtransition
DukeLogo
@ -23,6 +23,7 @@ LISTMENU "MainMenu"
//DukeTextItem "$MNU_NEWGAME", "m", "MultiMenu" // In EDuke this replaces "New Game" when in networking mode. Kept here as a reminder.
DukeTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
DukeTextItem "$MNU_OPTIONS", "o", "OptionsMenu"
DukeTextItem "VR Options", "v", "VROptionsMenu"
DukeTextItem "$MNU_HELP", "h", "HelpMenu"
DukeTextItem "$MNU_CREDITS", "c", "CreditsMenu"
DukeTextItem "$MNU_QUITGAME", "q", "QuitMenu"
@ -35,6 +36,7 @@ LISTMENU "MainMenu"
BloodTextItem "$MNU_NEWGAME", "n", "EpisodeMenu"
//BloodTextItem "$MNU_MULTIPLAYER", "m", "MultiMenu"
BloodTextItem "$MNU_OPTIONS", "o", "OptionsMenu"
BloodTextItem "VR Options", "v", "VROptionsMenu"
BloodTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
BloodTextItem "$MNU_HELP", "h", "HelpMenu"
BloodTextItem "$MNU_CREDITS", "c", "CreditsMenu"
@ -52,6 +54,7 @@ LISTMENU "MainMenu"
SWTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
SWTextItem "$MNU_SAVEGAME", "s", "none"
SWTextItem "$MNU_OPTIONS", "o", "OptionsMenu"
SWTextItem "VR Options", "v", "VROptionsMenu"
ifnotgame (shareware)
{
SWTextItem "$MNU_CREDITS", "c", "CreditsMenu"
@ -73,6 +76,7 @@ LISTMENU "MainMenu"
ExhumedTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
//ExhumedTextItem "$TXT_EX_MAP00", "m", "StartGameNoSkill", 1
ExhumedTextItem "$MNU_OPTIONS", "v", "OptionsMenu"
ExhumedTextItem "VR Options", "v", "VROptionsMenu"
ExhumedTextItem "$MNU_QUITGAME", "q", "QuitMenu"
}
}
@ -96,6 +100,7 @@ LISTMENU "IngameMenu"
DukeTextItem "$MNU_SAVEGAME", "s", "SaveGameMenu"
DukeTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
DukeTextItem "$MNU_OPTIONS", "o", "OptionsMenu"
DukeTextItem "VR Options", "o", "VROptionsMenu"
DukeTextItem "$MNU_HELP", "h", "HelpMenu"
DukeTextItem "$MNU_ENDGAME", "e", "EndgameMenu"
DukeTextItem "$MNU_QUITGAME", "q", "QuitMenu"
@ -107,6 +112,7 @@ LISTMENU "IngameMenu"
Linespacing 17
BloodTextItem "$MNU_NEWGAME", "n", "EpisodeMenu"
BloodTextItem "$MNU_OPTIONS", "o", "OptionsMenu"
BloodTextItem "VR Options", "v", "VROptionsMenu"
BloodTextItem "$MNU_SAVEGAME", "s", "SaveGameMenu"
BloodTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
BloodTextItem "$MNU_HELP", "h", "HelpMenu"
@ -126,6 +132,7 @@ LISTMENU "IngameMenu"
SWTextItem "$MNU_LOADGAME", "l", "LoadGameMenu"
SWTextItem "$MNU_SAVEGAME", "s", "SaveGameMenu"
SWTextItem "$MNU_OPTIONS", "o", "OptionsMenu"
SWTextItem "VR Options", "v", "VROptionsMenu"
ifnotgame (shareware)
{
SWTextItem "$MNU_CREDITS", "c", "CreditsMenu"
@ -148,6 +155,7 @@ LISTMENU "IngameMenu"
ExhumedTextItem "$MNU_SAVEGAME", "s", "SaveGameMenu"
//ExhumedTextItem "$TXT_EX_MAP00", "m", "StartGameNoSkill", 1
ExhumedTextItem "$MNU_OPTIONS", "v", "OptionsMenu"
ExhumedTextItem "VR Options", "v", "VROptionsMenu"
ExhumedTextItem "$MNU_QUITGAME", "q", "QuitMenu"
}
}
@ -501,7 +509,69 @@ OptionMenu "OptionsMenu" protected
SafeCommand "$OPTMNU_DEFAULTS", "reset2defaults"
SafeCommand "$OPTMNU_RESETTOSAVED", "reset2saved"
//Command "$OPTMNU_CONSOLE", "menuconsole"
}
}
//-------------------------------------------------------------------------------------------
//
// VR Options Menu
//
//-------------------------------------------------------------------------------------------
OptionValue "TurningMode"
{
90, "Snap 90 Degrees"
45, "Snap 45 Degrees"
30, "Snap 30 Degrees"
9, "Smooth Very Fast"
6, "Smooth Fast"
3, "Smooth Medium"
1, "Smooth Slow"
}
OptionValue "DirectionMode"
{
0, "HMD"
1, "Off-hand controller"
}
OptionValue "ControlScheme"
{
10, "Right Handed"
0, "Left Handed"
}
OptionMenu "VROptionsMenu" protected
{
Title "VR Options"
StaticText ""
//Option "Control Scheme", "vr_control_scheme", "ControlScheme"
//Option "Switch Sticks", "vr_switch_sticks", "YesNo"
StaticText ""
Option "Turning Mode", "vr_snapTurn", "TurningMode"
Option "Direction Mode", "vr_move_use_offhand", "DirectionMode"
StaticText ""
Slider "Height Adjust", "vr_height_adjust", 0.0, 1.0, 0.1
StaticText ""
StaticText ""
StaticText "Positional Tracking will exacerbate some rendering glitches"
StaticText "when crossing sector boundaries"
StaticText ""
Option "Positional Tracking", "vr_positional_tracking", "YesNo"
StaticText ""
StaticText "HUD"
StaticText ""
Slider "VR HUD Scale", "vr_hud_scale", 0.05, 1.0, 0.05, 2
StaticText ""
Slider "VR HUD Stereo Effect", "vr_hud_stereo", 0.0, 5.0, 0.1, 2
Slider "VR HUD Pitch Rotate", "vr_hud_rotate", 0.0, 50.0, 1.0, 2
Option "VR HUD Fix Pitch", "vr_hud_fixed_pitch", "OnOff"
Option "VR HUD Fix Roll", "vr_hud_fixed_roll", "OnOff"
StaticText ""
SafeCommand "$OPTMNU_DEFAULTS", "resetcvar vr_hud_scale hud_scale vr_hud_stereo vr_hud_rotate vr_hud_fixed_pitch vr_hud_fixed_roll"
}
//-------------------------------------------------------------------------------------------
//
@ -1094,6 +1164,8 @@ OptionMenu "VideoOptions" protected
Slider "$DSPLYMNU_AMBIENT_LIGHT", "r_ambientlight", 0.5, 4.0, 0.1
StaticText ""
Option "Show FPS", "vid_fps", "OnOff"
Option "Draw Sky", "draw_sky", "OnOff"
Option "$DSPLYMNU_VOXELS", "r_voxels", "OnOff"
Option "$DSPLYMNU_SHADOWS", "r_shadows", "OnOff"
Option "$DSPLYMNU_SLOPETILT", "cl_slopetilting", "OnOff"
@ -1107,7 +1179,6 @@ OptionMenu "VideoOptions" protected
Option "$DSPLYMNU_VIEWBOB", "cl_viewvbob", "OnOff"
Option "$DSPLYMNU_VIEWSWAY", "cl_viewhbob", "OnOff"
}
Slider "$DSPLYMNU_FOV", "r_fov", 60, 130, 10, 1
StaticText ""
Option "$GLPREFMNU_RENDERQUALITY", gl_seamless, "Precision"
@ -1231,7 +1302,6 @@ OptionMenu "AutomapOptions"
Option "$AUTOMAPMNU_FOLLOW", "am_followplayer", "OnOff"
Slider "$AUTOMAPMNU_LINEALPHA", "am_linealpha", 0.1, 1.0, 0.1, 1
Slider "$AUTOMAPMNU_LINETHICKNESS", "am_linethickness", 1, 8, 1, 0
StaticText ""
// todo:
//CVAR(Bool, am_textfont, false, CVAR_ARCHIVE)
@ -1331,7 +1401,7 @@ OptionMenu "HUDOptions" protected
StaticText ""
Option "$DSPLYMNU_CROSSHAIR", "cl_crosshair", OnOff
Slider "$DSPLYMNU_CROSSHAIRSCALE", "crosshairscale", 0.0, 2.0, 0.05, 2
Slider "$DSPLYMNU_CROSSHAIRSCALE", "crosshairscale", 0.25, 1.0, 0.125, 2
Option "$HUDMNU_CROSSHAIR", "crosshair", "Crosshairs"
//ColorPicker "$HUDMNU_CROSSHAIRCOLOR", "crosshaircolor" fixme: Does not exist yet in Raze.
Option "$HUDMNU_CROSSHAIRHEALTH", "crosshairhealth", "CrosshairHealthTypes"

View file

@ -712,7 +712,7 @@ vec3 AmbientOcclusionColor()
void main()
{
#ifdef NO_CLIPDISTANCE_SUPPORT
if (ClipDistanceA.x < 0 || ClipDistanceA.y < 0 || ClipDistanceA.z < 0 || ClipDistanceA.w < 0 || ClipDistanceB.x < 0) discard;
if (ClipDistanceA.x < 0.0 || ClipDistanceA.y < 0.0 || ClipDistanceA.z < 0.0 || ClipDistanceA.w < 0.0 || ClipDistanceB.x < 0.0) discard;
#endif
#ifndef LEGACY_USER_SHADER
@ -781,7 +781,7 @@ void main()
if ((uTextureMode & 0xffff) == 7)
{
float gray = grayscale(frag);
vec4 cm = (uObjectColor + gray * (uAddColor - uObjectColor)) * 2;
vec4 cm = (uObjectColor + gray * (uAddColor - uObjectColor)) * 2.0;
frag = vec4(clamp(cm.rgb, 0.0, 1.0), frag.a);
}
frag = frag * ProcessLight(material, vColor);

View file

@ -54,7 +54,7 @@ void main()
pixelpos.xyz = worldcoord.xyz;
pixelpos.w = -eyeCoordPos.z/eyeCoordPos.w;
if (uGlowTopColor.a > 0 || uGlowBottomColor.a > 0)
if (uGlowTopColor.a > 0.0 || uGlowBottomColor.a > 0.0)
{
float topatpoint = (uGlowTopPlane.w + uGlowTopPlane.x * worldcoord.x + uGlowTopPlane.y * worldcoord.z) * uGlowTopPlane.z;
float bottomatpoint = (uGlowBottomPlane.w + uGlowBottomPlane.x * worldcoord.x + uGlowBottomPlane.y * worldcoord.z) * uGlowBottomPlane.z;
@ -63,7 +63,7 @@ void main()
glowdist.z = clamp(glowdist.x / (topatpoint - bottomatpoint), 0.0, 1.0);
}
if (uObjectColor2.a != 0)
if (uObjectColor2.a != 0.0)
{
float topatpoint = (uGradientTopPlane.w + uGradientTopPlane.x * worldcoord.x + uGradientTopPlane.y * worldcoord.z) * uGradientTopPlane.z;
float bottomatpoint = (uGradientBottomPlane.w + uGradientBottomPlane.x * worldcoord.x + uGradientBottomPlane.y * worldcoord.z) * uGradientBottomPlane.z;
@ -116,7 +116,7 @@ void main()
}
else
{
ClipDistance0 = 1;
ClipDistance0 = 1.0;
}
// clip planes used for translucency splitting

View file

@ -8,5 +8,5 @@ void main()
{
float exposureAdjustment = texture(ExposureTexture, vec2(0.5)).x;
vec4 color = texture(SceneTexture, Offset + TexCoord * Scale);
FragColor = max(vec4((color.rgb + vec3(0.001)) * exposureAdjustment - 1, 1), vec4(0));
FragColor = max(vec4((color.rgb + vec3(0.001)) * exposureAdjustment - 1.0, 1.0), vec4(0));
}

View file

@ -7,7 +7,7 @@ void main()
{
vec4 frag = texture(SceneTexture, TexCoord);
frag.rgb = clamp(pow(frag.rgb, vec3(uFixedColormapStart.a)), 0.0, 1.0);
if (uFixedColormapRange.a == 0)
if (uFixedColormapRange.a == 0.0)
{
float gray = (frag.r * 0.3 + frag.g * 0.56 + frag.b * 0.14);
vec4 cm = uFixedColormapStart + gray * uFixedColormapRange;

View file

@ -11,7 +11,7 @@ vec4 ApplyGamma(vec4 c)
vec3 valgray;
if (GrayFormula == 0)
valgray = vec3(c.r + c.g + c.b) * (1 - Saturation) / 3 + c.rgb * Saturation;
valgray = vec3(c.r + c.g + c.b) * (1.0 - Saturation) / 3.0 + c.rgb * Saturation;
else if (GrayFormula == 2) // new formula
valgray = mix(vec3(pow(dot(pow(vec3(c), vec3(2.2)), vec3(0.2126, 0.7152, 0.0722)), 1.0/2.2)), c.rgb, Saturation);
else

View file

@ -29,7 +29,7 @@ vec3 Tonemap(vec3 color)
vec3 Tonemap(vec3 color)
{
color = color / (1 + color);
color = color / (1.0 + color);
return sRGB(color);
}
@ -37,7 +37,7 @@ vec3 Tonemap(vec3 color)
vec3 Tonemap(vec3 color)
{
vec3 x = max(vec3(0), color - 0.004);
vec3 x = max(vec3(0.0), color - 0.004);
return (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06); // no sRGB needed
}