OpenGL texture API
This commit is contained in:
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 {
|
||||
GLuint id;
|
||||
} 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