-
- if( src_data )
- {
- qoi_desc info;
- u8 *tex_buffer = qoi_decode( src_data, length, &info, 4 );
-
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, info.width, info.height,
- 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_buffer );
-
- vg_free( tex_buffer );
- vg_free( src_data );
- }
- else
- {
- u32 tex_err[4] =
- {
- 0xffff00ff,
- 0xff000000,
- 0xff000000,
- 0xffff00ff
- };
-
+
+ return texture_name;
+}
+
+VG_STATIC void vg_tex2d_set_error(void)
+{
+ u32 tex_err[4] =
+ {
+ 0xffff00ff,
+ 0xff000000,
+ 0xff000000,
+ 0xffff00ff
+ };
+
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 2, 2,
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_err );
+}
+
+VG_STATIC void vg_tex2d_qoi( void *mem, u32 size, const char *name )
+{
+ qoi_desc info;
+ u8 *tex_buffer = qoi_decode( mem, size, &info, 4 );
+
+ if( tex_buffer )
+ {
+ vg_info( "Texture decoded: [%u %u] %s\n",
+ info.width, info.height, name );
+
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, info.width, info.height,
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, tex_buffer );
+
+ QOI_FREE(tex_buffer);
+ }
+ else
+ {
+ vg_error( "File size: %u\n", size );
+ vg_tex2d_set_error();
+ }
+}
+
+VG_STATIC GLuint vg_tex2d_rgba( const char *path )
+{
+ GLuint texture_name = vg_tex2d_new();
+
+ vg_linear_clear( vg_mem.scratch );
+ u32 size;
+ void *file = vg_file_read( vg_mem.scratch, path, &size );
+
+ if( file )
+ {
+ vg_tex2d_qoi( file, size, path );
+ }
+ else
+ {