Do some stuff

This commit is contained in:
Bailey Harrison 2022-09-03 05:56:51 +01:00
parent aaaf52a0ba
commit f0433f145c
18 changed files with 119 additions and 22 deletions

View File

@ -13,7 +13,7 @@
namespace components {
class DECLSPEC Camera : public Component {
class ENGINE_API Camera : public Component {
public:
Camera(Object* parent);

View File

@ -7,7 +7,7 @@ class Window;
class Input;
class ResourceManager;
class DECLSPEC Component {
class ENGINE_API Component {
public:

View File

@ -8,7 +8,7 @@
namespace components {
class DECLSPEC CustomComponent : public Component {
class ENGINE_API CustomComponent : public Component {
public:
CustomComponent(Object* parent);

View File

@ -14,7 +14,7 @@
namespace components {
class DECLSPEC Renderer : public Component {
class ENGINE_API Renderer : public Component {
public:
Renderer(Object*);

View File

@ -11,7 +11,7 @@
namespace components {
class DECLSPEC UI : public Component {
class ENGINE_API UI : public Component {
public:
UI(Object*);

View File

@ -14,7 +14,7 @@
namespace components {
class DECLSPEC Transform : public Component {
class ENGINE_API Transform : public Component {
// Scale, rotate (XYZ), translate

View File

@ -1,13 +1,13 @@
#pragma once
#ifndef DECLSPEC
#ifndef ENGINE_API
# ifdef _MSC_VER
# ifdef ENGINE_EXPORTS
# define DECLSPEC __declspec(dllexport)
# define ENGINE_API __declspec(dllexport)
# else
# define DECLSPEC __declspec(dllimport)
# define ENGINE_API __declspec(dllimport)
# endif
# else
# define DECLSPEC
# define ENGINE_API
# endif
#endif

View File

@ -19,7 +19,7 @@ enum class InputDevice : int {
};
// This class should be used to get platform/input-device independent input
class DECLSPEC Input {
class ENGINE_API Input {
public:

View File

@ -33,7 +33,7 @@ struct GameIO {
// This object lives until it is deleted by its parent(s) or finally when the "Scene" is destroyed.
// Therefore it is safe to return raw pointers
class DECLSPEC Object {
class ENGINE_API Object {
public:
Object(std::string name, Object* parent, SceneRoot& root, struct GameIO things);

View File

@ -9,7 +9,7 @@
// Doesn't own resources, only holds weak_ptrs
class DECLSPEC ResourceManager {
class ENGINE_API ResourceManager {
public:
ResourceManager();

View File

@ -12,7 +12,7 @@
namespace resources {
class DECLSPEC Font : public Resource {
class ENGINE_API Font : public Resource {
public:

View File

@ -22,7 +22,7 @@ struct Vertex {
namespace resources {
class DECLSPEC Mesh : public Resource {
class ENGINE_API Mesh : public Resource {
public:
Mesh(const std::vector<Vertex>& vertices);

View File

@ -5,7 +5,7 @@
#include <string>
#include <filesystem>
class DECLSPEC Resource {
class ENGINE_API Resource {
public:
Resource(const std::filesystem::path& resPath, const std::string& type);

View File

@ -13,7 +13,7 @@
namespace resources {
class DECLSPEC Shader : public Resource {
class ENGINE_API Shader : public Resource {
public:
Shader(const std::filesystem::path& resPath);

View File

@ -8,7 +8,7 @@
namespace resources {
class DECLSPEC Texture : public Resource {
class ENGINE_API Texture : public Resource {
private:

View File

@ -7,7 +7,7 @@
#include <filesystem>
// Holds everything you would expect to find in a game scene
class DECLSPEC SceneRoot : public Object {
class ENGINE_API SceneRoot : public Object {
public:
// create a new empty scene

View File

@ -14,9 +14,9 @@
#include <array>
#include <string>
DECLSPEC extern const uint64_t BILLION;
ENGINE_API extern const uint64_t BILLION;
class DECLSPEC Window {
class ENGINE_API Window {
public:
Window(const std::string& title);

97
renderer/CMakeLists.txt Normal file
View File

@ -0,0 +1,97 @@
cmake_minimum_required(VERSION 3.4)
# options
project(
engine_renderer
LANGUAGES CXX
VERSION "0.1.0"
)
add_library(${PROJECT_NAME} SHARED
src/renderer.cpp
# API
include/renderer.hpp
)
# compiling options:
target_compile_definitions(${PROJECT_NAME} PRIVATE DEFINITIONS "PROJECT_EXPORTS")
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W3)
target_compile_options(${PROJECT_NAME} PRIVATE /MP)
endif()
target_include_directories(${PROJECT_NAME} PUBLIC include)
target_include_directories(${PROJECT_NAME} PRIVATE src)
# Pass some project information into the source code
configure_file(config.h.in config.h)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
# libraries:
# MinGW library if using it
if (MINGW)
target_link_libraries(${PROJECT_NAME} PUBLIC mingw32)
endif()
# SDL2:
set(SDL2_DISABLE_INSTALL ON CACHE INTERNAL "" FORCE)
set(SDL_SHARED ON CACHE INTERNAL "" FORCE)
set(SDL_STATIC OFF CACHE INTERNAL "" FORCE)
set(SDL_TEST OFF CACHE INTERNAL "" FORCE)
set(BUILD_SHARED_LIBS ON)
add_subdirectory(dependencies/SDL)
target_include_directories(${PROJECT_NAME} PUBLIC dependencies/SDL/include)
target_link_libraries(${PROJECT_NAME} PUBLIC SDL2::SDL2)
target_link_libraries(${PROJECT_NAME} PUBLIC SDL2::SDL2main)
# GLM:
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(dependencies/glm)
target_include_directories(${PROJECT_NAME} PUBLIC dependencies/glm)
# GLAD:
set(GLAD_PROFILE "core" CACHE INTERNAL "" FORCE)
set(GLAD_API "gl=3.3" CACHE INTERNAL "" FORCE)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(GLAD_GENERATOR "c-debug" CACHE INTERNAL "" FORCE)
else()
set(GLAD_GENERATOR "c" CACHE INTERNAL "" FORCE)
endif()
set(GLAD_SPEC "gl" CACHE INTERNAL "" FORCE)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(dependencies/glad)
set_property(TARGET glad PROPERTY POSITION_INDEPENDENT_CODE ON)
target_link_libraries(${PROJECT_NAME} PUBLIC glad)
target_include_directories(${PROJECT_NAME} PUBLIC dependencies/glad/include)
# spdlog
set(SPDLOG_BUILD_SHARED ON CACHE INTERNAL "" FORCE)
set(BUILD_SHARED_LIBS ON)
add_subdirectory(dependencies/spdlog)
target_link_libraries(${PROJECT_NAME} PUBLIC spdlog)
target_include_directories(${PROJECT_NAME} PUBLIC dependencies/spdlog/include)
# freetype
set(FT_DISABLE_ZLIB TRUE CACHE INTERNAL "" FORCE)
set(FT_DISABLE_BZIP2 TRUE CACHE INTERNAL "" FORCE)
set(FT_DISABLE_PNG TRUE CACHE INTERNAL "" FORCE)
set(FT_DISABLE_HARFBUZZ TRUE CACHE INTERNAL "" FORCE)
set(FT_DISABLE_BROTLI TRUE CACHE INTERNAL "" FORCE)
set(BUILD_SHARED_LIBS ON)
add_subdirectory(dependencies/freetype)
target_link_libraries(${PROJECT_NAME} PRIVATE freetype)
target_include_directories(${PROJECT_NAME} PRIVATE dependencies/freetype/include)
# stb
target_include_directories(${PROJECT_NAME} PRIVATE dependencies/stb)