Browse Source

Fix some linux-windows compilation compatibility issues

master
C. J. Howard 6 years ago
parent
commit
df8405f4e8
Signed by: cjhoward GPG Key ID: 03E1FABA9C3EC195
13 changed files with 225 additions and 195 deletions
  1. +3
    -1
      .gitignore
  2. +40
    -21
      CMakeLists.txt
  3. +1
    -1
      lib/emergent
  4. +81
    -82
      src/application.cpp
  5. +21
    -21
      src/controls.cpp
  6. +5
    -5
      src/game/biome.cpp
  7. +9
    -9
      src/input.cpp
  8. +17
    -15
      src/material-loader.cpp
  9. +3
    -3
      src/model-loader.cpp
  10. +18
    -18
      src/render-passes.cpp
  11. +12
    -4
      src/settings.cpp
  12. +15
    -15
      src/states/loading-state.cpp
  13. +0
    -0
      src/windows/antkeeper.manifest

+ 3
- 1
.gitignore View File

@ -3,4 +3,6 @@ CMakeCache.txt
cmake_install.cmake
Makefile
src/configuration.hpp
.DS_Store
.DS_Store
*.swo
*.swp

+ 40
- 21
CMakeLists.txt View File

@ -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 "<CMAKE_RC_COMPILER> <SOURCE> <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)
include(CPack)

+ 1
- 1
lib/emergent

@ -1 +1 @@
Subproject commit c79c7f5a714472ae123a12400d462e59c05bd443
Subproject commit 16405a4181a39cff79b57b4c9c2389c31a136794

+ 81
- 82
src/application.cpp View File

@ -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<int>(resolution.x), static_cast<int>(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<int>(resolution.x), static_cast<int>(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<int>(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<int>(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<int>(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", &copyrightFontBasename);
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<int>(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<int>(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<int>(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<std::codecvt_utf8<char32_t>, 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<int>(resolution.x), static_cast<int>(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

+ 21
- 21
src/controls.cpp View File

@ -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;
}
}

+ 5
- 5
src/game/biome.cpp View File

@ -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;
}
}

+ 9
- 9
src/input.cpp View File

@ -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;
}

+ 17
- 15
src/material-loader.cpp View File

@ -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;
}

+ 3
- 3
src/model-loader.cpp View File

@ -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

+ 18
- 18
src/render-passes.cpp View File

@ -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;
}

+ 12
- 4
src/settings.cpp View File

@ -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<std::string> 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();

+ 15
- 15
src/states/loading-state.cpp View File

@ -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)

src/dpi-aware.manifest → src/windows/antkeeper.manifest View File


Loading…
Cancel
Save