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
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* glfw.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/05/11 01:58:00 by charles #+# #+# */
/* Updated: 2020/05/12 19:05:43 by charles ### ########.fr */
/* */
/* ************************************************************************** */
#include "scop.h"
bool g_window_resized = false;
void st_resize_callback(GLFWwindow *window, int width, int height)
{
(void)window;
g_window_resized = true;
glViewport(0, 0, width, height);
}
GLFWwindow *glfw_init(int width, int height)
{
GLFWwindow *window;
if (!glfwInit())
return (NULL);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
window = glfwCreateWindow(width, height, "scop", NULL, NULL);
if (window == NULL)
{
glfwTerminate();
return (NULL);
}
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, st_resize_callback);
if (glewInit() != GLEW_OK)
{
glfwDestroyWindow(window);
glfwTerminate();
return (NULL);
}
glfwSwapInterval(1);
/* glViewport(0, 0, width, height); */
return (window);
}
|