OpenGL

[OpenGL] 1. 환경 구축 (NuGet)

부비새 2024. 4. 3. 15:00

컴퓨터그래픽스 실습환경을 구축하기 위해 VS에 GULT를 준비할 것이다.

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 qualit

www.transmissionzero.co.uk

위 사이트에서 파일을 직접받아 헤더를 포함시킬 수 있지만 이번에는 NuGet 패키지 관리자로 설치한다.


도구->NuGet 패키지 관리자 -> 솔루션용 NuGet 패키지 관
검색창에 freeglut 검색 -> 최선버전 3.2.2.v140 -> 설치

 

끗.


다음 예제 코드로 실행이 잘 되는지 확인해보자

#include <windows.h>
#include <GL/gl.h>
#include <GL/glut.h>

void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT);

    glColor3f(1.0, 1.0, 1.0); 


    glBegin(GL_POLYGON);
    glVertex3f(0.25, 0.25, 0.0);
    glVertex3f(0.75, 0.25, 0.0);
    glVertex3f(0.75, 0.75, 0.0);
    glVertex3f(0.25, 0.75, 0.0);
    glEnd();
    glFlush();
}

// OpenGL 초기화 함수
void init(void)
{
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}

int main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(600, 600);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Sample");

    init();

    glutDisplayFunc(display);
    glutMainLoop();
    return 0;
}

 

OpenGL 환경 준비 완료~

 

++ 

FreeGLUT 와 GLUT for Windows의 차이점 - FreeGLUT에서는 GLUT를 사용할 때 반드시 glutInit() 함수를 호출해서 GLUT 초기화를 진행해야 한다