Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: colors

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2000
    Location
    Erlangen, Germany
    Posts
    28

    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. #2
    Intern Contributor
    Join Date
    Aug 2000
    Location
    france
    Posts
    89

    Re: colors

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

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2000
    Location
    Erlangen, Germany
    Posts
    28

    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. #4
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,258

    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.
    - Michael Steinberg

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2000
    Location
    Erlangen, Germany
    Posts
    28

    Re: colors

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

    thanks

  6. #6
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,258

    Re: colors

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

Posting Permissions

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