Import portable branch
13
.gitattributes
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Automatically normalize line endings.
|
||||
* text=auto
|
||||
|
||||
# MSVC files have to be CRLF
|
||||
*.vcproj text eol=crlf
|
||||
*.sln text eol=crlf
|
||||
|
||||
# Do not change external files
|
||||
external/** -text
|
||||
DoConfig/fltk/** -text
|
||||
|
||||
# TSC files are not text, but 'git diff' likes to think they are
|
||||
*.tsc binary
|
105
.gitignore
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
# Exclude obj directory (object files for Makefile build)
|
||||
/obj
|
||||
|
||||
# Exclude the (recommended) CMake build directory
|
||||
/build*
|
||||
|
||||
# Exclude executables
|
||||
/game_english/CSE2_debug.exe
|
||||
/game_english/DoConfig_debug.exe
|
||||
/game_english/CSE2.exe
|
||||
/game_english/DoConfig.exe
|
||||
/game_english/CSE2_debug
|
||||
/game_english/DoConfig_debug
|
||||
/game_english/CSE2
|
||||
/game_english/DoConfig
|
||||
/game_english/CSE2_debug.rpx
|
||||
/game_english/CSE2.rpx
|
||||
/game_english/CSE2.3dsx
|
||||
/game_english/\!CSE2
|
||||
/game_japanese/CSE2_debug.exe
|
||||
/game_japanese/DoConfig_debug.exe
|
||||
/game_japanese/CSE2.exe
|
||||
/game_japanese/DoConfig.exe
|
||||
/game_japanese/CSE2_debug
|
||||
/game_japanese/DoConfig_debug
|
||||
/game_japanese/CSE2
|
||||
/game_japanese/DoConfig
|
||||
/game_japanese/CSE2_debug.rpx
|
||||
/game_japanese/CSE2.rpx
|
||||
/game_japanese/CSE2.3dsx
|
||||
/game_japanese/\!CSE2
|
||||
|
||||
# Exclude MSVC debug data
|
||||
/game_english/CSE2_debug.ilk
|
||||
/game_english/CSE2_debug.pdb
|
||||
/game_english/DoConfig_debug.ilk
|
||||
/game_english/DoConfig_debug.pdb
|
||||
/game_english/CSE2.ilk
|
||||
/game_english/CSE2.pdb
|
||||
/game_english/DoConfig.ilk
|
||||
/game_english/DoConfig.pdb
|
||||
/game_japanese/CSE2_debug.ilk
|
||||
/game_japanese/CSE2_debug.pdb
|
||||
/game_japanese/DoConfig_debug.ilk
|
||||
/game_japanese/DoConfig_debug.pdb
|
||||
/game_japanese/CSE2.ilk
|
||||
/game_japanese/CSE2.pdb
|
||||
/game_japanese/DoConfig.ilk
|
||||
/game_japanese/DoConfig.pdb
|
||||
|
||||
# Exclude misc. MSVC junk
|
||||
/.vs
|
||||
/out
|
||||
/CMakeSettings.json
|
||||
|
||||
# Exclude save data
|
||||
/game_english/Config.dat
|
||||
/game_english/Profile.dat
|
||||
/game_english/290.rec
|
||||
/game_english/window.rect
|
||||
/game_japanese/Config.dat
|
||||
/game_japanese/Profile.dat
|
||||
/game_japanese/290.rec
|
||||
/game_japanese/window.rect
|
||||
|
||||
# Exclude configuration files
|
||||
/game_english/fps
|
||||
/game_english/mute
|
||||
/game_english/save
|
||||
/game_english/s_reverse
|
||||
/game_japanese/fps
|
||||
/game_japanese/mute
|
||||
/game_japanese/save
|
||||
/game_japanese/s_reverse
|
||||
|
||||
# Exclude error logs
|
||||
/game_english/error.log
|
||||
/game_japanese/error.log
|
||||
|
||||
###################
|
||||
# Accurate branch #
|
||||
###################
|
||||
|
||||
# Exclude devilution-comparer assembly output
|
||||
/devilution/orig.asm
|
||||
/devilution/compare.asm
|
||||
|
||||
# Exclude MSVC IntelliSense database
|
||||
/vs2003/CSE2.ncb
|
||||
|
||||
# Exclude MSVC Solution User Options file
|
||||
/vs2003/CSE2.suo
|
||||
|
||||
# Exclude MSVC build folders
|
||||
/vs2003/Debug
|
||||
/vs2003/Release
|
||||
/vs2003/Debug (Japanese)
|
||||
/vs2003/Release (Japanese)
|
||||
|
||||
###################
|
||||
# Portable branch #
|
||||
###################
|
||||
|
||||
# Exclude converted resource files
|
||||
/src/Resource
|
140
.travis.yml
Normal file
|
@ -0,0 +1,140 @@
|
|||
# Optimize git clone
|
||||
git:
|
||||
depth: 5
|
||||
|
||||
# Bionic is the most recent version of Ubuntu I can get to work properly
|
||||
dist: bionic
|
||||
|
||||
# Enable C++ language support
|
||||
language: cpp
|
||||
|
||||
osx_image: xcode11.3
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
packages:
|
||||
- make
|
||||
- cmake
|
||||
- gcc-9
|
||||
- g++-9
|
||||
- clang-9
|
||||
- libsdl1.2-dev
|
||||
- libsdl2-dev
|
||||
- libglfw3-dev
|
||||
- libfreetype6-dev
|
||||
homebrew:
|
||||
packages:
|
||||
- make
|
||||
- cmake
|
||||
- gcc@9
|
||||
- llvm@9
|
||||
- sdl
|
||||
- sdl2
|
||||
- glfw
|
||||
- freetype
|
||||
|
||||
env:
|
||||
- PLATFORM=SDL2 AUDIO=SDL2 RENDERER=Software
|
||||
- PLATFORM=SDL2 AUDIO=SDL2 RENDERER=SDLSurface
|
||||
- PLATFORM=SDL2 AUDIO=SDL2 RENDERER=SDLTexture
|
||||
- PLATFORM=SDL2 AUDIO=SDL2 RENDERER=OpenGL3
|
||||
- PLATFORM=SDL2 AUDIO=SDL2 RENDERER=OpenGLES2
|
||||
- PLATFORM=SDL1 AUDIO=SDL1 RENDERER=Software
|
||||
- PLATFORM=SDL1 AUDIO=SDL1 RENDERER=OpenGL3
|
||||
- PLATFORM=GLFW3 AUDIO=miniaudio RENDERER=Software
|
||||
- PLATFORM=GLFW3 AUDIO=miniaudio RENDERER=OpenGL3
|
||||
- PLATFORM=GLFW3 AUDIO=miniaudio RENDERER=OpenGLES2
|
||||
- PLATFORM=Null AUDIO=Null RENDERER=Software
|
||||
|
||||
jobs:
|
||||
exclude:
|
||||
# macOS doesn't support OpenGLES2, apparently
|
||||
- os: osx
|
||||
env: PLATFORM=SDL2 AUDIO=SDL2 RENDERER=OpenGLES2
|
||||
- os: osx
|
||||
env: PLATFORM=GLFW3 AUDIO=miniaudio RENDERER=OpenGLES2
|
||||
# GCC is mysteriously broken when trying to parse macOS headers for miniaudio
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
env: PLATFORM=GLFW3 AUDIO=miniaudio RENDERER=OpenGL3
|
||||
- os: osx
|
||||
compiler: gcc
|
||||
env: PLATFORM=GLFW3 AUDIO=miniaudio RENDERER=Software
|
||||
|
||||
before_install:
|
||||
# Set URL for Discord send script
|
||||
- DISCORD_SEND_SCRIPT_URL=https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
|
||||
- DISCORD_SEND_SCRIPT_FILENAME=discordSendNotification.sh
|
||||
|
||||
# Display available disk space
|
||||
- df -h
|
||||
|
||||
# Display Travis OS name
|
||||
- echo $TRAVIS_OS_NAME
|
||||
|
||||
# The following Homebrew packages aren't linked by default, and need to be prepended to the path explicitly.
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
||||
export PATH="$(brew --prefix llvm)/bin:$PATH";
|
||||
fi
|
||||
|
||||
# /usr/bin/gcc points to an older compiler on both Linux and macOS.
|
||||
- if [ "$CXX" = "g++" ]; then export CXX="g++-9" CC="gcc-9"; fi
|
||||
|
||||
# /usr/bin/clang points to an older compiler on both Linux and macOS.
|
||||
#
|
||||
# Homebrew's llvm package doesn't ship a versioned clang++ binary, so the values
|
||||
# below don't work on macOS. Fortunately, the path change above makes the
|
||||
# default values (clang and clang++) resolve to the correct compiler on macOS.
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then
|
||||
if [ "$CXX" = "clang++" ]; then export CXX="clang++-9" CC="clang-9"; fi;
|
||||
fi
|
||||
|
||||
# Display compilers/cmake name/version
|
||||
- echo ${CC}
|
||||
- echo ${CXX}
|
||||
- ${CC} --version
|
||||
- ${CXX} --version
|
||||
- cmake --version
|
||||
|
||||
install:
|
||||
# Get number of cores (or 2 by default if somehow none of these are available somehow)
|
||||
- JOBS=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 2)
|
||||
- echo $JOBS
|
||||
|
||||
# Recommanded build directory
|
||||
- CMAKE_BUILD_DIR=build
|
||||
|
||||
before_script:
|
||||
# Make build directory and generate CMake build files
|
||||
- mkdir -p ${CMAKE_BUILD_DIR} && cd ${CMAKE_BUILD_DIR}
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=Release -DFIX_BUGS=ON -DBACKEND_PLATFORM=$PLATFORM -DBACKEND_AUDIO=$AUDIO -DBACKEND_RENDERER=$RENDERER -DCMAKE_C_FLAGS="-Wall -Wextra -pedantic" -DCMAKE_CXX_FLAGS="-Wall -Wextra -pedantic"
|
||||
- cd ..
|
||||
|
||||
script:
|
||||
- cd ${CMAKE_BUILD_DIR}
|
||||
- cmake --build . --config Release --parallel $JOBS
|
||||
- cd ..
|
||||
|
||||
after_success:
|
||||
# Send success notification to Discord through DISCORD_WEBHOOK_URL
|
||||
- travis_retry wget ${DISCORD_SEND_SCRIPT_URL} -O ${DISCORD_SEND_SCRIPT_FILENAME}
|
||||
- chmod +x ${DISCORD_SEND_SCRIPT_FILENAME}
|
||||
- ./${DISCORD_SEND_SCRIPT_FILENAME} success $DISCORD_WEBHOOK_URL
|
||||
|
||||
after_failure:
|
||||
# Send failure notification to Discord through DISCORD_WEBHOOK_URL
|
||||
- travis_retry wget ${DISCORD_SEND_SCRIPT_URL} -O ${DISCORD_SEND_SCRIPT_FILENAME}
|
||||
- chmod +x ${DISCORD_SEND_SCRIPT_FILENAME}
|
||||
- ./${DISCORD_SEND_SCRIPT_FILENAME} failure $DISCORD_WEBHOOK_URL
|
781
CMakeLists.txt
Normal file
|
@ -0,0 +1,781 @@
|
|||
cmake_minimum_required(VERSION 3.8)
|
||||
|
||||
if((${CMAKE_VERSION} VERSION_EQUAL 3.9) OR (${CMAKE_VERSION} VERSION_GREATER 3.9))
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
endif()
|
||||
|
||||
|
||||
#############
|
||||
# Constants #
|
||||
#############
|
||||
|
||||
set(ASSETS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/assets")
|
||||
|
||||
|
||||
###########
|
||||
# Options #
|
||||
###########
|
||||
|
||||
option(JAPANESE "Enable the Japanese-language build (instead of the unofficial Aeon Genesis English translation)" OFF)
|
||||
option(FIX_BUGS "Fix various bugs in the game" OFF)
|
||||
option(FIX_MAJOR_BUGS "Fix bugs that invoke undefined behaviour or cause memory leaks" ON)
|
||||
option(DEBUG_SAVE "Re-enable the ability to drag-and-drop save files onto the window" OFF)
|
||||
option(DOCONFIG "Compile a DoConfig clone tool - not useful for console ports" ON)
|
||||
option(LANCZOS_RESAMPLER "Use Lanczos filtering for audio resampling instead of linear-interpolation (Lanczos is more performance-intensive, but higher quality)" OFF)
|
||||
option(FREETYPE_FONTS "Use FreeType2 to render the DejaVu Mono (English) or Migu1M (Japanese) fonts, instead of using pre-rendered copies of Courier New (English) and MS Gothic (Japanese)" OFF)
|
||||
|
||||
set(BACKEND_RENDERER "SDLTexture" CACHE STRING "Which renderer the game should use: 'OpenGL3' for an OpenGL 3.2 renderer, 'OpenGLES2' for an OpenGL ES 2.0 renderer, 'SDLTexture' for SDL2's hardware-accelerated Texture API, 'SDLSurface' for SDL2's software-rendered Surface API, 'Wii U' for the Wii U's hardware-accelerated GX2 API, '3DS' for the 3DS's hardware accelerated Citro2D/Citro3D API, or 'Software' for a handwritten software renderer")
|
||||
set(BACKEND_AUDIO "SDL2" CACHE STRING "Which audio backend the game should use: 'SDL2', 'SDL1', 'miniaudio', 'WiiU-Hardware', 'WiiU-Software', '3DS-Hardware', '3DS-Software', or 'Null'")
|
||||
set(BACKEND_PLATFORM "SDL2" CACHE STRING "Which platform backend the game should use: 'SDL2', 'SDL1', 'GLFW3', 'WiiU', '3DS', or 'Null'")
|
||||
|
||||
option(LTO "Enable link-time optimisation" OFF)
|
||||
option(PKG_CONFIG_STATIC_LIBS "On platforms with pkg-config, static-link the dependencies (good for Windows builds, so you don't need to bundle DLL files)" OFF)
|
||||
option(MSVC_LINK_STATIC_RUNTIME "Link the static MSVC runtime library (Visual Studio only)" OFF)
|
||||
|
||||
option(FORCE_LOCAL_LIBS "Compile the built-in versions of SDL2, GLFW3, and FreeType instead of using the system-provided ones" OFF)
|
||||
|
||||
|
||||
#########
|
||||
# Setup #
|
||||
#########
|
||||
|
||||
project(CSE2 LANGUAGES C CXX)
|
||||
|
||||
add_executable(CSE2 WIN32
|
||||
"${ASSETS_DIRECTORY}/resources/CSE2.rc"
|
||||
"${ASSETS_DIRECTORY}/resources/CSE2.manifest"
|
||||
"src/ArmsItem.cpp"
|
||||
"src/ArmsItem.h"
|
||||
"src/Back.cpp"
|
||||
"src/Back.h"
|
||||
"src/Bitmap.cpp"
|
||||
"src/Bitmap.h"
|
||||
"src/Boss.cpp"
|
||||
"src/Boss.h"
|
||||
"src/BossAlmo1.cpp"
|
||||
"src/BossAlmo1.h"
|
||||
"src/BossAlmo2.cpp"
|
||||
"src/BossAlmo2.h"
|
||||
"src/BossBallos.cpp"
|
||||
"src/BossBallos.h"
|
||||
"src/BossFrog.cpp"
|
||||
"src/BossFrog.h"
|
||||
"src/BossIronH.cpp"
|
||||
"src/BossIronH.h"
|
||||
"src/BossLife.cpp"
|
||||
"src/BossLife.h"
|
||||
"src/BossOhm.cpp"
|
||||
"src/BossOhm.h"
|
||||
"src/BossPress.cpp"
|
||||
"src/BossPress.h"
|
||||
"src/BossTwinD.cpp"
|
||||
"src/BossTwinD.h"
|
||||
"src/BossX.cpp"
|
||||
"src/BossX.h"
|
||||
"src/BulHit.cpp"
|
||||
"src/BulHit.h"
|
||||
"src/Bullet.cpp"
|
||||
"src/Bullet.h"
|
||||
"src/Caret.cpp"
|
||||
"src/Caret.h"
|
||||
"src/CommonDefines.h"
|
||||
"src/Config.cpp"
|
||||
"src/Config.h"
|
||||
"src/Draw.cpp"
|
||||
"src/Draw.h"
|
||||
"src/Ending.cpp"
|
||||
"src/Ending.h"
|
||||
"src/Escape.cpp"
|
||||
"src/Escape.h"
|
||||
"src/Fade.cpp"
|
||||
"src/Fade.h"
|
||||
"src/File.cpp"
|
||||
"src/File.h"
|
||||
"src/Flags.cpp"
|
||||
"src/Flags.h"
|
||||
"src/Flash.cpp"
|
||||
"src/Flash.h"
|
||||
"src/Font.cpp"
|
||||
"src/Font.h"
|
||||
"src/Frame.cpp"
|
||||
"src/Frame.h"
|
||||
"src/Game.cpp"
|
||||
"src/Game.h"
|
||||
"src/Generic.cpp"
|
||||
"src/Generic.h"
|
||||
"src/GenericLoad.cpp"
|
||||
"src/GenericLoad.h"
|
||||
"src/Input.cpp"
|
||||
"src/Input.h"
|
||||
"src/KeyControl.cpp"
|
||||
"src/KeyControl.h"
|
||||
"src/Main.cpp"
|
||||
"src/Main.h"
|
||||
"src/Map.cpp"
|
||||
"src/Map.h"
|
||||
"src/MapName.cpp"
|
||||
"src/MapName.h"
|
||||
"src/MiniMap.cpp"
|
||||
"src/MiniMap.h"
|
||||
"src/MyChar.cpp"
|
||||
"src/MyChar.h"
|
||||
"src/MycHit.cpp"
|
||||
"src/MycHit.h"
|
||||
"src/MycParam.cpp"
|
||||
"src/MycParam.h"
|
||||
"src/NpcAct.h"
|
||||
"src/NpcAct000.cpp"
|
||||
"src/NpcAct020.cpp"
|
||||
"src/NpcAct040.cpp"
|
||||
"src/NpcAct060.cpp"
|
||||
"src/NpcAct080.cpp"
|
||||
"src/NpcAct100.cpp"
|
||||
"src/NpcAct120.cpp"
|
||||
"src/NpcAct140.cpp"
|
||||
"src/NpcAct160.cpp"
|
||||
"src/NpcAct180.cpp"
|
||||
"src/NpcAct200.cpp"
|
||||
"src/NpcAct220.cpp"
|
||||
"src/NpcAct240.cpp"
|
||||
"src/NpcAct260.cpp"
|
||||
"src/NpcAct280.cpp"
|
||||
"src/NpcAct300.cpp"
|
||||
"src/NpcAct320.cpp"
|
||||
"src/NpcAct340.cpp"
|
||||
"src/NpChar.cpp"
|
||||
"src/NpChar.h"
|
||||
"src/NpcHit.cpp"
|
||||
"src/NpcHit.h"
|
||||
"src/NpcTbl.cpp"
|
||||
"src/NpcTbl.h"
|
||||
"src/Organya.cpp"
|
||||
"src/Organya.h"
|
||||
"src/PixTone.cpp"
|
||||
"src/PixTone.h"
|
||||
"src/Profile.cpp"
|
||||
"src/Profile.h"
|
||||
"src/Random.cpp"
|
||||
"src/Random.h"
|
||||
"src/Resource.cpp"
|
||||
"src/Resource.h"
|
||||
"src/SelStage.cpp"
|
||||
"src/SelStage.h"
|
||||
"src/Shoot.cpp"
|
||||
"src/Shoot.h"
|
||||
"src/Sound.cpp"
|
||||
"src/Sound.h"
|
||||
"src/Stage.cpp"
|
||||
"src/Stage.h"
|
||||
"src/Star.cpp"
|
||||
"src/Star.h"
|
||||
"src/TextScr.cpp"
|
||||
"src/TextScr.h"
|
||||
"src/Triangle.cpp"
|
||||
"src/Triangle.h"
|
||||
"src/ValueView.cpp"
|
||||
"src/ValueView.h"
|
||||
"src/WindowsWrapper.h"
|
||||
"src/Backends/Audio.h"
|
||||
"src/Backends/Controller.h"
|
||||
"src/Backends/Misc.h"
|
||||
"src/Backends/Rendering.h"
|
||||
)
|
||||
|
||||
set(RESOURCES
|
||||
"BITMAP/Credit01.bmp"
|
||||
"BITMAP/Credit02.bmp"
|
||||
"BITMAP/Credit03.bmp"
|
||||
"BITMAP/Credit04.bmp"
|
||||
"BITMAP/Credit05.bmp"
|
||||
"BITMAP/Credit06.bmp"
|
||||
"BITMAP/Credit07.bmp"
|
||||
"BITMAP/Credit08.bmp"
|
||||
"BITMAP/Credit09.bmp"
|
||||
"BITMAP/Credit10.bmp"
|
||||
"BITMAP/Credit11.bmp"
|
||||
"BITMAP/Credit12.bmp"
|
||||
"BITMAP/Credit14.bmp"
|
||||
"BITMAP/Credit15.bmp"
|
||||
"BITMAP/Credit16.bmp"
|
||||
"BITMAP/Credit17.bmp"
|
||||
"BITMAP/Credit18.bmp"
|
||||
"CURSOR/CURSOR_IKA.png"
|
||||
"CURSOR/CURSOR_NORMAL.png"
|
||||
"ORG/Access.org"
|
||||
"ORG/Anzen.org"
|
||||
"ORG/Balcony.org"
|
||||
"ORG/Ballos.org"
|
||||
"ORG/BreakDown.org"
|
||||
"ORG/Cemetery.org"
|
||||
"ORG/Curly.org"
|
||||
"ORG/Dr.org"
|
||||
"ORG/Ending.org"
|
||||
"ORG/Escape.org"
|
||||
"ORG/Fanfale1.org"
|
||||
"ORG/Fanfale2.org"
|
||||
"ORG/Fanfale3.org"
|
||||
"ORG/FireEye.org"
|
||||
"ORG/Gameover.org"
|
||||
"ORG/Ginsuke.org"
|
||||
"ORG/Grand.org"
|
||||
"ORG/Gravity.org"
|
||||
"ORG/Hell.org"
|
||||
"ORG/ironH.org"
|
||||
"ORG/Jenka.org"
|
||||
"ORG/Jenka2.org"
|
||||
"ORG/Kodou.org"
|
||||
"ORG/LastBtl3.org"
|
||||
"ORG/LastBtl.org"
|
||||
"ORG/LastCave.org"
|
||||
"ORG/Marine.org"
|
||||
"ORG/Maze.org"
|
||||
"ORG/MDown2.org"
|
||||
"ORG/Mura.org"
|
||||
"ORG/Oside.org"
|
||||
"ORG/Plant.org"
|
||||
"ORG/quiet.org"
|
||||
"ORG/Requiem.org"
|
||||
"ORG/Toroko.org"
|
||||
"ORG/Vivi.org"
|
||||
"ORG/Wanpak2.org"
|
||||
"ORG/Wanpaku.org"
|
||||
"ORG/Weed.org"
|
||||
"ORG/White.org"
|
||||
"ORG/XXXX.org"
|
||||
"ORG/Zonbie.org"
|
||||
"WAVE/Wave.dat"
|
||||
)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH
|
||||
"${CMAKE_SOURCE_DIR}/cmake"
|
||||
)
|
||||
|
||||
|
||||
###################
|
||||
# Option handling #
|
||||
###################
|
||||
|
||||
if(JAPANESE)
|
||||
set(BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/game_japanese")
|
||||
list(APPEND RESOURCES "BITMAP/pixel_jp.bmp")
|
||||
target_compile_definitions(CSE2 PRIVATE JAPANESE)
|
||||
else()
|
||||
set(BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/game_english")
|
||||
list(APPEND RESOURCES "BITMAP/pixel.bmp")
|
||||
endif()
|
||||
|
||||
if(FIX_BUGS)
|
||||
target_compile_definitions(CSE2 PRIVATE FIX_BUGS)
|
||||
endif()
|
||||
|
||||
if(FIX_BUGS OR FIX_MAJOR_BUGS)
|
||||
target_compile_definitions(CSE2 PRIVATE FIX_MAJOR_BUGS)
|
||||
endif()
|
||||
|
||||
if(DEBUG_SAVE)
|
||||
target_compile_definitions(CSE2 PRIVATE DEBUG_SAVE)
|
||||
endif()
|
||||
|
||||
if(LANCZOS_RESAMPLER)
|
||||
target_compile_definitions(CSE2 PRIVATE LANCZOS_RESAMPLER)
|
||||
endif()
|
||||
|
||||
if(FREETYPE_FONTS)
|
||||
target_compile_definitions(CSE2 PRIVATE FREETYPE_FONTS)
|
||||
endif()
|
||||
|
||||
if(PKG_CONFIG_STATIC_LIBS)
|
||||
target_link_options(CSE2 PRIVATE "-static")
|
||||
endif()
|
||||
|
||||
if(LTO)
|
||||
include(CheckIPOSupported)
|
||||
|
||||
check_ipo_supported(RESULT result)
|
||||
|
||||
if(result)
|
||||
set_target_properties(CSE2 PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# This is messy as hell, and has been replaced by CMAKE_MSVC_RUNTIME_LIBRARY,
|
||||
# but that's a very recent CMake addition, so we're still doing it this way for now
|
||||
if(MSVC AND MSVC_LINK_STATIC_RUNTIME)
|
||||
# Statically-link the CRT (vcpkg static libs do this)
|
||||
foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag_var} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(BACKEND_RENDERER MATCHES "OpenGL3")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/OpenGL3.cpp")
|
||||
elseif(BACKEND_RENDERER MATCHES "OpenGLES2")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/OpenGLES2.cpp")
|
||||
elseif(BACKEND_RENDERER MATCHES "SDLTexture")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/SDLTexture.cpp")
|
||||
elseif(BACKEND_RENDERER MATCHES "SDLSurface")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/SDLSurface.cpp")
|
||||
elseif(BACKEND_RENDERER MATCHES "WiiU")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/WiiU.cpp")
|
||||
elseif(BACKEND_RENDERER MATCHES "3DS")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/3DS.cpp")
|
||||
target_link_libraries(CSE2 PRIVATE "${CTRU_ROOT}/lib/libcitro2d.a" "${CTRU_ROOT}/lib/libcitro3d.a")
|
||||
elseif(BACKEND_RENDERER MATCHES "Software")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Software.cpp")
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid BACKEND_RENDERER selected")
|
||||
endif()
|
||||
|
||||
if(BACKEND_AUDIO MATCHES "SDL2")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Audio/SoftwareMixer.cpp"
|
||||
"src/Backends/Audio/SoftwareMixer/Mixer.cpp"
|
||||
"src/Backends/Audio/SoftwareMixer/Mixer.h"
|
||||
"src/Backends/Audio/SoftwareMixer/Backend.h"
|
||||
"src/Backends/Audio/SoftwareMixer/SDL2.cpp"
|
||||
)
|
||||
elseif(BACKEND_AUDIO MATCHES "SDL1")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Audio/SoftwareMixer.cpp"
|
||||
"src/Backends/Audio/SoftwareMixer/Mixer.cpp"
|
||||
"src/Backends/Audio/SoftwareMixer/Mixer.h"
|
||||
"src/Backends/Audio/SoftwareMixer/Backend.h"
|
||||
"src/Backends/Audio/SoftwareMixer/SDL1.cpp"
|
||||
)
|
||||
elseif(BACKEND_AUDIO MATCHES "miniaudio")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Audio/SoftwareMixer.cpp"
|
||||
"src/Backends/Audio/SoftwareMixer/Mixer.cpp"
|
||||
"src/Backends/Audio/SoftwareMixer/Mixer.h"
|
||||
"src/Backends/Audio/SoftwareMixer/Backend.h"
|
||||
"src/Backends/Audio/SoftwareMixer/miniaudio.cpp"
|
||||
)
|
||||
|
||||
# Link libdl, libm, and libpthread
|
||||
include(CheckLibraryExists)
|
||||
|
||||
check_library_exists(m pow "" LIBM)
|
||||
if(LIBM)
|
||||
target_link_libraries(CSE2 PRIVATE m)
|
||||
endif()
|
||||
|
||||
check_library_exists(pthread pthread_create "" LIBPTHREAD)
|
||||
if(LIBPTHREAD)
|
||||
target_link_libraries(CSE2 PRIVATE pthread)
|
||||
endif()
|
||||
|
||||
target_link_libraries(CSE2 PRIVATE ${CMAKE_DL_LIBS})
|
||||
elseif(BACKEND_AUDIO MATCHES "WiiU-Hardware")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Audio/WiiU.cpp"
|
||||
)
|
||||
elseif(BACKEND_AUDIO MATCHES "WiiU-Software")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Audio/SoftwareMixer.cpp"
|
||||
"src/Backends/Audio/SoftwareMixer/Mixer.cpp"
|
||||
"src/Backends/Audio/SoftwareMixer/Mixer.h"
|
||||
"src/Backends/Audio/SoftwareMixer/Backend.h"
|
||||
"src/Backends/Audio/SoftwareMixer/WiiU.cpp"
|
||||
)
|
||||
elseif(BACKEND_AUDIO MATCHES "3DS-Hardware")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Audio/3DS.cpp"
|
||||
)
|
||||
elseif(BACKEND_AUDIO MATCHES "3DS-Software")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Audio/SoftwareMixer.cpp"
|
||||
"src/Backends/Audio/SoftwareMixer/Mixer.cpp"
|
||||
"src/Backends/Audio/SoftwareMixer/Mixer.h"
|
||||
"src/Backends/Audio/SoftwareMixer/Backend.h"
|
||||
"src/Backends/Audio/SoftwareMixer/3DS.cpp"
|
||||
)
|
||||
elseif(BACKEND_AUDIO MATCHES "Null")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Audio/Null.cpp"
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid BACKEND_AUDIO selected")
|
||||
endif()
|
||||
|
||||
if(BACKEND_PLATFORM MATCHES "SDL2")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Controller/SDL.cpp"
|
||||
"src/Backends/Platform/SDL2.cpp"
|
||||
"src/Backends/Shared/SDL.h"
|
||||
)
|
||||
elseif(BACKEND_PLATFORM MATCHES "SDL1")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Controller/SDL.cpp"
|
||||
"src/Backends/Platform/SDL1.cpp"
|
||||
"src/Backends/Shared/SDL.h"
|
||||
)
|
||||
elseif(BACKEND_PLATFORM MATCHES "GLFW3")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Controller/GLFW3.cpp"
|
||||
"src/Backends/Platform/GLFW3.cpp"
|
||||
"src/Backends/Shared/GLFW3.h"
|
||||
)
|
||||
elseif(BACKEND_PLATFORM MATCHES "WiiU")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Controller/Null.cpp"
|
||||
"src/Backends/Platform/WiiU.cpp"
|
||||
)
|
||||
elseif(BACKEND_PLATFORM MATCHES "3DS")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Controller/Null.cpp"
|
||||
"src/Backends/Platform/3DS.cpp"
|
||||
)
|
||||
elseif(BACKEND_PLATFORM MATCHES "Null")
|
||||
target_sources(CSE2 PRIVATE
|
||||
"src/Backends/Controller/Null.cpp"
|
||||
"src/Backends/Platform/Null.cpp"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(BACKEND_PLATFORM MATCHES "SDL2" AND BACKEND_RENDERER MATCHES "OpenGL3")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Window/OpenGL3/SDL2.cpp")
|
||||
elseif(BACKEND_PLATFORM MATCHES "SDL2" AND BACKEND_RENDERER MATCHES "OpenGLES2")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Window/OpenGLES2/SDL2.cpp")
|
||||
elseif(BACKEND_PLATFORM MATCHES "SDL2" AND BACKEND_RENDERER MATCHES "SDLTexture")
|
||||
elseif(BACKEND_PLATFORM MATCHES "SDL2" AND BACKEND_RENDERER MATCHES "SDLSurface")
|
||||
elseif(BACKEND_PLATFORM MATCHES "SDL2" AND BACKEND_RENDERER MATCHES "Software")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Window/Software/SDL2.cpp")
|
||||
elseif(BACKEND_PLATFORM MATCHES "SDL1" AND BACKEND_RENDERER MATCHES "OpenGL3")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Window/OpenGL3/SDL1.cpp")
|
||||
elseif(BACKEND_PLATFORM MATCHES "SDL1" AND BACKEND_RENDERER MATCHES "Software")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Window/Software/SDL1.cpp")
|
||||
elseif(BACKEND_PLATFORM MATCHES "GLFW3" AND BACKEND_RENDERER MATCHES "OpenGL3")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Window/OpenGL3/GLFW3.cpp")
|
||||
elseif(BACKEND_PLATFORM MATCHES "GLFW3" AND BACKEND_RENDERER MATCHES "OpenGLES2")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Window/OpenGLES2/GLFW3.cpp")
|
||||
elseif(BACKEND_PLATFORM MATCHES "GLFW3" AND BACKEND_RENDERER MATCHES "Software")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Window/Software/GLFW3.cpp")
|
||||
elseif(BACKEND_PLATFORM MATCHES "WiiU" AND BACKEND_RENDERER MATCHES "WiiU")
|
||||
elseif(BACKEND_PLATFORM MATCHES "WiiU" AND BACKEND_RENDERER MATCHES "Software")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Window/Software/WiiU.cpp")
|
||||
elseif(BACKEND_PLATFORM MATCHES "3DS" AND BACKEND_RENDERER MATCHES "3DS")
|
||||
elseif(BACKEND_PLATFORM MATCHES "3DS" AND BACKEND_RENDERER MATCHES "Software")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Window/Software/3DS.cpp")
|
||||
elseif(BACKEND_PLATFORM MATCHES "Null" AND BACKEND_RENDERER MATCHES "Software")
|
||||
target_sources(CSE2 PRIVATE "src/Backends/Rendering/Window/Software/Null.cpp")
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid BACKEND_PLATFORM/BACKEND_RENDERER combination")
|
||||
endif()
|
||||
|
||||
|
||||
##########
|
||||
# Tweaks #
|
||||
##########
|
||||
|
||||
# Make some tweaks if we're using MSVC
|
||||
if(MSVC)
|
||||
# Disable warnings that normally fire up on MSVC when using "unsafe" functions instead of using MSVC's "safe" _s functions
|
||||
target_compile_definitions(CSE2 PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
|
||||
# Make it so source files are recognized as UTF-8 by MSVC
|
||||
target_compile_options(CSE2 PRIVATE "/utf-8")
|
||||
|
||||
# Use `main` instead of `WinMain`
|
||||
set_target_properties(CSE2 PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||
endif()
|
||||
|
||||
# On Windows, we use native icons instead
|
||||
if(NOT WIN32)
|
||||
list(APPEND RESOURCES "ICON/ICON_MINI.png")
|
||||
endif()
|
||||
|
||||
|
||||
##################
|
||||
# Misc. settings #
|
||||
##################
|
||||
|
||||
# Force strict C90
|
||||
set_target_properties(CSE2 PROPERTIES
|
||||
C_STANDARD 90
|
||||
C_STANDARD_REQUIRED ON
|
||||
C_EXTENSIONS OFF
|
||||
)
|
||||
|
||||
if(NOT BACKEND_PLATFORM MATCHES "WiiU" AND NOT BACKEND_PLATFORM MATCHES "3DS")
|
||||
# Force strict C++98
|
||||
set_target_properties(CSE2 PROPERTIES
|
||||
CXX_STANDARD 98
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_EXTENSIONS OFF
|
||||
)
|
||||
endif()
|
||||
|
||||
# Name debug builds "CSE2_debug", to distinguish them
|
||||
set_target_properties(CSE2 PROPERTIES DEBUG_OUTPUT_NAME "CSE2_debug")
|
||||
|
||||
# Send executable to the build_en/build_jp directory
|
||||
set_target_properties(CSE2 PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIRECTORY}
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BUILD_DIRECTORY}
|
||||
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${BUILD_DIRECTORY}
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${BUILD_DIRECTORY}
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BUILD_DIRECTORY}
|
||||
)
|
||||
|
||||
|
||||
################
|
||||
# Dependencies #
|
||||
################
|
||||
|
||||
if(NOT FORCE_LOCAL_LIBS)
|
||||
find_package(PkgConfig QUIET)
|
||||
endif()
|
||||
|
||||
if(BACKEND_PLATFORM MATCHES "GLFW3")
|
||||
if(NOT FORCE_LOCAL_LIBS)
|
||||
find_package(glfw3)
|
||||
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(glfw3 QUIET IMPORTED_TARGET glfw3)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET PkgConfig::glfw3)
|
||||
# pkg-config
|
||||
if (PKG_CONFIG_STATIC_LIBS)
|
||||
message(STATUS "Using system GLFW3 (pkg-config, static)")
|
||||
target_compile_options(CSE2 PRIVATE ${glfw3_STATIC_CFLAGS})
|
||||
target_link_libraries(CSE2 PRIVATE ${glfw3_STATIC_LDFLAGS})
|
||||
else()
|
||||
message(STATUS "Using system GLFW3 (pkg-config, dynamic)")
|
||||
target_compile_options(CSE2 PRIVATE ${glfw3_CFLAGS})
|
||||
target_link_libraries(CSE2 PRIVATE ${glfw3_LDFLAGS})
|
||||
endif()
|
||||
elseif(TARGET glfw)
|
||||
# CMake
|
||||
message(STATUS "Using system GLFW3 (CMake)")
|
||||
target_link_libraries(CSE2 PRIVATE glfw)
|
||||
else()
|
||||
# Compile it ourselves
|
||||
message(STATUS "Using local GLFW3")
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
|
||||
set(GLFW_BUILD_DOCS OFF CACHE INTERNAL "" FORCE)
|
||||
set(GLFW_INSTALL OFF CACHE INTERNAL "" FORCE)
|
||||
add_subdirectory("external/glfw" EXCLUDE_FROM_ALL)
|
||||
target_link_libraries(CSE2 PRIVATE glfw)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BACKEND_PLATFORM MATCHES "SDL2" OR BACKEND_AUDIO MATCHES "SDL2")
|
||||
if(NOT FORCE_LOCAL_LIBS)
|
||||
find_package(SDL2)
|
||||
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(sdl2 QUIET IMPORTED_TARGET sdl2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET PkgConfig::sdl2)
|
||||
# pkg-config
|
||||
if (PKG_CONFIG_STATIC_LIBS)
|
||||
message(STATUS "Using system SDL2 (pkg-config, static)")
|
||||
# Do not link libSDL2main.a, otherwise we get weird linker errors about SDL_main not being found.
|
||||
# We don't need SDL2's WinMain->main shim anyway, so we can just ignore it.
|
||||
list(REMOVE_ITEM sdl2_STATIC_CFLAGS "-Dmain=SDL_main")
|
||||
list(REMOVE_ITEM sdl2_STATIC_LDFLAGS "-lSDL2main")
|
||||
target_compile_options(CSE2 PRIVATE ${sdl2_STATIC_CFLAGS})
|
||||
target_link_libraries(CSE2 PRIVATE ${sdl2_STATIC_LDFLAGS})
|
||||
else()
|
||||
message(STATUS "Using system SDL2 (pkg-config, dynamic)")
|
||||
# Do not link libSDL2main.a, otherwise we get weird linker errors about SDL_main not being found.
|
||||
# We don't need SDL2's WinMain->main shim anyway, so we can just ignore it.
|
||||
list(REMOVE_ITEM sdl2_CFLAGS "-Dmain=SDL_main")
|
||||
list(REMOVE_ITEM sdl2_LDFLAGS "-lSDL2main")
|
||||
target_compile_options(CSE2 PRIVATE ${sdl2_CFLAGS})
|
||||
target_link_libraries(CSE2 PRIVATE ${sdl2_LDFLAGS})
|
||||
endif()
|
||||
elseif(TARGET SDL2::SDL2)
|
||||
# CMake-generated config (Arch, vcpkg, Raspbian)
|
||||
message(STATUS "Using system SDL2 (CMake, dynamic)")
|
||||
target_link_libraries(CSE2 PRIVATE SDL2::SDL2)
|
||||
elseif(TARGET SDL2::SDL2-static)
|
||||
# CMake-generated config (Arch, vcpkg, Raspbian)
|
||||
message(STATUS "Using system SDL2 (CMake, static)")
|
||||
target_link_libraries(CSE2 PRIVATE SDL2::SDL2-static)
|
||||
elseif(SDL2_FOUND)
|
||||
# Autotools-generated config (MSYS2)
|
||||
message(STATUS "Using system SDL2 (Autotools)")
|
||||
target_include_directories(CSE2 PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
target_link_libraries(CSE2 PRIVATE ${SDL2_LIBRARIES})
|
||||
else()
|
||||
# Compile it ourselves
|
||||
message(STATUS "Using local SDL2")
|
||||
set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
|
||||
if(MSVC)
|
||||
set(LIBC ON CACHE INTERNAL "" FORCE) # Needed to prevent possible 'symbol already defined' errors
|
||||
endif()
|
||||
add_subdirectory("external/SDL2" EXCLUDE_FROM_ALL)
|
||||
target_link_libraries(CSE2 PRIVATE SDL2-static)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BACKEND_PLATFORM MATCHES "SDL1" OR BACKEND_AUDIO MATCHES "SDL1")
|
||||
if(BACKEND_PLATFORM MATCHES "SDL2" OR BACKEND_AUDIO MATCHES "SDL2")
|
||||
message(FATAL_ERROR "SDL1 and SDL2 cannot be used simultaneously!")
|
||||
endif()
|
||||
|
||||
find_package(SDL 1.2.15)
|
||||
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(sdl QUIET IMPORTED_TARGET sdl)
|
||||
endif()
|
||||
|
||||
if(TARGET PkgConfig::sdl)
|
||||
# pkg-config
|
||||
if (PKG_CONFIG_STATIC_LIBS)
|
||||
message(STATUS "Using system SDL1 (pkg-config, static)")
|
||||
# Do not link libSDLmain.a, otherwise we get weird linker errors about SDL_main not being found.
|
||||
# We don't need SDL's WinMain->main shim anyway, so we can just ignore it.
|
||||
list(REMOVE_ITEM sdl_STATIC_CFLAGS "-Dmain=SDL_main")
|
||||
list(REMOVE_ITEM sdl_STATIC_LDFLAGS "-lSDLmain")
|
||||
target_compile_options(CSE2 PRIVATE ${sdl_STATIC_CFLAGS})
|
||||
target_link_libraries(CSE2 PRIVATE ${sdl_STATIC_LDFLAGS})
|
||||
else()
|
||||
message(STATUS "Using system SDL1 (pkg-config, dynamic)")
|
||||
# Do not link libSDLmain.a, otherwise we get weird linker errors about SDL_main not being found.
|
||||
# We don't need SDL's WinMain->main shim anyway, so we can just ignore it.
|
||||
list(REMOVE_ITEM sdl_CFLAGS "-Dmain=SDL_main")
|
||||
list(REMOVE_ITEM sdl_LDFLAGS "-lSDLmain")
|
||||
target_compile_options(CSE2 PRIVATE ${sdl_CFLAGS})
|
||||
target_link_libraries(CSE2 PRIVATE ${sdl_LDFLAGS})
|
||||
endif()
|
||||
elseif(SDL_FOUND)
|
||||
message(STATUS "Using system SDL1 (CMake)")
|
||||
target_include_directories(CSE2 PRIVATE ${SDL_INCLUDE_DIR})
|
||||
target_link_libraries(CSE2 PRIVATE ${SDL_LIBRARY})
|
||||
else()
|
||||
message(FATAL_ERROR "SDL1 not installed!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FREETYPE_FONTS)
|
||||
if(NOT FORCE_LOCAL_LIBS)
|
||||
find_package(Freetype)
|
||||
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(freetype2 QUIET IMPORTED_TARGET freetype2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET PkgConfig::freetype2)
|
||||
# pkg-config
|
||||
if (PKG_CONFIG_STATIC_LIBS)
|
||||
message(STATUS "Using system FreeType (pkg-config, static)")
|
||||
target_compile_options(CSE2 PRIVATE ${freetype2_STATIC_CFLAGS})
|
||||
target_link_libraries(CSE2 PRIVATE ${freetype2_STATIC_LDFLAGS})
|
||||
else()
|
||||
message(STATUS "Using system FreeType (pkg-config, dynamic)")
|
||||
target_compile_options(CSE2 PRIVATE ${freetype2_CFLAGS})
|
||||
target_link_libraries(CSE2 PRIVATE ${freetype2_LDFLAGS})
|
||||
endif()
|
||||
elseif(FREETYPE_FOUND)
|
||||
message(STATUS "Using system FreeType (CMake)")
|
||||
target_include_directories(CSE2 PRIVATE ${FREETYPE_INCLUDE_DIRS})
|
||||
target_link_libraries(CSE2 PRIVATE ${FREETYPE_LIBRARIES})
|
||||
else()
|
||||
# Compile it ourselves
|
||||
message(STATUS "Using local FreeType")
|
||||
if(FORCE_LOCAL_LIBS)
|
||||
set(CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz ON CACHE INTERNAL "" FORCE)
|
||||
set(CMAKE_DISABLE_FIND_PACKAGE_ZLIB ON CACHE INTERNAL "" FORCE)
|
||||
set(CMAKE_DISABLE_FIND_PACKAGE_PNG ON CACHE INTERNAL "" FORCE)
|
||||
set(CMAKE_DISABLE_FIND_PACKAGE_BZip2 ON CACHE INTERNAL "" FORCE)
|
||||
set(CMAKE_DISABLE_FIND_PACKAGE_BrotliDec ON CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
add_subdirectory("external/freetype" EXCLUDE_FROM_ALL)
|
||||
target_link_libraries(CSE2 PRIVATE freetype)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(BACKEND_RENDERER MATCHES "OpenGL3")
|
||||
add_subdirectory("external/glad" EXCLUDE_FROM_ALL)
|
||||
target_link_libraries(CSE2 PRIVATE glad)
|
||||
endif()
|
||||
|
||||
if(BACKEND_RENDERER MATCHES "OpenGLES2")
|
||||
find_package(OpenGLES2 REQUIRED)
|
||||
target_include_directories(CSE2 PRIVATE ${OPENGLES2_INCLUDE_DIR})
|
||||
target_link_libraries(CSE2 PRIVATE ${OPENGLES2_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(BACKEND_RENDERER MATCHES "OpenGL3" OR (BACKEND_PLATFORM MATCHES "GLFW3" AND BACKEND_RENDERER MATCHES "Software"))
|
||||
if (CMAKE_VERSION GREATER_EQUAL 3.11)
|
||||
cmake_policy(SET CMP0072 NEW)
|
||||
endif()
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(CSE2 PRIVATE OpenGL::GL)
|
||||
endif()
|
||||
|
||||
|
||||
#######################
|
||||
# Resource conversion #
|
||||
#######################
|
||||
|
||||
# Build bin2h externally, so it isn't cross-compiled when CSE2 is (Emscripten, cross-GCC, MinGW on Linux, etc.)
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(bin2h
|
||||
SOURCE_DIR "${CMAKE_SOURCE_DIR}/bin2h"
|
||||
DOWNLOAD_COMMAND ""
|
||||
UPDATE_COMMAND ""
|
||||
BUILD_BYPRODUCTS "<INSTALL_DIR>/bin/bin2h"
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
INSTALL_COMMAND
|
||||
${CMAKE_COMMAND} --build . --config Release --target install
|
||||
)
|
||||
|
||||
ExternalProject_Get_Property(bin2h INSTALL_DIR)
|
||||
|
||||
add_executable(bin2h_tool IMPORTED)
|
||||
add_dependencies(bin2h_tool bin2h)
|
||||
set_target_properties(bin2h_tool PROPERTIES IMPORTED_LOCATION "${INSTALL_DIR}/bin/bin2h")
|
||||
|
||||
# Convert resources to header files
|
||||
foreach(FILENAME IN LISTS RESOURCES)
|
||||
set(IN_DIR "${ASSETS_DIRECTORY}/resources")
|
||||
set(OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/Resource")
|
||||
get_filename_component(DIRECTORY "${FILENAME}" DIRECTORY)
|
||||
add_custom_command(
|
||||
OUTPUT "${OUT_DIR}/${FILENAME}.h"
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${OUT_DIR}/${DIRECTORY}"
|
||||
COMMAND bin2h_tool "${IN_DIR}/${FILENAME}" "${OUT_DIR}/${FILENAME}.h"
|
||||
DEPENDS bin2h_tool "${IN_DIR}/${FILENAME}"
|
||||
)
|
||||
target_sources(CSE2 PRIVATE "${OUT_DIR}/${FILENAME}.h")
|
||||
endforeach()
|
||||
|
||||
|
||||
############
|
||||
# DoConfig #
|
||||
############
|
||||
|
||||
if(DOCONFIG)
|
||||
add_subdirectory("DoConfig")
|
||||
|
||||
# Name debug builds "DoConfig_debug", to distinguish them
|
||||
set_target_properties(DoConfig PROPERTIES DEBUG_OUTPUT_NAME "DoConfig_debug")
|
||||
|
||||
# Send executable to the build_en/build_jp directory
|
||||
set_target_properties(DoConfig PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIRECTORY}
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BUILD_DIRECTORY}
|
||||
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${BUILD_DIRECTORY}
|
||||
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${BUILD_DIRECTORY}
|
||||
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BUILD_DIRECTORY}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(RISCOS)
|
||||
include(RISCOSApp)
|
||||
endif()
|
BIN
DoConfig/1.ico
Normal file
After Width: | Height: | Size: 766 B |
134
DoConfig/CMakeLists.txt
Normal file
|
@ -0,0 +1,134 @@
|
|||
cmake_minimum_required(VERSION 3.8)
|
||||
|
||||
option(DOCONFIG_LEGACY_OPENGL "Use OpenGL 2.1 instead of 3.2" OFF)
|
||||
|
||||
option(PKG_CONFIG_STATIC_LIBS "On platforms with pkg-config, static-link the dependencies (good for Windows builds, so you don't need to bundle DLL files)" OFF)
|
||||
option(MSVC_LINK_STATIC_RUNTIME "Link the static MSVC runtime library (Visual Studio only)" OFF)
|
||||
|
||||
option(FORCE_LOCAL_LIBS "Compile the built-in version of GLFW3 instead of using the system-provided one" OFF)
|
||||
|
||||
project(DoConfig LANGUAGES C CXX)
|
||||
|
||||
add_executable(DoConfig WIN32
|
||||
"icon.rc"
|
||||
"DoConfig.cpp"
|
||||
"imgui/imconfig.h"
|
||||
"imgui/imgui.cpp"
|
||||
"imgui/imgui.h"
|
||||
"imgui/imgui_demo.cpp"
|
||||
"imgui/imgui_draw.cpp"
|
||||
"imgui/imgui_impl_glfw.cpp"
|
||||
"imgui/imgui_impl_glfw.h"
|
||||
"imgui/imgui_internal.h"
|
||||
"imgui/imgui_widgets.cpp"
|
||||
"imgui/imstb_rectpack.h"
|
||||
"imgui/imstb_textedit.h"
|
||||
"imgui/imstb_truetype.h"
|
||||
)
|
||||
|
||||
set_target_properties(DoConfig PROPERTIES
|
||||
C_STANDARD 90
|
||||
C_STANDARD_REQUIRED ON
|
||||
C_EXTENSIONS OFF
|
||||
CXX_STANDARD 98
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_EXTENSIONS OFF
|
||||
)
|
||||
|
||||
target_link_libraries(DoConfig PRIVATE ${CMAKE_DL_LIBS})
|
||||
|
||||
target_include_directories(DoConfig PRIVATE "../external/glad/include")
|
||||
target_compile_definitions(DoConfig PRIVATE IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||
|
||||
if(DOCONFIG_LEGACY_OPENGL)
|
||||
target_compile_definitions(DoConfig PRIVATE LEGACY_OPENGL)
|
||||
target_sources(DoConfig PRIVATE
|
||||
"imgui/imgui_impl_opengl2.cpp"
|
||||
"imgui/imgui_impl_opengl2.h"
|
||||
)
|
||||
else()
|
||||
target_sources(DoConfig PRIVATE
|
||||
"imgui/imgui_impl_opengl3.cpp"
|
||||
"imgui/imgui_impl_opengl3.h"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(PKG_CONFIG_STATIC_LIBS)
|
||||
target_link_options(DoConfig PRIVATE "-static")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# Disable warnings that normally fire up on MSVC when using "unsafe" functions instead of using MSVC's "safe" _s functions
|
||||
target_compile_definitions(DoConfig PRIVATE _CRT_SECURE_NO_WARNINGS)
|
||||
|
||||
# Use `main` instead of `WinMain`
|
||||
set_target_properties(DoConfig PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup")
|
||||
|
||||
# This is messy as hell, and has been replaced by CMAKE_MSVC_RUNTIME_LIBRARY,
|
||||
# but that's a very recent CMake addition, so we're still doing it this way for now
|
||||
if(MSVC_LINK_STATIC_RUNTIME)
|
||||
# Statically-link the CRT (vcpkg static libs do this)
|
||||
foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag_var} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
################
|
||||
# Dependencies #
|
||||
################
|
||||
|
||||
# glad
|
||||
|
||||
add_subdirectory("../external/glad" "glad" EXCLUDE_FROM_ALL)
|
||||
target_link_libraries(DoConfig PRIVATE glad)
|
||||
|
||||
if (CMAKE_VERSION GREATER_EQUAL 3.11)
|
||||
cmake_policy(SET CMP0072 NEW)
|
||||
endif()
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(DoConfig PRIVATE OpenGL::GL)
|
||||
|
||||
# GLFW3
|
||||
|
||||
if(NOT FORCE_LOCAL_LIBS)
|
||||
find_package(PkgConfig QUIET)
|
||||
endif()
|
||||
|
||||
if(NOT FORCE_LOCAL_LIBS)
|
||||
find_package(glfw3)
|
||||
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(glfw3 QUIET IMPORTED_TARGET glfw3)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET PkgConfig::glfw3)
|
||||
# pkg-config
|
||||
if (PKG_CONFIG_STATIC_LIBS)
|
||||
message(STATUS "Using system GLFW3 (pkg-config, static)")
|
||||
target_compile_options(DoConfig PRIVATE ${glfw3_STATIC_CFLAGS})
|
||||
target_link_libraries(DoConfig PRIVATE ${glfw3_STATIC_LDFLAGS})
|
||||
else()
|
||||
message(STATUS "Using system GLFW3 (pkg-config, dynamic)")
|
||||
target_compile_options(DoConfig PRIVATE ${glfw3_CFLAGS})
|
||||
target_link_libraries(DoConfig PRIVATE ${glfw3_LDFLAGS})
|
||||
endif()
|
||||
elseif(TARGET glfw)
|
||||
# CMake
|
||||
message(STATUS "Using system GLFW3 (CMake)")
|
||||
target_link_libraries(DoConfig PRIVATE glfw)
|
||||
else()
|
||||
# Compile it ourselves
|
||||
message(STATUS "Using local GLFW3")
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
|
||||
set(GLFW_BUILD_DOCS OFF CACHE INTERNAL "" FORCE)
|
||||
set(GLFW_INSTALL OFF CACHE INTERNAL "" FORCE)
|
||||
add_subdirectory("../external/glfw" "glfw" EXCLUDE_FROM_ALL)
|
||||
target_link_libraries(DoConfig PRIVATE glfw)
|
||||
endif()
|
329
DoConfig/DoConfig.cpp
Normal file
|
@ -0,0 +1,329 @@
|
|||
// Released under the MIT licence.
|
||||
// See LICENCE.txt for details.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "glad/glad.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "imgui/imgui.h"
|
||||
#include "imgui/imgui_impl_glfw.h"
|
||||
#ifdef LEGACY_OPENGL
|
||||
#include "imgui/imgui_impl_opengl2.h"
|
||||
#else
|
||||
#include "imgui/imgui_impl_opengl3.h"
|
||||
#endif
|
||||
|
||||
#define WINDOW_WIDTH 360
|
||||
#define WINDOW_HEIGHT 290
|
||||
|
||||
struct Config
|
||||
{
|
||||
char proof[0x20];
|
||||
char font_name[0x40];
|
||||
int move_button_mode;
|
||||
int attack_button_mode;
|
||||
int ok_button_mode;
|
||||
int display_mode;
|
||||
bool bJoystick;
|
||||
int joystick_button[8];
|
||||
};
|
||||
|
||||
static const char *proof = "DOUKUTSU20041206";
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
(void)argc;
|
||||
|
||||
char *config_path;
|
||||
|
||||
for (size_t i = strlen(argv[0]);; --i)
|
||||
{
|
||||
if (i == 0 || argv[0][i - 1] == '\\' || argv[0][i - 1] == '/')
|
||||
{
|
||||
const char config_string[] = "Config.dat";
|
||||
|
||||
config_path = (char*)malloc(i + sizeof(config_string));
|
||||
|
||||
if (config_path == NULL)
|
||||
return 1;
|
||||
|
||||
memcpy(config_path, argv[0], i);
|
||||
memcpy(config_path + i, config_string, sizeof(config_string)); // Will copy null-character
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////
|
||||
// Initialise GLFW //
|
||||
/////////////////////
|
||||
|
||||
if (glfwInit())
|
||||
{
|
||||
#ifdef LEGACY_OPENGL
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
|
||||
#else
|
||||
const char *glsl_version = "#version 150 core";
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
|
||||
#endif
|
||||
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
|
||||
|
||||
GLFWwindow *window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, "DoConfig - Doukutsu Monogatari Settings", NULL, NULL);
|
||||
|
||||
if (window != NULL)
|
||||
{
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(2);
|
||||
|
||||
if (gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
|
||||
{
|
||||
// Check if the platform supports the version of OpenGL we want
|
||||
#ifdef LEGACY_OPENGL
|
||||
if (GLAD_GL_VERSION_2_1)
|
||||
#else
|
||||
if (GLAD_GL_VERSION_3_2)
|
||||
#endif
|
||||
{
|
||||
///////////////////////////
|
||||
// Initialise Dear ImGui //
|
||||
///////////////////////////
|
||||
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO &io = ImGui::GetIO();
|
||||
io.IniFilename = NULL; // Disable `imgui.ini`
|
||||
|
||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||
#ifdef LEGACY_OPENGL
|
||||
ImGui_ImplOpenGL2_Init();
|
||||
#else
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
#endif
|
||||
|
||||
/////////////////////
|
||||
// Load Config.dat //
|
||||
/////////////////////
|
||||
|
||||
Config configuration;
|
||||
|
||||
FILE *file = fopen(config_path, "rb");
|
||||
|
||||
if (file != NULL)
|
||||
{
|
||||
// Read from file
|
||||
fread(configuration.proof, 1, sizeof(configuration.proof), file);
|
||||
fread(configuration.font_name, 1, sizeof(configuration.font_name), file);
|
||||
configuration.move_button_mode = fgetc(file);
|
||||
fseek(file, 3, SEEK_CUR);
|
||||
configuration.attack_button_mode = fgetc(file);
|
||||
fseek(file, 3, SEEK_CUR);
|
||||
configuration.ok_button_mode = fgetc(file);
|
||||
fseek(file, 3, SEEK_CUR);
|
||||
configuration.display_mode = fgetc(file);
|
||||
fseek(file, 3, SEEK_CUR);
|
||||
configuration.bJoystick = fgetc(file);
|
||||
|
||||
for (unsigned int i = 0; i < 8; ++i)
|
||||
{
|
||||
const int decode_table[6] = {0, 1, 2, 4, 5, 3};
|
||||
|
||||
fseek(file, 3, SEEK_CUR);
|
||||
configuration.joystick_button[i] = decode_table[fgetc(file) - 1];
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
if (file == NULL || memcmp(configuration.proof, proof, strlen(proof)))
|
||||
{
|
||||
// Reset to defaults
|
||||
memset(&configuration, 0, sizeof(configuration));
|
||||
strcpy(configuration.proof, proof);
|
||||
strcpy(configuration.font_name, "Courier New");
|
||||
|
||||
for (unsigned int i = 0; i < 8; ++i)
|
||||
configuration.joystick_button[i] = i % 6;
|
||||
}
|
||||
|
||||
//////////////
|
||||
// Mainloop //
|
||||
//////////////
|
||||
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
glfwPollEvents();
|
||||
|
||||
#ifdef LEGACY_OPENGL
|
||||
ImGui_ImplOpenGL2_NewFrame();
|
||||
#else
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
#endif
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0));
|
||||
ImGui::SetNextWindowSize(ImVec2(WINDOW_WIDTH, WINDOW_HEIGHT));
|
||||
|
||||
ImGui::Begin("Main window", NULL, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBackground);
|
||||
|
||||
if (ImGui::BeginTable("Block1", 2, ImGuiTableFlags_Borders))
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::RadioButton("Arrows for Movement", &configuration.move_button_mode, 0);
|
||||
ImGui::RadioButton("<>? for Movement", &configuration.move_button_mode, 1);
|
||||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::RadioButton("Jump=Okay", &configuration.ok_button_mode, 0);
|
||||
ImGui::RadioButton("Attack=Okay", &configuration.ok_button_mode, 1);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
ImGui::RadioButton("Z=Jump; X=Attack", &configuration.attack_button_mode, 0);
|
||||
ImGui::RadioButton("X=Jump; Z=Attack", &configuration.attack_button_mode, 1);
|
||||
|
||||
ImGui::TableSetColumnIndex(1);
|
||||
ImGui::SetNextItemWidth(-1.0f);
|
||||
const char *items[] = {"Fullscreen 16-bit", "Windowed 320x240", "Windowed 640x480", "Fullscreen 24-bit", "Fullscreen 32-bit"};
|
||||
ImGui::Combo("", &configuration.display_mode, items, IM_ARRAYSIZE(items));
|
||||
ImGui::Checkbox("Use Joypad", &configuration.bJoystick);
|
||||
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
// Joypad binding
|
||||
|
||||
if (ImGui::BeginTable("Joypad binding", 9))
|
||||
{
|
||||
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 60.0f);
|
||||
|
||||
for (int y = 0; y < 7; ++y)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
|
||||
if (y == 0)
|
||||
{
|
||||
for (int x = 1; x < 9; ++x)
|
||||
{
|
||||
ImGui::TableSetColumnIndex(x);
|
||||
ImGui::Text(" %d", x);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int x = 0; x < 9; ++x)
|
||||
{
|
||||
ImGui::TableSetColumnIndex(x);
|
||||
|
||||
if (x == 0)
|
||||
{
|
||||
const char *inputs[6] = {"Jump:", "Attack:", "Weapon+:", "Weapon-:", "Items:", "Map:"};
|
||||
ImGui::Text("%s", inputs[y - 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
static char name_buffer[5] = {'#', '#', '0', '0', '\0'};
|
||||
name_buffer[2] = '0' + x;
|
||||
name_buffer[3] = '0' + y;
|
||||
ImGui::RadioButton(name_buffer, &configuration.joystick_button[x - 1], y - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
if (ImGui::Button("Okay", ImVec2(ImGui::GetContentRegionAvail().x / 2, 0.0f)))
|
||||
{
|
||||
glfwSetWindowShouldClose(window, 1);
|
||||
|
||||
// Save to file
|
||||
FILE *file = fopen(config_path, "wb");
|
||||
|
||||
if (file != NULL)
|
||||
{
|
||||
fwrite(configuration.proof, 1, sizeof(configuration.proof), file);
|
||||
fwrite(configuration.font_name, 1, sizeof(configuration.font_name), file);
|
||||
fputc(configuration.move_button_mode, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
fputc(configuration.attack_button_mode, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
fputc(configuration.ok_button_mode, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
fputc(configuration.display_mode, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
fputc(configuration.bJoystick, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
|
||||
for (unsigned int i = 0; i < 8; ++i)
|
||||
{
|
||||
const int encode_table[6] = {0, 1, 2, 5, 3, 4};
|
||||
|
||||
fputc(encode_table[configuration.joystick_button[i]] + 1, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
fputc(0, file);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Cancel", ImVec2(ImGui::GetContentRegionAvail().x, 0.0f)))
|
||||
glfwSetWindowShouldClose(window, 1);
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
ImGui::Render();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
#ifdef LEGACY_OPENGL
|
||||
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
|
||||
#else
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
#endif
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LEGACY_OPENGL
|
||||
ImGui_ImplOpenGL2_Shutdown();
|
||||
#else
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
#endif
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
free(config_path);
|
||||
|
||||
return 0;
|
||||
}
|
1
DoConfig/icon.rc
Normal file
|
@ -0,0 +1 @@
|
|||
GLFW_ICON ICON "1.ico"
|
21
DoConfig/imgui/LICENSE.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2020 Omar Cornut
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
108
DoConfig/imgui/imconfig.h
Normal file
|
@ -0,0 +1,108 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// COMPILE-TIME OPTIONS FOR DEAR IMGUI
|
||||
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
|
||||
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
|
||||
//-----------------------------------------------------------------------------
|
||||
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/branch with your modifications to imconfig.h)
|
||||
// B) or add configuration directives in your own file and compile with #define IMGUI_USER_CONFIG "myfilename.h"
|
||||
// If you do so you need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include
|
||||
// the imgui*.cpp files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
|
||||
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
|
||||
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
//---- Define assertion handler. Defaults to calling assert().
|
||||
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
|
||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
||||
|
||||
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
|
||||
// Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
|
||||
//#define IMGUI_API __declspec( dllexport )
|
||||
//#define IMGUI_API __declspec( dllimport )
|
||||
|
||||
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
|
||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
//---- Disable all of Dear ImGui or don't implement standard windows.
|
||||
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
|
||||
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
|
||||
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
|
||||
//#define IMGUI_DISABLE_METRICS_WINDOW // Disable debug/metrics window: ShowMetricsWindow() will be empty.
|
||||
|
||||
//---- Don't implement some functions to reduce linkage requirements.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
|
||||
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
|
||||
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
||||
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
||||
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
|
||||
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
|
||||
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
|
||||
|
||||
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||
|
||||
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
|
||||
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
|
||||
//---- Use 32-bit for ImWchar (default is 16-bit) to support full unicode code points.
|
||||
//#define IMGUI_USE_WCHAR32
|
||||
|
||||
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
|
||||
// By default the embedded implementations are declared static and not available outside of imgui cpp files.
|
||||
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
|
||||
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
|
||||
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
||||
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
||||
|
||||
//---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library.
|
||||
// Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
|
||||
// #define IMGUI_USE_STB_SPRINTF
|
||||
|
||||
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
|
||||
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
|
||||
/*
|
||||
#define IM_VEC2_CLASS_EXTRA \
|
||||
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
|
||||
operator MyVec2() const { return MyVec2(x,y); }
|
||||
|
||||
#define IM_VEC4_CLASS_EXTRA \
|
||||
ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
|
||||
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
||||
*/
|
||||
|
||||
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
|
||||
// Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bit indices).
|
||||
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
|
||||
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
|
||||
//#define ImDrawIdx unsigned int
|
||||
|
||||
//---- Override ImDrawCallback signature (will need to modify renderer back-ends accordingly)
|
||||
//struct ImDrawList;
|
||||
//struct ImDrawCmd;
|
||||
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
|
||||
//#define ImDrawCallback MyImDrawCallback
|
||||
|
||||
//---- Debug Tools: Macro to break in Debugger
|
||||
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
|
||||
//#define IM_DEBUG_BREAK IM_ASSERT(0)
|
||||
//#define IM_DEBUG_BREAK __debugbreak()
|
||||
|
||||
//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
|
||||
// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
|
||||
// This adds a small runtime cost which is why it is not enabled by default.
|
||||
//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
|
||||
|
||||
//---- Debug Tools: Enable slower asserts
|
||||
//#define IMGUI_DEBUG_PARANOID
|
||||
|
||||
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
|
||||
/*
|
||||
namespace ImGui
|
||||
{
|
||||
void MyFunction(const char* name, const MyMatrix44& v);
|
||||
}
|
||||
*/
|
10806
DoConfig/imgui/imgui.cpp
Normal file
2560
DoConfig/imgui/imgui.h
Normal file
6520
DoConfig/imgui/imgui_demo.cpp
Normal file
3662
DoConfig/imgui/imgui_draw.cpp
Normal file
369
DoConfig/imgui/imgui_impl_glfw.cpp
Normal file
|
@ -0,0 +1,369 @@
|
|||
// dear imgui: Platform Binding for GLFW
|
||||
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..)
|
||||
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||
// (Requires: GLFW 3.1+)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Platform: Clipboard support.
|
||||
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange' (note: the resizing cursors requires GLFW 3.4+).
|
||||
// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2020-01-17: Inputs: Disable error callback while assigning mouse cursors because some X11 setup don't have them and it generates errors.
|
||||
// 2019-12-05: Inputs: Added support for new mouse cursors added in GLFW 3.4+ (resizing cursors, not allowed cursor).
|
||||
// 2019-10-18: Misc: Previously installed user callbacks are now restored on shutdown.
|
||||
// 2019-07-21: Inputs: Added mapping for ImGuiKey_KeyPadEnter.
|
||||
// 2019-05-11: Inputs: Don't filter value from character callback before calling AddInputCharacter().
|
||||
// 2019-03-12: Misc: Preserve DisplayFramebufferScale when main window is minimized.
|
||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
||||
// 2018-11-07: Inputs: When installing our GLFW callbacks, we save user's previously installed ones - if any - and chain call them.
|
||||
// 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls.
|
||||
// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor.
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_glfw.cpp/.h away from the old combined GLFW+OpenGL/Vulkan examples.
|
||||
// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors flag + honor ImGuiConfigFlags_NoMouseCursorChange flag.
|
||||
// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value, passed to glfwSetCursor()).
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||
// 2018-01-25: Inputs: Added gamepad support if ImGuiConfigFlags_NavEnableGamepad is set.
|
||||
// 2018-01-25: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set).
|
||||
// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
|
||||
// 2018-01-18: Inputs: Added mapping for ImGuiKey_Insert.
|
||||
// 2017-08-25: Inputs: MousePos set to -FLT_MAX,-FLT_MAX when mouse is unavailable/missing (instead of -1,-1).
|
||||
// 2016-10-15: Misc: Added a void* user_data parameter to Clipboard function handlers.
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_glfw.h"
|
||||
|
||||
// GLFW
|
||||
#include <GLFW/glfw3.h>
|
||||
#ifdef _WIN32
|
||||
#undef APIENTRY
|
||||
#define GLFW_EXPOSE_NATIVE_WIN32
|
||||
#include <GLFW/glfw3native.h> // for glfwGetWin32Window
|
||||
#endif
|
||||
#define GLFW_HAS_WINDOW_TOPMOST (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ GLFW_FLOATING
|
||||
#define GLFW_HAS_WINDOW_HOVERED (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ GLFW_HOVERED
|
||||
#define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwSetWindowOpacity
|
||||
#define GLFW_HAS_PER_MONITOR_DPI (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+ glfwGetMonitorContentScale
|
||||
#define GLFW_HAS_VULKAN (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+ glfwCreateWindowSurface
|
||||
#ifdef GLFW_RESIZE_NESW_CURSOR // let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2019-11-29 (cursors defines) // FIXME: Remove when GLFW 3.4 is released?
|
||||
#define GLFW_HAS_NEW_CURSORS (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3400) // 3.4+ GLFW_RESIZE_ALL_CURSOR, GLFW_RESIZE_NESW_CURSOR, GLFW_RESIZE_NWSE_CURSOR, GLFW_NOT_ALLOWED_CURSOR
|
||||
#else
|
||||
#define GLFW_HAS_NEW_CURSORS (0)
|
||||
#endif
|
||||
|
||||
// Data
|
||||
enum GlfwClientApi
|
||||
{
|
||||
GlfwClientApi_Unknown,
|
||||
GlfwClientApi_OpenGL,
|
||||
GlfwClientApi_Vulkan
|
||||
};
|
||||
static GLFWwindow* g_Window = NULL; // Main window
|
||||
static GlfwClientApi g_ClientApi = GlfwClientApi_Unknown;
|
||||
static double g_Time = 0.0;
|
||||
static bool g_MouseJustPressed[ImGuiMouseButton_COUNT] = {};
|
||||
static GLFWcursor* g_MouseCursors[ImGuiMouseCursor_COUNT] = {};
|
||||
static bool g_InstalledCallbacks = false;
|
||||
|
||||
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
||||
static GLFWmousebuttonfun g_PrevUserCallbackMousebutton = NULL;
|
||||
static GLFWscrollfun g_PrevUserCallbackScroll = NULL;
|
||||
static GLFWkeyfun g_PrevUserCallbackKey = NULL;
|
||||
static GLFWcharfun g_PrevUserCallbackChar = NULL;
|
||||
|
||||
static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data)
|
||||
{
|
||||
return glfwGetClipboardString((GLFWwindow*)user_data);
|
||||
}
|
||||
|
||||
static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text)
|
||||
{
|
||||
glfwSetClipboardString((GLFWwindow*)user_data, text);
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods)
|
||||
{
|
||||
if (g_PrevUserCallbackMousebutton != NULL)
|
||||
g_PrevUserCallbackMousebutton(window, button, action, mods);
|
||||
|
||||
if (action == GLFW_PRESS && button >= 0 && button < IM_ARRAYSIZE(g_MouseJustPressed))
|
||||
g_MouseJustPressed[button] = true;
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset)
|
||||
{
|
||||
if (g_PrevUserCallbackScroll != NULL)
|
||||
g_PrevUserCallbackScroll(window, xoffset, yoffset);
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.MouseWheelH += (float)xoffset;
|
||||
io.MouseWheel += (float)yoffset;
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (g_PrevUserCallbackKey != NULL)
|
||||
g_PrevUserCallbackKey(window, key, scancode, action, mods);
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (action == GLFW_PRESS)
|
||||
io.KeysDown[key] = true;
|
||||
if (action == GLFW_RELEASE)
|
||||
io.KeysDown[key] = false;
|
||||
|
||||
// Modifiers are not reliable across systems
|
||||
io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
|
||||
io.KeyShift = io.KeysDown[GLFW_KEY_LEFT_SHIFT] || io.KeysDown[GLFW_KEY_RIGHT_SHIFT];
|
||||
io.KeyAlt = io.KeysDown[GLFW_KEY_LEFT_ALT] || io.KeysDown[GLFW_KEY_RIGHT_ALT];
|
||||
#ifdef _WIN32
|
||||
io.KeySuper = false;
|
||||
#else
|
||||
io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
|
||||
#endif
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c)
|
||||
{
|
||||
if (g_PrevUserCallbackChar != NULL)
|
||||
g_PrevUserCallbackChar(window, c);
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.AddInputCharacter(c);
|
||||
}
|
||||
|
||||
static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
|
||||
{
|
||||
g_Window = window;
|
||||
g_Time = 0.0;
|
||||
|
||||
// Setup back-end capabilities flags
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||
io.BackendPlatformName = "imgui_impl_glfw";
|
||||
|
||||
// Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
|
||||
io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB;
|
||||
io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
|
||||
io.KeyMap[ImGuiKey_RightArrow] = GLFW_KEY_RIGHT;
|
||||
io.KeyMap[ImGuiKey_UpArrow] = GLFW_KEY_UP;
|
||||
io.KeyMap[ImGuiKey_DownArrow] = GLFW_KEY_DOWN;
|
||||
io.KeyMap[ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP;
|
||||
io.KeyMap[ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN;
|
||||
io.KeyMap[ImGuiKey_Home] = GLFW_KEY_HOME;
|
||||
io.KeyMap[ImGuiKey_End] = GLFW_KEY_END;
|
||||
io.KeyMap[ImGuiKey_Insert] = GLFW_KEY_INSERT;
|
||||
io.KeyMap[ImGuiKey_Delete] = GLFW_KEY_DELETE;
|
||||
io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
|
||||
io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE;
|
||||
io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
|
||||
io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
|
||||
io.KeyMap[ImGuiKey_KeyPadEnter] = GLFW_KEY_KP_ENTER;
|
||||
io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
|
||||
io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
|
||||
io.KeyMap[ImGuiKey_V] = GLFW_KEY_V;
|
||||
io.KeyMap[ImGuiKey_X] = GLFW_KEY_X;
|
||||
io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
|
||||
io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
|
||||
|
||||
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
||||
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
||||
io.ClipboardUserData = g_Window;
|
||||
#if defined(_WIN32)
|
||||
io.ImeWindowHandle = (void*)glfwGetWin32Window(g_Window);
|
||||
#endif
|
||||
|
||||
// Create mouse cursors
|
||||
// (By design, on X11 cursors are user configurable and some cursors may be missing. When a cursor doesn't exist,
|
||||
// GLFW will emit an error which will often be printed by the app, so we temporarily disable error reporting.
|
||||
// Missing cursors will return NULL and our _UpdateMouseCursor() function will use the Arrow cursor instead.)
|
||||
GLFWerrorfun prev_error_callback = glfwSetErrorCallback(NULL);
|
||||
g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
||||
g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR);
|
||||
g_MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR);
|
||||
#if GLFW_HAS_NEW_CURSORS
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_RESIZE_ALL_CURSOR);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_RESIZE_NESW_CURSOR);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_RESIZE_NWSE_CURSOR);
|
||||
g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_NOT_ALLOWED_CURSOR);
|
||||
#else
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
||||
g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
||||
g_MouseCursors[ImGuiMouseCursor_NotAllowed] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR);
|
||||
#endif
|
||||
glfwSetErrorCallback(prev_error_callback);
|
||||
|
||||
// Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
|
||||
g_PrevUserCallbackMousebutton = NULL;
|
||||
g_PrevUserCallbackScroll = NULL;
|
||||
g_PrevUserCallbackKey = NULL;
|
||||
g_PrevUserCallbackChar = NULL;
|
||||
if (install_callbacks)
|
||||
{
|
||||
g_InstalledCallbacks = true;
|
||||
g_PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
|
||||
g_PrevUserCallbackScroll = glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
|
||||
g_PrevUserCallbackKey = glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
|
||||
g_PrevUserCallbackChar = glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
|
||||
}
|
||||
|
||||
g_ClientApi = client_api;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks)
|
||||
{
|
||||
return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_OpenGL);
|
||||
}
|
||||
|
||||
bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks)
|
||||
{
|
||||
return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan);
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_Shutdown()
|
||||
{
|
||||
if (g_InstalledCallbacks)
|
||||
{
|
||||
glfwSetMouseButtonCallback(g_Window, g_PrevUserCallbackMousebutton);
|
||||
glfwSetScrollCallback(g_Window, g_PrevUserCallbackScroll);
|
||||
glfwSetKeyCallback(g_Window, g_PrevUserCallbackKey);
|
||||
glfwSetCharCallback(g_Window, g_PrevUserCallbackChar);
|
||||
g_InstalledCallbacks = false;
|
||||
}
|
||||
|
||||
for (ImGuiMouseCursor cursor_n = 0; cursor_n < ImGuiMouseCursor_COUNT; cursor_n++)
|
||||
{
|
||||
glfwDestroyCursor(g_MouseCursors[cursor_n]);
|
||||
g_MouseCursors[cursor_n] = NULL;
|
||||
}
|
||||
g_ClientApi = GlfwClientApi_Unknown;
|
||||
}
|
||||
|
||||
static void ImGui_ImplGlfw_UpdateMousePosAndButtons()
|
||||
{
|
||||
// Update buttons
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
for (int i = 0; i < IM_ARRAYSIZE(io.MouseDown); i++)
|
||||
{
|
||||
// If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
|
||||
io.MouseDown[i] = g_MouseJustPressed[i] || glfwGetMouseButton(g_Window, i) != 0;
|
||||
g_MouseJustPressed[i] = false;
|
||||
}
|
||||
|
||||
// Update mouse position
|
||||
const ImVec2 mouse_pos_backup = io.MousePos;
|
||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
#ifdef __EMSCRIPTEN__
|
||||
const bool focused = true; // Emscripten
|
||||
#else
|
||||
const bool focused = glfwGetWindowAttrib(g_Window, GLFW_FOCUSED) != 0;
|
||||
#endif
|
||||
if (focused)
|
||||
{
|
||||
if (io.WantSetMousePos)
|
||||
{
|
||||
glfwSetCursorPos(g_Window, (double)mouse_pos_backup.x, (double)mouse_pos_backup.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
double mouse_x, mouse_y;
|
||||
glfwGetCursorPos(g_Window, &mouse_x, &mouse_y);
|
||||
io.MousePos = ImVec2((float)mouse_x, (float)mouse_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ImGui_ImplGlfw_UpdateMouseCursor()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if ((io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange) || glfwGetInputMode(g_Window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
|
||||
return;
|
||||
|
||||
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
|
||||
if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
|
||||
{
|
||||
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
|
||||
glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show OS mouse cursor
|
||||
// FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here.
|
||||
glfwSetCursor(g_Window, g_MouseCursors[imgui_cursor] ? g_MouseCursors[imgui_cursor] : g_MouseCursors[ImGuiMouseCursor_Arrow]);
|
||||
glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
static void ImGui_ImplGlfw_UpdateGamepads()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||
return;
|
||||
|
||||
// Update gamepad inputs
|
||||
#define MAP_BUTTON(NAV_NO, BUTTON_NO) { if (buttons_count > BUTTON_NO && buttons[BUTTON_NO] == GLFW_PRESS) io.NavInputs[NAV_NO] = 1.0f; }
|
||||
#define MAP_ANALOG(NAV_NO, AXIS_NO, V0, V1) { float v = (axes_count > AXIS_NO) ? axes[AXIS_NO] : V0; v = (v - V0) / (V1 - V0); if (v > 1.0f) v = 1.0f; if (io.NavInputs[NAV_NO] < v) io.NavInputs[NAV_NO] = v; }
|
||||
int axes_count = 0, buttons_count = 0;
|
||||
const float* axes = glfwGetJoystickAxes(GLFW_JOYSTICK_1, &axes_count);
|
||||
const unsigned char* buttons = glfwGetJoystickButtons(GLFW_JOYSTICK_1, &buttons_count);
|
||||
MAP_BUTTON(ImGuiNavInput_Activate, 0); // Cross / A
|
||||
MAP_BUTTON(ImGuiNavInput_Cancel, 1); // Circle / B
|
||||
MAP_BUTTON(ImGuiNavInput_Menu, 2); // Square / X
|
||||
MAP_BUTTON(ImGuiNavInput_Input, 3); // Triangle / Y
|
||||
MAP_BUTTON(ImGuiNavInput_DpadLeft, 13); // D-Pad Left
|
||||
MAP_BUTTON(ImGuiNavInput_DpadRight, 11); // D-Pad Right
|
||||
MAP_BUTTON(ImGuiNavInput_DpadUp, 10); // D-Pad Up
|
||||
MAP_BUTTON(ImGuiNavInput_DpadDown, 12); // D-Pad Down
|
||||
MAP_BUTTON(ImGuiNavInput_FocusPrev, 4); // L1 / LB
|
||||
MAP_BUTTON(ImGuiNavInput_FocusNext, 5); // R1 / RB
|
||||
MAP_BUTTON(ImGuiNavInput_TweakSlow, 4); // L1 / LB
|
||||
MAP_BUTTON(ImGuiNavInput_TweakFast, 5); // R1 / RB
|
||||
MAP_ANALOG(ImGuiNavInput_LStickLeft, 0, -0.3f, -0.9f);
|
||||
MAP_ANALOG(ImGuiNavInput_LStickRight,0, +0.3f, +0.9f);
|
||||
MAP_ANALOG(ImGuiNavInput_LStickUp, 1, +0.3f, +0.9f);
|
||||
MAP_ANALOG(ImGuiNavInput_LStickDown, 1, -0.3f, -0.9f);
|
||||
#undef MAP_BUTTON
|
||||
#undef MAP_ANALOG
|
||||
if (axes_count > 0 && buttons_count > 0)
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||
else
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_NewFrame()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
|
||||
|
||||
// Setup display size (every frame to accommodate for window resizing)
|
||||
int w, h;
|
||||
int display_w, display_h;
|
||||
glfwGetWindowSize(g_Window, &w, &h);
|
||||
glfwGetFramebufferSize(g_Window, &display_w, &display_h);
|
||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||
if (w > 0 && h > 0)
|
||||
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
|
||||
|
||||
// Setup time step
|
||||
double current_time = glfwGetTime();
|
||||
io.DeltaTime = g_Time > 0.0 ? (float)(current_time - g_Time) : (float)(1.0f / 60.0f);
|
||||
g_Time = current_time;
|
||||
|
||||
ImGui_ImplGlfw_UpdateMousePosAndButtons();
|
||||
ImGui_ImplGlfw_UpdateMouseCursor();
|
||||
|
||||
// Update game controllers (if enabled and available)
|
||||
ImGui_ImplGlfw_UpdateGamepads();
|
||||
}
|
35
DoConfig/imgui/imgui_impl_glfw.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
// dear imgui: Platform Binding for GLFW
|
||||
// This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..)
|
||||
// (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Platform: Clipboard support.
|
||||
// [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
// [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW.
|
||||
// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// About GLSL version:
|
||||
// The 'glsl_version' initialization parameter defaults to "#version 150" if NULL.
|
||||
// Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure!
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
|
||||
struct GLFWwindow;
|
||||
|
||||
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks);
|
||||
IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks);
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
|
||||
|
||||
// GLFW callbacks
|
||||
// - When calling Init with 'install_callbacks=true': GLFW callbacks will be installed for you. They will call user's previously installed callbacks, if any.
|
||||
// - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call those function yourself from your own GLFW callbacks.
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
|
248
DoConfig/imgui/imgui_impl_opengl2.cpp
Normal file
|
@ -0,0 +1,248 @@
|
|||
// dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline)
|
||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||
// **Prefer using the code in imgui_impl_opengl3.cpp**
|
||||
// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read.
|
||||
// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more
|
||||
// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might
|
||||
// confuse your GPU driver.
|
||||
// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API.
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2020-01-23: OpenGL: Explicitly backup, setup and restore GL_TEXTURE_ENV to increase compatibility with legacy OpenGL applications.
|
||||
// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
||||
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
||||
// 2018-08-03: OpenGL: Disabling/restoring GL_LIGHTING and GL_COLOR_MATERIAL to increase compatibility with legacy OpenGL applications.
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_opengl2.cpp/.h away from the old combined GLFW/SDL+OpenGL2 examples.
|
||||
// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplOpenGL2_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2017-09-01: OpenGL: Save and restore current polygon mode.
|
||||
// 2016-09-10: OpenGL: Uploading font texture as RGBA32 to increase compatibility with users shaders (not ideal).
|
||||
// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_opengl2.h"
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||
#include <stddef.h> // intptr_t
|
||||
#else
|
||||
#include <stdint.h> // intptr_t
|
||||
#endif
|
||||
|
||||
// Include OpenGL header (without an OpenGL loader) requires a bit of fiddling
|
||||
#if defined(_WIN32) && !defined(APIENTRY)
|
||||
#define APIENTRY __stdcall // It is customary to use APIENTRY for OpenGL function pointer declarations on all platforms. Additionally, the Windows OpenGL header needs APIENTRY.
|
||||
#endif
|
||||
#if defined(_WIN32) && !defined(WINGDIAPI)
|
||||
#define WINGDIAPI __declspec(dllimport) // Some Windows OpenGL headers need this
|
||||
#endif
|
||||
#if defined(__APPLE__)
|
||||
#define GL_SILENCE_DEPRECATION
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
// OpenGL Data
|
||||
static GLuint g_FontTexture = 0;
|
||||
|
||||
// Functions
|
||||
bool ImGui_ImplOpenGL2_Init()
|
||||
{
|
||||
// Setup back-end capabilities flags
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendRendererName = "imgui_impl_opengl2";
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL2_Shutdown()
|
||||
{
|
||||
ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL2_NewFrame()
|
||||
{
|
||||
if (!g_FontTexture)
|
||||
ImGui_ImplOpenGL2_CreateDeviceObjects();
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL2_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height)
|
||||
{
|
||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
// If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
|
||||
// you may need to backup/reset/restore current shader using the lines below. DO NOT MODIFY THIS FILE! Add the code in your calling function:
|
||||
// GLint last_program;
|
||||
// glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
|
||||
// glUseProgram(0);
|
||||
// ImGui_ImplOpenGL2_RenderDrawData(...);
|
||||
// glUseProgram(last_program)
|
||||
|
||||
// Setup viewport, orthographic projection matrix
|
||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrtho(draw_data->DisplayPos.x, draw_data->DisplayPos.x + draw_data->DisplaySize.x, draw_data->DisplayPos.y + draw_data->DisplaySize.y, draw_data->DisplayPos.y, -1.0f, +1.0f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
// OpenGL2 Render function.
|
||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
||||
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
|
||||
void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data)
|
||||
{
|
||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||
if (fb_width == 0 || fb_height == 0)
|
||||
return;
|
||||
|
||||
// Backup GL state
|
||||
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
||||
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
||||
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
|
||||
GLint last_tex_env_mode; glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &last_tex_env_mode);
|
||||
glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT);
|
||||
|
||||
// Setup desired GL state
|
||||
ImGui_ImplOpenGL2_SetupRenderState(draw_data, fb_width, fb_height);
|
||||
|
||||
// Will project scissor/clipping rectangles into framebuffer space
|
||||
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||
|
||||
// Render command lists
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data;
|
||||
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data;
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, pos)));
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, uv)));
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (const GLvoid*)((const char*)vtx_buffer + IM_OFFSETOF(ImDrawVert, col)));
|
||||
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
if (pcmd->UserCallback)
|
||||
{
|
||||
// User callback, registered via ImDrawList::AddCallback()
|
||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||
ImGui_ImplOpenGL2_SetupRenderState(draw_data, fb_width, fb_height);
|
||||
else
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Project scissor/clipping rectangles into framebuffer space
|
||||
ImVec4 clip_rect;
|
||||
clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
|
||||
clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
|
||||
clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
|
||||
clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
|
||||
|
||||
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
||||
{
|
||||
// Apply scissor/clipping rectangle
|
||||
glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
|
||||
|
||||
// Bind texture, Draw
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
|
||||
}
|
||||
}
|
||||
idx_buffer += pcmd->ElemCount;
|
||||
}
|
||||
}
|
||||
|
||||
// Restore modified GL state
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)last_texture);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glPopAttrib();
|
||||
glPolygonMode(GL_FRONT, (GLenum)last_polygon_mode[0]); glPolygonMode(GL_BACK, (GLenum)last_polygon_mode[1]);
|
||||
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
|
||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, last_tex_env_mode);
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL2_CreateFontsTexture()
|
||||
{
|
||||
// Build texture atlas
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
unsigned char* pixels;
|
||||
int width, height;
|
||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
|
||||
|
||||
// Upload texture to graphics system
|
||||
GLint last_texture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||
glGenTextures(1, &g_FontTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
// Store our identifier
|
||||
io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture;
|
||||
|
||||
// Restore state
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL2_DestroyFontsTexture()
|
||||
{
|
||||
if (g_FontTexture)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
glDeleteTextures(1, &g_FontTexture);
|
||||
io.Fonts->TexID = 0;
|
||||
g_FontTexture = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL2_CreateDeviceObjects()
|
||||
{
|
||||
return ImGui_ImplOpenGL2_CreateFontsTexture();
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL2_DestroyDeviceObjects()
|
||||
{
|
||||
ImGui_ImplOpenGL2_DestroyFontsTexture();
|
||||
}
|
31
DoConfig/imgui/imgui_impl_opengl2.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
// dear imgui: Renderer for OpenGL2 (legacy OpenGL, fixed pipeline)
|
||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// **DO NOT USE THIS CODE IF YOUR CODE/ENGINE IS USING MODERN OPENGL (SHADERS, VBO, VAO, etc.)**
|
||||
// **Prefer using the code in imgui_impl_opengl3.cpp**
|
||||
// This code is mostly provided as a reference to learn how ImGui integration works, because it is shorter to read.
|
||||
// If your code is using GL3+ context or any semi modern OpenGL calls, using this is likely to make everything more
|
||||
// complicated, will require your code to reset every single OpenGL attributes to their initial state, and might
|
||||
// confuse your GPU driver.
|
||||
// The GL2 code is unable to reset attributes or even call e.g. "glUseProgram(0)" because they don't exist in that API.
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_Init();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL2_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL2_NewFrame();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL2_RenderDrawData(ImDrawData* draw_data);
|
||||
|
||||
// Called by Init/NewFrame/Shutdown
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateFontsTexture();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyFontsTexture();
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL2_CreateDeviceObjects();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL2_DestroyDeviceObjects();
|
677
DoConfig/imgui/imgui_impl_opengl3.cpp
Normal file
|
@ -0,0 +1,677 @@
|
|||
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
|
||||
// - Desktop GL: 2.x 3.x 4.x
|
||||
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2020-05-08: OpenGL: Made default GLSL version 150 (instead of 130) on OSX.
|
||||
// 2020-04-21: OpenGL: Fixed handling of glClipControl(GL_UPPER_LEFT) by inverting projection matrix.
|
||||
// 2020-04-12: OpenGL: Fixed context version check mistakenly testing for 4.0+ instead of 3.2+ to enable ImGuiBackendFlags_RendererHasVtxOffset.
|
||||
// 2020-03-24: OpenGL: Added support for glbinding 2.x OpenGL loader.
|
||||
// 2020-01-07: OpenGL: Added support for glbinding 3.x OpenGL loader.
|
||||
// 2019-10-25: OpenGL: Using a combination of GL define and runtime GL version to decide whether to use glDrawElementsBaseVertex(). Fix building with pre-3.2 GL loaders.
|
||||
// 2019-09-22: OpenGL: Detect default GL loader using __has_include compiler facility.
|
||||
// 2019-09-16: OpenGL: Tweak initialization code to allow application calling ImGui_ImplOpenGL3_CreateFontsTexture() before the first NewFrame() call.
|
||||
// 2019-05-29: OpenGL: Desktop GL only: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||
// 2019-04-30: OpenGL: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||
// 2019-03-29: OpenGL: Not calling glBindBuffer more than necessary in the render loop.
|
||||
// 2019-03-15: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized GL function loaders early.
|
||||
// 2019-03-03: OpenGL: Fix support for ES 2.0 (WebGL 1.0).
|
||||
// 2019-02-20: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if defined by the headers/loader.
|
||||
// 2019-02-11: OpenGL: Projecting clipping rectangles correctly using draw_data->FramebufferScale to allow multi-viewports for retina display.
|
||||
// 2019-02-01: OpenGL: Using GLSL 410 shaders for any version over 410 (e.g. 430, 450).
|
||||
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
||||
// 2018-11-13: OpenGL: Support for GL 4.5's glClipControl(GL_UPPER_LEFT) / GL_CLIP_ORIGIN.
|
||||
// 2018-08-29: OpenGL: Added support for more OpenGL loaders: glew and glad, with comments indicative that any loader can be used.
|
||||
// 2018-08-09: OpenGL: Default to OpenGL ES 3 on iOS and Android. GLSL version default to "#version 300 ES".
|
||||
// 2018-07-30: OpenGL: Support for GLSL 300 ES and 410 core. Fixes for Emscripten compilation.
|
||||
// 2018-07-10: OpenGL: Support for more GLSL versions (based on the GLSL version string). Added error output when shaders fail to compile/link.
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_opengl3.cpp/.h away from the old combined GLFW/SDL+OpenGL3 examples.
|
||||
// 2018-06-08: OpenGL: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
||||
// 2018-05-25: OpenGL: Removed unnecessary backup/restore of GL_ELEMENT_ARRAY_BUFFER_BINDING since this is part of the VAO state.
|
||||
// 2018-05-14: OpenGL: Making the call to glBindSampler() optional so 3.2 context won't fail if the function is a NULL pointer.
|
||||
// 2018-03-06: OpenGL: Added const char* glsl_version parameter to ImGui_ImplOpenGL3_Init() so user can override the GLSL version e.g. "#version 150".
|
||||
// 2018-02-23: OpenGL: Create the VAO in the render function so the setup can more easily be used with multiple shared GL context.
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplSdlGL3_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-01-07: OpenGL: Changed GLSL shader version from 330 to 150.
|
||||
// 2017-09-01: OpenGL: Save and restore current bound sampler. Save and restore current polygon mode.
|
||||
// 2017-05-01: OpenGL: Fixed save and restore of current blend func state.
|
||||
// 2017-05-01: OpenGL: Fixed save and restore of current GL_ACTIVE_TEXTURE.
|
||||
// 2016-09-05: OpenGL: Fixed save and restore of current scissor rectangle.
|
||||
// 2016-07-29: OpenGL: Explicitly setting GL_UNPACK_ROW_LENGTH to reduce issues because SDL changes it. (#752)
|
||||
|
||||
//----------------------------------------
|
||||
// OpenGL GLSL GLSL
|
||||
// version version string
|
||||
//----------------------------------------
|
||||
// 2.0 110 "#version 110"
|
||||
// 2.1 120 "#version 120"
|
||||
// 3.0 130 "#version 130"
|
||||
// 3.1 140 "#version 140"
|
||||
// 3.2 150 "#version 150"
|
||||
// 3.3 330 "#version 330 core"
|
||||
// 4.0 400 "#version 400 core"
|
||||
// 4.1 410 "#version 410 core"
|
||||
// 4.2 420 "#version 410 core"
|
||||
// 4.3 430 "#version 430 core"
|
||||
// ES 2.0 100 "#version 100" = WebGL 1.0
|
||||
// ES 3.0 300 "#version 300 es" = WebGL 2.0
|
||||
//----------------------------------------
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_opengl3.h"
|
||||
#include <stdio.h>
|
||||
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
|
||||
#include <stddef.h> // intptr_t
|
||||
#else
|
||||
#include <stdint.h> // intptr_t
|
||||
#endif
|
||||
|
||||
|
||||
// GL includes
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
#include <GLES2/gl2.h>
|
||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV))
|
||||
#include <OpenGLES/ES3/gl.h> // Use GL ES 3
|
||||
#else
|
||||
#include <GLES3/gl3.h> // Use GL ES 3
|
||||
#endif
|
||||
#else
|
||||
// About Desktop OpenGL function loaders:
|
||||
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
|
||||
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
||||
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
||||
#include <GL/gl3w.h> // Needs to be initialized with gl3wInit() in user's code
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
||||
#include <GL/glew.h> // Needs to be initialized with glewInit() in user's code.
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||
#include <glad/glad.h> // Needs to be initialized with gladLoadGL() in user's code.
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||
#ifndef GLFW_INCLUDE_NONE
|
||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||
#endif
|
||||
#include <glbinding/Binding.h> // Needs to be initialized with glbinding::Binding::initialize() in user's code.
|
||||
#include <glbinding/gl/gl.h>
|
||||
using namespace gl;
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
||||
#ifndef GLFW_INCLUDE_NONE
|
||||
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
|
||||
#endif
|
||||
#include <glbinding/glbinding.h>// Needs to be initialized with glbinding::initialize() in user's code.
|
||||
#include <glbinding/gl/gl.h>
|
||||
using namespace gl;
|
||||
#else
|
||||
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Desktop GL 3.2+ has glDrawElementsBaseVertex() which GL ES and WebGL don't have.
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2) || defined(IMGUI_IMPL_OPENGL_ES3) || !defined(GL_VERSION_3_2)
|
||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 0
|
||||
#else
|
||||
#define IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET 1
|
||||
#endif
|
||||
|
||||
// OpenGL Data
|
||||
static GLuint g_GlVersion = 0; // Extracted at runtime using GL_MAJOR_VERSION, GL_MINOR_VERSION queries (e.g. 320 for GL 3.2)
|
||||
static char g_GlslVersionString[32] = ""; // Specified by user or detected based on compile time GL settings.
|
||||
static GLuint g_FontTexture = 0;
|
||||
static GLuint g_ShaderHandle = 0, g_VertHandle = 0, g_FragHandle = 0;
|
||||
static GLint g_AttribLocationTex = 0, g_AttribLocationProjMtx = 0; // Uniforms location
|
||||
static GLuint g_AttribLocationVtxPos = 0, g_AttribLocationVtxUV = 0, g_AttribLocationVtxColor = 0; // Vertex attributes location
|
||||
static unsigned int g_VboHandle = 0, g_ElementsHandle = 0;
|
||||
|
||||
// Functions
|
||||
bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||
{
|
||||
// Query for GL version (e.g. 320 for GL 3.2)
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
GLint major, minor;
|
||||
glGetIntegerv(GL_MAJOR_VERSION, &major);
|
||||
glGetIntegerv(GL_MINOR_VERSION, &minor);
|
||||
g_GlVersion = (GLuint)(major * 100 + minor * 10);
|
||||
#else
|
||||
g_GlVersion = 200; // GLES 2
|
||||
#endif
|
||||
|
||||
// Setup back-end capabilities flags
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendRendererName = "imgui_impl_opengl3";
|
||||
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||
if (g_GlVersion >= 320)
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||
#endif
|
||||
|
||||
// Store GLSL version string so we can refer to it later in case we recreate shaders.
|
||||
// Note: GLSL version is NOT the same as GL version. Leave this to NULL if unsure.
|
||||
#if defined(IMGUI_IMPL_OPENGL_ES2)
|
||||
if (glsl_version == NULL)
|
||||
glsl_version = "#version 100";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_ES3)
|
||||
if (glsl_version == NULL)
|
||||
glsl_version = "#version 300 es";
|
||||
#elif defined(__APPLE__)
|
||||
if (glsl_version == NULL)
|
||||
glsl_version = "#version 150";
|
||||
#else
|
||||
if (glsl_version == NULL)
|
||||
glsl_version = "#version 130";
|
||||
#endif
|
||||
IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString));
|
||||
strcpy(g_GlslVersionString, glsl_version);
|
||||
strcat(g_GlslVersionString, "\n");
|
||||
|
||||
// Dummy construct to make it easily visible in the IDE and debugger which GL loader has been selected.
|
||||
// The code actually never uses the 'gl_loader' variable! It is only here so you can read it!
|
||||
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
|
||||
// you are likely to get a crash below.
|
||||
// You can explicitly select a loader by using '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
||||
const char* gl_loader = "Unknown";
|
||||
IM_UNUSED(gl_loader);
|
||||
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
|
||||
gl_loader = "GL3W";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
|
||||
gl_loader = "GLEW";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
|
||||
gl_loader = "GLAD";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
|
||||
gl_loader = "glbinding2";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
|
||||
gl_loader = "glbinding3";
|
||||
#elif defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
||||
gl_loader = "custom";
|
||||
#else
|
||||
gl_loader = "none";
|
||||
#endif
|
||||
|
||||
// Make a dummy GL call (we don't actually need the result)
|
||||
// IF YOU GET A CRASH HERE: it probably means that you haven't initialized the OpenGL function loader used by this code.
|
||||
// Desktop OpenGL 3/4 need a function loader. See the IMGUI_IMPL_OPENGL_LOADER_xxx explanation above.
|
||||
GLint current_texture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_Shutdown()
|
||||
{
|
||||
ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_NewFrame()
|
||||
{
|
||||
if (!g_ShaderHandle)
|
||||
ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||
}
|
||||
|
||||
static void ImGui_ImplOpenGL3_SetupRenderState(ImDrawData* draw_data, int fb_width, int fb_height, GLuint vertex_array_object)
|
||||
{
|
||||
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glDisable(GL_CULL_FACE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
#ifdef GL_POLYGON_MODE
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
#endif
|
||||
|
||||
// Support for GL 4.5 rarely used glClipControl(GL_UPPER_LEFT)
|
||||
bool clip_origin_lower_left = true;
|
||||
#if defined(GL_CLIP_ORIGIN) && !defined(__APPLE__)
|
||||
GLenum current_clip_origin = 0; glGetIntegerv(GL_CLIP_ORIGIN, (GLint*)¤t_clip_origin);
|
||||
if (current_clip_origin == GL_UPPER_LEFT)
|
||||
clip_origin_lower_left = false;
|
||||
#endif
|
||||
|
||||
// Setup viewport, orthographic projection matrix
|
||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||
glViewport(0, 0, (GLsizei)fb_width, (GLsizei)fb_height);
|
||||
float L = draw_data->DisplayPos.x;
|
||||
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
||||
float T = draw_data->DisplayPos.y;
|
||||
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
||||
if (!clip_origin_lower_left) { float tmp = T; T = B; B = tmp; } // Swap top and bottom if origin is upper left
|
||||
const float ortho_projection[4][4] =
|
||||
{
|
||||
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, -1.0f, 0.0f },
|
||||
{ (R+L)/(L-R), (T+B)/(B-T), 0.0f, 1.0f },
|
||||
};
|
||||
glUseProgram(g_ShaderHandle);
|
||||
glUniform1i(g_AttribLocationTex, 0);
|
||||
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
|
||||
#ifdef GL_SAMPLER_BINDING
|
||||
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
|
||||
#endif
|
||||
|
||||
(void)vertex_array_object;
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glBindVertexArray(vertex_array_object);
|
||||
#endif
|
||||
|
||||
// Bind vertex/index buffers and setup attributes for ImDrawVert
|
||||
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, g_ElementsHandle);
|
||||
glEnableVertexAttribArray(g_AttribLocationVtxPos);
|
||||
glEnableVertexAttribArray(g_AttribLocationVtxUV);
|
||||
glEnableVertexAttribArray(g_AttribLocationVtxColor);
|
||||
glVertexAttribPointer(g_AttribLocationVtxPos, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, pos));
|
||||
glVertexAttribPointer(g_AttribLocationVtxUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, uv));
|
||||
glVertexAttribPointer(g_AttribLocationVtxColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)IM_OFFSETOF(ImDrawVert, col));
|
||||
}
|
||||
|
||||
// OpenGL3 Render function.
|
||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
||||
// Note that this implementation is little overcomplicated because we are saving/setting up/restoring every OpenGL state explicitly, in order to be able to run within any OpenGL engine that doesn't do so.
|
||||
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data)
|
||||
{
|
||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
|
||||
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
|
||||
if (fb_width <= 0 || fb_height <= 0)
|
||||
return;
|
||||
|
||||
// Backup GL state
|
||||
GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, (GLint*)&last_active_texture);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
GLuint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_program);
|
||||
GLuint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&last_texture);
|
||||
#ifdef GL_SAMPLER_BINDING
|
||||
GLuint last_sampler; glGetIntegerv(GL_SAMPLER_BINDING, (GLint*)&last_sampler);
|
||||
#endif
|
||||
GLuint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, (GLint*)&last_array_buffer);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
GLuint last_vertex_array_object; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint*)&last_vertex_array_object);
|
||||
#endif
|
||||
#ifdef GL_POLYGON_MODE
|
||||
GLint last_polygon_mode[2]; glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode);
|
||||
#endif
|
||||
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
|
||||
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
|
||||
GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, (GLint*)&last_blend_src_rgb);
|
||||
GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, (GLint*)&last_blend_dst_rgb);
|
||||
GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, (GLint*)&last_blend_src_alpha);
|
||||
GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, (GLint*)&last_blend_dst_alpha);
|
||||
GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, (GLint*)&last_blend_equation_rgb);
|
||||
GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, (GLint*)&last_blend_equation_alpha);
|
||||
GLboolean last_enable_blend = glIsEnabled(GL_BLEND);
|
||||
GLboolean last_enable_cull_face = glIsEnabled(GL_CULL_FACE);
|
||||
GLboolean last_enable_depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||
GLboolean last_enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
||||
|
||||
// Setup desired GL state
|
||||
// Recreate the VAO every time (this is to easily allow multiple GL contexts to be rendered to. VAO are not shared among GL contexts)
|
||||
// The renderer would actually work without any VAO bound, but then our VertexAttrib calls would overwrite the default one currently bound.
|
||||
GLuint vertex_array_object = 0;
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glGenVertexArrays(1, &vertex_array_object);
|
||||
#endif
|
||||
ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
|
||||
|
||||
// Will project scissor/clipping rectangles into framebuffer space
|
||||
ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
|
||||
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
||||
|
||||
// Render command lists
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
|
||||
// Upload vertex/index buffers
|
||||
glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)cmd_list->VtxBuffer.Size * (int)sizeof(ImDrawVert), (const GLvoid*)cmd_list->VtxBuffer.Data, GL_STREAM_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)cmd_list->IdxBuffer.Size * (int)sizeof(ImDrawIdx), (const GLvoid*)cmd_list->IdxBuffer.Data, GL_STREAM_DRAW);
|
||||
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
if (pcmd->UserCallback != NULL)
|
||||
{
|
||||
// User callback, registered via ImDrawList::AddCallback()
|
||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||
ImGui_ImplOpenGL3_SetupRenderState(draw_data, fb_width, fb_height, vertex_array_object);
|
||||
else
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Project scissor/clipping rectangles into framebuffer space
|
||||
ImVec4 clip_rect;
|
||||
clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
|
||||
clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
|
||||
clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
|
||||
clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
|
||||
|
||||
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
|
||||
{
|
||||
// Apply scissor/clipping rectangle
|
||||
glScissor((int)clip_rect.x, (int)(fb_height - clip_rect.w), (int)(clip_rect.z - clip_rect.x), (int)(clip_rect.w - clip_rect.y));
|
||||
|
||||
// Bind texture, Draw
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||
#if IMGUI_IMPL_OPENGL_MAY_HAVE_VTX_OFFSET
|
||||
if (g_GlVersion >= 320)
|
||||
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)), (GLint)pcmd->VtxOffset);
|
||||
else
|
||||
#endif
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, (void*)(intptr_t)(pcmd->IdxOffset * sizeof(ImDrawIdx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy the temporary VAO
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glDeleteVertexArrays(1, &vertex_array_object);
|
||||
#endif
|
||||
|
||||
// Restore modified GL state
|
||||
glUseProgram(last_program);
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
#ifdef GL_SAMPLER_BINDING
|
||||
glBindSampler(0, last_sampler);
|
||||
#endif
|
||||
glActiveTexture(last_active_texture);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glBindVertexArray(last_vertex_array_object);
|
||||
#endif
|
||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||
glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
|
||||
glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
|
||||
if (last_enable_blend) glEnable(GL_BLEND); else glDisable(GL_BLEND);
|
||||
if (last_enable_cull_face) glEnable(GL_CULL_FACE); else glDisable(GL_CULL_FACE);
|
||||
if (last_enable_depth_test) glEnable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
|
||||
if (last_enable_scissor_test) glEnable(GL_SCISSOR_TEST); else glDisable(GL_SCISSOR_TEST);
|
||||
#ifdef GL_POLYGON_MODE
|
||||
glPolygonMode(GL_FRONT_AND_BACK, (GLenum)last_polygon_mode[0]);
|
||||
#endif
|
||||
glViewport(last_viewport[0], last_viewport[1], (GLsizei)last_viewport[2], (GLsizei)last_viewport[3]);
|
||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL3_CreateFontsTexture()
|
||||
{
|
||||
// Build texture atlas
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
unsigned char* pixels;
|
||||
int width, height;
|
||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
|
||||
|
||||
// Upload texture to graphics system
|
||||
GLint last_texture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||
glGenTextures(1, &g_FontTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, g_FontTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
#ifdef GL_UNPACK_ROW_LENGTH
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
||||
|
||||
// Store our identifier
|
||||
io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture;
|
||||
|
||||
// Restore state
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_DestroyFontsTexture()
|
||||
{
|
||||
if (g_FontTexture)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
glDeleteTextures(1, &g_FontTexture);
|
||||
io.Fonts->TexID = 0;
|
||||
g_FontTexture = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// If you get an error please report on github. You may try different GL context version or GLSL version. See GL<>GLSL version table at the top of this file.
|
||||
static bool CheckShader(GLuint handle, const char* desc)
|
||||
{
|
||||
GLint status = 0, log_length = 0;
|
||||
glGetShaderiv(handle, GL_COMPILE_STATUS, &status);
|
||||
glGetShaderiv(handle, GL_INFO_LOG_LENGTH, &log_length);
|
||||
if ((GLboolean)status == GL_FALSE)
|
||||
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to compile %s!\n", desc);
|
||||
if (log_length > 1)
|
||||
{
|
||||
ImVector<char> buf;
|
||||
buf.resize((int)(log_length + 1));
|
||||
glGetShaderInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
|
||||
fprintf(stderr, "%s\n", buf.begin());
|
||||
}
|
||||
return (GLboolean)status == GL_TRUE;
|
||||
}
|
||||
|
||||
// If you get an error please report on GitHub. You may try different GL context version or GLSL version.
|
||||
static bool CheckProgram(GLuint handle, const char* desc)
|
||||
{
|
||||
GLint status = 0, log_length = 0;
|
||||
glGetProgramiv(handle, GL_LINK_STATUS, &status);
|
||||
glGetProgramiv(handle, GL_INFO_LOG_LENGTH, &log_length);
|
||||
if ((GLboolean)status == GL_FALSE)
|
||||
fprintf(stderr, "ERROR: ImGui_ImplOpenGL3_CreateDeviceObjects: failed to link %s! (with GLSL '%s')\n", desc, g_GlslVersionString);
|
||||
if (log_length > 1)
|
||||
{
|
||||
ImVector<char> buf;
|
||||
buf.resize((int)(log_length + 1));
|
||||
glGetProgramInfoLog(handle, log_length, NULL, (GLchar*)buf.begin());
|
||||
fprintf(stderr, "%s\n", buf.begin());
|
||||
}
|
||||
return (GLboolean)status == GL_TRUE;
|
||||
}
|
||||
|
||||
bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
||||
{
|
||||
// Backup GL state
|
||||
GLint last_texture, last_array_buffer;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
|
||||
glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
GLint last_vertex_array;
|
||||
glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
|
||||
#endif
|
||||
|
||||
// Parse GLSL version string
|
||||
int glsl_version = 130;
|
||||
sscanf(g_GlslVersionString, "#version %d", &glsl_version);
|
||||
|
||||
const GLchar* vertex_shader_glsl_120 =
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"attribute vec2 Position;\n"
|
||||
"attribute vec2 UV;\n"
|
||||
"attribute vec4 Color;\n"
|
||||
"varying vec2 Frag_UV;\n"
|
||||
"varying vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_130 =
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"in vec2 Position;\n"
|
||||
"in vec2 UV;\n"
|
||||
"in vec4 Color;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_300_es =
|
||||
"precision mediump float;\n"
|
||||
"layout (location = 0) in vec2 Position;\n"
|
||||
"layout (location = 1) in vec2 UV;\n"
|
||||
"layout (location = 2) in vec4 Color;\n"
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* vertex_shader_glsl_410_core =
|
||||
"layout (location = 0) in vec2 Position;\n"
|
||||
"layout (location = 1) in vec2 UV;\n"
|
||||
"layout (location = 2) in vec4 Color;\n"
|
||||
"uniform mat4 ProjMtx;\n"
|
||||
"out vec2 Frag_UV;\n"
|
||||
"out vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Frag_UV = UV;\n"
|
||||
" Frag_Color = Color;\n"
|
||||
" gl_Position = ProjMtx * vec4(Position.xy,0,1);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_120 =
|
||||
"#ifdef GL_ES\n"
|
||||
" precision mediump float;\n"
|
||||
"#endif\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"varying vec2 Frag_UV;\n"
|
||||
"varying vec4 Frag_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_130 =
|
||||
"uniform sampler2D Texture;\n"
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_300_es =
|
||||
"precision mediump float;\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"layout (location = 0) out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
const GLchar* fragment_shader_glsl_410_core =
|
||||
"in vec2 Frag_UV;\n"
|
||||
"in vec4 Frag_Color;\n"
|
||||
"uniform sampler2D Texture;\n"
|
||||
"layout (location = 0) out vec4 Out_Color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
|
||||
"}\n";
|
||||
|
||||
// Select shaders matching our GLSL versions
|
||||
const GLchar* vertex_shader = NULL;
|
||||
const GLchar* fragment_shader = NULL;
|
||||
if (glsl_version < 130)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_120;
|
||||
fragment_shader = fragment_shader_glsl_120;
|
||||
}
|
||||
else if (glsl_version >= 410)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_410_core;
|
||||
fragment_shader = fragment_shader_glsl_410_core;
|
||||
}
|
||||
else if (glsl_version == 300)
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_300_es;
|
||||
fragment_shader = fragment_shader_glsl_300_es;
|
||||
}
|
||||
else
|
||||
{
|
||||
vertex_shader = vertex_shader_glsl_130;
|
||||
fragment_shader = fragment_shader_glsl_130;
|
||||
}
|
||||
|
||||
// Create shaders
|
||||
const GLchar* vertex_shader_with_version[2] = { g_GlslVersionString, vertex_shader };
|
||||
g_VertHandle = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(g_VertHandle, 2, vertex_shader_with_version, NULL);
|
||||
glCompileShader(g_VertHandle);
|
||||
CheckShader(g_VertHandle, "vertex shader");
|
||||
|
||||
const GLchar* fragment_shader_with_version[2] = { g_GlslVersionString, fragment_shader };
|
||||
g_FragHandle = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(g_FragHandle, 2, fragment_shader_with_version, NULL);
|
||||
glCompileShader(g_FragHandle);
|
||||
CheckShader(g_FragHandle, "fragment shader");
|
||||
|
||||
g_ShaderHandle = glCreateProgram();
|
||||
glAttachShader(g_ShaderHandle, g_VertHandle);
|
||||
glAttachShader(g_ShaderHandle, g_FragHandle);
|
||||
glLinkProgram(g_ShaderHandle);
|
||||
CheckProgram(g_ShaderHandle, "shader program");
|
||||
|
||||
g_AttribLocationTex = glGetUniformLocation(g_ShaderHandle, "Texture");
|
||||
g_AttribLocationProjMtx = glGetUniformLocation(g_ShaderHandle, "ProjMtx");
|
||||
g_AttribLocationVtxPos = (GLuint)glGetAttribLocation(g_ShaderHandle, "Position");
|
||||
g_AttribLocationVtxUV = (GLuint)glGetAttribLocation(g_ShaderHandle, "UV");
|
||||
g_AttribLocationVtxColor = (GLuint)glGetAttribLocation(g_ShaderHandle, "Color");
|
||||
|
||||
// Create buffers
|
||||
glGenBuffers(1, &g_VboHandle);
|
||||
glGenBuffers(1, &g_ElementsHandle);
|
||||
|
||||
ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||
|
||||
// Restore modified GL state
|
||||
glBindTexture(GL_TEXTURE_2D, last_texture);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
|
||||
#ifndef IMGUI_IMPL_OPENGL_ES2
|
||||
glBindVertexArray(last_vertex_array);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
||||
{
|
||||
if (g_VboHandle) { glDeleteBuffers(1, &g_VboHandle); g_VboHandle = 0; }
|
||||
if (g_ElementsHandle) { glDeleteBuffers(1, &g_ElementsHandle); g_ElementsHandle = 0; }
|
||||
if (g_ShaderHandle && g_VertHandle) { glDetachShader(g_ShaderHandle, g_VertHandle); }
|
||||
if (g_ShaderHandle && g_FragHandle) { glDetachShader(g_ShaderHandle, g_FragHandle); }
|
||||
if (g_VertHandle) { glDeleteShader(g_VertHandle); g_VertHandle = 0; }
|
||||
if (g_FragHandle) { glDeleteShader(g_FragHandle); g_FragHandle = 0; }
|
||||
if (g_ShaderHandle) { glDeleteProgram(g_ShaderHandle); g_ShaderHandle = 0; }
|
||||
|
||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||
}
|
84
DoConfig/imgui/imgui_impl_opengl3.h
Normal file
|
@ -0,0 +1,84 @@
|
|||
// dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline
|
||||
// - Desktop GL: 2.x 3.x 4.x
|
||||
// - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0)
|
||||
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// About Desktop OpenGL function loaders:
|
||||
// Modern Desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
|
||||
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
|
||||
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
|
||||
|
||||
// About GLSL version:
|
||||
// The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string.
|
||||
// On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es"
|
||||
// Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp.
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
|
||||
// Backend API
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL);
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data);
|
||||
|
||||
// (Optional) Called by Init/NewFrame/Shutdown
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||
IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||
IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects();
|
||||
|
||||
// Specific OpenGL ES versions
|
||||
//#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten
|
||||
//#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android
|
||||
|
||||
// Attempt to auto-detect the default Desktop GL loader based on available header files.
|
||||
// If auto-detection fails or doesn't select the same GL loader file as used by your application,
|
||||
// you are likely to get a crash in ImGui_ImplOpenGL3_Init().
|
||||
// You can explicitly select a loader by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line.
|
||||
#if !defined(IMGUI_IMPL_OPENGL_ES2) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_ES3) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3) \
|
||||
&& !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM)
|
||||
|
||||
// Try to detect GLES on matching platforms
|
||||
#if defined(__APPLE__)
|
||||
#include "TargetConditionals.h"
|
||||
#endif
|
||||
#if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__))
|
||||
#define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es"
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100"
|
||||
|
||||
// Otherwise try to detect supported Desktop OpenGL loaders..
|
||||
#elif defined(__has_include)
|
||||
#if __has_include(<GL/glew.h>)
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GLEW
|
||||
#elif __has_include(<glad/glad.h>)
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GLAD
|
||||
#elif __has_include(<GL/gl3w.h>)
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GL3W
|
||||
#elif __has_include(<glbinding/glbinding.h>)
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING3
|
||||
#elif __has_include(<glbinding/Binding.h>)
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GLBINDING2
|
||||
#else
|
||||
#error "Cannot detect OpenGL loader!"
|
||||
#endif
|
||||
#else
|
||||
#define IMGUI_IMPL_OPENGL_LOADER_GL3W // Default to GL3W embedded in our repository
|
||||
#endif
|
||||
|
||||
#endif
|
2377
DoConfig/imgui/imgui_internal.h
Normal file
10482
DoConfig/imgui/imgui_widgets.cpp
Normal file
639
DoConfig/imgui/imstb_rectpack.h
Normal file
|
@ -0,0 +1,639 @@
|
|||
// [DEAR IMGUI]
|
||||
// This is a slightly modified version of stb_rect_pack.h 1.00.
|
||||
// Those changes would need to be pushed into nothings/stb:
|
||||
// - Added STBRP__CDECL
|
||||
// Grep for [DEAR IMGUI] to find the changes.
|
||||
|
||||
// stb_rect_pack.h - v1.00 - public domain - rectangle packing
|
||||
// Sean Barrett 2014
|
||||
//
|
||||
// Useful for e.g. packing rectangular textures into an atlas.
|
||||
// Does not do rotation.
|
||||
//
|
||||
// Not necessarily the awesomest packing method, but better than
|
||||
// the totally naive one in stb_truetype (which is primarily what
|
||||
// this is meant to replace).
|
||||
//
|
||||
// Has only had a few tests run, may have issues.
|
||||
//
|
||||
// More docs to come.
|
||||
//
|
||||
// No memory allocations; uses qsort() and assert() from stdlib.
|
||||
// Can override those by defining STBRP_SORT and STBRP_ASSERT.
|
||||
//
|
||||
// This library currently uses the Skyline Bottom-Left algorithm.
|
||||
//
|
||||
// Please note: better rectangle packers are welcome! Please
|
||||
// implement them to the same API, but with a different init
|
||||
// function.
|
||||
//
|
||||
// Credits
|
||||
//
|
||||
// Library
|
||||
// Sean Barrett
|
||||
// Minor features
|
||||
// Martins Mozeiko
|
||||
// github:IntellectualKitty
|
||||
//
|
||||
// Bugfixes / warning fixes
|
||||
// Jeremy Jaussaud
|
||||
// Fabian Giesen
|
||||
//
|
||||
// Version history:
|
||||
//
|
||||
// 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles
|
||||
// 0.99 (2019-02-07) warning fixes
|
||||
// 0.11 (2017-03-03) return packing success/fail result
|
||||
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
|
||||
// 0.09 (2016-08-27) fix compiler warnings
|
||||
// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
|
||||
// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)
|
||||
// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
|
||||
// 0.05: added STBRP_ASSERT to allow replacing assert
|
||||
// 0.04: fixed minor bug in STBRP_LARGE_RECTS support
|
||||
// 0.01: initial release
|
||||
//
|
||||
// LICENSE
|
||||
//
|
||||
// See end of file for license information.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// INCLUDE SECTION
|
||||
//
|
||||
|
||||
#ifndef STB_INCLUDE_STB_RECT_PACK_H
|
||||
#define STB_INCLUDE_STB_RECT_PACK_H
|
||||
|
||||
#define STB_RECT_PACK_VERSION 1
|
||||
|
||||
#ifdef STBRP_STATIC
|
||||
#define STBRP_DEF static
|
||||
#else
|
||||
#define STBRP_DEF extern
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct stbrp_context stbrp_context;
|
||||
typedef struct stbrp_node stbrp_node;
|
||||
typedef struct stbrp_rect stbrp_rect;
|
||||
|
||||
#ifdef STBRP_LARGE_RECTS
|
||||
typedef int stbrp_coord;
|
||||
#else
|
||||
typedef unsigned short stbrp_coord;
|
||||
#endif
|
||||
|
||||
STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
|
||||
// Assign packed locations to rectangles. The rectangles are of type
|
||||
// 'stbrp_rect' defined below, stored in the array 'rects', and there
|
||||
// are 'num_rects' many of them.
|
||||
//
|
||||
// Rectangles which are successfully packed have the 'was_packed' flag
|
||||
// set to a non-zero value and 'x' and 'y' store the minimum location
|
||||
// on each axis (i.e. bottom-left in cartesian coordinates, top-left
|
||||
// if you imagine y increasing downwards). Rectangles which do not fit
|
||||
// have the 'was_packed' flag set to 0.
|
||||
//
|
||||
// You should not try to access the 'rects' array from another thread
|
||||
// while this function is running, as the function temporarily reorders
|
||||
// the array while it executes.
|
||||
//
|
||||
// To pack into another rectangle, you need to call stbrp_init_target
|
||||
// again. To continue packing into the same rectangle, you can call
|
||||
// this function again. Calling this multiple times with multiple rect
|
||||
// arrays will probably produce worse packing results than calling it
|
||||
// a single time with the full rectangle array, but the option is
|
||||
// available.
|
||||
//
|
||||
// The function returns 1 if all of the rectangles were successfully
|
||||
// packed and 0 otherwise.
|
||||
|
||||
struct stbrp_rect
|
||||
{
|
||||
// reserved for your use:
|
||||
int id;
|
||||
|
||||
// input:
|
||||
stbrp_coord w, h;
|
||||
|
||||
// output:
|
||||
stbrp_coord x, y;
|
||||
int was_packed; // non-zero if valid packing
|
||||
|
||||
}; // 16 bytes, nominally
|
||||
|
||||
|
||||
STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes);
|
||||
// Initialize a rectangle packer to:
|
||||
// pack a rectangle that is 'width' by 'height' in dimensions
|
||||
// using temporary storage provided by the array 'nodes', which is 'num_nodes' long
|
||||
//
|
||||
// You must call this function every time you start packing into a new target.
|
||||
//
|
||||
// There is no "shutdown" function. The 'nodes' memory must stay valid for
|
||||
// the following stbrp_pack_rects() call (or calls), but can be freed after
|
||||
// the call (or calls) finish.
|
||||
//
|
||||
// Note: to guarantee best results, either:
|
||||
// 1. make sure 'num_nodes' >= 'width'
|
||||
// or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
|
||||
//
|
||||
// If you don't do either of the above things, widths will be quantized to multiples
|
||||
// of small integers to guarantee the algorithm doesn't run out of temporary storage.
|
||||
//
|
||||
// If you do #2, then the non-quantized algorithm will be used, but the algorithm
|
||||
// may run out of temporary storage and be unable to pack some rectangles.
|
||||
|
||||
STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
|
||||
// Optionally call this function after init but before doing any packing to
|
||||
// change the handling of the out-of-temp-memory scenario, described above.
|
||||
// If you call init again, this will be reset to the default (false).
|
||||
|
||||
|
||||
STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
|
||||
// Optionally select which packing heuristic the library should use. Different
|
||||
// heuristics will produce better/worse results for different data sets.
|
||||
// If you call init again, this will be reset to the default.
|
||||
|
||||
enum
|
||||
{
|
||||
STBRP_HEURISTIC_Skyline_default=0,
|
||||
STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
|
||||
STBRP_HEURISTIC_Skyline_BF_sortHeight
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// the details of the following structures don't matter to you, but they must
|
||||
// be visible so you can handle the memory allocations for them
|
||||
|
||||
struct stbrp_node
|
||||
{
|
||||
stbrp_coord x,y;
|
||||
stbrp_node *next;
|
||||
};
|
||||
|
||||
struct stbrp_context
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int align;
|
||||
int init_mode;
|
||||
int heuristic;
|
||||
int num_nodes;
|
||||
stbrp_node *active_head;
|
||||
stbrp_node *free_head;
|
||||
stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPLEMENTATION SECTION
|
||||
//
|
||||
|
||||
#ifdef STB_RECT_PACK_IMPLEMENTATION
|
||||
#ifndef STBRP_SORT
|
||||
#include <stdlib.h>
|
||||
#define STBRP_SORT qsort
|
||||
#endif
|
||||
|
||||
#ifndef STBRP_ASSERT
|
||||
#include <assert.h>
|
||||
#define STBRP_ASSERT assert
|
||||
#endif
|
||||
|
||||
// [DEAR IMGUI] Added STBRP__CDECL
|
||||
#ifdef _MSC_VER
|
||||
#define STBRP__NOTUSED(v) (void)(v)
|
||||
#define STBRP__CDECL __cdecl
|
||||
#else
|
||||
#define STBRP__NOTUSED(v) (void)sizeof(v)
|
||||
#define STBRP__CDECL
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
STBRP__INIT_skyline = 1
|
||||
};
|
||||
|
||||
STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
|
||||
{
|
||||
switch (context->init_mode) {
|
||||
case STBRP__INIT_skyline:
|
||||
STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
|
||||
context->heuristic = heuristic;
|
||||
break;
|
||||
default:
|
||||
STBRP_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
|
||||
{
|
||||
if (allow_out_of_mem)
|
||||
// if it's ok to run out of memory, then don't bother aligning them;
|
||||
// this gives better packing, but may fail due to OOM (even though
|
||||
// the rectangles easily fit). @TODO a smarter approach would be to only
|
||||
// quantize once we've hit OOM, then we could get rid of this parameter.
|
||||
context->align = 1;
|
||||
else {
|
||||
// if it's not ok to run out of memory, then quantize the widths
|
||||
// so that num_nodes is always enough nodes.
|
||||
//
|
||||
// I.e. num_nodes * align >= width
|
||||
// align >= width / num_nodes
|
||||
// align = ceil(width/num_nodes)
|
||||
|
||||
context->align = (context->width + context->num_nodes-1) / context->num_nodes;
|
||||
}
|
||||
}
|
||||
|
||||
STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes)
|
||||
{
|
||||
int i;
|
||||
#ifndef STBRP_LARGE_RECTS
|
||||
STBRP_ASSERT(width <= 0xffff && height <= 0xffff);
|
||||
#endif
|
||||
|
||||
for (i=0; i < num_nodes-1; ++i)
|
||||
nodes[i].next = &nodes[i+1];
|
||||
nodes[i].next = NULL;
|
||||
context->init_mode = STBRP__INIT_skyline;
|
||||
context->heuristic = STBRP_HEURISTIC_Skyline_default;
|
||||
context->free_head = &nodes[0];
|
||||
context->active_head = &context->extra[0];
|
||||
context->width = width;
|
||||
context->height = height;
|
||||
context->num_nodes = num_nodes;
|
||||
stbrp_setup_allow_out_of_mem(context, 0);
|
||||
|
||||
// node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
|
||||
context->extra[0].x = 0;
|
||||
context->extra[0].y = 0;
|
||||
context->extra[0].next = &context->extra[1];
|
||||
context->extra[1].x = (stbrp_coord) width;
|
||||
#ifdef STBRP_LARGE_RECTS
|
||||
context->extra[1].y = (1<<30);
|
||||
#else
|
||||
context->extra[1].y = 65535;
|
||||
#endif
|
||||
context->extra[1].next = NULL;
|
||||
}
|
||||
|
||||
// find minimum y position if it starts at x1
|
||||
static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
|
||||
{
|
||||
stbrp_node *node = first;
|
||||
int x1 = x0 + width;
|
||||
int min_y, visited_width, waste_area;
|
||||
|
||||
STBRP__NOTUSED(c);
|
||||
|
||||
STBRP_ASSERT(first->x <= x0);
|
||||
|
||||
#if 0
|
||||
// skip in case we're past the node
|
||||
while (node->next->x <= x0)
|
||||
++node;
|
||||
#else
|
||||
STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
|
||||
#endif
|
||||
|
||||
STBRP_ASSERT(node->x <= x0);
|
||||
|
||||
min_y = 0;
|
||||
waste_area = 0;
|
||||
visited_width = 0;
|
||||
while (node->x < x1) {
|
||||
if (node->y > min_y) {
|
||||
// raise min_y higher.
|
||||
// we've accounted for all waste up to min_y,
|
||||
// but we'll now add more waste for everything we've visted
|
||||
waste_area += visited_width * (node->y - min_y);
|
||||
min_y = node->y;
|
||||
// the first time through, visited_width might be reduced
|
||||
if (node->x < x0)
|
||||
visited_width += node->next->x - x0;
|
||||
else
|
||||
visited_width += node->next->x - node->x;
|
||||
} else {
|
||||
// add waste area
|
||||
int under_width = node->next->x - node->x;
|
||||
if (under_width + visited_width > width)
|
||||
under_width = width - visited_width;
|
||||
waste_area += under_width * (min_y - node->y);
|
||||
visited_width += under_width;
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
*pwaste = waste_area;
|
||||
return min_y;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int x,y;
|
||||
stbrp_node **prev_link;
|
||||
} stbrp__findresult;
|
||||
|
||||
static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
|
||||
{
|
||||
int best_waste = (1<<30), best_x, best_y = (1 << 30);
|
||||
stbrp__findresult fr;
|
||||
stbrp_node **prev, *node, *tail, **best = NULL;
|
||||
|
||||
// align to multiple of c->align
|
||||
width = (width + c->align - 1);
|
||||
width -= width % c->align;
|
||||
STBRP_ASSERT(width % c->align == 0);
|
||||
|
||||
// if it can't possibly fit, bail immediately
|
||||
if (width > c->width || height > c->height) {
|
||||
fr.prev_link = NULL;
|
||||
fr.x = fr.y = 0;
|
||||
return fr;
|
||||
}
|
||||
|
||||
node = c->active_head;
|
||||
prev = &c->active_head;
|
||||
while (node->x + width <= c->width) {
|
||||
int y,waste;
|
||||
y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
|
||||
if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
|
||||
// bottom left
|
||||
if (y < best_y) {
|
||||
best_y = y;
|
||||
best = prev;
|
||||
}
|
||||
} else {
|
||||
// best-fit
|
||||
if (y + height <= c->height) {
|
||||
// can only use it if it first vertically
|
||||
if (y < best_y || (y == best_y && waste < best_waste)) {
|
||||
best_y = y;
|
||||
best_waste = waste;
|
||||
best = prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
prev = &node->next;
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
best_x = (best == NULL) ? 0 : (*best)->x;
|
||||
|
||||
// if doing best-fit (BF), we also have to try aligning right edge to each node position
|
||||
//
|
||||
// e.g, if fitting
|
||||
//
|
||||
// ____________________
|
||||
// |____________________|
|
||||
//
|
||||
// into
|
||||
//
|
||||
// | |
|
||||
// | ____________|
|
||||
// |____________|
|
||||
//
|
||||
// then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
|
||||
//
|
||||
// This makes BF take about 2x the time
|
||||
|
||||
if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
|
||||
tail = c->active_head;
|
||||
node = c->active_head;
|
||||
prev = &c->active_head;
|
||||
// find first node that's admissible
|
||||
while (tail->x < width)
|
||||
tail = tail->next;
|
||||
while (tail) {
|
||||
int xpos = tail->x - width;
|
||||
int y,waste;
|
||||
STBRP_ASSERT(xpos >= 0);
|
||||
// find the left position that matches this
|
||||
while (node->next->x <= xpos) {
|
||||
prev = &node->next;
|
||||
node = node->next;
|
||||
}
|
||||
STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
|
||||
y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
|
||||
if (y + height <= c->height) {
|
||||
if (y <= best_y) {
|
||||
if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
|
||||
best_x = xpos;
|
||||
STBRP_ASSERT(y <= best_y);
|
||||
best_y = y;
|
||||
best_waste = waste;
|
||||
best = prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
tail = tail->next;
|
||||
}
|
||||
}
|
||||
|
||||
fr.prev_link = best;
|
||||
fr.x = best_x;
|
||||
fr.y = best_y;
|
||||
return fr;
|
||||
}
|
||||
|
||||
static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
|
||||
{
|
||||
// find best position according to heuristic
|
||||
stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
|
||||
stbrp_node *node, *cur;
|
||||
|
||||
// bail if:
|
||||
// 1. it failed
|
||||
// 2. the best node doesn't fit (we don't always check this)
|
||||
// 3. we're out of memory
|
||||
if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
|
||||
res.prev_link = NULL;
|
||||
return res;
|
||||
}
|
||||
|
||||
// on success, create new node
|
||||
node = context->free_head;
|
||||
node->x = (stbrp_coord) res.x;
|
||||
node->y = (stbrp_coord) (res.y + height);
|
||||
|
||||
context->free_head = node->next;
|
||||
|
||||
// insert the new node into the right starting point, and
|
||||
// let 'cur' point to the remaining nodes needing to be
|
||||
// stiched back in
|
||||
|
||||
cur = *res.prev_link;
|
||||
if (cur->x < res.x) {
|
||||
// preserve the existing one, so start testing with the next one
|
||||
stbrp_node *next = cur->next;
|
||||
cur->next = node;
|
||||
cur = next;
|
||||
} else {
|
||||
*res.prev_link = node;
|
||||
}
|
||||
|
||||
// from here, traverse cur and free the nodes, until we get to one
|
||||
// that shouldn't be freed
|
||||
while (cur->next && cur->next->x <= res.x + width) {
|
||||
stbrp_node *next = cur->next;
|
||||
// move the current node to the free list
|
||||
cur->next = context->free_head;
|
||||
context->free_head = cur;
|
||||
cur = next;
|
||||
}
|
||||
|
||||
// stitch the list back in
|
||||
node->next = cur;
|
||||
|
||||
if (cur->x < res.x + width)
|
||||
cur->x = (stbrp_coord) (res.x + width);
|
||||
|
||||
#ifdef _DEBUG
|
||||
cur = context->active_head;
|
||||
while (cur->x < context->width) {
|
||||
STBRP_ASSERT(cur->x < cur->next->x);
|
||||
cur = cur->next;
|
||||
}
|
||||
STBRP_ASSERT(cur->next == NULL);
|
||||
|
||||
{
|
||||
int count=0;
|
||||
cur = context->active_head;
|
||||
while (cur) {
|
||||
cur = cur->next;
|
||||
++count;
|
||||
}
|
||||
cur = context->free_head;
|
||||
while (cur) {
|
||||
cur = cur->next;
|
||||
++count;
|
||||
}
|
||||
STBRP_ASSERT(count == context->num_nodes+2);
|
||||
}
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// [DEAR IMGUI] Added STBRP__CDECL
|
||||
static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
|
||||
{
|
||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||
const stbrp_rect *q = (const stbrp_rect *) b;
|
||||
if (p->h > q->h)
|
||||
return -1;
|
||||
if (p->h < q->h)
|
||||
return 1;
|
||||
return (p->w > q->w) ? -1 : (p->w < q->w);
|
||||
}
|
||||
|
||||
// [DEAR IMGUI] Added STBRP__CDECL
|
||||
static int STBRP__CDECL rect_original_order(const void *a, const void *b)
|
||||
{
|
||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||
const stbrp_rect *q = (const stbrp_rect *) b;
|
||||
return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
|
||||
}
|
||||
|
||||
#ifdef STBRP_LARGE_RECTS
|
||||
#define STBRP__MAXVAL 0xffffffff
|
||||
#else
|
||||
#define STBRP__MAXVAL 0xffff
|
||||
#endif
|
||||
|
||||
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
|
||||
{
|
||||
int i, all_rects_packed = 1;
|
||||
|
||||
// we use the 'was_packed' field internally to allow sorting/unsorting
|
||||
for (i=0; i < num_rects; ++i) {
|
||||
rects[i].was_packed = i;
|
||||
}
|
||||
|
||||
// sort according to heuristic
|
||||
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
|
||||
|
||||
for (i=0; i < num_rects; ++i) {
|
||||
if (rects[i].w == 0 || rects[i].h == 0) {
|
||||
rects[i].x = rects[i].y = 0; // empty rect needs no space
|
||||
} else {
|
||||
stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
|
||||
if (fr.prev_link) {
|
||||
rects[i].x = (stbrp_coord) fr.x;
|
||||
rects[i].y = (stbrp_coord) fr.y;
|
||||
} else {
|
||||
rects[i].x = rects[i].y = STBRP__MAXVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// unsort
|
||||
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
|
||||
|
||||
// set was_packed flags and all_rects_packed status
|
||||
for (i=0; i < num_rects; ++i) {
|
||||
rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
|
||||
if (!rects[i].was_packed)
|
||||
all_rects_packed = 0;
|
||||
}
|
||||
|
||||
// return the all_rects_packed status
|
||||
return all_rects_packed;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------------
|
||||
This software is available under 2 licenses -- choose whichever you prefer.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
------------------------------------------------------------------------------
|
||||
*/
|
1417
DoConfig/imgui/imstb_textedit.h
Normal file
4903
DoConfig/imgui/imstb_truetype.h
Normal file
32
LICENCE.txt
Normal file
|
@ -0,0 +1,32 @@
|
|||
THIS PROJECT CONTAINS PROPRIETARY CODE AND ASSETS.
|
||||
THIS IS NOT FREE/LIBRE SOFTWARE OR OPEN-SOURCE SOFTWARE.
|
||||
USE AT YOUR OWN RISK.
|
||||
|
||||
The original code and assets belongs to Daisuke "Pixel" Amaya.
|
||||
|
||||
Modifications and custom code are under the following licence:
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Regan "cuckydev" Green
|
||||
Copyright (c) 2019-2020 Clownacy
|
||||
Copyright (c) 2019-2020 Gabriel Ravier
|
||||
Copyright (c) 2020 Cameron Cawley
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
68
PHILOSOPHY.md
Normal file
|
@ -0,0 +1,68 @@
|
|||
# `accurate` branch
|
||||
Being a pure, plain decompilation of the original `Doukutsu.exe` file (v1.0.0.6),
|
||||
there should not be much to say about this branch's philosophies:
|
||||
|
||||
## Goal
|
||||
The end-goal is for the project to be able to produce an `.exe` file that is
|
||||
identical to the original. This means that there should be no custom code,
|
||||
decompiled code should ideally be made to produce the same assembly code as the
|
||||
original, bugs should be left intact, etc.
|
||||
|
||||
Another goal of the project is to document Cave Story's inner-working, so code
|
||||
should be reasonably-annotated. Likewise, bugs should be documented, and fixes
|
||||
provided wrapped in `#ifdef FIX_BUGS` conditions.
|
||||
|
||||
## Accuracy to the original source code
|
||||
Personally, I do aim to make the decompiled code _functionally_-accurate to the
|
||||
original, down to generating the same assembly code, but I do not aim for
|
||||
_visually_-accurate code.
|
||||
|
||||
Despite this, I do try to preserve the original function/variable names,
|
||||
variable-declaration locations, and source file naming.
|
||||
|
||||
Part of the reason why I do not aim for visually-accurate source code is that we
|
||||
know from the [Organya source code release](https://github.com/shbow/organya/)
|
||||
what Pixel's code-style looked like, and I find it **extremely** hard to read.
|
||||
|
||||
## Language
|
||||
Cave Story's developer (Pixel) primarily speaks Japanese, but his code's
|
||||
variable/function names are mostly written in English (with a few rare instances
|
||||
of Romanised Japanese).
|
||||
|
||||
The Organya source code release indicates that Pixel wrote his comments in
|
||||
Japanese, however, in this project, I prefer them to be written in English.
|
||||
|
||||
The English employed in this project is a mix of American English, Canadian
|
||||
English, and British English.
|
||||
|
||||
|
||||
|
||||
# `portable` branch
|
||||
This branch takes a different direction to the `accurate` branch, but they still
|
||||
share many core philosophies:
|
||||
|
||||
## Goal
|
||||
While accurately-reproducing Cave Story's original code is still a priority, the
|
||||
main focus of this branch is to port the game to other platforms, while also
|
||||
preserving the game the way it was experienced back in 2004.
|
||||
|
||||
Essentially, this branch exists to provide a purist Cave Story experience
|
||||
without requiring an old Windows XP computer.
|
||||
|
||||
Notably, this means that bugs should still be left intact. However, bugs and
|
||||
other coding errors that affect portability should be fixed.
|
||||
|
||||
For comparison, I believe this branch shares many parallels with the
|
||||
Chocolate Doom project. Follow the link below to see that project's list of
|
||||
philosophies, which may be applicable here:
|
||||
|
||||
https://github.com/chocolate-doom/chocolate-doom/blob/master/PHILOSOPHY.md
|
||||
|
||||
## Custom code
|
||||
Cave Story's original source code was written in C++, but stylised like C89
|
||||
(with a number of exceptions). Custom code added to the project should follow
|
||||
suit, but the C-style doesn't have to be C89 - personally, I prefer to write in
|
||||
the subset of C99 that C++98 allows.
|
||||
|
||||
I prefer compiler-specific code to be avoided, since more-portable code benefits
|
||||
all compilers, and keeps the codebase free of clutter.
|
225
README.md
Normal file
|
@ -0,0 +1,225 @@
|
|||
[![Build Status](https://travis-ci.com/Clownacy/CSE2.svg?branch=portable)](https://travis-ci.com/Clownacy/CSE2)
|
||||
|
||||
## Table of Contents
|
||||
|
||||
This repo has two main branches:
|
||||
|
||||
Branch | Description
|
||||
--------|--------
|
||||
[accurate](https://www.github.com/Clownacy/CSE2/tree/accurate) | The main decompilation branch. The code is intended to be as close to the original as possible, down to all the bugs and platform-dependencies.
|
||||
[portable](https://www.github.com/Clownacy/CSE2/tree/portable) | This branch ports the engine away from WinAPI and DirectX, and addresses numerous portability issues, allowing it to run on other platforms.
|
||||
|
||||
# CSE2 (Portable)
|
||||
|
||||
CSE2 is a decompilation of Cave Story.
|
||||
|
||||
This branch migrates the engine away from WinAPI and DirectX, and addresses
|
||||
numerous portability issues, allowing it to run on other platforms.
|
||||
|
||||
Supported platforms include...
|
||||
* Windows
|
||||
* Linux
|
||||
* macOS
|
||||
* Wii U
|
||||
* 3DS
|
||||
* RISC OS
|
||||
|
||||
![Screenshot](images/screenshot.png)
|
||||
|
||||
## Background
|
||||
|
||||
When Pixel made Cave Story, he compiled the original Windows EXE with no
|
||||
optimisations. This left the generated assembly code extremely verbose and easy
|
||||
to read. It also made the code very decompiler-friendly, since the assembly
|
||||
could be mapped directly back to the original C++ code.
|
||||
|
||||
Technically, this alone made a decompilation feasible, as was the case for [the
|
||||
Super Mario 64 decompilation project](https://github.com/n64decomp/sm64) -
|
||||
however, there was more to be found...
|
||||
|
||||
In 2007, a Linux port of Cave Story was made by Simon Parzer and Peter Mackay.
|
||||
Details about it can be found on [Peter's old blog](https://web.archive.org/web/20070911202919/http://aaiiee.wordpress.com:80/).
|
||||
This port received an update in 2011, including two shiny new executables. What
|
||||
they didn't realise was that they left huge amounts of debugging information in
|
||||
these executables, including the names of every C++ source file, as well as the
|
||||
variables, functions, and structs they contained.
|
||||
|
||||
This was a goldmine of information about not just the game's inner-workings, but
|
||||
its _source code._ This is the same lucky-break [the Diablo decompilation project](https://github.com/diasurgical/devilution)
|
||||
had. With it, much of the game's code was pre-documented and explained, saving
|
||||
us the effort of doing it ourselves. In fact, the combination of
|
||||
easy-to-decompile code, and a near-full set of function/variable names, reduced
|
||||
much of the decompilation process to mere copy-paste.
|
||||
|
||||
To top it all off, some of Cave Story's original source code would eventually
|
||||
see the light of day:
|
||||
|
||||
In early 2018, the Organya music engine was [released on GitHub](https://github.com/shbow/organya)
|
||||
by an old friend of Pixel's. On top of providing an insight into Pixel's coding
|
||||
style, this helped with figuring out one of the most complex parts of Cave
|
||||
Story's codebase.
|
||||
|
||||
And... that's it! It's not often that a game this decompilable comes along, so
|
||||
I'm glad that Cave Story was one of them. [Patching a dusty old executable from 2005 sucks](https://github.com/Clownacy/Cave-Story-Mod-Loader/blob/master/src/mods/graphics_enhancement/widescreen/patch_camera.c).
|
||||
|
||||
## Dependencies
|
||||
|
||||
* SDL2 (if `BACKEND_AUDIO` or `BACKEND_PLATFORM` are set to `SDL2`)
|
||||
* SDL (if `BACKEND_AUDIO` or `BACKEND_PLATFORM` are set to `SDL1`)
|
||||
* GLFW3 (if `BACKEND_PLATFORM` is set to `GLFW3`)
|
||||
* FreeType (if `FREETYPE_FONTS` is enabled)
|
||||
|
||||
If these are not found, they will be built locally (with the exception of SDL).
|
||||
|
||||
In addition, `pkg-config` is required for builds that require static-linkage.
|
||||
|
||||
A list of dependencies for specific platforms can be found [on the wiki](https://github.com/Clownacy/CSE2/wiki/Dependency-lists).
|
||||
|
||||
## Building
|
||||
|
||||
This project uses CMake, allowing it to be built with a range of compilers.
|
||||
|
||||
(A beginner-friendly guide can be found in [VISUAL_STUDIO_2019_GUIDE.md](VISUAL_STUDIO_2019_GUIDE.md))
|
||||
|
||||
Switch to the terminal (Visual Studio users should open the [Developer Command Prompt](https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs))
|
||||
and `cd` into this folder. After that, generate the files for your build system
|
||||
with:
|
||||
|
||||
```
|
||||
cmake -B build -DCMAKE_BUILD_TYPE=Release
|
||||
```
|
||||
|
||||
MSYS2 users should append `-G"MSYS Makefiles" -DPKG_CONFIG_STATIC_LIBS=ON` to
|
||||
this command, also.
|
||||
|
||||
You can also add the following flags:
|
||||
|
||||
Name | Function
|
||||
--------|--------
|
||||
`-DJAPANESE=ON` | Enable the Japanese-language build (instead of the unofficial Aeon Genesis English translation)
|
||||
`-DFIX_BUGS=ON` | Fix various bugs in the game
|
||||
`-DDEBUG_SAVE=ON` | Re-enable the ability to drag-and-drop save files onto the window
|
||||
`-DDOCONFIG=OFF` | Disable compiling the DoConfig tool (it is not useful for console ports)
|
||||
`-DDOCONFIG_LEGACY_OPENGL=ON` | Make DoConfig use OpenGL 2.1 instead of OpenGL 3.2 (useful for older/limited platforms)
|
||||
`-DLANCZOS_RESAMPLER=ON` | Use Lanczos filtering for audio resampling instead of linear-interpolation (Lanczos is more performance-intensive, but higher quality)
|
||||
`-DFREETYPE_FONTS=ON` | Use FreeType2 to render the DejaVu Mono (English) or Migu1M (Japanese) fonts, instead of using pre-rendered copies of Courier New (English) and MS Gothic (Japanese)
|
||||
`-DBACKEND_RENDERER=OpenGL3` | Render with OpenGL 3.2 (hardware-accelerated)
|
||||
`-DBACKEND_RENDERER=OpenGLES2` | Render with OpenGL ES 2.0 (hardware-accelerated)
|
||||
`-DBACKEND_RENDERER=SDLTexture` | (Default) Render with SDL2's Texture API (hardware-accelerated) (note: requires `-DBACKEND_PLATFORM=SDL2`)
|
||||
`-DBACKEND_RENDERER=SDLSurface` | Render with SDL2's Surface API (software-rendered) (note: requires `-DBACKEND_PLATFORM=SDL2`)
|
||||
`-DBACKEND_RENDERER=WiiU` | Render with the Wii U's GX2 API (hardware-accelerated)
|
||||
`-DBACKEND_RENDERER=3DS` | Render with the 3DS's Citro2D/Citro3D API (hardware-accelerated)
|
||||
`-DBACKEND_RENDERER=Software` | Render with a handwritten software-renderer
|
||||
`-DBACKEND_AUDIO=SDL2` | (Default) Deliver audio with SDL2 (software-mixer)
|
||||
`-DBACKEND_AUDIO=miniaudio` | Deliver audio with miniaudio (software-mixer)
|
||||
`-DBACKEND_AUDIO=WiiU-Hardware` | Deliver audio with Wii U's AXVoice API (hardware-accelerated) (WARNING - currently broken: voices randomly disappear for unknown reasons)
|
||||
`-DBACKEND_AUDIO=WiiU-Software` | Deliver audio with Wii U's AXVoice API (software-mixer)
|
||||
`-DBACKEND_AUDIO=3DS-Hardware` | Deliver audio with 3DS's NDSP API (hardware-accelerated)
|
||||
`-DBACKEND_AUDIO=3DS-Software` | Deliver audio with 3DS's NDSP API (software-mixer)
|
||||
`-DBACKEND_AUDIO=Null` | Don't deliver audio at all (WARNING - game will have no audio)
|
||||
`-DBACKEND_PLATFORM=SDL2` | (Default) Use SDL2 for miscellaneous platform-dependant operations
|
||||
`-DBACKEND_PLATFORM=GLFW3` | Use GLFW3 for miscellaneous platform-dependant operations
|
||||
`-DBACKEND_PLATFORM=WiiU` | Use the Wii U's native APIs for miscellaneous platform-dependant operations
|
||||
`-DBACKEND_PLATFORM=3DS` | Use the 3DS's native APIs for miscellaneous platform-dependant operations
|
||||
`-DBACKEND_PLATFORM=Null` | Don't do platform-dependant operations at all (WARNING - game will have no video or input)
|
||||
`-DLTO=ON` | Enable link-time optimisation
|
||||
`-DPKG_CONFIG_STATIC_LIBS=ON` | On platforms with pkg-config, static-link the dependencies (good for Windows builds, so you don't need to bundle DLL files)
|
||||
`-DMSVC_LINK_STATIC_RUNTIME=ON` | Link the static MSVC runtime library, to reduce the number of required DLL files (Visual Studio only)
|
||||
`-DFORCE_LOCAL_LIBS=ON` | Compile the built-in versions of SDL2, GLFW3, and FreeType instead of using the system-provided ones
|
||||
|
||||
You can pass your own compiler flags with `-DCMAKE_C_FLAGS` and `-DCMAKE_CXX_FLAGS`.
|
||||
|
||||
You can then compile CSE2 with this command:
|
||||
|
||||
```
|
||||
cmake --build build --config Release
|
||||
```
|
||||
|
||||
If you're a Visual Studio user, you can open the generated `CSE2.sln` file
|
||||
instead, which can be found in the `build` folder.
|
||||
|
||||
Once built, the executables can be found in the `game_english`/`game_japanese`
|
||||
folder, depending on the selected language.
|
||||
|
||||
### Building for the Wii U
|
||||
|
||||
To target the Wii U, you'll need devkitPro, devkitPPC, and WUT.
|
||||
|
||||
First, add the devkitPPC tools directory to your PATH (because WUT's CMake
|
||||
support is broken, as of writing):
|
||||
|
||||
```
|
||||
PATH=$PATH:$DEVKITPPC/bin
|
||||
```
|
||||
|
||||
Then, generate the build files with this command:
|
||||
|
||||
```
|
||||
cmake -B buildwiiu -DCMAKE_BUILD_TYPE=Release -DFORCE_LOCAL_LIBS=ON -DBACKEND_PLATFORM=WiiU -DBACKEND_RENDERER=WiiU -DBACKEND_AUDIO=WiiU-Software -DDOCONFIG=OFF -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/wut/share/wut.toolchain.cmake
|
||||
```
|
||||
|
||||
Finally, build the game with this command:
|
||||
|
||||
```
|
||||
cmake --build buildwiiu
|
||||
```
|
||||
|
||||
This will build a binary, but you still need to convert it to an `.rpx` file
|
||||
that can be ran on your Wii U.
|
||||
|
||||
First, we need to strip the binary:
|
||||
|
||||
```
|
||||
powerpc-eabi-strip -g game_english/CSE2
|
||||
```
|
||||
|
||||
Then, we convert it to an `.rpx`:
|
||||
```
|
||||
elf2rpl game_english/CSE2 game_english/CSE2.rpx
|
||||
```
|
||||
|
||||
`game_english/CSE2.rpx` is now ready to be ran on your Wii U. This port expects
|
||||
the data folder to be in a folder called `CSE2-portable-en`/`CSE2-portable-jp`
|
||||
on the root of your SD card.
|
||||
|
||||
### Building for the 3DS
|
||||
|
||||
To target the 3DS, you'll need devkitPro, devkitARM, Citro2D, Citro3D, libctru,
|
||||
and bannertool, along with the `3dstools` and `devkitpro-pkgbuild-helpers`
|
||||
packages.
|
||||
|
||||
Open a terminal, and `cd` into the CSE2 directory. Then execute this command:
|
||||
|
||||
```
|
||||
cmake -B build3ds -DCMAKE_BUILD_TYPE=Release -DFORCE_LOCAL_LIBS=ON -DBACKEND_PLATFORM=3DS -DBACKEND_RENDERER=3DS -DBACKEND_AUDIO=3DS-Hardware -DDOCONFIG=OFF -DFREETYPE_FONTS=ON -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/3ds.cmake
|
||||
```
|
||||
|
||||
(Note that `FREETYPE_FONTS` is enabled. If you're creating a Japanese build,
|
||||
it's best to disable this, as the FreeType font is unreadable at 320x240).
|
||||
|
||||
This will create the build files. To build CSE2, run:
|
||||
|
||||
```
|
||||
cmake --build build3ds
|
||||
```
|
||||
|
||||
This will create an elf file. Before we can create a `.3dsx` file from it, we
|
||||
need to make an `.smdh` file:
|
||||
|
||||
```
|
||||
bannertool makesmdh -i $DEVKITPRO/libctru/default_icon.png -s "CSE2" -l "Port of Cave Story" -p "Clownacy" -o build3ds/smdh.smdh
|
||||
```
|
||||
|
||||
We can finally generate a `.3dsx` file:
|
||||
|
||||
```
|
||||
3dsxtool game_english/CSE2 game_english/CSE2.3dsx --romfs=game_english/data --smdh=build3ds/smdh.smdh
|
||||
```
|
||||
|
||||
## Licensing
|
||||
|
||||
Being a decompilation, the majority of the code in this project is proprietary
|
||||
and belongs to Daisuke "Pixel" Amaya.
|
||||
|
||||
Modifications and custom code are made available under the MIT licence. See
|
||||
`LICENCE.txt` for details.
|
62
VISUAL_STUDIO_2019_GUIDE.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
So you want to compile CSE2?
|
||||
|
||||
Well, to start, you'll need Visual Studio. I know a lot of people
|
||||
recommend MSYS2 instead, and while it is a lot more lightweight, it's
|
||||
also way more complex, and outright broken in some places, which will
|
||||
make compiling an absolute nightmare (I'm looking at you, Brotli).
|
||||
|
||||
So, we'll be using Visual Studio Community 2019. Don't worry - it's
|
||||
free. You can download it here:
|
||||
|
||||
https://visualstudio.microsoft.com/
|
||||
|
||||
Once it's downloaded, run `vs_Community.exe`. Follow the installer until
|
||||
you reach this menu:
|
||||
|
||||
![Screenshot](images/vs2019guide1.png)
|
||||
|
||||
Here, you'll want to select the 'Desktop development with C++' workload,
|
||||
and then click 'Install'. Once it's done installing, you'll be prompted
|
||||
to restart your computer.
|
||||
|
||||
Next, download a copy of CSE2's source code if you haven't already and
|
||||
extract it somewhere. You can find a copy of CSE2 Portable's code here:
|
||||
|
||||
https://github.com/Clownacy/CSE2/archive/portable.zip
|
||||
|
||||
You are now ready to compile CSE2. To begin, open Visual Studio 2019. If
|
||||
it prompts you to open a project, select 'Continue without code' to skip
|
||||
past it and enter the main IDE. It should look something like this:
|
||||
|
||||
![Screenshot](images/vs2019guide2.png)
|
||||
|
||||
From here, select `File/Open/CMake`, and then navigate to where you
|
||||
extracted the CSE2 source code, and open the `CMakeLists.txt` file.
|
||||
|
||||
After this, Visual Studio will spend a few minutes configuring itself.
|
||||
You can see all of this in the little text console at the bottom of the
|
||||
window. Eventually, it will conclude, and hopefully not report any
|
||||
errors. The window should now look something like this:
|
||||
|
||||
![Screenshot](images/vs2019guide3.png)
|
||||
|
||||
You are now able to produce 64-bit Debug builds of CSE2. To do so,
|
||||
simply select `Build/Build All`. Like before, Visual Studio will spend
|
||||
the next few minutes performing tasks, and reporting back in the text
|
||||
console. It should eventually generate `CSE2_debug.exe` and
|
||||
`DoConfig_debug.exe`, which you can find in CSE2's `game_english`
|
||||
folder.
|
||||
|
||||
However, you probably want to be compiling Release builds, not Debug
|
||||
builds. To do so, select the 'Open the CMake Settings Editor' option. It
|
||||
will take you to this menu:
|
||||
|
||||
![Screenshot](images/vs2019guide4.png)
|
||||
|
||||
From here, change the 'Configuration type' option to 'Release'. You can
|
||||
now rebuild CSE2, and the files `CSE2.exe` and `DoConfig.exe` will be
|
||||
generated in the `game_english` folder.
|
||||
|
||||
And... that's it. If you want, you can edit CSE2's code by expanding the
|
||||
`src` folder on the right, and selecting one of the various `.cpp`
|
||||
files.
|
BIN
assets/resources/BITMAP/Credit01.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit02.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit03.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit04.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit05.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit06.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit07.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit08.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit09.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit10.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit11.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit12.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit14.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit15.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit16.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit17.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/Credit18.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
assets/resources/BITMAP/pixel.bmp
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/resources/BITMAP/pixel_jp.bmp
Normal file
After Width: | Height: | Size: 1.4 KiB |
9
assets/resources/CSE2.manifest
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
</assembly>
|
84
assets/resources/CSE2.rc
Normal file
|
@ -0,0 +1,84 @@
|
|||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource1.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Japanese resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
|
||||
#pragma code_page(932)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,6
|
||||
PRODUCTVERSION 1,0,0,6
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "041104b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "Doukutsu"
|
||||
VALUE "FileVersion", "1, 0, 0, 6"
|
||||
VALUE "InternalName", "Doukutsu Monogatari"
|
||||
VALUE "LegalCopyright", "I can't get MSVC2003 to understand Japanese so here's a placeholder"
|
||||
VALUE "OriginalFilename", "Doukutsu.exe"
|
||||
VALUE "ProductName", "I can't get MSVC2003 to understand Japanese so here's a placeholder"
|
||||
VALUE "ProductVersion", "1, 0, 0, 6"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x411, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
GLFW_ICON ICON "ICON/GLFW_ICON.ico"
|
||||
#endif // Japanese resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
BIN
assets/resources/CURSOR/CURSOR_IKA.png
Normal file
After Width: | Height: | Size: 229 B |
BIN
assets/resources/CURSOR/CURSOR_NORMAL.png
Normal file
After Width: | Height: | Size: 144 B |
BIN
assets/resources/ICON/GLFW_ICON.ico
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/resources/ICON/ICON_MINI.png
Normal file
After Width: | Height: | Size: 231 B |
BIN
assets/resources/ORG/Access.org
Normal file
BIN
assets/resources/ORG/Anzen.org
Normal file
BIN
assets/resources/ORG/Balcony.org
Normal file
BIN
assets/resources/ORG/Ballos.org
Normal file
BIN
assets/resources/ORG/BreakDown.org
Normal file
BIN
assets/resources/ORG/Cemetery.org
Normal file
BIN
assets/resources/ORG/Curly.org
Normal file
BIN
assets/resources/ORG/Dr.org
Normal file
BIN
assets/resources/ORG/Ending.org
Normal file
BIN
assets/resources/ORG/Escape.org
Normal file
BIN
assets/resources/ORG/Fanfale1.org
Normal file
BIN
assets/resources/ORG/Fanfale2.org
Normal file
BIN
assets/resources/ORG/Fanfale3.org
Normal file
BIN
assets/resources/ORG/FireEye.org
Normal file
BIN
assets/resources/ORG/Gameover.org
Normal file
BIN
assets/resources/ORG/Ginsuke.org
Normal file
BIN
assets/resources/ORG/Grand.org
Normal file
BIN
assets/resources/ORG/Gravity.org
Normal file
BIN
assets/resources/ORG/Hell.org
Normal file
BIN
assets/resources/ORG/Jenka.org
Normal file
BIN
assets/resources/ORG/Jenka2.org
Normal file
BIN
assets/resources/ORG/Kodou.org
Normal file
BIN
assets/resources/ORG/LastBtl.org
Normal file
BIN
assets/resources/ORG/LastBtl3.org
Normal file
BIN
assets/resources/ORG/LastCave.org
Normal file
BIN
assets/resources/ORG/MDown2.org
Normal file
BIN
assets/resources/ORG/Marine.org
Normal file
BIN
assets/resources/ORG/Maze.org
Normal file
BIN
assets/resources/ORG/Mura.org
Normal file
BIN
assets/resources/ORG/Oside.org
Normal file
BIN
assets/resources/ORG/Plant.org
Normal file
BIN
assets/resources/ORG/Requiem.org
Normal file
BIN
assets/resources/ORG/Toroko.org
Normal file
BIN
assets/resources/ORG/Vivi.org
Normal file
BIN
assets/resources/ORG/Wanpak2.org
Normal file
BIN
assets/resources/ORG/Wanpaku.org
Normal file
BIN
assets/resources/ORG/Weed.org
Normal file
BIN
assets/resources/ORG/White.org
Normal file
BIN
assets/resources/ORG/XXXX.org
Normal file
BIN
assets/resources/ORG/Zonbie.org
Normal file
BIN
assets/resources/ORG/ironH.org
Normal file
BIN
assets/resources/ORG/quiet.org
Normal file
BIN
assets/resources/WAVE/Wave.dat
Normal file
3
assets/resources/afxres.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
// Quick-and-dirty shim to make CSE2.rc work in newer versions of Visual Studio
|
||||
|
||||
#include "windows.h"
|
16
assets/resources/resource1.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by CSE2.rc
|
||||
//
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 172
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
2
assets/riscos/!Boot,feb
Normal file
|
@ -0,0 +1,2 @@
|
|||
Set CSE2$Dir <Obey$Dir>
|
||||
IconSprites <CSE2$Dir>.!Sprites
|