1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 06:52:34 +02:00

Merge pull request #607 from madebr/cmake

cmake updates
This commit is contained in:
Daniel Evans 2018-08-28 10:05:32 +01:00 committed by GitHub
commit aeece2683e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 50 additions and 40 deletions

View File

@ -2,6 +2,7 @@ add_library(rw_interface INTERFACE)
add_library(openrw::interface ALIAS rw_interface)
# target_compile_features(rw_interface INTERFACE cxx_std_14) is not supported by CMake 3.2
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@ -38,14 +39,25 @@ if(MINGW)
)
endif()
if(WIN32)
# Required minimum version of Windows = Vista
set(RW_NTDDI_VISTA 0x06000000)
set(RW_WINVER 0x0600)
target_compile_definitions(rw_interface
INTERFACE
"NTDDI_VERSION=${RW_NTDDI_VISTA}"
"WINVER=${RW_WINVER}"
"_WIN32_WINNT=${RW_WINVER}"
)
endif()
target_compile_definitions(rw_interface
INTERFACE
"$<$<CONFIG:Debug>:RW_DEBUG=1>"
"$<$<CONFIG:Debug>:RW_DEBUG>"
"GLM_FORCE_RADIANS"
"GLM_ENABLE_EXPERIMENTAL"
"RW_VERBOSE_DEBUG_MESSAGES=$<BOOL:${RW_VERBOSE_DEBUG_MESSAGES}>"
"RENDER_PROFILER=0"
"RW_PROFILER=$<BOOL:${ENABLE_PROFILING}>"
"$<$<BOOL:${RW_VERBOSE_DEBUG_MESSAGES}>:RW_VERBOSE_DEBUG_MESSAGES>"
"$<$<BOOL:${ENABLE_PROFILING}>:RW_PROFILER>"
)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")

View File

@ -57,7 +57,7 @@ FileContentsInfo FileIndex::openFileRaw(const std::string &filePath) const {
throw std::runtime_error("Unable to open file: " + filePath);
}
#if RW_DEBUG
#ifdef RW_DEBUG
if (indexData->type != IndexedDataType::FILE) {
RW_MESSAGE("Reading raw data from archive \"" << filePath << "\"");
}

View File

@ -1,6 +1,6 @@
#include <functional>
#if RW_DEBUG
#ifdef RW_DEBUG
std::function<void()> _rw_abort_cb[2] = {nullptr, nullptr};
#if defined(RW_WINDOWS)

View File

@ -1,7 +1,7 @@
#ifndef _LIBRW_DEBUG_HPP_
#define _LIBRW_DEBUG_HPP_
#if RW_DEBUG
#ifdef RW_DEBUG
#include <cstdlib>
#include <functional>
@ -39,7 +39,7 @@ void WinBreak();
#define _RW_FAILED_CHECK_ACTION()
#endif
#if RW_DEBUG && RW_VERBOSE_DEBUG_MESSAGES
#if defined(RW_DEBUG) && defined(RW_VERBOSE_DEBUG_MESSAGES)
#include <iostream>
#define RW_MESSAGE(msg) \
std::cout << __FILE__ << ":" << __LINE__ << ": " << msg << std::endl

View File

@ -72,7 +72,7 @@ bool SoundManager::initializeOpenAL() {
}
bool SoundManager::initializeAVCodec() {
#if RW_DEBUG && RW_VERBOSE_DEBUG_MESSAGES
#if defined(RW_DEBUG) && defined(RW_VERBOSE_DEBUG_MESSAGES)
av_log_set_level(AV_LOG_WARNING);
#else
av_log_set_level(AV_LOG_ERROR);

View File

@ -1,7 +1,7 @@
#ifndef _RWENGINE_PROFILER_HPP_
#define _RWENGINE_PROFILER_HPP_
#if RW_PROFILER
#ifdef RW_PROFILER
#include <chrono>
#include <cstdint>
#include <stack>

View File

@ -604,7 +604,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(ped.modelName)
READ_VALUE(ped.align)
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "Player Health: " << ped.info.health << " ("
<< ped.info.armour << ")" << std::endl;
std::cout << "Player model: " << ped.modelName << std::endl;
@ -639,7 +639,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(garages[i]);
}
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "Garages: " << garageData.garageCount << std::endl;
std::cout << "Bombs Free: " << garageData.freeBombs << std::endl;
std::cout << "Sprays Free: " << garageData.freeResprays << std::endl;
@ -674,7 +674,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(veh.modelId)
READ_VALUE(veh.unknown2)
READ_VALUE(veh.state)
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << " v " << veh.modelId << " " << veh.state.position.x << " "
<< veh.state.position.y << " " << veh.state.position.z
<< std::endl;
@ -687,7 +687,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(veh.modelId)
READ_VALUE(veh.unknown2)
READ_VALUE(veh.state)
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << " b " << veh.modelId << " " << veh.state.position.x << " "
<< veh.state.position.y << " " << veh.state.position.z
<< std::endl;
@ -736,7 +736,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
inst->setRotation(glm::normalize(static_cast<glm::quat>(m)));
}
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "Objects " << objectCount << std::endl;
for (size_t o = 0; o < objectCount; ++o) {
auto& obj = objects[o];
@ -786,7 +786,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(crane)
}
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "Cranes: " << craneData.numCranes << std::endl;
for (size_t c = 0; c < craneData.numCranes; ++c) {
Block6Crane& crane = craneData.cranes[c];
@ -806,7 +806,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
Block7Data pickupData;
READ_VALUE(pickupData);
#if RW_DEBUG
#ifdef RW_DEBUG
for (const auto &pickup : pickupData.pickups) {
if (pickup.type == 0) continue;
std::cout << " " << uint16_t(pickup.type) << " " << pickup.position.x << " "
@ -827,7 +827,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(payphone)
}
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "Payphones: " << payphoneData.numPayphones << std::endl;
for (const auto& payphone : payphones) {
std::cout << " " << uint16_t(payphone.state) << " " << payphone.position.x
@ -847,7 +847,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
Block9Data restartData;
READ_VALUE(restartData);
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "Hospitals: " << restartData.numHospitals
<< " police: " << restartData.numPolice << std::endl;
for (int s = 0; s < restartData.numHospitals; ++s) {
@ -873,7 +873,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
Block10Data radarData;
READ_VALUE(radarData);
#if RW_DEBUG
#ifdef RW_DEBUG
for (const auto &blip : radarData.blips) {
if (blip.type == 0) continue;
std::cout << " " << blip.position.x << " " << blip.position.y << " "
@ -934,7 +934,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(zoneData.numMapZones);
READ_VALUE(zoneData.numAudioZones);
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "zones: " << zoneData.numNavZones << " "
<< zoneData.numZoneInfos << " " << zoneData.numMapZones << " "
<< zoneData.numAudioZones << std::endl;
@ -1004,7 +1004,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
Block12Data gangData;
READ_VALUE(gangData);
#if RW_DEBUG
#ifdef RW_DEBUG
for (const auto &gang : gangData.gangs) {
std::cout << " " << gang.carModelId << " " << gang.weaponPrimary << " "
<< gang.weaponSecondary << std::endl;
@ -1028,7 +1028,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(carGenerators[g])
}
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "Car generators: " << carGeneratorData.generatorCount
<< std::endl;
for (size_t g = 0; g < carGeneratorData.generatorCount; ++g) {
@ -1051,7 +1051,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(particles[p])
}
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "particles: " << particleCount << std::endl;
#endif
@ -1071,7 +1071,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(audioObjects[a])
}
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "Audio Objects: " << audioCount << std::endl;
#endif
@ -1094,7 +1094,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(state.playerInfo.singlePayerHealthcare)
READ_VALUE(state.playerInfo.unknown5)
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "Player money: " << state.playerInfo.money << " ("
<< state.playerInfo.displayedMoney << ")" << std::endl;
#endif
@ -1157,7 +1157,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
READ_VALUE(state.gameStats.peopleKilledSinceLastBustedOrWasted);
READ_VALUE(state.gameStats.lastMissionGXT);
#if RW_DEBUG
#ifdef RW_DEBUG
std::cout << "Player kills: " << state.gameStats.playerKills << std::endl;
std::cout << "longest flight " << state.gameStats.longestDodoFlight
<< std::endl;
@ -1172,7 +1172,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
Block18Data streamingData;
READ_VALUE(streamingData);
#if RW_DEBUG && 0 // No idea what the data in the section means yet
#if defined(RW_DEBUG) && 0 // No idea what the data in the section means yet
static const size_t streamSize = sqrt(200 * 8);
for (int x = 0; x < streamSize; ++x) {
for (int y = 0; y < streamSize; ++y) {
@ -1198,7 +1198,7 @@ bool SaveGame::loadGame(GameState& state, const std::string& file) {
Block19Data pedTypeData;
READ_VALUE(pedTypeData);
#if RW_DEBUG
#ifdef RW_DEBUG
for (const auto &type : pedTypeData.types) {
printf("%08x: %f %f %f %f %f threat %08x avoid %08x\n", type.bitstring_,
static_cast<double>(type.unknown2),

View File

@ -128,7 +128,7 @@ void OpenGLRenderer::useDrawBuffer(DrawBuffer* dbuff) {
glBindVertexArray(dbuff->getVAOName());
currentDbuff = dbuff;
bufferCounter++;
#if RW_PROFILER
#ifdef RW_PROFILER
if (currentDebugDepth > 0) {
profileInfo[currentDebugDepth - 1].buffers++;
}
@ -145,7 +145,7 @@ void OpenGLRenderer::useTexture(GLuint unit, GLuint tex) {
glBindTexture(GL_TEXTURE_2D, tex);
currentTextures[unit] = tex;
textureCounter++;
#if RW_PROFILER
#ifdef RW_PROFILER
if (currentDebugDepth > 0) {
profileInfo[currentDebugDepth - 1].textures++;
}
@ -291,7 +291,7 @@ void OpenGLRenderer::setDrawState(const glm::mat4& model, DrawBuffer* draw,
uploadUBO(UBOObject, objectData);
drawCounter++;
#if RW_PROFILER
#ifdef RW_PROFILER
if (currentDebugDepth > 0) {
profileInfo[currentDebugDepth - 1].draws++;
profileInfo[currentDebugDepth - 1].primitives += p.count;
@ -421,7 +421,7 @@ void OpenGLRenderer::uploadUBOEntry(Buffer &buffer, const void *data, size_t siz
}
void OpenGLRenderer::pushDebugGroup(const std::string& title) {
#if RW_PROFILER
#ifdef RW_PROFILER
if (ogl_ext_KHR_debug) {
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, title.c_str());
ProfileInfo& prof = profileInfo[currentDebugDepth];
@ -440,7 +440,7 @@ void OpenGLRenderer::pushDebugGroup(const std::string& title) {
}
const Renderer::ProfileInfo& OpenGLRenderer::popDebugGroup() {
#if RW_PROFILER
#ifdef RW_PROFILER
if (ogl_ext_KHR_debug) {
glPopDebugGroup();
currentDebugDepth--;

View File

@ -403,7 +403,7 @@ private:
template <class T>
void uploadUBO(Buffer& buffer, const T& data) {
uploadUBOEntry(buffer, &data, sizeof(T));
#if RW_PROFILER
#ifdef RW_PROFILER
if (currentDebugDepth > 0) {
profileInfo[currentDebugDepth - 1].uploads++;
}

View File

@ -148,10 +148,6 @@ TextRenderer::TextRenderer(GameRenderer* renderer) : renderer(renderer) {
}
void TextRenderer::setFontTexture(font_t font, const std::string& textureName) {
if (font >= FONTS_COUNT) {
RW_ERROR("Illegal font: " << font);
return;
}
auto ftexture = renderer->getData()->findSlotTexture("fonts", textureName);
const glm::u32vec2 textureSize = ftexture->getSize();
glm::u8vec2 glyphOffset{textureSize.x / 16, textureSize.x / 16};
@ -169,6 +165,8 @@ void TextRenderer::setFontTexture(font_t font, const std::string& textureName) {
case FONT_ARIAL:
glyphWidths = &fontWidthsArial;
break;
default:
throw std::runtime_error("Illegal font");
}
std::uint8_t monoWidth = 0;
if (font == FONT_PAGER) {

View File

@ -849,7 +849,7 @@ void RWGame::renderDebugObjects(float time, ViewCamera& camera) {
}
void RWGame::renderProfile() {
#if RW_PROFILER
#ifdef RW_PROFILER
auto& frame = perf::Profiler::get().getFrame();
constexpr float upperlimit = 30000.f;
constexpr float lineHeight = 15.f;