Changeset bae0911 in opengl-game
- Timestamp:
- May 10, 2019, 9:09:49 PM (6 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- caa2359
- Parents:
- 155a7cf
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TODO.txt
r155a7cf rbae0911 2 2 ========== 3 3 -Change the logger class to use cout instead of printf. Consider how easy variable argument support would be. 4 -Change all error messages to use the logger class so they get printed to the log file as well. 4 - What I really need to do is completely refactor the logger class to return an ofstream to the logger file 5 and use streaming to send output to it. The log file can be closed in the destructor. 5 6 -Add code to allow for resizing/maximizing the window 6 -Add logic to make imgui element placement depedent on the window size so it works in fullscreen 7 - Doesn't seem to be necessary on OSX anymore, check that in works on Window and Linux, including removing 8 the window title bar in fullscreen mode and bringing it back in windowed mode 7 9 -Check the book's "Printing Parameters from the GL Context" to output a bunch of OpenGL context params 8 10 -Move some common functions into a Utils class … … 13 15 -Fix the texture-mapping code to not flip the texture upside down. 14 16 -Make sure fullscreen works correctly on OSX. Check the book to see how to handle Retina Display. 17 -Change all error messages to use the logger class so they get printed to the log file as well. 15 18 16 19 NEW TODO -
logger.cpp
r155a7cf rbae0911 5 5 #include <cstdarg> 6 6 #include <iostream> 7 8 using namespace std;9 7 10 8 bool restart_gl_log() { … … 15 13 } 16 14 time_t now = time(NULL); 17 char* date = ctime(&now);18 fprintf(file, "GL_LOG_FILE log. local time %s\n", date );15 string date(ctime(&now)); 16 fprintf(file, "GL_LOG_FILE log. local time %s\n", date.c_str()); 19 17 fclose(file); 20 18 return true; 21 19 } 22 20 23 bool gl_log(const char*message, ...) {21 bool gl_log(const string message, ...) { 24 22 va_list argptr; 25 23 FILE* file = fopen(GL_LOG_FILE, "a"); … … 28 26 return false; 29 27 } 30 va_start(argptr, message );31 vfprintf(file, message , argptr);28 va_start(argptr, message.c_str()); 29 vfprintf(file, message.c_str(), argptr); 32 30 va_end(argptr); 33 31 fprintf(file, "\n"); … … 36 34 } 37 35 38 bool gl_log_err(const char*message, ...) {36 bool gl_log_err(const string message, ...) { 39 37 va_list argptr; 40 38 FILE* file = fopen(GL_LOG_FILE, "a"); … … 43 41 return false; 44 42 } 45 va_start(argptr, message );46 vfprintf(file, message , argptr);43 va_start(argptr, message.c_str()); 44 vfprintf(file, message.c_str(), argptr); 47 45 va_end(argptr); 48 46 fprintf(file, "\n"); 49 va_start(argptr, message );50 vfprintf(stderr, message , argptr);47 va_start(argptr, message.c_str()); 48 vfprintf(stderr, message.c_str(), argptr); 51 49 va_end(argptr); 52 50 fprintf(stderr, "\n"); -
logger.h
r155a7cf rbae0911 1 1 #ifndef LOGGER_H 2 2 #define LOGGER_H 3 4 #include <string> 5 6 using namespace std; 3 7 4 8 #define GL_LOG_FILE "gl.log" 5 9 6 10 bool restart_gl_log(); 7 bool gl_log(const char*message, ...);8 bool gl_log_err(const char*message, ...);11 bool gl_log(const string message, ...); 12 bool gl_log_err(const string message, ...); 9 13 10 14 #endif -
new-game.cpp
r155a7cf rbae0911 301 301 cout << "New OpenGL Game" << endl; 302 302 303 if (!restart_gl_log()) {}304 gl_log("starting GLFW\n%s \n", glfwGetVersionString());303 restart_gl_log(); 304 gl_log("starting GLFW\n%s", glfwGetVersionString()); 305 305 306 306 glfwSetErrorCallback(glfw_error_callback); 307 307 if (!glfwInit()) { 308 cerr << "ERROR: could not start GLFW3" << endl;308 gl_log_err("ERROR: could not start GLFW3"); 309 309 return 1; 310 310 } … … 337 337 338 338 if (!window) { 339 cerr << "ERROR: could not open window with GLFW3" << endl;;339 gl_log_err("ERROR: could not open window with GLFW3"); 340 340 glfwTerminate(); 341 341 return 1; … … 403 403 const GLubyte* version = glGetString(GL_VERSION); 404 404 cout << "Renderer: " << renderer << endl; 405 cout << "OpenGL version supported " << version << endl; 405 cout << "Supported OpenGL version: " << version << endl; 406 407 gl_log("Renderer: %s", renderer); 408 gl_log("Supported OpenGL version: %s", version); 406 409 407 410 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); … … 976 979 977 980 void glfw_error_callback(int error, const char* description) { 978 gl_log_err("GLFW ERROR: code %i msg: %s \n", error, description);981 gl_log_err("GLFW ERROR: code %i msg: %s", error, description); 979 982 } 980 983 … … 1217 1220 1218 1221 if (!image_data) { 1219 cerr << "ERROR: could not load " << file_name << endl;1222 gl_log_err("ERROR: could not load %s", file_name.c_str()); 1220 1223 } 1221 1224 1222 1225 // Not Power-of-2 check 1223 1226 if ((*x & (*x - 1)) != 0 || (*y & (*y - 1)) != 0) { 1224 cerr << "WARNING: texture " << file_name << " is not power-of-2 dimensions" << endl;1227 gl_log_err("WARNING: texture %s is not power-of-2 dimensions", file_name.c_str()); 1225 1228 } 1226 1229
Note:
See TracChangeset
for help on using the changeset viewer.