OpenMiner/include/chunk.h

66 lines
1.8 KiB
C
Raw Normal View History

2013-03-02 00:11:18 +01:00
/*---------------------------------------------------------------------------------
KubKraft
Copyright (C) 2012 Quent42340 <quent42340@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
---------------------------------------------------------------------------------*/
#ifndef CHUNK_H
#define CHUNK_H
class Chunk {
public:
2013-04-29 15:29:22 +02:00
Chunk(int x, int y, int z);
2013-03-02 00:11:18 +01:00
~Chunk();
2013-03-09 03:23:13 +01:00
void setSurroundingChunk(unsigned char face, Chunk* chunk);
void render();
2013-03-02 00:11:18 +01:00
void deleteCube(Cube *cube);
void addCube(Cube *selectedCube, int type = 2);
2013-03-02 00:11:18 +01:00
2013-03-09 03:23:13 +01:00
void refreshVBO();
2013-03-02 00:11:18 +01:00
int x() const { return m_x; }
int y() const { return m_y; }
int z() const { return m_z; }
2013-04-30 19:36:41 +02:00
void putCube(int x, int y, int z, int type) { m_cubes[CUBE_POS(x, y, z)] = new Cube(x, y, z, type); }
std::unordered_map<int, Cube*> cubes() const { return m_cubes; }
2013-03-02 00:11:18 +01:00
2013-03-09 15:20:18 +01:00
Chunk **surroundingChunks() const { return m_surroundingChunks; }
2013-03-02 00:11:18 +01:00
private:
int m_x;
int m_y;
int m_z;
std::unordered_map<int, Cube*> m_cubes;
Cube *getCube(int x, int y, int z);
Chunk **m_surroundingChunks;
GLuint m_vboVertices;
GLuint m_vboTexCoords;
GLuint m_vboColors;
int m_vboVertexCount;
2013-04-29 23:53:31 +02:00
float getTexOffsetU(int type, int i = -1, Cube *cube = NULL);
float getTexOffsetV(int type);
2013-03-02 00:11:18 +01:00
};
#endif // CHUNK_H