Switched from QOpenGLFunctions_3_1 to QOpenGLFunctions. This seems to require not using vertex arrays, which needs further investigation.

This commit is contained in:
David Williams 2014-03-25 22:49:59 +01:00
parent 19387fd62e
commit a78508a79f
3 changed files with 9 additions and 13 deletions

View File

@ -46,7 +46,7 @@ ADD_EXECUTABLE(BasicExample ${SRC_FILES})
IF(MSVC) IF(MSVC)
SET_TARGET_PROPERTIES(BasicExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127") SET_TARGET_PROPERTIES(BasicExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127")
ENDIF(MSVC) ENDIF(MSVC)
TARGET_LINK_LIBRARIES(BasicExample Qt5::OpenGL PolyVoxCore) TARGET_LINK_LIBRARIES(BasicExample Qt5::OpenGL ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} PolyVoxCore)
SET_PROPERTY(TARGET BasicExample PROPERTY FOLDER "Examples") SET_PROPERTY(TARGET BasicExample PROPERTY FOLDER "Examples")
#Install - Only install the example in Windows #Install - Only install the example in Windows

View File

@ -21,8 +21,8 @@ void OpenGLWidget::setSurfaceMeshToRender(const PolyVox::SurfaceMesh<PositionMat
const auto& vecVertices = surfaceMesh.getVertices(); const auto& vecVertices = surfaceMesh.getVertices();
//Create the VAO for the mesh //Create the VAO for the mesh
glGenVertexArrays(1, &vertexArrayObject); //glGenVertexArrays(1, &vertexArrayObject);
glBindVertexArray(vertexArrayObject); //glBindVertexArray(vertexArrayObject);
//The GL_ARRAY_BUFFER will contain the list of vertex positions //The GL_ARRAY_BUFFER will contain the list of vertex positions
glGenBuffers(1, &vertexBuffer); glGenBuffers(1, &vertexBuffer);
@ -38,18 +38,14 @@ void OpenGLWidget::setSurfaceMeshToRender(const PolyVox::SurfaceMesh<PositionMat
glEnableVertexAttribArray(0); //We're talking about shader attribute '0' glEnableVertexAttribArray(0); //We're talking about shader attribute '0'
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(PositionMaterial), 0); //take the first 3 floats from every sizeof(decltype(vecVertices)::value_type) glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(PositionMaterial), 0); //take the first 3 floats from every sizeof(decltype(vecVertices)::value_type)
glBindVertexArray(0); //glBindVertexArray(0);
noOfIndices = vecIndices.size(); //Save this for the call to glDrawElements later noOfIndices = vecIndices.size(); //Save this for the call to glDrawElements later
} }
void OpenGLWidget::initializeGL() void OpenGLWidget::initializeGL()
{ {
if(!initializeOpenGLFunctions()) initializeOpenGLFunctions();
{
std::cerr << "Could not initialise OpenGL functions" << std::endl;
exit(EXIT_FAILURE);
}
//Print out some information about the OpenGL implementation. //Print out some information about the OpenGL implementation.
std::cout << "OpenGL Implementation Details:" << std::endl; std::cout << "OpenGL Implementation Details:" << std::endl;
@ -164,11 +160,11 @@ void OpenGLWidget::paintGL()
shader.setUniformValue("modelToWorldMatrix", modelToWorldMatrix); //Update to the latest camera matrix shader.setUniformValue("modelToWorldMatrix", modelToWorldMatrix); //Update to the latest camera matrix
glBindVertexArray(vertexArrayObject); //glBindVertexArray(vertexArrayObject);
glDrawElements(GL_TRIANGLES, noOfIndices, GL_UNSIGNED_INT, 0); glDrawElements(GL_TRIANGLES, noOfIndices, GL_UNSIGNED_INT, 0);
glBindVertexArray(0); //glBindVertexArray(0);
shader.release(); shader.release();

View File

@ -26,14 +26,14 @@ distribution.
#include "PolyVoxCore/SurfaceMesh.h" #include "PolyVoxCore/SurfaceMesh.h"
#include <QOpenGLFunctions_3_1> #include <QOpenGLFunctions>
#include <QGLWidget> #include <QGLWidget>
#include <QOpenGLShaderProgram> #include <QOpenGLShaderProgram>
#include <QOpenGLVertexArrayObject> #include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer> #include <QOpenGLBuffer>
class OpenGLWidget : public QGLWidget, protected QOpenGLFunctions_3_1 class OpenGLWidget : public QGLWidget, protected QOpenGLFunctions
{ {
public: public:
//Constructor //Constructor