MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / Initialise

Method Initialise

Source/SysGL/Graphics/GraphicsContextGL.cpp:74–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72
73extern bool initgl();
74bool GraphicsContextGL::Initialise()
75{
76 glfwSetErrorCallback(error_callback);
77
78 // Initialise GLFW
79 if( !glfwInit() )
80 {
81 fprintf( stderr, "Failed to initialize GLFW\n" );
82 return false;
83 }
84
85 glfwWindowHint(GLFW_SAMPLES, 4);
86 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
87 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
88
89#ifdef DAEDALUS_OSX
90 // OSX 10.7+ only supports 3.2 with core profile/forward compat.
91 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
92 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
93#endif
94
95 glfwWindowHint(GLFW_DEPTH_BITS, 24);
96 //glfwWindowHint(GLFW_STENCIL_BITS, 0);
97
98 // Open a window and create its OpenGL context
99 gWindow = glfwCreateWindow( SCR_WIDTH, SCR_HEIGHT,
100 "Daedalus",
101 NULL, NULL );
102 if (!gWindow)
103 {
104 fprintf( stderr, "Failed to open GLFW window\n" );
105
106 glfwTerminate();
107 return false;
108 }
109
110 glfwMakeContextCurrent(gWindow);
111
112 // Ensure we can capture the escape key being pressed below
113 //glfwEnable( GLFW_STICKY_KEYS );
114
115 // Enable vertical sync (on cards that support it)
116 glfwSwapInterval( 1 );
117
118 // Initialise GLEW
119 //glewExperimental = GL_TRUE;
120 GLenum err = glewInit();
121 if (err != GLEW_OK || !GLEW_VERSION_3_2)
122 {
123 fprintf( stderr, "Failed to initialize GLEW\n" );
124 glfwDestroyWindow(gWindow);
125 gWindow = NULL;
126 glfwTerminate();
127 return false;
128 }
129
130 ClearAllSurfaces();
131

Callers 1

CreateMethod · 0.45

Calls 1

initglFunction · 0.85

Tested by

no test coverage detected