$darkmode
Suckless OGL 1.0.0
A lean, high-performance C11 PBR Renderer
texture.h
Go to the documentation of this file.
1 
6 #ifndef TEXTURE_H
7 #define TEXTURE_H
8 
9 #include "gl_common.h"
10 
11 enum { MAX_TEXTURE_DIMENSION = 8192 };
12 
24 void texture_ensure_pbo(GLuint* pbo_id, GLsizeiptr* current_size,
25  GLsizeiptr required_size);
26 
34 void* texture_map_pbo(GLuint pbo_id, size_t size_bytes);
35 
48 GLuint texture_preallocate_hdr(int width, int height, GLuint old_tex);
49 
60 GLuint texture_upload_hdr_from_pbo(GLuint pbo_id, void* ptr, int width,
61  int height, GLuint reuse_tex_id);
62 
68 void texture_generate_hdr_mipmap(GLuint tex);
69 
80 float* texture_load_pixels(const char* path, int* width, int* height,
81  int* channels);
82 
89 GLuint texture_load_rgba_png(const char* path);
90 
91 #endif /* TEXTURE_H */
Common OpenGL definitions, RAII helpers, and utilities.
@ MAX_TEXTURE_DIMENSION
Definition: texture.h:11
GLuint texture_upload_hdr_from_pbo(GLuint pbo_id, void *ptr, int width, int height, GLuint reuse_tex_id)
Finalizes HDR upload from a PBO (Unmap -> Upload -> Mipmaps).
Definition: texture.c:258
float * texture_load_pixels(const char *path, int *width, int *height, int *channels)
Decodes an HDR image into RAM without uploading to GPU.
Definition: texture.c:19
void texture_ensure_pbo(GLuint *pbo_id, GLsizeiptr *current_size, GLsizeiptr required_size)
Ensures a PBO is allocated with sufficient size.
Definition: texture.c:74
GLuint texture_load_rgba_png(const char *path)
Loads a PNG image from disk and creates an OpenGL RGBA texture.
Definition: texture.c:330
GLuint texture_preallocate_hdr(int width, int height, GLuint old_tex)
Pre-allocates VRAM for an HDR texture (glTexStorage2D only).
Definition: texture.c:157
void texture_generate_hdr_mipmap(GLuint tex)
Generates mipmaps for an HDR texture.
Definition: texture.c:319
void * texture_map_pbo(GLuint pbo_id, size_t size_bytes)
Maps a PBO for writing.
Definition: texture.c:102