that 2-year old "temporary Win32 hack".legacy
| @@ -13,6 +13,8 @@ | |||||
| <AdditionalIncludeDirectories Condition="'$(Platform)'=='Win32'">$(GlIncludes);$(SdlIncludes);$(D3d9Includes);$(XinputIncludes);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | <AdditionalIncludeDirectories Condition="'$(Platform)'=='Win32'">$(GlIncludes);$(SdlIncludes);$(D3d9Includes);$(XinputIncludes);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
| <AdditionalIncludeDirectories Condition="'$(Platform)'=='x64'">$(GlIncludes);$(SdlIncludes);$(D3d9Includes);$(XinputIncludes);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | <AdditionalIncludeDirectories Condition="'$(Platform)'=='x64'">$(GlIncludes);$(SdlIncludes);$(D3d9Includes);$(XinputIncludes);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||||
| <PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | <PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
| <PreprocessorDefinitions>LOL_CONFIG_PROJECTDIR="$(ProjectDir.Replace('\',"\\"))";%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
| <PreprocessorDefinitions>LOL_CONFIG_SOLUTIONDIR="$(SolutionDir.Replace('\',"\\"))";%(PreprocessorDefinitions)</PreprocessorDefinitions> | |||||
| <PreprocessorDefinitions Condition="'$(Platform)'=='Win32'">WIN32;$(Win32Defines);%(PreprocessorDefinitions)</PreprocessorDefinitions> | <PreprocessorDefinitions Condition="'$(Platform)'=='Win32'">WIN32;$(Win32Defines);%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
| <PreprocessorDefinitions Condition="'$(Platform)'=='x64'">WIN32;$(Win32Defines);%(PreprocessorDefinitions)</PreprocessorDefinitions> | <PreprocessorDefinitions Condition="'$(Platform)'=='x64'">WIN32;$(Win32Defines);%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
| <PreprocessorDefinitions Condition="'$(Platform)'=='Xbox 360'">_XBOX;$(XboxDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions> | <PreprocessorDefinitions Condition="'$(Platform)'=='Xbox 360'">_XBOX;$(XboxDefines);%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
| @@ -85,7 +85,8 @@ bool GdiPlusImageData::Open(char const *path) | |||||
| { | { | ||||
| #if !LOL_RELEASE | #if !LOL_RELEASE | ||||
| if (status != Gdiplus::InvalidParameter) | if (status != Gdiplus::InvalidParameter) | ||||
| Log::Error("error %d loading %s\n", status, path); | |||||
| Log::Error("error %d loading %s\n", | |||||
| status, &fullpath[0]); | |||||
| #endif | #endif | ||||
| delete bitmap; | delete bitmap; | ||||
| bitmap = NULL; | bitmap = NULL; | ||||
| @@ -21,22 +21,28 @@ | |||||
| namespace lol | namespace lol | ||||
| { | { | ||||
| namespace System | |||||
| { | |||||
| /* | |||||
| * Module-specific macros. These can be overridden by the build process, | |||||
| * typically with compiler command-line flags. | |||||
| */ | |||||
| extern void Init(Array<char const *> &args); | |||||
| extern void SetDataDir(char const *dir); | |||||
| extern char const *GetDataDir(); | |||||
| #if !defined LOL_CONFIG_PROJECTDIR | |||||
| # define LOL_CONFIG_PROJECTDIR "" | |||||
| #endif | |||||
| static inline void Init(int argc, char *argv[]) | |||||
| #if !defined LOL_CONFIG_SOLUTIONDIR | |||||
| # define LOL_CONFIG_SOLUTIONDIR "" | |||||
| #endif | |||||
| namespace System | |||||
| { | { | ||||
| Array<char const *> args; | |||||
| for (int i = 0; i < argc; i++) | |||||
| args << argv[i]; | |||||
| extern void Init(int argc, char *argv[], | |||||
| char const *projectdir = LOL_CONFIG_PROJECTDIR, | |||||
| char const *solutiondir = LOL_CONFIG_SOLUTIONDIR); | |||||
| Init(args); | |||||
| } | |||||
| extern void SetDataDir(char const *dir); | |||||
| extern char const *GetDataDir(); | |||||
| } /* namespace System */ | } /* namespace System */ | ||||
| @@ -20,25 +20,47 @@ namespace lol | |||||
| namespace System | namespace System | ||||
| { | { | ||||
| void Init(Array<char const *> &args) | |||||
| { | |||||
| /* Try to guess the data directory from the executable location. */ | |||||
| if (args.Count() > 0) | |||||
| { | |||||
| #if defined _WIN32 | #if defined _WIN32 | ||||
| # define SEPARATOR '\\' | # define SEPARATOR '\\' | ||||
| #else | #else | ||||
| # define SEPARATOR '/' | # define SEPARATOR '/' | ||||
| #endif | #endif | ||||
| char const *last_slash = strrchr(args[0], SEPARATOR); | |||||
| if (last_slash) | |||||
| void Init(int argc, char *argv[], | |||||
| char const *projectdir, char const *solutiondir) | |||||
| { | |||||
| bool got_rootdir = false; | |||||
| /* Find the common prefix between project dir and solution dir. */ | |||||
| for (int i = 0; ; i++) | |||||
| { | |||||
| if (projectdir[i] != solutiondir[i] || projectdir[i] == '\0') | |||||
| { | { | ||||
| String dir; | |||||
| dir.Resize(last_slash - args[0] + 1); | |||||
| memcpy(&dir[0], args[0], last_slash - args[0] + 1); | |||||
| /* FIXME: at this point we should check whether the binary | |||||
| * was launched from this subdirectory; from now we just | |||||
| * assume it was. */ | |||||
| if (i) | |||||
| { | |||||
| String rootdir = projectdir; | |||||
| if (rootdir.Last() != SEPARATOR) | |||||
| rootdir += SEPARATOR; | |||||
| SetDataDir(&rootdir[0]); | |||||
| got_rootdir = true; | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
| /* Try to guess the data directory from the executable location. */ | |||||
| if (!got_rootdir && argc > 0) | |||||
| { | |||||
| char const *last_slash = strrchr(argv[0], SEPARATOR); | |||||
| if (last_slash) | |||||
| { | |||||
| String dir(argv[0], last_slash - argv[0] + 1); | |||||
| SetDataDir(&dir[0]); | SetDataDir(&dir[0]); | ||||
| got_rootdir = true; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -9,10 +9,6 @@ | |||||
| # include "config.h" | # include "config.h" | ||||
| #endif | #endif | ||||
| #if defined _WIN32 | |||||
| # include <direct.h> | |||||
| #endif | |||||
| #if defined _XBOX | #if defined _XBOX | ||||
| # define _USE_MATH_DEFINES /* for M_PI */ | # define _USE_MATH_DEFINES /* for M_PI */ | ||||
| # include <xtl.h> | # include <xtl.h> | ||||
| @@ -479,12 +475,6 @@ int main(int argc, char **argv) | |||||
| Application app("BtPhysTest", ivec2(1280, 720), 60.0f); | Application app("BtPhysTest", ivec2(1280, 720), 60.0f); | ||||
| #if defined _MSC_VER && !defined _XBOX | |||||
| _chdir(".."); | |||||
| #elif defined _WIN32 && !defined _XBOX | |||||
| _chdir("../.."); | |||||
| #endif | |||||
| new BtPhysTest(argc > 1); | new BtPhysTest(argc > 1); | ||||
| app.ShowPointer(false); | app.ShowPointer(false); | ||||
| @@ -18,10 +18,6 @@ | |||||
| using namespace std; | using namespace std; | ||||
| using namespace lol; | using namespace lol; | ||||
| #if defined _WIN32 | |||||
| # include <direct.h> | |||||
| #endif | |||||
| extern char const *lolfx_01_triangle; | extern char const *lolfx_01_triangle; | ||||
| class Triangle : public WorldEntity | class Triangle : public WorldEntity | ||||
| @@ -78,12 +74,6 @@ int main(int argc, char **argv) | |||||
| Application app("Tutorial 1: Triangle", ivec2(640, 480), 60.0f); | Application app("Tutorial 1: Triangle", ivec2(640, 480), 60.0f); | ||||
| #if defined _MSC_VER && !defined _XBOX | |||||
| _chdir(".."); | |||||
| #elif defined _WIN32 && !defined _XBOX | |||||
| _chdir("../.."); | |||||
| #endif | |||||
| new DebugFps(5, 5); | new DebugFps(5, 5); | ||||
| new Triangle(); | new Triangle(); | ||||
| @@ -18,10 +18,6 @@ | |||||
| using namespace std; | using namespace std; | ||||
| using namespace lol; | using namespace lol; | ||||
| #if defined _WIN32 | |||||
| # include <direct.h> | |||||
| #endif | |||||
| extern char const *lolfx_02_cube; | extern char const *lolfx_02_cube; | ||||
| class Cube : public WorldEntity | class Cube : public WorldEntity | ||||
| @@ -139,12 +135,6 @@ int main(int argc, char **argv) | |||||
| Application app("Tutorial 2: Cube", ivec2(640, 480), 60.0f); | Application app("Tutorial 2: Cube", ivec2(640, 480), 60.0f); | ||||
| #if defined _MSC_VER && !defined _XBOX | |||||
| _chdir(".."); | |||||
| #elif defined _WIN32 && !defined _XBOX | |||||
| _chdir("../.."); | |||||
| #endif | |||||
| new DebugFps(5, 5); | new DebugFps(5, 5); | ||||
| new Cube(); | new Cube(); | ||||
| @@ -18,10 +18,6 @@ | |||||
| using namespace std; | using namespace std; | ||||
| using namespace lol; | using namespace lol; | ||||
| #if defined _WIN32 | |||||
| # include <direct.h> | |||||
| #endif | |||||
| extern char const *lolfx_03_noise; | extern char const *lolfx_03_noise; | ||||
| class NoiseDemo : public WorldEntity | class NoiseDemo : public WorldEntity | ||||
| @@ -89,12 +85,6 @@ int main(int argc, char **argv) | |||||
| Application app("Tutorial 3: Noise", ivec2(1280, 720), 60.0f); | Application app("Tutorial 3: Noise", ivec2(1280, 720), 60.0f); | ||||
| #if defined _MSC_VER && !defined _XBOX | |||||
| _chdir(".."); | |||||
| #elif defined _WIN32 && !defined _XBOX | |||||
| _chdir("../.."); | |||||
| #endif | |||||
| new NoiseDemo(); | new NoiseDemo(); | ||||
| app.Run(); | app.Run(); | ||||
| @@ -18,10 +18,6 @@ | |||||
| using namespace std; | using namespace std; | ||||
| using namespace lol; | using namespace lol; | ||||
| #if defined _WIN32 | |||||
| # include <direct.h> | |||||
| #endif | |||||
| extern char const *lolfx_08_fbo; | extern char const *lolfx_08_fbo; | ||||
| class FBO : public WorldEntity | class FBO : public WorldEntity | ||||
| @@ -142,12 +138,6 @@ int main(int argc, char **argv) | |||||
| Application app("Tutorial 08: Framebuffer Object", ivec2(640, 480), 60.0f); | Application app("Tutorial 08: Framebuffer Object", ivec2(640, 480), 60.0f); | ||||
| #if defined _MSC_VER && !defined _XBOX | |||||
| _chdir(".."); | |||||
| #elif defined _WIN32 && !defined _XBOX | |||||
| _chdir("../.."); | |||||
| #endif | |||||
| new FBO(); | new FBO(); | ||||
| app.Run(); | app.Run(); | ||||
| @@ -18,10 +18,6 @@ | |||||
| #include "core.h" | #include "core.h" | ||||
| #include "loldebug.h" | #include "loldebug.h" | ||||
| #if defined _WIN32 | |||||
| # include <direct.h> | |||||
| #endif | |||||
| using namespace lol; | using namespace lol; | ||||
| extern char const *lolfx_11_fractal; | extern char const *lolfx_11_fractal; | ||||
| @@ -556,12 +552,6 @@ int main(int argc, char **argv) | |||||
| System::Init(argc, argv); | System::Init(argc, argv); | ||||
| Application app("Tutorial 3: Fractal", window_size, 60.0f); | Application app("Tutorial 3: Fractal", window_size, 60.0f); | ||||
| #if defined _MSC_VER && !defined _XBOX | |||||
| _chdir(".."); | |||||
| #elif defined _WIN32 && !defined _XBOX | |||||
| _chdir("../.."); | |||||
| #endif | |||||
| new DebugFps(5, 5); | new DebugFps(5, 5); | ||||
| new Fractal(window_size); | new Fractal(window_size); | ||||
| //new DebugRecord("fractalol.ogm", 60.0f); | //new DebugRecord("fractalol.ogm", 60.0f); | ||||