diff --git a/projects/apis/opengl/loader/opengl_device_loader.c b/projects/apis/opengl/loader/opengl_device_loader.c index 8828c8a..f8978c6 100644 --- a/projects/apis/opengl/loader/opengl_device_loader.c +++ b/projects/apis/opengl/loader/opengl_device_loader.c @@ -9,6 +9,7 @@ #include "buffer/opengl_buffer.h" #include "textures/opengl_texture.h" #include "framebuffer/opengl_framebuffer.h" +#include "graphics_pipeline/opengl_graphics_pipeline.h" gnDeviceFunctions loadOpenGLDeviceFunctions() { return (gnDeviceFunctions){ @@ -22,8 +23,8 @@ gnDeviceFunctions loadOpenGLDeviceFunctions() { ._gnCreateRenderPassDescriptor = openglCreateRenderPass, ._gnDestroyRenderPassDescriptor = openglDestroyRenderPass, - ._gnCreateGraphicsPipeline = NULL, - ._gnDestroyGraphicsPipeline = NULL, + ._gnCreateGraphicsPipeline = openglCreateGraphicsPipeline, + ._gnDestroyGraphicsPipeline = openglDestroyGraphicsPipeline, ._gnCreateFramebuffer = openglCreateFramebuffer, ._gnDestroyFramebuffer = openglDestroyFramebuffer, diff --git a/projects/apis/opengl/src/graphics_pipeline/opengl_graphics_pipeline.c b/projects/apis/opengl/src/graphics_pipeline/opengl_graphics_pipeline.c new file mode 100644 index 0000000..461cfa2 --- /dev/null +++ b/projects/apis/opengl/src/graphics_pipeline/opengl_graphics_pipeline.c @@ -0,0 +1,16 @@ +#include "opengl_graphics_pipeline.h" +#include "shaders/opengl_shader_module.h" + +gnReturnCode openglCreateGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gnOutputDevice device, gnGraphicsPipelineInfo info) { + graphicsPipeline->graphicsPipeline = malloc(sizeof(gnPlatformGraphicsPipeline)); + graphicsPipeline->graphicsPipeline->program = glCreateProgram(); + for (int i = 0; i < info.shaderModuleCount; i++) { + glAttachShader(graphicsPipeline->graphicsPipeline->program, info.shaderModules[i]->shaderModule->id); + } + glLinkProgram(graphicsPipeline->graphicsPipeline->program); + return GN_SUCCESS; +} +void openglDestroyGraphicsPipeline(gnGraphicsPipeline graphicsPipeline) { + glDeleteProgram(graphicsPipeline->graphicsPipeline->program); + free(graphicsPipeline->graphicsPipeline); +} diff --git a/projects/apis/opengl/src/graphics_pipeline/opengl_graphics_pipeline.h b/projects/apis/opengl/src/graphics_pipeline/opengl_graphics_pipeline.h new file mode 100644 index 0000000..388aadf --- /dev/null +++ b/projects/apis/opengl/src/graphics_pipeline/opengl_graphics_pipeline.h @@ -0,0 +1,10 @@ +#pragma once +#include "glad/glad.h" +#include "core/src/pipelines/graphics_pipeline/gryphn_graphics_pipeline.h" + +typedef struct gnPlatformGraphicsPipeline_t { + GLuint program; +} gnPlatformGraphicsPipeline; + +gnReturnCode openglCreateGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gnOutputDevice device, gnGraphicsPipelineInfo info); +void openglDestroyGraphicsPipeline(gnGraphicsPipeline graphicsPipeline);