This is no code capable of running on its own, look to foray-examples if you need that. This is instead just a simple template
Header
#pragma once
namespace foray-template {
{
protected:
virtual void ApiInit() override;
virtual void ApiOnResized(VkExtent2D size) override;
virtual void ApiDestroy() override;
std::unique_ptr<foray::scene::Scene> mScene;
};
}
Intended as base class for demo applications. Compared to MinimalAppBase it offers a complete simple ...
Definition foray_defaultappbase.hpp:20
Context used for render processes. This object is rebuilt for every frame. /.
Definition foray_framerenderinfo.hpp:14
Base class for operating system events.
Definition foray_event.hpp:13
The only purpose of this class is to copy the image onto the swapchain.
Definition foray_imagetoswapchain.hpp:7
Definition foray_api.hpp:19
Source
void TemplateApp::ApiInit()
{
mScene = std::make_unique<foray::scene::Scene>(&mContext);
converter.LoadGltfModel(
);
mScene->UpdateTlasManager();
mScene->UseDefaultCamera(true);
mSwapCopyStage.Init(&mContext, mainFrameBuf);
mSwapCopyStage.SetFlipY(true);
RegisterRenderStage(&mSwapCopyStage);
}
{
mScene->InvokeOnEvent(event);
}
void TemplateApp::ApiOnResized(VkExtent2D size)
{
mScene->InvokeOnResized(size);
}
{
mScene->Update(renderInfo, cmdBuffer);
mSwapCopyStage.RecordFrame(cmdBuffer, renderInfo);
}
void TemplateApp::ApiDestroy()
{
mSwapCopyStage.Destroy();
mScene = nullptr;
}
void PrepareSwapchainImageForPresent(VkCommandBuffer cmdBuffer)
Adds a Pipeline barrier transitioning the swapchain image into present layout and assuring all writes...
Definition foray_framerenderinfo.hpp:35
core::DeviceSyncCommandBuffer & GetPrimaryCommandBuffer()
Definition foray_framerenderinfo.hpp:26
virtual void Begin()
vkBeginCommandBuffer();
Extension of the commandbuffer wrapper for device and/or host synchronized command buffer execution.
Definition foray_commandbuffer.hpp:90
virtual void Submit()
Submits the commandbuffer.
Wraps allocation and lifetime functionality of VkImage.
Definition foray_managedimage.hpp:13
Type which reads glTF files and merges a scene of the file into the scene graph.
Definition foray_modelconverter.hpp:37
CMakeLists.txt
project(template) // TODO: Name your project
# collect sources
file(GLOB_RECURSE src "*.cpp")
# Make sure there are source files, add_executable would otherwise fail
if (NOT src)
message(FATAL_ERROR "Project \"${PROJECT_NAME}\" does not contain any source files")
endif ()
# Declare executable
add_executable(${PROJECT_NAME} ${src})
# Set strict mode for project only
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS ${STRICT_FLAGS})
# Set directories via compile macros
target_compile_options(${PROJECT_NAME} PUBLIC "-DFORAY_SHADER_DIR=\"$CACHE{FORAY_SHADER_DIR}\"")
# Link foray lib
target_link_libraries(
${PROJECT_NAME}
PUBLIC foray
)
# Windows requires SDL2 libs linked specifically
if (WIN32)
target_link_libraries(
${PROJECT_NAME}
PUBLIC ${SDL2_LIBRARIES}
)
endif()
# Configure include directories
target_include_directories(
${PROJECT_NAME}
PUBLIC "${CMAKE_SOURCE_DIR}/foray/src"
PUBLIC "${CMAKE_SOURCE_DIR}/foray/third_party"
PUBLIC ${Vulkan_INCLUDE_DIR}
)