Skip to content

Commit

Permalink
Add glm folder to make it easier to build
Browse files Browse the repository at this point in the history
  • Loading branch information
Hopson97 committed Mar 11, 2021
1 parent 2ed7bab commit 77cac31
Show file tree
Hide file tree
Showing 395 changed files with 60,351 additions and 36 deletions.
125 changes: 100 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,110 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.10)

set(CMAKE_CXX_STANDARD 17)
#Set up project
project(mc-one-week VERSION 1.0)

#Enable debug symbols
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose debug or release" FORCE)
endif()
#Set executable
add_executable(mc-one-week
Source/Item/Material.cpp
Source/Item/ItemStack.cpp
Source/Application.cpp
Source/World/Event/PlayerDigEvent.cpp
Source/World/Block/BlockDatabase.cpp
Source/World/Block/BlockData.cpp
Source/World/Block/ChunkBlock.cpp
Source/World/Block/BlockTypes/BlockType.cpp
Source/World/World.cpp
Source/World/Generation/Biome/LightForest.cpp
Source/World/Generation/Biome/Biome.cpp
Source/World/Generation/Biome/DesertBiome.cpp
Source/World/Generation/Biome/GrasslandBiome.cpp
Source/World/Generation/Biome/TemperateForestBiome.cpp
Source/World/Generation/Biome/OceanBiome.cpp
Source/World/Generation/Structures/TreeGenerator.cpp
Source/World/Generation/Structures/StructureBuilder.cpp
Source/World/Generation/Terrain/SuperFlatGenerator.cpp
Source/World/Generation/Terrain/ClassicOverWorldGenerator.cpp
Source/World/Chunk/ChunkMesh.cpp
Source/World/Chunk/ChunkManager.cpp
Source/World/Chunk/Chunk.cpp
Source/World/Chunk/ChunkSection.cpp
Source/World/Chunk/ChunkMeshBuilder.cpp
Source/States/PlayingState.cpp
Source/Physics/AABB.cpp
Source/Player/Player.cpp
Source/Maths/Ray.cpp
Source/Maths/Frustum.cpp
Source/Maths/NoiseGenerator.cpp
Source/Maths/Vector2XZ.cpp
Source/Maths/Matrix.cpp
Source/Maths/GeneralMaths.cpp
Source/Camera.cpp
Source/GL/GLFunctions.cpp
Source/Context.cpp
Source/Texture/CubeTexture.cpp
Source/Texture/BasicTexture.cpp
Source/Texture/TextureAtlas.cpp
Source/Input/ToggleKey.cpp
Source/Input/Keyboard.cpp
Source/Main.cpp
Source/Controller.cpp
Source/Util/Random.cpp
Source/Util/FPSCounter.cpp
Source/Util/FileUtil.cpp
Source/Shaders/FloraShader.cpp
Source/Shaders/WaterShader.cpp
Source/Shaders/SkyboxShader.cpp
Source/Shaders/Shader.cpp
Source/Shaders/ChunkShader.cpp
Source/Shaders/BasicShader.cpp
Source/Shaders/ShaderLoader.cpp
Source/Renderer/RenderMaster.cpp
Source/Renderer/WaterRenderer.cpp
Source/Renderer/ChunkRenderer.cpp
Source/Renderer/SkyboxRenderer.cpp
Source/Renderer/SFMLRenderer.cpp
Source/Renderer/FloraRenderer.cpp
Source/Model.cpp
)

project(mc-one-week)
#Set module path
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})

#Add the files
file(GLOB_RECURSE SOURCES Source/*.cpp)
add_executable(mc-one-week ${SOURCES})
#Find libraries
find_package(Threads)
find_package(SFML REQUIRED audio network graphics window system)

#Add libraries
#SFML
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
find_package(SFML REQUIRED graphics network audio window system)
add_subdirectory(deps/glm)
add_subdirectory(deps/glad)

#glm
find_package(glm REQUIRED)
function(setup_target TARGET)
#Set C++17
target_compile_features(${TARGET} PUBLIC cxx_std_17)
set_target_properties(${TARGET} PROPERTIES CXX_EXTENSIONS OFF)

# glad
# https://github.com/aaronmjacobs/InitGL
set(GLAD_DIR "Source/glad")
add_library("glad" "${GLAD_DIR}/glad.c")
target_include_directories("glad" PRIVATE "${GLAD_DIR}")
target_include_directories(${PROJECT_NAME} PUBLIC ${GLM_INCLUDE_DIRS} PRIVATE "${GLAD_DIR}")
target_link_libraries(${PROJECT_NAME} "glad" "${CMAKE_DL_LIBS}")
#Set flags
if(MSVC)
target_compile_options(${TARGET} PRIVATE
/W4 /WX)
else()
target_compile_options(${TARGET} PRIVATE
-Wall -Wextra -pedantic)
endif()

target_include_directories(
${TARGET}
PRIVATE
deps
)
endfunction(setup_target)

find_package(Threads)
setup_target(mc-one-week)

target_link_libraries(mc-one-week Threads::Threads ${EXECUTABLE_NAME} ${SFML_LIBRARIES})
target_link_libraries(mc-one-week
glm
glad
Threads::Threads
${SFML_LIBRARIES}
${SFML_DEPENDENCIES}
${CMAKE_DL_LIBS}
)
3 changes: 2 additions & 1 deletion Source/Context.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Context.h"

#include "glad/glad.h"
#include <glad/glad.h>


unsigned int g_X;
unsigned int g_Y;
Expand Down
2 changes: 1 addition & 1 deletion Source/GL/GLFunctions.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef GLFUNCTIONS_H_INCLUDED
#define GLFUNCTIONS_H_INCLUDED

#include "../glad/glad.h"
#include <glad/glad.h>

namespace GL {
void drawElements(GLuint indicesCount) noexcept;
Expand Down
2 changes: 1 addition & 1 deletion Source/Mesh.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef MESH_H_INCLUDED
#define MESH_H_INCLUDED

#include "glad/glad.h"
#include <glad/glad.h>
#include <vector>

struct Mesh {
Expand Down
3 changes: 2 additions & 1 deletion Source/Renderer/SFMLRenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "SFMLRenderer.h"

#include "../glad/glad.h"
#include <glad/glad.h>


void SFMLRenderer::add(const sf::Drawable &drawable)
{
Expand Down
3 changes: 2 additions & 1 deletion Source/Shaders/ShaderLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#include "../Util/FileUtil.h"

#include "../glad/glad.h"
#include <glad/glad.h>

#include <stdexcept>

namespace {
Expand Down
2 changes: 1 addition & 1 deletion Source/Shaders/ShaderLoader.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SHADERLOADER_H_INCLUDED
#define SHADERLOADER_H_INCLUDED

#include "../glad/glad.h"
#include <glad/glad.h>
#include <string>

GLuint loadShaders(const std::string &vertexShader,
Expand Down
3 changes: 2 additions & 1 deletion Source/Texture/BasicTexture.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef TEXTURE_H_INCLUDED
#define TEXTURE_H_INCLUDED

#include "../glad/glad.h"
#include <glad/glad.h>

#include <SFML/Graphics.hpp>
#include <string>

Expand Down
3 changes: 2 additions & 1 deletion Source/Texture/CubeTexture.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef CUBETEXTURE_H_INCLUDED
#define CUBETEXTURE_H_INCLUDED

#include "../glad/glad.h"
#include <glad/glad.h>

#include <SFML/Graphics.hpp>
#include <array>
#include <string>
Expand Down
3 changes: 2 additions & 1 deletion Source/World/Chunk/ChunkMeshBuilder.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef CHUNKMESHBUILDER_H_INCLUDED
#define CHUNKMESHBUILDER_H_INCLUDED

#include "../../glad/glad.h"
#include <glad/glad.h>

#include <SFML/Graphics.hpp>
#include <vector>

Expand Down
4 changes: 2 additions & 2 deletions config.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
renderdistance 8
renderdistance 16
fullscreen 0
windowsize 1280 720
windowsize 1600 900
fov 105
3 changes: 3 additions & 0 deletions deps/glad/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_library(glad
glad.c
)
1 change: 1 addition & 0 deletions Source/glad/glad.c → deps/glad/glad.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <string.h>
#include "glad.h"


static void* get_proc(const char *namez);

#if defined(_WIN32) || defined(__CYGWIN__)
Expand Down
File renamed without changes.
70 changes: 70 additions & 0 deletions deps/glm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
file(GLOB ROOT_SOURCE *.cpp)
file(GLOB ROOT_INLINE *.inl)
file(GLOB ROOT_HEADER *.hpp)
file(GLOB ROOT_TEXT ../*.txt)
file(GLOB ROOT_MD ../*.md)
file(GLOB ROOT_NAT ../util/glm.natvis)

file(GLOB_RECURSE CORE_SOURCE ./detail/*.cpp)
file(GLOB_RECURSE CORE_INLINE ./detail/*.inl)
file(GLOB_RECURSE CORE_HEADER ./detail/*.hpp)

file(GLOB_RECURSE EXT_SOURCE ./ext/*.cpp)
file(GLOB_RECURSE EXT_INLINE ./ext/*.inl)
file(GLOB_RECURSE EXT_HEADER ./ext/*.hpp)

file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp)
file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl)
file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp)

file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp)
file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl)
file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp)

file(GLOB_RECURSE SIMD_SOURCE ./simd/*.cpp)
file(GLOB_RECURSE SIMD_INLINE ./simd/*.inl)
file(GLOB_RECURSE SIMD_HEADER ./simd/*.h)

source_group("Text Files" FILES ${ROOT_TEXT} ${ROOT_MD})
source_group("Core Files" FILES ${CORE_SOURCE})
source_group("Core Files" FILES ${CORE_INLINE})
source_group("Core Files" FILES ${CORE_HEADER})
source_group("EXT Files" FILES ${EXT_SOURCE})
source_group("EXT Files" FILES ${EXT_INLINE})
source_group("EXT Files" FILES ${EXT_HEADER})
source_group("GTC Files" FILES ${GTC_SOURCE})
source_group("GTC Files" FILES ${GTC_INLINE})
source_group("GTC Files" FILES ${GTC_HEADER})
source_group("GTX Files" FILES ${GTX_SOURCE})
source_group("GTX Files" FILES ${GTX_INLINE})
source_group("GTX Files" FILES ${GTX_HEADER})
source_group("SIMD Files" FILES ${SIMD_SOURCE})
source_group("SIMD Files" FILES ${SIMD_INLINE})
source_group("SIMD Files" FILES ${SIMD_HEADER})

add_library(glm INTERFACE)
target_include_directories(glm INTERFACE ../)

if(BUILD_STATIC_LIBS)
add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
target_link_libraries(glm_static PUBLIC glm)
add_library(glm::glm_static ALIAS glm_static)
endif()

if(BUILD_SHARED_LIBS)
add_library(glm_shared SHARED ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
target_link_libraries(glm_shared PUBLIC glm)
add_library(glm::glm_shared ALIAS glm_shared)
endif()
Loading

0 comments on commit 77cac31

Please sign in to comment.