-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain2.cpp
More file actions
143 lines (112 loc) · 2.91 KB
/
main2.cpp
File metadata and controls
143 lines (112 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//
// main2.cpp
// OpenGL-Practice
//
// Created by 장이국 on 2021/03/19.
//
#define GL_SILENCE_DEPRECATION
#include <iostream>
#ifdef _WIN32
#include "glut.h"
#elif __APPLE__
#include <OpenGL/OpenGL.h>
#include <GLUT/GLUT.h>
#endif
#define PI 3.14
namespace main2 {
void reshape(int w, int h)
{
glLoadIdentity();
glViewport(0, 0, w, h);
gluOrtho2D(0.0, 200, 0.0, 200.0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0, 1, 0);
glRectf(30, 30.0, 50.0, 50.0);
glColor3f(1, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2f(10, 10);
glVertex2f(10, 50);
glVertex2f(50, 50);
glVertex2f(50, 10);
glEnd();
glutSwapBuffers();
}
void teapot(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1, 1, 0);
glutSolidTeapot(0.5);
glColor3f(1, 0, 0);
glutWireTeapot(0.5);
glFlush();
}
void dot_circle()
{
GLfloat size[2];
GLfloat angle;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1, 1, 1);
glGetFloatv(GL_POINT_SIZE_RANGE, size);
// glPointSize(size[0]);
// glPointSize(size[1]);
glPointSize(10);
glBegin(GL_POINTS);
for (angle = 0; angle <= 2 * PI; angle += PI / 10) {
glVertex3f(0.5 * cos(angle), 0.5 * sin(angle), 0);
}
glEnd();
glFlush();
}
void rainbow_line()
{
gluOrtho2D(-1, 6, -3, 3);
glClear(GL_COLOR_BUFFER_BIT);
glLineWidth(10);
glBegin(GL_LINE_STRIP);
glColor3f(1, 0, 0); // 빨
glVertex3f(0, 0, 0);
glColor3f(1, 1, 0); // 노
glVertex3f(1, 0, 0);
glColor3f(0, 1, 0); // 초
glVertex3f(2, 0, 0);
glColor3f(0, 1, 1); // 초
glVertex3f(3, 0, 0);
glColor3f(0, 0, 1); // 파
glVertex3f(4, 0, 0);
glColor3f(1, 0, 1); // 보
glVertex3f(5, 0, 0);
glEnd();
glFlush();
}
void rainbow_triangle(){
float angle = PI / 2;
gluOrtho2D(-1.1, 1.1, -1.1, 1.1);
glClear(GL_COLOR_BUFFER_BIT);
glShadeModel(GL_SMOOTH);
glBegin(GL_TRIANGLES);
glColor3f(1, 1, 1);
glVertex3f(cos(angle), sin(angle), 0);
angle += PI * 4 / 3;
glColor3f(0, 1, 0);
glVertex3f(cos(angle), sin(angle), 0);
angle += PI * 4 / 3;
glColor3f(0, 0, 1);
glVertex3f(cos(angle), sin(angle), 0);
glEnd();
glFlush();
}
}
/*int main(int argc, char* argv[])
{
glutInit(&argc, argv);
//glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutCreateWindow("OpenGL-Practice");
//glutReshapeFunc(reshape);
glClearColor(0, 0, 0, 1);
glutDisplayFunc(main2:: rainbow_triangle);
glutMainLoop();
return 0;
}*/