Browse Source

math.h do not like my logger..

Rename log() to Log()
Godzil 3 years ago
parent
commit
e763e6233c
4 changed files with 31 additions and 31 deletions
  1. 7 7
      source/display.c
  2. 5 5
      source/include/log.h
  3. 3 3
      source/main.c
  4. 16 16
      source/mesh.c

+ 7 - 7
source/display.c

@@ -39,15 +39,15 @@ bool initialiseWindow(bool fullScreen)
 
     if (SDL_Init(SDL_INIT_EVERYTHING))
     {
-        log(TLOG_PANIC, NULL, "SDL Initialisation error!! error: %s", SDL_GetError());
+        Log(TLOG_PANIC, NULL, "SDL Initialisation error!! error: %s", SDL_GetError());
         goto exit;
     }
 
-    log(TLOG_DEBUG, NULL, "SDL properly initialised!");
+    Log(TLOG_DEBUG, NULL, "SDL properly initialised!");
 
     if (fullScreen)
     {
-        log(TLOG_DEBUG, NULL, "Will go fullscreen! Fasten your seatbelts!");
+        Log(TLOG_DEBUG, NULL, "Will go fullscreen! Fasten your seatbelts!");
         SDL_DisplayMode displayMode;
         SDL_GetCurrentDisplayMode(0, &displayMode);
 
@@ -61,18 +61,18 @@ bool initialiseWindow(bool fullScreen)
                               windowFlags);
     if (window == NULL)
     {
-        log(TLOG_PANIC, NULL, "SDL Window creation error: %s", SDL_GetError());
+        Log(TLOG_PANIC, NULL, "SDL Window creation error: %s", SDL_GetError());
         goto exit;
     }
-    log(TLOG_DEBUG, NULL, "SDL Window created!");
+    Log(TLOG_DEBUG, NULL, "SDL Window created!");
 
     renderer = SDL_CreateRenderer(window, -1, 0);
     if (renderer == NULL)
     {
-        log(TLOG_PANIC, NULL, "SDL Renderer creation error: %s", SDL_GetError());
+        Log(TLOG_PANIC, NULL, "SDL Renderer creation error: %s", SDL_GetError());
         goto exit;
     }
-    log(TLOG_DEBUG, NULL, "SDL Renderer created!");
+    Log(TLOG_DEBUG, NULL, "SDL Renderer created!");
 
     if (fullScreen)
     {

+ 5 - 5
source/include/log.h

@@ -65,7 +65,7 @@ extern int MAX_DEBUG_LEVEL;
 # endif
 #endif
 
-#define log(_level, _user, _fmt, ...)\
+#define Log(_level, _user, _fmt, ...)\
  if (_level <= MAXIMUM_DEBUG_LEVEL)\
   if ((_level <= MAX_DEBUG_LEVEL) || (_level <= TLOG_PANIC))\
    do { log_real(_level, _user, _fmt, ##__VA_ARGS__); } while(0)
@@ -75,15 +75,15 @@ void log_real(int level, const char *user, const char *fmt, ...);
 #define LOG(_level, _str, ...) if ((_level <= MAX_DEBUG_LEVEL) || (_level <= TLOG_PANIC)) do { fputs(_str, stderr); } while(0)
 #define LOGCODE(_level, _user, _code)\
    if (_level <= MAXIMUM_DEBUG_LEVEL) do{\
-    log(_level, _user, "");\
+    Log(_level, _user, "");\
     if ((_level <= MAX_DEBUG_LEVEL) || (_level <= TLOG_PANIC))\
        do { _code; fprintf(stderr, "\n"); } while(0); } while(0)
 
 #define INFOL(_level, _fmt) LOGCODE(_level, "INFOL", { printf _fmt; })
 
-#define FUNC_IN() log(TLOG_VERBOSE, NULL, ">>%s", __func__)
-#define FUNC_OUT() log(TLOG_VERBOSE, NULL, "<<%s", __func__)
-#define FUNC_OUTR(out) log(TLOG_VERBOSE, NULL, "<<%s (%d)", __func__, out)
+#define FUNC_IN() Log(TLOG_VERBOSE, NULL, ">>%s", __func__)
+#define FUNC_OUT() Log(TLOG_VERBOSE, NULL, "<<%s", __func__)
+#define FUNC_OUTR(out) Log(TLOG_VERBOSE, NULL, "<<%s (%d)", __func__, out)
 
 void log_displayPanic(int signal);
 

+ 3 - 3
source/main.c

@@ -50,7 +50,7 @@ void setup()
     frameBuffer = (uint32_t *)calloc(windowWidth * windowHeight, sizeof(uint32_t));
     if (!frameBuffer)
     {
-        log(TLOG_PANIC, NULL, "Memory allocation error.");
+        Log(TLOG_PANIC, NULL, "Memory allocation error.");
         goto exit;
     }
 
@@ -58,7 +58,7 @@ void setup()
                                            windowHeight);
     if (frameBufferTexture == NULL)
     {
-        log(TLOG_PANIC, NULL, "SDL Texture creation error: %s", SDL_GetError());
+        Log(TLOG_PANIC, NULL, "SDL Texture creation error: %s", SDL_GetError());
         goto exit;
     }
 
@@ -289,7 +289,7 @@ int main(int argc, char *argv[])
     bool fullScreen = false;
     MAX_DEBUG_LEVEL = TLOG_DEBUG;
 
-    log(TLOG_ALWAYS, NULL, "Booting 3D Engine (version %s)!", VERSION);
+    Log(TLOG_ALWAYS, NULL, "Booting 3D Engine (version %s)!", VERSION);
 
     for (param_i = 1 ; (param_i < argc) && (argv[param_i][0] == '-') ; param_i++)
     {

+ 16 - 16
source/mesh.c

@@ -133,22 +133,22 @@ void loadOBJFile(const char *filepath)
 
         if (objFileLoaderParser(fileBuff))
         {
-            log(TLOG_ERROR, "OBJLoader", "Errors occurred while opening the file '%s'.", filepath);
+            Log(TLOG_ERROR, "OBJLoader", "Errors occurred while opening the file '%s'.", filepath);
         }
 
-        log(TLOG_VERBOSE, "OBJLoader", "OBJ File '%s' loaded. Some stats:", filepath);
-        log(TLOG_VERBOSE, "OBJLoader", "Total ignored lines         : %lu", objFileLoaderIgnoredLines);
-        log(TLOG_VERBOSE, "OBJLoader", "Number of vertices          : %lu", objFileLoaderLoadedVertices);
-        log(TLOG_VERBOSE, "OBJLoader", "Number of normal vertices   : %lu", objFileLoaderLoadedVerticesNormal);
-        log(TLOG_VERBOSE, "OBJLoader", "Number of texture vertices  : %lu", objFileLoaderLoadedVerticesTexture);
-        log(TLOG_VERBOSE, "OBJLoader", "Number of faces in file     : %lu", objFileLoaderLoadedFaces);
-        log(TLOG_VERBOSE, "OBJLoader", "Number of created triangles : %lu", objFileLoaderTotalTri);
+        Log(TLOG_VERBOSE, "OBJLoader", "OBJ File '%s' loaded. Some stats:", filepath);
+        Log(TLOG_VERBOSE, "OBJLoader", "Total ignored lines         : %lu", objFileLoaderIgnoredLines);
+        Log(TLOG_VERBOSE, "OBJLoader", "Number of vertices          : %lu", objFileLoaderLoadedVertices);
+        Log(TLOG_VERBOSE, "OBJLoader", "Number of normal vertices   : %lu", objFileLoaderLoadedVerticesNormal);
+        Log(TLOG_VERBOSE, "OBJLoader", "Number of texture vertices  : %lu", objFileLoaderLoadedVerticesTexture);
+        Log(TLOG_VERBOSE, "OBJLoader", "Number of faces in file     : %lu", objFileLoaderLoadedFaces);
+        Log(TLOG_VERBOSE, "OBJLoader", "Number of created triangles : %lu", objFileLoaderTotalTri);
 
         free(fileBuff);
     }
     else
     {
-        log(TLOG_ERROR, "OBJLoader", "Can't open/find the file '%s'.", filepath);
+        Log(TLOG_ERROR, "OBJLoader", "Can't open/find the file '%s'.", filepath);
     }
 }
 
@@ -178,7 +178,7 @@ static int objFileLoaderParser(const char *content)
         }
         if (lineLength >= MAX_LINE_LENGTH)
         {
-            log(TLOG_ERROR, "OBJLoader", "Line %d is too long! (%d)", currentLineNum, lineLength);
+            Log(TLOG_ERROR, "OBJLoader", "Line %d is too long! (%d)", currentLineNum, lineLength);
             return -1;
         }
         memset(lineBuff, 0, MAX_LINE_LENGTH);
@@ -268,7 +268,7 @@ static int objFileLoaderParseFaceVertex(char *buf, uint32_t *v, uint32_t  *vt, u
             case 1: *vt = atol(buf); break;
             case 2: *vn = atol(buf); break;
             default:
-                log(TLOG_ERROR, "OBJLoader", "Too many entry for a face vertex!");
+                Log(TLOG_ERROR, "OBJLoader", "Too many entry for a face vertex!");
                 ret = 1;
                 break;
             }
@@ -289,7 +289,7 @@ int objFileLoaderExecuteLine(int argc, char *argv[], uint32_t currentLine)
         /* Vertice entry */
         if (argc != 4)
         {
-            log(TLOG_ERROR, "OBJLoader", "Malformed file at line %d: Vertices expect 3 parameters!", currentLine);
+            Log(TLOG_ERROR, "OBJLoader", "Malformed file at line %d: Vertices expect 3 parameters!", currentLine);
         }
         else
         {
@@ -304,7 +304,7 @@ int objFileLoaderExecuteLine(int argc, char *argv[], uint32_t currentLine)
         /* Vertice Normal entry */
         if (argc != 4)
         {
-            log(TLOG_ERROR, "OBJLoader", "Malformed file at line %d: Vertices normal expect 3 parameters!", currentLine);
+            Log(TLOG_ERROR, "OBJLoader", "Malformed file at line %d: Vertices normal expect 3 parameters!", currentLine);
         }
         else
         {
@@ -319,7 +319,7 @@ int objFileLoaderExecuteLine(int argc, char *argv[], uint32_t currentLine)
         /* Vertice Normal entry */
         if ((argc < 3) || (argc > 4))
         {
-            log(TLOG_ERROR, "OBJLoader", "Malformed file at line %d: Vertices texture expect 2 or 3 parameters!", currentLine);
+            Log(TLOG_ERROR, "OBJLoader", "Malformed file at line %d: Vertices texture expect 2 or 3 parameters!", currentLine);
         }
         else
         {
@@ -363,7 +363,7 @@ int objFileLoaderExecuteLine(int argc, char *argv[], uint32_t currentLine)
         }
         else
         {
-            log(TLOG_ERROR, "OBJLoader", "Malformed file at line %d: Too few/many parameters!", currentLine);
+            Log(TLOG_ERROR, "OBJLoader", "Malformed file at line %d: Too few/many parameters!", currentLine);
         }
     }
     /* We ignore groups for now, may use it later. */
@@ -376,7 +376,7 @@ int objFileLoaderExecuteLine(int argc, char *argv[], uint32_t currentLine)
         }
         else
         {
-            log(TLOG_ERROR, "OBJLoader", "Malformed file at line %d: Too few/many parameters!", currentLine);
+            Log(TLOG_ERROR, "OBJLoader", "Malformed file at line %d: Too few/many parameters!", currentLine);
         }
     }
 #endif