-
Notifications
You must be signed in to change notification settings - Fork 17
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
11 changed files
with
232 additions
and
212 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
add_subdirectory(Common) | ||
add_subdirectory(hello_vulkan_triangle) | ||
add_subdirectory(hello_vulkan_image) |
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,5 @@ | ||
add_library( | ||
SignalHandler # | ||
HostUniforms.hpp # | ||
SignalHandler.hpp SignalHandler.cpp) | ||
target_include_directories(SignalHandler PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..) |
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,18 @@ | ||
#pragma once | ||
|
||
#include <Eigen/Geometry> | ||
|
||
|
||
struct ModelViewProjectionStack | ||
{ | ||
ModelViewProjectionStack() | ||
{ | ||
model.setIdentity(); | ||
view.setIdentity(); | ||
projection.setIdentity(); | ||
} | ||
|
||
Eigen::Transform<float, 3, Eigen::Projective> model; | ||
Eigen::Transform<float, 3, Eigen::Projective> view; | ||
Eigen::Transform<float, 3, Eigen::Projective> projection; | ||
}; |
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,10 @@ | ||
#pragma once | ||
|
||
#include "SignalHandler.hpp" | ||
|
||
|
||
bool SignalHandler::initialized = false; | ||
std::atomic_bool SignalHandler::ctrl_c_hit = false; | ||
#if !defined(_WIN32) | ||
struct sigaction SignalHandler::sigint_handler = {}; | ||
#endif |
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 <signal.h> | ||
|
||
#include <atomic> | ||
#include <iostream> | ||
|
||
|
||
struct SignalHandler | ||
{ | ||
static bool initialized; | ||
static std::atomic_bool ctrl_c_hit; | ||
static struct sigaction sigint_handler; | ||
|
||
static auto stop_render_loop(int) -> void | ||
{ | ||
std::cout << "[CTRL+C HIT] Preparing to close the program!" << std::endl; | ||
ctrl_c_hit = true; | ||
} | ||
|
||
static auto init() -> void | ||
{ | ||
if (initialized) | ||
return; | ||
|
||
#if defined(_WIN32) | ||
signal(SIGINT, stop_render_loop); | ||
signal(SIGTERM, stop_render_loop); | ||
signal(SIGABRT, stop_render_loop); | ||
#else | ||
sigint_handler.sa_handler = SignalHandler::stop_render_loop; | ||
sigemptyset(&sigint_handler.sa_mask); | ||
sigint_handler.sa_flags = 0; | ||
sigaction(SIGINT, &sigint_handler, nullptr); | ||
#endif | ||
|
||
initialized = true; | ||
} | ||
}; |
31 changes: 19 additions & 12 deletions
31
cpp/examples/Shakti/Vulkan/hello_vulkan_image/CMakeLists.txt
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,28 +1,35 @@ | ||
add_executable(hello_vulkan_image main.cpp) | ||
target_link_libraries( | ||
hello_vulkan_image # | ||
PRIVATE DO::Sara::Core # | ||
hello_vulkan_image | ||
PRIVATE SignalHandler # | ||
DO::Sara::Core # | ||
DO::Shakti::Vulkan) | ||
set_target_properties(hello_vulkan_image PROPERTIES FOLDER "Examples/Shakti/Vulkan") | ||
set_target_properties(hello_vulkan_image PROPERTIES FOLDER | ||
"Examples/Shakti/Vulkan") | ||
|
||
add_custom_target(compile_hello_vulkan_image_shaders) | ||
set_target_properties(compile_hello_vulkan_image_shaders PROPERTIES FOLDER "Examples/Shakti/Vulkan") | ||
set_target_properties(compile_hello_vulkan_image_shaders | ||
PROPERTIES FOLDER "Examples/Shakti/Vulkan") | ||
add_custom_command( | ||
TARGET compile_hello_vulkan_image_shaders | ||
COMMAND ${CMAKE_COMMAND} -E make_directory | ||
$<TARGET_FILE_DIR:hello_vulkan_image>/hello_vulkan_image_shaders | ||
COMMAND ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.vert -o | ||
$<TARGET_FILE_DIR:hello_vulkan_image>/hello_vulkan_image_shaders/vert.spv | ||
COMMAND ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.frag -o | ||
$<TARGET_FILE_DIR:hello_vulkan_image>/hello_vulkan_image_shaders/frag.spv) | ||
COMMAND | ||
${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.vert -o | ||
$<TARGET_FILE_DIR:hello_vulkan_image>/hello_vulkan_image_shaders/vert.spv | ||
COMMAND | ||
${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.frag -o | ||
$<TARGET_FILE_DIR:hello_vulkan_image>/hello_vulkan_image_shaders/frag.spv) | ||
|
||
# file(GLOB SHADER_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.vert *.frag) | ||
add_custom_command( | ||
TARGET hello_vulkan_image | ||
PRE_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E make_directory | ||
$<TARGET_FILE_DIR:hello_vulkan_image>/hello_vulkan_image_shaders | ||
COMMAND ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.vert -o | ||
$<TARGET_FILE_DIR:hello_vulkan_image>/hello_vulkan_image_shaders/vert.spv | ||
COMMAND ${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.frag -o | ||
$<TARGET_FILE_DIR:hello_vulkan_image>/hello_vulkan_image_shaders/frag.spv) | ||
COMMAND | ||
${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.vert -o | ||
$<TARGET_FILE_DIR:hello_vulkan_image>/hello_vulkan_image_shaders/vert.spv | ||
COMMAND | ||
${GLSLC_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/shader.frag -o | ||
$<TARGET_FILE_DIR:hello_vulkan_image>/hello_vulkan_image_shaders/frag.spv) |
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
Oops, something went wrong.