Trivial, stupid error in trivial shader

Hi

Ok he’re my ultra drawing routine:

  glTranslatef(0.0f,0.0f,-2.0f);
	float z[4] = {1.0, 1.0, 1.0, 1.0};
	location = glGetUniformLocation(p, "color");
	glUniform1fv(location, 1, z);
	glBegin(GL_TRIANGLES);						
	glVertex3f( 0.0f, 1.0f, 0.0f);				
	glVertex3f(-1.0f,-1.0f, 0.0f);				
	glVertex3f( 1.0f,-1.0f, 0.0f);				
	glEnd();	

vertex:

void main()
{
	gl_Position = ftransform();
} 
uniform vec4 color;
void main()
{
	gl_FragColor = color;
} 

Ok this is really simple… why i’m getting black screen instead of nice white one ? (am i too sleepy or what :slight_smile:

Firstly, I think you want glUniform4fv, not glUniform1fv.

Next, what do your perspective and modelview matrices look like?

I would also use 0.5f instead of 0.0f for z values. (assuming an identity projection matrix)

Also be careful that if you translate every frame, you will soon push your triangle beyond the far clipping plane.

Use:
glPushMatrix();
<draw>
glPopMatrix();

yes thats it glUniform4fv solves it … :slight_smile:

PS i don’t paste everything in my drawing routine. translating and other stuff were well tested in fixed-func-style :slight_smile:

Thanks

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.