-
Notifications
You must be signed in to change notification settings - Fork 0
/
window.cpp
67 lines (53 loc) · 1.61 KB
/
window.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "headers/window.h"
GLFWwindow* Window::mWindow = NULL;
Window* Window::mInstance = NULL;
Window::Window()
{
const GLuint WIDTH = 800, HEIGHT = 600;
// Init GLFW
glfwInit( );
// Set all the required options for GLFW
glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 3 );
glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 3 );
glfwWindowHint( GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE );
glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE );
glfwWindowHint( GLFW_RESIZABLE, GL_FALSE );
// Create a GLFWwindow object that we can use for GLFW's functions
mWindow = glfwCreateWindow( WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr );
int screenWidth, screenHeight;
glfwGetFramebufferSize( mWindow, &screenWidth, &screenHeight );
if ( nullptr == mWindow )
{
std::cout << "Failed to create GLFW mWindow" << std::endl;
glfwTerminate( );
}
glfwMakeContextCurrent( mWindow );
// Set this to true so GLEW knows to use a modern approach to retrieving function pointers and extensions
glewExperimental = GL_TRUE;
// Initialize GLEW to setup the OpenGL Function pointers
if ( GLEW_OK != glewInit() )
{
std::cout << "Failed to initialize GLEW" << std::endl;
}
// Define the viewport dimensions
glViewport(0, 0, screenWidth, screenHeight );
}
GLFWwindow* Window::GetGLFWWindow()
{
return mWindow;
}
Window::~Window()
{
delete mWindow;
//delete mRenderer;
delete mInstance;
}
void Window::CreateWindow()
{
if(mInstance == NULL)
mInstance = new Window();
}
Window* Window::GetWindow()
{
return mInstance;
}