1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 08:04:49 -05:00

Create VAOs properly

This commit is contained in:
Jon Beniston 2022-06-19 11:39:13 +01:00
parent 74d61855e4
commit 0a91c30038
2 changed files with 9 additions and 7 deletions

View File

@ -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();

View File

@ -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();