Changeset 98f06d9 in opengl-game
- Timestamp:
- May 24, 2019, 8:01:34 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- a23fc08
- Parents:
- d9b6a1c
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
rd9b6a1c r98f06d9 5 5 6 6 gl.log 7 game.log 7 8 crash.log 8 9 -
TODO.txt
rd9b6a1c r98f06d9 1 1 TODO 2 2 ========== 3 -Change the logger class to use cout instead of printf. Consider how easy variable argument support would be.4 - What I really need to do is completely refactor the logger class to return an ofstream to the logger file5 and use streaming to send output to it. The log file can be closed in the destructor.6 3 -Add code to allow for resizing/maximizing the window 7 4 - Doesn't seem to be necessary on OSX anymore, check that in works on Window and Linux, including removing 8 5 the window title bar in fullscreen mode and bringing it back in windowed mode 6 -Update the IMGUI code in a generic way to support this as well 9 7 -Check the book's "Printing Parameters from the GL Context" to output a bunch of OpenGL context params 10 8 -Move some common functions into a Utils class … … 16 14 -Make sure fullscreen works correctly on OSX. Check the book to see how to handle Retina Display. 17 15 -Change all error messages to use the logger class so they get printed to the log file as well. 16 -Change the logger class to use cout instead of printf. Consider how easy variable argument support would be. 17 - What I really need to do is completely refactor the logger class to return an ofstream to the logger file 18 and use streaming to send output to it. The log file can be closed in the destructor. 18 19 19 20 NEW TODO -
logger.cpp
rd9b6a1c r98f06d9 52 52 return true; 53 53 } 54 55 ofstream ofs; 56 57 void open_log() { 58 ofs.open(LOG_FILE, ios::out); 59 60 time_t now = time(NULL); 61 string date(ctime(&now)); 62 ofs << "LOG_FILE log. local time " << date << endl; 63 } 64 65 ofstream& get_log() { 66 return ofs; 67 } 68 69 void close_log() { 70 ofs.close(); 71 } -
logger.h
rd9b6a1c r98f06d9 3 3 4 4 #include <string> 5 #include <fstream> 5 6 6 7 using namespace std; 7 8 8 9 #define GL_LOG_FILE "gl.log" 10 #define LOG_FILE "game.log" 11 12 extern ofstream ofs; 9 13 10 14 bool restart_gl_log(); … … 12 16 bool gl_log_err(const string message, ...); 13 17 18 void open_log(); 19 ofstream& get_log(); 20 void close_log(); 21 14 22 #endif -
new-game.cpp
rd9b6a1c r98f06d9 346 346 gl_log("starting GLFW\n%s", glfwGetVersionString()); 347 347 348 open_log(); 349 get_log() << "starting GLFW" << endl; 350 get_log() << glfwGetVersionString() << endl; 351 348 352 glfwSetErrorCallback(glfw_error_callback); 349 353 if (!glfwInit()) { 350 354 gl_log_err("ERROR: could not start GLFW3"); 355 cerr << "ERROR: could not start GLFW3" << endl; 356 get_log() << "ERROR: could not start GLFW3" << endl; 351 357 return 1; 352 358 } … … 380 386 if (!window) { 381 387 gl_log_err("ERROR: could not open window with GLFW3"); 388 cerr << "ERROR: could not open window with GLFW3" << endl; 389 get_log() << "ERROR: could not open window with GLFW3" << endl; 382 390 glfwTerminate(); 383 391 return 1; … … 449 457 gl_log("Renderer: %s", renderer); 450 458 gl_log("Supported OpenGL version: %s", version); 459 460 get_log() << "Renderer: " << renderer << endl; 461 get_log() << "Supported OpenGL version: " << version << endl; 451 462 452 463 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); … … 1011 1022 glfwTerminate(); 1012 1023 1024 close_log(); 1025 1013 1026 // free memory 1014 1027 … … 1034 1047 void glfw_error_callback(int error, const char* description) { 1035 1048 gl_log_err("GLFW ERROR: code %i msg: %s", error, description); 1049 cerr << "GLFW ERROR: code " << error << " msg: " << description << endl; 1050 get_log() << "GLFW ERROR: code " << error << " msg: " << description << endl; 1036 1051 } 1037 1052 … … 1275 1290 if (!image_data) { 1276 1291 gl_log_err("ERROR: could not load %s", file_name.c_str()); 1292 cerr << "ERROR: could not load " << file_name << endl; 1293 get_log() << "ERROR: could not load " << file_name << endl; 1277 1294 } 1278 1295 … … 1280 1297 if ((*x & (*x - 1)) != 0 || (*y & (*y - 1)) != 0) { 1281 1298 gl_log_err("WARNING: texture %s is not power-of-2 dimensions", file_name.c_str()); 1299 cerr << "WARNING: texture " << file_name << " is not power-of-2 dimensions" << endl; 1300 get_log() << "WARNING: texture " << file_name << " is not power-of-2 dimensions" << endl; 1282 1301 } 1283 1302
Note:
See TracChangeset
for help on using the changeset viewer.