Update the BasicExample to use OpenGL 3

The example now uses OpenGL 3 features like Vertex Array Objects and uses
no immediate mode stuff. Qt5 is used for some features like matrices and
shaders.

There is now no dependency on GLEW either.
This commit is contained in:
Matt Williams
2014-03-19 21:26:04 +00:00
parent 868fbb84a0
commit ac16dfd325
4 changed files with 158 additions and 102 deletions

View File

@ -26,9 +26,12 @@ distribution.
#include "PolyVoxCore/SurfaceMesh.h"
#include "glew/glew.h"
#include <QOpenGLFunctions_3_1>
#include <QGLWidget>
#include <QOpenGLShaderProgram>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
class OpenGLWidget : public QGLWidget
{
@ -40,8 +43,8 @@ public:
void mouseMoveEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
//Convert a SrfaceMesh to OpenGL index/vertex buffers
void setSurfaceMeshToRender(const PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal>& surfaceMesh);
//Convert a SurfaceMesh to OpenGL index/vertex buffers
void setSurfaceMeshToRender(const PolyVox::SurfaceMesh<PolyVox::PositionMaterial>& surfaceMesh);
protected:
//Qt OpenGL functions
@ -51,11 +54,13 @@ protected:
private:
//Index/vertex buffer data
GLuint m_uBeginIndex;
GLuint m_uEndIndex;
GLuint noOfIndices;
GLuint indexBuffer;
GLuint vertexBuffer;
GLuint vertexArrayObject;
QOpenGLShaderProgram shader;
QOpenGLFunctions_3_1* gl;
//Mouse data
QPoint m_LastFrameMousePos;