Browse Source

Fix Linux build and re-add DEBUG and NDEBUG compile definitions

master
C. J. Howard 5 years ago
parent
commit
1c555d2aea
Signed by: cjhoward GPG Key ID: 03E1FABA9C3EC195
3 changed files with 25 additions and 7 deletions
  1. +7
    -0
      CMakeLists.txt
  2. +2
    -0
      src/entity/systems/sound-system.cpp
  3. +16
    -7
      src/timestamp.cpp

+ 7
- 0
CMakeLists.txt View File

@ -42,6 +42,13 @@ set(EXECUTABLE_TARGET ${PROJECT_NAME}-executable)
add_executable(${EXECUTABLE_TARGET} ${SOURCE_FILES}) add_executable(${EXECUTABLE_TARGET} ${SOURCE_FILES})
set_target_properties(${EXECUTABLE_TARGET} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) set_target_properties(${EXECUTABLE_TARGET} PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
# Add compile definitions
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(${EXECUTABLE_TARGET} PRIVATE DEBUG)
else()
target_compile_definitions(${EXECUTABLE_TARGET} PRIVATE NDEBUG)
endif()
# Set link flags to show console window on debug builds and hide it on release builds # Set link flags to show console window on debug builds and hide it on release builds
if(MSVC) if(MSVC)
set_target_properties(${EXECUTABLE_TARGET} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE") set_target_properties(${EXECUTABLE_TARGET} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")

+ 2
- 0
src/entity/systems/sound-system.cpp View File

@ -53,6 +53,7 @@ SoundSystem::SoundSystem(ComponentManager* componentManager):
alGenBuffers((ALuint)1, &buffer); alGenBuffers((ALuint)1, &buffer);
/*
// Load wav file // Load wav file
{ {
const char* filename = "data/shutter.wav"; const char* filename = "data/shutter.wav";
@ -75,6 +76,7 @@ SoundSystem::SoundSystem(ComponentManager* componentManager):
alBufferData(buffer, format, sampleData, sampleDataSize, sampleRate); alBufferData(buffer, format, sampleData, sampleDataSize, sampleRate);
} }
*/
alSourcei(source, AL_BUFFER, buffer); alSourcei(source, AL_BUFFER, buffer);
//alSourcePlay(source); //alSourcePlay(source);

+ 16
- 7
src/timestamp.cpp View File

@ -28,12 +28,21 @@ std::string timestamp()
auto now = std::chrono::system_clock::now(); auto now = std::chrono::system_clock::now();
std::time_t tt = std::chrono::system_clock::to_time_t(now); std::time_t tt = std::chrono::system_clock::to_time_t(now);
std::size_t ms = (std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000).count(); std::size_t ms = (std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000).count();
struct std::tm timeinfo;
localtime_s(&timeinfo, &tt);
std::stringstream stream;
stream << std::put_time(&timeinfo, "%Y%m%d-%H%M%S-");
stream << std::setfill('0') << std::setw(3) << ms;
#if defined(_WIN32)
struct std::tm timeinfo;
localtime_s(&timeinfo, &tt);
std::stringstream stream;
stream << std::put_time(&timeinfo, "%Y%m%d-%H%M%S-");
stream << std::setfill('0') << std::setw(3) << ms;
#else
struct std::tm* timeinfo = localtime(&tt);
std::stringstream stream;
stream << std::put_time(timeinfo, "%Y%m%d-%H%M%S-");
stream << std::setfill('0') << std::setw(3) << ms;
#endif
return stream.str(); return stream.str();
}
}

Loading…
Cancel
Save