Fix Windows x64 builds

master
Jordan Snelling 2019-10-31 01:14:17 +00:00
parent c6418540b3
commit 6c06d0ba8d
36 changed files with 12399 additions and 8689 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 3.12 FATAL_ERROR)
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD 17)
set (PROJECT_NAME "Zepha")
set (MAIN_EXEC_NAME "Zepha")
@ -7,32 +7,74 @@ set (TEST_EXEC_NAME "ZephaTest")
project (${PROJECT_NAME})
find_path(GLEW_HEADERS GL/glew.h)
find_path(GLFW_HEADERS GLFW/glfw3.h)
find_path(LUA_HEADERS lua.hpp)
find_path(ASSIMP_HEADERS assimp/Importer.hpp)
find_path(ENET_HEADERS enet/enet.h)
find_path(NOISE_HEADERS noise/noise.h)
find_path(GLM_HEADERS glm/glm.hpp)
find_path(PTHREAD_HEADERS pthread.h)
find_library(GLEW_LIB glew32)
find_library(GLFW_LIB glfw3dll)
find_library(LUA_LIB lua)
if (WIN32)
find_library(ASSIMP_LIB assimp)
# find_library(ASSIMP_LIB assimp-vc142-mt)
else()
find_library(ASSIMP_LIB assimp)
endif()
find_library(ENET_LIB enet)
find_library(NOISE_LIB noise-static)
find_library(NOISEUTIL_LIB noiseutils-static)
if (WIN32)
find_library(PTHREAD_LIB pthreadVC3)
else()
find_library(PTHREAD_LIB pthread)
endif()
include_directories(
# Include Header Only Libraries
lib/header/catch2/include # Catch2 unit testing library.
lib/header/gzip/include # GZip Compression header library.
lib/header/glm/include # OpenGL Mathematics Library.
${GLM_HEADERS} # OpenGL Mathematics Library.
lib/header/sol2/include # Sol2 Lua Parser library.
lib/header/cute_files/include # Cute file traversal header library.
lib/header/stb_image/include # STB Image processor header library.
lib/header/json/include # JSON header library.
# Include Static Library Headers
lib/static/glew/include # GLEW headers.
lib/static/glfw/include # GLFW headers.
lib/static/assimp/include # Assimp headers.
lib/static/lua/install/include # Lua headers.
lib/static/enet/include # ENet headers.
lib/static/noise/include # Noise headers.
# lib/static/glew/include # GLEW headers.
# lib/static/glfw/include # GLFW headers.
# lib/static/assimp/include # Assimp headers.
# lib/static/lua/install/include # Lua headers.
# lib/static/enet/include # ENet headers.
# lib/static/noise/include # Noise headers.
${GLEW_HEADERS}
${LUA_HEADERS}
${ASSIMP_HEADERS}
${ENET_HEADERS}
${NOISE_HEADERS}
${PTHREAD_HEADERS}
)
add_subdirectory (src)
add_executable (${MAIN_EXEC_NAME} src/Main.cpp)
target_link_libraries (${MAIN_EXEC_NAME} Zepha_Core)
target_include_directories(${MAIN_EXEC_NAME} PRIVATE ${GLFW_HEADERS})
# Load Libraries
include(${CMAKE_CURRENT_SOURCE_DIR}/LoadLibs.cmake)
# Fix Win32 networking
if(WIN32)
target_link_libraries(${MAIN_EXEC_NAME} winmm ws2_32)
endif()
# Enable Safeties
target_compile_definitions(${MAIN_EXEC_NAME} PUBLIC SOL_ALL_SAFETIES_ON)

View File

@ -1,3 +1,6 @@
# Enet
target_link_libraries(${MAIN_EXEC_NAME} ${ENET_LIB})
# Find and Link OpenGL
find_package (OpenGL REQUIRED)
target_link_libraries(${MAIN_EXEC_NAME} ${OPENGL_gl_LIBRARY})
@ -7,12 +10,15 @@ set (GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set (GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set (GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory (lib/static/glfw)
# Find GLFW
if (WIN32)
target_link_libraries (${MAIN_EXEC_NAME} glfw3dll)
else()
target_link_libraries (${MAIN_EXEC_NAME} glfw)
include_directories(lib/static/glfw/src)
endif()
# Link Glew
target_link_libraries(${MAIN_EXEC_NAME} ${CMAKE_SOURCE_DIR}/lib/static/glew/libGLEW.a)
target_link_libraries(${MAIN_EXEC_NAME} ${GLEW_LIB})
# Build and Link Assimp
set(BUILD_SHARED_LIBS OFF)
@ -24,21 +30,17 @@ set(ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT OFF)
set(ASSIMP_BUILD_B3D_IMPORTER ON)
set(ASSIMP_BUILD_X3D_IMPORTER ON) # Doesn't compile if not defined
add_subdirectory(lib/static/assimp)
target_compile_options(assimp PRIVATE -w)
# add_subdirectory(lib/static/assimp)
target_link_libraries(${MAIN_EXEC_NAME} assimp)
# Link Lua 5.3.5
target_link_libraries(${MAIN_EXEC_NAME} ${CMAKE_SOURCE_DIR}/lib/static/lua/install/lib/liblua.a)
# Enet
target_link_libraries(${MAIN_EXEC_NAME} ${CMAKE_SOURCE_DIR}/lib/static/enet/.libs/libenet.a)
target_link_libraries(${MAIN_EXEC_NAME} ${LUA_LIB})
# Link Noise
target_link_libraries(${MAIN_EXEC_NAME} ${CMAKE_SOURCE_DIR}/lib/static/noise/build/src/libnoise.a)
target_link_libraries(${MAIN_EXEC_NAME} ${NOISE_LIB})
# Link PThread Dynamically
target_link_libraries (${MAIN_EXEC_NAME} pthread)
target_link_libraries (${MAIN_EXEC_NAME} ${PTHREAD_LIB})
# Link Z Dynamically
target_link_libraries (${MAIN_EXEC_NAME} z)

25
WindowsBuilding.md Normal file
View File

@ -0,0 +1,25 @@
# Idiot's Guide to building Zepha on Windows:
## ~~Your Amazon Wish List~~ Prequesites:
### Step 0:
Download [Zepha](https://github.com/Aurailus/Zeus_cpp/)
### Step 1:
Install [VCPKG](https://github.com/microsoft/vcpkg), (like to your desktop, as it's just a folder)
### Step 2:
Install [CMake](https://cmake.org/download/)
### Step 3:
Install [Visual Studio Community](https://visualstudio.microsoft.com/vs/community/) (Clang and GCC not supported!)
### Step 4:
Install VCPKG dependancies:
In powershell, in the `vcpkg` folder, execute:
`.\vcpkg install gzip glm sol2 stb-image glew glfw assimp libnoise enet lua pthread --triplet x64-windows`
## ~~Hiring Cowboy Builders~~ The Pre-Building Process:
Load up CMake, and find the downloaded `Zeus_cpp` repo, and create another folder called `Zeus_build`.
With CMake, click `Browse Source`, select the `Zeus_cpp` folder as mentioned earlier as this contains the information to correctly build the game. With that step done, click `Browse Build`, and select the folder `Zeus_build`. With these folders correctly chosen, click configure, which should bring up a wizard like window.
Once in the window for configuring the build, set `optional platform for generator` to `x64` under the dropdown menu. After that, select the radio button `Specify toolchain for crosscompiling`, which will allow you to select the `vcpkg` libraries and header files required by `Zeus_cpp`. With that out of the way, click `next`
Navigate to the toolchain file which is located in the `vcpkg` folder, which is found here: `vcpkg\scripts\buildsystems\vcpkg.cmake` with the toolchain file completed, click `Finish`
## ~~Reading Some Books~~ Getting Libraries Fixed:

View File

@ -131,7 +131,12 @@ void cf_do_unit_tests();
#if !defined _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#ifdef _WIN32
#define NOMINMAX
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#endif
struct cf_file_t
{

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
#pragma once
#include <c++/5/string>
#include <string>
class ItemDef {
public:

View File

@ -9,6 +9,8 @@
#include <glm/vec3.hpp>
#include "../../util/TransPos.h"
typedef unsigned int uint;
struct MapGenJob {
std::array<uint, 4096> blocks;

View File

@ -8,6 +8,8 @@
#include <vector>
#include "MeshPart.h"
#include "../../util/Dir.h"
#include <algorithm>
#include <limits>
struct BlockModel {
std::array<std::vector<MeshPart>, 7> parts;
@ -32,7 +34,7 @@ struct BlockModel {
{glm::vec3{0, 1, 1}, glm::vec3{}, glm::vec2{1, 0}, glm::vec2{}},
{glm::vec3{0, 1, 0}, glm::vec3{}, glm::vec2{0, 0}, glm::vec2{}}};
indices = {0, 1, 2, 2, 3, 0};
MeshPart leftMeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[std::min(static_cast<int>(textureRefs.size() - 1), 2)]);
MeshPart leftMeshPart = MeshPart::MeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[(std::min)(static_cast<int>(textureRefs.size() - 1), 2)]);
blockModel.parts[static_cast<int>(Dir::LEFT)].push_back(leftMeshPart);
//Right Face
@ -42,7 +44,7 @@ struct BlockModel {
{glm::vec3{1, 0, 0}, glm::vec3{}, glm::vec2{0, 1}, glm::vec2{}},
{glm::vec3{1, 1, 0}, glm::vec3{}, glm::vec2{0, 0}, glm::vec2{}}};
indices = {0, 1, 2, 2, 3, 0};
MeshPart rightMeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[std::min(static_cast<int>(textureRefs.size() - 1), 3)]);
MeshPart rightMeshPart = MeshPart::MeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[(std::min)(static_cast<int>(textureRefs.size() - 1), 3)]);
blockModel.parts[static_cast<int>(Dir::RIGHT)].push_back(rightMeshPart);
//Top Face
@ -52,7 +54,7 @@ struct BlockModel {
{glm::vec3{1, 1, 1}, glm::vec3{}, glm::vec2{1, 1}, glm::vec2{}},
{glm::vec3{1, 1, 0}, glm::vec3{}, glm::vec2{1, 0}, glm::vec2{}}};
indices = {0, 1, 2, 2, 3, 0};
MeshPart topMeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[std::min(static_cast<int>(textureRefs.size() - 1), 0)]);
MeshPart topMeshPart = MeshPart::MeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[(std::min)(static_cast<int>(textureRefs.size() - 1), 0)]);
blockModel.parts[static_cast<int>(Dir::TOP)].push_back(topMeshPart);
//Bottom Face
@ -62,7 +64,7 @@ struct BlockModel {
{glm::vec3{1, 0, 1}, glm::vec3{}, glm::vec2{1, 1}, glm::vec2{}},
{glm::vec3{0, 0, 1}, glm::vec3{}, glm::vec2{0, 1}, glm::vec2{}}};
indices = {0, 1, 2, 2, 3, 0};
MeshPart bottomMeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[std::min(static_cast<int>(textureRefs.size() - 1), 1)]);
MeshPart bottomMeshPart = MeshPart::MeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[(std::min)(static_cast<int>(textureRefs.size() - 1), 1)]);
blockModel.parts[static_cast<int>(Dir::BOTTOM)].push_back(bottomMeshPart);
//Front Face
@ -72,7 +74,7 @@ struct BlockModel {
{glm::vec3{1, 1, 1}, glm::vec3{}, glm::vec2{1, 0}, glm::vec2{}},
{glm::vec3{0, 1, 1}, glm::vec3{}, glm::vec2{0, 0}, glm::vec2{}}};
indices = {0, 1, 2, 2, 3, 0};
MeshPart frontMeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[std::min(static_cast<int>(textureRefs.size() - 1), 4)]);
MeshPart frontMeshPart = MeshPart::MeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[(std::min)(static_cast<int>(textureRefs.size() - 1), 4)]);
blockModel.parts[static_cast<int>(Dir::FRONT)].push_back(frontMeshPart);
//Back Face
@ -82,7 +84,7 @@ struct BlockModel {
{glm::vec3{1, 1, 0}, glm::vec3{}, glm::vec2{1, 0}, glm::vec2{}},
{glm::vec3{1, 0, 0}, glm::vec3{}, glm::vec2{1, 1}, glm::vec2{}}};
indices = {0, 1, 2, 2, 3, 0};
MeshPart backMeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[std::min(static_cast<int>(textureRefs.size() - 1), 5)]);
MeshPart backMeshPart = MeshPart::MeshPart(vertices, indices, (textureRefs.empty()) ? nullptr : textureRefs[(std::min)(static_cast<int>(textureRefs.size() - 1), 5)]);
blockModel.parts[static_cast<int>(Dir::BACK)].push_back(backMeshPart);
return blockModel;

View File

@ -6,6 +6,8 @@
#include <stb_image/stb_image.h>
#include <stb_image/stb_image_write.h>
typedef unsigned int uint;
//Height is optional and defaults to 0
TextureAtlas::TextureAtlas(unsigned int width, unsigned int height) :
pageWidth(width),

View File

@ -56,6 +56,8 @@ void Client::loop() {
}
Client::~Client() {
if (serverPID != 0) kill(serverPID, SIGKILL);
#ifndef _WIN32
if (serverPID != 0) kill(serverPID, SIGKILL);
#endif
sceneManager.cleanupScene();
}

View File

@ -3,6 +3,7 @@
//
#include "AnimationState.h"
typedef unsigned int uint;
AnimationState::AnimationState(Model &source) {
const ModelAnimation& animation = source.getAnimation();

View File

@ -4,6 +4,7 @@
//
#include "Model.h"
typedef unsigned int uint;
void Model::fromMesh(uptr<EntityMesh> mesh) {
meshes.clear();

View File

@ -10,6 +10,7 @@
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <glm/glm.hpp>
#include <glm/ext.hpp>
#include "ModelBone.h"

View File

@ -7,6 +7,7 @@
#include <string>
#include <vector>
#include "AnimChannel.h"
typedef unsigned int uint;
class ModelAnimation {
public:

View File

@ -1,9 +1,9 @@
#include <cmath>
//
// Created by aurailus on 15/05/19.
//
#include <cmath>
#include <random>
#include "ParticleEntity.h"
ParticleEntity::ParticleEntity(glm::vec3 pos, BlockDef &block) {
@ -41,7 +41,7 @@ ParticleEntity::ParticleEntity(glm::vec3 pos, BlockDef &block) {
0, 2, 1, 2, 0, 3,
};
auto dir = glm::radians(static_cast<float>(random() % 360));
auto dir = glm::radians(static_cast<float>(rand() % 360));
float xDir = sinf(dir);
float zDir = cosf(dir);

View File

@ -4,6 +4,7 @@
#pragma once
#include <glm/glm.hpp>
#include "../Entity.h"
#include "../../../def/item/BlockDef.h"

View File

@ -34,8 +34,8 @@ void Frustum::update(glm::vec3 &pos, glm::vec3 &look, glm::vec3 &up, glm::vec3 &
planes[BOTTOM].setPoints(nbl,nbr,fbr);
planes[LEFT].setPoints(ntl,nbl,fbl);
planes[RIGHT].setPoints(nbr,ntr,fbr);
planes[NEAR].setPoints(ntl,ntr,nbr);
planes[FAR].setPoints(ftr,ftl,fbl);
planes[FNEAR].setPoints(ntl,ntr,nbr);
planes[FFAR].setPoints(ftr,ftl,fbl);
}
int Frustum::pointInFrustum(glm::vec3 &p) {

View File

@ -16,8 +16,8 @@ private:
BOTTOM,
LEFT,
RIGHT,
NEAR,
FAR
FNEAR,
FFAR
};
public:

View File

@ -5,7 +5,7 @@
#pragma once
#include <GL/gl.h>
#include <GL/glew.h>
#include <glm/mat4x4.hpp>
struct GuiUniforms {

View File

@ -5,6 +5,7 @@
#pragma once
#include "Shader.h"
typedef unsigned int uint;
class LightingShader : public Shader {
public:

View File

@ -3,6 +3,7 @@
//
#include "SSAOShader.h"
typedef unsigned int uint;
SSAOShader::SSAOShader(glm::vec2 windowSize, float bufferScale, uint kernelCount) : Shader(),
windowSize(windowSize),

View File

@ -6,6 +6,7 @@
#include "Shader.h"
#include <random>
typedef unsigned int uint;
class SSAOShader : public Shader {
public:

View File

@ -14,6 +14,8 @@
#include <glm/gtc/type_ptr.hpp>
#include "../../../util/Log.h"
typedef unsigned int uint;
class Shader {
public:
Shader();

View File

@ -3,6 +3,7 @@
//
#include <iostream>
#include <algorithm>
#include "InventoryList.h"
InventoryList::InventoryList(unsigned short size, unsigned short width) :

View File

@ -6,7 +6,7 @@
#include <iostream>
#include <unordered_set>
#include <bits/unordered_map.h>
#include <unordered_map>
#include <thread>
#include <mutex>
#include <glm/vec3.hpp>

View File

@ -15,6 +15,7 @@ WorldInterpolationStream::WorldInterpolationStream(unsigned int seed, LocalDefs&
bool WorldInterpolationStream::pushBack(Packet p) {
queuedTasks.push_back(std::move(p));
return true;
}
std::vector<std::shared_ptr<BlockChunk>> WorldInterpolationStream::update() {

View File

@ -102,7 +102,7 @@ void MeshGenerator::addFaces(const glm::vec3 &offset, const vector<MeshPart> &me
case ShaderMod::ROTATE_Z:
case ShaderMod::SWAY_ATTACHED:
case ShaderMod::SWAY_FULL_BLOCK: {
modData = {Util::packFloat((offset - 8.f) / 8), mp.modValue, 0};
modData = {Util::packFloat((offset - 8.f) / 8.f), mp.modValue, 0};
break;
}
}

View File

@ -13,6 +13,7 @@
#include <vector>
#include <cstdio>
#include "../../../../def/item/MeshPart.h"
#include "../MeshDetails.h"
#include "../../../../def/item/BlockModelVertex.h"
#include "../../../../world/chunk/BlockChunk.h"
@ -29,7 +30,7 @@ public:
std::array<NoiseSample, 3>& blockOffsets);
private:
BlockDef& getBlockAt(const glm::vec3 &pos);
void addFaces(const glm::vec3 &offset, const vector<MeshPart> &meshParts);
void addFaces(const glm::vec3 &offset, const std::vector<MeshPart> &meshParts);
unsigned int indOffset = 0;

View File

@ -7,6 +7,8 @@
#include <GLFW/glfw3.h>
#include <iostream>
typedef unsigned short ushort;
LuaInputManager::LuaInputManager() {
for (bool& key : keysDown) key = false;
for (bool& key : keysPressed) key = false;

View File

@ -6,6 +6,8 @@
#include <sol2/sol.hpp>
typedef unsigned short ushort;
class LuaInputManager {
public:
LuaInputManager();

View File

@ -4,6 +4,8 @@
#include "ServerDimension.h"
typedef unsigned int uint;
void ServerDimension::setChunk(sptr<BlockChunk> chunk) {
blockChunks.insert({chunk->pos, chunk});
}

View File

@ -8,6 +8,8 @@
#include <glm/vec3.hpp>
#include "../../world/chunk/BlockChunk.h"
typedef unsigned int uint;
class ServerDimension {
public:
ServerDimension() = default;

View File

@ -12,6 +12,8 @@
#include <iostream>
#include "Log.h"
typedef unsigned short ushort;
namespace Util {
struct EnumClassHash {
template <typename T>

View File

@ -21,7 +21,7 @@ void NetHandler::initServer(unsigned short port, short max_clients) {
if (enet_initialize() != 0) {
fprintf(stderr, "[FATAL] Failed to Initialize ENet.\n");
state = NetState::ERROR;
state = NetState::ENET_ERROR;
return;
}
@ -33,7 +33,7 @@ void NetHandler::initServer(unsigned short port, short max_clients) {
if (host == nullptr) {
fprintf(stderr, "[FATAL] Failed to create ENet host.\n");
state = NetState::ERROR;
state = NetState::ENET_ERROR;
return;
}
@ -45,7 +45,7 @@ void NetHandler::initClient(Address hostAddress, int attempts, int timeout) {
if (enet_initialize() != 0) {
fprintf(stderr, "[FATAL] Failed to Initialize ENet.\n");
state = NetState::ERROR;
state = NetState::ENET_ERROR;
return;
}
@ -53,7 +53,7 @@ void NetHandler::initClient(Address hostAddress, int attempts, int timeout) {
if (host == nullptr) {
fprintf(stderr, "[FATAL] Failed to create ENet client.\n");
state = NetState::ERROR;
state = NetState::ENET_ERROR;
return;
}
@ -67,7 +67,7 @@ void NetHandler::initClient(Address hostAddress, int attempts, int timeout) {
if (peer == nullptr) {
fprintf(stderr, "[FATAL] Failed to find ENet peer.\n");
state = NetState::ERROR;
state = NetState::ENET_ERROR;
return;
}

View File

@ -8,7 +8,7 @@
enum class NetState {
UNINITIALIZED,
FAILED_CONNECT,
ERROR,
ENET_ERROR,
CLIENT,
HOST,
CLOSED

View File

@ -14,6 +14,8 @@
#include "../../game/scene/world/graph/MeshChunk.h"
#include "../../util/Log.h"
typedef unsigned int uint;
class BlockChunk {
public:
BlockChunk() = default;