PDA

View Full Version : Does GL shader support really work?



Caius Aérobus
17th April 2012, 19:38
As far as I know, this code should work:


void
MyClass::draw()
{
if (this->pshader->isLinked()) {
int val_loc = this->pshader->attributeLocation("val");
this->pshader->setUniformValue(val_loc, (GLfloat)1.0);
}
// OpenGL stuff
}

Vertex shader:


uniform float val;

varying float new_val;

void main()
{
new_val = val;
gl_Position = ftransform();
}

Fragment shader:


varying float new_val;

void main()
{
if (new_val < 0.5)
gl_FragColor = vec4(1.0,0.0,0.0,1.0);
else
gl_FragColor = vec4(0.0,0.0,1.0,1.0);
}


but my object appears red...

Caius Aérobus
18th April 2012, 11:36
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!

wysota
18th April 2012, 11:42
Where did you put this code? What is the superclass of MyClass?

Caius Aérobus
18th April 2012, 11:45
I fixed the problem: get attribute location and set uniform value!!!
My apologizes!
You can delete this thread now, at your convenience.