summaryrefslogtreecommitdiff
path: root/src/engine.c
diff options
context:
space:
mode:
authorAaditya Dhruv <[email protected]>2026-01-30 19:12:03 -0600
committerAaditya Dhruv <[email protected]>2026-01-30 19:12:03 -0600
commit1a721b98caf7559f4a18baa8d3b92269e8f1f6ce (patch)
tree32be8966361f8f8ae74c6c0af226e39fe9feb375 /src/engine.c
parent4992ce0098cac8caef6c9315816b688d96259bce (diff)
Add basic block textures
- Remove the code that sent colors through uniform variables, instead send texture data - Each vertex now has a texture coordinate - struct texture is a easy way to represent textures, can be extended later - Shaders updated to use textures
Diffstat (limited to 'src/engine.c')
-rw-r--r--src/engine.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/engine.c b/src/engine.c
index ec1d9d3..5b6cf05 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -4,6 +4,7 @@
#include "cglm/io.h"
#include "chunk.h"
#include "input.h"
+#include "texture.h"
#include "window.h"
#include "world.h"
#include <SDL2/SDL_render.h>
@@ -35,6 +36,12 @@ int engine_init(struct engine *engine) {
};
engine->shader = shader;
+
+ // Load Textures
+ struct texture* texture = { 0 };
+ texture_init(&engine->texture);
+ texture_load(engine->texture, "textures/grass.jpg");
+
// Setup Objects to draw
// memset(engine->loaded_chunks, 0, (1 + CHUNK_DISTANCE * 2) * (1 + CHUNK_DISTANCE * 2));
@@ -131,7 +138,7 @@ void engine_start(struct engine* engine) {
world_get_chunk(engine->world, chunk_coord, &chunk);
// Load chunk
chunk_load(chunk, chunk_coord);
- chunk_draw(chunk, engine->shader);
+ chunk_draw(chunk, engine->shader, engine->texture);
}
}
SDL_RenderPresent(engine->window->renderer);