store Image instead of Texture in blocks
parent
e5b99d829f
commit
b4ae2d01df
|
@ -50,6 +50,6 @@ void DrawRectangleEco(float posX, float posY, int width, int height, Color color
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
Texture2D GetBlockTexture(uint8_t id) {
|
Image GetBlockImage(uint8_t id) {
|
||||||
return *(Texture2D*)blocks_get_tex(id);
|
return *(Image*)blocks_get_img(id);
|
||||||
}
|
}
|
|
@ -21,4 +21,4 @@ uint32_t blocks_get_biome(uint8_t id);
|
||||||
uint32_t blocks_get_kind(uint8_t id);
|
uint32_t blocks_get_kind(uint8_t id);
|
||||||
|
|
||||||
// NOTE(zaklaus): viewer-related functions
|
// NOTE(zaklaus): viewer-related functions
|
||||||
void *blocks_get_tex(uint8_t id);
|
void *blocks_get_img(uint8_t id);
|
|
@ -14,7 +14,7 @@ typedef struct {
|
||||||
char symbol;
|
char symbol;
|
||||||
|
|
||||||
// NOTE(zaklaus): viewer data
|
// NOTE(zaklaus): viewer data
|
||||||
Texture2D tex;
|
Image img;
|
||||||
} block;
|
} block;
|
||||||
|
|
||||||
#include "blocks_list.c"
|
#include "blocks_list.c"
|
||||||
|
@ -24,17 +24,14 @@ int32_t blocks_setup(void) {
|
||||||
block *b = &blocks[i];
|
block *b = &blocks[i];
|
||||||
|
|
||||||
// TODO(zaklaus): introduce texgen
|
// TODO(zaklaus): introduce texgen
|
||||||
Image img = GenImageColor(WORLD_BLOCK_SIZE, WORLD_BLOCK_SIZE, RAYWHITE);
|
b->img = GenImageColor(WORLD_BLOCK_SIZE, WORLD_BLOCK_SIZE, RAYWHITE);
|
||||||
|
|
||||||
b->tex = LoadTextureFromImage(img);
|
|
||||||
UnloadImage(img);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void blocks_destroy(void) {
|
void blocks_destroy(void) {
|
||||||
for (uint32_t i=0; i<BLOCKS_COUNT; i++) {
|
for (uint32_t i=0; i<BLOCKS_COUNT; i++) {
|
||||||
UnloadTexture(blocks[i].tex);
|
UnloadImage(blocks[i].img);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +63,6 @@ uint32_t blocks_get_kind(uint8_t id) {
|
||||||
return blocks[id].kind;
|
return blocks[id].kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *blocks_get_tex(uint8_t id) {
|
void *blocks_get_img(uint8_t id) {
|
||||||
return (void*)&blocks[id].tex;
|
return (void*)&blocks[id].img;
|
||||||
}
|
}
|
Loading…
Reference in New Issue