GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Sunday, February 27, 2011

OpenGL - Points

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

void setup(){
    // backgrouning the screen
    glClearColor(0.0, 0.0, 0.0, 1.0);
    // make the coord width and height 20 in scale
    gluOrtho2D(-10.0, 10.0, -10.0, 10.0);
}

void display(){
    // clearing the buffer screen in memory
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(0.0, 1.0, 0.1);
    glPointSize(5.0);        // make the point 5 in width

    glBegin(GL_POINTS);
        glVertex2f(1.0, 1.0);
        glVertex2f(2.0, 2.0);
        glVertex2f(3.0, 3.0);
        glVertex2f(4.0, 4.0);
        glVertex2f(5.0, 5.0);
    glEnd();

    glFlush();
}

int main(int argc, char *argv[]){
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowPosition(200, 100);
    glutInitWindowSize(400, 300);
    glutCreateWindow("Hello World");
    glutDisplayFunc(display);

    setup();
    glutMainLoop();

    return 0;

}


Share/Bookmark

No comments:

Post a Comment