Merge pull request #1604 from colobot/dev-graphics-overhaul

Graphics overhaul
dev
Emxx52 2023-08-23 02:06:58 +02:00 committed by GitHub
commit 3c4b9f6d01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
756 changed files with 17709 additions and 22035 deletions

View File

@ -13,33 +13,34 @@ jobs:
container: ['']
fail-fast: false
steps:
- name: Switch to gcc-9
run: sudo apt install gcc-9 g++-9 && sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9 && sudo update-alternatives --set gcc /usr/bin/gcc-9
if: matrix.host_os == 'ubuntu-18.04'
- name: Install Colobot dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng-dev libglew-dev libopenal-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-regex-dev libphysfs-dev gettext git po4a vorbis-tools librsvg2-bin xmlstarlet libmpg123-dev
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng-dev libglew-dev libopenal-dev libphysfs-dev gettext git po4a vorbis-tools librsvg2-bin xmlstarlet libglm-dev libmpg123-dev
if: matrix.container == ''
- uses: actions/checkout@v2
- name: Checkout the Google Test submodule
run: git submodule update --init -- lib/googletest
- name: Checkout the nlohmann json submodule
run: git submodule update --init -- lib/json
- name: Create build directory
run: cmake -E make_directory build
- name: Run CMake (for Linux)
working-directory: build
run: cmake -DCMAKE_INSTALL_PREFIX=/install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=1 -DDESKTOP=1 ..
run: cmake --preset Linux-CI
if: matrix.target_os == 'linux'
- name: Build
working-directory: build
run: make -j `nproc`
run: cmake --build --preset Linux-CI
- name: Install
working-directory: build
run: DESTDIR=. make install
run: cmake --build --preset Linux-CI --target install
- name: Patch library path
working-directory: build
run: patchelf --set-rpath '.' install/colobot
if: matrix.target_os == 'linux'
- name: Upload build
uses: actions/upload-artifact@v2
with:
name: ${{matrix.target_os}}-debug
path: build/install
path: install
if: matrix.host_os == 'ubuntu-20.04'
- name: Create AppImage
working-directory: build
@ -55,8 +56,8 @@ jobs:
# Prepare folder for zip
mkdir -p appimage
cp -rp install/data appimage/data
cp -rp install/lang appimage/lang
cp -rp ../install/data appimage/data
cp -rp ../install/lang appimage/lang
cp -p Colobot-x86_64.AppImage appimage/colobot
if: matrix.target_os == 'linux'
- name: Upload AppImage
@ -68,7 +69,7 @@ jobs:
- name: Run tests
# TODO: Maybe run Windows tests using wine as well?
working-directory: build
run: ./colobot_ut --gtest_output=xml:gtestresults.xml
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
if: matrix.target_os == 'linux'
- name: Upload test results
uses: actions/upload-artifact@v2
@ -87,24 +88,24 @@ jobs:
fail-fast: false
steps:
- name: Install Colobot dependencies
run: brew install cmake sdl2 sdl2_image sdl2_ttf boost glew physfs flac libsndfile libvorbis vorbis-tools gettext libicns librsvg wget xmlstarlet
run: brew install cmake sdl2 sdl2_image sdl2_ttf glew physfs flac libsndfile libvorbis vorbis-tools gettext libicns librsvg wget xmlstarlet glm
if: matrix.container == ''
- uses: actions/checkout@v2
- name: Checkout the Google Test submodule
run: git submodule update --init -- lib/googletest
- name: Checkout the nlohmann json submodule
run: git submodule update --init -- lib/json
- name: Create build directory
run: cmake -E make_directory build
- name: Run CMake (for Mac)
working-directory: build
run: cmake -DCMAKE_INSTALL_PREFIX=./install -DCMAKE_SKIP_INSTALL_RPATH=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DDEV_BUILD=1 -DPORTABLE=1 -DTESTS=1 -DDESKTOP=1 -DOPENAL_LIBRARY=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenAL.framework/OpenAL.tbd ..
run: cmake --preset MacOS-CI
if: matrix.target_os == 'macos'
- name: Build
working-directory: build
run: make -j `nproc`
run: cmake --build --preset MacOS-CI
- name: Run tests
# TODO: Maybe run Windows tests using wine as well?
working-directory: build
run: ./colobot_ut --gtest_output=xml:gtestresults.xml
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
if: matrix.target_os == 'macos'
- name: Upload test results
uses: actions/upload-artifact@v2
@ -125,6 +126,8 @@ jobs:
- uses: actions/checkout@v2
- name: Checkout the Google Test submodule
run: git submodule update --init -- lib/googletest
- name: Checkout the nlohmann json submodule
run: git submodule update --init -- lib/json
- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master
- name: Setup VS Environment
@ -167,25 +170,22 @@ jobs:
- name: Create build directory
run: cmake -E make_directory build
- name: Run CMake (for Windows)
working-directory: build
run: cmake -G "Ninja" -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}\scripts\buildsystems\vcpkg.cmake -DUSE_STATIC_RUNTIME=1 -DCBOT_STATIC=1 -DBOOST_STATIC=1 -DGLEW_STATIC=1 -DSNDFILE_STATIC=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}\build\install -DDEV_BUILD=1 -DPORTABLE=1 -DTOOLS=1 -DTESTS=1 -DDESKTOP=1 ..
run: cmake --preset Windows-CI -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}\scripts\buildsystems\vcpkg.cmake
- name: Build
working-directory: build
run: |
$nproc = (Get-CIMInstance -Class 'CIM_Processor').NumberOfLogicalProcessors
cmake --build . -j $nproc
cmake --build --preset Windows-CI -j $nproc
shell: pwsh
- name: Install
working-directory: build
run: cmake --install .
run: cmake --build --preset Windows-CI --target install
- name: Upload build
uses: actions/upload-artifact@v2
with:
name: windows-msvc-debug-${{ matrix.arch }}
path: build/install
path: install
- name: Run tests
working-directory: build
run: ./colobot_ut --gtest_output=xml:gtestresults.xml
run: ./Colobot-UnitTests --gtest_output=xml:gtestresults.xml
- name: Upload test results
uses: actions/upload-artifact@v2
with:
@ -195,10 +195,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install Colobot dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng-dev libglew-dev libopenal-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-regex-dev libphysfs-dev gettext git po4a vorbis-tools librsvg2-bin xmlstarlet doxygen graphviz libmpg123-dev
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsndfile1-dev libvorbis-dev libogg-dev libpng-dev libglew-dev libopenal-dev libphysfs-dev gettext git po4a vorbis-tools librsvg2-bin xmlstarlet doxygen graphviz libglm-dev libmpg123-dev
- uses: actions/checkout@v2
- name: Create build directory
run: cmake -E make_directory build
- name: Checkout the nlohmann json submodule
run: git submodule update --init -- lib/json
- name: Run CMake
working-directory: build
run: cmake ..

1
.gitignore vendored
View File

@ -17,7 +17,6 @@ CMakeDoxygenDefaults.cmake
/Doxyfile
# Ignore targets
/colobot
/src/CBot/libCBot.so
# Ignore local data

3
.gitmodules vendored
View File

@ -7,3 +7,6 @@
path = lib/googletest
url = https://github.com/google/googletest.git
ignore = all
[submodule "lib/json"]
path = lib/json
url = https://github.com/nlohmann/json

175
CBot/CMakeLists.txt Normal file
View File

@ -0,0 +1,175 @@
if(CBOT_STATIC)
add_library(CBot STATIC)
else()
add_library(CBot SHARED)
install(TARGETS CBot
LIBRARY DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
endif()
target_sources(CBot PRIVATE
src/CBot/CBot.h
src/CBot/CBotCStack.cpp
src/CBot/CBotCStack.h
src/CBot/CBotClass.cpp
src/CBot/CBotClass.h
src/CBot/CBotDebug.cpp
src/CBot/CBotDebug.h
src/CBot/CBotDefParam.cpp
src/CBot/CBotDefParam.h
src/CBot/CBotDefines.h
src/CBot/CBotEnums.h
src/CBot/CBotExternalCall.cpp
src/CBot/CBotExternalCall.h
src/CBot/CBotFileUtils.cpp
src/CBot/CBotFileUtils.h
src/CBot/CBotInstr/CBotBlock.cpp
src/CBot/CBotInstr/CBotBlock.h
src/CBot/CBotInstr/CBotBoolExpr.cpp
src/CBot/CBotInstr/CBotBoolExpr.h
src/CBot/CBotInstr/CBotBreak.cpp
src/CBot/CBotInstr/CBotBreak.h
src/CBot/CBotInstr/CBotCase.cpp
src/CBot/CBotInstr/CBotCase.h
src/CBot/CBotInstr/CBotCatch.cpp
src/CBot/CBotInstr/CBotCatch.h
src/CBot/CBotInstr/CBotCondition.cpp
src/CBot/CBotInstr/CBotCondition.h
src/CBot/CBotInstr/CBotDefArray.cpp
src/CBot/CBotInstr/CBotDefArray.h
src/CBot/CBotInstr/CBotDefBoolean.cpp
src/CBot/CBotInstr/CBotDefBoolean.h
src/CBot/CBotInstr/CBotDefClass.cpp
src/CBot/CBotInstr/CBotDefClass.h
src/CBot/CBotInstr/CBotDefFloat.cpp
src/CBot/CBotInstr/CBotDefFloat.h
src/CBot/CBotInstr/CBotDefInt.cpp
src/CBot/CBotInstr/CBotDefInt.h
src/CBot/CBotInstr/CBotDefString.cpp
src/CBot/CBotInstr/CBotDefString.h
src/CBot/CBotInstr/CBotDo.cpp
src/CBot/CBotInstr/CBotDo.h
src/CBot/CBotInstr/CBotEmpty.cpp
src/CBot/CBotInstr/CBotEmpty.h
src/CBot/CBotInstr/CBotExprLitBool.cpp
src/CBot/CBotInstr/CBotExprLitBool.h
src/CBot/CBotInstr/CBotExprLitChar.cpp
src/CBot/CBotInstr/CBotExprLitChar.h
src/CBot/CBotInstr/CBotExprLitNan.cpp
src/CBot/CBotInstr/CBotExprLitNan.h
src/CBot/CBotInstr/CBotExprLitNull.cpp
src/CBot/CBotInstr/CBotExprLitNull.h
src/CBot/CBotInstr/CBotExprLitNum.cpp
src/CBot/CBotInstr/CBotExprLitNum.h
src/CBot/CBotInstr/CBotExprLitString.cpp
src/CBot/CBotInstr/CBotExprLitString.h
src/CBot/CBotInstr/CBotExprRetVar.cpp
src/CBot/CBotInstr/CBotExprRetVar.h
src/CBot/CBotInstr/CBotExprUnaire.cpp
src/CBot/CBotInstr/CBotExprUnaire.h
src/CBot/CBotInstr/CBotExprVar.cpp
src/CBot/CBotInstr/CBotExprVar.h
src/CBot/CBotInstr/CBotExpression.cpp
src/CBot/CBotInstr/CBotExpression.h
src/CBot/CBotInstr/CBotFieldExpr.cpp
src/CBot/CBotInstr/CBotFieldExpr.h
src/CBot/CBotInstr/CBotFor.cpp
src/CBot/CBotInstr/CBotFor.h
src/CBot/CBotInstr/CBotFunction.cpp
src/CBot/CBotInstr/CBotFunction.h
src/CBot/CBotInstr/CBotIf.cpp
src/CBot/CBotInstr/CBotIf.h
src/CBot/CBotInstr/CBotIndexExpr.cpp
src/CBot/CBotInstr/CBotIndexExpr.h
src/CBot/CBotInstr/CBotInstr.cpp
src/CBot/CBotInstr/CBotInstr.h
src/CBot/CBotInstr/CBotInstrCall.cpp
src/CBot/CBotInstr/CBotInstrCall.h
src/CBot/CBotInstr/CBotInstrMethode.cpp
src/CBot/CBotInstr/CBotInstrMethode.h
src/CBot/CBotInstr/CBotInstrUtils.cpp
src/CBot/CBotInstr/CBotInstrUtils.h
src/CBot/CBotInstr/CBotLeftExpr.cpp
src/CBot/CBotInstr/CBotLeftExpr.h
src/CBot/CBotInstr/CBotLeftExprVar.cpp
src/CBot/CBotInstr/CBotLeftExprVar.h
src/CBot/CBotInstr/CBotListArray.cpp
src/CBot/CBotInstr/CBotListArray.h
src/CBot/CBotInstr/CBotListExpression.cpp
src/CBot/CBotInstr/CBotListExpression.h
src/CBot/CBotInstr/CBotListInstr.cpp
src/CBot/CBotInstr/CBotListInstr.h
src/CBot/CBotInstr/CBotLogicExpr.cpp
src/CBot/CBotInstr/CBotLogicExpr.h
src/CBot/CBotInstr/CBotNew.cpp
src/CBot/CBotInstr/CBotNew.h
src/CBot/CBotInstr/CBotParExpr.cpp
src/CBot/CBotInstr/CBotParExpr.h
src/CBot/CBotInstr/CBotPostIncExpr.cpp
src/CBot/CBotInstr/CBotPostIncExpr.h
src/CBot/CBotInstr/CBotPreIncExpr.cpp
src/CBot/CBotInstr/CBotPreIncExpr.h
src/CBot/CBotInstr/CBotRepeat.cpp
src/CBot/CBotInstr/CBotRepeat.h
src/CBot/CBotInstr/CBotReturn.cpp
src/CBot/CBotInstr/CBotReturn.h
src/CBot/CBotInstr/CBotSwitch.cpp
src/CBot/CBotInstr/CBotSwitch.h
src/CBot/CBotInstr/CBotThrow.cpp
src/CBot/CBotInstr/CBotThrow.h
src/CBot/CBotInstr/CBotTry.cpp
src/CBot/CBotInstr/CBotTry.h
src/CBot/CBotInstr/CBotTwoOpExpr.cpp
src/CBot/CBotInstr/CBotTwoOpExpr.h
src/CBot/CBotInstr/CBotWhile.cpp
src/CBot/CBotInstr/CBotWhile.h
src/CBot/CBotProgram.cpp
src/CBot/CBotProgram.h
src/CBot/CBotStack.cpp
src/CBot/CBotStack.h
src/CBot/CBotToken.cpp
src/CBot/CBotToken.h
src/CBot/CBotTypResult.cpp
src/CBot/CBotTypResult.h
src/CBot/CBotUtils.cpp
src/CBot/CBotUtils.h
src/CBot/CBotVar/CBotVar.cpp
src/CBot/CBotVar/CBotVar.h
src/CBot/CBotVar/CBotVarValue.h
src/CBot/CBotVar/CBotVarArray.cpp
src/CBot/CBotVar/CBotVarArray.h
src/CBot/CBotVar/CBotVarBoolean.cpp
src/CBot/CBotVar/CBotVarBoolean.h
src/CBot/CBotVar/CBotVarByte.h
src/CBot/CBotVar/CBotVarChar.h
src/CBot/CBotVar/CBotVarClass.cpp
src/CBot/CBotVar/CBotVarClass.h
src/CBot/CBotVar/CBotVarDouble.h
src/CBot/CBotVar/CBotVarFloat.cpp
src/CBot/CBotVar/CBotVarFloat.h
src/CBot/CBotVar/CBotVarInt.cpp
src/CBot/CBotVar/CBotVarInt.h
src/CBot/CBotVar/CBotVarLong.h
src/CBot/CBotVar/CBotVarPointer.cpp
src/CBot/CBotVar/CBotVarPointer.h
src/CBot/CBotVar/CBotVarShort.h
src/CBot/CBotVar/CBotVarString.cpp
src/CBot/CBotVar/CBotVarString.h
src/CBot/stdlib/Compilation.cpp
src/CBot/stdlib/Compilation.h
src/CBot/stdlib/FileFunctions.cpp
src/CBot/stdlib/MathFunctions.cpp
src/CBot/stdlib/StringFunctions.cpp
src/CBot/stdlib/stdlib.h
src/CBot/stdlib/stdlib_public.h
)
target_include_directories(CBot PUBLIC src)
target_link_libraries(CBot PRIVATE
Colobot-Common
)
if(COLOBOT_LINT_BUILD)
add_fake_header_sources("src/CBot" CBot)
endif()

View File

@ -1,9 +1,10 @@
/**
* \dir src/CBot
* \dir CBot
* \brief CBot library
*/
/**
* \namespace CBot
* \brief CBot engine
*/
*/

View File

@ -23,11 +23,11 @@
#include "CBot/CBotInstr/CBotFunction.h"
#include "CBot/CBotInstr/CBotInstrCall.h"
#include <array>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <boost/algorithm/string/replace.hpp>
namespace CBot
{
@ -53,22 +53,34 @@ void CBotDebug::DumpCompiledProgram(CBotProgram* program)
instructions[ptr] = instructionsNextId++;
}
char buffer[20];
sprintf(buffer, "instr%d", instructions[ptr]);
return std::string(buffer);
std::array<char, 20> buffer;
snprintf(buffer.data(), buffer.size(), "instr%d", instructions[ptr]);
return std::string(buffer.data());
};
std::function<void(CBotInstr*)> DumpInstr = [&](CBotInstr* instr)
{
if (finished.find(instr) != finished.end()) return;
finished.insert(instr);
std::string label = "<b>"+instr->GetDebugName()+"</b>\n";
auto replaceAll = [](std::string& text, const std::string& from, const std::string& to)
{
std::size_t pos = 0;
while ((pos = text.find(from, pos)) != std::string::npos)
{
text.replace(pos, from.length(), to);
pos += to.length();
}
};
std::string data = instr->GetDebugData();
boost::algorithm::replace_all(data, "&", "&amp;");
boost::algorithm::replace_all(data, "<", "&lt;");
boost::algorithm::replace_all(data, ">", "&gt;");
replaceAll(data, "&", "&amp;");
replaceAll(data, "<", "&lt;");
replaceAll(data, ">", "&gt;");
std::string label = "<b>"+instr->GetDebugName()+"</b>\n";
label += data;
boost::algorithm::replace_all(label, "\n", "<br/>");
replaceAll(label, "\n", "<br/>");
std::string additional = "";
if (instr->GetDebugName() == "CBotFunction")

View File

@ -38,7 +38,7 @@ class CBotDebug;
* \endcode
* the following structure is generated:
* \dot
* # Generated using the CBot_compile_graph tool
* # Generated using the CBot-CompileGraph tool
* # and slightly modified
* digraph {
* start [label=<START> shape=box3d color=cyan]

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