]> git.lizzy.rs Git - shadowclad.git/blob - level.c
Texturing mockup
[shadowclad.git] / level.c
1 #include <GL/gl.h>
2 #include <assimp/cimport.h>
3 #include <assimp/scene.h>
4
5 #include <stdlib.h>
6 #include <stdio.h> // TODO remove
7
8 #include "level.h"
9 #include "tga.h"
10
11 const Block BLOCK_EMPTY = 0;
12 const Block BLOCK_WALL01 = 1;
13
14 TgaImage* levelImage = NULL;
15
16 Block getBlock(GLushort x, GLushort y) {
17         if (levelImage == NULL) {
18                 return BLOCK_EMPTY;
19         }
20         return ((Block*) (*levelImage).bytes)[x * (*levelImage).header.imageWidth + y];
21 }
22
23 void setImage(TgaImage* image) {
24         levelImage = image;
25 }
26
27 const struct aiScene* importModel(const char* path) {
28         const struct aiScene* scene = aiImportFile(path, 0u);
29         if (scene == NULL) {
30                 fprintf(stderr, "Asset import failed at file %s\n", path); // TODO factor logging the heck outta here
31         }
32         return scene;
33         // TODO aiReleaseImport(scene);
34 }