Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 참고 문헌 : MACHINE LEARNING 기계학습 _ 오일석
- 시스템콜
- C++
- 코테준비
- DP
- 스택
- substr
- sql고득점kit
- 프로그래머스
- 최대공약수
- set
- MySQL
- 우선순위큐
- 다이나믹프로그래밍
- 문자열
- MAP
- 정렬
- 코테
- 플로이드와샬
- 동적계획법
- 다익스트라
- 코딩테스트연습
- String
- 백준
- Dijkstra
- 리시프
- unordered_map
- vector
- 알고리즘
- dfs
Archives
- Today
- Total
YeJin's Footsteps
OpenGL 기초 (실습) 본문
1. First Example
![]() |
![]() |
2. Teapot Example
![]() |
![]() |
3. Teapot Example 2 (My favorite color)
#include <glut.h>
void display(void) {
glClear(GL_COLOR_BUFFER_BIT);//화면을 지우고
glColor3f(0.0, 0.9, 0.9);//민트색
glutSolidTeapot(0.5);//솔리드 티팟
glColor3f(1, 1, 1);//하얀색
glutWireTeapot(0.5);//와이어 티팟
glFlush();
}
void main(int argc, char**argv)
{
glutCreateWindow("Teapot");
glClearColor(0.0, 0.0, 0.0, 0.0);//검은 배경
glutDisplayFunc(display);
glutMainLoop();
}

4. Point Example
#include <glut.h>
#include <math.h>
#define Pi 3.141592
void display(void) {
GLfloat size[2];
GLfloat angle;
glClear(GL_COLOR_BUFFER_BIT);
/** 제일 중요한 부분 **/
glColor3f(1.0, 1.0, 1.0);
glGetFloatv(GL_POINT_SIZE_RANGE, size);
glPointSize(size[0]);//하드웨어가 서포트 할수있는 가장 작은 점의 크기(size[1]은 가장 큰 점)
//size[0]+((size[1]-size[0])/2.0) -> 그 중간 값. 원이 이쁘게 나옴
glBegin(GL_POINTS);//점들을 계속 지정
for (angle = 0.0; angle <= 2.0 * Pi; angle += Pi / 30.0) //0부터 360도까지 6도 간격으로
glVertex3f(0.5 * cos(angle), 0.5 * sin(angle), 0.0);
glEnd();
/*-----------------------------------------------------*/
glFlush();
}
void main(int argc, char**argv)
{
glutCreateWindow("Point Example");
glutDisplayFunc(display);
glutMainLoop();
}
![]() |
![]() |
5. Line Example
#include <glut.h>
void myDisplay() {
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glLineWidth(5.0);
glColor3f(0.0, 0.9, 0.9);//민트색에서
glVertex3f(1.0, 0.0, 0.0);
glColor3f(1.0, 1.0, 1.0);//하얀색으로 그라데이션
glVertex3f(-1.0, 0.0, 0.0);
glEnd();
glFlush();
}
void main(int argc, char** argv) {
glutCreateWindow("Line Example");
glutDisplayFunc(myDisplay);
glutMainLoop();
}

6. Triangle Example
#include <glut.h>
void myDisplay() {
glClear(GL_COLOR_BUFFER_BIT);
glShadeModel(GL_SMOOTH);//그라데이션으로 다각형을 채움
glBegin(GL_TRIANGLES);
glColor3f(0.0, 0.9, 0.9);
glVertex3f(0.0, 0.5, 0.0);
glColor3f(0.9, 0.9, 0.0);
glVertex3f(-0.5, -0.5, 0.0);
glColor3f(0.9, 0.0, 0.9);
glVertex3f(0.5, -0.5, 0.0);
glEnd();
glFlush();
}
void main(int argc, char** argv) {
glutCreateWindow("Triangle Example");
glutDisplayFunc(myDisplay);
glutMainLoop();
}

'Computer Science & Engineering > OpenGL' 카테고리의 다른 글
OpenGL 응용1 (0) | 2021.04.10 |
---|