Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. All my shader uniforms are reporting back -1 on their openGL location.

All my shader uniforms are reporting back -1 on their openGL location.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 721 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kloveridge
    wrote on last edited by
    #1

    I have the following code that prepares my openGL shaders:

    @GPUShaderOGL::GPUShaderOGL(const QString &_name, BotSource *_bot, const ShaderProto& _shaderproto)
    : GPUShader(_name, _bot, _shaderproto)
    {
    m_programOGL = new QOpenGLShaderProgram();
    if( !m_programOGL->addShaderFromSourceCode(QOpenGLShader::Vertex, _bot->vsh().toStdString().c_str()))
    {
    qDebug() << _bot->vsh_linenumbers();
    QString theLog = m_programOGL->log();
    qDebug() << theLog;
    qDebug() << "Failed to compile VERTEX program: " << m_name;
    Q_ASSERT(0);
    }

    QString fsh = _bot->fsh();
    if(!m_programOGL->addShaderFromSourceCode(QOpenGLShader::Fragment, fsh.toStdString().c_str())) {
    qDebug() << _bot->fsh_linenumbers();
    qDebug() << m_programOGL->log();
    qDebug() << "Failed to compile FRAGMENT program:" << m_name;
    Q_ASSERT(0);
    }

    if( !m_programOGL->link() )
    {
    qDebug() << m_programOGL->log();
    qDebug() << "Failed to link program:" << m_name;
    Q_ASSERT(0);
    }

    m_programOGL->bind();

    if( m_uniform ) {
    Uniform::UniformArray& uniforms = m_uniform->uniformlist();
    for( Uniform::UniformArray::iterator it=uniforms.begin(); it!=uniforms.end(); ++it )
    {
    Uniform::UniformEntry& uni = *it;
    uni.glLocation = m_programOGL->attributeLocation(uni.name);
    qDebug() << uni.name << " location: " << uni.glLocation;
    }
    }
    }
    @

    When I run this, all my uniforms are reporting back -1 on their uniforms. What am I missing here?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tilsitt
      wrote on last edited by
      #2

      Hi,

      maybe you should try to call "uniformLocation()":http://qt-project.org/doc/qt-5/qopenglshaderprogram.html#uniformLocation for uniform variables.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kloveridge
        wrote on last edited by
        #3

        Doh! You're awesome! That fixed it. I've been staring at this for a hour.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved