$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 #include <stdint.h>
11 
12 enum { MAX_TEXTURE_DIMENSION = 8192 };
13 
25 void texture_ensure_pbo(GLuint* pbo_id, GLsizeiptr* current_size,
26  GLsizeiptr required_size);
27 
35 void* texture_map_pbo(GLuint pbo_id, size_t size_bytes);
36 
49 GLuint texture_preallocate_hdr(int width, int height, GLuint old_tex);
50 
61 GLuint texture_upload_hdr_from_pbo(GLuint pbo_id, void* ptr, int width,
62  int height, GLuint reuse_tex_id);
63 
69 void texture_generate_hdr_mipmap(GLuint tex);
70 
81 float* texture_load_pixels(const char* path, int* width, int* height,
82  int* channels);
83 
90 GLuint texture_load_rgba_png(const char* path);
91 
92 #endif /* TEXTURE_H */
Common OpenGL definitions, RAII helpers, and utilities.
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:259
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:20
void texture_ensure_pbo(GLuint *pbo_id, GLsizeiptr *current_size, GLsizeiptr required_size)
Ensures a PBO is allocated with sufficient size.
Definition: texture.c:75
GLuint texture_load_rgba_png(const char *path)
Loads a PNG image from disk and creates an OpenGL RGBA texture.
Definition: texture.c:331
@ MAX_TEXTURE_DIMENSION
Definition: texture.h:12
GLuint texture_preallocate_hdr(int width, int height, GLuint old_tex)
Pre-allocates VRAM for an HDR texture (glTexStorage2D only).
Definition: texture.c:158
void texture_generate_hdr_mipmap(GLuint tex)
Generates mipmaps for an HDR texture.
Definition: texture.c:320
void * texture_map_pbo(GLuint pbo_id, size_t size_bytes)
Maps a PBO for writing.
Definition: texture.c:103