Compare commits
4 Commits
f4e448177b
...
97a70e911d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
97a70e911d | ||
![]() |
2f1db4043a | ||
![]() |
eb11649a03 | ||
![]() |
026fc52d7c |
@@ -4,6 +4,7 @@
|
||||
#include "shaders/opengl_shader_module.h"
|
||||
#include "renderpass/opengl_render_pass_descriptor.h"
|
||||
#include "uniforms/pool/opengl_uniform_pool.h"
|
||||
#include "uniforms/uniform/opengl_uniform.h"
|
||||
#include "commands/pool/opengl_command_pool.h"
|
||||
#include "buffer/opengl_buffer.h"
|
||||
|
||||
@@ -39,9 +40,9 @@ gnDeviceFunctions loadOpenGLDeviceFunctions() {
|
||||
._gnUniformPoolAllocateUniforms = openglAllocateUniforms,
|
||||
._gnDestroyUniformPool = openglDestroyUniformPool,
|
||||
|
||||
._gnUpdateBufferUniform = NULL,
|
||||
._gnUpdateStorageUniform = NULL,
|
||||
._gnUpdateImageUniform = NULL,
|
||||
._gnUpdateBufferUniform = openglUpdateBufferUniform,
|
||||
._gnUpdateStorageUniform = openglUpdateStorageUniform,
|
||||
._gnUpdateImageUniform = openglUpdateImageUniform,
|
||||
|
||||
._gnCreateTexture = NULL,
|
||||
._gnTextureData = NULL,
|
||||
|
@@ -14,6 +14,7 @@ gnReturnCode openglCreateBuffer(gnBufferHandle buffer, gnDevice device, gnBuffer
|
||||
glCreateBuffers(1, &buffer->buffer->id);
|
||||
buffer->buffer->type = gnBufferTypeToGLEnum(info.type);
|
||||
buffer->buffer->usage = (info.usage == GN_DYNAMIC_DRAW) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW;
|
||||
glNamedBufferData(buffer->buffer->id, info.size, NULL, buffer->buffer->usage);
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
void openglBufferData(gnBufferHandle buffer, size_t dataSize, void* data) {
|
||||
|
@@ -1,12 +1,15 @@
|
||||
#include "opengl_uniform_pool.h"
|
||||
#include "uniforms/uniform/opengl_uniform.h"
|
||||
|
||||
gnReturnCode openglCreateUniformPool(gnUniformPool pool, gnDeviceHandle device) {
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
gnUniform* openglAllocateUniforms(gnUniformPool pool, const gnUniformAllocationInfo allocInfo) {
|
||||
gnUniform* uniforms = malloc(sizeof(gnUniform) * allocInfo.setCount);
|
||||
for (int i = 0; i < allocInfo.setCount; i++)
|
||||
for (int i = 0; i < allocInfo.setCount; i++) {
|
||||
uniforms[i] = malloc(sizeof(struct gnUniform_t));
|
||||
uniforms[i]->uniform = malloc(sizeof(struct gnPlatformUniform_t));
|
||||
}
|
||||
return uniforms;
|
||||
}
|
||||
void openglDestroyUniformPool(gnUniformPool pool) {
|
||||
|
14
projects/apis/opengl/src/uniforms/uniform/opengl_uniform.c
Normal file
14
projects/apis/opengl/src/uniforms/uniform/opengl_uniform.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "opengl_uniform.h"
|
||||
|
||||
void openglUpdateBufferUniform(gnUniform uniform, gnBufferUniformInfo* info) {
|
||||
uniform->uniform->type = gl_buffer;
|
||||
uniform->uniform->buffer_info = *info;
|
||||
}
|
||||
void openglUpdateStorageUniform(gnUniform uniform, gnStorageUniformInfo* info) {
|
||||
uniform->uniform->type = gl_storage;
|
||||
uniform->uniform->storage_info = *info;
|
||||
}
|
||||
void openglUpdateImageUniform(gnUniform uniform, gnImageUniformInfo* info) {
|
||||
uniform->uniform->type = gl_image;
|
||||
uniform->uniform->image_info = *info;
|
||||
}
|
20
projects/apis/opengl/src/uniforms/uniform/opengl_uniform.h
Normal file
20
projects/apis/opengl/src/uniforms/uniform/opengl_uniform.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "glad/glad.h"
|
||||
#include "core/src/uniforms/gryphn_uniform.h"
|
||||
|
||||
typedef enum openglUniformType {
|
||||
gl_buffer, gl_storage, gl_image
|
||||
} openglUniformType;
|
||||
|
||||
typedef struct gnPlatformUniform_t {
|
||||
openglUniformType type;
|
||||
union {
|
||||
gnBufferUniformInfo buffer_info;
|
||||
gnStorageUniformInfo storage_info;
|
||||
gnImageUniformInfo image_info;
|
||||
};
|
||||
} gnPlatformUniform;
|
||||
|
||||
void openglUpdateBufferUniform(gnUniform uniform, gnBufferUniformInfo* info);
|
||||
void openglUpdateStorageUniform(gnUniform uniform, gnStorageUniformInfo* info);
|
||||
void openglUpdateImageUniform(gnUniform uniform, gnImageUniformInfo* info);
|
@@ -2,8 +2,6 @@
|
||||
#include "command/command_pool/gryphn_command_pool.h"
|
||||
#include "instance/gryphn_instance.h"
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
gnReturnCode gnCommandPoolAllocateCommandBuffersFromPointer(gnCommandBufferHandle* buffers, uint32_t count, gnCommandPoolHandle commandPool) {
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
buffers[i] = malloc(sizeof(struct gnCommandBuffer_t));
|
||||
|
@@ -6,6 +6,7 @@ gnReturnCode gnCreateTexture(gnTexture* texture, gnDevice device, const gnTextur
|
||||
*texture = malloc(sizeof(struct gnTexture_t));
|
||||
(*texture)->device = device;
|
||||
(*texture)->info = info;
|
||||
|
||||
return device->instance->callingLayer->deviceFunctions._gnCreateTexture(*texture, device, info);
|
||||
}
|
||||
|
||||
@@ -13,5 +14,6 @@ void gnTextureData(gnTextureHandle texture, void* pixelData) {
|
||||
texture->device->instance->callingLayer->deviceFunctions._gnTextureData(texture, pixelData);
|
||||
}
|
||||
void gnDestroyTexture(gnTexture texture) {
|
||||
if (texture == GN_NULL_HANDLE) return;
|
||||
texture->device->instance->callingLayer->deviceFunctions._gnDestroyTexture(texture);
|
||||
}
|
||||
|
Reference in New Issue
Block a user