add texgen code wip

isolation_bkp/dynres
Dominik Madarász 2021-05-12 19:38:11 +02:00
parent 6621d248b8
commit 16bcb94158
5 changed files with 33 additions and 7 deletions

View File

@ -26,6 +26,8 @@ add_executable(eco2d
source/world/perlin.c source/world/perlin.c
source/world/world.c source/world/world.c
source/gen/texgen.c
source/world/worldgen/worldgen_test.c source/world/worldgen/worldgen_test.c
${PKT_SRCS} ${PKT_SRCS}

View File

@ -0,0 +1,8 @@
#pragma once
#include "system.h"
#include "raylib.h"
#include "world/blocks.h"
#include "assets.h"
Image texgen_build_block(uint32_t biome, uint32_t kind);
Texture2D texgen_build_sprite(asset_id id);

View File

@ -1,5 +1,6 @@
#include "assets.h" #include "assets.h"
#include "raylib.h" #include "raylib.h"
#include "gen/texgen.h"
#define ASSETS_COUNT (sizeof(assets)/sizeof(asset)) #define ASSETS_COUNT (sizeof(assets)/sizeof(asset))
@ -23,10 +24,7 @@ int32_t assets_setup(void) {
switch (b->kind) { switch (b->kind) {
case AKIND_TEXTURE: { case AKIND_TEXTURE: {
// TODO(zaklaus): introduce texgen b->tex = texgen_build_sprite(b->id);
Image img = GenImageColor(1, 1, RAYWHITE);
b->tex = LoadTextureFromImage(img);
UnloadImage(img);
}break; }break;
case AKIND_SOUND: { case AKIND_SOUND: {

View File

@ -0,0 +1,19 @@
#include "gen/texgen.h"
#include "world/world.h"
Image texgen_build_block(uint32_t biome, uint32_t kind) {
// TODO(zaklaus):
(void)biome;
(void)kind;
return GenImageColor(WORLD_BLOCK_SIZE, WORLD_BLOCK_SIZE, RAYWHITE);
}
Texture2D texgen_build_sprite(asset_id id) {
// TODO(zaklaus):
(void)id;
Image img = GenImageColor(1, 1, RAYWHITE);
Texture2D tex = LoadTextureFromImage(img);
UnloadImage(img);
return tex;
}

View File

@ -3,6 +3,7 @@
#include "world/world.h" #include "world/world.h"
#include "world/blocks.h" #include "world/blocks.h"
#include "raylib.h" #include "raylib.h"
#include "gen/texgen.h"
#define BLOCKS_COUNT (sizeof(blocks)/sizeof(block)) #define BLOCKS_COUNT (sizeof(blocks)/sizeof(block))
@ -22,9 +23,7 @@ typedef struct {
int32_t blocks_setup(void) { int32_t blocks_setup(void) {
for (uint32_t i=0; i<BLOCKS_COUNT; i++) { for (uint32_t i=0; i<BLOCKS_COUNT; i++) {
block *b = &blocks[i]; block *b = &blocks[i];
b->img = texgen_build_block(b->biome, b->kind);
// TODO(zaklaus): introduce texgen
b->img = GenImageColor(WORLD_BLOCK_SIZE, WORLD_BLOCK_SIZE, RAYWHITE);
} }
return 0; return 0;
} }