Changeset 6abfd07 in opengl-game for new-game.cpp
- Timestamp:
- May 31, 2019, 6:26:19 PM (6 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- b373466
- Parents:
- a23fc08
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
new-game.cpp
ra23fc08 r6abfd07 35 35 #include "Compiler.h" 36 36 37 #ifdef WINDOWS 38 #include <windows.h> 39 #include <excpt.h> 40 #include <io.h> 41 42 #include "FileStackWalker.h" 43 #else 44 // TODO: Move as much Windows crash-logging stuff into CrashLogger as well 45 #include "CrashLogger.h" 46 #endif 37 #include "CrashLogger.h" 47 38 48 39 using namespace std; … … 300 291 */ 301 292 302 CrashLogger logger;303 304 293 // Helps to test logging during crashes 305 /* 306 void badFunc() { 294 int badFunc() { 307 295 int* test = NULL; 296 297 string test2 = "lol"; 298 cout << test2 << endl; 299 308 300 *test = 1; 309 } 310 */ 311 312 #ifdef WINDOWS 313 314 // Give it a file handle to crash.log instead (using the code in CrashLogger.cpp) 315 FileStackWalker sw(2); 316 317 bool handleException(unsigned int expCode, EXCEPTION_POINTERS* pExp, HANDLE thread); 318 #endif 301 return *test; 302 } 303 304 int __main(int argc, char* argv[]); 319 305 320 306 int main(int argc, char* argv[]) { 321 #ifdef WINDOWS 322 __try { 323 __main(argc, argv); 324 // maybe do this and call a function inside CrashLogger 325 // In that case, also pass GetCurrentThread() as a parameter to then pass to handleException 326 // I could also move almost all of this into CrashLogger by creating a function in CrashLogger that takes a reference 327 // to the effective main function and, for Windows, wraps it in all this error-handling stuff 328 } __except( handleException(GetExceptionCode(), GetExceptionInformation(), GetCurrentThread()) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_EXECUTE_HANDLER) { 329 _write(2, "CAUGHT\n", 7); 330 } 307 CrashLogger logger(__main, argc, argv); 331 308 332 309 exit(0); … … 334 311 335 312 int __main(int argc, char* argv[]) { 336 #endif337 313 cout << "New OpenGL Game" << endl; 338 314 … … 1023 999 delete *it; 1024 1000 } 1025 } 1026 1027 #ifdef WINDOWS 1028 bool handleException(unsigned int expCode, EXCEPTION_POINTERS* pExp, HANDLE thread) { 1029 if (pExp != NULL) { 1030 sw.ShowCallstack(thread, pExp->ContextRecord); 1031 } 1032 1033 if (expCode == EXCEPTION_ACCESS_VIOLATION) { 1034 _write(2, "ACCESS VIOLATION\n", 17); 1035 } 1036 1037 return true; 1038 } 1039 #endif 1001 1002 return 0; 1003 } 1040 1004 1041 1005 void glfw_error_callback(int error, const char* description) {
Note:
See TracChangeset
for help on using the changeset viewer.