Add GridDrawable
This commit is contained in:
22
openVulkanoCpp/Scene/Prefabs/GridDrawable.cpp
Normal file
22
openVulkanoCpp/Scene/Prefabs/GridDrawable.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "GridDrawable.hpp"
|
||||
|
||||
namespace openVulkanoCpp::Scene
|
||||
{
|
||||
GridDrawable::GridDrawable()
|
||||
: Drawable(DrawEncoder::GetDrawEncoder<GridDrawable>(), DrawPhase::POST)
|
||||
{
|
||||
m_shader.cullMode = CullMode::NONE;
|
||||
m_shader.topology = Topology::TRIANGLE_STRIP;
|
||||
m_shader.AddShaderProgram(ShaderProgramType::VERTEX, "Shader/grid");
|
||||
m_shader.AddShaderProgram(ShaderProgramType::FRAGMENT, "Shader/grid");
|
||||
m_shader.alphaBlend = true;
|
||||
|
||||
SetShader(&m_shader);
|
||||
}
|
||||
}
|
||||
25
openVulkanoCpp/Scene/Prefabs/GridDrawable.hpp
Normal file
25
openVulkanoCpp/Scene/Prefabs/GridDrawable.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Scene/Drawable.hpp"
|
||||
#include "Scene/Shader.hpp"
|
||||
|
||||
namespace openVulkanoCpp::Scene
|
||||
{
|
||||
class GridDrawable : public Drawable
|
||||
{
|
||||
Shader m_shader;
|
||||
|
||||
public:
|
||||
GridDrawable();
|
||||
|
||||
[[nodiscard]] Shader& GetShader() { return m_shader; }
|
||||
|
||||
[[nodiscard]] Drawable* Copy() override { return new GridDrawable(); }
|
||||
};
|
||||
}
|
||||
24
openVulkanoCpp/Vulkan/Scene/GridDrawableVulkanEncoder.cpp
Normal file
24
openVulkanoCpp/Vulkan/Scene/GridDrawableVulkanEncoder.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "Scene/Prefabs/GridDrawable.hpp"
|
||||
#include "VulkanGeometry.hpp"
|
||||
#include "Vulkan/VulkanDrawContext.hpp"
|
||||
|
||||
using namespace openVulkanoCpp::Scene;
|
||||
|
||||
namespace openVulkanoCpp::Vulkan
|
||||
{
|
||||
void EncodeGridDrawable(Drawable* instance, Vulkan::VulkanDrawContext* drawContext)
|
||||
{
|
||||
drawContext->commandBuffer.draw(4, 1, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void* gridDrawableVulkanEncoderReg = DrawEncoder::RegisterVulkanEncodeFunction<GridDrawable>(&openVulkanoCpp::Vulkan::EncodeGridDrawable);
|
||||
}
|
||||
Reference in New Issue
Block a user