Create VAOs properly

pull/1291/head
Jon Beniston 2022-06-19 11:39:13 +01:00
rodzic 74d61855e4
commit 0a91c30038
2 zmienionych plików z 9 dodań i 7 usunięć

Wyświetl plik

@ -51,6 +51,10 @@ void GLShaderSimple::initializeGL(int majorVersion, int minorVersion)
if (!m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, m_fragmentShaderSourceColored)) {
qDebug() << "GLShaderSimple::initializeGL: error in fragment shader: " << m_program->log();
}
m_vao = new QOpenGLVertexArrayObject();
m_vao->create();
m_vao->bind();
}
else
{
@ -74,9 +78,6 @@ void GLShaderSimple::initializeGL(int majorVersion, int minorVersion)
m_colorLoc = m_program->uniformLocation("uColour");
if (m_vao)
{
m_vao = new QOpenGLVertexArrayObject();
m_vao->create();
m_vao->bind();
m_verticesBuf = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
m_verticesBuf->setUsagePattern(QOpenGLBuffer::DynamicDraw);
m_verticesBuf->create();

Wyświetl plik

@ -32,9 +32,9 @@ GLShaderTextured::GLShaderTextured() :
m_verticesBuf(nullptr),
m_textureCoordsBuf(nullptr),
m_texture(nullptr),
m_textureId(0),
m_vertexLoc(0),
m_texCoordLoc(0),
m_textureId(0),
m_matrixLoc(0),
m_textureLoc(0),
m_useImmutableStorage(true)
@ -60,6 +60,10 @@ void GLShaderTextured::initializeGL(int majorVersion, int minorVersion)
if (!m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, m_fragmentShaderSourceTextured)) {
qDebug() << "GLShaderTextured::initializeGL: error in fragment shader: " << m_program->log();
}
m_vao = new QOpenGLVertexArrayObject();
m_vao->create();
m_vao->bind();
}
else
{
@ -85,9 +89,6 @@ void GLShaderTextured::initializeGL(int majorVersion, int minorVersion)
m_textureLoc = m_program->uniformLocation("uTexture");
if (m_vao)
{
m_vao = new QOpenGLVertexArrayObject();
m_vao->create();
m_vao->bind();
m_verticesBuf = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
m_verticesBuf->setUsagePattern(QOpenGLBuffer::DynamicDraw);
m_verticesBuf->create();