I have a simple school task, I need to draw an octahedron and a sphere with light in it. It works, but works weird I use this code 8 times with different coordinates to draw an octahedron

glColor3f(1.0, 0.0, 1.0);
    glVertex3f( 0.25 - position, -0.25 - position, -0.25);
    glVertex3f( 0.25 - position, -0.25 - position,  0.25);
    glVertex3f( 0.0  - position,  0.25 - position,  0.0);
    // position is just an additional thing to move edges

and this to draw a sphere

if (lightEnabled == true) {
        glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

        GLfloat lights[] = {0.3, 0.3, 0.3, 1.0};
        glLightfv(GL_LIGHT0, GL_AMBIENT, lights);
        GLfloat lightsPosition[] = {0.0, 0.0, 0.5, 1.0};
        glLightfv(GL_LIGHT0, GL_POSITION, lightsPosition);
    } else {

    glutWireSphere(0.1, 25, 25);

Here's the screen of the problem with edgesAs you can see, purple and yellow edges are bright, and that's not exactly correct

I was told that this is a problem with normal matrix or something, but I can't figure it out.


Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.