본문 바로가기
Dev/C, C++

OpenGL, Visual Studio 2019에서 시작하기(메모)

by E.Clone 2019. 4. 12.

1. 준비

 

https://www.transmissionzero.co.uk/software/freeglut-devel/

 

freeglut Windows Development Libraries

Introduction Whilst at the University of Essex, I took a module called “Interactive Computer Graphics” (or EE222 as we referred to it). Half of the course consisted of using POV-Ray to create images, and then putting them together to make a high quality an

www.transmissionzero.co.uk

여기에서 freeglut 3.0.0 MSVC Package 다운로드 받는다.

압축파일 구성은 이렇다

필요한 것은, include 폴더, lib 폴더 그리고 bin 폴더 안에 있는 freeglut.dll 파일이다.

 

2. Visual Studio 프로젝트 생성 및 세팅

 

프로젝트 생성은 C++ 콘솔 어플리케이션으로 시작한다. 프로젝트 생성이 완료되었다면 위에서 받아두었던 파일을 프로젝트 폴더로 옮겨준다. 솔루션 탐색기의 프로젝트명의 우클릭으로 파일탐색기에서 폴더열기를 할 수 있다.

프로젝트 폴더 열기

 

include와 lib폴더 그리고, bin폴더 안에 있던 freeglut.dll 파일을 가져왔다

 

아까와 마찬가지로 프로젝트 이름을 우클릭하여 속성에 들어가 다음과 같은 세팅을 한다.

C/C++ 의 '일반' 탭에서 추가 포함 디렉터리에 ./include 를 넣어준다.

 

링커의 '일반' 탭에서 추가 라이브러리 디렉터리에 ./lib 을 넣어준다.

 

3. 예제 실행

 

준비해 둔 예제가 있다. 복사 붙여넣기를 하여 실행 해 보자.

정상적으로 작동하는 것을 확인하였다

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

#include "gl/glut.h"

void display() {

 

    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

    glClear(GL_COLOR_BUFFER_BIT);

    glColor3f(0.0f, 0.0f, 1.0f);

    glBegin

 

    (GL_POLYGON);

    glVertex2f(-0.2f, -0.2f);

    glVertex2f(0.4f, -0.4f);

    glVertex2f(0.4f, 0.4f);

    glVertex2f(-0.2f, 0.2f);

 

    glEnd();

    glFinish();

}

int main(int argc, char** argv)

{

    glutInit(&argc, argv);

    glutCreateWindow

    ("OpenGL");

    glutDisplayFunc(display);

    glutMainLoop();

    return 0;

}

cs
반응형