Bladeren bron

misc: carry on with the lowercase rampage.

Using “Array” instead of “array” is now fully deprecated, and I replaced
the Log::Debug() etc. functions with msg::debug() etc. because log:: was
unavailable due to being a maths function.

Added up-to-date copyright notice and BOM to modified files, just in case.
undefined
Sam Hocevar 10 jaren geleden
bovenliggende
commit
70edc0d38e
38 gewijzigde bestanden met toevoegingen van 492 en 461 verwijderingen
  1. +18
    -17
      doc/samples/benchmark/half.cpp
  2. +13
    -12
      doc/samples/benchmark/real.cpp
  3. +20
    -19
      doc/samples/benchmark/trig.cpp
  4. +13
    -12
      doc/samples/benchmark/vector.cpp
  5. +28
    -27
      doc/samples/benchsuite.cpp
  6. +9
    -8
      doc/tutorial/14_lol_lua.cpp
  7. +11
    -10
      src/base/assert.cpp
  8. +22
    -21
      src/base/log.cpp
  9. +9
    -8
      src/dict.cpp
  10. +22
    -21
      src/eglapp.cpp
  11. +10
    -9
      src/entity.cpp
  12. +10
    -9
      src/gpu/renderer.cpp
  13. +20
    -20
      src/gpu/shader.cpp
  14. +8
    -7
      src/gpu/vertexbuffer.cpp
  15. +11
    -10
      src/image/codec/android-image.cpp
  16. +16
    -15
      src/image/codec/gdiplus-image.cpp
  17. +9
    -8
      src/image/codec/imlib2-image.cpp
  18. +8
    -7
      src/image/codec/ios-image.cpp
  19. +8
    -7
      src/image/codec/sdl-image.cpp
  20. +6
    -6
      src/image/image.cpp
  21. +17
    -16
      src/input/controller.cpp
  22. +28
    -15
      src/lol/algorithm/sort.h
  23. +19
    -29
      src/lol/base/array.h
  24. +10
    -9
      src/lol/base/assert.h
  25. +19
    -18
      src/lol/base/log.h
  26. +5
    -5
      src/lolimgui.cpp
  27. +7
    -7
      src/lolua/baselua.cpp
  28. +17
    -16
      src/math/vector.cpp
  29. +8
    -7
      src/mesh/mesh.cpp
  30. +15
    -14
      src/platform/android/androidapp.cpp
  31. +10
    -9
      src/platform/sdl/sdlapp.cpp
  32. +12
    -11
      src/platform/sdl/sdlinput.cpp
  33. +8
    -7
      src/sample.cpp
  34. +12
    -11
      src/sys/init.cpp
  35. +3
    -3
      src/sys/threadtypes.cpp
  36. +4
    -4
      src/t/base/map.cpp
  37. +12
    -12
      src/t/sys/thread.cpp
  38. +15
    -15
      src/ticker.cpp

+ 18
- 17
doc/samples/benchmark/half.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine - Benchmark program // Lol Engine — Benchmark program
// //
// Copyright: (c) 2005-2011 Sam Hocevar <sam@hocevar.net> // Copyright: © 2005—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This program is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#if HAVE_CONFIG_H #if HAVE_CONFIG_H
@@ -110,16 +111,16 @@ void bench_half(int mode)
for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++) for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++)
result[i] *= 1e9f / (HALF_TABLE_SIZE * HALF_RUNS); result[i] *= 1e9f / (HALF_TABLE_SIZE * HALF_RUNS);


Log::Info(" ns/elem\n"); msg::info(" ns/elem\n");
Log::Info("float = half (array) %7.3f\n", result[0]); msg::info("float = half (array) %7.3f\n", result[0]);
Log::Info("float = half (fast) %7.3f\n", result[1]); msg::info("float = half (fast) %7.3f\n", result[1]);
Log::Info("float = float %7.3f\n", result[2]); msg::info("float = float %7.3f\n", result[2]);
Log::Info("float += half %7.3f\n", result[3]); msg::info("float += half %7.3f\n", result[3]);
Log::Info("half = half %7.3f\n", result[4]); msg::info("half = half %7.3f\n", result[4]);
Log::Info("half = -half %7.3f\n", result[5]); msg::info("half = -half %7.3f\n", result[5]);
Log::Info("half = float (array) %7.3f\n", result[6]); msg::info("half = float (array) %7.3f\n", result[6]);
Log::Info("half = float (fast) %7.3f\n", result[7]); msg::info("half = float (fast) %7.3f\n", result[7]);
Log::Info("half = float (accurate) %7.3f\n", result[8]); msg::info("half = float (accurate) %7.3f\n", result[8]);
Log::Info("half += float %7.3f\n", result[9]); msg::info("half += float %7.3f\n", result[9]);
} }



+ 13
- 12
doc/samples/benchmark/real.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine - Benchmark program // Lol Engine — Benchmark program
// //
// Copyright: (c) 2005-2011 Sam Hocevar <sam@hocevar.net> // Copyright: © 2005—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This program is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#if HAVE_CONFIG_H #if HAVE_CONFIG_H
@@ -70,11 +71,11 @@ void bench_real(int mode)
for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++) for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++)
result[i] *= 1e9f / (REAL_TABLE_SIZE * REAL_RUNS); result[i] *= 1e9f / (REAL_TABLE_SIZE * REAL_RUNS);


Log::Info(" ns/elem\n"); msg::info(" ns/elem\n");
Log::Info("real = real + real %7.3f\n", result[0]); msg::info("real = real + real %7.3f\n", result[0]);
Log::Info("real = real * real %7.3f\n", result[1]); msg::info("real = real * real %7.3f\n", result[1]);
Log::Info("real = real / real %7.3f\n", result[2]); msg::info("real = real / real %7.3f\n", result[2]);
Log::Info("real = sin(real) %7.3f\n", result[3]); msg::info("real = sin(real) %7.3f\n", result[3]);
Log::Info("real = exp(real) %7.3f\n", result[4]); msg::info("real = exp(real) %7.3f\n", result[4]);
} }



+ 20
- 19
doc/samples/benchmark/trig.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine - Benchmark program // Lol Engine — Benchmark program
// //
// Copyright: (c) 2005-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2005—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This program is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#if HAVE_CONFIG_H #if HAVE_CONFIG_H
@@ -173,18 +174,18 @@ void bench_trig(int mode)
for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++) for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++)
result[i] *= 1e9f / (TRIG_TABLE_SIZE * TRIG_RUNS); result[i] *= 1e9f / (TRIG_TABLE_SIZE * TRIG_RUNS);


Log::Info(" ns/elem\n"); msg::info(" ns/elem\n");
Log::Info("float = sinf(float) %7.3f\n", result[0]); msg::info("float = sinf(float) %7.3f\n", result[0]);
Log::Info("float = f_sinf(float) %7.3f\n", result[1]); msg::info("float = f_sinf(float) %7.3f\n", result[1]);
Log::Info("float = lol_sin(float) %7.3f\n", result[2]); msg::info("float = lol_sin(float) %7.3f\n", result[2]);
Log::Info("float = cosf(float) %7.3f\n", result[3]); msg::info("float = cosf(float) %7.3f\n", result[3]);
Log::Info("float = f_cosf(float) %7.3f\n", result[4]); msg::info("float = f_cosf(float) %7.3f\n", result[4]);
Log::Info("float = lol_cos(float) %7.3f\n", result[5]); msg::info("float = lol_cos(float) %7.3f\n", result[5]);
Log::Info("float = sinf,cosf(float) %7.3f\n", result[6]); msg::info("float = sinf,cosf(float) %7.3f\n", result[6]);
Log::Info("float = f_sinf,f_cosf(float) %7.3f\n", result[7]); msg::info("float = f_sinf,f_cosf(float) %7.3f\n", result[7]);
Log::Info("float = lol_sincos(float) %7.3f\n", result[8]); msg::info("float = lol_sincos(float) %7.3f\n", result[8]);
Log::Info("float = tanf(float) %7.3f\n", result[9]); msg::info("float = tanf(float) %7.3f\n", result[9]);
Log::Info("float = f_tanf(float) %7.3f\n", result[10]); msg::info("float = f_tanf(float) %7.3f\n", result[10]);
Log::Info("float = lol_tanf(float) %7.3f\n", result[11]); msg::info("float = lol_tanf(float) %7.3f\n", result[11]);
} }



+ 13
- 12
doc/samples/benchmark/vector.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine - Benchmark program // Lol Engine — Benchmark program
// //
// Copyright: (c) 2005-2011 Sam Hocevar <sam@hocevar.net> // Copyright: © 2005—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This program is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#if HAVE_CONFIG_H #if HAVE_CONFIG_H
@@ -79,11 +80,11 @@ void bench_matrix(int mode)
for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++) for (size_t i = 0; i < sizeof(result) / sizeof(*result); i++)
result[i] *= 1e9f / (MATRIX_TABLE_SIZE * MATRIX_RUNS); result[i] *= 1e9f / (MATRIX_TABLE_SIZE * MATRIX_RUNS);


Log::Info(" ns/elem\n"); msg::info(" ns/elem\n");
Log::Info("mat4 = mat4 %7.3f\n", result[0]); msg::info("mat4 = mat4 %7.3f\n", result[0]);
Log::Info("float = mat4.det() %7.3f\n", result[1]); msg::info("float = mat4.det() %7.3f\n", result[1]);
Log::Info("mat4 *= mat4 %7.3f\n", result[2]); msg::info("mat4 *= mat4 %7.3f\n", result[2]);
Log::Info("mat4 += mat4 %7.3f\n", result[3]); msg::info("mat4 += mat4 %7.3f\n", result[3]);
Log::Info("mat4 = mat4.invert() %7.3f\n", result[4]); msg::info("mat4 = mat4.invert() %7.3f\n", result[4]);
} }



+ 28
- 27
doc/samples/benchsuite.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine - Benchmark program // Lol Engine — Benchmark program
// //
// Copyright: (c) 2005-2011 Sam Hocevar <sam@hocevar.net> // Copyright: © 2005—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This program is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#if HAVE_CONFIG_H #if HAVE_CONFIG_H
@@ -27,39 +28,39 @@ int main(int argc, char **argv)
{ {
UNUSED(argc, argv); UNUSED(argc, argv);


Log::Info("-----------------------\n"); msg::info("-----------------------\n");
Log::Info(" High precision floats\n"); msg::info(" High precision floats\n");
Log::Info("-----------------------\n"); msg::info("-----------------------\n");
bench_real(1); bench_real(1);


Log::Info("--------------------------\n"); msg::info("--------------------------\n");
Log::Info(" Trigonometry [-1e5, 1e5]\n"); msg::info(" Trigonometry [-1e5, 1e5]\n");
Log::Info("--------------------------\n"); msg::info("--------------------------\n");
bench_trig(1); bench_trig(1);


Log::Info("------------------------\n"); msg::info("------------------------\n");
Log::Info(" Trigonometry [-pi, pi]\n"); msg::info(" Trigonometry [-pi, pi]\n");
Log::Info("------------------------\n"); msg::info("------------------------\n");
bench_trig(2); bench_trig(2);


Log::Info("----------------------------\n"); msg::info("----------------------------\n");
Log::Info(" Trigonometry [-1e-2, 1e-2]\n"); msg::info(" Trigonometry [-1e-2, 1e-2]\n");
Log::Info("----------------------------\n"); msg::info("----------------------------\n");
bench_trig(3); bench_trig(3);


Log::Info("----------------------------\n"); msg::info("----------------------------\n");
Log::Info(" Float matrices [-2.0, 2.0]\n"); msg::info(" Float matrices [-2.0, 2.0]\n");
Log::Info("----------------------------\n"); msg::info("----------------------------\n");
bench_matrix(1); bench_matrix(1);


Log::Info("-------------------------------------\n"); msg::info("-------------------------------------\n");
Log::Info(" Half precision floats (random bits)\n"); msg::info(" Half precision floats (random bits)\n");
Log::Info("-------------------------------------\n"); msg::info("-------------------------------------\n");
bench_half(1); bench_half(1);


Log::Info("-----------------------------------\n"); msg::info("-----------------------------------\n");
Log::Info(" Half precision floats [-2.0, 2.0]\n"); msg::info(" Half precision floats [-2.0, 2.0]\n");
Log::Info("-----------------------------------\n"); msg::info("-----------------------------------\n");
bench_half(2); bench_half(2);


#if defined _WIN32 #if defined _WIN32


+ 9
- 8
doc/tutorial/14_lol_lua.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine - Graphing tutorial // Lol Engine — Graphing tutorial
// //
// Copyright: (c) 2012-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2012—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This program is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#if HAVE_CONFIG_H #if HAVE_CONFIG_H
@@ -170,10 +171,10 @@ public:
float loluademo_inst_return = demo_loader->GetVar<float>("loluademo_inst_return"); float loluademo_inst_return = demo_loader->GetVar<float>("loluademo_inst_return");
DemoObject* loluademo_inst = demo_loader->GetPtr<DemoObject>("loluademo_inst"); DemoObject* loluademo_inst = demo_loader->GetPtr<DemoObject>("loluademo_inst");


Log::Info("Lua Vars: \ msg::info("Lua Vars: \
testvalue_num: %.2f, testvalue_int: %i, testvalue_uint: %i, testvalue_str: %s.\n", testvalue_num: %.2f, testvalue_int: %i, testvalue_uint: %i, testvalue_str: %s.\n",
testvalue_num, testvalue_int, testvalue_uint, testvalue_str.C()); testvalue_num, testvalue_int, testvalue_uint, testvalue_str.C());
Log::Info("Lua Vars: \ msg::info("Lua Vars: \
function_return: %s, loluademo_return: %i, loluademo_inst_return: %.f, loluademo_getx: %i, loluademo_inst->m_x: %i.\n", function_return: %s, loluademo_return: %i, loluademo_inst_return: %.f, loluademo_getx: %i, loluademo_inst->m_x: %i.\n",
function_return.C(), loluademo_return, loluademo_inst_return, loluademo_getx, loluademo_inst->m_x); function_return.C(), loluademo_return, loluademo_inst_return, loluademo_getx, loluademo_inst->m_x);




+ 11
- 10
src/base/assert.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -28,7 +29,7 @@ void DumpStack()
{ {
#if EMSCRIPTEN #if EMSCRIPTEN
/* This would require demangling but we don't care yet. */ /* This would require demangling but we don't care yet. */
Log::Debug("%s\n", emscripten_run_script_string("(new Error).stack")); msg::debug("%s\n", emscripten_run_script_string("(new Error).stack"));
#elif HAVE_CXA_DEMANGLE && HAVE_BACKTRACE_SYMBOLS #elif HAVE_CXA_DEMANGLE && HAVE_BACKTRACE_SYMBOLS
/* Get current stack frames */ /* Get current stack frames */
void *stack_ptrs[50]; void *stack_ptrs[50];
@@ -36,7 +37,7 @@ void DumpStack()
char **callstack = backtrace_symbols(stack_ptrs, size); char **callstack = backtrace_symbols(stack_ptrs, size);


if (size > 1) if (size > 1)
Log::Debug("%d functions in stack trace:\n", (int)size - 1); msg::debug("%d functions in stack trace:\n", (int)size - 1);


/* Parse stack frames, skipping the first element (because /* Parse stack frames, skipping the first element (because
* that’s ourselves) and print information. */ * that’s ourselves) and print information. */
@@ -67,13 +68,13 @@ void DumpStack()
if (ret == 0) if (ret == 0)
name = realname; name = realname;


Log::Debug("#%d %s: %s+%s %s\n", (int)i, msg::debug("#%d %s: %s+%s %s\n", (int)i,
callstack[i], name, offset, address); callstack[i], name, offset, address);
free(realname); free(realname);
} }
else else
{ {
Log::Debug("#%d %s\n", (int)i, callstack[i]); msg::debug("#%d %s\n", (int)i, callstack[i]);
} }
} }




+ 22
- 21
src/base/log.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -28,38 +29,38 @@ namespace lol
{ {


/* /*
* Public Log class * Public log class
*/ */


void Log::Debug(char const *fmt, ...) void msg::debug(char const *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
Helper(DebugMessage, fmt, ap); helper(MessageType::Debug, fmt, ap);
va_end(ap); va_end(ap);
} }


void Log::Info(char const *fmt, ...) void msg::info(char const *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
Helper(InfoMessage, fmt, ap); helper(MessageType::Info, fmt, ap);
va_end(ap); va_end(ap);
} }


void Log::Warn(char const *fmt, ...) void msg::warn(char const *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
Helper(WarnMessage, fmt, ap); helper(MessageType::Warning, fmt, ap);
va_end(ap); va_end(ap);
} }


void Log::Error(char const *fmt, ...) void msg::error(char const *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
Helper(ErrorMessage, fmt, ap); helper(MessageType::Error, fmt, ap);
va_end(ap); va_end(ap);
} }


@@ -67,10 +68,10 @@ void Log::Error(char const *fmt, ...)
* Private helper function * Private helper function
*/ */


void Log::Helper(MessageType type, char const *fmt, va_list ap) void msg::helper(MessageType type, char const *fmt, va_list ap)
{ {
#if defined __ANDROID__ #if defined __ANDROID__
int const prio[] = static int const prio[] =
{ {
ANDROID_LOG_DEBUG, ANDROID_LOG_DEBUG,
ANDROID_LOG_INFO, ANDROID_LOG_INFO,
@@ -79,10 +80,10 @@ void Log::Helper(MessageType type, char const *fmt, va_list ap)
}; };


String buf = String::vformat(fmt, ap); String buf = String::vformat(fmt, ap);
__android_log_print(prio[type], "LOL", "[%d] %s", (int)gettid(), &buf[0]); __android_log_print(prio[(int)type], "LOL", "[%d] %s", (int)gettid(), &buf[0]);


#else #else
char const *prefix[] = static char const * const prefix[] =
{ {
"DEBUG", "DEBUG",
"INFO", "INFO",
@@ -91,14 +92,14 @@ void Log::Helper(MessageType type, char const *fmt, va_list ap)
}; };


# if defined _WIN32 # if defined _WIN32
String buf = String(prefix[type]) + ": " + String::vformat(fmt, ap); String buf = String(prefix[(int)type]) + ": " + String::vformat(fmt, ap);


array<WCHAR> widechar; array<WCHAR> widechar;
widechar.Resize(buf.count() + 1); widechar.Resize(buf.count() + 1);
MultiByteToWideChar(CP_UTF8, 0, buf.C(), buf.count() + 1, widechar.data(), widechar.count()); MultiByteToWideChar(CP_UTF8, 0, buf.C(), buf.count() + 1, widechar.data(), widechar.count());
OutputDebugStringW(widechar.data()); OutputDebugStringW(widechar.data());
# else # else
fprintf(stderr, "%s: ", prefix[type]); fprintf(stderr, "%s: ", prefix[(int)type]);
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
# endif # endif
#endif #endif


+ 9
- 8
src/dict.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -39,7 +40,7 @@ public:
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
if (nentities) if (nentities)
Log::Error("still %i entities in dict\n", nentities); msg::error("still %i entities in dict\n", nentities);
#endif #endif
} }


@@ -134,7 +135,7 @@ void Dict::RemoveSlot(Entity *entity)
} }


#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
Log::Error("removing unregistered entity %p (%s)\n", msg::error("removing unregistered entity %p (%s)\n",
entity, entity->GetName()); entity, entity->GetName());
#endif #endif
} }


+ 22
- 21
src/eglapp.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -80,7 +81,7 @@ EglApp::EglApp(char const *title, ivec2 res, float fps) :
data->dpy = XOpenDisplay(nullptr); data->dpy = XOpenDisplay(nullptr);
if (data->dpy == nullptr) if (data->dpy == nullptr)
{ {
Log::Error("cannot connect to X server\n"); msg::error("cannot connect to X server\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }


@@ -110,13 +111,13 @@ EglApp::EglApp(char const *title, ivec2 res, float fps) :
# endif # endif
if (data->egl_dpy == EGL_NO_DISPLAY) if (data->egl_dpy == EGL_NO_DISPLAY)
{ {
Log::Error("cannot get EGL display\n"); msg::error("cannot get EGL display\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }


if (!eglInitialize(data->egl_dpy, nullptr, nullptr)) if (!eglInitialize(data->egl_dpy, nullptr, nullptr))
{ {
Log::Error("cannot initialize EGL\n"); msg::error("cannot initialize EGL\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }


@@ -138,19 +139,19 @@ EglApp::EglApp(char const *title, ivec2 res, float fps) :
EGLint num_config; EGLint num_config;
if (!eglChooseConfig(data->egl_dpy, attr, &ecfg, 1, &num_config)) if (!eglChooseConfig(data->egl_dpy, attr, &ecfg, 1, &num_config))
{ {
Log::Error("cannot choose EGL config (%i)\n", eglGetError()); msg::error("cannot choose EGL config (%i)\n", eglGetError());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }


if (num_config != 1) if (num_config != 1)
{ {
Log::Error("cannot choose between %i EGL configs\n", num_config); msg::error("cannot choose between %i EGL configs\n", num_config);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }


if (!eglBindAPI(EGL_OPENGL_ES_API)) if (!eglBindAPI(EGL_OPENGL_ES_API))
{ {
Log::Error("cannot bind OpenGL ES API (%i)\n", eglGetError()); msg::error("cannot bind OpenGL ES API (%i)\n", eglGetError());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }


@@ -197,28 +198,28 @@ EglApp::EglApp(char const *title, ivec2 res, float fps) :
switch (eglGetError()) switch (eglGetError())
{ {
case EGL_BAD_DISPLAY: case EGL_BAD_DISPLAY:
Log::Error("missing EGL display connection\n"); msg::error("missing EGL display connection\n");
break; break;
case EGL_NOT_INITIALIZED: case EGL_NOT_INITIALIZED:
Log::Error("EGL display not initialized\n"); msg::error("EGL display not initialized\n");
break; break;
case EGL_BAD_CONFIG: case EGL_BAD_CONFIG:
Log::Error("invalid EGL configuration\n"); msg::error("invalid EGL configuration\n");
break; break;
case EGL_BAD_NATIVE_WINDOW: case EGL_BAD_NATIVE_WINDOW:
Log::Error("invalid EGL native window\n"); msg::error("invalid EGL native window\n");
break; break;
case EGL_BAD_ATTRIBUTE: case EGL_BAD_ATTRIBUTE:
Log::Error("invalid EGL window attribute\n"); msg::error("invalid EGL window attribute\n");
break; break;
case EGL_BAD_ALLOC: case EGL_BAD_ALLOC:
Log::Error("cannot allocate EGL surface\n"); msg::error("cannot allocate EGL surface\n");
break; break;
case EGL_BAD_MATCH: case EGL_BAD_MATCH:
Log::Error("unsupported EGL window\n"); msg::error("unsupported EGL window\n");
break; break;
default: default:
Log::Error("cannot create EGL surface (%i)\n", eglGetError()); msg::error("cannot create EGL surface (%i)\n", eglGetError());
break; break;
} }


@@ -236,7 +237,7 @@ EglApp::EglApp(char const *title, ivec2 res, float fps) :
EGL_NO_CONTEXT, ctxattr); EGL_NO_CONTEXT, ctxattr);
if (data->egl_ctx == EGL_NO_CONTEXT) if (data->egl_ctx == EGL_NO_CONTEXT)
{ {
Log::Error("cannot create EGL context (%i)\n", eglGetError()); msg::error("cannot create EGL context (%i)\n", eglGetError());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }




+ 10
- 9
src/entity.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -36,7 +37,7 @@ Entity::~Entity()
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
if (!m_destroy) if (!m_destroy)
Log::Error("entity destructor called directly\n"); msg::error("entity destructor called directly\n");
#endif #endif
} }


@@ -58,7 +59,7 @@ void Entity::TickGame(float seconds)
UNUSED(seconds); UNUSED(seconds);
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
if (m_tickstate != STATE_PRETICK_GAME) if (m_tickstate != STATE_PRETICK_GAME)
Log::Error("invalid entity game tick\n"); msg::error("invalid entity game tick\n");
m_tickstate = STATE_POSTTICK_GAME; m_tickstate = STATE_POSTTICK_GAME;
#endif #endif
} }
@@ -68,7 +69,7 @@ void Entity::TickDraw(float seconds, Scene &scene)
(void)seconds; (void)seconds;
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
if (m_tickstate != STATE_PRETICK_DRAW) if (m_tickstate != STATE_PRETICK_DRAW)
Log::Error("invalid entity draw tick\n"); msg::error("invalid entity draw tick\n");
m_tickstate = STATE_POSTTICK_DRAW; m_tickstate = STATE_POSTTICK_DRAW;
#endif #endif
} }


+ 10
- 9
src/gpu/renderer.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -88,7 +89,7 @@ Renderer::Renderer(ivec2 size)
m_data->m_d3d_ctx = Direct3DCreate9(D3D_SDK_VERSION); m_data->m_d3d_ctx = Direct3DCreate9(D3D_SDK_VERSION);
if (!m_data->m_d3d_ctx) if (!m_data->m_d3d_ctx)
{ {
Log::Error("cannot initialise D3D\n"); msg::error("cannot initialise D3D\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }


@@ -119,7 +120,7 @@ Renderer::Renderer(ivec2 size)
&d3dpp, &m_data->m_d3d_dev); &d3dpp, &m_data->m_d3d_dev);
if (FAILED(hr)) if (FAILED(hr))
{ {
Log::Error("cannot create D3D device\n"); msg::error("cannot create D3D device\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }


@@ -129,7 +130,7 @@ Renderer::Renderer(ivec2 size)
GLenum glerr = glewInit(); GLenum glerr = glewInit();
if (glerr != GLEW_OK) if (glerr != GLEW_OK)
{ {
Log::Error("cannot initialise GLEW: %s\n", glewGetErrorString(glerr)); msg::error("cannot initialise GLEW: %s\n", glewGetErrorString(glerr));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
# endif # endif


+ 20
- 20
src/gpu/shader.cpp Bestand weergeven

@@ -1,9 +1,9 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net> // Copyright © 20102015 Sam Hocevar <sam@hocevar.net>
// //
// This program is free software. It comes without any warranty, to // This library is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it // the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want // and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force. // to Public License, Version 2, as published by the WTFPL Task Force.
@@ -269,9 +269,9 @@ Shader::Shader(String const &name,
&data->vert_table); &data->vert_table);
if (FAILED(hr)) if (FAILED(hr))
{ {
Log::Error("failed to compile vertex shader %s: %s\n", name.C(), msg::error("failed to compile vertex shader %s: %s\n", name.C(),
error_msg ? error_msg->GetBufferPointer() : "error"); error_msg ? error_msg->GetBufferPointer() : "error");
Log::Error("shader source:\n%s\n", vert); msg::error("shader source:\n%s\n", vert);
} }
data->m_dev->CreateVertexShader((DWORD *)shader_code->GetBufferPointer(), data->m_dev->CreateVertexShader((DWORD *)shader_code->GetBufferPointer(),
&data->vert_shader); &data->vert_shader);
@@ -287,14 +287,14 @@ Shader::Shader(String const &name,
glGetShaderiv(data->vert_id, GL_COMPILE_STATUS, &status); glGetShaderiv(data->vert_id, GL_COMPILE_STATUS, &status);
if (status != GL_TRUE) if (status != GL_TRUE)
{ {
Log::Error("failed to compile vertex shader %s: %s\n", msg::error("failed to compile vertex shader %s: %s\n",
name.C(), errbuf); name.C(), errbuf);
Log::Error("shader source:\n%s\n", shader_code.C()); msg::error("shader source:\n%s\n", shader_code.C());
} }
else if (len > 16) else if (len > 16)
{ {
Log::Debug("compile log for vertex shader %s: %s\n", name.C(), errbuf); msg::debug("compile log for vertex shader %s: %s\n", name.C(), errbuf);
Log::Debug("shader source:\n%s\n", shader_code.C()); msg::debug("shader source:\n%s\n", shader_code.C());
} }
#endif #endif


@@ -306,9 +306,9 @@ Shader::Shader(String const &name,
&data->frag_table); &data->frag_table);
if (FAILED(hr)) if (FAILED(hr))
{ {
Log::Error("failed to compile fragment shader %s: %s\n", name.C(), msg::error("failed to compile fragment shader %s: %s\n", name.C(),
error_msg ? error_msg->GetBufferPointer() : "error"); error_msg ? error_msg->GetBufferPointer() : "error");
Log::Error("shader source:\n%s\n", frag); msg::error("shader source:\n%s\n", frag);
} }
data->m_dev->CreatePixelShader((DWORD *)shader_code->GetBufferPointer(), data->m_dev->CreatePixelShader((DWORD *)shader_code->GetBufferPointer(),
&data->frag_shader); &data->frag_shader);
@@ -324,15 +324,15 @@ Shader::Shader(String const &name,
glGetShaderiv(data->frag_id, GL_COMPILE_STATUS, &status); glGetShaderiv(data->frag_id, GL_COMPILE_STATUS, &status);
if (status != GL_TRUE) if (status != GL_TRUE)
{ {
Log::Error("failed to compile fragment shader %s: %s\n", msg::error("failed to compile fragment shader %s: %s\n",
name.C(), errbuf); name.C(), errbuf);
Log::Error("shader source:\n%s\n", shader_code.C()); msg::error("shader source:\n%s\n", shader_code.C());
} }
else if (len > 16) else if (len > 16)
{ {
Log::Debug("compile log for fragment shader %s: %s\n", msg::debug("compile log for fragment shader %s: %s\n",
name.C(), errbuf); name.C(), errbuf);
Log::Debug("shader source:\n%s\n", shader_code.C()); msg::debug("shader source:\n%s\n", shader_code.C());
} }
#endif #endif


@@ -366,11 +366,11 @@ Shader::Shader(String const &name,
glGetProgramiv(data->prog_id, GL_LINK_STATUS, &status); glGetProgramiv(data->prog_id, GL_LINK_STATUS, &status);
if (status != GL_TRUE) if (status != GL_TRUE)
{ {
Log::Error("failed to link program %s: %s\n", name.C(), errbuf); msg::error("failed to link program %s: %s\n", name.C(), errbuf);
} }
else if (len > 16) else if (len > 16)
{ {
Log::Debug("link log for program %s: %s\n", name.C(), errbuf); msg::debug("link log for program %s: %s\n", name.C(), errbuf);
} }


GLint validated; GLint validated;
@@ -378,7 +378,7 @@ Shader::Shader(String const &name,
glGetProgramiv(data->prog_id, GL_VALIDATE_STATUS, &validated); glGetProgramiv(data->prog_id, GL_VALIDATE_STATUS, &validated);
if (validated != GL_TRUE) if (validated != GL_TRUE)
{ {
Log::Error("failed to validate program %s\n", name.C()); msg::error("failed to validate program %s\n", name.C());
} }


GLint num_attribs; GLint num_attribs;
@@ -416,7 +416,7 @@ Shader::Shader(String const &name,


if (usage == VertexUsage::MAX || index == -1) if (usage == VertexUsage::MAX || index == -1)
{ {
Log::Error("unable to parse attribute semantic from name: %s\n", msg::error("unable to parse attribute semantic from name: %s\n",
name_buffer); name_buffer);
} }
else else
@@ -428,7 +428,7 @@ Shader::Shader(String const &name,
#if _DEBUG #if _DEBUG
if (data->attrib_locations.has_key(flags)) if (data->attrib_locations.has_key(flags))
{ {
Log::Error("error while parsing attribute semantics in %s\n", msg::error("error while parsing attribute semantics in %s\n",
name.C()); name.C());
} }
#endif #endif
@@ -459,7 +459,7 @@ ShaderAttrib Shader::GetAttribLocation(VertexUsage usage, int index) const
/* Only spit an error once, we don’t need to flood the console. */ /* Only spit an error once, we don’t need to flood the console. */
if (!data->attrib_errors.has_key(ret.m_flags)) if (!data->attrib_errors.has_key(ret.m_flags))
{ {
Log::Error("attribute %s not found in shader %s\n", msg::error("attribute %s not found in shader %s\n",
usage.ToString().C(), data->m_name.C()); usage.ToString().C(), data->m_name.C());
data->attrib_errors[ret.m_flags] = true; data->attrib_errors[ret.m_flags] = true;
} }


+ 8
- 7
src/gpu/vertexbuffer.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -370,7 +371,7 @@ void VertexDeclaration::SetStream(VertexBuffer *vb, ShaderAttrib attribs[])


if (attr_index == m_count) if (attr_index == m_count)
{ {
Log::Error("stream #%d with usage %x not found in declaration\n", msg::error("stream #%d with usage %x not found in declaration\n",
index, usage.ToScalar()); index, usage.ToScalar());
attr_index = 0; attr_index = 0;
} }


+ 11
- 10
src/image/codec/android-image.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -55,14 +56,14 @@ bool AndroidImageCodec::Load(Image *image, char const *path)
if (res < 0) if (res < 0)
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
Log::Error("JVM environment not found, trying to attach thread\n"); msg::error("JVM environment not found, trying to attach thread\n");
#endif #endif
res = g_activity->vm->AttachCurrentThread(&env, nullptr); res = g_activity->vm->AttachCurrentThread(&env, nullptr);
} }
if (res < 0) if (res < 0)
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
Log::Error("JVM environment not found, cannot open image %s\n", path); msg::error("JVM environment not found, cannot open image %s\n", path);
#endif #endif
return false; return false;
} }
@@ -77,7 +78,7 @@ bool AndroidImageCodec::Load(Image *image, char const *path)
if (!m_bmp) if (!m_bmp)
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
Log::Error("could not load %s\n", path); msg::error("could not load %s\n", path);
#endif #endif
return false; return false;
} }
@@ -121,7 +122,7 @@ bool AndroidImageCodec::Close()
if (res < 0) if (res < 0)
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
Log::Error("JVM environment not found, cannot close image\n"); msg::error("JVM environment not found, cannot close image\n");
#endif #endif
return false; return false;
} }


+ 16
- 15
src/image/codec/gdiplus-image.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#if HAVE_CONFIG_H #if HAVE_CONFIG_H
@@ -55,7 +56,7 @@ bool GdiPlusImageCodec::Load(Image *image, char const *path)
status = Gdiplus::GdiplusStartup(&token, &input, nullptr); status = Gdiplus::GdiplusStartup(&token, &input, nullptr);
if (status != Gdiplus::Ok) if (status != Gdiplus::Ok)
{ {
Log::Error("error %d while initialising GDI+\n", status); msg::error("error %d while initialising GDI+\n", status);
return false; return false;
} }


@@ -68,7 +69,7 @@ bool GdiPlusImageCodec::Load(Image *image, char const *path)
wchar_t *wpath = new wchar_t[len + 1]; wchar_t *wpath = new wchar_t[len + 1];
if (mbstowcs(wpath, fullpath.C(), len + 1) == (size_t)-1) if (mbstowcs(wpath, fullpath.C(), len + 1) == (size_t)-1)
{ {
Log::Error("invalid image name %s\n", fullpath.C()); msg::error("invalid image name %s\n", fullpath.C());
delete[] wpath; delete[] wpath;
continue; continue;
} }
@@ -82,7 +83,7 @@ bool GdiPlusImageCodec::Load(Image *image, char const *path)
if (status != Gdiplus::Ok) if (status != Gdiplus::Ok)
{ {
if (status != Gdiplus::InvalidParameter) if (status != Gdiplus::InvalidParameter)
Log::Error("error %d loading %s\n", msg::error("error %d loading %s\n",
status, fullpath.C()); status, fullpath.C());
delete bitmap; delete bitmap;
bitmap = nullptr; bitmap = nullptr;
@@ -96,7 +97,7 @@ bool GdiPlusImageCodec::Load(Image *image, char const *path)


if (!bitmap) if (!bitmap)
{ {
Log::Error("could not load %s\n", path); msg::error("could not load %s\n", path);
return false; return false;
} }


@@ -106,7 +107,7 @@ bool GdiPlusImageCodec::Load(Image *image, char const *path)
if (bitmap->LockBits(&rect, Gdiplus::ImageLockModeRead, if (bitmap->LockBits(&rect, Gdiplus::ImageLockModeRead,
PixelFormat32bppARGB, &bdata) != Gdiplus::Ok) PixelFormat32bppARGB, &bdata) != Gdiplus::Ok)
{ {
Log::Error("could not lock bits in %s\n", path); msg::error("could not lock bits in %s\n", path);
delete bitmap; delete bitmap;
return false; return false;
} }
@@ -149,7 +150,7 @@ bool GdiPlusImageCodec::Save(Image *image, char const *path)
Gdiplus::GetImageEncodersSize(&num, &encoder_size); Gdiplus::GetImageEncodersSize(&num, &encoder_size);
if (num == 0) if (num == 0)
{ {
Log::Error("no GDI+ image encoders found\n"); msg::error("no GDI+ image encoders found\n");
return false; return false;
} }
Gdiplus::ImageCodecInfo *codecs Gdiplus::ImageCodecInfo *codecs
@@ -170,7 +171,7 @@ bool GdiPlusImageCodec::Save(Image *image, char const *path)
wchar_t *wpath = new wchar_t[len + 1]; wchar_t *wpath = new wchar_t[len + 1];
if (mbstowcs(wpath, path, len + 1) == (size_t)-1) if (mbstowcs(wpath, path, len + 1) == (size_t)-1)
{ {
Log::Error("could not convert GDI+ filename '%s' to widechar\n", path); msg::error("could not convert GDI+ filename '%s' to widechar\n", path);
delete[] wpath; delete[] wpath;
delete[] codecs; delete[] codecs;
return false; return false;
@@ -186,7 +187,7 @@ bool GdiPlusImageCodec::Save(Image *image, char const *path)
if (b->LockBits(&rect, (unsigned int)Gdiplus::ImageLockModeWrite, if (b->LockBits(&rect, (unsigned int)Gdiplus::ImageLockModeWrite,
PixelFormat32bppARGB, &bdata) != Gdiplus::Ok) PixelFormat32bppARGB, &bdata) != Gdiplus::Ok)
{ {
Log::Error("could not lock GDI+ image bits\n"); msg::error("could not lock GDI+ image bits\n");
delete b; delete b;
delete[] wpath; delete[] wpath;
delete[] codecs; delete[] codecs;
@@ -204,7 +205,7 @@ bool GdiPlusImageCodec::Save(Image *image, char const *path)


if (b->Save(wpath, &clsid, nullptr) != Gdiplus::Ok) if (b->Save(wpath, &clsid, nullptr) != Gdiplus::Ok)
{ {
Log::Error("could not save GDI+ image '%s'\n", path); msg::error("could not save GDI+ image '%s'\n", path);
delete[] wpath; delete[] wpath;
delete[] codecs; delete[] codecs;
delete b; delete b;


+ 9
- 8
src/image/codec/imlib2-image.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -53,7 +54,7 @@ bool Imlib2ImageCodec::Load(Image *image, char const *path)
if (!im) if (!im)
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
Log::Error("could not load image %s\n", path); msg::error("could not load image %s\n", path);
#endif #endif
return false; return false;
} }
@@ -65,7 +66,7 @@ bool Imlib2ImageCodec::Load(Image *image, char const *path)
{ {
imlib_free_image(); imlib_free_image();
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
Log::Error("could not get image data for %s\n", path); msg::error("could not get image data for %s\n", path);
#endif #endif
return false; return false;
} }


+ 8
- 7
src/image/codec/ios-image.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -50,7 +51,7 @@ bool IosImageCodec::Load(Image *image, char const *path)
if (!image) if (!image)
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
Log::Error("could not load %s\n", path); msg::error("could not load %s\n", path);
#endif #endif
return false; return false;
} }


+ 8
- 7
src/image/codec/sdl-image.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -58,7 +59,7 @@ bool SdlImageCodec::Load(Image *image, char const *path)
if (!surface) if (!surface)
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
Log::Error("could not load image %s\n", path); msg::error("could not load image %s\n", path);
#endif #endif
return false; return false;
} }


+ 6
- 6
src/image/image.cpp Bestand weergeven

@@ -1,9 +1,9 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net> // Copyright © 20102015 Sam Hocevar <sam@hocevar.net>
// //
// This program is free software. It comes without any warranty, to // This library is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it // the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want // and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force. // to Public License, Version 2, as published by the WTFPL Task Force.
@@ -162,13 +162,13 @@ bool Image::Load(char const *path)
last_codec = codec; last_codec = codec;
if (codec->Load(this, path)) if (codec->Load(this, path))
{ {
Log::Info("Image::Load: Codec %s succesfully loaded %s.\n", codec->GetName(), path); msg::info("Image::Load: Codec %s succesfully loaded %s.\n", codec->GetName(), path);
return true; return true;
} }
} }


//Log error, because we shouldn't be here //Log error, because we shouldn't be here
Log::Error("Image::Load: Last codec %s, Error loading image %s.\n", last_codec->GetName(), path); msg::error("Image::Load: Last codec %s, Error loading image %s.\n", last_codec->GetName(), path);
return false; return false;
} }


@@ -180,13 +180,13 @@ bool Image::Save(char const *path)
last_codec = codec; last_codec = codec;
if (codec->Save(this, path)) if (codec->Save(this, path))
{ {
Log::Info("Image::Save: Codec %s succesfully saved %s.\n", codec->GetName(), path); msg::info("Image::Save: Codec %s succesfully saved %s.\n", codec->GetName(), path);
return true; return true;
} }
} }


//Log error, because we shouldn't be here //Log error, because we shouldn't be here
Log::Error("Image::Save: Last codec %s, Error saving image %s.\n", last_codec->GetName(), path); msg::error("Image::Save: Last codec %s, Error saving image %s.\n", last_codec->GetName(), path);
return false; return false;
} }




+ 17
- 16
src/input/controller.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Benjamin Litzelmann // Copyright: © 2010—2015 Benjamin Litzelmann
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -22,7 +23,7 @@ void KeyBinding::Bind(const String& device_name, const String& key_name)


if (!device) if (!device)
{ {
Log::Warn("trying to bind key to nonexistent input device %s\n", msg::warn("trying to bind key to nonexistent input device %s\n",
device_name.C()); device_name.C());
return; return;
} }
@@ -30,7 +31,7 @@ void KeyBinding::Bind(const String& device_name, const String& key_name)
int keyindex = device->GetKeyIndex(key_name); int keyindex = device->GetKeyIndex(key_name);
if (keyindex < 0) if (keyindex < 0)
{ {
Log::Warn("trying to bind nonexistent key %s.%s\n", msg::warn("trying to bind nonexistent key %s.%s\n",
device_name.C(), key_name.C()); device_name.C(), key_name.C());
return; return;
} }
@@ -67,7 +68,7 @@ void AxisBinding::Bind(const String& device_name, const String& axis_name)
const InputDevice* device = InputDevice::Get(device_name); const InputDevice* device = InputDevice::Get(device_name);
if (!device) if (!device)
{ {
Log::Warn("trying to bind axis to nonexistent input device %s\n", msg::warn("trying to bind axis to nonexistent input device %s\n",
device_name.C()); device_name.C());
return; return;
} }
@@ -75,7 +76,7 @@ void AxisBinding::Bind(const String& device_name, const String& axis_name)
int axisindex = device->GetAxisIndex(axis_name); int axisindex = device->GetAxisIndex(axis_name);
if (axisindex < 0) if (axisindex < 0)
{ {
Log::Warn("trying to bind nonexistent axis %s.%s\n", msg::warn("trying to bind nonexistent axis %s.%s\n",
device_name.C(), axis_name.C()); device_name.C(), axis_name.C());
return; return;
} }
@@ -88,7 +89,7 @@ void AxisBinding::BindKey(const String& device_name, const String& key_name)
const InputDevice* device = InputDevice::Get(device_name); const InputDevice* device = InputDevice::Get(device_name);
if (!device) if (!device)
{ {
Log::Warn("trying to bind axis key to nonexistent input device %s\n", msg::warn("trying to bind axis key to nonexistent input device %s\n",
device_name.C()); device_name.C());
return; return;
} }
@@ -96,7 +97,7 @@ void AxisBinding::BindKey(const String& device_name, const String& key_name)
int keyindex = device->GetKeyIndex(key_name); int keyindex = device->GetKeyIndex(key_name);
if (keyindex < 0) if (keyindex < 0)
{ {
Log::Warn("trying to bind nonexistent axis key %s.%s\n", msg::warn("trying to bind nonexistent axis key %s.%s\n",
device_name.C(), key_name.C()); device_name.C(), key_name.C());
return; return;
} }
@@ -109,7 +110,7 @@ void AxisBinding::BindKeys(const String& device_name, const String& min_key_name
const InputDevice* device = InputDevice::Get(device_name); const InputDevice* device = InputDevice::Get(device_name);
if (!device) if (!device)
{ {
Log::Warn("trying to bind axis keys to nonexistent input device %s\n", msg::warn("trying to bind axis keys to nonexistent input device %s\n",
device_name.C()); device_name.C());
return; return;
} }
@@ -117,7 +118,7 @@ void AxisBinding::BindKeys(const String& device_name, const String& min_key_name
int minkeyindex = device->GetKeyIndex(min_key_name); int minkeyindex = device->GetKeyIndex(min_key_name);
if (minkeyindex < 0) if (minkeyindex < 0)
{ {
Log::Warn("trying to bind nonexistent axis key %s.%s\n", msg::warn("trying to bind nonexistent axis key %s.%s\n",
device_name.C(), min_key_name.C()); device_name.C(), min_key_name.C());
return; return;
} }
@@ -125,7 +126,7 @@ void AxisBinding::BindKeys(const String& device_name, const String& min_key_name
int maxkeyindex = device->GetKeyIndex(max_key_name); int maxkeyindex = device->GetKeyIndex(max_key_name);
if (maxkeyindex < 0) if (maxkeyindex < 0)
{ {
Log::Warn("trying to bind nonexistent axis key %s.%s\n", msg::warn("trying to bind nonexistent axis key %s.%s\n",
device_name.C(), max_key_name.C()); device_name.C(), max_key_name.C());
return; return;
} }
@@ -236,7 +237,7 @@ Controller::Controller(String const &name)
m_active = false; m_active = false;
if (Get(name) != nullptr) if (Get(name) != nullptr)
{ {
Log::Warn("controller “%s” has already been registered\n", name.C()); msg::warn("controller “%s” has already been registered\n", name.C());
} }
controllers.push(this); controllers.push(this);
} }


+ 28
- 15
src/lol/algorithm/sort.h Bestand weergeven

@@ -18,8 +18,12 @@
namespace lol namespace lol
{ {


/*
* Shuffle an array.
*/

template<typename T, typename ARRAY> template<typename T, typename ARRAY>
void array_base<T, ARRAY>::Shuffle() void array_base<T, ARRAY>::shuffle()
{ {
auto n = count(); auto n = count();
auto ni = n; auto ni = n;
@@ -30,8 +34,16 @@ void array_base<T, ARRAY>::Shuffle()
} }
} }


/*
* Sort an array
*/

template<typename T, typename ARRAY> template<typename T, typename ARRAY>
void array_base<T, ARRAY>::Sort(SortAlgorithm algorithm) static void quick_swap_sort(array_base<T, ARRAY> &a,
ptrdiff_t start, ptrdiff_t stop);

template<typename T, typename ARRAY>
void array_base<T, ARRAY>::sort(SortAlgorithm algorithm)
{ {
#if !SORT_WORKS // yeah cause it's shite. #if !SORT_WORKS // yeah cause it's shite.
algorithm = SortAlgorithm::Bubble; algorithm = SortAlgorithm::Bubble;
@@ -55,12 +67,13 @@ void array_base<T, ARRAY>::Sort(SortAlgorithm algorithm)
// Quick sort with swap // Quick sort with swap
else if (algorithm == SortAlgorithm::QuickSwap) else if (algorithm == SortAlgorithm::QuickSwap)
{ {
SortQuickSwap(0, count_s()); quick_swap_sort(*this, 0, count_s());
} }
} }


template<typename T, typename ARRAY> template<typename T, typename ARRAY>
void array_base<T, ARRAY>::SortQuickSwap(ptrdiff_t start, ptrdiff_t stop) static void quick_swap_sort(array_base<T, ARRAY> &a,
ptrdiff_t start, ptrdiff_t stop)
{ {
ptrdiff_t m[3] = ptrdiff_t m[3] =
{ {
@@ -71,7 +84,7 @@ void array_base<T, ARRAY>::SortQuickSwap(ptrdiff_t start, ptrdiff_t stop)


for (int i = 0; i < 2; ) for (int i = 0; i < 2; )
{ {
if (m_data[m[i+1]] < m_data[m[i]]) if (a[m[i+1]] < a[m[i]])
{ {
ptrdiff_t mt = m[i+1]; ptrdiff_t mt = m[i+1];
m[i+1] = m[i]; m[i+1] = m[i];
@@ -81,34 +94,34 @@ void array_base<T, ARRAY>::SortQuickSwap(ptrdiff_t start, ptrdiff_t stop)
else else
i++; i++;
} }
//actual stuff // actual stuff
T median = m_data[m[1]]; T median = a[m[1]];
ptrdiff_t i0 = start; ptrdiff_t i0 = start, i1 = stop - 1;
ptrdiff_t i1 = stop - 1;
bool b_swap = false; bool b_swap = false;
while (i0 < i1) while (i0 < i1)
{ {
if (!(m_data[i0] < median) && m_data[i1] < median) if (!(a[i0] < median) && a[i1] < median)
{ {
std::swap(m_data[i0], m_data[i1]); std::swap(a[i0], a[i1]);
i0++; i0++;
i1--; i1--;
b_swap = true; b_swap = true;
} }
else else
{ {
if (m_data[i0] < median) if (a[i0] < median)
i0++; i0++;
if (!(m_data[i1] < median)) if (!(a[i1] < median))
i1--; i1--;
} }
} }
if (stop - start == 1 || !b_swap) if (stop - start == 1 || !b_swap)
return; return;
if (start < i0) if (start < i0)
SortQuickSwap(start, i0); quick_swap_sort(a, start, i0);
if (i0 < stop) if (i0 < stop)
SortQuickSwap(i0, stop); quick_swap_sort(a, i0, stop);
} }


} /* namespace lol */ } /* namespace lol */


+ 19
- 29
src/lol/base/array.h Bestand weergeven

@@ -367,20 +367,20 @@ public:
m_reserved = toreserve; m_reserved = toreserve;
} }


void Shuffle(); void shuffle();
void Sort(SortAlgorithm algorithm); void sort(SortAlgorithm algorithm);
void SortQuickSwap(ptrdiff_t start, ptrdiff_t stop);


/* Support C++11 range-based for loops */ /* Support C++11 range-based for loops */
class ConstIterator class const_iterator
{ {
public: public:
ConstIterator(array_base const *that, ptrdiff_t pos) const_iterator(array_base const *that, ptrdiff_t pos)
: m_pos(pos), : m_pos(pos),
m_array(that) m_array(that)
{ } { }


bool operator !=(const ConstIterator& that) const bool operator !=(const const_iterator& that) const
{ {
return m_pos != that.m_pos; return m_pos != that.m_pos;
} }
@@ -390,7 +390,7 @@ public:
return (*m_array)[m_pos]; return (*m_array)[m_pos];
} }


ConstIterator const & operator ++() const_iterator const & operator ++()
{ {
++m_pos; ++m_pos;
return *this; return *this;
@@ -401,15 +401,15 @@ public:
array_base const *m_array; array_base const *m_array;
}; };


class Iterator class iterator
{ {
public: public:
Iterator(array_base *that, ptrdiff_t pos) iterator(array_base *that, ptrdiff_t pos)
: m_pos(pos), : m_pos(pos),
m_array(that) m_array(that)
{ } { }


bool operator !=(const Iterator& that) const bool operator !=(const iterator& that) const
{ {
return m_pos != that.m_pos; return m_pos != that.m_pos;
} }
@@ -419,7 +419,7 @@ public:
return (*m_array)[m_pos]; return (*m_array)[m_pos];
} }


Iterator const & operator ++() iterator const & operator ++()
{ {
++m_pos; ++m_pos;
return *this; return *this;
@@ -532,38 +532,28 @@ public:
*/ */


template<typename... T> template<typename... T>
typename array<T...>::Iterator begin(array<T...> &a) typename array<T...>::iterator begin(array<T...> &a)
{ {
return typename array<T...>::Iterator(&a, 0); return typename array<T...>::iterator(&a, 0);
} }


template<typename... T> template<typename... T>
typename array<T...>::Iterator end(array<T...> &a) typename array<T...>::iterator end(array<T...> &a)
{ {
return typename array<T...>::Iterator(&a, a.count()); return typename array<T...>::iterator(&a, a.count());
} }


template<typename... T> template<typename... T>
typename array<T...>::ConstIterator begin(array<T...> const &a) typename array<T...>::const_iterator begin(array<T...> const &a)
{ {
return typename array<T...>::ConstIterator(&a, 0); return typename array<T...>::const_iterator(&a, 0);
} }


template<typename... T> template<typename... T>
typename array<T...>::ConstIterator end(array<T...> const &a) typename array<T...>::const_iterator end(array<T...> const &a)
{ {
return typename array<T...>::ConstIterator(&a, a.count()); return typename array<T...>::const_iterator(&a, a.count());
} }


/*
* Transitional alias for the deprecated camelcase version of lol::array
*/

#if LOL_FEATURE_CXX11_TEMPLATE_ALIASES
template<typename... T> using Array = array<T...>;
#else
# define Array array
#endif

} /* namespace lol */ } /* namespace lol */



+ 10
- 9
src/lol/base/assert.h Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#pragma once #pragma once
@@ -109,13 +110,13 @@ static inline void DebugAbort()
*/ */


#define LOL_ERROR_1(t) \ #define LOL_ERROR_1(t) \
lol::Log::Error("assertion at %s:%d: %s\n", __FILE__, __LINE__, #t) lol::msg::error("assertion at %s:%d: %s\n", __FILE__, __LINE__, #t)


#define LOL_ERROR_2(t, s) \ #define LOL_ERROR_2(t, s) \
lol::Log::Error("assertion at %s:%d: %s\n", __FILE__, __LINE__, s) lol::msg::error("assertion at %s:%d: %s\n", __FILE__, __LINE__, s)


#define LOL_ERROR_3(t, s, ...) \ #define LOL_ERROR_3(t, s, ...) \
lol::Log::Error("assertion at %s:%d: " s "\n", __FILE__, __LINE__, __VA_ARGS__) lol::msg::error("assertion at %s:%d: " s "\n", __FILE__, __LINE__, __VA_ARGS__)


#if LOL_BUILD_RELEASE #if LOL_BUILD_RELEASE
# define ASSERT(...) UNUSED(LOL_CALL(LOL_1ST, (__VA_ARGS__))) # define ASSERT(...) UNUSED(LOL_CALL(LOL_1ST, (__VA_ARGS__)))


+ 19
- 18
src/lol/base/log.h Bestand weergeven

@@ -1,17 +1,18 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#pragma once #pragma once


// //
// The Log interface // The msg interface
// ----------------- // -----------------
// The central logging system. // The central logging system.
// //
@@ -22,7 +23,7 @@
namespace lol namespace lol
{ {


class Log class msg
{ {
public: public:
#ifdef __GNUC__ #ifdef __GNUC__
@@ -30,22 +31,22 @@ public:
#else #else
# define LOL_FMT_ATTR(n, p) # define LOL_FMT_ATTR(n, p)
#endif #endif
static void Debug(char const *format, ...) LOL_FMT_ATTR(1, 2); static void debug(char const *format, ...) LOL_FMT_ATTR(1, 2);
static void Info(char const *format, ...) LOL_FMT_ATTR(1, 2); static void info(char const *format, ...) LOL_FMT_ATTR(1, 2);
static void Warn(char const *format, ...) LOL_FMT_ATTR(1, 2); static void warn(char const *format, ...) LOL_FMT_ATTR(1, 2);
static void Error(char const *format, ...) LOL_FMT_ATTR(1, 2); static void error(char const *format, ...) LOL_FMT_ATTR(1, 2);
#undef LOL_FMT_ATTR #undef LOL_FMT_ATTR


private: private:
enum MessageType enum class MessageType
{ {
DebugMessage, Debug,
InfoMessage, Info,
WarnMessage, Warning,
ErrorMessage Error
}; };


static void Helper(MessageType type, char const *fmt, va_list ap); static void helper(MessageType type, char const *fmt, va_list ap);
}; };


} /* namespace lol */ } /* namespace lol */


+ 5
- 5
src/lolimgui.cpp Bestand weergeven

@@ -1,9 +1,9 @@
// //
// imGui integration in lolengine // imGui integration in lolengine
// //
// Copyright © 2009-2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com> // Copyright © 2009—2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
// //
// This program is free software. It comes without any warranty, to // This library is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it // the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want // and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force. // to Public License, Version 2, as published by the WTFPL Task Force.
@@ -230,7 +230,7 @@ void LolImGui::TickGame(float seconds)
cursor.y = 1.f - cursor.y; cursor.y = 1.f - cursor.y;
cursor *= video_size; cursor *= video_size;
io.MousePos = ImVec2(cursor.x, cursor.y); io.MousePos = ImVec2(cursor.x, cursor.y);
Log::Debug("%.2f/%.2f\n", io.MousePos.x, io.MousePos.y); msg::debug("%.2f/%.2f\n", io.MousePos.x, io.MousePos.y);
io.MouseWheel = m_controller->GetAxisValue(LolImGuiAxis::Scroll); io.MouseWheel = m_controller->GetAxisValue(LolImGuiAxis::Scroll);


for (int i = LolImGuiKey::MOUSE_KEY_START; i < LolImGuiKey::MOUSE_KEY_END; ++i) for (int i = LolImGuiKey::MOUSE_KEY_START; i < LolImGuiKey::MOUSE_KEY_END; ++i)
@@ -243,11 +243,11 @@ void LolImGui::TickGame(float seconds)
case LolImGuiKey::Focus: case LolImGuiKey::Focus:
if (m_controller->IsKeyReleased(i)) if (m_controller->IsKeyReleased(i))
{ {
Log::Debug("Not focused .....\n"); msg::debug("Not focused .....\n");
io.MousePos = ImVec2(-1.f, -1.f); io.MousePos = ImVec2(-1.f, -1.f);
} }
else else
Log::Debug("Focused !!\n"); msg::debug("Focused !!\n");
break; break;
} }
} }


+ 7
- 7
src/lolua/baselua.cpp Bestand weergeven

@@ -1,10 +1,10 @@
// //
// Base Lua class for Lua script loading // Base Lua class for Lua script loading
// //
// Copyright: (c) 2009-2015 Sam Hocevar <sam@hocevar.net> // Copyright: © 2009—2015 Sam Hocevar <sam@hocevar.net>
// 2009-2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com> // © 2009—2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
// //
// This program is free software. It comes without any warranty, to // This library is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it // the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want // and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force. // to Public License, Version 2, as published by the WTFPL Task Force.
@@ -29,7 +29,7 @@ class LuaBaseData
static int LuaPanic(LuaState* l) static int LuaPanic(LuaState* l)
{ {
char const *message = lua_tostring(l, -1); char const *message = lua_tostring(l, -1);
Log::Error("%s\n", message); msg::error("%s\n", message);
DebugAbort(); DebugAbort();
return 0; return 0;
} }
@@ -59,18 +59,18 @@ class LuaBaseData
String s = f.ReadString(); String s = f.ReadString();
f.Close(); f.Close();


Log::Debug("loading Lua file %s\n", candidate.C()); msg::debug("loading Lua file %s\n", candidate.C());
status = LuaDoCode(l, s); status = LuaDoCode(l, s);
break; break;
} }
} }


if (status == LUA_ERRFILE) if (status == LUA_ERRFILE)
Log::Error("could not find Lua file %s\n", filename); msg::error("could not find Lua file %s\n", filename);
else if (status == 1) else if (status == 1)
{ {
LuaString error; error.Get(l, -1); LuaString error; error.Get(l, -1);
Log::Error("Lua error %s\n", error().C()); msg::error("Lua error %s\n", error().C());
lua_pop(l, 1); lua_pop(l, 1);
} }




+ 17
- 16
src/math/vector.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -16,7 +17,7 @@ namespace lol
{ {


#define LOL_PRINTF_TOSTRING(type, ...) \ #define LOL_PRINTF_TOSTRING(type, ...) \
template<> void type::printf() const { Log::Debug(__VA_ARGS__); } \ template<> void type::printf() const { msg::debug(__VA_ARGS__); } \
template<> String type::tostring() const { return String::format(__VA_ARGS__); } template<> String type::tostring() const { return String::format(__VA_ARGS__); }


LOL_PRINTF_TOSTRING(vec2, "[ %6.6f %6.6f ]\n", x, y); LOL_PRINTF_TOSTRING(vec2, "[ %6.6f %6.6f ]\n", x, y);
@@ -32,8 +33,8 @@ template<> void mat2::printf() const
{ {
mat2 const &p = *this; mat2 const &p = *this;


Log::Debug("[ %6.6f %6.6f\n", p[0][0], p[1][0]); msg::debug("[ %6.6f %6.6f\n", p[0][0], p[1][0]);
Log::Debug(" %6.6f %6.6f ]\n", p[0][1], p[1][1]); msg::debug(" %6.6f %6.6f ]\n", p[0][1], p[1][1]);
} }


template<> String mat2::tostring() const template<> String mat2::tostring() const
@@ -48,9 +49,9 @@ template<> void mat3::printf() const
{ {
mat3 const &p = *this; mat3 const &p = *this;


Log::Debug("[ %6.6f %6.6f %6.6f\n", p[0][0], p[1][0], p[2][0]); msg::debug("[ %6.6f %6.6f %6.6f\n", p[0][0], p[1][0], p[2][0]);
Log::Debug(" %6.6f %6.6f %6.6f\n", p[0][1], p[1][1], p[2][1]); msg::debug(" %6.6f %6.6f %6.6f\n", p[0][1], p[1][1], p[2][1]);
Log::Debug(" %6.6f %6.6f %6.6f ]\n", p[0][2], p[1][2], p[2][2]); msg::debug(" %6.6f %6.6f %6.6f ]\n", p[0][2], p[1][2], p[2][2]);
} }


template<> String mat3::tostring() const template<> String mat3::tostring() const
@@ -66,13 +67,13 @@ template<> void mat4::printf() const
{ {
mat4 const &p = *this; mat4 const &p = *this;


Log::Debug("[ %6.6f %6.6f %6.6f %6.6f\n", msg::debug("[ %6.6f %6.6f %6.6f %6.6f\n",
p[0][0], p[1][0], p[2][0], p[3][0]); p[0][0], p[1][0], p[2][0], p[3][0]);
Log::Debug(" %6.6f %6.6f %6.6f %6.6f\n", msg::debug(" %6.6f %6.6f %6.6f %6.6f\n",
p[0][1], p[1][1], p[2][1], p[3][1]); p[0][1], p[1][1], p[2][1], p[3][1]);
Log::Debug(" %6.6f %6.6f %6.6f %6.6f\n", msg::debug(" %6.6f %6.6f %6.6f %6.6f\n",
p[0][2], p[1][2], p[2][2], p[3][2]); p[0][2], p[1][2], p[2][2], p[3][2]);
Log::Debug(" %6.6f %6.6f %6.6f %6.6f ]\n", msg::debug(" %6.6f %6.6f %6.6f %6.6f ]\n",
p[0][3], p[1][3], p[2][3], p[3][3]); p[0][3], p[1][3], p[2][3], p[3][3]);
} }




+ 8
- 7
src/mesh/mesh.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -117,7 +118,7 @@ void SubMesh::Render()


if (m_vbos[i] == nullptr) if (m_vbos[i] == nullptr)
{ {
Log::Error("trying to render a mesh with a null VBO\n"); msg::error("trying to render a mesh with a null VBO\n");
continue; continue;
} }




+ 15
- 14
src/platform/android/androidapp.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -40,7 +41,7 @@ AAssetManager *g_assets;
extern "C" jint extern "C" jint
JNI_OnLoad(JavaVM* vm, void* reserved) JNI_OnLoad(JavaVM* vm, void* reserved)
{ {
Log::Info("Java layer loading library, vm=0x%08lx", (long)(intptr_t)vm); msg::info("Java layer loading library, vm=0x%08lx", (long)(intptr_t)vm);
return JNI_VERSION_1_4; return JNI_VERSION_1_4;
} }


@@ -142,7 +143,7 @@ int lol::AndroidAppData::CreateDisplay()


if (eglMakeCurrent(m_display, m_surface, m_surface, m_context) == EGL_FALSE) if (eglMakeCurrent(m_display, m_surface, m_surface, m_context) == EGL_FALSE)
{ {
Log::Error("unable to eglMakeCurrent"); msg::error("unable to eglMakeCurrent");
return -1; return -1;
} }


@@ -150,7 +151,7 @@ int lol::AndroidAppData::CreateDisplay()
eglQuerySurface(m_display, m_surface, EGL_HEIGHT, &h); eglQuerySurface(m_display, m_surface, EGL_HEIGHT, &h);


/* Launch our renderer */ /* Launch our renderer */
Log::Info("Java layer initialising renderer (%dx%d)", w, h); msg::info("Java layer initialising renderer (%dx%d)", w, h);
Video::Setup(ivec2(w, h)); Video::Setup(ivec2(w, h));


return 0; return 0;
@@ -265,7 +266,7 @@ AndroidAppData *g_data;


void android_main(android_app* native_app) void android_main(android_app* native_app)
{ {
Log::Info("Java layer calling android_main() for app 0x%08lx", msg::info("Java layer calling android_main() for app 0x%08lx",
(long)native_app); (long)native_app);


/* Register native activity */ /* Register native activity */
@@ -276,12 +277,12 @@ void android_main(android_app* native_app)
jint res = g_activity->vm->GetEnv((void **)&jni_env, JNI_VERSION_1_2); jint res = g_activity->vm->GetEnv((void **)&jni_env, JNI_VERSION_1_2);
if (res < 0) if (res < 0)
{ {
Log::Info("JVM environment not found, trying to attach thread\n"); msg::info("JVM environment not found, trying to attach thread\n");
res = g_activity->vm->AttachCurrentThread(&jni_env, nullptr); res = g_activity->vm->AttachCurrentThread(&jni_env, nullptr);
} }
if (res < 0) if (res < 0)
{ {
Log::Error("JVM environment not found, cannot run main()\n"); msg::error("JVM environment not found, cannot run main()\n");
return; return;
} }


@@ -327,7 +328,7 @@ void android_main(android_app* native_app)
source->process(native_app, source); source->process(native_app, source);
} }


Log::Info("Java layer running real main()\n"); msg::info("Java layer running real main()\n");


/* Call the user's main() function. One of these will work. */ /* Call the user's main() function. One of these will work. */
lol_android_main(); lol_android_main();
@@ -339,7 +340,7 @@ lol::AndroidApp::AndroidApp(char const *title, ivec2 res, float fps)
: m_data(g_data) : m_data(g_data)
{ {
/* Launch our ticker */ /* Launch our ticker */
Log::Info("Java layer initialising ticker at %g fps", fps); msg::info("Java layer initialising ticker at %g fps", fps);
Ticker::Setup(fps); Ticker::Setup(fps);


m_data->m_wanted_resolution = res; m_data->m_wanted_resolution = res;


+ 10
- 9
src/platform/sdl/sdlapp.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -69,7 +70,7 @@ SdlAppDisplay::SdlAppDisplay(char const *title, ivec2 res)
{ {
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE) < 0) if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE) < 0)
{ {
Log::Error("cannot initialise SDL: %s\n", SDL_GetError()); msg::error("cannot initialise SDL: %s\n", SDL_GetError());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@@ -85,7 +86,7 @@ SdlAppDisplay::SdlAppDisplay(char const *title, ivec2 res)
SDL_WINDOW_OPENGL); SDL_WINDOW_OPENGL);
if (!data->m_window) if (!data->m_window)
{ {
Log::Error("cannot create rendering window: %s\n", SDL_GetError()); msg::error("cannot create rendering window: %s\n", SDL_GetError());
SDL_Quit(); SDL_Quit();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@@ -116,7 +117,7 @@ SdlAppDisplay::SdlAppDisplay(char const *title, ivec2 res)


if (!data->m_window) if (!data->m_window)
{ {
Log::Error("cannot create rendering window: %s\n", SDL_GetError()); msg::error("cannot create rendering window: %s\n", SDL_GetError());
SDL_Quit(); SDL_Quit();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }


+ 12
- 11
src/platform/sdl/sdlinput.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -74,7 +75,7 @@ static int sdl12_to_scancode(int ch, int sc)
case id: return String(str); case id: return String(str);
# include "input/keys.h" # include "input/keys.h"
default: default:
Log::Error("ScanCodeToText unknown scancode %0d\n", sc); msg::error("ScanCodeToText unknown scancode %0d\n", sc);
} }
return String(); return String();
} }
@@ -87,7 +88,7 @@ static int sdl12_to_scancode(int ch, int sc)
case id: return String(#name); case id: return String(#name);
# include "input/keys.h" # include "input/keys.h"
default: default:
Log::Error("ScanCodeToText unknown scancode %0d\n", sc); msg::error("ScanCodeToText unknown scancode %0d\n", sc);
} }
return String(); return String();
} }
@@ -290,7 +291,7 @@ void SdlInputData::Tick(float seconds)
} }
m_keyboard->SetKey(sc2, !m_keyboard->GetKey(sc2)); m_keyboard->SetKey(sc2, !m_keyboard->GetKey(sc2));
/* DEBUG STUFF /* DEBUG STUFF
Log::Info("Repeat: 0x%02x : %s/%s/%s/%i\n", msg::info("Repeat: 0x%02x : %s/%s/%s/%i\n",
(int)m_keyboard, ScanCodeToText(sc2).C(), ScanCodeToName(sc2).C(), (int)m_keyboard, ScanCodeToText(sc2).C(), ScanCodeToName(sc2).C(),
m_keyboard->GetKey(sc2) ? "up" : "down", event.key.repeat); m_keyboard->GetKey(sc2) ? "up" : "down", event.key.repeat);
*/ */
@@ -317,14 +318,14 @@ void SdlInputData::Tick(float seconds)
m_keyboard->AddText(str); m_keyboard->AddText(str);
} }
/* DEBUG STUFF /* DEBUG STUFF
Log::Info("Repeat: 0x%02x : %s/%s/%s/%i\n", msg::info("Repeat: 0x%02x : %s/%s/%s/%i\n",
(int)m_keyboard, ScanCodeToText(sc).C(), ScanCodeToName(sc).C(), (int)m_keyboard, ScanCodeToText(sc).C(), ScanCodeToName(sc).C(),
event.type == SDL_KEYDOWN ? "up" : "down", event.key.repeat); event.type == SDL_KEYDOWN ? "up" : "down", event.key.repeat);
*/ */
} }
/* DEBUG STUFF /* DEBUG STUFF
else else
Log::Error("unknown keypress (sym 0x%02x, scancode %0d)\n", msg::error("unknown keypress (sym 0x%02x, scancode %0d)\n",
event.key.keysym.sym, event.key.keysym.scancode); event.key.keysym.sym, event.key.keysym.scancode);
*/ */
# endif # endif


+ 8
- 7
src/sample.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -64,7 +65,7 @@ Sample::Sample(char const *path)
} }
if (!data->m_chunk) if (!data->m_chunk)
{ {
Log::Error("could not load sample %s: %s\n", path, Mix_GetError()); msg::error("could not load sample %s: %s\n", path, Mix_GetError());
} }
data->m_channel = -1; data->m_channel = -1;
#endif #endif


+ 12
- 11
src/sys/init.cpp Bestand weergeven

@@ -1,11 +1,12 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> // Copyright: © 2010—2015 Sam Hocevar <sam@hocevar.net>
// This program is free software; you can redistribute it and/or //
// modify it under the terms of the Do What The Fuck You Want To // This library is free software; you can redistribute it and/or
// Public License, Version 2, as published by Sam Hocevar. See // modify it under the terms of the Do What The Fuck You Want To
// http://www.wtfpl.net/ for more details. // Public License, Version 2, as published by Sam Hocevar. See
// http://www.wtfpl.net/ for more details.
// //


#include <lol/engine-internal.h> #include <lol/engine-internal.h>
@@ -42,9 +43,9 @@ void Init(int argc, char *argv[],
{ {
using namespace std; using namespace std;


Log::Debug("project dir: “%s”\n", projectdir.C()); msg::debug("project dir: “%s”\n", projectdir.C());
Log::Debug("solution dir: “%s”\n", solutiondir.C()); msg::debug("solution dir: “%s”\n", solutiondir.C());
Log::Debug("source subdir: “%s”\n", sourcesubdir.C()); msg::debug("source subdir: “%s”\n", sourcesubdir.C());


/* /*
* Retrieve binary directory, defaulting to no directory on Android * Retrieve binary directory, defaulting to no directory on Android
@@ -138,9 +139,9 @@ void Init(int argc, char *argv[],
got_rootdir = true; got_rootdir = true;
} }


Log::Debug("binary dir: “%s”\n", binarydir.C()); msg::debug("binary dir: “%s”\n", binarydir.C());
for (int i = 0; i < data_dir.count(); ++i) for (int i = 0; i < data_dir.count(); ++i)
Log::Debug("data dir %d/%d: “%s”\n", i + 1, data_dir.count(), msg::debug("data dir %d/%d: “%s”\n", i + 1, data_dir.count(),
data_dir[i].C()); data_dir[i].C());
} }




+ 3
- 3
src/sys/threadtypes.cpp Bestand weergeven

@@ -1,8 +1,8 @@
// //
// Lol Engine // Lol Engine
// //
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> // Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
// © 2014—2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com> // © 2014—2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
// //
// This library is free software. It comes without any warranty, to // This library is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it // the extent permitted by applicable law. You can redistribute it
@@ -223,7 +223,7 @@ void AsyncImageLoader::TreatResult(ThreadJob* result)
} }
else else
{ {
Log::Error("AsyncImageJob FAILED. See load image error above.\n"); msg::error("AsyncImageJob FAILED. See load image error above.\n");
} }
//Delete all that //Delete all that
delete(result); delete(result);


+ 4
- 4
src/t/base/map.cpp Bestand weergeven

@@ -1,7 +1,7 @@
// //
// Lol Engine // Lol Engine — unit tests
// //
// Copyright © 2010-2015 Sam Hocevar <sam@hocevar.net> // Copyright © 20102015 Sam Hocevar <sam@hocevar.net>
// //
// This program is free software. It comes without any warranty, to // This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it // the extent permitted by applicable law. You can redistribute it
@@ -69,7 +69,7 @@ lolunit_declare_fixture(MapTest)
} }
for (int i = 0; i < a.count(); i++) for (int i = 0; i < a.count(); i++)
m[i] = i; m[i] = i;
a.Shuffle(); a.shuffle();
for (int i = 0; i < a.count(); i++) for (int i = 0; i < a.count(); i++)
m.remove(a[i]); m.remove(a[i]);
} }
@@ -86,7 +86,7 @@ lolunit_declare_fixture(MapTest)
} }
for (int i = 0; i < a.count(); i++) for (int i = 0; i < a.count(); i++)
m[a[i]] = i; m[a[i]] = i;
a.Shuffle(); a.shuffle();
for (int i = 0; i < a.count(); i++) for (int i = 0; i < a.count(); i++)
m.remove(a[i]); m.remove(a[i]);
} }


+ 12
- 12
src/t/sys/thread.cpp Bestand weergeven

@@ -1,5 +1,5 @@
// //
// Lol Engine // Lol Engine — unit tests
// //
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> // Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net>
// © 2014—2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com> // © 2014—2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com>
@@ -38,9 +38,9 @@ lolunit_declare_fixture(thread_test)
{ {
Timer timer; Timer timer;
m_done = false; m_done = false;
Log::Info("%s: STARTED WORK\n", GetName()); msg::info("%s: STARTED WORK\n", GetName());
timer.Wait(2.f); timer.Wait(2.f);
Log::Info("%s: ENDED WORK\n", GetName()); msg::info("%s: ENDED WORK\n", GetName());
m_done = true; m_done = true;
return true; return true;
} }
@@ -81,14 +81,14 @@ lolunit_declare_fixture(thread_test)


void AddJob(ThreadJob* job) void AddJob(ThreadJob* job)
{ {
Log::Info("%s DISPATCHING JOB %s\n", GetName(), job->GetName()); msg::info("%s DISPATCHING JOB %s\n", GetName(), job->GetName());
DispatchJob(job); DispatchJob(job);
} }
bool GetWorkResult(array<ThreadJob*>& results) bool GetWorkResult(array<ThreadJob*>& results)
{ {
results += m_job_result; results += m_job_result;
m_job_result.empty(); m_job_result.empty();
Log::Info("%s GETWORKRESULT (%i)\n", GetName(), results.count()); msg::info("%s GETWORKRESULT (%i)\n", GetName(), results.count());
return results.count() > 0; return results.count() > 0;
} }


@@ -99,7 +99,7 @@ lolunit_declare_fixture(thread_test)
case UnitTestStatus::NOT_QUEUED: case UnitTestStatus::NOT_QUEUED:
if (!!GetDispatchCount()) if (!!GetDispatchCount())
{ {
Log::Info("%s TICKGAME %s\n", GetName(), m_status.ToString().C()); msg::info("%s TICKGAME %s\n", GetName(), m_status.ToString().C());
m_status = UnitTestStatus::QUEUED; m_status = UnitTestStatus::QUEUED;
} }
break; break;
@@ -110,14 +110,14 @@ lolunit_declare_fixture(thread_test)
if (GetDispatchedCount()) if (GetDispatchedCount())
#endif #endif
{ {
Log::Info("%s TICKGAME %s\n", GetName(), m_status.ToString().C()); msg::info("%s TICKGAME %s\n", GetName(), m_status.ToString().C());
m_status = UnitTestStatus::RETRIEVED; m_status = UnitTestStatus::RETRIEVED;
} }
break; break;
case UnitTestStatus::RETRIEVED: case UnitTestStatus::RETRIEVED:
if (m_job_result.count() == 4) if (m_job_result.count() == 4)
{ {
Log::Info("%s TICKGAME %s\n", GetName(), m_status.ToString().C()); msg::info("%s TICKGAME %s\n", GetName(), m_status.ToString().C());
m_status = UnitTestStatus::DONE; m_status = UnitTestStatus::DONE;
} }
break; break;
@@ -151,10 +151,10 @@ lolunit_declare_fixture(thread_test)


lolunit_declare_test(threads) lolunit_declare_test(threads)
{ {
Log::Info("%s START\n", m_manager.GetName()); msg::info("%s START\n", m_manager.GetName());
//Start threads manager //Start threads manager
m_manager.Start(); m_manager.Start();
Log::Info("%s STARTED\n", m_manager.GetName()); msg::info("%s STARTED\n", m_manager.GetName());


UnitTestJob job[4]; UnitTestJob job[4];
lolunit_assert_equal(0, m_manager.Test_GetDispatchCount()); lolunit_assert_equal(0, m_manager.Test_GetDispatchCount());
@@ -187,10 +187,10 @@ lolunit_declare_fixture(thread_test)
m_manager.GetWorkResult(results); m_manager.GetWorkResult(results);
lolunit_assert_equal(4, results.count()); lolunit_assert_equal(4, results.count());


Log::Info("%s STOP\n", m_manager.GetName()); msg::info("%s STOP\n", m_manager.GetName());
//Stop manager //Stop manager
m_manager.Stop(); m_manager.Stop();
Log::Info("%s STOPPED\n", m_manager.GetName()); msg::info("%s STOPPED\n", m_manager.GetName());
} }


lolunit_declare_test(queue_try_push) lolunit_declare_test(queue_try_push)


+ 15
- 15
src/ticker.cpp Bestand weergeven

@@ -44,7 +44,7 @@ public:
"still %d entities in ticker\n", nentities); "still %d entities in ticker\n", nentities);
ASSERT(m_autolist.count() == 0, ASSERT(m_autolist.count() == 0,
"still %d autoreleased entities\n", m_autolist.count()); "still %d autoreleased entities\n", m_autolist.count());
Log::Debug("%d frames required to quit\n", frame - quitframe); msg::debug("%d frames required to quit\n", frame - quitframe);


#if LOL_FEATURE_THREADS #if LOL_FEATURE_THREADS
gametick.push(0); gametick.push(0);
@@ -150,7 +150,7 @@ int Ticker::Unref(Entity *entity)
void TickerData::GameThreadMain() void TickerData::GameThreadMain()
{ {
#if LOL_BUILD_DEBUG #if LOL_BUILD_DEBUG
Log::Info("ticker game thread initialised\n"); msg::info("ticker game thread initialised\n");
#endif #endif


for (;;) for (;;)
@@ -167,7 +167,7 @@ void TickerData::GameThreadMain()
drawtick.push(0); drawtick.push(0);


#if LOL_BUILD_DEBUG #if LOL_BUILD_DEBUG
Log::Info("ticker game thread terminated\n"); msg::info("ticker game thread terminated\n");
#endif #endif
} }
#endif /* LOL_FEATURE_THREADS */ #endif /* LOL_FEATURE_THREADS */
@@ -176,7 +176,7 @@ void TickerData::GameThreadMain()
void TickerData::DrawThreadMain() /* unused */ void TickerData::DrawThreadMain() /* unused */
{ {
#if LOL_BUILD_DEBUG #if LOL_BUILD_DEBUG
Log::Info("ticker draw thread initialised\n"); msg::info("ticker draw thread initialised\n");
#endif #endif


for (;;) for (;;)
@@ -191,7 +191,7 @@ void TickerData::DrawThreadMain() /* unused */
} }


#if LOL_BUILD_DEBUG #if LOL_BUILD_DEBUG
Log::Info("ticker draw thread terminated\n"); msg::info("ticker draw thread terminated\n");
#endif #endif
} }
#endif /* LOL_FEATURE_THREADS */ #endif /* LOL_FEATURE_THREADS */
@@ -213,16 +213,16 @@ void TickerData::GameThreadTick()
Profiler::Start(Profiler::STAT_TICK_GAME); Profiler::Start(Profiler::STAT_TICK_GAME);


#if 0 #if 0
Log::Debug("-------------------------------------\n"); msg::debug("-------------------------------------\n");
for (int g = 0; g < Entity::ALLGROUP_END; ++g) for (int g = 0; g < Entity::ALLGROUP_END; ++g)
{ {
Log::Debug("%s Group %d\n", msg::debug("%s Group %d\n",
(g < Entity::GAMEGROUP_END) ? "Game" : "Draw", g); (g < Entity::GAMEGROUP_END) ? "Game" : "Draw", g);


for (int i = 0; i < data->m_list[g].count(); ++i) for (int i = 0; i < data->m_list[g].count(); ++i)
{ {
Entity *e = data->m_list[g][i]; Entity *e = data->m_list[g][i];
Log::Debug(" \\-- [%p] %s (m_ref %d, destroy %d)\n", msg::debug(" \\-- [%p] %s (m_ref %d, destroy %d)\n",
e, e->GetName(), e->m_ref, e->m_destroy); e, e->GetName(), e->m_ref, e->m_destroy);
} }
} }
@@ -255,7 +255,7 @@ void TickerData::GameThreadTick()
data->keepalive += data->deltatime; data->keepalive += data->deltatime;
if (data->keepalive > 10.f) if (data->keepalive > 10.f)
{ {
Log::Info("ticker keepalive: tick!\n"); msg::info("ticker keepalive: tick!\n");
data->keepalive = 0.f; data->keepalive = 0.f;
} }
#endif #endif
@@ -276,7 +276,7 @@ void TickerData::GameThreadTick()
if (e->m_ref) if (e->m_ref)
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
Log::Error("poking %s\n", e->GetName()); msg::error("poking %s\n", e->GetName());
#endif #endif
e->m_ref--; e->m_ref--;
n++; n++;
@@ -285,7 +285,7 @@ void TickerData::GameThreadTick()


#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
if (n) if (n)
Log::Error("%d entities stuck after %d frames, poked %d\n", msg::error("%d entities stuck after %d frames, poked %d\n",
data->nentities, data->quitdelay, n); data->nentities, data->quitdelay, n);
#endif #endif


@@ -397,14 +397,14 @@ void TickerData::GameThreadTick()
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
if (e->m_tickstate != Entity::STATE_IDLE) if (e->m_tickstate != Entity::STATE_IDLE)
Log::Error("entity %s [%p] not idle for game tick\n", msg::error("entity %s [%p] not idle for game tick\n",
e->GetName(), e); e->GetName(), e);
e->m_tickstate = Entity::STATE_PRETICK_GAME; e->m_tickstate = Entity::STATE_PRETICK_GAME;
#endif #endif
e->TickGame(data->deltatime); e->TickGame(data->deltatime);
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
if (e->m_tickstate != Entity::STATE_POSTTICK_GAME) if (e->m_tickstate != Entity::STATE_POSTTICK_GAME)
Log::Error("entity %s [%p] missed super game tick\n", msg::error("entity %s [%p] missed super game tick\n",
e->GetName(), e); e->GetName(), e);
e->m_tickstate = Entity::STATE_IDLE; e->m_tickstate = Entity::STATE_IDLE;
#endif #endif
@@ -446,14 +446,14 @@ void TickerData::DrawThreadTick()
{ {
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
if (e->m_tickstate != Entity::STATE_IDLE) if (e->m_tickstate != Entity::STATE_IDLE)
Log::Error("entity %s [%p] not idle for draw tick\n", msg::error("entity %s [%p] not idle for draw tick\n",
e->GetName(), e); e->GetName(), e);
e->m_tickstate = Entity::STATE_PRETICK_DRAW; e->m_tickstate = Entity::STATE_PRETICK_DRAW;
#endif #endif
e->TickDraw(data->deltatime, Scene::GetScene(scene_idx)); e->TickDraw(data->deltatime, Scene::GetScene(scene_idx));
#if !LOL_BUILD_RELEASE #if !LOL_BUILD_RELEASE
if (e->m_tickstate != Entity::STATE_POSTTICK_DRAW) if (e->m_tickstate != Entity::STATE_POSTTICK_DRAW)
Log::Error("entity %s [%p] missed super draw tick\n", msg::error("entity %s [%p] missed super draw tick\n",
e->GetName(), e); e->GetName(), e);
e->m_tickstate = Entity::STATE_IDLE; e->m_tickstate = Entity::STATE_IDLE;
#endif #endif


||||||
x
 
000:0
Laden…
Annuleren
Opslaan