├── configuration └── delta.conf ├── dependencies ├── CMakeLists.txt └── submodules │ └── CMakeLists.txt ├── assets ├── chicken.png ├── icosphere.dia └── icosphere.ysce ├── .gitmodules ├── .gitignore ├── include ├── delta.h └── template_application.h ├── src ├── main.cpp └── template_application.cpp ├── CMakeLists.txt └── README.md /configuration/delta.conf: -------------------------------------------------------------------------------- 1 | /delta 2 | /assets -------------------------------------------------------------------------------- /dependencies/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(submodules) 2 | -------------------------------------------------------------------------------- /assets/chicken.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ange-yaghi/delta-template/HEAD/assets/chicken.png -------------------------------------------------------------------------------- /assets/icosphere.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ange-yaghi/delta-template/HEAD/assets/icosphere.dia -------------------------------------------------------------------------------- /assets/icosphere.ysce: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ange-yaghi/delta-template/HEAD/assets/icosphere.ysce -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dependencies/submodules/delta-studio"] 2 | path = dependencies/submodules/delta-studio 3 | url = https://github.com/ange-yaghi/delta-studio 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore build files 2 | build/ 3 | 4 | # Ignore user's workspace 5 | workspace/ 6 | 7 | # clangd cache and code completion files 8 | .cache 9 | compile_commands.json 10 | -------------------------------------------------------------------------------- /include/delta.h: -------------------------------------------------------------------------------- 1 | #ifndef DELTA_TEMPLATE_DELTA_INCLUDES_H 2 | #define DELTA_TEMPLATE_DELTA_INCLUDES_H 3 | 4 | #include 5 | #include 6 | 7 | #endif /* DELTA_TEMPLATE_DELTA_INCLUDES_H */ 8 | -------------------------------------------------------------------------------- /dependencies/submodules/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(delta-studio) 2 | 3 | set_property(TARGET delta-basic PROPERTY FOLDER "delta") 4 | set_property(TARGET delta-basic-demo PROPERTY FOLDER "delta") 5 | set_property(TARGET delta-core PROPERTY FOLDER "delta") 6 | set_property(TARGET delta-physics PROPERTY FOLDER "delta") 7 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/template_application.h" 2 | 3 | #include 4 | 5 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { 6 | (void)nCmdShow; 7 | (void)lpCmdLine; 8 | (void)hPrevInstance; 9 | 10 | TemplateApplication app; 11 | app.Initialize((void *)&hInstance, ysContextObject::DeviceAPI::DirectX11); 12 | app.Run(); 13 | app.Destroy(); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | # Enable group projects in folders 4 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) 5 | set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "cmake") 6 | 7 | project(delta-template) 8 | 9 | set(CMAKE_CXX_STANDARD 11) 10 | 11 | add_executable(delta-template WIN32 12 | # Source files 13 | src/main.cpp 14 | src/template_application.cpp 15 | 16 | # Include files 17 | include/delta.h 18 | include/template_application.h 19 | ) 20 | 21 | target_link_libraries(delta-template 22 | delta-basic) 23 | 24 | target_include_directories(delta-template 25 | PUBLIC dependencies/submodules) 26 | 27 | add_subdirectory(dependencies) 28 | -------------------------------------------------------------------------------- /include/template_application.h: -------------------------------------------------------------------------------- 1 | #ifndef DELTA_TEMPLATE_TEMPLATE_APPLICATION_H 2 | #define DELTA_TEMPLATE_TEMPLATE_APPLICATION_H 3 | 4 | #include "delta.h" 5 | 6 | class TemplateApplication { 7 | public: 8 | TemplateApplication(); 9 | ~TemplateApplication(); 10 | 11 | void Initialize(void *instance, ysContextObject::DeviceAPI api); 12 | void Run(); 13 | void Destroy(); 14 | 15 | protected: 16 | void Process(); 17 | void Render(); 18 | 19 | dbasic::ShaderSet m_shaderSet; 20 | dbasic::DefaultShaders m_shaders; 21 | 22 | dbasic::DeltaEngine m_engine; 23 | dbasic::AssetManager m_assetManager; 24 | 25 | ysTexture *m_demoTexture; 26 | float m_currentRotation; 27 | float m_temperature; 28 | }; 29 | 30 | #endif /* DELTA_TEMPLATE_TEMPLATE_APPLICATION_H */ 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Delta Template Project 2 | 3 | This is a basic template project used to create an application that uses the [Delta Studio](https://github.com/ange-yaghi/delta-studio) game engine. 4 | 5 | ## Steps to Clone and Build 6 | 7 | **Note: this project currently only builds on Windows!** 8 | 9 | ### Step 1 - Clone the repository 10 | ```git clone --recurse-submodules https://github.com/ange-yaghi/delta-template``` 11 | 12 | ### Step 2 - Install CMake 13 | Install the latest version of CMake [here](https://cmake.org/) if it's not already installed. 14 | 15 | ### Step 3 - Install Dependencies 16 | You will need to install the following dependencies and CMake will need to be able to locate them (ie. they need to be listed on your PATH): 17 | 18 | 1. SDL2 19 | 2. SDL2_image 20 | 3. Boost (make sure to build the optional dependencies) 21 | 22 | ### Step 4 - Build and Run 23 | From the root directory of the project, run the following commands: 24 | 25 | ``` 26 | mkdir build 27 | cd build 28 | cmake .. 29 | cmake --build . 30 | ``` 31 | 32 | If these steps are successful, a Visual Studio solution will be generated in ```build/Debug```. You can open this project with Visual Studio and then run the ```delta-template``` project. If you encounter an error telling you that you're missing DLLs, you will have to copy those DLLs to your EXE's directory. 33 | -------------------------------------------------------------------------------- /src/template_application.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/template_application.h" 2 | 3 | TemplateApplication::TemplateApplication() { 4 | m_demoTexture = nullptr; 5 | m_currentRotation = 0.0f; 6 | m_temperature = 0.0f; 7 | } 8 | 9 | TemplateApplication::~TemplateApplication() { 10 | /* void */ 11 | } 12 | 13 | void TemplateApplication::Initialize(void *instance, ysContextObject::DeviceAPI api) { 14 | dbasic::Path modulePath = dbasic::GetModulePath(); 15 | dbasic::Path confPath = modulePath.Append("delta.conf"); 16 | 17 | std::string enginePath = "../dependencies/submodules/delta-studio/engines/basic"; 18 | std::string assetPath = "../assets"; 19 | if (confPath.Exists()) { 20 | std::fstream confFile(confPath.ToString(), std::ios::in); 21 | 22 | std::getline(confFile, enginePath); 23 | std::getline(confFile, assetPath); 24 | enginePath = modulePath.Append(enginePath).ToString(); 25 | assetPath = modulePath.Append(assetPath).ToString(); 26 | 27 | confFile.close(); 28 | } 29 | 30 | m_engine.GetConsole()->SetDefaultFontDirectory(enginePath + "/fonts/"); 31 | 32 | const std::string shaderPath = enginePath + "/shaders/"; 33 | 34 | dbasic::DeltaEngine::GameEngineSettings settings; 35 | settings.API = api; 36 | settings.DepthBuffer = true; 37 | settings.Instance = instance; 38 | settings.ShaderDirectory = shaderPath.c_str(); 39 | settings.WindowTitle = "Delta Template Application"; 40 | settings.WindowPositionX = 0; 41 | settings.WindowPositionY = 0; 42 | settings.WindowStyle = ysWindow::WindowStyle::Windowed; 43 | 44 | m_engine.CreateGameWindow(settings); 45 | 46 | m_engine.InitializeShaderSet(&m_shaderSet); 47 | m_engine.InitializeDefaultShaders(&m_shaders, &m_shaderSet); 48 | m_engine.InitializeConsoleShaders(&m_shaderSet); 49 | m_engine.SetShaderSet(&m_shaderSet); 50 | 51 | m_shaders.SetClearColor(ysColor::srgbiToLinear(0x34, 0x98, 0xdb)); 52 | 53 | m_assetManager.SetEngine(&m_engine); 54 | 55 | m_assetManager.LoadTexture((assetPath + "/chicken.png").c_str(), "Chicken"); 56 | m_demoTexture = m_assetManager.GetTexture("Chicken")->GetTexture(); 57 | 58 | m_assetManager.CompileInterchangeFile((assetPath + "/icosphere").c_str(), 1.0f, true); 59 | m_assetManager.LoadSceneFile((assetPath + "/icosphere").c_str(), true); 60 | 61 | m_shaders.SetCameraMode(dbasic::DefaultShaders::CameraMode::Target); 62 | } 63 | 64 | void TemplateApplication::Process() { 65 | if (m_engine.IsKeyDown(ysKey::Code::Space)) { 66 | m_currentRotation += m_engine.GetFrameLength(); 67 | } 68 | 69 | if (m_engine.IsKeyDown(ysKey::Code::Up)) { 70 | m_temperature += m_engine.GetFrameLength() * 0.5f; 71 | } 72 | else if (m_engine.IsKeyDown(ysKey::Code::Down)) { 73 | m_temperature -= m_engine.GetFrameLength() * 0.5f; 74 | } 75 | 76 | if (m_temperature < 0.0f) m_temperature = 0.0f; 77 | if (m_temperature > 1.0f) m_temperature = 1.0f; 78 | } 79 | 80 | void TemplateApplication::Render() { 81 | const int screenWidth = m_engine.GetGameWindow()->GetGameWidth(); 82 | const int screenHeight = m_engine.GetGameWindow()->GetGameHeight(); 83 | 84 | m_shaders.SetScreenDimensions((float)screenWidth, (float)screenHeight); 85 | m_shaders.CalculateCamera(); 86 | 87 | m_shaders.SetCameraPosition(ysMath::LoadVector(4.0f, 4.0f, 2.0f)); 88 | m_shaders.SetCameraUp(ysMath::Constants::ZAxis); 89 | 90 | m_shaders.ResetLights(); 91 | m_shaders.SetAmbientLight(ysMath::GetVector4(ysColor::srgbiToLinear(0x34, 0x98, 0xdb))); 92 | 93 | dbasic::Light light; 94 | light.Active = 1; 95 | light.Attenuation0 = 0.0f; 96 | light.Attenuation1 = 0.0f; 97 | light.Color = ysVector4(0.85f, 0.85f, 0.8f, 1.0f); 98 | light.Direction = ysVector4(0.0f, 0.0f, 0.0f, 0.0f); 99 | light.FalloffEnabled = 0; 100 | light.Position = ysVector4(10.0f, 10.0f, 10.0f); 101 | m_shaders.AddLight(light); 102 | 103 | dbasic::Light light2; 104 | light2.Active = 1; 105 | light2.Attenuation0 = -1.0f; 106 | light2.Attenuation1 = -1.0f; 107 | light2.Color = ysVector4(0.3f, 0.3f, 0.5f, 1.0f); 108 | light2.Direction = ysVector4(0.0f, 0.0f, 0.0f, 0.0f); 109 | light2.FalloffEnabled = 0; 110 | light2.Position = ysVector4(-10.0f, 10.0f, 10.0f); 111 | m_shaders.AddLight(light2); 112 | 113 | dbasic::Light glow; 114 | glow.Active = 1; 115 | glow.Attenuation0 = 0.0f; 116 | glow.Attenuation1 = 0.0f; 117 | glow.Color = ysVector4(5.0f * m_temperature, 0.0f, 0.0f, 1.0f); 118 | glow.Direction = ysVector4(0.0f, 0.0f, 0.0f, 0.0f); 119 | glow.FalloffEnabled = 1; 120 | glow.Position = ysVector4(0.0f, 0.0f, 0.0f); 121 | m_shaders.AddLight(glow); 122 | 123 | const ysMatrix rotationTurntable = ysMath::RotationTransform(ysMath::Constants::ZAxis, m_currentRotation); 124 | 125 | m_shaders.ResetBrdfParameters(); 126 | m_shaders.SetMetallic(0.8f); 127 | m_shaders.SetIncidentSpecular(0.8f); 128 | m_shaders.SetSpecularRoughness(0.7f); 129 | m_shaders.SetSpecularMix(1.0f); 130 | m_shaders.SetDiffuseMix(1.0f); 131 | m_shaders.SetEmission(ysMath::Mul(ysColor::srgbiToLinear(0xff, 0x0, 0x0), ysMath::LoadScalar(m_temperature))); 132 | m_shaders.SetBaseColor(ysColor::srgbiToLinear(0x34, 0x49, 0x5e)); 133 | m_shaders.SetColorReplace(true); 134 | m_shaders.SetObjectTransform(ysMath::MatMult(ysMath::TranslationTransform(ysMath::LoadVector(0.0f, 0.0f, 0.0f)), rotationTurntable)); 135 | m_engine.DrawModel(m_shaders.GetRegularFlags(), m_assetManager.GetModelAsset("Icosphere")); 136 | 137 | m_shaders.ResetBrdfParameters(); 138 | m_shaders.SetMetallic(0.0f); 139 | m_shaders.SetIncidentSpecular(0.0f); 140 | m_shaders.SetSpecularRoughness(0.8f); 141 | m_shaders.SetSpecularMix(0.1f); 142 | m_shaders.SetDiffuseMix(1.0f); 143 | m_shaders.SetColorReplace(true); 144 | m_shaders.SetBaseColor(ysColor::srgbiToLinear(0xbd, 0xc3, 0xc7)); 145 | m_shaders.SetObjectTransform(ysMath::MatMult(ysMath::TranslationTransform(ysMath::LoadVector(0.0f, 0.0f, 0.0f)), rotationTurntable)); 146 | m_shaders.SetObjectTransform(ysMath::MatMult(ysMath::TranslationTransform(ysMath::LoadVector(0.0f, 0.0f, -1.0f)), rotationTurntable)); 147 | m_engine.DrawModel(m_shaders.GetRegularFlags(), m_assetManager.GetModelAsset("Floor")); 148 | } 149 | 150 | void TemplateApplication::Run() { 151 | while (m_engine.IsOpen()) { 152 | m_engine.StartFrame(); 153 | 154 | Process(); 155 | Render(); 156 | 157 | m_engine.EndFrame(); 158 | } 159 | } 160 | 161 | void TemplateApplication::Destroy() { 162 | m_shaderSet.Destroy(); 163 | 164 | m_assetManager.Destroy(); 165 | m_engine.Destroy(); 166 | } 167 | --------------------------------------------------------------------------------