OpenGL texture API
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include "uniforms/uniform/opengl_uniform.h"
|
#include "uniforms/uniform/opengl_uniform.h"
|
||||||
#include "commands/pool/opengl_command_pool.h"
|
#include "commands/pool/opengl_command_pool.h"
|
||||||
#include "buffer/opengl_buffer.h"
|
#include "buffer/opengl_buffer.h"
|
||||||
|
#include "textures/opengl_texture.h"
|
||||||
|
|
||||||
gnDeviceFunctions loadOpenGLDeviceFunctions() {
|
gnDeviceFunctions loadOpenGLDeviceFunctions() {
|
||||||
return (gnDeviceFunctions){
|
return (gnDeviceFunctions){
|
||||||
@@ -44,9 +45,9 @@ gnDeviceFunctions loadOpenGLDeviceFunctions() {
|
|||||||
._gnUpdateStorageUniform = openglUpdateStorageUniform,
|
._gnUpdateStorageUniform = openglUpdateStorageUniform,
|
||||||
._gnUpdateImageUniform = openglUpdateImageUniform,
|
._gnUpdateImageUniform = openglUpdateImageUniform,
|
||||||
|
|
||||||
._gnCreateTexture = NULL,
|
._gnCreateTexture = openglCreateTexture,
|
||||||
._gnTextureData = NULL,
|
._gnTextureData = openglTextureData,
|
||||||
._gnDestroyTexture = NULL,
|
._gnDestroyTexture = openglDestroyTexture,
|
||||||
|
|
||||||
._gnSubmit = NULL,
|
._gnSubmit = NULL,
|
||||||
._gnPresent = NULL,
|
._gnPresent = NULL,
|
||||||
|
34
projects/apis/opengl/src/textures/opengl_texture.c
Normal file
34
projects/apis/opengl/src/textures/opengl_texture.c
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#include "opengl_texture.h"
|
||||||
|
#include "surface/opengl_surface.h"
|
||||||
|
|
||||||
|
GLenum GryphnTargetToOpenGL(gnTextureType type) {
|
||||||
|
switch(type) {
|
||||||
|
case GN_TEXTURE_2D: return GL_TEXTURE_2D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gnReturnCode openglCreateTexture(gnTexture texture, gnDevice device, const gnTextureInfo info) {
|
||||||
|
texture->texture = malloc(sizeof(gnPlatformTexture));
|
||||||
|
glCreateTextures(GryphnTargetToOpenGL(info.type), 1, &texture->texture->id);
|
||||||
|
glTextureStorage2D(
|
||||||
|
texture->texture->id,
|
||||||
|
1,
|
||||||
|
glGryphnFormatToOpenGLInternalFormat(info.format),
|
||||||
|
info.extent.x, info.extent.y
|
||||||
|
);
|
||||||
|
return GN_SUCCESS;
|
||||||
|
}
|
||||||
|
void openglTextureData(gnTextureHandle texture, void* pixelData) {
|
||||||
|
glTextureSubImage2D(
|
||||||
|
texture->texture->id,
|
||||||
|
0,
|
||||||
|
0, 0,
|
||||||
|
texture->info.extent.x, texture->info.extent.y,
|
||||||
|
GL_RGBA,
|
||||||
|
GL_UNSIGNED_BYTE,
|
||||||
|
pixelData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
void openglDestroyTexture(gnTexture texture) {
|
||||||
|
|
||||||
|
}
|
@@ -5,3 +5,7 @@
|
|||||||
typedef struct gnPlatformTexture_t {
|
typedef struct gnPlatformTexture_t {
|
||||||
GLuint id;
|
GLuint id;
|
||||||
} gnPlatformTexture;
|
} gnPlatformTexture;
|
||||||
|
|
||||||
|
gnReturnCode openglCreateTexture(gnTexture texture, gnDevice device, const gnTextureInfo info);
|
||||||
|
void openglTextureData(gnTextureHandle texture, void* pixelData);
|
||||||
|
void openglDestroyTexture(gnTexture texture);
|
||||||
|
Reference in New Issue
Block a user