2015-12-07 22:32:55 +00:00
|
|
|
#ifndef OPENGLTERRAINCHUNK_H
|
|
|
|
#define OPENGLTERRAINCHUNK_H
|
|
|
|
|
|
|
|
#include "opengl_global.h"
|
|
|
|
|
|
|
|
class QImage;
|
|
|
|
|
|
|
|
namespace paysages {
|
|
|
|
namespace opengl {
|
|
|
|
|
|
|
|
class OPENGLSHARED_EXPORT OpenGLTerrainChunk {
|
|
|
|
public:
|
|
|
|
OpenGLTerrainChunk(OpenGLRenderer *renderer, double x, double z, double size, int nbchunks);
|
|
|
|
~OpenGLTerrainChunk();
|
|
|
|
|
|
|
|
bool maintain();
|
|
|
|
void updatePriority(CameraDefinition *camera);
|
|
|
|
void render(OpenGLShaderProgram *program);
|
|
|
|
|
|
|
|
void askReset(bool topology = true, bool texture = true);
|
|
|
|
void askInterrupt();
|
|
|
|
void askResume();
|
|
|
|
|
|
|
|
inline int getVerticesLevel() const {
|
|
|
|
return vertices_level;
|
|
|
|
}
|
2015-12-13 18:06:27 +00:00
|
|
|
inline double getPriority() const {
|
|
|
|
return priority;
|
|
|
|
}
|
2015-12-07 22:32:55 +00:00
|
|
|
inline const OpenGLVertexArray *getVertices() const {
|
|
|
|
return vertices;
|
|
|
|
}
|
|
|
|
|
2015-12-10 22:41:42 +00:00
|
|
|
/**
|
|
|
|
* Release any allocated resource in the opengl context.
|
|
|
|
*
|
|
|
|
* Must be called in the opengl rendering thread, and before the destructor is called.
|
|
|
|
*/
|
|
|
|
void destroy(OpenGLFunctions *functions);
|
|
|
|
|
2015-12-07 22:32:55 +00:00
|
|
|
/**
|
2016-01-06 18:55:49 +00:00
|
|
|
* Fill 'vertices' with a quick initial set of vertices, that can be augmented later using 'augmentVertices'.
|
2015-12-07 22:32:55 +00:00
|
|
|
*/
|
|
|
|
void setFirstStepVertices();
|
|
|
|
|
|
|
|
/**
|
2016-01-06 18:55:49 +00:00
|
|
|
* Improve the level of detail of tessellated vertices in 'vertices'.
|
2015-12-07 22:32:55 +00:00
|
|
|
*
|
|
|
|
* This will double the existing resolution.
|
|
|
|
*/
|
|
|
|
void augmentVertices();
|
|
|
|
|
|
|
|
/**
|
2016-01-06 18:55:49 +00:00
|
|
|
* Update 'vertices' using 'source'.
|
2015-12-07 22:32:55 +00:00
|
|
|
*/
|
|
|
|
void updateVertices(const OpenGLVertexArray &source, int vertice_level);
|
|
|
|
|
|
|
|
/**
|
2016-01-06 18:55:49 +00:00
|
|
|
* Set a square (two triangles) in 'vertices_next'.
|
2015-12-07 22:32:55 +00:00
|
|
|
*/
|
|
|
|
void fillVerticesFromSquare(OpenGLVertexArray *array, int index_offset, double x, double z, double size);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Vector3 getCenter();
|
|
|
|
|
2015-12-13 18:06:27 +00:00
|
|
|
double priority;
|
|
|
|
|
2015-12-07 22:32:55 +00:00
|
|
|
double _startx;
|
|
|
|
double _startz;
|
|
|
|
double _size;
|
|
|
|
double _overall_step;
|
|
|
|
|
|
|
|
OpenGLVertexArray *vertices;
|
|
|
|
int vertices_level;
|
|
|
|
|
|
|
|
Mutex *_lock_data;
|
|
|
|
|
|
|
|
OpenGLRenderer *_renderer;
|
|
|
|
OpenGLSharedState *glstate;
|
|
|
|
|
|
|
|
bool _reset_topology;
|
|
|
|
bool _reset_texture;
|
|
|
|
bool interrupt;
|
|
|
|
|
|
|
|
QImage *_texture;
|
|
|
|
bool _texture_changed;
|
|
|
|
int _texture_current_size;
|
|
|
|
int _texture_wanted_size;
|
|
|
|
int _texture_max_size;
|
|
|
|
|
|
|
|
// LOD control
|
|
|
|
double distance_to_camera;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // OPENGLTERRAINCHUNK_H
|