Caius Aérobus
17th April 2012, 18: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...
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...