Mac OpenGL 설치
2020. 9. 1. 08:07ㆍComputer Graphics/OpenGl
1. 우선 Xcode를 설치 및 실행한다.
Xcode에 자동적으로 OpenGL이 설치되어있기 때문에 특별히 해야하는 건 없다. 다음으로 Command Line Tool을 선택한 다음 언어는 C++로 설정해준다.


2. OpenGL 프레임 워크 추가하기

밑에 + 버튼을 누른 후 OpenGL과 Glut를 검색해서 추가하면 된다.

3. 이제 사용할 OpenGL을 import해서 사용하면 완료!!
#include <iostream> #include <OpenGL/OpenGL.h> #include <GLUT/GLUT.h> int main(int argc, const char * argv[]) { // insert code here... std::cout << "Hello, World!\n"; return 0; }
4. 간단한 테스트 코드
#include <iostream> #include <OpenGL/OpenGL.h> #include <GLUT/GLUT.h> void myDisplay(){ glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex3f(-0.5, -0.5, 0.0); glVertex3f(0.5, -0.5, 0.0); glVertex3f(0.5, 0.5, 0.0); glVertex3f(-0.5, 0.5, 0.0); glEnd(); glFlush(); } int main(int argc, char* argv[]) { glutInit(&argc, argv); glutCreateWindow("Test"); glutDisplayFunc(myDisplay); glutMainLoop(); return 0; }
결과

'Computer Graphics > OpenGl' 카테고리의 다른 글
OpenGL 콜백함수 (0) | 2020.09.21 |
---|