Problem using glvertex

Hello, im very very new to opengl, i really need ur help


#include <iostream>
#include <GL/glut.h>

GLfloat angleCube = 0.0f;     // Rotational angle for cube [NEW]
int refreshMills = 10;

void myDisplay(void)
{
    glClearColor(0.0, 0.0, 0.0, 1.0); //clear the color of the windows
    glClear(GL_COLOR_BUFFER_BIT); //clear the color buffer
    glColor3f(1.0, 0.0, 0.0);
    glPointSize(1);
    
    glColor3f(0.0, 1.0, 0.0);
    glRotatef(angleCube, 0.0f, 1.0f, 0.0f);
    glBegin(GL_POLYGON);
    {
        glVertex2f(-0.6, 0.2);
        glVertex2f(-0.3, 0.2);
        glVertex2f(-0.3, 0.7);
        glVertex2f(-0.1, 0.2);
        glVertex2f(0.1, 0.7);
        glVertex2f(0.1, 0.2);
        glVertex2f(0.7, 0.2);
        glVertex2f(0.4, -0.3);
        glVertex2f(0.4, -0.5);
        glVertex2f(0.1, -0.5);
        glVertex2f(0.1,-0.3);
        glVertex2f(0, -0.3);
        glVertex2f(0, -0.5);
        glVertex2f(-0.3, -0.5);
        glVertex2f(-0.3, -0.3);
        glVertex2f(-0.6, -0.3);
    }
    glEnd();
    angleCube -= 0.20f;

    glLoadIdentity(); //load identity matrix
    gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); //set the view
    glFlush(); //flush it all to the screen

}

void timer(int value) {
    glutPostRedisplay();      // Post re-paint request to activate display()
    glutTimerFunc(refreshMills, timer, 0); // next timer call milliseconds later
}

void myReshape(int w, int h)
{
    glViewport(0, 0, (GLsizei)w, (GLsizei)h); // size of virtual camera
    glMatrixMode(GL_PROJECTION); //set so we can play with 'camera'
    glLoadIdentity();
    gluPerspective(60, (GLfloat)w / (GLfloat)h, 10.0, 10.0); //angle view
    glMatrixMode(GL_MODELVIEW); //switch back model editing mode
}


int main(int argc, char **argv)
{
    glutInit(&argc, argv); //initialize the program
    glutInitDisplayMode(GLUT_SINGLE);
    glutInitWindowSize(800, 600);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Graphics programming using openGL");
    glutDisplayFunc(myDisplay);
    glutReshapeFunc(myReshape);
    //glutTimerFunc(0, timer, 0);
    glutMainLoop();

    return 0;
}

above are my code, im trying to create a polygon using 16 vertex, however my output only shows 14 vertex. What happened? What should i fix?
i really2 need ur help:)

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