Changeset 92cbc6a in opengl-game
- Timestamp:
- Sep 15, 2019, 5:37:50 AM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- c1d9b2a
- Parents:
- a6f6833
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
opengl-game.cpp
ra6f6833 r92cbc6a 73 73 74 74 void OpenGLGame::initOpenGL() { 75 glfwMakeContextCurrent(window); 76 glViewport(0, 0, gui->getWindowWidth(), gui->getWindowHeight()); 77 78 glewExperimental = GL_TRUE; 79 glewInit(); 80 81 if (GLEW_KHR_debug) { 82 cout << "FOUND GLEW debug extension" << endl; 83 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); 84 glDebugMessageCallback((GLDEBUGPROC)opengl_debug_callback, nullptr); 85 cout << "Bound debug callback" << endl; 86 } else { 87 cout << "OpenGL debug message callback is not supported" << endl; 88 } 75 89 } 76 90 … … 100 114 } 101 115 116 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 117 118 // Anton's book suggests placing this here, after glClear(). Check it's impact on framerate 119 // TODO: This doesn't seem to work correctly when in the loop. DO some research 120 // max viewport dims are clamped to glGet(GL_MAX_VIEWPORT_DIMS) 121 //glViewport(0, 0, gui->getWindowWidth(), gui->getWindowHeight()); 122 102 123 glfwSwapBuffers(window); 103 124 } … … 109 130 delete gui; 110 131 } 132 133 void APIENTRY opengl_debug_callback( 134 GLenum source, 135 GLenum type, 136 GLuint id, 137 GLenum severity, 138 GLsizei length, 139 const GLchar* message, 140 const void* userParam 141 ) { 142 string strMessage(message); 143 144 // TODO: Use C++ strings directly and see if there are other ways to clean 145 // this function up 146 char source_str[2048]; 147 char type_str[2048]; 148 char severity_str[2048]; 149 150 switch (source) { 151 case 0x8246: 152 strcpy(source_str, "API"); 153 break; 154 case 0x8247: 155 strcpy(source_str, "WINDOW_SYSTEM"); 156 break; 157 case 0x8248: 158 strcpy(source_str, "SHADER_COMPILER"); 159 break; 160 case 0x8249: 161 strcpy(source_str, "THIRD_PARTY"); 162 break; 163 case 0x824A: 164 strcpy(source_str, "APPLICATION"); 165 break; 166 case 0x824B: 167 strcpy(source_str, "OTHER"); 168 break; 169 default: 170 strcpy(source_str, "undefined"); 171 break; 172 } 173 174 switch (type) { 175 case 0x824C: 176 strcpy(type_str, "ERROR"); 177 break; 178 case 0x824D: 179 strcpy(type_str, "DEPRECATED_BEHAVIOR"); 180 break; 181 case 0x824E: 182 strcpy(type_str, "UNDEFINED_BEHAVIOR"); 183 break; 184 case 0x824F: 185 strcpy(type_str, "PORTABILITY"); 186 break; 187 case 0x8250: 188 strcpy(type_str, "PERFORMANCE"); 189 break; 190 case 0x8251: 191 strcpy(type_str, "OTHER"); 192 break; 193 case 0x8268: 194 strcpy(type_str, "MARKER"); 195 break; 196 case 0x8269: 197 strcpy(type_str, "PUSH_GROUP"); 198 break; 199 case 0x826A: 200 strcpy(type_str, "POP_GROUP"); 201 break; 202 default: 203 strcpy(type_str, "undefined"); 204 break; 205 } 206 switch (severity) { 207 case 0x9146: 208 strcpy(severity_str, "HIGH"); 209 break; 210 case 0x9147: 211 strcpy(severity_str, "MEDIUM"); 212 break; 213 case 0x9148: 214 strcpy(severity_str, "LOW"); 215 break; 216 case 0x826B: 217 strcpy(severity_str, "NOTIFICATION"); 218 break; 219 default: 220 strcpy(severity_str, "undefined"); 221 break; 222 } 223 224 if (string(severity_str) != "NOTIFICATION") { 225 cout << "OpenGL Error!!!" << endl; 226 cout << "Source: " << string(source_str) << endl; 227 cout << "Type: " << string(type_str) << endl; 228 cout << "Severity: " << string(severity_str) << endl; 229 cout << strMessage << endl; 230 } 231 } -
opengl-game.hpp
ra6f6833 r92cbc6a 21 21 }; 22 22 23 void APIENTRY opengl_debug_callback( 24 GLenum source, 25 GLenum type, 26 GLuint id, 27 GLenum severity, 28 GLsizei length, 29 const GLchar* message, 30 const void* userParam 31 ); 32 23 33 #endif // _OPENGL_GAME_H
Note:
See TracChangeset
for help on using the changeset viewer.