Results 1 to 2 of 2

Thread: Polygon edges

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2007

    Polygon edges

    I'm quite new to opengl. Probably this is a noobish question for many of you, but I would really like to know how to draw a box or cube (one color, i.e. Red) with visible edges from any viewing angle. In many vewing positions, the edge between two faces cannot be distinguished. I'm currently using a basic way to draw the box, by setting a color and drawing with GL_POLYGON. (using Linux and Qt)
    I'm using opengl to simulate a mechanical hand and all 3D objects should be like in real world. With or without shadows, the objects should have the same color and lighting properties in any viewing angle.

    Thank you.
    In Open Source we trust!

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2007

    Re: Polygon edges

    I figured out how to make those edges visible. It's all about lighting. But still, i cant figure how to set the light fixed. I made a simple object (a box) and even when i push matrix, the light still rotates/translates with the object. here is the code

    void GLScene:aintGL()
    glTranslatef( 0.0, 0.0, -10.0 );
    glScalef( scale, scale, scale );
    glRotatef( xRot, 1.0, 0.0, 0.0 );
    glRotatef( yRot, 0.0, 1.0, 0.0 );
    glRotatef( zRot, 0.0, 0.0, 1.0 );

    paintGL - executed everytime I change an angle

    next: initialization (lights and stuff)

    void GLScene::initializeGL()

    GLfloat whiteDir[4] = {1.0, 0.0, 0.0, 1.0};
    GLfloat whiteAmb[4] = {1.0, 0.0, 0.0, 1.0};
    GLfloat lightPos[4] = {2.0, 2.0, 2.0, 0.0};
    // glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, whiteAmb);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, whiteDir);
    glMaterialfv(GL_FRONT, GL_SPECULAR, whiteDir);
    glMaterialf(GL_FRONT, GL_SHININESS, 100.0);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteDir);
    glLightfv(GL_LIGHT0, GL_SPECULAR, whiteDir);

    glLightfv(GL_LIGHT0, GL_POSITION, lightPos);
    glShadeModel( GL_SMOOTH );
    glClearColor( 0.0, 0.0, 0.0, 0.0 );
    object = glGenLists( 1 );
    glNewList( object, GL_COMPILE );

    drawbox function, draws a cube 1x1x1.

    What i need is to have the light fixed (like in real world, when illuminating an object that rotates around its own axis, with a fixed light source.)
    Anyone has any idea of how can i do this?

    Thanks in advance.
    In Open Source we trust!

Similar Threads

  1. antialiasing polygon edges
    By David Patte in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-16-2010, 01:31 PM
  2. polylines or polygon edges
    By gjsonke in forum COLLADA
    Replies: 1
    Last Post: 11-09-2007, 10:54 AM
  3. Jagged Polygon Edges
    By jmikhael in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 07-22-2003, 09:44 AM
  4. antialiasing polygon edges
    By srikirti in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 11-28-2002, 12:38 AM
  5. Edges of Polygon
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-25-2001, 01:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean