Created
February 10, 2019 06:05
-
-
Save cseas/2c6ac3e7802ea883cfe9c2b0b294b5d5 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
Please help me, it fails to include GLUT in my program for some reason.