-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgl_framework.cpp
More file actions
61 lines (49 loc) · 1.26 KB
/
Copy pathgl_framework.cpp
File metadata and controls
61 lines (49 loc) · 1.26 KB
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
51
52
53
54
55
56
57
58
#include "gl_framework.hpp"
namespace csX75
{
int win_width;
int win_height;
//! Initialize GL State
void initGL(void)
{
//Set framebuffer clear color
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
//Set depth buffer furthest depth
glClearDepth(1.0);
}
//!GLFW Error Callback
void error_callback(int error, const char* description)
{
std::cerr<<description<<std::endl;
}
//!GLFW framebuffer resize callback
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
if ( height == 0 ) height = 1;
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
//Draw to the whole window
glViewport( 0, 0, width, height );
//Keep the aspect ratio fixed
double aspect;
if (width > height)
{
aspect = (double)width/(double)height;
//glOrtho(-aspect, aspect, -1.0, 1.0, -1.0, 1.0);
}
else
{
aspect = (double)height/(double)width;
//glOrtho(-1.0, 1.0, -aspect, aspect, -1.0, 1.0);
}
win_width = width;
win_height = height;
}
//!GLFW keyboard callback
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
//!Close the window if the ESC key was pressed
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);
}
};