-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChunkManager.cpp
More file actions
34 lines (25 loc) · 861 Bytes
/
Copy pathChunkManager.cpp
File metadata and controls
34 lines (25 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "ChunkManager.h"
ChunkManager::ChunkManager(int drawDistance, int chunkSize) {
distance = drawDistance;
size = chunkSize;
addNewMesh( 0, 0, 0xffff0000);
addNewMesh(-1, -1, 0xff00ff00);
addNewMesh( 0, -1, 0xff0000ff);
addNewMesh( 1, -1, 0xfff0f0f0);
}
void ChunkManager::addNewMesh(int offsetX, int offsetY, uint32_t color) {
Mesh* m = new Mesh(size, color);
m->translate(offsetX * (size - 1), 0, offsetY * (size - 1));
m->createBuffers();
chunkList.push_back(Chunk{offsetX, offsetY, m});
}
void ChunkManager::update(const glm::vec3& position, const glm::vec3& direction) {
}
void ChunkManager::draw(bgfx::ViewId view, bgfx::ProgramHandle program) {
for (auto& chunk : chunkList) {
chunk.mesh->bindBuffers();
glm::mat4 model = chunk.mesh->getModelMatrix();
bgfx::setTransform(&model[0][0]);
bgfx::submit(view, program);
}
}