Results 1 to 4 of 4

Thread: Does GL shader support really work?

  1. #1
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Does GL shader support really work?

    As far as I know, this code should work:

    Qt Code:
    1. void
    2. MyClass::draw()
    3. {
    4. if (this->pshader->isLinked()) {
    5. int val_loc = this->pshader->attributeLocation("val");
    6. this->pshader->setUniformValue(val_loc, (GLfloat)1.0);
    7. }
    8. // OpenGL stuff
    9. }
    To copy to clipboard, switch view to plain text mode 

    Vertex shader:

    Qt Code:
    1. uniform float val;
    2.  
    3. varying float new_val;
    4.  
    5. void main()
    6. {
    7. new_val = val;
    8. gl_Position = ftransform();
    9. }
    To copy to clipboard, switch view to plain text mode 

    Fragment shader:

    Qt Code:
    1. varying float new_val;
    2.  
    3. void main()
    4. {
    5. if (new_val < 0.5)
    6. gl_FragColor = vec4(1.0,0.0,0.0,1.0);
    7. else
    8. gl_FragColor = vec4(0.0,0.0,1.0,1.0);
    9. }
    To copy to clipboard, switch view to plain text mode 

    but my object appears red...

  2. #2
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Does GL shader support really work?

    I tested the shader code by using the "classical" OpenGL functions to include it in OpenGL stuff and it works well, my object appearing blue as expected.
    So I suspect there is really an issue with Qt integration of GLSL!

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Does GL shader support really work?

    Where did you put this code? What is the superclass of MyClass?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Mar 2006
    Posts
    142
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Does GL shader support really work?

    I fixed the problem: get attribute location and set uniform value!!!
    My apologizes!
    You can delete this thread now, at your convenience.

Similar Threads

  1. Replies: 8
    Last Post: 28th January 2014, 08:09
  2. QPainter and Shader
    By shetan in forum Qt Programming
    Replies: 1
    Last Post: 5th April 2011, 08:33
  3. Geometry shader with QT4.7
    By saraksh in forum General Programming
    Replies: 3
    Last Post: 28th March 2011, 16:40
  4. Fragment shader with 2d
    By krzat in forum Newbie
    Replies: 1
    Last Post: 20th December 2010, 21:37
  5. Node Shader Editor
    By AMDx64BT in forum Newbie
    Replies: 1
    Last Post: 6th December 2009, 22:30

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
  •  
Qt is a trademark of The Qt Company.