23 int width, height, channels;
28 void *temp = stbi_load_from_memory((
const stbi_uc *)buffer, size, &width,
29 &height, &channels, 4);
32 allocator_alloc_copy_ty(
byte, alloc, temp, width * height * channels * 2);
33 stbi_image_free(temp);
39 glGenTextures(1, &image->
gl);
40 glBindTexture(GL_TEXTURE_2D, image->
gl);
41 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
42 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
43 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
44 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
46 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image->
width, image->
height, 0, GL_RGBA,
47 GL_UNSIGNED_BYTE, image->
raw);
48 glBindTexture(GL_TEXTURE_2D, 0);
static void image_init(image_t *image, allocator_t alloc, const void *buffer, sz size)
Reinterprets the buffer as the contents of the image file and loads the raw image into memory.
Definition image.h:21