Skip to content
Snippets Groups Projects
Commit 43f31b4c authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

build basic graphics pipeline

parent 02053915
No related branches found
No related tags found
4 merge requests!12Resolve "Swapchain Class",!7Resolve "Shader Program Class",!5Resolve "Pipeline State Object",!4Resolve "Renderpass Class"
Pipeline #24788 passed
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 fragColor; layout(location = 0) in vec3 fragColor;
layout(location = 0) out vec4 outColor; layout(location = 0) out vec4 outColor;
void main() { void main() {
......
...@@ -2,11 +2,9 @@ ...@@ -2,11 +2,9 @@
#extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec2 inPosition; layout(location = 0) in vec2 inPosition;
layout(location = 1) in vec3 inColor;
layout(location = 0) out vec3 fragColor; layout(location = 0) out vec3 fragColor;
void main() { void main() {
gl_Position = vec4(inPosition, 0.0, 1.0); gl_Position = vec4(inPosition, 0.0, 1.0);
fragColor = inColor; fragColor = vec3(1);
} }
\ No newline at end of file
No preview for this file type
...@@ -6,11 +6,13 @@ ...@@ -6,11 +6,13 @@
int main(int argc, const char** argv) { int main(int argc, const char** argv) {
const char* applicationName = "First Triangle"; const char* applicationName = "First Triangle";
const int windowWidth = 800;
const int windowHeight = 600;
vkcv::Window window = vkcv::Window::create( vkcv::Window window = vkcv::Window::create(
applicationName, applicationName,
800, windowWidth,
600, windowHeight,
false false
); );
vkcv::Core core = vkcv::Core::create( vkcv::Core core = vkcv::Core::create(
...@@ -56,6 +58,17 @@ int main(int argc, const char** argv) { ...@@ -56,6 +58,17 @@ int main(int argc, const char** argv) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
vkcv::ShaderProgram triangleShaderProgram = vkcv::ShaderProgram::create();
triangleShaderProgram.addShader(vkcv::ShaderProgram::ShaderStage::VERTEX, "shaders/vert.spv");
triangleShaderProgram.addShader(vkcv::ShaderProgram::ShaderStage::FRAGMENT, "shaders/frag.spv");
const vkcv::Pipeline trianglePipelineDefinition(triangleShaderProgram, windowWidth, windowHeight, trianglePass);
vkcv::PipelineHandle trianglePipeline;
if (!core.createGraphicsPipeline(trianglePipelineDefinition, trianglePipeline)) {
std::cout << "Error. Could not create graphics pipeline. Exiting." << std::endl;
return EXIT_FAILURE;
}
/* /*
* BufferHandle triangleVertices = core.createBuffer(vertices); * BufferHandle triangleVertices = core.createBuffer(vertices);
* BufferHandle triangleIndices = core.createBuffer(indices); * BufferHandle triangleIndices = core.createBuffer(indices);
......
...@@ -530,7 +530,7 @@ namespace vkcv ...@@ -530,7 +530,7 @@ namespace vkcv
} }
bool Core::createGraphicsPipeline(const Pipeline& pipeline, PipelineHandle& handle) { bool Core::createGraphicsPipeline(const Pipeline& pipeline, PipelineHandle& handle) {
// TODO: this search could be avoided if ShaderProgram could be queried for a specific stage // TODO: this search could be avoided if ShaderProgram could be queried for a specific stage
const auto shaderStageFlags = pipeline.m_shaderProgram.getShaderStages(); const auto shaderStageFlags = pipeline.m_shaderProgram.getShaderStages();
const auto shaderCode = pipeline.m_shaderProgram.getShaderCode(); const auto shaderCode = pipeline.m_shaderProgram.getShaderCode();
...@@ -651,7 +651,7 @@ namespace vkcv ...@@ -651,7 +651,7 @@ namespace vkcv
{}, {},
false, false,
vk::LogicOp::eClear, vk::LogicOp::eClear,
0, 1, //TODO: hardcoded to one
&colorBlendAttachmentState, &colorBlendAttachmentState,
{ 1.f,1.f,1.f,1.f } { 1.f,1.f,1.f,1.f }
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment