The Industry's Foundation for High Performance Graphics

1. colors

I used following material property for a four sided cube(there is no side parallel to z axis).

GLfloat mat_amb_diff[] = { 1.0, 0.0, 0.0, 1.0 };
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE,
mat_amb_diff);

I confused with the color it shows.
GL_FRONT: which is front? Which direction?

thanks

2. Re: colors

The GL_FRONT is the direction of the normal of you'r facets.

3. Re: colors

Sorry. I could not understand. Now I took only two sides of the cube. I see Red inside and white color ourside. I commented normals also. What is facet here?

The GL_FRONT is the direction of the normal of you'r facets.

Here, I am giving drawing how it looks like. Any ideas?

(WHITE)
|-------------
| | (RED)
| --->Direction of normal
| x(center)
| <--(RED)
|

[This message has been edited by Ramesh (edited 12-05-2000).]

[This message has been edited by Ramesh (edited 12-05-2000).]

4. Re: colors

In OpenGL you can tell the driver which side of a polygon is front and which side is back through either defining GL_CCW or GL_CW.
That is, the polygons have to be defined clockwise or counterclockwise, depending on what you specified. CCW means, that if you look on the polygon, they are arranged ccw.
To define the direction of the vertices enables the driver to get the normal of a face through a simple cross-product. It then can differ between two sides of the polygon, which are GL_FRONT and GL_BACK.
You only have to say which is front and follow that consequently. Then, you should get predictable results.

5. Re: colors

How can I calculte a normal vector of a polygon v1(x1,y1,z1),v2(x2,y2,z2) ....etc.

thanks

6. Re: colors

If it's CCW
vecn = (vec1-vec0)X(vec2-vec0)
where x is the crossproduct

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•