Results 1 to 9 of 9

Thread: QGLShaderProgram works on Debug mode, fails on running in Release.

  1. #1
    Join Date
    Sep 2013
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Unhappy QGLShaderProgram works on Debug mode, fails on running in Release.

    I'm loosing my mind trying to imagine what the hell I'm missing.

    This is my first time with OpenGL with Qt and I wanna use custom shaders, all seems to work properly on Debug mode but in Release

    Qt Code:
    1. bool __thiscall QGLShaderPrivate::create(void): Could not create shader of type 1.
    2. Vertex Shader Error ""
    3. bool __thiscall QGLShaderPrivate::create(void): Could not create shader of type 2.
    4. Fragment Shader Error ""
    5. Shader Program Linker Error ""
    To copy to clipboard, switch view to plain text mode 

    PS. I forget to say that this errors are shown in the console but the app doesn't crash, it just doesn't work properly.


    Thanks in advance for any help!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QGLShaderProgram works on Debug mode, fails on running in Release.

    How about sharing some information about what your code is doing to trigger this warning from the Qt internals.
    Or whether the fault occurs inside an IDE or in a standalone deployed environment

  3. #3
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QGLShaderProgram works on Debug mode, fails on running in Release.

    Your shader program has not been linked yet. That's why you receive the warning in the console.

  4. #4
    Join Date
    Sep 2013
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QGLShaderProgram works on Debug mode, fails on running in Release.

    Thank you both!

    About the test both were made using the IDE but in deployment Debug runs fine and Release seems to have the same problems (but obviously I don't get that console messages).

    Here is my loading routine (pretty basic):

    Qt Code:
    1. void MyGLWidget::loadShader(QString vshader, QString fshader)
    2. {
    3. if(ShaderProgram)
    4. {
    5. ShaderProgram->release();
    6. ShaderProgram->removeAllShaders();
    7. }
    8. else ShaderProgram = new QGLShaderProgram;
    9.  
    10. if(VertexShader)
    11. {
    12. delete VertexShader;
    13. VertexShader = NULL;
    14. }
    15.  
    16. if(FragmentShader)
    17. {
    18. delete FragmentShader;
    19. FragmentShader = NULL;
    20. }
    21.  
    22. std::cout << "loadShader "<<vshader.toStdString()<<" "<<fshader.toStdString()<<std::endl;
    23. // load and compile vertex shader
    24. QFileInfo vsh(vshader);
    25. if(vsh.exists())
    26. {
    27. VertexShader = new QGLShader(QGLShader::Vertex);
    28. if(VertexShader->compileSourceFile(vshader))
    29. ShaderProgram->addShader(VertexShader);
    30. else qWarning() << "Vertex Shader Error" << VertexShader->log();
    31. }
    32. else qWarning() << "Vertex Shader source file " << vshader << " not found.";
    33.  
    34. // load and compile fragment shader
    35. QFileInfo fsh(fshader);
    36. if(fsh.exists())
    37. {
    38. FragmentShader = new QGLShader(QGLShader::Fragment);
    39. if(FragmentShader->compileSourceFile(fshader))
    40. ShaderProgram->addShader(FragmentShader);
    41. else qWarning() << "Fragment Shader Error" << FragmentShader->log();
    42. }
    43. else qWarning() << "Fragment Shader source file " << fshader << " not found.";
    44.  
    45. if(!ShaderProgram->link())
    46. {
    47. qWarning() << "Shader Program Linker Error" << ShaderProgram->log();
    48. }
    49. else
    50. ShaderProgram->bind();
    51. }
    To copy to clipboard, switch view to plain text mode 

    And the problem is shown in the IDE for Release mode:
    Qt Code:
    1. bool __thiscall QGLShaderPrivate::create(void): Could not create shader of type 1.
    2. Vertex Shader Error ""
    3. bool __thiscall QGLShaderPrivate::create(void): Could not create shader of type 2.
    4. Fragment Shader Error ""
    5. Shader Program Linker Error ""
    6. GPU: "GeForce GTX 560/PCIe/SSE2"
    7. OpenGL: "2.1.2"
    8. GLSL: "1.20 NVIDIA via Cg compiler"
    To copy to clipboard, switch view to plain text mode 


    Thanks in advance.

  5. #5
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QGLShaderProgram works on Debug mode, fails on running in Release.

    Would you click Projects and see whether "Shadow Build" is ticked. If it is, remove it. Now build again and run in release mode.

  6. #6
    Join Date
    Sep 2013
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QGLShaderProgram works on Debug mode, fails on running in Release.

    That's even more strange... if I disable Shadow Build it doesn't run:
    The program has unexpectedly finished. ...Test3.exe exited with code -1073741515
    Edit: I found that this means that is missing some libs, it happens since disabling shadow build it is placed in another directory, after putting that dlls there I have the same "bool __thiscall QGLShaderPrivate::create(void): Could not create shader of type" error.

    So that didn't solve nothing but thank you for your time anyway.
    Last edited by escobar; 23rd September 2013 at 13:18.

  7. #7
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QGLShaderProgram works on Debug mode, fails on running in Release.

    Would you upload your shader programs in a different way. Add vertext.sh and fragment.sh to your src. Then try linking them this way as below:

    Qt Code:
    1. //#version 130
    2.  
    3. precision mediump float;
    4.  
    5. uniform mat4 mvpMatrix;
    6.  
    7. attribute vec4 vertex;
    8. attribute float color;
    9.  
    10. varying float varyingColor;
    11.  
    12. void main(void)
    13. {
    14. varyingColor = color;
    15. gl_Position = mvpMatrix * vertex;
    16. }
    To copy to clipboard, switch view to plain text mode 
    fragment shader has the same format, you know it. Then do this in the code:

    Qt Code:
    1. initCommon();
    2.  
    3. shaderProgram.addShaderFromSourceFile(QGLShader::Vertex, ":/vertexShader.vsh");
    4.  
    5. shaderProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/fragmentShader.fsh");
    6.  
    7. if(!shaderProgram.link())
    8. {
    9. exit(1);
    10. }
    To copy to clipboard, switch view to plain text mode 

    initCommon() is:
    Qt Code:
    1. void GlWidget::initCommon()
    2. {
    3. //qglClearColor(QColor(Qt::black));
    4. glEnable(GL_DEPTH_TEST);
    5. glEnable(GL_CULL_FACE);
    6.  
    7. glEnable(GL_BLEND);
    8. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    9. }
    To copy to clipboard, switch view to plain text mode 

    check this method and let us know about the result.

    PS: don't forget to upload your shaders to your resources.

  8. #8
    Join Date
    Sep 2013
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QGLShaderProgram works on Debug mode, fails on running in Release.

    No luck, also I tried to load from "./a.vert" "./a.frag" it founds the files but they aren't created properly.



    It looks that the problem is during the compilation not on loading.

    compileSourceCode(code) doesn't work neither on Release but works on Debug.
    Last edited by escobar; 23rd September 2013 at 14:02.

  9. #9
    Join Date
    Sep 2013
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QGLShaderProgram works on Debug mode, fails on running in Release.

    I fixed it... just by updating to Qt 5.1.1

Similar Threads

  1. Replies: 1
    Last Post: 7th March 2012, 21:34
  2. Replies: 4
    Last Post: 27th May 2010, 15:18
  3. Replies: 1
    Last Post: 2nd November 2009, 12:02
  4. Replies: 9
    Last Post: 15th April 2009, 06:23
  5. Replies: 8
    Last Post: 10th October 2007, 18:20

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.