OpenGL
[OpenGL] GLAD 설치 및 사용법
usingsystem
2024. 4. 1. 16:11
728x90
GLAD는 라이브러리를 인스톨 하는것이아닌 필요한 소스 코드를 생성해서 내 프로젝트에 가져가는 개념이다.
Url : https://glad.dav1d.de/
https://glad.dav1d.de/
Extensions...
glad.dav1d.de
생성
원하는 버전 선택 후 생성
include 복사
다운받은 glad폴더의 include폴더안 glad, KHR폴더를
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\xx.yy.zzzzz\include 안에 복사해준다.
glad.c 사용
glad.c는 직접 소스코드에 포함시킨다.
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#pragma comment(lib, "glew32.lib")
#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glfw3.lib")
#include <stdio.h>
#include "glad.c"
const unsigned int WIN_W = 300; // window size in pixels, (Width, Height)
const unsigned int WIN_H = 300;
int main(void) {
// start GLFW
glfwInit();
GLFWwindow* window = glfwCreateWindow(WIN_W, WIN_H, "Hello GLEW", NULL, NULL);
glfwMakeContextCurrent(window);
// start GLAD
gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
// main loop
while (!glfwWindowShouldClose(window)) {
// draw
glClear(GL_COLOR_BUFFER_BIT);
// GLFW actions
glfwSwapBuffers(window);
glfwPollEvents();
}
// done
glfwTerminate();
return 0;
}
728x90