Does GL shader support really work?
As far as I know, this code should work:
Code:
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:
Code:
uniform float val;
varying float new_val;
void main()
{
new_val = val;
gl_Position = ftransform();
}
Fragment shader:
Code:
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...
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!
Re: Does GL shader support really work?
Where did you put this code? What is the superclass of MyClass?
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.