47 lines
1022 B
C
47 lines
1022 B
C
/**
|
|
* Copyright (c) 2021 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "chunk.h"
|
|
|
|
void chunkCreate(chunk_t *chunk) {
|
|
int32_t count, x, y, z, i;
|
|
|
|
count = CHUNK_WIDTH * CHUNK_HEIGHT * CHUNK_DEPTH;
|
|
chunk->primitive = primitiveCreate(count * 4, count * 6);
|
|
|
|
i = 0;
|
|
for(z = 0; z < CHUNK_DEPTH; z++) {
|
|
for(y = 0; y < CHUNK_HEIGHT; y++) {
|
|
for(x = 0; x < CHUNK_WIDTH; x++) {
|
|
quadBuffer(chunk->primitive,
|
|
x, y, 0, 0,
|
|
x+1, y+1, 1, 1,
|
|
i*4, i*6
|
|
);
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void chunkRender(chunk_t *chunk, shader_t *shader) {
|
|
float x, y, z;
|
|
x = (chunk->x * CHUNK_WIDTH);
|
|
y = (chunk->y * CHUNK_HEIGHT);
|
|
z = (chunk->z * CHUNK_DEPTH);
|
|
|
|
shaderUsePosition(shader, x*2, y*2, z*2, 0, 0, 0);
|
|
primitiveDraw(chunk->primitive, 0, chunk->primitive->indiceCount);
|
|
}
|
|
|
|
void chunkLoad(chunk_t *chunk, int32_t x, int32_t y, int32_t z) {
|
|
|
|
}
|
|
|
|
void chunkUnload(chunk_t *chunk) {
|
|
|
|
} |