2013-11-05 10:45:26 +00:00
|
|
|
#ifndef OPENGLRENDERER_H
|
|
|
|
#define OPENGLRENDERER_H
|
|
|
|
|
|
|
|
#include "opengl_global.h"
|
|
|
|
|
2013-11-14 20:46:47 +00:00
|
|
|
#include "SoftwareRenderer.h"
|
2013-11-05 10:45:26 +00:00
|
|
|
|
2015-09-06 23:15:59 +00:00
|
|
|
class QMatrix4x4;
|
|
|
|
|
2013-11-05 10:45:26 +00:00
|
|
|
namespace paysages {
|
|
|
|
namespace opengl {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Scenery renderer in an OpenGL context.
|
|
|
|
*/
|
2013-12-15 14:06:43 +00:00
|
|
|
class OPENGLSHARED_EXPORT OpenGLRenderer: public SoftwareRenderer
|
2013-11-05 10:45:26 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-08-18 20:29:18 +00:00
|
|
|
OpenGLRenderer(Scenery* scenery);
|
2013-11-14 20:46:47 +00:00
|
|
|
virtual ~OpenGLRenderer();
|
2013-11-05 10:45:26 +00:00
|
|
|
|
2014-08-28 13:09:47 +00:00
|
|
|
inline OpenGLSkybox *getSkybox() const {return skybox;}
|
|
|
|
inline OpenGLWater *getWater() const {return water;}
|
|
|
|
inline OpenGLTerrain *getTerrain() const {return terrain;}
|
2015-09-14 17:25:54 +00:00
|
|
|
inline bool isDisplayed() const {return displayed;}
|
2014-08-28 13:09:47 +00:00
|
|
|
|
2013-11-05 10:45:26 +00:00
|
|
|
void initialize();
|
2014-08-27 16:19:48 +00:00
|
|
|
void prepareOpenGLState();
|
2013-11-05 10:45:26 +00:00
|
|
|
void resize(int width, int height);
|
|
|
|
void paint();
|
2013-12-15 14:06:43 +00:00
|
|
|
|
2015-08-19 18:06:47 +00:00
|
|
|
/**
|
|
|
|
* Reset the whole state (when the scenery has been massively updated).
|
|
|
|
*/
|
|
|
|
void reset();
|
|
|
|
|
2015-08-18 17:12:54 +00:00
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
|
2015-09-06 23:15:59 +00:00
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
|
2014-09-18 15:38:37 +00:00
|
|
|
/**
|
|
|
|
* Change the camera location.
|
|
|
|
*/
|
|
|
|
void setCamera(CameraDefinition *camera);
|
2013-12-21 22:48:54 +00:00
|
|
|
void cameraChangeEvent(CameraDefinition* camera);
|
|
|
|
|
2013-12-23 09:26:29 +00:00
|
|
|
inline OpenGLFunctions* getOpenGlFunctions() const {return functions;}
|
2013-12-22 14:04:33 +00:00
|
|
|
inline OpenGLSharedState* getSharedState() const {return shared_state;}
|
2013-12-21 22:48:54 +00:00
|
|
|
|
2013-12-15 14:18:11 +00:00
|
|
|
virtual double getPrecision(const Vector3 &location) override;
|
2015-11-08 22:32:52 +00:00
|
|
|
virtual Color applyMediumTraversal(const Vector3 &location, const Color &color) override;
|
2013-12-21 22:48:54 +00:00
|
|
|
|
2015-09-06 23:15:59 +00:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Update the mouse_projected member.
|
|
|
|
*/
|
|
|
|
void updateMouseProjection();
|
|
|
|
|
2013-12-21 22:48:54 +00:00
|
|
|
private:
|
2013-12-23 09:26:29 +00:00
|
|
|
bool ready;
|
2015-08-18 17:12:54 +00:00
|
|
|
bool paused;
|
2015-09-14 17:25:54 +00:00
|
|
|
bool displayed;
|
2014-08-27 16:19:48 +00:00
|
|
|
int vp_width;
|
|
|
|
int vp_height;
|
2013-12-23 09:26:29 +00:00
|
|
|
|
2015-09-06 23:15:59 +00:00
|
|
|
bool mouse_tracking;
|
|
|
|
int mouse_x;
|
|
|
|
int mouse_y;
|
|
|
|
Vector3 *mouse_projected;
|
|
|
|
|
|
|
|
QMatrix4x4 *view_matrix;
|
|
|
|
|
2013-12-23 09:26:29 +00:00
|
|
|
OpenGLFunctions* functions;
|
2013-12-22 14:04:33 +00:00
|
|
|
OpenGLSharedState* shared_state;
|
2013-12-21 22:48:54 +00:00
|
|
|
|
|
|
|
OpenGLSkybox* skybox;
|
2013-12-21 23:41:19 +00:00
|
|
|
OpenGLWater* water;
|
2013-12-23 13:09:52 +00:00
|
|
|
OpenGLTerrain* terrain;
|
2013-11-05 10:45:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // OPENGLRENDERER_H
|