-
Notifications
You must be signed in to change notification settings - Fork 0
/
GL.cpp
37 lines (31 loc) · 989 Bytes
/
GL.cpp
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
31
32
33
34
35
36
37
#include "GL.h"
GLFWwindow* GL::initGLFW(int width, int height) {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
//glfwWindowHint(GLFW_SAMPLES, 16);
GLFWwindow* window = glfwCreateWindow(width, height, "AudioFFT", nullptr, nullptr);
if (window == nullptr) {
printf("Failed to create GLFW window\n");
glfwTerminate();
}
glfwMakeContextCurrent(window);
glfwSwapInterval(0);
return window;
}
void GL::initGLAD() {
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
printf("Failed to initialize GLAD\n");
glfwTerminate();
}
}
void fboCallback(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);
}
void GL::initViewportDefault(GLFWwindow *pWwindow) {
int width, height;
glfwGetWindowSize(pWwindow, &width, &height);
glViewport(0, 0, width, height);
glfwSetFramebufferSizeCallback(pWwindow, fboCallback);
}