-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
945 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# build the Frame code on linux and run the test | ||
# copy from https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml | ||
name: CMake on multiple platforms | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | ||
fail-fast: true | ||
# Matrix not used, missing windows knowledge to do build it | ||
# clang compiler not working with ubuntu because issue with std lib and clang (tested with clang15) | ||
matrix: | ||
os: [ubuntu-latest] | ||
build_type: [Release] | ||
c_compiler: [gcc] | ||
cpp_compiler: [g++] | ||
triplet: [x64-linux-release] | ||
include: | ||
- os: ubuntu-latest | ||
c_compiler: gcc | ||
cpp_compiler: g++ | ||
triplet: x64-linux-release | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
lfs: true | ||
submodules: true | ||
- name: Set reusable strings | ||
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. | ||
id: strings | ||
shell: bash | ||
run: | | ||
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | ||
- name: apt install | ||
if: ${{ matrix.os == 'ubuntu-latest' }} | ||
run: | | ||
sudo apt update | ||
sudo apt install -y libxmu-dev libxi-dev libgl-dev libglx-dev libgles-dev \ | ||
build-essential libx11-xcb-dev libegl1-mesa-dev libopengl-dev \ | ||
libxkbcommon-dev libwayland-dev libxrandr-dev mesa-vulkan-drivers libglu1-mesa-dev libdrm-dev libegl-dev libglm-dev | ||
# the dependency list is too big but at least it works | ||
# https://packages.ubuntu.com/search | ||
- name: vcpkg build | ||
id: vcpkg | ||
uses: johnwason/vcpkg-action@v6 #cache build so improve the build time a lot | ||
with: | ||
manifest-dir: ${{ github.workspace }} # Set to directory containing vcpkg.json | ||
triplet: "${{ matrix.triplet }}" | ||
token: ${{ github.token }} | ||
github-binarycache: true | ||
cache-key: "${{ matrix.triplet }}" # TODO must use sha1 of vcpkg.json and triplet | ||
- name: Configure CMake | ||
run: > | ||
cmake -B ${{ steps.strings.outputs.build-output-dir }} | ||
-DBUILD_SKIP_CLIENT=ON | ||
${{ steps.vcpkg.outputs.vcpkg-cmake-config }} | ||
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | ||
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | ||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | ||
-S ${{ github.workspace }} ; | ||
- name: Build | ||
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). | ||
run: > | ||
CC="${{ matrix.c_compiler }}" CXX="${{ matrix.cpp_compiler }}" cmake | ||
--build ${{ steps.strings.outputs.build-output-dir }} --verbose -j 4 | ||
- name: Show files after | ||
run: ls -ltrR ${{ github.workspace }} | ||
- name: Run tests | ||
working-directory: ${{ steps.strings.outputs.build-output-dir }} | ||
run: xvfb-run ctest --build-config ${{ matrix.build_type }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "frame/gui/gui_window_interface.h" | ||
#include <imgui.h> | ||
|
||
class ModalInfo : public frame::gui::GuiWindowInterface | ||
{ | ||
public: | ||
ModalInfo(const std::string& name, const std::string& text) : | ||
name_(name), text_(text) | ||
{ | ||
} | ||
bool DrawCallback() override | ||
{ | ||
ImGui::TextUnformatted(text_.c_str()); | ||
if (ImGui::Button("Ok")) | ||
{ | ||
end_ = true; | ||
} | ||
return true; | ||
} | ||
bool End() const override | ||
{ | ||
return end_; | ||
} | ||
std::string GetName() const override | ||
{ | ||
return name_; | ||
} | ||
void SetName(const std::string& name) override | ||
{ | ||
name_ = name; | ||
} | ||
|
||
private: | ||
bool end_ = false; | ||
std::string name_; | ||
std::string text_; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <cstdint> | ||
|
||
#include "frame/name_interface.h" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#pragma once | ||
|
||
#include <array> | ||
#define GLM_ENABLE_EXPERIMENTAL | ||
#include <glm/glm.hpp> | ||
|
||
namespace frame | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#pragma once | ||
|
||
#include <mutex> | ||
#include <spdlog/sinks/base_sink.h> | ||
#include <string> | ||
|
||
#include "frame/logger.h" | ||
|
||
namespace frame::gui | ||
{ | ||
|
||
/** | ||
* @brief A sink for spdlog that stores log messages in a vector of strings. | ||
* | ||
* This sink is useful for testing and debugging, as it allows to check the | ||
* log messages that have been generated by the application. | ||
* | ||
* The sink stores the log messages in a vector of strings, which can be | ||
* accessed using the GetLogs() method. The logs are stored in the order they | ||
* were generated, and can be cleared using the ClearLogs() method. | ||
* | ||
* The sink is thread safe, and can be used with multiple threads. | ||
*/ | ||
class GuiLoggerSink : public spdlog::sinks::base_sink<std::mutex> | ||
{ | ||
protected: | ||
void sink_it_(const spdlog::details::log_msg& msg) override | ||
{ | ||
// log_msg is a struct containing the log entry info like level, | ||
// timestamp, thread id etc. msg.raw contains pre formatted log | ||
|
||
// If needed (very likely but not mandatory), the sink formats the | ||
// message before sending it to its final desination: | ||
spdlog::memory_buf_t formatted; | ||
spdlog::sinks::base_sink<std::mutex>::formatter_->format( | ||
msg, formatted); | ||
const auto time = std::chrono::current_zone() | ||
->to_local(std::chrono::system_clock::now()); | ||
const auto current_milli{ | ||
duration_cast<std::chrono::milliseconds>(time.time_since_epoch()) | ||
.count() % 1000}; | ||
const auto time_p = std::format("{:%X}.{:03} ", time, current_milli); | ||
std::string formatted_message(msg.payload.begin(), msg.payload.end()); | ||
logs.push_back({msg.level, std::move(time_p + formatted_message)}); | ||
} | ||
void flush_() override | ||
{ | ||
} | ||
|
||
public: | ||
/// @brief Get the logs that have been generated. | ||
const std::vector<LogMessage>& GetLogs() const | ||
{ | ||
return logs; | ||
} | ||
/// @brief Clear the logs that have been generated. | ||
void ClearLogs() | ||
{ | ||
logs.clear(); | ||
} | ||
|
||
private: | ||
std::vector<LogMessage> logs; | ||
}; | ||
|
||
} // namespace frame::gui. |
Oops, something went wrong.