Retrograded to OpenGL 3.0 functions
This commit is contained in:
parent
39789aea3f
commit
8098482d50
6 changed files with 52 additions and 38 deletions
|
@ -1,6 +1,6 @@
|
|||
#include "OpenGLRenderer.h"
|
||||
|
||||
#include <QOpenGLFunctions_3_2_Core>
|
||||
#include OPENGL_FUNCTIONS_INCLUDE
|
||||
#include "CameraDefinition.h"
|
||||
#include "OpenGLSharedState.h"
|
||||
#include "OpenGLSkybox.h"
|
||||
|
@ -9,7 +9,9 @@
|
|||
OpenGLRenderer::OpenGLRenderer(Scenery* scenery):
|
||||
SoftwareRenderer(scenery)
|
||||
{
|
||||
functions = new QOpenGLFunctions_3_2_Core();
|
||||
ready = false;
|
||||
|
||||
functions = new OpenGLFunctions();
|
||||
shared_state = new OpenGLSharedState();
|
||||
|
||||
skybox = new OpenGLSkybox(this);
|
||||
|
@ -27,50 +29,58 @@ OpenGLRenderer::~OpenGLRenderer()
|
|||
|
||||
void OpenGLRenderer::initialize()
|
||||
{
|
||||
// TODO Check return value
|
||||
functions->initializeOpenGLFunctions();
|
||||
ready = functions->initializeOpenGLFunctions();
|
||||
|
||||
functions->glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
if (ready)
|
||||
{
|
||||
functions->glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
functions->glDisable(GL_LIGHTING);
|
||||
functions->glDisable(GL_LIGHTING);
|
||||
|
||||
functions->glFrontFace(GL_CCW);
|
||||
functions->glCullFace(GL_BACK);
|
||||
functions->glEnable(GL_CULL_FACE);
|
||||
functions->glFrontFace(GL_CCW);
|
||||
functions->glCullFace(GL_BACK);
|
||||
functions->glEnable(GL_CULL_FACE);
|
||||
|
||||
functions->glDepthFunc(GL_LESS);
|
||||
functions->glDepthMask(1);
|
||||
functions->glEnable(GL_DEPTH_TEST);
|
||||
functions->glDepthFunc(GL_LESS);
|
||||
functions->glDepthMask(1);
|
||||
functions->glEnable(GL_DEPTH_TEST);
|
||||
|
||||
functions->glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
functions->glEnable(GL_LINE_SMOOTH);
|
||||
functions->glLineWidth(1.0);
|
||||
functions->glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
functions->glEnable(GL_LINE_SMOOTH);
|
||||
functions->glLineWidth(1.0);
|
||||
|
||||
functions->glDisable(GL_FOG);
|
||||
functions->glDisable(GL_FOG);
|
||||
|
||||
functions->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
functions->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
prepare();
|
||||
prepare();
|
||||
|
||||
skybox->initialize();
|
||||
skybox->updateScenery();
|
||||
skybox->initialize();
|
||||
skybox->updateScenery();
|
||||
|
||||
water->initialize();
|
||||
water->updateScenery();
|
||||
water->initialize();
|
||||
water->updateScenery();
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLRenderer::resize(int width, int height)
|
||||
{
|
||||
functions->glViewport(0, 0, width, height);
|
||||
if (ready)
|
||||
{
|
||||
functions->glViewport(0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLRenderer::paint()
|
||||
{
|
||||
functions->glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
functions->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
if (ready)
|
||||
{
|
||||
functions->glClearColor(0.0, 0.0, 0.0, 0.0);
|
||||
functions->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
skybox->render();
|
||||
water->render();
|
||||
skybox->render();
|
||||
water->render();
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLRenderer::cameraChangeEvent(CameraDefinition *camera)
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
#include "SoftwareRenderer.h"
|
||||
|
||||
class QOpenGLFunctions_3_2_Core;
|
||||
|
||||
namespace paysages {
|
||||
namespace opengl {
|
||||
|
||||
|
@ -25,14 +23,16 @@ public:
|
|||
|
||||
void cameraChangeEvent(CameraDefinition* camera);
|
||||
|
||||
inline QOpenGLFunctions_3_2_Core* getOpenGlFunctions() const {return functions;}
|
||||
inline OpenGLFunctions* getOpenGlFunctions() const {return functions;}
|
||||
inline OpenGLSharedState* getSharedState() const {return shared_state;}
|
||||
|
||||
virtual double getPrecision(const Vector3 &location) override;
|
||||
virtual Color applyMediumTraversal(Vector3 location, Color color) override;
|
||||
|
||||
private:
|
||||
QOpenGLFunctions_3_2_Core* functions;
|
||||
bool ready;
|
||||
|
||||
OpenGLFunctions* functions;
|
||||
OpenGLSharedState* shared_state;
|
||||
|
||||
OpenGLSkybox* skybox;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "OpenGLShaderProgram.h"
|
||||
|
||||
#include OPENGL_FUNCTIONS_INCLUDE
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLFunctions_3_2_Core>
|
||||
#include <QDir>
|
||||
#include "OpenGLRenderer.h"
|
||||
#include "OpenGLSharedState.h"
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <QString>
|
||||
|
||||
class QOpenGLShaderProgram;
|
||||
class QOpenGLFunctions_3_2_Core;
|
||||
|
||||
namespace paysages {
|
||||
namespace opengl {
|
||||
|
@ -39,7 +38,7 @@ private:
|
|||
|
||||
QString name;
|
||||
QOpenGLShaderProgram* program;
|
||||
QOpenGLFunctions_3_2_Core* functions;
|
||||
OpenGLFunctions* functions;
|
||||
|
||||
std::string source_vertex;
|
||||
std::string source_fragment;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "OpenGLVariable.h"
|
||||
|
||||
#include <cassert>
|
||||
#include OPENGL_FUNCTIONS_INCLUDE
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLFunctions_3_2_Core>
|
||||
#include <cassert>
|
||||
#include "OpenGLRenderer.h"
|
||||
#include "OpenGLShaderProgram.h"
|
||||
#include "Vector3.h"
|
||||
|
@ -22,7 +22,7 @@ OpenGLVariable::OpenGLVariable(const std::string &name):
|
|||
void OpenGLVariable::apply(OpenGLShaderProgram *program, int &texture_unit)
|
||||
{
|
||||
QOpenGLShaderProgram* pr = program->getProgram();
|
||||
QOpenGLFunctions_3_2_Core* functions = program->getRenderer()->getOpenGlFunctions();
|
||||
OpenGLFunctions* functions = program->getRenderer()->getOpenGlFunctions();
|
||||
|
||||
if (texture_toupload)
|
||||
{
|
||||
|
@ -133,7 +133,7 @@ void OpenGLVariable::set(const Color &color)
|
|||
|
||||
void OpenGLVariable::uploadTexture(OpenGLRenderer* renderer)
|
||||
{
|
||||
QOpenGLFunctions_3_2_Core* functions = renderer->getOpenGlFunctions();
|
||||
OpenGLFunctions* functions = renderer->getOpenGlFunctions();
|
||||
|
||||
assert(type == TYPE_TEXTURE_2D or type == TYPE_TEXTURE_3D or type == TYPE_TEXTURE_4D);
|
||||
|
||||
|
|
|
@ -25,4 +25,9 @@ namespace opengl {
|
|||
}
|
||||
using namespace paysages::opengl;
|
||||
|
||||
//#define OpenGLFunctions QOpenGLFunctions_3_2_Core
|
||||
#define OpenGLFunctions QOpenGLFunctions_3_0
|
||||
#define OPENGL_FUNCTIONS_INCLUDE <OpenGLFunctions>
|
||||
class OpenGLFunctions;
|
||||
|
||||
#endif // OPENGL_GLOBAL_H
|
||||
|
|
Loading…
Reference in a new issue