Skip to content

Commit

Permalink
Apply recent framework changes to sample templates (#1073)
Browse files Browse the repository at this point in the history
  • Loading branch information
SaschaWillems committed Jul 1, 2024
1 parent 23d68d6 commit 8ab686d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions bldsys/cmake/template/sample/sample.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ bool @SAMPLE_NAME@::prepare(const vkb::ApplicationOptions &options)
load_scene("scenes/sponza/Sponza01.gltf");

// Attach a move script to the camera component in the scene
auto &camera_node = vkb::add_free_camera(*scene, "main_camera", get_render_context().get_surface_extent());
auto &camera_node = vkb::add_free_camera(get_scene(), "main_camera", get_render_context().get_surface_extent());
auto camera = &camera_node.get_component<vkb::sg::Camera>();

// Example Scene Render Pipeline
vkb::ShaderSource vert_shader("base.vert");
vkb::ShaderSource frag_shader("base.frag");
auto scene_subpass = std::make_unique<vkb::ForwardSubpass>(get_render_context(), std::move(vert_shader), std::move(frag_shader), *scene, *camera);
auto render_pipeline = vkb::RenderPipeline();
render_pipeline.add_subpass(std::move(scene_subpass));
auto scene_subpass = std::make_unique<vkb::ForwardSubpass>(get_render_context(), std::move(vert_shader), std::move(frag_shader), get_scene(), *camera);
auto render_pipeline = std::make_unique<vkb::RenderPipeline>();
render_pipeline->add_subpass(std::move(scene_subpass));
set_render_pipeline(std::move(render_pipeline));

// Add a GUI with the stats you want to monitor
stats->request_stats({/*stats you require*/});
gui = std::make_unique<vkb::Gui>(*this, *window, stats.get());
get_stats().request_stats({/*stats you require*/});
create_gui(*window, &get_stats());

return true;
}

std::unique_ptr<vkb::VulkanSample> create_@SAMPLE_NAME_FILE@()
std::unique_ptr<vkb::VulkanSample<vkb::BindingType::C>> create_@SAMPLE_NAME_FILE@()
{
return std::make_unique<@SAMPLE_NAME@>();
}
6 changes: 3 additions & 3 deletions bldsys/cmake/template/sample/sample.h.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2019-2023, Arm Limited and Contributors
/* Copyright (c) 2019-2024, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
Expand All @@ -21,7 +21,7 @@
#include "scene_graph/components/camera.h"
#include "vulkan_sample.h"

class @SAMPLE_NAME@ : public vkb::VulkanSample
class @SAMPLE_NAME@ : public vkb::VulkanSample<vkb::BindingType::C>
{
public:
@SAMPLE_NAME@();
Expand All @@ -31,4 +31,4 @@ class @SAMPLE_NAME@ : public vkb::VulkanSample
virtual ~@SAMPLE_NAME@() = default;
};

std::unique_ptr<vkb::VulkanSample> create_@SAMPLE_NAME_FILE@();
std::unique_ptr<vkb::VulkanSample<vkb::BindingType::C>> create_@SAMPLE_NAME_FILE@();
6 changes: 3 additions & 3 deletions bldsys/cmake/template/sample_api/sample.cpp.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2023, Arm Limited and Contributors
/* Copyright (c) 2024, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
Expand All @@ -23,7 +23,7 @@

@SAMPLE_NAME@::~@SAMPLE_NAME@()
{
if (device)
if (has_device())
{
vkDestroyPipeline(get_device().get_handle(), sample_pipeline, nullptr);
vkDestroyPipelineLayout(get_device().get_handle(), sample_pipeline_layout, nullptr);
Expand Down Expand Up @@ -168,7 +168,7 @@ void @SAMPLE_NAME@::render(float delta_time)
ApiVulkanSample::submit_frame();
}

std::unique_ptr<vkb::VulkanSample> create_@SAMPLE_NAME_FILE@()
std::unique_ptr<vkb::VulkanSample<vkb::BindingType::C>> create_@SAMPLE_NAME_FILE@()
{
return std::make_unique<@SAMPLE_NAME@>();
}
4 changes: 2 additions & 2 deletions bldsys/cmake/template/sample_api/sample.h.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2023, Arm Limited and Contributors
/* Copyright (c) 2024, Arm Limited and Contributors
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -39,4 +39,4 @@ class @SAMPLE_NAME@ : public ApiVulkanSample
VkPipelineLayout sample_pipeline_layout{};
};

std::unique_ptr<vkb::VulkanSample> create_@SAMPLE_NAME_FILE@();
std::unique_ptr<vkb::VulkanSample<vkb::BindingType::C>> create_@SAMPLE_NAME_FILE@();

0 comments on commit 8ab686d

Please sign in to comment.