-static u8 const_vg_tex2d_err[] =
-{
- 0x00, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x00, 0xff,
- 0x00, 0x00, 0xff, 0xff,
- 0xff, 0xff, 0x00, 0xff
-};
-
-#define QOI_SRGB 0
-#define QOI_LINEAR 1
-
-typedef struct {
- unsigned int width;
- unsigned int height;
- unsigned char channels;
- unsigned char colorspace;
-} qoi_desc;
-
-#ifndef QOI_ZEROARR
- #define QOI_ZEROARR(a) memset((a),0,sizeof(a))
-#endif
-
-#define QOI_OP_INDEX 0x00 /* 00xxxxxx */
-#define QOI_OP_DIFF 0x40 /* 01xxxxxx */
-#define QOI_OP_LUMA 0x80 /* 10xxxxxx */
-#define QOI_OP_RUN 0xc0 /* 11xxxxxx */
-#define QOI_OP_RGB 0xfe /* 11111110 */
-#define QOI_OP_RGBA 0xff /* 11111111 */
-
-#define QOI_MASK_2 0xc0 /* 11000000 */
-
-#define QOI_COLOR_HASH(C) (C.rgba.r*3 + C.rgba.g*5 + C.rgba.b*7 + C.rgba.a*11)
-#define QOI_MAGIC \
- (((unsigned int)'q') << 24 | ((unsigned int)'o') << 16 | \
- ((unsigned int)'i') << 8 | ((unsigned int)'f'))
-#define QOI_HEADER_SIZE 14
-
-/* 2GB is the max file size that this implementation can safely handle. We guard
-against anything larger than that, assuming the worst case with 5 bytes per
-pixel, rounded down to a nice clean value. 400 million pixels ought to be
-enough for anybody. */
-#define QOI_PIXELS_MAX ((unsigned int)400000000)
-
-typedef union {
- struct { unsigned char r, g, b, a; } rgba;
- unsigned int v;
-} qoi_rgba_t;
-
-static const unsigned char qoi_padding[8] = {0,0,0,0,0,0,0,1};
-static u32 qoi_read_32( const u8 *bytes, int *p ) {
- u32 a = bytes[(*p)++];
- u32 b = bytes[(*p)++];
- u32 c = bytes[(*p)++];
- u32 d = bytes[(*p)++];
- return a << 24 | b << 16 | c << 8 | d;
-}
-
-struct texture_load_info{
- GLuint *dest;
- u32 width, height, flags;
- u8 *rgba;
-};
-
-VG_STATIC void async_vg_tex2d_upload( void *payload, u32 size )
-{
- struct texture_load_info *info = payload;
-
- glGenTextures( 1, info->dest );
- glBindTexture( GL_TEXTURE_2D, *info->dest );
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, info->width, info->height,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, info->rgba );
-
- if( !(info->flags & VG_TEX2D_NOMIP) ){
- glGenerateMipmap( GL_TEXTURE_2D );
- }
-
- if( info->flags & VG_TEX2D_LINEAR ){
- if( info->flags & VG_TEX2D_NOMIP ){
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
- }
- else{
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- GL_LINEAR_MIPMAP_LINEAR );
- }
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
- }
-
- if( info->flags & VG_TEX2D_NEAREST ){
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
- }
-
- if( info->flags & VG_TEX2D_CLAMP ){
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- }
-
- if( info->flags & VG_TEX2D_REPEAT ){
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
- }
-}
-
-VG_STATIC void vg_tex2d_replace_with_error( GLuint *dest )
-{
- u32 hdr_size = vg_align8(sizeof(struct texture_load_info));