-
-
Save eborghi10/8ee8a425875852ff0c4ed51298e69bf7 to your computer and use it in GitHub Desktop.
Simple C++ OpenGL program to draw points on a 2D canvas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<GL/glut.h> | |
void display() { | |
glClear(GL_COLOR_BUFFER_BIT); | |
glColor3f(1.0, 0.0, 0.0); | |
glBegin(GL_POINTS); | |
glVertex2f(10.0, 10.0); | |
glVertex2f(150.0, 80.0); | |
glVertex2f(100.0, 20.0); | |
glVertex2f(200.0, 100.0); | |
glEnd(); | |
glFlush(); | |
} | |
void myinit() { | |
glClearColor(1.0, 1.0, 1.0, 1.0); | |
glColor3f(1.0, 0.0, 0.0); | |
glPointSize(5.0); | |
glMatrixMode(GL_PROJECTION); | |
glLoadIdentity(); | |
gluOrtho2D(0.0, 499.0, 0.0, 499.0); | |
} | |
void main(int argc, char** argv) { | |
glutInit(&argc, argv); | |
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); | |
glutInitWindowSize(500, 500); | |
glutInitWindowPosition(0, 0); | |
glutCreateWindow("Points"); | |
glutDisplayFunc(display); | |
myinit(); | |
glutMainLoop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment