blob: 13adf2ae4fe5dd22430442866eeda6aa8935449d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "TZR_resource.h"
#include "TZR_globals.h"
#include "reserve.h"
#include <SDL2/SDL_render.h>
#include <SDL2/SDL_rwops.h>
#include <stdio.h>
#include <stdlib.h>
TZR_Uint
TZR_LoadResourceFromMemory(TZR_ResourceType type, const void *data, int size)
{
void *vec = ___tzr_resources;
if (reserve(&vec,
___tzr_resources_size + 1,
&___tzr_resources_capacity,
sizeof(TZR_Resource)))
{
fprintf(stderr, "failed to reserve for new ressource\n");
return 0;
}
___tzr_resources = vec;
TZR_Resource *const res = &___tzr_resources[___tzr_resources_size];
res->type = type;
res->path = NULL;
if (TZR_DirectResourceLoad(res, data, size))
return 0;
___tzr_resources_size += 1;
return ___tzr_resources_size;
}
|