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)
SET_TARGET_PROPERTIES(BasicExample PROPERTIES COMPILE_FLAGS "/W4 /wd4127")
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")
#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();
//Create the VAO for the mesh
glGenVertexArrays(1, &vertexArrayObject);
glBindVertexArray(vertexArrayObject);
//glGenVertexArrays(1, &vertexArrayObject);
//glBindVertexArray(vertexArrayObject);
//The GL_ARRAY_BUFFER will contain the list of vertex positions
glGenBuffers(1, &vertexBuffer);
@ -38,18 +38,14 @@ void OpenGLWidget::setSurfaceMeshToRender(const PolyVox::SurfaceMesh<PositionMat
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)
glBindVertexArray(0);
//glBindVertexArray(0);
noOfIndices = vecIndices.size(); //Save this for the call to glDrawElements later
}
void OpenGLWidget::initializeGL()
{
if(!initializeOpenGLFunctions())
{
std::cerr << "Could not initialise OpenGL functions" << std::endl;
exit(EXIT_FAILURE);
}
initializeOpenGLFunctions();
//Print out some information about the OpenGL implementation.
std::cout << "OpenGL Implementation Details:" << std::endl;
@ -164,11 +160,11 @@ void OpenGLWidget::paintGL()
shader.setUniformValue("modelToWorldMatrix", modelToWorldMatrix); //Update to the latest camera matrix
glBindVertexArray(vertexArrayObject);
//glBindVertexArray(vertexArrayObject);
glDrawElements(GL_TRIANGLES, noOfIndices, GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
//glBindVertexArray(0);
shader.release();

View File

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