Skip to content

Commit

Permalink
Add new plugin: real time shader selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Dawid-Lorenz-Mobica committed Jul 4, 2023
1 parent 43bdaf0 commit ac48c2a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion framework/api_vulkan_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ void ApiVulkanSample::on_update_ui_overlay(vkb::Drawer &drawer)

void ApiVulkanSample::store_shader(const vkb::ShaderSourceLanguage& shaderLanguage, const std::vector<std::pair<vkb::ShaderType, std::string>>& listOfShader)
{
// platform->get_available_shaders().insert({shaderLanguage, listOfShader});
Application::get_available_shaders().insert({shaderLanguage, listOfShader});
}

void ApiVulkanSample::create_swapchain_buffers()
Expand Down
2 changes: 1 addition & 1 deletion framework/hpp_api_vulkan_sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class HPPApiVulkanSample : public vkb::HPPVulkanSample
* @param delta_time The time taken since the last frame
* @param additional_ui Function that implements an additional Gui
*/
void update_overlay(float delta_time, const std::function<void()>& additional_ui);
void update_overlay(float delta_time, const std::function<void()>& additional_ui) override;

/**
* @brief If the gui is enabled, then record the drawing commands to a command buffer
Expand Down
5 changes: 5 additions & 0 deletions framework/platform/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@ std::weak_ptr<Gui> Application::get_gui()
{
return gui;
}

std::map<ShaderSourceLanguage, std::vector<std::pair<ShaderType, std::string>>>& Application::get_available_shaders()
{
return available_shaders;
}
} // namespace vkb
7 changes: 7 additions & 0 deletions framework/platform/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class Application

std::weak_ptr<Gui> get_gui();

std::map<ShaderSourceLanguage, std::vector<std::pair<ShaderType, std::string>>>& get_available_shaders();

protected:
float fps{0.0f};

Expand All @@ -123,6 +125,11 @@ class Application
private:
std::string name{};

/**
* @brief stores the names of the shaders the sample uses
*/
std::map<ShaderSourceLanguage, std::vector<std::pair<ShaderType, std::string>>> available_shaders;

// The debug info of the app
DebugInfo debug_info{};

Expand Down
2 changes: 1 addition & 1 deletion framework/platform/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void Platform::set_window_properties(const Window::OptionalProperties &propertie

std::map<ShaderSourceLanguage, std::vector<std::pair<ShaderType, std::string>>>& Platform::get_available_shaders()
{
return available_shaders;
return get_app().get_available_shaders();
}

const std::string &Platform::get_external_storage_directory()
Expand Down
5 changes: 0 additions & 5 deletions framework/platform/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,6 @@ class Platform
const apps::AppInfo *requested_app{nullptr};

std::vector<Plugin *> plugins;

/**
* @brief stores the names of the shaders the sample uses
*/
std::map<ShaderSourceLanguage, std::vector<std::pair<ShaderType, std::string>>> available_shaders;

/// Static so can be set via JNI code in android_platform.cpp
static std::vector<std::string> arguments;
Expand Down

0 comments on commit ac48c2a

Please sign in to comment.