Mercurial > public > algo-animator
annotate main.c @ 2:ea3c427d922d
draw a weird filled rectangle
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Mon, 12 Jun 2023 18:45:30 +0100 |
parents | 6882194679b5 |
children | e4003f606e07 |
rev | line source |
---|---|
0 | 1 #include <stdio.h> |
2 #include <GL/glut.h> | |
3 | |
4 | |
5 #define HEIGHT 1080 | |
6 #define WIDTH 1920 | |
7 | |
8 | |
9 void setup() { | |
2
ea3c427d922d
draw a weird filled rectangle
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
10 |
0 | 11 // Set background dark |
12 glClearColor(0.0, 0.0, 0.0, 1.0); | |
13 | |
14 // Set point color and size to 1 pixel | |
15 glColor3f(0.0, 1.0, 0.0); | |
16 glPointSize(5.0); | |
17 | |
18 // Matrix projection and reset with identity | |
19 glMatrixMode(GL_PROJECTION); | |
20 glLoadIdentity(); | |
2
ea3c427d922d
draw a weird filled rectangle
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
21 |
0 | 22 // Set the coordinates to be used with the viewport |
2
ea3c427d922d
draw a weird filled rectangle
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
23 gluOrtho2D(-300, 300, 300, -300); |
ea3c427d922d
draw a weird filled rectangle
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
24 |
ea3c427d922d
draw a weird filled rectangle
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
25 glMatrixMode(GL_MODELVIEW); |
ea3c427d922d
draw a weird filled rectangle
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
26 glLoadIdentity(); |
ea3c427d922d
draw a weird filled rectangle
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
27 |
0 | 28 } |
29 | |
30 | |
31 void display() { | |
32 glClear(GL_COLOR_BUFFER_BIT); | |
2
ea3c427d922d
draw a weird filled rectangle
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
33 glRectf(100.0f, 100.0f, 200.0f, 200.0f); |
ea3c427d922d
draw a weird filled rectangle
Dennis C. M. <dennis@denniscm.com>
parents:
0
diff
changeset
|
34 // glVertex2i(1920/2, 1080/2); |
0 | 35 glFlush(); |
36 } | |
37 | |
38 | |
39 int main(int argc, char** argv) { | |
40 glutInit(&argc, argv); | |
41 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); | |
42 glutInitWindowSize(WIDTH, HEIGHT); | |
43 glutCreateWindow("OpenGL Window"); | |
44 setup(); | |
45 glutDisplayFunc(display); | |
46 glutMainLoop(); | |
47 | |
48 return 0; | |
49 } |