about summary refs log tree commit diff
path: root/src/game/client/mapres_image.cpp
blob: 1c81b309f986c4e56681b78003a8c716959c0a88 (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
31
32
33
34
35
36
37
38
39
40
41
#include <baselib/system.h>
#include "../../engine/interface.h"
#include "mapres_image.h"
#include "../mapres.h"

static int map_textures[64] = {0};
static int count = 0;

int img_init()
{
	int start, count;
	map_get_type(MAPRES_IMAGE, &start, &count);
	dbg_msg("mapres_image", "start=%d count=%d", start, count);
	for(int i = 0; i < 64; i++)
	{
		if(map_textures[i])
		{
			gfx_unload_texture(map_textures[i]);
			map_textures[i] = 0;
		}
	}

	for(int i = 0; i < count; i++)
	{
		mapres_image *img = (mapres_image *)map_get_item(start+i, 0, 0);
		void *data = map_get_data(img->image_data);
		map_textures[i] = gfx_load_texture_raw(img->width, img->height, data);
	}
	
	return count;
}

int img_num()
{
	return count;
}

int img_get(int index)
{
	return map_textures[index];
}