Skip to content

Commit

Permalink
Merge pull request #159 from JacobDomagala/151-v003-release
Browse files Browse the repository at this point in the history
[#151]: `v0.0.3` release
  • Loading branch information
JacobDomagala authored Dec 4, 2023
2 parents 0be5072 + 17ea5b8 commit 7fba5e9
Show file tree
Hide file tree
Showing 24 changed files with 155 additions and 110 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ jobs:
echo "#!/bin/bash
root_dir=\${1}
build_dir=\${2}
pip install conan==1.59.0 --break-system-packages
conan install \$root_dir --install-folder=build --build=missing --settings=build_type=Release -c tools.system.package_manager:mode=install
pip install conan --break-system-packages
conan profile detect
conan install \$root_dir --output-folder=build --build=missing --settings=build_type=Release -c tools.system.package_manager:mode=install
wget https://sdk.lunarg.com/sdk/download/1.3.216.0/linux/vulkansdk-linux-x86_64-1.3.216.0.tar.gz
tar xf vulkansdk-linux-x86_64-1.3.216.0.tar.gz -C \$root_dir/dependencies
source \$root_dir/dependencies/1.3.216.0/setup-env.sh" > init_script.sh
mkdir vulkan
tar xf vulkansdk-linux-x86_64-1.3.216.0.tar.gz -C \$root_dir/vulkan
source \$root_dir/vulkan/1.3.216.0/setup-env.sh" > init_script.sh
- name: Run static analysis
uses: JacobDomagala/StaticAnalysis@master
with:
exclude_dir: dependencies
cmake_args: -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
exclude_dir: vulkan
init_script: init_script.sh
apt_pckgs: xorg-dev python3-pip
verbose: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-dri3-dev \
libxcb-util-dev libxcb-cursor-dev
pip install conan==1.59.0
pip install conan
wget https://sdk.lunarg.com/sdk/download/$SDK_VERSION/linux/vulkansdk-linux-x86_64-$SDK_VERSION.tar.gz
tar xf vulkansdk-linux-x86_64-$SDK_VERSION.tar.gz
Expand All @@ -46,8 +46,7 @@ jobs:
working-directory: ${{runner.workspace}}/build
run: |
# Use newer ABI
conan profile new default --detect
conan profile update settings.compiler.libcxx=libstdc++11 default
conan profile detect
conan install $GITHUB_WORKSPACE --output-folder=build --build=missing --settings=build_type=$BUILD_TYPE
- name: Run CMake
Expand All @@ -56,7 +55,8 @@ jobs:
run: |
source ${{runner.workspace}}/Looper/$SDK_VERSION/setup-env.sh
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWARNINGS_AS_ERRORS=ON -DENABLE_INCLUDE_WHAT_YOU_USE=OFF\
-DENABLE_SANITIZER_ADDRESS=ON -DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=OFF -DENABLE_SANITIZER_LEAK=ON -DUNITY_BUILD=ON
-DENABLE_SANITIZER_ADDRESS=ON -DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=OFF -DENABLE_SANITIZER_LEAK=ON -DUNITY_BUILD=ON\
-DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake
- name: Build
working-directory: ${{runner.workspace}}/build
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ jobs:
- name: Install Conan
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.59.0

- name: Cache Conan packages
id: cache-conan
Expand All @@ -60,7 +58,7 @@ jobs:
run: |
$env:VULKAN_SDK="$env:VULKAN_DIR\$env:SDK_VERSION"
cmake $env:GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE
cmake $env:GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE -DCMAKE_TOOLCHAIN_FILE=${{runner.workspace}}\build\build\conan_toolchain.cmake
cmake --build . --config $env:BUILD_TYPE > output.txt
cat output.txt
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,5 @@ dependencies/glfw/glfw*
*imgui.ini
/CMakeSettings.json
*.cache/*
compile_commands.json
compile_commands.json
CMakeUserPresets.json
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(cmake/util_functions.cmake)

add_subdirectory(dependencies)
add_subdirectory(engine)
add_subdirectory(game)
add_subdirectory(editor)
Expand All @@ -47,4 +46,4 @@ compile_shader(SOURCE_FILE "${SHADERS_PATH}/default.frag" OUTPUT_FILE_NAME "${S
compile_shader(SOURCE_FILE "${SHADERS_PATH}/ui.vert" OUTPUT_FILE_NAME "${SHADERS_PATH}/ui.vert.spv")
compile_shader(SOURCE_FILE "${SHADERS_PATH}/ui.frag" OUTPUT_FILE_NAME "${SHADERS_PATH}/ui.frag.spv")
compile_shader(SOURCE_FILE "${SHADERS_PATH}/line.vert" OUTPUT_FILE_NAME "${SHADERS_PATH}/line.vert.spv")
compile_shader(SOURCE_FILE "${SHADERS_PATH}/line.frag" OUTPUT_FILE_NAME "${SHADERS_PATH}/line.frag.spv")
compile_shader(SOURCE_FILE "${SHADERS_PATH}/line.frag" OUTPUT_FILE_NAME "${SHADERS_PATH}/line.frag.spv")
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# Looper
Looper is a game engine with an integrated editor and a 2D type game with a level editor, all written in modern C++20. It uses Vulkan for rendering and ImGui/glfw3 for UI and window/input handling. The project is compatible with Ubuntu and Windows.


[![Watch the video](https://raw.githubusercontent.com/wiki/JacobDomagala/Looper/Looper_github.gif)](https://www.youtube.com/watch?v=Qh-vOKMPQGQ)
![gif](https://raw.githubusercontent.com/wiki/JacobDomagala/Looper/Looper_github.gif)

## Requirements
- C++20 compatible compiler (e.g. GCC, Clang, MSVC)
Expand All @@ -22,9 +21,6 @@ The typical build process would look like this:
# Create build directory
mkdir build && cd build

# Use newer ABI
conan profile new default --detect
conan profile update settings.compiler.libcxx=libstdc++11 default
conan install .. --output-folder=build --build=missing --settings=build_type=Release

# Generate build system for Windows/Linux
Expand All @@ -43,5 +39,9 @@ cmake --build .
## Contributing
If you would like to contribute to the project, please fork the repository and submit a pull request with your proposed changes. We welcome any improvements or new features that enhance the functionality and user experience of Looper.

## Youtube
For past and future video logs, please visit my [Youtube](https://www.youtube.com/watch?v=Qh-vOKMPQGQ&list=PLRLVUsGGaSH-s0A_2w_eo2LQEfTZuqi7Y) channel. <br>
[![Playlist](https://img.youtube.com/vi/cyZFLKrvoPc/0.jpg)](https://www.youtube.com/watch?v=cyZFLKrvoPc&list=PLRLVUsGGaSH-s0A_2w_eo2LQEfTZuqi7Y "YouTube Playlist")

## License
Please refer to the LICENSE file in the repository for details on the licensing of this project.
6 changes: 3 additions & 3 deletions conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
fmt/10.1.0
glfw/3.3.8
imgui/1.89.9
stb/20200203
stb/cci.20230920
glm/0.9.9.8
nlohmann_json/3.11.2

[generators]
cmake_find_package_multi
cmake
CMakeToolchain
CMakeDeps
18 changes: 0 additions & 18 deletions dependencies/CMakeLists.txt

This file was deleted.

3 changes: 0 additions & 3 deletions dependencies/stb_image/CMakeLists.txt

This file was deleted.

20 changes: 16 additions & 4 deletions editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ Editor::Render(VkCommandBuffer cmdBuffer)
const auto idx = static_cast< size_t >(layer);
const auto& numObjects = renderData.numMeshes.at(idx);
const auto renderThisLayer = renderLayerToDraw_ == -1 ? true : renderLayerToDraw_ == layer;

if (numObjects == 0 or !renderThisLayer)
{
continue;
Expand Down Expand Up @@ -804,6 +804,8 @@ Editor::CreateLevel(const std::string& name, const glm::ivec2& size)
m_levelFileName = (LEVELS_DIR / (name + ".dgl")).string();
gui_.LevelLoaded(m_currentLevel);

m_currentLevel->GenerateTextureForCollision();

SetupRendererData();
}

Expand Down Expand Up @@ -1037,14 +1039,20 @@ Editor::Update()

if (m_animateGameObject && m_currentSelectedGameObject)
{
auto moveBy = std::dynamic_pointer_cast< Animatable >(m_currentSelectedGameObject)
->SingleAnimate(m_deltaTime);
const auto& animatable = std::dynamic_pointer_cast< Animatable >(m_currentSelectedGameObject);
auto moveBy = animatable->SingleAnimate(deltaTime_);

if (glm::length(moveBy) > 0.0f)
{
const auto prevPosition = m_currentSelectedGameObject->GetPreviousPosition();
const auto direction = m_currentSelectedGameObject->GetPosition() - prevPosition;

const auto viewAngle = glm::atan(direction.y, direction.x);

m_currentSelectedGameObject->Rotate(viewAngle);
m_currentSelectedGameObject->Move(moveBy);
}
else
else if (animatable->AnimationFinished())
{
m_animateGameObject = false;
}
Expand Down Expand Up @@ -1123,6 +1131,8 @@ Editor::MainLoop()
while (IsRunning() and (singleFrameTimer.count() >= TARGET_TIME_MICRO))
{
const time::ScopedTimer frameTimer(&timeLastFrame_);

deltaTime_ = m_timer.GetMsDeltaTime();
InputManager::PollEvents();

// Run all deffered work units
Expand Down Expand Up @@ -1159,6 +1169,8 @@ Editor::MainLoop()
{
LaunchGameLoop();
}

m_timer.ToggleTimer();
}
}
}
Expand Down
59 changes: 32 additions & 27 deletions editor/gui/editor_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,12 +561,13 @@ void
EditorGUI::RenderCreateNewLevelWindow()
{
const auto halfSize = windowSize_ / 2.0f;
std::unordered_map< std::string, glm::ivec2 > sizes = {{"Small", glm::ivec2{4096, 4096}},
std::unordered_map< std::string, glm::ivec2 > sizes = {{"Small", glm::ivec2{8192, 8192}},
{"Medium", glm::ivec2{16384, 16384}},
{"Large", glm::ivec2{65536, 65536}}};
static glm::ivec2 size = {1024, 1024};

static std::string name = "DummyLevelName";
static std::string currentSize = "Small";
static glm::ivec2 size = sizes[currentSize];

ImGui::SetNextWindowPos({halfSize.x - 160, halfSize.y - 60});
ImGui::SetNextWindowSize({300, 180});
Expand Down Expand Up @@ -904,6 +905,7 @@ EditorGUI::RenderGameObjectMenu() // NOLINT
if (ImGui::Checkbox("##Has Collision", &collision))
{
currentlySelectedGameObject_->SetHasCollision(collision);
parent_.GetLevel().UpdateCollisionTexture();
}
});

Expand All @@ -926,6 +928,7 @@ EditorGUI::RenderGameObjectMenu() // NOLINT
if (ImGui::SliderFloat2("##Size", &sprite_size.x, 10, 1000))
{
currentlySelectedGameObject_->SetSize(sprite_size);
parent_.GetLevel().UpdateCollisionTexture();
}
});

Expand All @@ -947,36 +950,37 @@ EditorGUI::RenderGameObjectMenu() // NOLINT
if (ImGui::CollapsingHeader("Shader"))
{
const auto sectionSize = ImGui::GetContentRegionAvail();
const auto currentPos = ImGui::GetCursorScreenPos();
ImGui::SetCursorScreenPos(ImVec2(currentPos.x + sectionSize.x / 4.0f, currentPos.y));
ImGui::Image(static_cast< ImTextureID >(
GetDescriptor(currentlySelectedGameObject_->GetSprite().GetTexture()->GetID(),
descriptorPool_, descriptorSetLayout_)),
{sectionSize.x, sectionSize.x});
{glm::min(sectionSize.x, 128.0f), glm::min(sectionSize.x, 128.0f)});

DrawWidget("Texture", [this, sectionSize]() {
if (ImGui::BeginTable("TextureInfoTable", 2))
{
auto& sprite = currentlySelectedGameObject_->GetSprite();
const float fullWidth = sectionSize.x;
const float inputTextWidth = fullWidth * 0.90f;
const float buttonWidth = fullWidth * 0.10f;

ImGui::PushItemWidth(inputTextWidth);
ImGui::InputText("##Texture", sprite.GetTextureName().data(),
sprite.GetTextureName().size(), ImGuiInputTextFlags_ReadOnly);
ImGui::PopItemWidth(); // Always pair a Push call with a Pop

ImGui::SameLine();
CreateRow("Name", fmt::format("{}", sprite.GetTextureName()));
CreateRow("ID", fmt::format("{}", sprite.GetTexture()->GetID()));
CreateActionRowLabel("File", [this]() {
auto& sprite = currentlySelectedGameObject_->GetSprite();

ImGui::InputText("##Texture", sprite.GetTextureName().data(),
sprite.GetTextureName().size(), ImGuiInputTextFlags_ReadOnly);
ImGui::SameLine();

ImGui::PushItemWidth(buttonWidth);
if (ImGui::Button(ICON_FA_PENCIL ""))
{
auto textureName = FileManager::FileDialog(
IMAGES_DIR, {{"PNG texture", "png"}, {"JPEG texture", "jpg"}}, false);
if (!textureName.empty())
if (ImGui::Button(ICON_FA_PENCIL ""))
{
sprite.SetTextureFromFile(textureName);
auto textureName = FileManager::FileDialog(
IMAGES_DIR, {{"PNG texture", "png"}, {"JPEG texture", "jpg"}}, false);
if (!textureName.empty())
{
sprite.SetTextureFromFile(textureName);
}
}
}
ImGui::PopItemWidth(); // Always pair a Push call with a Pop
});
});
}
ImGui::EndTable();
}

if (currentlySelectedGameObject_->GetType() == ObjectType::ENEMY)
Expand Down Expand Up @@ -1020,8 +1024,9 @@ EditorGUI::RenderGameObjectMenu() // NOLINT
time::Timer::ConvertToMs(animatablePtr->GetAnimationDuration()).count();
if (parent_.IsObjectAnimated())
{
timer += static_cast< float >(parent_.GetDeltaTime().count());
timer = glm::min(animationDuration, timer);
// timer += static_cast< float >(parent_.GetDeltaTime().count());
// timer = glm::min(animationDuration, timer);
timer = animatablePtr->GetTotalTimeElapsed().count();
}

ImGui::SameLine();
Expand Down Expand Up @@ -1127,7 +1132,7 @@ EditorGUI::UpdateUI()
windowSize_ = parent_.GetWindowSize();

windowWidth_ = windowSize_.x / 7;
toolsWindowHeight_ = windowSize_.y / 20;
toolsWindowHeight_ = std::max(windowSize_.y / 20.0f, 64.0f);
levelWindowHeight_ = windowSize_.y - toolsWindowHeight_;
gameObjectWindowHeight_ = windowSize_.y;

Expand Down
3 changes: 2 additions & 1 deletion editor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
int
main(int /* argc */, char** /* argv */)
{
looper::Editor editor(looper::USE_DEFAULT_SIZE);
// looper::Editor editor(looper::USE_DEFAULT_SIZE);
looper::Editor editor({1920, 1080});
editor.MainLoop();

return EXIT_SUCCESS;
Expand Down
12 changes: 8 additions & 4 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ target_include_directories(${MODULE_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" "


# Load all TPLs
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
find_package(Vulkan REQUIRED)

target_link_libraries_system(${MODULE_NAME} PUBLIC stb_image CONAN_PKG::fmt CONAN_PKG::glfw CONAN_PKG::imgui CONAN_PKG::glm CONAN_PKG::nlohmann_json)
find_package(fmt REQUIRED)
find_package(glfw3 REQUIRED)
find_package(imgui REQUIRED)
find_package(glm REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(stb REQUIRED)

target_link_libraries_system(${MODULE_NAME} PUBLIC stb::stb fmt::fmt glfw imgui::imgui glm::glm nlohmann_json::nlohmann_json)
target_link_libraries(${MODULE_NAME} PUBLIC project_warnings project_options Vulkan::Vulkan)
target_compile_features(${MODULE_NAME} PRIVATE cxx_std_20)

Expand Down
2 changes: 1 addition & 1 deletion engine/core/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Application::GetCamera()
time::milliseconds
Application::GetDeltaTime() const
{
return m_deltaTime;
return deltaTime_;
}

bool
Expand Down
2 changes: 1 addition & 1 deletion engine/core/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Application : public InputListener
std::unique_ptr< renderer::Window > m_window = {};
renderer::Camera m_camera = {};
time::Timer m_timer = {};
time::milliseconds m_deltaTime = {};
time::milliseconds deltaTime_ = {};
int32_t m_frames = 0;
float m_frameTimer = 0.0f;
int32_t m_framesLastSecond = 0;
Expand Down
Loading

0 comments on commit 7fba5e9

Please sign in to comment.