From df8405f4e83febb81a5ce8f772bd7f5b9e9b6036 Mon Sep 17 00:00:00 2001 From: "C. J. Howard" Date: Sat, 1 Sep 2018 02:23:44 +0900 Subject: [PATCH] Fix some linux-windows compilation compatibility issues --- .gitignore | 4 +- CMakeLists.txt | 61 ++++--- lib/emergent | 2 +- src/application.cpp | 163 +++++++++--------- src/controls.cpp | 42 ++--- src/game/biome.cpp | 10 +- src/input.cpp | 18 +- src/material-loader.cpp | 32 ++-- src/model-loader.cpp | 6 +- src/render-passes.cpp | 36 ++-- src/settings.cpp | 16 +- src/states/loading-state.cpp | 30 ++-- .../antkeeper.manifest} | 0 13 files changed, 225 insertions(+), 195 deletions(-) rename src/{dpi-aware.manifest => windows/antkeeper.manifest} (100%) diff --git a/.gitignore b/.gitignore index fff12ec..63cc3b0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ CMakeCache.txt cmake_install.cmake Makefile src/configuration.hpp -.DS_Store \ No newline at end of file +.DS_Store +*.swo +*.swp diff --git a/CMakeLists.txt b/CMakeLists.txt index 12dda07..9e3f1a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,18 +130,32 @@ set(SDL2main_LIBRARY SDL2main) set(SDL2_LIBRARIES ${SDL2main_LIBRARY} ${SDL2_LIBRARY} - dinput8 - dxguid - user32 - gdi32 - winmm - imm32 - ole32 - oleaut32 - shell32 - version - uuid ) + +if(MSVC) + set(SDL2_LIBRARIES + ${SDL2_LIBRARIES} + dinput8 + dxguid + user32 + gdi32 + winmm + imm32 + ole32 + oleaut32 + shell32 + version + uuid + ) +else() + set(SDL2_LIBRARIES + ${SDL2_LIBRARIES} + pthread + dl + ) +endif() + + ExternalProject_Add(SDL2-project SOURCE_DIR ${PROJECT_SOURCE_DIR}/lib/SDL2 CMAKE_ARGS @@ -242,13 +256,10 @@ set(EXECUTABLE_SOURCES # Setup manifest and exe icon for windows if(${PLATFORM} STREQUAL "win32" OR ${PLATFORM} STREQUAL "win64") - list(APPEND EXECUTABLE_SOURCES "${EXECUTABLE_SOURCE_DIR}/dpi-aware.manifest") + list(APPEND EXECUTABLE_SOURCES "${EXECUTABLE_SOURCE_DIR}/windows/antkeeper.manifest") if(EXISTS ${PROJECT_SOURCE_DIR}/data) set(RC_FILES "${PROJECT_SOURCE_DIR}/data/icons/icon.rc") - #set(CMAKE_RC_COMPILER_INIT windres) - #enable_language(RC) - #set(CMAKE_RC_COMPILE_OBJECT " ") set(EXECUTABLE_SOURCES "${EXECUTABLE_SOURCES};${RC_FILES}") endif() endif() @@ -291,11 +302,19 @@ list(APPEND EXECUTABLE_LIBRARIES target_link_libraries(${EXECUTABLE_TARGET} ${EXECUTABLE_LIBRARIES}) # Add run target -add_custom_target(run - COMMAND ${EXECUTABLE_TARGET} - DEPENDS ${EXECUTABLE_TARGET} - WORKING_DIRECTORY ${PLATFORM_PACKAGE_DIR} -) +if(${PLATFORM} STREQUAL "linux32" OR ${PLATFORM} STREQUAL "linux64") + add_custom_target(run + COMMAND optirun "${PLATFORM_PACKAGE_DIR}/${EXECUTABLE_NAME}" + DEPENDS ${EXECUTABLE_TARGET} + WORKING_DIRECTORY ${PLATFORM_PACKAGE_DIR} + ) +else() + add_custom_target(run + COMMAND ${EXECUTABLE_TARGET} + DEPENDS ${EXECUTABLE_TARGET} + WORKING_DIRECTORY ${PLATFORM_PACKAGE_DIR} + ) +endif() # Add dist target add_custom_target(dist @@ -352,4 +371,4 @@ elseif(${PLATFORM} STREQUAL "linux32" OR ${PLATFORM} STREQUAL "linux64") endif() endif() -include(CPack) \ No newline at end of file +include(CPack) diff --git a/lib/emergent b/lib/emergent index c79c7f5..16405a4 160000 --- a/lib/emergent +++ b/lib/emergent @@ -1 +1 @@ -Subproject commit c79c7f5a714472ae123a12400d462e59c05bd443 +Subproject commit 16405a4181a39cff79b57b4c9c2389c31a136794 diff --git a/src/application.cpp b/src/application.cpp index f058349..2a054a0 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -56,16 +56,16 @@ Application::Application(int argc, char* argv[]): context = nullptr; // Initialize SDL - std::cout << "Initializing SDL... "; + std::cout << std::string("Initializing SDL... "); if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER) < 0) { - std::cout << "failed: \"" << SDL_GetError() << "\"" << std::endl; + std::cout << std::string("failed: \"") << SDL_GetError() << std::string("\"") << std::endl; close(EXIT_FAILURE); return; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Print SDL version strings @@ -73,43 +73,43 @@ Application::Application(int argc, char* argv[]): SDL_version linked; SDL_VERSION(&compiled); SDL_GetVersion(&linked); - std::cout << "Compiled with SDL " << (int)compiled.major << "." << (int)compiled.minor << "." << (int)compiled.patch << std::endl; - std::cout << "Linking to SDL " << (int)linked.major << "." << (int)linked.minor << "." << (int)linked.patch << std::endl; + std::cout << std::string("Compiled with SDL ") << (int)compiled.major << std::string(".") << (int)compiled.minor << std::string(".") << (int)compiled.patch << std::endl; + std::cout << std::string("Linking to SDL ") << (int)linked.major << std::string(".") << (int)linked.minor << std::string(".") << (int)linked.patch << std::endl; // Find app and user data paths - appDataPath = std::string(SDL_GetBasePath()) + "data/"; + appDataPath = std::string(SDL_GetBasePath()) + std::string("data/"); userDataPath = SDL_GetPrefPath("cjhoward", "antkeeper"); - std::cout << "Application data path: \"" << appDataPath << "\"" << std::endl; - std::cout << "User data path: \"" << userDataPath << "\"" << std::endl; + std::cout << std::string("Application data path: \"") << appDataPath << std::string("\"") << std::endl; + std::cout << std::string("User data path: \"") << userDataPath << std::string("\"") << std::endl; // Form pathes to settings files - defaultSettingsFilename = appDataPath + "default-settings.txt"; - userSettingsFilename = userDataPath + "settings.txt"; + defaultSettingsFilename = appDataPath + std::string("default-settings.txt"); + userSettingsFilename = userDataPath + std::string("settings.txt"); // Load default settings - std::cout << "Loading default settings from \"" << defaultSettingsFilename << "\"... "; + std::cout << std::string("Loading default settings from \"") << defaultSettingsFilename << std::string("\"... "); if (!settings.load(defaultSettingsFilename)) { - std::cout << "failed" << std::endl; + std::cout << std::string("failed") << std::endl; close(EXIT_FAILURE); return; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Load user settings - std::cout << "Loading user settings from \"" << userSettingsFilename << "\"... "; + std::cout << std::string("Loading user settings from \"") << userSettingsFilename << std::string("\"... "); if (!settings.load(userSettingsFilename)) { // Failed, save default settings as user settings - std::cout << "failed" << std::endl; + std::cout << std::string("failed") << std::endl; saveUserSettings(); } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Get values of required settings @@ -140,7 +140,7 @@ Application::Application(int argc, char* argv[]): if (SDL_GetDisplayMode(0, i, &displayMode) != 0) { - std::cerr << "Failed to get display mode: \"" << SDL_GetError() << "\"" << std::endl; + std::cerr << std::string("Failed to get display mode: \"") << SDL_GetError() << std::string("\"") << std::endl; close(EXIT_FAILURE); return; } @@ -160,7 +160,7 @@ Application::Application(int argc, char* argv[]): SDL_DisplayMode desktopDisplayMode; if (SDL_GetDesktopDisplayMode(0, &desktopDisplayMode) != 0) { - std::cerr << "Failed to get desktop display mode: \"" << SDL_GetError() << "\"" << std::endl; + std::cerr << std::string("Failed to get desktop display mode: \"") << SDL_GetError() << std::string("\"") << std::endl; close(EXIT_FAILURE); return; } @@ -214,16 +214,15 @@ Application::Application(int argc, char* argv[]): languageIndex = 0; std::string requestedLanguage; settings.get("language", &requestedLanguage); + std::string stringsDirectory = appDataPath + std::string("strings/"); // Find available languages { - std::string stringsDirectory = appDataPath + "strings/"; - // Open strings directory DIR* dir = opendir(stringsDirectory.c_str()); if (dir == nullptr) { - std::cout << "Failed to open strings directory \"" << stringsDirectory << "\"" << std::endl; + std::cout << std::string("Failed to open strings directory \"") << stringsDirectory << std::string("\"") << std::endl; close(EXIT_FAILURE); return; } @@ -264,15 +263,15 @@ Application::Application(int argc, char* argv[]): } // Load strings - std::string stringsFile = appDataPath + "strings/" + languages[languageIndex] + ".txt"; - std::cout << "Loading strings from \"" << stringsFile << "\"... "; + std::string stringsFile = appDataPath + std::string("strings/") + languages[languageIndex] + std::string(".txt"); + std::cout << std::string("Loading strings from \"") << stringsFile << std::string("\"... "); if (!strings.load(stringsFile)) { - std::cout << "failed" << std::endl; + std::cout << std::string("failed") << std::endl; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Get window title string @@ -280,87 +279,87 @@ Application::Application(int argc, char* argv[]): strings.get("title", &title); // Create window - std::cout << "Creating a " << resolution.x << "x" << resolution.y; + std::cout << std::string("Creating a ") << resolution.x << std::string("x") << resolution.y; std::cout << ((fullscreen) ? " fullscreen" : " windowed"); - std::cout << " window... "; + std::cout << std::string(" window... "); window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, static_cast(resolution.x), static_cast(resolution.y), windowFlags); if (window == nullptr) { - std::cout << "failed: \"" << SDL_GetError() << "\"" << std::endl; + std::cout << std::string("failed: \"") << SDL_GetError() << std::string("\"") << std::endl; close(EXIT_FAILURE); return; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Print video driver const char* videoDriver = SDL_GetCurrentVideoDriver(); if (!videoDriver) { - std::cout << "Unable to determine video driver" << std::endl; + std::cout << std::string("Unable to determine video driver") << std::endl; } else { - std::cout << "Using video driver \"" << videoDriver << "\"" << std::endl; + std::cout << std::string("Using video driver \"") << videoDriver << std::string("\"") << std::endl; } // Create an OpenGL context - std::cout << "Creating an OpenGL context... "; + std::cout << std::string("Creating an OpenGL context... "); context = SDL_GL_CreateContext(window); if (context == nullptr) { - std::cout << "failed: \"" << SDL_GetError() << "\"" << std::endl; + std::cout << std::string("failed: \"") << SDL_GetError() << std::string("\"") << std::endl; close(EXIT_FAILURE); return; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Initialize GL3W - std::cout << "Initializing GL3W... "; + std::cout << std::string("Initializing GL3W... "); if (gl3wInit()) { - std::cout << "failed" << std::endl; + std::cout << std::string("failed") << std::endl; close(EXIT_FAILURE); return; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Check if OpenGL version is supported if (!gl3wIsSupported(OPENGL_VERSION_MAJOR, OPENGL_VERSION_MINOR)) { - std::cout << "OpenGL " << OPENGL_VERSION_MAJOR << "." << OPENGL_VERSION_MINOR << " not supported" << std::endl; + std::cout << std::string("OpenGL ") << OPENGL_VERSION_MAJOR << std::string(".") << OPENGL_VERSION_MINOR << std::string(" not supported") << std::endl; close(EXIT_FAILURE); return; } // Print OpenGL and GLSL version strings - std::cout << "Using OpenGL " << glGetString(GL_VERSION) << ", GLSL " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl; + std::cout << std::string("Using OpenGL ") << glGetString(GL_VERSION) << std::string(", GLSL ") << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl; // Set swap interval (vsync) if (swapInterval) { - std::cout << "Enabling vertical sync... "; + std::cout << std::string("Enabling vertical sync... "); } else { - std::cout << "Disabling vertical sync... "; + std::cout << std::string("Disabling vertical sync... "); } if (SDL_GL_SetSwapInterval(swapInterval) != 0) { - std::cout << "failed: \"" << SDL_GetError() << "\"" << std::endl; + std::cout << std::string("failed: \"") << SDL_GetError() << std::string("\"") << std::endl; swapInterval = SDL_GL_GetSwapInterval(); } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Clear screen to black @@ -369,28 +368,28 @@ Application::Application(int argc, char* argv[]): SDL_GL_SwapWindow(window); // Get display DPI - std::cout << "Getting DPI of display 0... "; + std::cout << std::string("Getting DPI of display 0... "); if (SDL_GetDisplayDPI(0, &dpi, nullptr, nullptr) != 0) { - std::cerr << "failed: \"" << SDL_GetError() << "\"" << std::endl; + std::cerr << std::string("failed: \"") << SDL_GetError() << std::string("\"") << std::endl; - std::cout << "Reverting to default DPI" << std::endl; + std::cout << std::string("Reverting to default DPI") << std::endl; settings.get("default_dpi", &dpi); } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Print DPI - std::cout << "Rendering at " << dpi << " DPI" << std::endl; + std::cout << std::string("Rendering at ") << dpi << std::string(" DPI") << std::endl; // Determine base font size settings.get("font_size", &fontSizePT); fontSizePX = fontSizePT * (1.0f / 72.0f) * dpi; // Print font size - std::cout << "Base font size is " << fontSizePT << "pt (" << fontSizePX << "px)" << std::endl; + std::cout << std::string("Base font size is ") << fontSizePT << std::string("pt (") << fontSizePX << std::string("px)") << std::endl; // Setup input inputManager = new SDLInputManager(); @@ -621,7 +620,7 @@ void Application::changeFullscreen() SDL_SetWindowSize(window, static_cast(resolution.x), static_cast(resolution.y)); if (SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN) != 0) { - std::cerr << "Failed to set fullscreen mode: \"" << SDL_GetError() << "\"" << std::endl; + std::cerr << std::string("Failed to set fullscreen mode: \"") << SDL_GetError() << std::string("\"") << std::endl; fullscreen = false; } } @@ -631,7 +630,7 @@ void Application::changeFullscreen() if (SDL_SetWindowFullscreen(window, 0) != 0) { - std::cerr << "Failed to set windowed mode: \"" << SDL_GetError() << "\"" << std::endl; + std::cerr << std::string("Failed to set windowed mode: \"") << SDL_GetError() << std::string("\"") << std::endl; fullscreen = true; } else @@ -644,11 +643,11 @@ void Application::changeFullscreen() // Print mode and resolution if (fullscreen) { - std::cout << "Changed to fullscreen mode at resolution " << resolution.x << "x" << resolution.y << std::endl; + std::cout << std::string("Changed to fullscreen mode at resolution ") << resolution.x << std::string("x") << resolution.y << std::endl; } else { - std::cout << "Changed to windowed mode at resolution " << resolution.x << "x" << resolution.y << std::endl; + std::cout << std::string("Changed to windowed mode at resolution ") << resolution.x << std::string("x") << resolution.y << std::endl; } // Save settings @@ -668,21 +667,21 @@ void Application::changeVerticalSync() if (swapInterval == 1) { - std::cout << "Enabling vertical sync... "; + std::cout << std::string("Enabling vertical sync... "); } else { - std::cout << "Disabling vertical sync... "; + std::cout << std::string("Disabling vertical sync... "); } if (SDL_GL_SetSwapInterval(swapInterval) != 0) { - std::cout << "failed: \"" << SDL_GetError() << "\"" << std::endl; + std::cout << std::string("failed: \"") << SDL_GetError() << std::string("\"") << std::endl; swapInterval = SDL_GL_GetSwapInterval(); } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Save settings @@ -692,14 +691,14 @@ void Application::changeVerticalSync() void Application::saveUserSettings() { - std::cout << "Saving user setttings to \"" << userSettingsFilename << "\"... "; + std::cout << std::string("Saving user setttings to \"") << userSettingsFilename << std::string("\"... "); if (!settings.save(userSettingsFilename)) { - std::cout << "failed" << std::endl; + std::cout << std::string("failed") << std::endl; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } } @@ -975,23 +974,23 @@ bool Application::loadUI() { // Load fonts FontLoader* fontLoader = new FontLoader(); - + menuFont = new Font(512, 512); if (!fontLoader->load("data/fonts/NotoSansCJKsc-Regular.otf", static_cast(fontSizePX + 0.5f), {UnicodeRange::BASIC_LATIN}, menuFont)) { - std::cerr << "Failed to load menu font" << std::endl; + std::cerr << std::string("Failed to load menu font") << std::endl; } copyrightFont = new Font(256, 256); if (!fontLoader->load("data/fonts/Varela-Regular.ttf", static_cast(fontSizePX * 0.8f + 0.5f), {UnicodeRange::BASIC_LATIN}, copyrightFont)) { - std::cerr << "Failed to load copyright font" << std::endl; + std::cerr << std::string("Failed to load copyright font") << std::endl; } levelNameFont = new Font(512, 512); if (!fontLoader->load("data/fonts/Vollkorn-Regular.ttf", static_cast(fontSizePX * 2.0f + 0.5f), {UnicodeRange::BASIC_LATIN}, levelNameFont)) { - std::cerr << "Failed to load level name font" << std::endl; + std::cerr << std::string("Failed to load level name font") << std::endl; } delete fontLoader; @@ -1735,7 +1734,7 @@ void Application::restringUI() strings.get("menu-font", &menuFontBasename); strings.get("copyright-font", ©rightFontBasename); strings.get("level-name-font", &levelNameFontBasename); - std::string fontsDirectory = appDataPath + "fonts/"; + std::string fontsDirectory = appDataPath + std::string("fonts/"); // Load fonts with the custom Unicode ranges FontLoader* fontLoader = new FontLoader(); @@ -1743,19 +1742,19 @@ void Application::restringUI() menuFont = new Font(512, 512); if (!fontLoader->load(fontsDirectory + menuFontBasename, static_cast(fontSizePX + 0.5f), unicodeRanges, menuFont)) { - std::cerr << "Failed to load menu font" << std::endl; + std::cerr << std::string("Failed to load menu font") << std::endl; } copyrightFont = new Font(256, 256); if (!fontLoader->load(fontsDirectory + copyrightFontBasename, static_cast(fontSizePX * 0.8f + 0.5f), unicodeRanges, copyrightFont)) { - std::cerr << "Failed to load copyright font" << std::endl; + std::cerr << std::string("Failed to load copyright font") << std::endl; } levelNameFont = new Font(512, 512); if (!fontLoader->load(fontsDirectory + levelNameFontBasename, static_cast(fontSizePX * 2.0f + 0.5f), unicodeRanges, levelNameFont)) { - std::cerr << "Failed to load level name font" << std::endl; + std::cerr << std::string("Failed to load level name font") << std::endl; } delete fontLoader; @@ -1796,7 +1795,7 @@ void Application::restringUI() /* std::u32string label; std::stringstream stream; - stream << (world + 1) << "-" << (level + 1) << ": "; + stream << (world + 1) << std::string("-") << (level + 1) << std::string(": "; label = std::wstring_convert, char32_t>().from_bytes(stream.str()) + levelName; */ @@ -1818,7 +1817,7 @@ void Application::restringUI() std::u32string label; std::stringstream stream; - stream << resolutions[i].x << "x" << resolutions[i].y; + stream << resolutions[i].x << std::string("x") << resolutions[i].y; std::string streamstring = stream.str(); label.assign(streamstring.begin(), streamstring.end()); @@ -2209,7 +2208,7 @@ void Application::selectFullscreenMode(std::size_t index) SDL_SetWindowSize(window, static_cast(resolution.x), static_cast(resolution.y)); if (SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN) != 0) { - std::cerr << "Failed to set fullscreen mode: \"" << SDL_GetError() << "\"" << std::endl; + std::cerr << std::string("Failed to set fullscreen mode: \"") << SDL_GetError() << std::string("\"") << std::endl; fullscreen = false; } } @@ -2219,7 +2218,7 @@ void Application::selectFullscreenMode(std::size_t index) if (SDL_SetWindowFullscreen(window, 0) != 0) { - std::cerr << "Failed to set windowed mode: \"" << SDL_GetError() << "\"" << std::endl; + std::cerr << std::string("Failed to set windowed mode: \"") << SDL_GetError() << std::string("\"") << std::endl; fullscreen = true; } else @@ -2232,11 +2231,11 @@ void Application::selectFullscreenMode(std::size_t index) // Print mode and resolution if (fullscreen) { - std::cout << "Changed to fullscreen mode at resolution " << resolution.x << "x" << resolution.y << std::endl; + std::cout << std::string("Changed to fullscreen mode at resolution ") << resolution.x << std::string("x") << resolution.y << std::endl; } else { - std::cout << "Changed to windowed mode at resolution " << resolution.x << "x" << resolution.y << std::endl; + std::cout << std::string("Changed to windowed mode at resolution ") << resolution.x << std::string("x") << resolution.y << std::endl; } // Save settings @@ -2257,21 +2256,21 @@ void Application::selectVSyncMode(std::size_t index) if (swapInterval == 1) { - std::cout << "Enabling vertical sync... "; + std::cout << std::string("Enabling vertical sync... "); } else { - std::cout << "Disabling vertical sync... "; + std::cout << std::string("Disabling vertical sync... "); } if (SDL_GL_SetSwapInterval(swapInterval) != 0) { - std::cout << "failed: \"" << SDL_GetError() << "\"" << std::endl; + std::cout << std::string("failed: \"") << SDL_GetError() << std::string("\"") << std::endl; swapInterval = SDL_GL_GetSwapInterval(); } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Save settings @@ -2288,15 +2287,15 @@ void Application::selectLanguage(std::size_t index) strings.clear(); // Load strings - std::string stringsFile = appDataPath + "strings/" + languages[languageIndex] + ".txt"; - std::cout << "Loading strings from \"" << stringsFile << "\"... "; + std::string stringsFile = appDataPath + std::string("strings/") + languages[languageIndex] + std::string(".txt"); + std::cout << std::string("Loading strings from \"") << stringsFile << std::string("\"... "); if (!strings.load(stringsFile)) { - std::cout << "failed" << std::endl; + std::cout << std::string("failed") << std::endl; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } // Save settings diff --git a/src/controls.cpp b/src/controls.cpp index 40ab1ea..0aaeabd 100644 --- a/src/controls.cpp +++ b/src/controls.cpp @@ -439,7 +439,7 @@ bool ControlProfile::save(const std::string& filename) std::ofstream file(filename.c_str()); if (!file.is_open()) { - std::cerr << "Failed to open control profile \"" << filename << "\"" << std::endl; + std::cerr << std::string("Failed to open control profile \"") << filename << std::string("\"") << std::endl; return false; } @@ -455,30 +455,30 @@ bool ControlProfile::save(const std::string& filename) for (auto boundKey: *boundKeys) { int key = boundKey.second; - file << "control\t" << it->first << "\tkeyboard\tkey\t" << key << '\n'; + file << std::string("control\t") << it->first << std::string("\tkeyboard\tkey\t") << key << '\n'; } for (auto boundMouseButton: *boundMouseButtons) { int button = boundMouseButton.second; - file << "control\t" << it->first << "\tmouse\tbutton\t" << button << '\n'; + file << std::string("control\t") << it->first << std::string("\tmouse\tbutton\t") << button << '\n'; } for (auto boundMouseWheelAxis: *boundMouseWheelAxes) { MouseWheelAxis axis = boundMouseWheelAxis.second; - file << "control\t" << it->first << "\tmouse\twheel\t"; + file << std::string("control\t") << it->first << std::string("\tmouse\twheel\t"); if (axis == MouseWheelAxis::POSITIVE_X) - file << "+x"; + file << std::string("+x"); else if (axis == MouseWheelAxis::NEGATIVE_X) - file << "-x"; + file << std::string("-x"); else if (axis == MouseWheelAxis::POSITIVE_Y) - file << "+y"; + file << std::string("+y"); else if (axis == MouseWheelAxis::NEGATIVE_Y) - file << "-y"; + file << std::string("-y"); else - file << "unknown"; + file << std::string("unknown"); file << '\n'; } @@ -486,7 +486,7 @@ bool ControlProfile::save(const std::string& filename) { const std::string& gamepadName = boundGamepadButton.first->getName(); int button = boundGamepadButton.second; - file << "control\t" << it->first << "\tgamepad\t" << gamepadName << "\tbutton\t" << button << '\n'; + file << std::string("control\t") << it->first << std::string("\tgamepad\t") << gamepadName << std::string("\tbutton\t") << button << '\n'; } for (auto boundGamepadAxis: *boundGamepadAxes) @@ -497,12 +497,12 @@ bool ControlProfile::save(const std::string& filename) std::stringstream axisstream; if (negative) - axisstream << "-"; + axisstream << std::string("-"); else - axisstream << "+"; + axisstream << std::string("+"); axisstream << axis; - file << "control\t" << it->first << "\tgamepad\t" << gamepadName << "\taxis\t" << axisstream.str() << '\n'; + file << std::string("control\t") << it->first << std::string("\tgamepad\t") << gamepadName << std::string("\taxis\t") << axisstream.str() << '\n'; } } @@ -517,7 +517,7 @@ bool ControlProfile::load(const std::string& filename) std::ifstream file(filename.c_str()); if (!file.is_open()) { - std::cerr << "Failed to open control profile \"" << filename << "\"" << std::endl; + std::cerr << std::string("Failed to open control profile \"") << filename << std::string("\"") << std::endl; return false; } @@ -541,7 +541,7 @@ bool ControlProfile::load(const std::string& filename) auto it = controls.find(tokens[1]); if (it == controls.end()) { - std::cerr << "Attempted to load unregistered control \"" << tokens[1] << "\" from control profile \"" << filename << "\"" << std::endl; + std::cerr << std::string("Attempted to load unregistered control \"") << tokens[1] << std::string("\" from control profile \"") << filename << std::string("\"") << std::endl; continue; } Control* control = it->second; @@ -561,7 +561,7 @@ bool ControlProfile::load(const std::string& filename) } else { - std::cerr << "Invalid line \"" << line << "\" in control profile \"" << filename << "\"" << std::endl; + std::cerr << std::string("Invalid line \"") << line << std::string("\" in control profile \"") << filename << std::string("\"") << std::endl; } } else if (tokens[2] == "mouse") @@ -589,7 +589,7 @@ bool ControlProfile::load(const std::string& filename) axis = MouseWheelAxis::NEGATIVE_Y; else { - std::cerr << "Invalid line \"" << line << "\" in control profile \"" << filename << "\"" << std::endl; + std::cerr << std::string("Invalid line \"") << line << std::string("\" in control profile \"") << filename << std::string("\"") << std::endl; continue; } @@ -597,7 +597,7 @@ bool ControlProfile::load(const std::string& filename) } else { - std::cerr << "Invalid line \"" << line << "\" in control profile \"" << filename << "\"" << std::endl; + std::cerr << std::string("Invalid line \"") << line << std::string("\" in control profile \"") << filename << std::string("\"") << std::endl; continue; } } @@ -605,7 +605,7 @@ bool ControlProfile::load(const std::string& filename) { if (tokens.size() != 6) { - std::cerr << "Invalid line \"" << line << "\" in control profile \"" << filename << "\"" << std::endl; + std::cerr << std::string("Invalid line \"") << line << std::string("\" in control profile \"") << filename << std::string("\"") << std::endl; continue; } @@ -637,13 +637,13 @@ bool ControlProfile::load(const std::string& filename) } else { - std::cerr << "Invalid line \"" << line << "\" in control profile \"" << filename << "\"" << std::endl; + std::cerr << std::string("Invalid line \"") << line << std::string("\" in control profile \"") << filename << std::string("\"") << std::endl; continue; } } else { - std::cerr << "Unsupported input device \"" << tokens[3] << "\" in control profile \"" << filename << "\"" << std::endl; + std::cerr << std::string("Unsupported input device \"") << tokens[3] << std::string("\" in control profile \"") << filename << std::string("\"") << std::endl; continue; } } diff --git a/src/game/biome.cpp b/src/game/biome.cpp index d0126b9..36793bc 100644 --- a/src/game/biome.cpp +++ b/src/game/biome.cpp @@ -46,7 +46,7 @@ bool Biome::load() diffuseCubemap = textureLoader.loadCube(diffuseCubemapFilename); if (!diffuseCubemap) { - std::cerr << "Failed to load diffuse cubemap \"" << diffuseCubemapFilename << "\"" << std::endl; + std::cerr << std::string("Failed to load diffuse cubemap \"") << diffuseCubemapFilename << std::string("\"") << std::endl; } // Load specular cubemap @@ -54,7 +54,7 @@ bool Biome::load() specularCubemap = textureLoader.loadCube(specularCubemapFilename); if (!specularCubemap) { - std::cerr << "Failed to load specular cubemap \"" << specularCubemapFilename << "\"" << std::endl; + std::cerr << std::string("Failed to load specular cubemap \"") << specularCubemapFilename << std::string("\"") << std::endl; } return true; @@ -66,7 +66,7 @@ bool Biosphere::load(const std::string& directory) DIR* dir = opendir(directory.c_str()); if (dir == nullptr) { - std::cout << "Failed to open biome directory \"" << directory << "\"" << std::endl; + std::cout << std::string("Failed to open biome directory \"") << directory << std::string("\"") << std::endl; return false; } @@ -107,11 +107,11 @@ bool Biosphere::load(const std::string& directory) if (!biome->load()) { - std::cout << "Failed to load biome \"" << biome->filename << "\"" << std::endl; + std::cout << std::string("Failed to load biome \"") << biome->filename << std::string("\"") << std::endl; } else { - std::cout << "Loaded biome \"" << biome->filename << "\"" << std::endl; + std::cout << std::string("Loaded biome \"") << biome->filename << std::string("\"") << std::endl; } } diff --git a/src/input.cpp b/src/input.cpp index b1f6373..8b4841d 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -528,7 +528,7 @@ void SDLInputManager::update() auto it = gamepadMap.find(instanceID); if (it == gamepadMap.end()) { - std::cerr << "Received event from invalid gamepad" << std::endl; + std::cerr << std::string("Received event from invalid gamepad") << std::endl; break; } @@ -544,7 +544,7 @@ void SDLInputManager::update() auto it = gamepadMap.find(instanceID); if (it == gamepadMap.end()) { - std::cerr << "Received event from invalid gamepad" << std::endl; + std::cerr << std::string("Received event from invalid gamepad") << std::endl; break; } @@ -560,7 +560,7 @@ void SDLInputManager::update() auto it = gamepadMap.find(instanceID); if (it == gamepadMap.end()) { - std::cerr << "Received event from invalid gamepad" << std::endl; + std::cerr << std::string("Received event from invalid gamepad") << std::endl; break; } @@ -612,7 +612,7 @@ void SDLInputManager::update() gamepad->setDisconnected(false); reconnected = true; - std::cout << "Reconnected gamepad \"" << name << "\" with ID " << instanceID << std::endl; + std::cout << std::string("Reconnected gamepad \"") << name << std::string("\" with ID ") << instanceID << std::endl; break; } } @@ -634,7 +634,7 @@ void SDLInputManager::update() // Connect gamepad gamepad->setDisconnected(false); - std::cout << "Connected gamepad \"" << name << "\" with ID " << instanceID << std::endl; + std::cout << std::string("Connected gamepad \"") << name << std::string("\" with ID ") << instanceID << std::endl; } } break; @@ -648,7 +648,7 @@ void SDLInputManager::update() auto mapIt = gamepadMap.find(instanceID); if (mapIt == gamepadMap.end()) { - std::cerr << "Attempted to remove nonexistent gamepad with ID " << instanceID << std::endl; + std::cerr << std::string("Attempted to remove nonexistent gamepad with ID ") << instanceID << std::endl; break; } Gamepad* gamepad = mapIt->second; @@ -659,7 +659,7 @@ void SDLInputManager::update() // Set disconnected flag gamepad->setDisconnected(true); - std::cout << "Disconnected gamepad \"" << gamepad->getName() << "\" with ID " << instanceID << std::endl; + std::cout << std::string("Disconnected gamepad \"") << gamepad->getName() << std::string("\" with ID ") << instanceID << std::endl; break; } @@ -752,7 +752,7 @@ void SDLInputManager::listen(InputEvent* inputEvent) auto it = gamepadMap.find(instanceID); if (it == gamepadMap.end()) { - std::cerr << "Received event from invalid gamepad" << std::endl; + std::cerr << std::string("Received event from invalid gamepad") << std::endl; return; } @@ -772,7 +772,7 @@ void SDLInputManager::listen(InputEvent* inputEvent) auto it = gamepadMap.find(instanceID); if (it == gamepadMap.end()) { - std::cerr << "Received event from invalid gamepad" << std::endl; + std::cerr << std::string("Received event from invalid gamepad") << std::endl; return; } diff --git a/src/material-loader.cpp b/src/material-loader.cpp index 7f0964b..386c6ff 100644 --- a/src/material-loader.cpp +++ b/src/material-loader.cpp @@ -73,14 +73,14 @@ Material* MaterialLoader::load(const std::string& filename) std::ifstream file(filename.c_str(), std::ifstream::in); if (!file.is_open()) { - std::cerr << "MaterialLoader::load(): Failed to open material file \"" << filename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::load(): Failed to open material file \"") << filename << std::string("\"") << std::endl; delete material; return nullptr; } std::string line; std::size_t lineNumber = 0; - const std::string whitespace = " \t"; + const std::string whitespace = " \t\r\n"; // Parse lines while (file.good() && std::getline(file, line)) @@ -113,7 +113,7 @@ Material* MaterialLoader::load(const std::string& filename) if (equalsSignPosition == std::string::npos) { // Skip lines with no equals sign - std::cerr << "MaterialLoader::load(): Invalid line " << lineNumber << " in \"" << filename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::load(): Invalid line ") << lineNumber << std::string(" in \"") << filename << std::string("\"") << std::endl; continue; } @@ -122,12 +122,12 @@ Material* MaterialLoader::load(const std::string& filename) if (valueStartPosition == std::string::npos) { // Skip lines with no value - std::cerr << "MaterialLoader::load(): Invalid line " << lineNumber << " in \"" << filename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::load(): Invalid line ") << lineNumber << std::string(" in \"") << filename << std::string("\"") << std::endl; continue; } // Find position the end of the value string - std::size_t valueEndPosition = line.find_first_of(" \t;", valueStartPosition); + std::size_t valueEndPosition = line.find_first_of(" \t;\r\n", valueStartPosition); // Determine value string std::string valueString; @@ -147,7 +147,7 @@ Material* MaterialLoader::load(const std::string& filename) Shader* shader = loadShader(valueString); if (!shader) { - std::cerr << "MaterialLoader::load(): Failed to load shader \"" << valueString << "\" on line " << lineNumber << " in \"" << filename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::load(): Failed to load shader \"") << valueString << std::string("\" on line ") << lineNumber << std::string(" in \"") << filename << std::string("\"") << std::endl; } else { @@ -172,7 +172,7 @@ Material* MaterialLoader::load(const std::string& filename) if (variableNamePosition == std::string::npos) { // Skip lines with no variable name - std::cerr << "MaterialLoader::load(): Invalid variable on line " << lineNumber << " in \"" << filename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::load(): Invalid variable on line ") << lineNumber << std::string(" in \"") << filename << std::string("\"") << std::endl; continue; } @@ -181,7 +181,7 @@ Material* MaterialLoader::load(const std::string& filename) if (equalsSignPosition == std::string::npos) { // Skip lines with no equals sign - std::cerr << "MaterialLoader::load(): Invalid variable on line " << lineNumber << " in \"" << filename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::load(): Invalid variable on line ") << lineNumber << std::string(" in \"") << filename << std::string("\"") << std::endl; continue; } @@ -190,7 +190,7 @@ Material* MaterialLoader::load(const std::string& filename) if (variableTypePosition == std::string::npos) { // Skip lines with no variable type definition - std::cerr << "MaterialLoader::load(): Invalid variable on line " << lineNumber << " in \"" << filename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::load(): Invalid variable on line ") << lineNumber << std::string(" in \"") << filename << std::string("\"") << std::endl; continue; } @@ -200,7 +200,7 @@ Material* MaterialLoader::load(const std::string& filename) if (leftParenthesisCount != rightParenthesisCount || leftParenthesisCount == 0) { // Skip lines with invalid number of parentheses - std::cerr << "MaterialLoader::load(): Invalid variable on line " << lineNumber << " in \"" << filename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::load(): Invalid variable on line ") << lineNumber << std::string(" in \"") << filename << std::string("\"") << std::endl; continue; } @@ -315,7 +315,7 @@ Material* MaterialLoader::load(const std::string& filename) } // Invalid command - std::cerr << "MaterialLoader::load(): Invalid command \"" << command << "\" on line " << lineNumber << " in \"" << filename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::load(): Invalid command \"") << command << std::string("\" on line ") << lineNumber << std::string(" in \"") << filename << std::string("\"") << std::endl; } } @@ -337,6 +337,8 @@ Shader* MaterialLoader::loadShader(const std::string& filename) } std::string fullFilename = std::string("data/shaders/") + filename; + + std::cout << std::string("Loading shader \"") << fullFilename << std::string("\"\n"); // Load shader Shader* shader = new Shader(); @@ -367,7 +369,7 @@ Texture2D* MaterialLoader::loadTexture2D(const std::string& filename) Texture2D* texture = textureLoader.load2D(fullFilename); if (!texture) { - std::cerr << "MaterialLoader::loadTexture2D(): Failed to load texture file \"" << fullFilename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::loadTexture2D(): Failed to load texture file \"") << fullFilename << std::string("\"") << std::endl; return nullptr; } @@ -392,7 +394,7 @@ TextureCube* MaterialLoader::loadTextureCube(const std::string& filename) TextureCube* texture = textureLoader.loadCube(fullFilename); if (!texture) { - std::cerr << "MaterialLoader::loadTextureCube(): Failed to load texture file \"" << fullFilename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::loadTextureCube(): Failed to load texture file \"") << fullFilename << std::string("\"") << std::endl; return nullptr; } @@ -545,7 +547,7 @@ bool MaterialLoader::loadShaderTexture2D(ShaderTexture2D* variable, const std::v Texture2D* value = loadTexture2D(filename); if (!value) { - std::cerr << "MaterialLoader::loadShaderTexture2D(): Failed to load 2D texture \"" << filename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::loadShaderTexture2D(): Failed to load 2D texture \"") << filename << std::string("\"") << std::endl; return false; } @@ -567,7 +569,7 @@ bool MaterialLoader::loadShaderTextureCube(ShaderTextureCube* variable, const st TextureCube* value = loadTextureCube(filename); if (!value) { - std::cerr << "MaterialLoader::loadShaderTextureCube(): Failed to load cube texture \"" << filename << "\"" << std::endl; + std::cerr << std::string("MaterialLoader::loadShaderTextureCube(): Failed to load cube texture \"") << filename << std::string("\"") << std::endl; return false; } diff --git a/src/model-loader.cpp b/src/model-loader.cpp index 9572090..a2b42e0 100644 --- a/src/model-loader.cpp +++ b/src/model-loader.cpp @@ -70,7 +70,7 @@ Model* ModelLoader::load(const std::string& filename) std::ifstream file(filename.c_str(), std::ifstream::in | std::ifstream::binary | std::ifstream::ate); if (!file.is_open()) { - std::cerr << "ModelLoader::load(): Failed to open model file \"" << filename << "\"" << std::endl; + std::cerr << std::string("ModelLoader::load(): Failed to open model file \"") << filename << std::string("\"") << std::endl; return nullptr; } @@ -383,13 +383,13 @@ Model* ModelLoader::load(const std::string& filename) modelGroup->material = materialLoader->load(materialFilename); if (!modelGroup->material) { - std::cerr << "ModelLoader::load(): Failed to load material file \"" << materialFilename << "\" for model file \"" << filename << "\"" << std::endl; + std::cerr << std::string("ModelLoader::load(): Failed to load material file \"") << materialFilename << std::string("\" for model file \"") << filename << std::string("\"") << std::endl; } } else { modelGroup->material = nullptr; - std::cerr << "ModelLoader::load(): No valid material loader, material file \"" << materialFilename << "\" not loaded" << std::endl; + std::cerr << std::string("ModelLoader::load(): No valid material loader, material file \"") << materialFilename << std::string("\" not loaded") << std::endl; } // Setup model group geometry diff --git a/src/render-passes.cpp b/src/render-passes.cpp index 4aa10cc..1f426a7 100644 --- a/src/render-passes.cpp +++ b/src/render-passes.cpp @@ -99,14 +99,14 @@ bool BlurRenderPass::load(const RenderContext* renderContext) // Load shader source if (!shader.loadSource("data/shaders/blur.glsl")) { - std::cerr << "BlurRenderPass: failed to load shader source." << std::endl; + std::cerr << std::string("BlurRenderPass: failed to load shader source.") << std::endl; return false; } // Generate permutation if (!shader.generatePermutation(permutation)) { - std::cerr << "BlurRenderPass: failed to generate shader permutation." << std::endl; + std::cerr << std::string("BlurRenderPass: failed to generate shader permutation.") << std::endl; return false; } @@ -118,7 +118,7 @@ bool BlurRenderPass::load(const RenderContext* renderContext) !resolutionParam.isConnected() || !directionParam.isConnected()) { - std::cerr << "BlurRenderPass: one or more shader variables were not connected to shader inputs." << std::endl; + std::cerr << std::string("BlurRenderPass: one or more shader variables were not connected to shader inputs.") << std::endl; return false; } @@ -254,14 +254,14 @@ bool ShadowMapRenderPass::load(const RenderContext* renderContext) // Load shader source if (!shader.loadSource("data/shaders/depth-pass.glsl")) { - std::cerr << "ShadowMapRenderPass: failed to load shader source." << std::endl; + std::cerr << std::string("ShadowMapRenderPass: failed to load shader source.") << std::endl; return false; } // Generate unskinned and skinned permutations if (!shader.generatePermutation(unskinnedPermutation) || !shader.generatePermutation(skinnedPermutation)) { - std::cerr << "ShadowMapRenderPass: failed to generate shader permutation." << std::endl; + std::cerr << std::string("ShadowMapRenderPass: failed to generate shader permutation.") << std::endl; return false; } @@ -274,7 +274,7 @@ bool ShadowMapRenderPass::load(const RenderContext* renderContext) if (!modelViewProjectionParam.isConnected() || !matrixPaletteParam->isConnected()) { - std::cerr << "ShadowMapRenderPass: one or more shader variables were not connected to shader inputs." << std::endl; + std::cerr << std::string("ShadowMapRenderPass: one or more shader variables were not connected to shader inputs.") << std::endl; return false; } @@ -473,7 +473,7 @@ bool LightingRenderPass::load(const RenderContext* renderContext) if (!shader.loadSource("data/shaders/standard.glsl")) { - std::cerr << "LightingRenderPass: Failed to load shader source." << std::endl; + std::cerr << std::string("LightingRenderPass: Failed to load shader source.") << std::endl; return false; } @@ -498,7 +498,7 @@ bool LightingRenderPass::load(const RenderContext* renderContext) // Generate shader permutations if (!shader.generatePermutation(unskinnedPermutation) || !shader.generatePermutation(skinnedPermutation)) { - std::cerr << "LightingRenderPass: failed to generate shader permutation." << std::endl; + std::cerr << std::string("LightingRenderPass: failed to generate shader permutation.") << std::endl; return false; } @@ -537,7 +537,7 @@ bool LightingRenderPass::load(const RenderContext* renderContext) !parameters.diffuseCubemap.isConnected() || !parameters.specularCubemap.isConnected()) { - std::cerr << "LightingRenderPass: one or more shader variables were not connected to shader inputs." << std::endl; + std::cerr << std::string("LightingRenderPass: one or more shader variables were not connected to shader inputs.") << std::endl; } return true; @@ -805,7 +805,7 @@ bool DebugRenderPass::load(const RenderContext* renderContext) { if (!shader.loadSource("data/shaders/unlit-solid.glsl")) { - std::cerr << "DebugRenderPass: Failed to load shader source." << std::endl; + std::cerr << std::string("DebugRenderPass: Failed to load shader source.") << std::endl; return false; } @@ -815,7 +815,7 @@ bool DebugRenderPass::load(const RenderContext* renderContext) // Generate shader permutations if (!shader.generatePermutation(permutation)) { - std::cerr << "DebugRenderPass: failed to generate shader permutation." << std::endl; + std::cerr << std::string("DebugRenderPass: failed to generate shader permutation.") << std::endl; return false; } @@ -823,7 +823,7 @@ bool DebugRenderPass::load(const RenderContext* renderContext) modelViewProjectionMatrixParam.connect(shader.getInput("modelViewProjectionMatrix")); if (!modelViewProjectionMatrixParam.isConnected()) { - std::cerr << "DebugRenderPass: one or more shader variables were not connected to shader inputs." << std::endl; + std::cerr << std::string("DebugRenderPass: one or more shader variables were not connected to shader inputs.") << std::endl; return false; } @@ -940,7 +940,7 @@ bool UIRenderPass::load(const RenderContext* renderContext) { if (!shader.loadSource("data/shaders/ui.glsl")) { - std::cerr << "UIRenderPass: Failed to load shader source." << std::endl; + std::cerr << std::string("UIRenderPass: Failed to load shader source.") << std::endl; return false; } @@ -951,7 +951,7 @@ bool UIRenderPass::load(const RenderContext* renderContext) // Generate shader permutations if (!shader.generatePermutation(untexturedPermutation) || !shader.generatePermutation(texturedPermutation)) { - std::cerr << "UIRenderPass: failed to generate shader permutation." << std::endl; + std::cerr << std::string("UIRenderPass: failed to generate shader permutation.") << std::endl; return false; } @@ -965,7 +965,7 @@ bool UIRenderPass::load(const RenderContext* renderContext) !textureOffsetParam.isConnected() || !textureScaleParam.isConnected()) { - std::cerr << "UIRenderPass: one or more shader variables were not connected to shader inputs." << std::endl; + std::cerr << std::string("UIRenderPass: one or more shader variables were not connected to shader inputs.") << std::endl; return false; } @@ -1143,7 +1143,7 @@ bool SkyboxRenderPass::load(const RenderContext* renderContext) { if (!shader.loadSource("data/shaders/skybox.glsl")) { - std::cerr << "SkyboxRenderPass: Failed to load shader source." << std::endl; + std::cerr << std::string("SkyboxRenderPass: Failed to load shader source.") << std::endl; return false; } @@ -1153,7 +1153,7 @@ bool SkyboxRenderPass::load(const RenderContext* renderContext) // Generate shader permutations if (!shader.generatePermutation(permutation)) { - std::cerr << "SkyboxRenderPass: failed to generate shader permutation." << std::endl; + std::cerr << std::string("SkyboxRenderPass: failed to generate shader permutation.") << std::endl; return false; } @@ -1162,7 +1162,7 @@ bool SkyboxRenderPass::load(const RenderContext* renderContext) cubemapParam.connect(shader.getInput("cubemap")); if (!matrixParam.isConnected() || !cubemapParam.isConnected()) { - std::cerr << "SkyboxRenderPass: one or more shader variables were not connected to shader inputs." << std::endl; + std::cerr << std::string("SkyboxRenderPass: one or more shader variables were not connected to shader inputs.") << std::endl; return false; } diff --git a/src/settings.cpp b/src/settings.cpp index 9d4957e..cd701e3 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -29,14 +29,22 @@ bool ParameterDict::load(const std::string& filename) std::ifstream file(filename.c_str()); if (!file.is_open()) { - std::cerr << "Failed to open file \"" << filename << "\"" << std::endl; + std::cerr << std::string("Failed to open file \"") << filename << std::string("\"") << std::endl; return false; } // Read file std::string line; + std::size_t lineNumber = 0; while (file.good() && std::getline(file, line)) { + ++lineNumber; + + if (!line.empty() && line[line.size() - 1] == '\r') + { + line = line.substr(0, line.size() - 1); + } + // Tokenize line (tab-delimeted) std::vector tokens; std::string token; @@ -49,7 +57,7 @@ bool ParameterDict::load(const std::string& filename) if (tokens.size() != 2) { - std::cerr << "Invalid line \"" << line << "\" in file \"" << filename << "\"" << std::endl; + std::cerr << std::string("Invalid line \"") << lineNumber << std::string("\" in file \"") << filename << std::string("\"") << std::endl; continue; } @@ -66,12 +74,12 @@ bool ParameterDict::save(const std::string& filename) std::ofstream file(filename.c_str()); if (!file.is_open()) { - std::cerr << "Failed to open file \"" << filename << "\"" << std::endl; + std::cerr << std::string("Failed to open file \"") << filename << std::string("\"") << std::endl; return false; } for (auto it = parameters.begin(); it != parameters.end(); ++it) - file << it->first << "\t" << it->second << std::endl; + file << it->first << std::string("\t") << it->second << std::endl; file.close(); diff --git a/src/states/loading-state.cpp b/src/states/loading-state.cpp index fe187a4..20ba4fa 100644 --- a/src/states/loading-state.cpp +++ b/src/states/loading-state.cpp @@ -33,59 +33,59 @@ void LoadingState::enter() { bool failure = false; - std::cout << "Loading controls... "; + std::cout << std::string("Loading controls... "); if (!application->loadControls()) { - std::cout << "failed" << std::endl; + std::cout << std::string("failed") << std::endl; failure = true; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } - std::cout << "Loading scene... "; + std::cout << std::string("Loading scene... "); if (!application->loadScene()) { - std::cout << "failed" << std::endl; + std::cout << std::string("failed") << std::endl; failure = true; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } - std::cout << "Loading models... "; + std::cout << std::string("Loading models... "); if (!application->loadModels()) { - std::cout << "failed" << std::endl; + std::cout << std::string("failed") << std::endl; failure = true; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } - std::cout << "Loading game... "; + std::cout << std::string("Loading game... "); if (!application->loadGame()) { - std::cout << "failed" << std::endl; + std::cout << std::string("failed") << std::endl; failure = true; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } - std::cout << "Loading UI... "; + std::cout << std::string("Loading UI... "); if (!application->loadUI()) { - std::cout << "failed" << std::endl; + std::cout << std::string("failed") << std::endl; failure = true; } else { - std::cout << "success" << std::endl; + std::cout << std::string("success") << std::endl; } if (failure) diff --git a/src/dpi-aware.manifest b/src/windows/antkeeper.manifest similarity index 100% rename from src/dpi-aware.manifest rename to src/windows/antkeeper.manifest