Michaël Lemaire
9a096ec329
Conflicts: src/basics/Disk.cpp src/basics/Disk.h src/basics/SpaceSegment.cpp src/definition/DefinitionNode.cpp src/definition/DefinitionNode.h src/definition/Scenery.cpp src/definition/Scenery.h src/definition/SurfaceMaterial.cpp src/definition/SurfaceMaterial.h src/definition/TextureLayerDefinition.cpp src/definition/definition_global.h src/interface/commandline/tests.cpp src/render/opengl/OpenGLRenderer.cpp src/render/software/SoftwareCanvasRenderer.cpp src/render/software/SoftwareCanvasRenderer.h src/render/software/SoftwareRenderer.h src/render/software/TerrainRasterizer.cpp src/render/software/TerrainRasterizer.h src/render/software/TerrainRenderer.h src/render/software/software_global.h
114 lines
2.4 KiB
C++
114 lines
2.4 KiB
C++
#ifndef OPENGLRENDERER_H
|
|
#define OPENGLRENDERER_H
|
|
|
|
#include "opengl_global.h"
|
|
|
|
#include "SoftwareRenderer.h"
|
|
|
|
class QMatrix4x4;
|
|
|
|
namespace paysages {
|
|
namespace opengl {
|
|
|
|
/*!
|
|
* \brief Scenery renderer in an OpenGL context.
|
|
*/
|
|
class OPENGLSHARED_EXPORT OpenGLRenderer : public SoftwareRenderer {
|
|
public:
|
|
OpenGLRenderer(Scenery *scenery);
|
|
virtual ~OpenGLRenderer();
|
|
|
|
inline OpenGLSkybox *getSkybox() const {
|
|
return skybox;
|
|
}
|
|
inline OpenGLWater *getWater() const {
|
|
return water;
|
|
}
|
|
inline OpenGLTerrain *getTerrain() const {
|
|
return terrain;
|
|
}
|
|
inline bool isDisplayed() const {
|
|
return displayed;
|
|
}
|
|
|
|
virtual void prepare() override;
|
|
|
|
void initialize();
|
|
void prepareOpenGLState();
|
|
void resize(int width, int height);
|
|
void paint();
|
|
|
|
/**
|
|
* Reset the whole state (when the scenery has been massively updated).
|
|
*/
|
|
void reset();
|
|
|
|
/**
|
|
* Pause the rendering process.
|
|
*
|
|
* This will prevent paintings and stop background tasks, until resume() is called.
|
|
*/
|
|
void pause();
|
|
/**
|
|
* Resume the rendering process, put on hold by pause().
|
|
*/
|
|
void resume();
|
|
|
|
/**
|
|
* Set the current mouse location, for use by getMouseProjection().
|
|
*/
|
|
void setMouseLocation(int x, int y);
|
|
|
|
/**
|
|
* Get the coordinates of the mouse, projected in world space.
|
|
*/
|
|
const Vector3 &getMouseProjection();
|
|
|
|
/**
|
|
* Change the camera location.
|
|
*/
|
|
void setCamera(CameraDefinition *camera);
|
|
void cameraChangeEvent(CameraDefinition *camera);
|
|
|
|
inline OpenGLFunctions *getOpenGlFunctions() const {
|
|
return functions;
|
|
}
|
|
inline OpenGLSharedState *getSharedState() const {
|
|
return shared_state;
|
|
}
|
|
|
|
virtual double getPrecision(const Vector3 &location) override;
|
|
virtual Color applyMediumTraversal(const Vector3 &location, const Color &color) override;
|
|
|
|
private:
|
|
/**
|
|
* Update the mouse_projected member.
|
|
*/
|
|
void updateMouseProjection();
|
|
|
|
private:
|
|
bool ready;
|
|
bool paused;
|
|
bool displayed;
|
|
int vp_width;
|
|
int vp_height;
|
|
|
|
bool mouse_tracking;
|
|
int mouse_x;
|
|
int mouse_y;
|
|
Vector3 *mouse_projected;
|
|
|
|
QMatrix4x4 *view_matrix;
|
|
|
|
OpenGLFunctions *functions;
|
|
OpenGLSharedState *shared_state;
|
|
|
|
OpenGLSkybox *skybox;
|
|
OpenGLWater *water;
|
|
OpenGLTerrain *terrain;
|
|
};
|
|
}
|
|
}
|
|
|
|
#endif // OPENGLRENDERER_H
|