Created
May 28, 2020 12:43
-
-
Save Suvink/5fd314b7599ff72165af9b5d4bb11466 to your computer and use it in GitHub Desktop.
This is the way of implementing the following tutorial in C. (https://services.suvink.me/opengl-c)
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<stdio.h> | |
#include <OpenGL/gl.h> | |
#include <GLUT/glut.h> | |
void myInit (void){ | |
glClearColor(1.0, 1.0, 0.0, 1.0); | |
glColor3f(0.2, 0.5, 0.4); | |
glPointSize(10.0); | |
gluOrtho2D(0, 500, 0, 500); | |
} | |
void display(void){ | |
glClear(GL_COLOR_BUFFER_BIT); | |
glBegin(GL_POINTS); | |
glVertex2f(100, 100); | |
glVertex2f(300, 200); | |
glEnd(); | |
glBegin( GL_QUADS ); | |
glVertex2f( 100.0, 100.0 ); | |
glVertex2f( 300.0, 100.0 ); | |
glVertex2f( 300.0, 200.0 ); | |
glVertex2f( 100.0, 200.0 ); | |
glEnd(); | |
glBegin( GL_TRIANGLE_STRIP ); | |
glVertex2f( 100.0, 210.0 ); | |
glVertex2f( 300.0, 210.0 ); | |
glVertex2f( 300.0, 310.0 ); | |
glEnd(); | |
glFlush(); | |
} | |
int main (int argc, char** argv) { | |
glutInit(&argc, argv); | |
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); | |
glutInitWindowSize(500, 500); | |
glutInitWindowPosition(100, 100); | |
glutCreateWindow("Python Code 1"); | |
myInit(); | |
glutDisplayFunc(display); | |
glutMainLoop(); | |
} | |
/* | |
Run this with following format | |
gcc filename.c -o filename -framework OpenGL -framework GLUT | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment