#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "vg/submodules/stb/stb_image_write.h"
+/* its a sad day. */
+#if 0
+#define STBI_MALLOC(X)
+#define STBI_REALLOC(X,Y)
+#define STBI_FREE(X)
+#endif
+
+#define STBI_ONLY_JPEG
+#define STBI_NO_THREAD_LOCALS
+#define STB_IMAGE_IMPLEMENTATION
+#include "vg/submodules/stb/stb_image.h"
+
struct vg_sprite
{
v4f uv_xywh;
#define VG_TEX2D_CLAMP 0x8
#define VG_TEX2D_NOMIP 0x10
-static u8 const_vg_tex2d_err[] =
-{
- 0x00, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0x00, 0xff,
- 0x00, 0x00, 0xff, 0xff,
- 0xff, 0xff, 0x00, 0xff
+static u8 const_vg_tex2d_err[] ={
+ 0xff,0x00,0xff,0xff, 0x00,0x00,0x00,0xff,
+ 0xff,0x00,0xff,0xff, 0x00,0x00,0x00,0xff,
+ 0x00,0x00,0x00,0xff, 0xff,0x00,0xff,0xff,
+ 0x00,0x00,0x00,0xff, 0xff,0x00,0xff,0xff,
+ 0xff,0x00,0xff,0xff, 0x00,0x00,0x00,0xff,
+ 0xff,0x00,0xff,0xff, 0x00,0x00,0x00,0xff,
+ 0x00,0x00,0x00,0xff, 0xff,0x00,0xff,0xff,
+ 0x00,0x00,0x00,0xff, 0xff,0x00,0xff,0xff,
};
#define QOI_SRGB 0
u8 *rgba;
};
-VG_STATIC void async_vg_tex2d_upload( void *payload, u32 size )
+static void async_vg_tex2d_upload( void *payload, u32 size )
{
+ if( vg_thread_purpose() != k_thread_purpose_main ){
+ vg_fatal_error( "Catastrophic programming error.\n" );
+ }
+
struct texture_load_info *info = payload;
glGenTextures( 1, info->dest );
}
}
-VG_STATIC void vg_tex2d_replace_with_error( GLuint *dest )
+static void vg_tex2d_replace_with_error( GLuint *dest )
{
u32 hdr_size = vg_align8(sizeof(struct texture_load_info));
info->dest = dest;
info->flags = VG_TEX2D_NEAREST|VG_TEX2D_REPEAT|VG_TEX2D_NOMIP;
- info->width = 2;
- info->height = 2;
+ info->width = 4;
+ info->height = 4;
info->rgba = const_vg_tex2d_err;
vg_async_dispatch( call, async_vg_tex2d_upload );
}
-VG_STATIC
+static
void vg_tex2d_load_qoi_async( const u8 *bytes, u32 size,
u32 flags, GLuint *dest )
{
vg_async_dispatch( call, async_vg_tex2d_upload );
}
-VG_STATIC
+static
void vg_tex2d_load_qoi_async_file( const char *path, u32 flags, GLuint *dest )
{
+ if( vg_thread_purpose() != k_thread_purpose_loader )
+ vg_fatal_error( "wrong thread\n" );
+
vg_linear_clear( vg_mem.scratch );
u32 size;