mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 16:05:02 +02:00
Implement sending of image data to GPU
This commit is contained in:
13
kitty/gl.h
13
kitty/gl.h
@@ -97,6 +97,19 @@ free_texture_impl(GLuint *tex_id) {
|
||||
*tex_id = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
send_image_to_gpu_impl(GLuint *tex_id, const void* data, GLsizei width, GLsizei height, bool is_rgb, bool is_4byte_aligned) {
|
||||
if (!(*tex_id)) { glGenTextures(1, tex_id); check_gl(); }
|
||||
glBindTexture(GL_TEXTURE_2D, *tex_id); check_gl();
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, is_4byte_aligned ? 4 : 1); check_gl();
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); check_gl();
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, is_rgb ? GL_RGB : GL_RGBA, GL_UNSIGNED_BYTE, data); check_gl();
|
||||
}
|
||||
|
||||
|
||||
// }}}
|
||||
|
||||
// Programs {{{
|
||||
|
||||
Reference in New Issue
Block a user