#include #include g_texture* g_texture_create(g_image* image) { sg_image sg_img = sg_make_image(&(sg_image_desc){ .width = image->width, .height = image->height, .data.subimage[0][0] = { .ptr = image->pixels, .size = image->width * image->height * image->channels }, .pixel_format = SG_PIXELFORMAT_RGBA8 // has to be used for opengl support }); g_image_free(image); sg_sampler sg_samp = sg_make_sampler(&(sg_sampler_desc){ .min_filter = SG_FILTER_LINEAR, .mag_filter = SG_FILTER_LINEAR }); g_texture* texture = calloc(1, sizeof(g_texture)); if(texture != NULL) { texture->image = sg_img; texture->sampler = sg_samp; } return texture; }