Skip to content
Snippets Groups Projects
Commit 590da3a1 authored by Sebastian Gaida's avatar Sebastian Gaida
Browse files

[#69] Fixed triangle, but not buffers

parent 086acb21
No related branches found
No related tags found
1 merge request!56Resolve "Partikelsystem"
Pipeline #25496 passed
No preview for this file type
......@@ -3,9 +3,16 @@
layout(location = 0) out vec4 outColor;
layout(set=0, binding=0) uniform vec4 uColor;
layout(set=0, binding=0) uniform uColor {
vec4 color;
} Color;
layout(set=0,binding=1) uniform uPosition{
vec3 position;
} Position;
void main()
{
outColor = uColor;
// outColor = Color.color;
outColor = vec4(1.0f, 0.0f,0.f,1.f);
}
\ No newline at end of file
#version 450 core
#extension GL_ARB_separate_shader_objects : enable
layout (location = 0) in vec3 position;
layout( push_constant ) uniform constants{
mat4 mvp;
};
vec3 positions[3] = {
vec3(-0.5, 0.5, -1),
vec3( 0.5, 0.5, -1),
vec3(0, -0.5, -1)
};
void main()
{
gl_Position = mvp * vec4(position, 1.0);
gl_Position = mvp * vec4(positions[gl_VertexIndex], 1.0);
}
\ No newline at end of file
No preview for this file type
......@@ -49,9 +49,9 @@ int main(int argc, const char** argv) {
testBuffer.fill(vec_data);
auto triangleIndexBuffer = core.createBuffer<uint16_t>(vkcv::BufferType::INDEX, n, vkcv::BufferMemoryType::DEVICE_LOCAL);
auto particleIndexBuffer = core.createBuffer<uint16_t>(vkcv::BufferType::INDEX, n, vkcv::BufferMemoryType::DEVICE_LOCAL);
uint16_t indices[3] = { 0, 1, 2 };
triangleIndexBuffer.fill(&indices[0], sizeof(indices));
particleIndexBuffer.fill(&indices[0], sizeof(indices));
std::cout << "Physical device: " << physicalDevice.getProperties().deviceName << std::endl;
......@@ -78,6 +78,7 @@ int main(int argc, const char** argv) {
particleShaderProgram.reflectShader(vkcv::ShaderStage::FRAGMENT);
std::vector<vkcv::DescriptorBinding> descriptorBindings = {
vkcv::DescriptorBinding(vkcv::DescriptorType::UNIFORM_BUFFER, 1, vkcv::ShaderStage::FRAGMENT),
vkcv::DescriptorBinding(vkcv::DescriptorType::UNIFORM_BUFFER, 1, vkcv::ShaderStage::FRAGMENT)};
vkcv::DescriptorSetHandle descriptorSet = core.createDescriptorSet(descriptorBindings);
......@@ -91,13 +92,19 @@ int main(int argc, const char** argv) {
true);
vkcv::PipelineHandle particlePipeline = core.createGraphicsPipeline(particlePipelineDefinition);
vkcv::Buffer<glm_vec4> color = core.createBuffer<glm_vec4>(
vkcv::Buffer<glm::vec4> color = core.createBuffer<glm::vec4>(
vkcv::BufferType::UNIFORM,
1
);
vkcv::Buffer<glm::vec4> position = core.createBuffer<glm::vec4>(
vkcv::BufferType::UNIFORM,
1
);
vkcv::DescriptorWrites setWrites;
setWrites.uniformBufferWrites = {vkcv::UniformBufferDescriptorWrite(0,color.getHandle())};
setWrites.uniformBufferWrites = {vkcv::UniformBufferDescriptorWrite(0,color.getHandle()),
vkcv::UniformBufferDescriptorWrite(1,position.getHandle())};
core.writeResourceDescription(descriptorSet,0,setWrites);
if (!particlePipeline)
......@@ -108,8 +115,8 @@ int main(int argc, const char** argv) {
const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle();
const vkcv::Mesh renderMesh({}, triangleIndexBuffer.getVulkanHandle(), 3);
vkcv::DrawcallInfo drawcalls(renderMesh, {});
const vkcv::Mesh renderMesh({}, particleIndexBuffer.getVulkanHandle(), 3);
vkcv::DrawcallInfo drawcalls(renderMesh, {vkcv::DescriptorSetUsage(0, core.getDescriptorSet(descriptorSet).vulkanHandle)});
auto start = std::chrono::system_clock::now();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment