Extracted opengl "explorer" in render/opengl library
This commit is contained in:
parent
b5c50d16d4
commit
cf75e86be6
20 changed files with 242 additions and 177 deletions
|
@ -4,6 +4,9 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include "WidgetExplorer.h"
|
||||||
|
#include "rendering/camera.h"
|
||||||
|
#include "rendering/renderer.h"
|
||||||
|
|
||||||
DialogExplorer::DialogExplorer(QWidget* parent, CameraDefinition* camera, bool camera_validable, Renderer* renderer) : QDialog(parent)
|
DialogExplorer::DialogExplorer(QWidget* parent, CameraDefinition* camera, bool camera_validable, Renderer* renderer) : QDialog(parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
#ifndef _PAYSAGES_QT_DIALOGEXPLORER_H_
|
#ifndef _PAYSAGES_QT_DIALOGEXPLORER_H_
|
||||||
#define _PAYSAGES_QT_DIALOGEXPLORER_H_
|
#define _PAYSAGES_QT_DIALOGEXPLORER_H_
|
||||||
|
|
||||||
|
#include "editing_global.h"
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include "widgetexplorer.h"
|
|
||||||
#include "rendering/camera.h"
|
class CameraDefinition;
|
||||||
|
class Renderer;
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace opengl {
|
||||||
|
class WidgetExplorer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class DialogExplorer : public QDialog
|
class DialogExplorer : public QDialog
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,6 @@ INCLUDEPATH += $$PWD/..
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
terrain/widgetheightmap.h \
|
terrain/widgetheightmap.h \
|
||||||
widgetexplorer.h \
|
|
||||||
widgetcurveeditor.h \
|
widgetcurveeditor.h \
|
||||||
tools.h \
|
tools.h \
|
||||||
previewosd.h \
|
previewosd.h \
|
||||||
|
@ -35,8 +34,6 @@ HEADERS += \
|
||||||
formrender.h \
|
formrender.h \
|
||||||
formclouds.h \
|
formclouds.h \
|
||||||
formatmosphere.h \
|
formatmosphere.h \
|
||||||
explorerchunkterrain.h \
|
|
||||||
explorerchunksky.h \
|
|
||||||
dialogrender.h \
|
dialogrender.h \
|
||||||
dialognoise.h \
|
dialognoise.h \
|
||||||
dialoglayers.h \
|
dialoglayers.h \
|
||||||
|
@ -47,7 +44,6 @@ HEADERS += \
|
||||||
baseinput.h \
|
baseinput.h \
|
||||||
baseformlayer.h \
|
baseformlayer.h \
|
||||||
baseform.h \
|
baseform.h \
|
||||||
baseexplorerchunk.h \
|
|
||||||
terrain/dialogterrainpainting.h \
|
terrain/dialogterrainpainting.h \
|
||||||
common/widgetglobalformbuttons.h \
|
common/widgetglobalformbuttons.h \
|
||||||
terrain/paintingbrush.h \
|
terrain/paintingbrush.h \
|
||||||
|
@ -73,7 +69,6 @@ HEADERS += \
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
terrain/widgetheightmap.cpp \
|
terrain/widgetheightmap.cpp \
|
||||||
widgetexplorer.cpp \
|
|
||||||
widgetcurveeditor.cpp \
|
widgetcurveeditor.cpp \
|
||||||
tools.cpp \
|
tools.cpp \
|
||||||
previewosd.cpp \
|
previewosd.cpp \
|
||||||
|
@ -95,8 +90,6 @@ SOURCES += \
|
||||||
formrender.cpp \
|
formrender.cpp \
|
||||||
formclouds.cpp \
|
formclouds.cpp \
|
||||||
formatmosphere.cpp \
|
formatmosphere.cpp \
|
||||||
explorerchunkterrain.cpp \
|
|
||||||
explorerchunksky.cpp \
|
|
||||||
dialogrender.cpp \
|
dialogrender.cpp \
|
||||||
dialognoise.cpp \
|
dialognoise.cpp \
|
||||||
dialoglayers.cpp \
|
dialoglayers.cpp \
|
||||||
|
@ -107,7 +100,6 @@ SOURCES += \
|
||||||
baseinput.cpp \
|
baseinput.cpp \
|
||||||
baseformlayer.cpp \
|
baseformlayer.cpp \
|
||||||
baseform.cpp \
|
baseform.cpp \
|
||||||
baseexplorerchunk.cpp \
|
|
||||||
terrain/dialogterrainpainting.cpp \
|
terrain/dialogterrainpainting.cpp \
|
||||||
common/widgetglobalformbuttons.cpp \
|
common/widgetglobalformbuttons.cpp \
|
||||||
terrain/paintingbrush.cpp \
|
terrain/paintingbrush.cpp \
|
||||||
|
@ -157,12 +149,6 @@ else:unix: LIBS += -L$$OUT_PWD/../basics/ -lpaysages_basics
|
||||||
INCLUDEPATH += $$PWD/../basics
|
INCLUDEPATH += $$PWD/../basics
|
||||||
DEPENDPATH += $$PWD/../basics
|
DEPENDPATH += $$PWD/../basics
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../exploring/release/ -lpaysages_exploring
|
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../exploring/debug/ -lpaysages_exploring
|
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../exploring/ -lpaysages_exploring
|
|
||||||
INCLUDEPATH += $$PWD/../exploring
|
|
||||||
DEPENDPATH += $$PWD/../exploring
|
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../rendering/release/ -lpaysages_rendering
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../rendering/release/ -lpaysages_rendering
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../rendering/debug/ -lpaysages_rendering
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../rendering/debug/ -lpaysages_rendering
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../rendering/ -lpaysages_rendering
|
else:unix: LIBS += -L$$OUT_PWD/../rendering/ -lpaysages_rendering
|
||||||
|
@ -174,3 +160,9 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../definition/debug
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../definition/ -lpaysages_definition
|
else:unix: LIBS += -L$$OUT_PWD/../definition/ -lpaysages_definition
|
||||||
INCLUDEPATH += $$PWD/../definition
|
INCLUDEPATH += $$PWD/../definition
|
||||||
DEPENDPATH += $$PWD/../definition
|
DEPENDPATH += $$PWD/../definition
|
||||||
|
|
||||||
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../render/opengl/release/ -lpaysages_render_opengl
|
||||||
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../render/opengl/debug/ -lpaysages_render_opengl
|
||||||
|
else:unix: LIBS += -L$$OUT_PWD/../render/opengl/ -lpaysages_render_opengl
|
||||||
|
INCLUDEPATH += $$PWD/../render/opengl
|
||||||
|
DEPENDPATH += $$PWD/../render/opengl
|
||||||
|
|
|
@ -6,9 +6,11 @@ namespace paysages
|
||||||
namespace system {}
|
namespace system {}
|
||||||
namespace basics {}
|
namespace basics {}
|
||||||
namespace definition {}
|
namespace definition {}
|
||||||
|
namespace opengl {}
|
||||||
}
|
}
|
||||||
using namespace paysages::system;
|
using namespace paysages::system;
|
||||||
using namespace paysages::basics;
|
using namespace paysages::basics;
|
||||||
using namespace paysages::definition;
|
using namespace paysages::definition;
|
||||||
|
using namespace paysages::opengl;
|
||||||
|
|
||||||
#endif // EDITING_GLOBAL_H
|
#endif // EDITING_GLOBAL_H
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
QT += opengl
|
|
||||||
|
|
||||||
TEMPLATE = lib
|
|
||||||
TARGET = paysages_exploring
|
|
||||||
|
|
||||||
DEFINES += EXPLORING_LIBRARY
|
|
||||||
CONFIG(release, debug|release): DEFINES += NDEBUG
|
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/..
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
main.cpp
|
|
||||||
|
|
||||||
HEADERS += main.h \
|
|
||||||
exploring_global.h
|
|
||||||
|
|
||||||
unix:!symbian {
|
|
||||||
maemo5 {
|
|
||||||
target.path = /opt/usr/lib
|
|
||||||
} else {
|
|
||||||
target.path = /usr/lib
|
|
||||||
}
|
|
||||||
INSTALLS += target
|
|
||||||
}
|
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../rendering/release/ -lpaysages_rendering
|
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../rendering/debug/ -lpaysages_rendering
|
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../rendering/ -lpaysages_rendering
|
|
||||||
INCLUDEPATH += $$PWD/../rendering
|
|
||||||
DEPENDPATH += $$PWD/../rendering
|
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../system/release/ -lpaysages_system
|
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../system/debug/ -lpaysages_system
|
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../system/ -lpaysages_system
|
|
||||||
INCLUDEPATH += $$PWD/../system
|
|
||||||
DEPENDPATH += $$PWD/../system
|
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../definition/release/ -lpaysages_definition
|
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../definition/debug/ -lpaysages_definition
|
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../definition/ -lpaysages_definition
|
|
||||||
INCLUDEPATH += $$PWD/../definition
|
|
||||||
DEPENDPATH += $$PWD/../definition
|
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../basics/release/ -lpaysages_basics
|
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../basics/debug/ -lpaysages_basics
|
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../basics/ -lpaysages_basics
|
|
||||||
INCLUDEPATH += $$PWD/../basics
|
|
||||||
DEPENDPATH += $$PWD/../basics
|
|
|
@ -1,26 +0,0 @@
|
||||||
#ifndef EXPLORING_GLOBAL_H
|
|
||||||
#define EXPLORING_GLOBAL_H
|
|
||||||
|
|
||||||
/* Shared object helpers */
|
|
||||||
#ifdef __cplusplus
|
|
||||||
# include <QtCore/qglobal.h>
|
|
||||||
#else
|
|
||||||
# if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
|
||||||
# define Q_DECL_EXPORT __declspec(dllexport)
|
|
||||||
# define Q_DECL_IMPORT __declspec(dllimport)
|
|
||||||
# else
|
|
||||||
# define Q_DECL_EXPORT
|
|
||||||
# define Q_DECL_IMPORT
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if defined(EXPLORING_LIBRARY)
|
|
||||||
# define EXPLORINGSHARED_EXPORT Q_DECL_EXPORT
|
|
||||||
#else
|
|
||||||
# define EXPLORINGSHARED_EXPORT Q_DECL_IMPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Namespace using */
|
|
||||||
|
|
||||||
/* Global import */
|
|
||||||
|
|
||||||
#endif // EXPLORING_GLOBAL_H
|
|
|
@ -1,24 +0,0 @@
|
||||||
#ifndef _PAYSAGES_EXPLORING_MAIN_H_
|
|
||||||
#define _PAYSAGES_EXPLORING_MAIN_H_
|
|
||||||
|
|
||||||
#include "exploring_global.h"
|
|
||||||
|
|
||||||
#include "rendering/renderer.h"
|
|
||||||
#include "rendering/camera.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EXPLORINGSHARED_EXPORT void exploringInit();
|
|
||||||
EXPLORINGSHARED_EXPORT void exploringSetViewPort(int width, int height, CameraDefinition* camera);
|
|
||||||
EXPLORINGSHARED_EXPORT void exploringRenderFrame(Renderer* renderer);
|
|
||||||
|
|
||||||
EXPLORINGSHARED_EXPORT void exploringStartStandAlone();
|
|
||||||
EXPLORINGSHARED_EXPORT void exploringInterruptStandAlone();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -6,17 +6,8 @@ SUBDIRS = \
|
||||||
basics \
|
basics \
|
||||||
definition \
|
definition \
|
||||||
rendering \
|
rendering \
|
||||||
exploring \
|
render/opengl \
|
||||||
editing \
|
editing \
|
||||||
controlling
|
controlling
|
||||||
|
|
||||||
#unix:SUBDIRS += testing tests
|
#unix:SUBDIRS += testing tests
|
||||||
|
|
||||||
basics.depends = system
|
|
||||||
definition.depends = basics
|
|
||||||
rendering.depends = definition
|
|
||||||
exploring.depends = rendering
|
|
||||||
editing.depends = exploring rendering
|
|
||||||
controlling.depends = rendering
|
|
||||||
#unix:testing.depends = rendering
|
|
||||||
unix:tests.depends = rendering
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#include "baseexplorerchunk.h"
|
#include "BaseExplorerChunk.h"
|
||||||
|
|
||||||
|
#include <QImage>
|
||||||
|
#include <QGLWidget>
|
||||||
|
|
||||||
#ifndef GL_CLAMP_TO_EDGE
|
#ifndef GL_CLAMP_TO_EDGE
|
||||||
#define GL_CLAMP_TO_EDGE 0x812F
|
#define GL_CLAMP_TO_EDGE 0x812F
|
|
@ -1,10 +1,18 @@
|
||||||
#ifndef _PAYSAGES_QT_BASEEXPLORERCHUNK_H_
|
#ifndef BASEEXPLORERCHUNK_H
|
||||||
#define _PAYSAGES_QT_BASEEXPLORERCHUNK_H_
|
#define BASEEXPLORERCHUNK_H
|
||||||
|
|
||||||
|
#include "opengl_global.h"
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QImage>
|
#include "rendering/tools/color.h"
|
||||||
#include <QGLWidget>
|
|
||||||
#include "rendering/renderer.h"
|
class QImage;
|
||||||
|
class QGLWidget;
|
||||||
|
class Renderer;
|
||||||
|
class ColorProfile;
|
||||||
|
class CameraDefinition;
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace opengl {
|
||||||
|
|
||||||
class BaseExplorerChunk
|
class BaseExplorerChunk
|
||||||
{
|
{
|
||||||
|
@ -40,10 +48,13 @@ private:
|
||||||
bool _reset_needed;
|
bool _reset_needed;
|
||||||
|
|
||||||
QImage* _texture;
|
QImage* _texture;
|
||||||
GLuint _texture_id;
|
unsigned int _texture_id;
|
||||||
bool _texture_changed;
|
bool _texture_changed;
|
||||||
int _texture_current_size;
|
int _texture_current_size;
|
||||||
int _texture_max_size;
|
int _texture_max_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BASEEXPLORERCHUNK_H
|
|
@ -1,8 +1,9 @@
|
||||||
#include "explorerchunksky.h"
|
#include "ExplorerChunkSky.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
#include "baseexplorerchunk.h"
|
#include "rendering/renderer.h"
|
||||||
#include "rendering/camera.h"
|
#include "rendering/camera.h"
|
||||||
|
#include <GL/gl.h>
|
||||||
|
|
||||||
ExplorerChunkSky::ExplorerChunkSky(Renderer* renderer, double size, SkyboxOrientation orientation) : BaseExplorerChunk(renderer)
|
ExplorerChunkSky::ExplorerChunkSky(Renderer* renderer, double size, SkyboxOrientation orientation) : BaseExplorerChunk(renderer)
|
||||||
{
|
{
|
|
@ -1,10 +1,13 @@
|
||||||
#ifndef _PAYSAGES_QT_EXPLORERCHUNKSKY_H_
|
#ifndef EXPLORERCHUNKSKY_H
|
||||||
#define _PAYSAGES_QT_EXPLORERCHUNKSKY_H_
|
#define EXPLORERCHUNKSKY_H
|
||||||
|
|
||||||
#include "baseexplorerchunk.h"
|
#include "opengl_global.h"
|
||||||
#include "rendering/renderer.h"
|
#include "BaseExplorerChunk.h"
|
||||||
#include "rendering/tools/euclid.h"
|
#include "rendering/tools/euclid.h"
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace opengl {
|
||||||
|
|
||||||
enum SkyboxOrientation
|
enum SkyboxOrientation
|
||||||
{
|
{
|
||||||
SKYBOX_NORTH,
|
SKYBOX_NORTH,
|
||||||
|
@ -31,4 +34,7 @@ private:
|
||||||
Vector3 _center;
|
Vector3 _center;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // EXPLORERCHUNKSKY_H
|
|
@ -1,8 +1,9 @@
|
||||||
#include "explorerchunkterrain.h"
|
#include "ExplorerChunkTerrain.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
#include "baseexplorerchunk.h"
|
#include <GL/gl.h>
|
||||||
#include "rendering/camera.h"
|
#include "rendering/camera.h"
|
||||||
|
#include "rendering/renderer.h"
|
||||||
|
|
||||||
ExplorerChunkTerrain::ExplorerChunkTerrain(Renderer* renderer, double x, double z, double size, int nbchunks, double water_height) : BaseExplorerChunk(renderer)
|
ExplorerChunkTerrain::ExplorerChunkTerrain(Renderer* renderer, double x, double z, double size, int nbchunks, double water_height) : BaseExplorerChunk(renderer)
|
||||||
{
|
{
|
|
@ -1,10 +1,12 @@
|
||||||
#ifndef _PAYSAGES_QT_EXPLORERCHUNKTERRAIN_H_
|
#ifndef EXPLORERCHUNKTERRAIN_H
|
||||||
#define _PAYSAGES_QT_EXPLORERCHUNKTERRAIN_H_
|
#define EXPLORERCHUNKTERRAIN_H
|
||||||
|
|
||||||
#include "baseexplorerchunk.h"
|
#include "BaseExplorerChunk.h"
|
||||||
#include "rendering/renderer.h"
|
|
||||||
#include "rendering/tools/euclid.h"
|
#include "rendering/tools/euclid.h"
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace opengl {
|
||||||
|
|
||||||
class ExplorerChunkTerrain:public BaseExplorerChunk
|
class ExplorerChunkTerrain:public BaseExplorerChunk
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -37,4 +39,7 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // EXPLORERCHUNKTERRAIN_H
|
|
@ -1,10 +1,31 @@
|
||||||
#include "main.h"
|
#include "OpenGLRenderer.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
#include "GL/gl.h"
|
#include <GL/gl.h>
|
||||||
#include "GL/glu.h"
|
#include <GL/glu.h>
|
||||||
|
#include "Scenery.h"
|
||||||
|
#include "renderer.h"
|
||||||
|
|
||||||
void exploringInit()
|
OpenGLRenderer::OpenGLRenderer(Scenery* scenery):
|
||||||
|
scenery(scenery)
|
||||||
|
{
|
||||||
|
if (scenery)
|
||||||
|
{
|
||||||
|
renderer = rendererCreate();
|
||||||
|
// TODO Bind scenery to renderer
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
renderer = sceneryCreateStandardRenderer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenGLRenderer::~OpenGLRenderer()
|
||||||
|
{
|
||||||
|
rendererDelete(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenGLRenderer::initialize()
|
||||||
{
|
{
|
||||||
glClearColor(0.0, 0.0, 0.0, 0.0);
|
glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||||
|
|
||||||
|
@ -27,7 +48,7 @@ void exploringInit()
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exploringSetViewPort(int width, int height, CameraDefinition* camera)
|
void OpenGLRenderer::resize(int width, int height)
|
||||||
{
|
{
|
||||||
CameraPerspective perspective;
|
CameraPerspective perspective;
|
||||||
|
|
||||||
|
@ -35,20 +56,13 @@ void exploringSetViewPort(int width, int height, CameraDefinition* camera)
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
perspective = cameraGetPerspective(camera);
|
perspective = cameraGetPerspective(renderer->render_camera);
|
||||||
gluPerspective(perspective.yfov * 180.0 / M_PI, perspective.xratio, perspective.znear, perspective.zfar);
|
gluPerspective(perspective.yfov * 180.0 / M_PI, perspective.xratio, perspective.znear, perspective.zfar);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void exploringRenderFrame(Renderer* renderer)
|
void OpenGLRenderer::paint()
|
||||||
{
|
{
|
||||||
}
|
|
||||||
|
|
||||||
void exploringStartStandAlone()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void exploringInterruptStandAlone()
|
|
||||||
{
|
|
||||||
}
|
}
|
33
src/render/opengl/OpenGLRenderer.h
Normal file
33
src/render/opengl/OpenGLRenderer.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#ifndef OPENGLRENDERER_H
|
||||||
|
#define OPENGLRENDERER_H
|
||||||
|
|
||||||
|
#include "opengl_global.h"
|
||||||
|
|
||||||
|
class Scenery;
|
||||||
|
class Renderer;
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace opengl {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Scenery renderer in an OpenGL context.
|
||||||
|
*/
|
||||||
|
class OPENGLSHARED_EXPORT OpenGLRenderer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OpenGLRenderer(Scenery* scenery=0);
|
||||||
|
~OpenGLRenderer();
|
||||||
|
|
||||||
|
void initialize();
|
||||||
|
void resize(int width, int height);
|
||||||
|
void paint();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Scenery* scenery;
|
||||||
|
Renderer* renderer;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // OPENGLRENDERER_H
|
|
@ -1,4 +1,4 @@
|
||||||
#include "widgetexplorer.h"
|
#include "WidgetExplorer.h"
|
||||||
|
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
@ -7,11 +7,10 @@
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include "Scenery.h"
|
#include "Scenery.h"
|
||||||
|
#include "OpenGLRenderer.h"
|
||||||
#include "rendering/tools/euclid.h"
|
#include "rendering/tools/euclid.h"
|
||||||
#include "../exploring/main.h"
|
#include "ExplorerChunkSky.h"
|
||||||
#include "explorerchunkterrain.h"
|
#include "ExplorerChunkTerrain.h"
|
||||||
#include "explorerchunksky.h"
|
|
||||||
#include "tools.h"
|
|
||||||
|
|
||||||
class ChunkMaintenanceThread : public QThread
|
class ChunkMaintenanceThread : public QThread
|
||||||
{
|
{
|
||||||
|
@ -86,6 +85,7 @@ QGLWidget(parent)
|
||||||
_renderer = sceneryCreateStandardRenderer();
|
_renderer = sceneryCreateStandardRenderer();
|
||||||
_renderer_created = true;
|
_renderer_created = true;
|
||||||
}
|
}
|
||||||
|
_opengl_renderer = new OpenGLRenderer(NULL);
|
||||||
_renderer->render_quality = 3;
|
_renderer->render_quality = 3;
|
||||||
_renderer->customData[2] = _base_camera;
|
_renderer->customData[2] = _base_camera;
|
||||||
_renderer->getCameraLocation = _getCameraLocation;
|
_renderer->getCameraLocation = _getCameraLocation;
|
||||||
|
@ -117,6 +117,7 @@ WidgetExplorer::~WidgetExplorer()
|
||||||
{
|
{
|
||||||
rendererDelete(_renderer);
|
rendererDelete(_renderer);
|
||||||
}
|
}
|
||||||
|
delete _opengl_renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetExplorer::startRendering()
|
void WidgetExplorer::startRendering()
|
||||||
|
@ -379,13 +380,13 @@ void WidgetExplorer::timerEvent(QTimerEvent*)
|
||||||
|
|
||||||
void WidgetExplorer::initializeGL()
|
void WidgetExplorer::initializeGL()
|
||||||
{
|
{
|
||||||
exploringInit();
|
_opengl_renderer->initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetExplorer::resizeGL(int w, int h)
|
void WidgetExplorer::resizeGL(int w, int h)
|
||||||
{
|
{
|
||||||
cameraSetRenderSize(_current_camera, w, h);
|
cameraSetRenderSize(_current_camera, w, h);
|
||||||
exploringSetViewPort(w, h, _current_camera);
|
_opengl_renderer->resize(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetExplorer::paintGL()
|
void WidgetExplorer::paintGL()
|
||||||
|
@ -455,6 +456,6 @@ void WidgetExplorer::paintGL()
|
||||||
|
|
||||||
while ((error_code = glGetError()) != GL_NO_ERROR)
|
while ((error_code = glGetError()) != GL_NO_ERROR)
|
||||||
{
|
{
|
||||||
logDebug(QString("[OpenGL] ERROR : ") + (const char*) gluErrorString(error_code));
|
qDebug("[OpenGL] ERROR : %s", (const char*)gluErrorString(error_code));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,18 @@
|
||||||
#ifndef _PAYSAGES_QT_WIDGETEXPLORER_H_
|
#ifndef WIDGETEXPLORER_H
|
||||||
#define _PAYSAGES_QT_WIDGETEXPLORER_H_
|
#define WIDGETEXPLORER_H
|
||||||
|
|
||||||
|
#include "opengl_global.h"
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
#include "baseexplorerchunk.h"
|
#include <QMutex>
|
||||||
#include "rendering/camera.h"
|
|
||||||
#include "rendering/renderer.h"
|
class CameraDefinition;
|
||||||
|
class Renderer;
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace opengl {
|
||||||
|
|
||||||
|
class OpenGLRenderer;
|
||||||
|
class BaseExplorerChunk;
|
||||||
|
|
||||||
class WidgetExplorer : public QGLWidget
|
class WidgetExplorer : public QGLWidget
|
||||||
{
|
{
|
||||||
|
@ -37,6 +45,7 @@ private:
|
||||||
CameraDefinition* _current_camera;
|
CameraDefinition* _current_camera;
|
||||||
CameraDefinition* _base_camera;
|
CameraDefinition* _base_camera;
|
||||||
|
|
||||||
|
OpenGLRenderer* _opengl_renderer;
|
||||||
Renderer* _renderer;
|
Renderer* _renderer;
|
||||||
bool _renderer_created;
|
bool _renderer_created;
|
||||||
bool _inited;
|
bool _inited;
|
||||||
|
@ -54,4 +63,7 @@ private:
|
||||||
int _last_mouse_y;
|
int _last_mouse_y;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // WIDGETEXPLORER_H
|
63
src/render/opengl/opengl.pro
Normal file
63
src/render/opengl/opengl.pro
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2013-11-04T11:54:27
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += opengl
|
||||||
|
|
||||||
|
TARGET = paysages_render_opengl
|
||||||
|
TEMPLATE = lib
|
||||||
|
|
||||||
|
DEFINES += OPENGL_LIBRARY
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
OpenGLRenderer.cpp \
|
||||||
|
BaseExplorerChunk.cpp \
|
||||||
|
ExplorerChunkSky.cpp \
|
||||||
|
ExplorerChunkTerrain.cpp \
|
||||||
|
WidgetExplorer.cpp
|
||||||
|
|
||||||
|
HEADERS +=\
|
||||||
|
opengl_global.h \
|
||||||
|
OpenGLRenderer.h \
|
||||||
|
BaseExplorerChunk.h \
|
||||||
|
ExplorerChunkSky.h \
|
||||||
|
ExplorerChunkTerrain.h \
|
||||||
|
WidgetExplorer.h
|
||||||
|
|
||||||
|
unix:!symbian {
|
||||||
|
maemo5 {
|
||||||
|
target.path = /opt/usr/lib
|
||||||
|
} else {
|
||||||
|
target.path = /usr/lib
|
||||||
|
}
|
||||||
|
INSTALLS += target
|
||||||
|
}
|
||||||
|
|
||||||
|
# TEMP
|
||||||
|
INCLUDEPATH += $$PWD/../..
|
||||||
|
|
||||||
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../system/release/ -lpaysages_system
|
||||||
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../system/debug/ -lpaysages_system
|
||||||
|
else:unix: LIBS += -L$$OUT_PWD/../../system/ -lpaysages_system
|
||||||
|
INCLUDEPATH += $$PWD/../../system
|
||||||
|
DEPENDPATH += $$PWD/../../system
|
||||||
|
|
||||||
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../basics/release/ -lpaysages_basics
|
||||||
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../basics/debug/ -lpaysages_basics
|
||||||
|
else:unix: LIBS += -L$$OUT_PWD/../../basics/ -lpaysages_basics
|
||||||
|
INCLUDEPATH += $$PWD/../../basics
|
||||||
|
DEPENDPATH += $$PWD/../../basics
|
||||||
|
|
||||||
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../definition/release/ -lpaysages_definition
|
||||||
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../definition/debug/ -lpaysages_definition
|
||||||
|
else:unix: LIBS += -L$$OUT_PWD/../../definition/ -lpaysages_definition
|
||||||
|
INCLUDEPATH += $$PWD/../../definition
|
||||||
|
DEPENDPATH += $$PWD/../../definition
|
||||||
|
|
||||||
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../rendering/release/ -lpaysages_rendering
|
||||||
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../rendering/debug/ -lpaysages_rendering
|
||||||
|
else:unix: LIBS += -L$$OUT_PWD/../../rendering/ -lpaysages_rendering
|
||||||
|
INCLUDEPATH += $$PWD/../../rendering
|
||||||
|
DEPENDPATH += $$PWD/../../rendering
|
17
src/render/opengl/opengl_global.h
Normal file
17
src/render/opengl/opengl_global.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef OPENGL_GLOBAL_H
|
||||||
|
#define OPENGL_GLOBAL_H
|
||||||
|
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
#if defined(OPENGL_LIBRARY)
|
||||||
|
# define OPENGLSHARED_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define OPENGLSHARED_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace paysages {
|
||||||
|
namespace opengl {}
|
||||||
|
}
|
||||||
|
using namespace paysages::opengl;
|
||||||
|
|
||||||
|
#endif // OPENGL_GLOBAL_H
|
Loading…
Reference in a new issue