├── .github └── workflows │ └── cmake.yml ├── .gitmodules ├── .pre-commit-config.yaml ├── CMakeLists.txt ├── Jenkinsfile ├── LICENSE ├── README.md ├── RcEditor ├── Assets │ ├── Config │ │ └── imgui.ini │ ├── Fonts │ │ └── FiraSans │ │ │ ├── FiraSans-Black.ttf │ │ │ ├── FiraSans-BlackItalic.ttf │ │ │ ├── FiraSans-Bold.ttf │ │ │ ├── FiraSans-BoldItalic.ttf │ │ │ ├── FiraSans-ExtraBold.ttf │ │ │ ├── FiraSans-ExtraBoldItalic.ttf │ │ │ ├── FiraSans-ExtraLight.ttf │ │ │ ├── FiraSans-ExtraLightItalic.ttf │ │ │ ├── FiraSans-Italic.ttf │ │ │ ├── FiraSans-Light.ttf │ │ │ ├── FiraSans-LightItalic.ttf │ │ │ ├── FiraSans-Medium.ttf │ │ │ ├── FiraSans-MediumItalic.ttf │ │ │ ├── FiraSans-Regular.ttf │ │ │ ├── FiraSans-SemiBold.ttf │ │ │ ├── FiraSans-SemiBoldItalic.ttf │ │ │ ├── FiraSans-Thin.ttf │ │ │ ├── FiraSans-ThinItalic.ttf │ │ │ └── OFL.txt │ ├── Game │ │ └── Textures │ │ │ ├── CC_City_Exterior_A2.png │ │ │ ├── CC_City_Exterior_B.png │ │ │ └── TILESET-LICENCE.txt │ ├── Icons │ │ ├── ContentBrowser │ │ │ ├── DirectoryIcon.png │ │ │ └── FileIcon.png │ │ └── Menu │ │ │ ├── playicon.png │ │ │ ├── simplay.png │ │ │ ├── simstop.png │ │ │ └── stopicon.png │ ├── Shaders │ │ ├── CircleCombined.glsl │ │ ├── MeshCombined.glsl │ │ ├── Metal │ │ │ ├── TextureFragment.metal │ │ │ └── TextureVertex.metal │ │ ├── SPIRV │ │ │ ├── Fragment.spv │ │ │ ├── TextureShader.spv │ │ │ └── Vertex.spv │ │ ├── TextureCombined.glsl │ │ └── Vulkan │ │ │ ├── TextureFragment.frag │ │ │ └── TextureVertex.vert │ └── textures │ │ ├── Default.jpg │ │ ├── Texture.png │ │ └── Tiles.png ├── CMakeLists.txt ├── media │ ├── AppImage.icns │ ├── AppImage.ico │ └── AppImage.png └── src │ ├── EditorLayer.cpp │ ├── EditorLayer.h │ ├── Panels │ ├── ContentBrowserPanel.cpp │ ├── ContentBrowserPanel.h │ ├── SceneHierarchyPanel.cpp │ └── SceneHierarchyPanel.h │ ├── RcEditorApp.cpp │ ├── ViewPanel.cpp │ └── ViewPanel.h ├── RcEngine ├── CMakeLists.txt ├── external │ ├── RcNetwork │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ └── src │ │ │ ├── lib.rs │ │ │ ├── steam │ │ │ └── mod.rs │ │ │ └── util │ │ │ ├── client.rs │ │ │ ├── logger.rs │ │ │ ├── mod.rs │ │ │ └── server.rs │ ├── entt │ │ ├── LICENSE │ │ └── include │ │ │ └── entt.hpp │ └── glad │ │ ├── CMakeLists.txt │ │ ├── include │ │ ├── KHR │ │ │ └── khrplatform.h │ │ └── glad │ │ │ └── glad.h │ │ └── src │ │ └── glad.c ├── macros.cmake ├── sndfile.cmake └── src │ ├── Platform │ ├── Mac │ │ ├── MacInput.cpp │ │ ├── MacInput.h │ │ ├── MacUtils.mm │ │ ├── MacWindow.cpp │ │ ├── MacWindow.h │ │ └── processordetection.cpp │ ├── MacUtils.h │ ├── Metal │ │ ├── MetalBuffer.h │ │ ├── MetalBuffer.mm │ │ ├── MetalImplementation.h │ │ ├── MetalResource.h │ │ ├── MetalShader.cpp │ │ ├── MetalShader.h │ │ └── metal-cpp │ │ │ ├── Foundation │ │ │ ├── Foundation.hpp │ │ │ ├── NSArray.hpp │ │ │ ├── NSAutoreleasePool.hpp │ │ │ ├── NSBundle.hpp │ │ │ ├── NSData.hpp │ │ │ ├── NSDate.hpp │ │ │ ├── NSDefines.hpp │ │ │ ├── NSDictionary.hpp │ │ │ ├── NSEnumerator.hpp │ │ │ ├── NSError.hpp │ │ │ ├── NSLock.hpp │ │ │ ├── NSNotification.hpp │ │ │ ├── NSNumber.hpp │ │ │ ├── NSObjCRuntime.hpp │ │ │ ├── NSObject.hpp │ │ │ ├── NSPrivate.hpp │ │ │ ├── NSProcessInfo.hpp │ │ │ ├── NSRange.hpp │ │ │ ├── NSString.hpp │ │ │ ├── NSTypes.hpp │ │ │ └── NSURL.hpp │ │ │ ├── LICENSE.txt │ │ │ └── Metal │ │ │ ├── MTLAccelerationStructure.hpp │ │ │ ├── MTLAccelerationStructureCommandEncoder.hpp │ │ │ ├── MTLAccelerationStructureTypes.hpp │ │ │ ├── MTLArgument.hpp │ │ │ ├── MTLArgumentEncoder.hpp │ │ │ ├── MTLBinaryArchive.hpp │ │ │ ├── MTLBlitCommandEncoder.hpp │ │ │ ├── MTLBlitPass.hpp │ │ │ ├── MTLBuffer.hpp │ │ │ ├── MTLCaptureManager.hpp │ │ │ ├── MTLCaptureScope.hpp │ │ │ ├── MTLCommandBuffer.hpp │ │ │ ├── MTLCommandEncoder.hpp │ │ │ ├── MTLCommandQueue.hpp │ │ │ ├── MTLComputeCommandEncoder.hpp │ │ │ ├── MTLComputePass.hpp │ │ │ ├── MTLComputePipeline.hpp │ │ │ ├── MTLCounters.hpp │ │ │ ├── MTLDefines.hpp │ │ │ ├── MTLDepthStencil.hpp │ │ │ ├── MTLDevice.hpp │ │ │ ├── MTLDrawable.hpp │ │ │ ├── MTLDynamicLibrary.hpp │ │ │ ├── MTLEvent.hpp │ │ │ ├── MTLFence.hpp │ │ │ ├── MTLFunctionConstantValues.hpp │ │ │ ├── MTLFunctionDescriptor.hpp │ │ │ ├── MTLFunctionHandle.hpp │ │ │ ├── MTLFunctionLog.hpp │ │ │ ├── MTLFunctionStitching.hpp │ │ │ ├── MTLHeaderBridge.hpp │ │ │ ├── MTLHeap.hpp │ │ │ ├── MTLIndirectCommandBuffer.hpp │ │ │ ├── MTLIndirectCommandEncoder.hpp │ │ │ ├── MTLIntersectionFunctionTable.hpp │ │ │ ├── MTLLibrary.hpp │ │ │ ├── MTLLinkedFunctions.hpp │ │ │ ├── MTLParallelRenderCommandEncoder.hpp │ │ │ ├── MTLPipeline.hpp │ │ │ ├── MTLPixelFormat.hpp │ │ │ ├── MTLPrivate.hpp │ │ │ ├── MTLRasterizationRate.hpp │ │ │ ├── MTLRenderCommandEncoder.hpp │ │ │ ├── MTLRenderPass.hpp │ │ │ ├── MTLRenderPipeline.hpp │ │ │ ├── MTLResource.hpp │ │ │ ├── MTLResourceStateCommandEncoder.hpp │ │ │ ├── MTLResourceStatePass.hpp │ │ │ ├── MTLSampler.hpp │ │ │ ├── MTLStageInputOutputDescriptor.hpp │ │ │ ├── MTLTexture.hpp │ │ │ ├── MTLTypes.hpp │ │ │ ├── MTLVertexDescriptor.hpp │ │ │ ├── MTLVisibleFunctionTable.hpp │ │ │ └── Metal.hpp │ ├── OpenGL │ │ ├── OpenGLBuffer.cpp │ │ ├── OpenGLBuffer.h │ │ ├── OpenGLContext.cpp │ │ ├── OpenGLContext.h │ │ ├── OpenGLFrameBuffer.cpp │ │ ├── OpenGLFrameBuffer.h │ │ ├── OpenGLRenderAPI.cpp │ │ ├── OpenGLRenderAPI.h │ │ ├── OpenGLShader.cpp │ │ ├── OpenGLShader.h │ │ ├── OpenGLTexture.cpp │ │ ├── OpenGLTexture.h │ │ ├── OpenGLUniformBuffer.cpp │ │ ├── OpenGLUniformBuffer.h │ │ ├── OpenGLUtils.cpp │ │ ├── OpenGLUtils.h │ │ ├── OpenGLVertexArray.cpp │ │ └── OpenGLVertexArray.h │ ├── Vulkan │ │ ├── VKBuffer.cpp │ │ ├── VKBuffer.h │ │ ├── VKTexture.cpp │ │ ├── VKTexture.h │ │ ├── VKUniformBuffer.cpp │ │ ├── VKUniformBuffer.h │ │ ├── VKUtils.cpp │ │ └── VKUtils.h │ ├── Windows │ │ ├── WindowsWindow.cpp │ │ ├── WindowsWindow.h │ │ └── processordetection.cpp │ └── processordetection.h │ ├── RcEngine.h │ ├── RcEngine │ ├── Core │ │ ├── Application.cpp │ │ ├── Application.h │ │ ├── Assert.h │ │ ├── Core.h │ │ ├── EntryPoint.h │ │ ├── Input.h │ │ ├── Layer.cpp │ │ ├── Layer.h │ │ ├── LayerStack.cpp │ │ ├── LayerStack.h │ │ ├── Log.cpp │ │ ├── Log.h │ │ ├── MouseButtonCodes.h │ │ ├── Timestep.h │ │ ├── UUID.cpp │ │ ├── UUID.h │ │ ├── Window.cpp │ │ ├── Window.h │ │ └── keycodes.h │ ├── Debug │ │ └── Instrumentor.h │ ├── Editor │ │ ├── EditorConsole │ │ │ └── EditorConsoleSink.h │ │ └── EditorConsolePanel.h │ ├── Events │ │ ├── ApplicationEvent.h │ │ ├── Event.h │ │ ├── KeyEvent.h │ │ └── MouseEvent.h │ ├── ImGui │ │ ├── ImGuiBuild.cpp │ │ ├── ImGuiLayer.cpp │ │ └── ImGuiLayer.h │ ├── Lua │ │ ├── luastate.cpp │ │ ├── luastate.h │ │ ├── luautil.cpp │ │ └── luautil.h │ ├── Math │ │ ├── Math.cpp │ │ └── Math.h │ ├── Network │ │ └── Network.h │ ├── Renderer │ │ ├── Buffer.cpp │ │ ├── Buffer.h │ │ ├── Camera.h │ │ ├── EditorCamera.cpp │ │ ├── EditorCamera.h │ │ ├── FrameBuffer.cpp │ │ ├── FrameBuffer.h │ │ ├── GraphicsContext.cpp │ │ ├── GraphicsContext.h │ │ ├── IsoCameraController.cpp │ │ ├── IsoCameraController.h │ │ ├── MeshLoader.cpp │ │ ├── MeshLoader.h │ │ ├── OrthoCamera.cpp │ │ ├── OrthoCamera.h │ │ ├── OrthoCameraController.cpp │ │ ├── OrthoCameraController.h │ │ ├── ProjectionCamera.cpp │ │ ├── ProjectionCamera.h │ │ ├── RenderAPI.cpp │ │ ├── RenderAPI.h │ │ ├── RenderCommand.cpp │ │ ├── RenderCommand.h │ │ ├── Renderer.cpp │ │ ├── Renderer.h │ │ ├── Renderer2D.cpp │ │ ├── Renderer2D.h │ │ ├── Renderer3D.cpp │ │ ├── Renderer3D.h │ │ ├── Shader.cpp │ │ ├── Shader.h │ │ ├── SubTexture2D.cpp │ │ ├── SubTexture2D.h │ │ ├── Texture.cpp │ │ ├── Texture.h │ │ ├── UniformBuffer.cpp │ │ ├── UniformBuffer.h │ │ ├── VertexArray.cpp │ │ └── VertexArray.h │ ├── Scene │ │ ├── Component.h │ │ ├── Entity.cpp │ │ ├── Entity.h │ │ ├── Scene.cpp │ │ ├── Scene.h │ │ ├── SceneCamera.cpp │ │ ├── SceneCamera.h │ │ ├── SceneSerializer.cpp │ │ ├── SceneSerializer.h │ │ └── ScriptableEntity.h │ ├── Sound │ │ ├── SoundBuffer.cpp │ │ ├── SoundBuffer.h │ │ ├── SoundDevice.cpp │ │ └── SoundDevice.h │ └── Utils │ │ └── PlatformUtils.h │ ├── rcpch.cpp │ └── rcpch.h ├── RcGame ├── Assets │ ├── Fonts │ │ └── FiraSans │ │ │ ├── FiraSans-Black.ttf │ │ │ ├── FiraSans-BlackItalic.ttf │ │ │ ├── FiraSans-Bold.ttf │ │ │ ├── FiraSans-BoldItalic.ttf │ │ │ ├── FiraSans-ExtraBold.ttf │ │ │ ├── FiraSans-ExtraBoldItalic.ttf │ │ │ ├── FiraSans-ExtraLight.ttf │ │ │ ├── FiraSans-ExtraLightItalic.ttf │ │ │ ├── FiraSans-Italic.ttf │ │ │ ├── FiraSans-Light.ttf │ │ │ ├── FiraSans-LightItalic.ttf │ │ │ ├── FiraSans-Medium.ttf │ │ │ ├── FiraSans-MediumItalic.ttf │ │ │ ├── FiraSans-Regular.ttf │ │ │ ├── FiraSans-SemiBold.ttf │ │ │ ├── FiraSans-SemiBoldItalic.ttf │ │ │ ├── FiraSans-Thin.ttf │ │ │ ├── FiraSans-ThinItalic.ttf │ │ │ └── OFL.txt │ ├── Game │ │ └── Textures │ │ │ ├── CC_City_Exterior_A2.png │ │ │ ├── CC_City_Exterior_B.png │ │ │ └── TILESET-LICENCE.txt │ ├── Shaders │ │ ├── FlatColor.glsl │ │ ├── FlatColorFrag.glsl │ │ ├── FlatColorShader.glsl │ │ ├── FragShader.glsl │ │ ├── TextureCombined.glsl │ │ ├── TextureShader.glsl │ │ ├── TextureShaderFrag.glsl │ │ └── VertShader.glsl │ └── textures │ │ ├── Default.jpg │ │ └── Tiles.png ├── CMakeLists.txt ├── ParticleSystem.cpp ├── ParticleSystem.h ├── RcApp.cpp ├── RcGame2D.cpp ├── RcGame2D.h └── media │ ├── AppImage.icns │ ├── AppImage.ico │ └── AppImage.png ├── cmake ├── FindFLAC.cmake ├── FindOgg.cmake ├── FindOpus.cmake └── FindVorbis.cmake └── scripts ├── generate-VSproj.bat ├── generate-cmake.sh ├── generate-xcode.sh └── jenkins └── jenkins-cmake.sh /.github/workflows/cmake.yml: -------------------------------------------------------------------------------- 1 | name: CMake 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | 9 | env: 10 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 11 | BUILD_TYPE: Release 12 | 13 | jobs: 14 | build: 15 | # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. 16 | # You can convert this to a matrix build if you need cross-platform coverage. 17 | # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 18 | runs-on: self-hosted 19 | 20 | steps: 21 | - uses: actions/checkout@v3 22 | with: 23 | submodules: recursive 24 | 25 | - name: Brew packages 26 | run: brew install lua@5.1 && brew install molten-vk && brew install openal-soft && brew install pkg-config && brew install glslang && brew install openal-soft && brew install libsndfile 27 | - name: Install Vulkan SDK 28 | uses: humbletim/install-vulkan-sdk@v1.1.1 29 | with: 30 | version: latest 31 | cache: true 32 | - name: Debug GitHub Workspace 33 | run: echo ${{github.workspace}} 34 | - name: Configure CMake 35 | # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. 36 | # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type 37 | run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} 38 | 39 | - name: Build 40 | # Build your program with the given configuration 41 | run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} 42 | 43 | - name: Saving Artifacts 44 | uses: actions/upload-artifact@v3 45 | with: 46 | name: cmake build 47 | path: ${{github.workspace}}/build 48 | 49 | 50 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "RcEngine/external/GLFW"] 2 | path = RcEngine/external/GLFW 3 | url = https://github.com/glfw/glfw.git 4 | branch = 3.3-stable 5 | [submodule "RcEngine/external/imgui"] 6 | path = RcEngine/external/imgui 7 | url = https://github.com/triscuitcircuit/imgui.git 8 | branch = docking 9 | [submodule "RcEngine/external/spdlog"] 10 | path = RcEngine/external/spdlog 11 | url = https://github.com/gabime/spdlog.git 12 | branch = v1.x 13 | [submodule "RcEngine/external/glm"] 14 | path = RcEngine/external/glm 15 | url = https://github.com/g-truc/glm.git 16 | [submodule "RcEngine/external/GL"] 17 | path = RcEngine/external/GL 18 | url = https://github.com/nigels-com/glew.git 19 | [submodule "RcEngine/external/corrosion"] 20 | path = RcEngine/external/corrosion 21 | url = https://github.com/AndrewGaspar/corrosion.git 22 | [submodule "RcEngine/external/SOIL2"] 23 | path = RcEngine/external/SOIL2 24 | url = https://github.com/triscuitcircuit/SOIL2 25 | [submodule "RcEngine/external/yaml-cpp"] 26 | path = RcEngine/external/yaml-cpp 27 | url = https://github.com/jbeder/yaml-cpp 28 | [submodule "RcEngine/external/imguizmo"] 29 | path = RcEngine/external/imguizmo 30 | url = https://github.com/triscuitcircuit/ImGuizmo 31 | [submodule "RcEngine/external/box2d"] 32 | path = RcEngine/external/box2d 33 | url = https://github.com/triscuitcircuit/box2d 34 | [submodule "RcEngine/external/sol2"] 35 | path = RcEngine/external/sol2 36 | url = https://github.com/triscuitcircuit/sol2 37 | [submodule "RcEngine/external/lua"] 38 | path = RcEngine/external/lua 39 | url = https://github.com/triscuitcircuit/lua-cmake 40 | [submodule "RcEngine/external/openal-soft"] 41 | path = RcEngine/external/openal-soft 42 | url = https://github.com/triscuitcircuit/openal-soft 43 | [submodule "RcEngine/external/sndfile"] 44 | path = RcEngine/external/sndfile 45 | url = https://github.com/triscuitcircuit/libsndfile 46 | [submodule "RcEngine/external/ios-cmake"] 47 | path = RcEngine/external/ios-cmake 48 | url = https://github.com/leetal/ios-cmake 49 | [submodule "RcEngine/external/tinyobj"] 50 | path = RcEngine/external/tinyobj 51 | url = https://github.com/triscuitcircuit/tinyobjloader 52 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | fail_fast: false 2 | 3 | repos: 4 | - repo: https://github.com/pre-commit/pre-commit-hooks 5 | rev: v2.3.0 6 | hooks: 7 | - id: check-yaml 8 | - id: clang-format 9 | args: [--style=Google] 10 | - id: clang-tidy -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.19) 2 | 3 | project(RCGameEngine) 4 | 5 | 6 | add_subdirectory(RcEngine) 7 | #add_subdirectory(RcGame) 8 | add_subdirectory(RcEditor) 9 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline{ 2 | agent any 3 | options{ 4 | skipDefaultCheckout(true) 5 | } 6 | stages { 7 | stage('Build'){ 8 | steps { 9 | cleanWs() 10 | checkout scm 11 | sh 'echo "Running Cmake build script...."' 12 | sh 'chmod +x scripts/jenkins/jenkins-cmake.sh' 13 | sh 'scripts/jenkins/jenkins-cmake.sh' 14 | archiveArtifacts artifacts: 'cmake-build/*', fingerprint: true 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Assets included DO NOT fall under the RcEngine MIT License and have their own license. 2 | If you wish to use the assets for your own project, please buy the assets from the appropriate vendors as listed on their readme or pdf. 3 | 4 | 5 | 6 | RcEngine MIT License 7 | 8 | Copyright (c) 2021 Tristan Zippert 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | RC-Engine 3 | ============================= 4 | A game engine made using both Rust and C++. 5 | The Rust language is used for the networking side of the engine, while C++ is used for standard rendering 6 | 7 | ## Compiling 8 | Compilations are tested and ran on a Macintosh, so Windows compilation results may vary. 9 | Make sure Rust Language is installed, as the RcNetwork library won't compile. 10 | 11 | To make sure the Rust library compiles correctly, please make sure to 12 | put the source sdk folder for [steamworks sdk](https://partner.steamgames.com/doc/sdk) within `RcEngine/external/RcNetwork/external` 13 | , or you can compile without it by deleting the steam folder within `RcNetwork`and removing the reference in `Cargo.toml` 14 | 15 | Work in progress 16 | 17 | Clone the project with git clone recursive 18 | ```shell 19 | git clone --recurse-submodules -j8 https:///github.com/triscuitcircuit/rcengine.git 20 | cd rcengine 21 | ``` 22 |
Standard Cmake build 23 | 1. make a "build" directory within the main directory 24 | 25 | ```shell 26 | mkdir build 27 | cd build 28 | ``` 29 | 2. run cmake within the build directory 30 | ```shell 31 | cmake .. 32 | ``` 33 |
34 | 35 |
36 | Xcode build from script 37 | 38 | 39 | 1. Go to the scripts directory and run the "generate-xcode.sh" script 40 | 41 | OR 42 | 2. Run the script through the MacOS terminal 43 | ```shell 44 | bash generate-xcode.sh 45 | ``` 46 | Then open up the Xcode project that was generated in the "xcode-build" folder 47 |
48 | 49 |
50 | Visual Studio build from .bat 51 | 52 | On Windows, you can run the "generate-VSproj.bat" file located in the "scripts" folder. 53 | 54 | This will generate a Visual Studio project within a Visual Studio 2019 project within a folder called "visual-studio-build". 55 | 56 |
57 | 58 | While very early in development, feel free to comment changes you would 59 | want in a simple game engine. This engine isn't meant to be a AAA engine by any means, and the scope 60 | is to make a 2.5D editor and engine with network capabilities. 61 | # Special Thanks 62 | - Special thanks to TheCherno for his guide on game engine design! 63 | - A special shout-out to 0x (https://github.com/0xworks) for helping with my OpenGL questions (And help with `OpenGLTexture.cpp`)!! 64 | - A special thanks to [Light3039](https://github.com/Light3039) on github for texture debug help( and for the `Tiles.png` debug texture)!!!! 65 | -------------------------------------------------------------------------------- /RcEditor/Assets/Config/imgui.ini: -------------------------------------------------------------------------------- 1 | [Window][DockSpace Demo] 2 | Pos=0,0 3 | Size=1280,720 4 | Collapsed=0 5 | 6 | [Window][Debug##Default] 7 | Pos=60,60 8 | Size=400,400 9 | Collapsed=0 10 | 11 | [Window][ViewPort] 12 | Pos=316,64 13 | Size=729,400 14 | Collapsed=0 15 | DockId=0x0000000D,0 16 | 17 | [Window][Scene Hierarchy] 18 | Pos=0,22 19 | Size=314,375 20 | Collapsed=0 21 | DockId=0x00000006,0 22 | 23 | [Window][Properties] 24 | Pos=0,399 25 | Size=314,321 26 | Collapsed=0 27 | DockId=0x00000008,0 28 | 29 | [Window][Renderer 2D Stats] 30 | Pos=1047,500 31 | Size=233,220 32 | Collapsed=0 33 | DockId=0x00000004,0 34 | 35 | [Window][Console] 36 | Pos=316,466 37 | Size=729,254 38 | Collapsed=0 39 | DockId=0x0000000A,0 40 | 41 | [Window][Dear ImGui Demo] 42 | Pos=1047,22 43 | Size=233,476 44 | Collapsed=0 45 | DockId=0x00000003,1 46 | 47 | [Window][##toolbar] 48 | Pos=316,22 49 | Size=729,40 50 | Collapsed=0 51 | DockId=0x0000000C,0 52 | 53 | [Window][Content Browser] 54 | Pos=316,466 55 | Size=729,254 56 | Collapsed=0 57 | DockId=0x0000000A,1 58 | 59 | [Window][Renderer] 60 | Pos=1047,22 61 | Size=233,476 62 | Collapsed=0 63 | DockId=0x00000003,0 64 | 65 | [Docking][Data] 66 | DockSpace ID=0x3BC79352 Window=0x4647B76E Pos=80,93 Size=1280,698 Split=X 67 | DockNode ID=0x00000005 Parent=0x3BC79352 SizeRef=314,698 Split=Y Selected=0x9A68760C 68 | DockNode ID=0x00000006 Parent=0x00000005 SizeRef=241,352 Selected=0x9A68760C 69 | DockNode ID=0x00000008 Parent=0x00000005 SizeRef=241,302 Selected=0xC89E3217 70 | DockNode ID=0x00000009 Parent=0x3BC79352 SizeRef=964,698 Split=X 71 | DockNode ID=0x00000001 Parent=0x00000009 SizeRef=729,698 Split=Y 72 | DockNode ID=0x00000007 Parent=0x00000001 SizeRef=714,415 Split=Y Selected=0x3969A3C6 73 | DockNode ID=0x0000000C Parent=0x00000007 SizeRef=686,40 HiddenTabBar=1 Selected=0x28257B55 74 | DockNode ID=0x0000000D Parent=0x00000007 SizeRef=686,400 CentralNode=1 Selected=0x3969A3C6 75 | DockNode ID=0x0000000A Parent=0x00000001 SizeRef=714,239 Selected=0xF9BEF62A 76 | DockNode ID=0x00000002 Parent=0x00000009 SizeRef=233,698 Split=Y Selected=0xE927CF2F 77 | DockNode ID=0x00000003 Parent=0x00000002 SizeRef=322,447 Selected=0x08EFC3CA 78 | DockNode ID=0x00000004 Parent=0x00000002 SizeRef=322,207 Selected=0x8427B473 79 | 80 | -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-Black.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-BlackItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-BlackItalic.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-Bold.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-BoldItalic.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-ExtraBold.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-ExtraBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-ExtraBoldItalic.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-ExtraLight.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-ExtraLightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-ExtraLightItalic.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-Italic.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-Light.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-LightItalic.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-Medium.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-MediumItalic.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-Regular.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-SemiBold.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-SemiBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-SemiBoldItalic.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-Thin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-Thin.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Fonts/FiraSans/FiraSans-ThinItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Fonts/FiraSans/FiraSans-ThinItalic.ttf -------------------------------------------------------------------------------- /RcEditor/Assets/Game/Textures/CC_City_Exterior_A2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Game/Textures/CC_City_Exterior_A2.png -------------------------------------------------------------------------------- /RcEditor/Assets/Game/Textures/CC_City_Exterior_B.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Game/Textures/CC_City_Exterior_B.png -------------------------------------------------------------------------------- /RcEditor/Assets/Game/Textures/TILESET-LICENCE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Game/Textures/TILESET-LICENCE.txt -------------------------------------------------------------------------------- /RcEditor/Assets/Icons/ContentBrowser/DirectoryIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Icons/ContentBrowser/DirectoryIcon.png -------------------------------------------------------------------------------- /RcEditor/Assets/Icons/ContentBrowser/FileIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Icons/ContentBrowser/FileIcon.png -------------------------------------------------------------------------------- /RcEditor/Assets/Icons/Menu/playicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Icons/Menu/playicon.png -------------------------------------------------------------------------------- /RcEditor/Assets/Icons/Menu/simplay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Icons/Menu/simplay.png -------------------------------------------------------------------------------- /RcEditor/Assets/Icons/Menu/simstop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Icons/Menu/simstop.png -------------------------------------------------------------------------------- /RcEditor/Assets/Icons/Menu/stopicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Icons/Menu/stopicon.png -------------------------------------------------------------------------------- /RcEditor/Assets/Shaders/CircleCombined.glsl: -------------------------------------------------------------------------------- 1 | #type vertex 2 | #version 410 core 3 | 4 | layout(location = 0) in vec3 a_WorldPosition; 5 | layout(location = 1) in vec3 a_LocalPosition; 6 | layout(location = 2) in vec4 a_Color; 7 | layout(location = 3) in float a_Thickness; 8 | layout(location = 4) in float a_Fade; 9 | layout(location = 5) in int a_EntityID; 10 | 11 | 12 | uniform mat4 u_ViewProjection; 13 | 14 | struct VertexOutput 15 | { 16 | vec3 LocalPosition; 17 | vec4 Color; 18 | float Thickness; 19 | float Fade; 20 | }; 21 | 22 | layout (location = 0) out VertexOutput Input; 23 | layout (location = 4) flat out int v_EntityID; 24 | 25 | void main() 26 | { 27 | 28 | Input.Color = a_Color; 29 | Input.LocalPosition = a_LocalPosition; 30 | Input.Thickness = a_Thickness; 31 | Input.Fade = a_Fade; 32 | v_EntityID = a_EntityID; 33 | 34 | gl_Position = u_ViewProjection * vec4(a_WorldPosition, 1.0); 35 | } 36 | 37 | #type fragment 38 | #version 410 core 39 | 40 | layout(location = 0) out vec4 o_Color; 41 | layout(location = 4) out int o_EntityID; 42 | 43 | struct VertexOutput 44 | { 45 | vec3 LocalPosition; 46 | vec4 Color; 47 | float Thickness; 48 | float Fade; 49 | }; 50 | 51 | layout(location = 0) in VertexOutput Input; 52 | layout(location = 4) flat in int v_EntityID; 53 | 54 | void main(){ 55 | // Calculate distance and fill circle with white 56 | float distance = 1.0 - length(Input.LocalPosition); 57 | float circle = smoothstep(0.0, Input.Fade, distance); 58 | circle *= smoothstep(Input.Thickness + Input.Fade, Input.Thickness, distance); 59 | 60 | if (circle == 0.0) 61 | discard; 62 | 63 | // Set output color 64 | o_Color = Input.Color; 65 | o_Color.a *= circle; 66 | 67 | o_EntityID = v_EntityID; 68 | } -------------------------------------------------------------------------------- /RcEditor/Assets/Shaders/MeshCombined.glsl: -------------------------------------------------------------------------------- 1 | #type vertex 2 | #version 410 core 3 | 4 | layout(location = 0) in vec3 a_WorldPosition; 5 | layout(location = 1) in vec3 a_LocalPosition; 6 | layout(location = 2) in vec4 a_Color; 7 | layout(location = 5) in int a_EntityID; 8 | 9 | uniform mat4 u_ViewProjection; 10 | uniform mat4 u_mv_Matrix; 11 | 12 | struct VertexOutput{ 13 | vec3 LocalPosition; 14 | vec4 Color; 15 | }; 16 | 17 | layout (location = 0) out VertexOutput Input; 18 | layout (location = 2) flat out int v_EntityID; 19 | 20 | void main(void) { 21 | Input.LocalPosition = a_LocalPosition; 22 | Input.Color = a_Color; 23 | 24 | gl_Position = u_ViewProjection * u_mv_Matrix * vec4(a_WorldPosition,1.0); 25 | } 26 | 27 | #type fragment 28 | #version 410 core 29 | 30 | layout(location = 0) out vec4 o_Color; 31 | layout(location = 2) out int o_EntityID; 32 | 33 | struct VertexOutput{ 34 | vec3 LocalPosition; 35 | vec4 Color; 36 | }; 37 | 38 | layout(location = 0) in VertexOutput Input; 39 | layout(location = 2) flat in int v_EntityID; 40 | 41 | void main(void){ 42 | o_Color = Input.Color; 43 | o_EntityID = v_EntityID; 44 | } -------------------------------------------------------------------------------- /RcEditor/Assets/Shaders/Metal/TextureVertex.metal: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | struct VertexOutput 7 | { 8 | float4 Color; 9 | float2 TexCoord; 10 | float TexIndex; 11 | float TilingFactor; 12 | }; 13 | 14 | struct Camera 15 | { 16 | float4x4 u_ViewProjection; 17 | }; 18 | 19 | struct main0_out 20 | { 21 | float4 VertexOutput_Color [[user(locn0)]]; 22 | float2 VertexOutput_TexCoord [[user(locn1)]]; 23 | float VertexOutput_TexIndex [[user(locn2)]]; 24 | float VertexOutput_TilingFactor [[user(locn3)]]; 25 | int v_EntityID [[user(locn4)]]; 26 | float4 gl_Position [[position]]; 27 | }; 28 | 29 | struct main0_in 30 | { 31 | float3 a_Position [[attribute(0)]]; 32 | float4 a_Color [[attribute(1)]]; 33 | float2 a_TexCoord [[attribute(2)]]; 34 | float a_TexIndex [[attribute(3)]]; 35 | float a_TilingFactor [[attribute(4)]]; 36 | int a_EntityID [[attribute(5)]]; 37 | }; 38 | 39 | vertex main0_out main0(main0_in in [[stage_in]], constant Camera& _49 [[buffer(0)]]) 40 | { 41 | main0_out out = {}; 42 | VertexOutput Input = {}; 43 | Input.Color = in.a_Color; 44 | Input.TexCoord = in.a_TexCoord; 45 | Input.TexIndex = in.a_TexIndex; 46 | Input.TilingFactor = in.a_TilingFactor; 47 | out.v_EntityID = in.a_EntityID; 48 | out.gl_Position = _49.u_ViewProjection * float4(in.a_Position, 1.0); 49 | out.VertexOutput_Color = Input.Color; 50 | out.VertexOutput_TexCoord = Input.TexCoord; 51 | out.VertexOutput_TexIndex = Input.TexIndex; 52 | out.VertexOutput_TilingFactor = Input.TilingFactor; 53 | return out; 54 | } 55 | 56 | -------------------------------------------------------------------------------- /RcEditor/Assets/Shaders/SPIRV/Fragment.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Shaders/SPIRV/Fragment.spv -------------------------------------------------------------------------------- /RcEditor/Assets/Shaders/SPIRV/TextureShader.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Shaders/SPIRV/TextureShader.spv -------------------------------------------------------------------------------- /RcEditor/Assets/Shaders/SPIRV/Vertex.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/Shaders/SPIRV/Vertex.spv -------------------------------------------------------------------------------- /RcEditor/Assets/Shaders/Vulkan/TextureVertex.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec3 a_Position; 5 | layout(location = 1) in vec4 a_Color; 6 | layout(location = 2) in vec2 a_TexCoord; 7 | layout(location = 3) in float a_TexIndex; 8 | layout(location = 4) in float a_TilingFactor; 9 | layout(location = 5) in int a_EntityID; 10 | 11 | layout(std140, binding = 0) uniform Camera 12 | { 13 | mat4 u_ViewProjection; 14 | }; 15 | 16 | struct VertexOutput 17 | { 18 | vec4 Color; 19 | vec2 TexCoord; 20 | float TexIndex; 21 | float TilingFactor; 22 | }; 23 | 24 | layout (location = 0) out VertexOutput Input; 25 | layout (location = 4) flat out int v_EntityID; 26 | 27 | void main() 28 | { 29 | 30 | Input.Color = a_Color; 31 | Input.TexCoord = a_TexCoord; 32 | Input.TexIndex = a_TexIndex; 33 | Input.TilingFactor = a_TilingFactor; 34 | v_EntityID = a_EntityID; 35 | 36 | gl_Position = u_ViewProjection * vec4(a_Position, 1.0); 37 | } 38 | -------------------------------------------------------------------------------- /RcEditor/Assets/textures/Default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/textures/Default.jpg -------------------------------------------------------------------------------- /RcEditor/Assets/textures/Texture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/textures/Texture.png -------------------------------------------------------------------------------- /RcEditor/Assets/textures/Tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/Assets/textures/Tiles.png -------------------------------------------------------------------------------- /RcEditor/media/AppImage.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/media/AppImage.icns -------------------------------------------------------------------------------- /RcEditor/media/AppImage.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/media/AppImage.ico -------------------------------------------------------------------------------- /RcEditor/media/AppImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcEditor/media/AppImage.png -------------------------------------------------------------------------------- /RcEditor/src/EditorLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/6/21. 3 | // 4 | #pragma once 5 | #include "RcEngine.h" 6 | #include "Panels/SceneHierarchyPanel.h" 7 | #include "Panels/ContentBrowserPanel.h" 8 | 9 | #ifndef RCENGINE_CLION_EDITORLAYER_H 10 | #define RCENGINE_CLION_EDITORLAYER_H 11 | namespace RcEngine{ 12 | class EditorLayer : public Layer{ 13 | public: 14 | EditorLayer(); 15 | virtual ~EditorLayer() = default; 16 | 17 | virtual void OnAttach() override; 18 | virtual void OnDetach() override; 19 | 20 | void OnUpdate(Timestep ts) override; 21 | virtual void OnImGuiRender() override; 22 | void OnEvent(Event& e) override; 23 | private: 24 | bool OnKeyPressed(KeyPressedEvent& e ); 25 | bool OnMouseScroll(MouseScrolledEvent& e); 26 | 27 | void NewScene(); 28 | void OpenScene(); 29 | void OpenScene(const std::filesystem::path& path); 30 | void SaveAs(); 31 | 32 | void OnScenePlay(); 33 | void OnSceneStop(); 34 | void OnSceneEdit(); 35 | 36 | void OnSceneSimulation(); 37 | 38 | 39 | //UI specific functions 40 | void UI_Toolbar(); 41 | 42 | 43 | 44 | private: 45 | OrthoCameraController m_CameraController; 46 | 47 | Ref m_FrameBuffer; 48 | 49 | glm::vec4 m_SquareColor = {0.8f,0.0f,0.0f,1.0f}; 50 | glm::vec4 m_TextureColor = {0.2f,0.3f,0.8f,1.0f}; 51 | 52 | EditorCamera m_EditorCamera; 53 | 54 | bool m_ViewportFocused = false, m_ViewportHovered = false; 55 | glm::vec2 m_ViewportSize = { 0.0f, 0.0f }; 56 | glm::vec2 m_ViewportBounds[2]; 57 | 58 | Entity m_SquareEntity; 59 | Entity m_CameraEntity; 60 | Entity m_SecondCamera; 61 | Ref m_ActiveScene; 62 | Ref m_EditorScene; 63 | std::filesystem::path m_EditorScenePath; 64 | 65 | struct ProfileResult{ 66 | const char* Name; 67 | float time; 68 | }; 69 | std::vector m_Profiler; 70 | 71 | 72 | glm::vec2 m_ViewPortSize = {1264,666}; 73 | 74 | //panels 75 | SceneHierarchyPanel m_Panel; 76 | ContentBrowserPanel m_ContentBrowserPanel; 77 | 78 | //editor menu 79 | Ref m_IconPlay,m_StopPlay, m_IconSimulate, m_IconSimulateStop; 80 | 81 | //Script 82 | std::string m_ScriptString; 83 | 84 | int m_GizmoType = -1; 85 | 86 | enum class SceneState{ 87 | Edit =0, Play =1, Simulate=2 88 | }; 89 | SceneState m_SceneState = SceneState::Edit; 90 | 91 | 92 | 93 | }; 94 | } 95 | #endif //RCENGINE_CLION_EDITORLAYER_H 96 | -------------------------------------------------------------------------------- /RcEditor/src/Panels/ContentBrowserPanel.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/30/21. 3 | // 4 | #pragma once 5 | #include 6 | #include "RcEngine/Renderer/Texture.h" 7 | 8 | #ifndef RCENGINE_CONTENTBROWSERPANEL_H 9 | #define RCENGINE_CONTENTBROWSERPANEL_H 10 | namespace RcEngine{ 11 | class ContentBrowserPanel{ 12 | public: 13 | ContentBrowserPanel(); 14 | void OnImGuiRender(); 15 | private: 16 | std::filesystem::path m_CurrentDirectory; 17 | 18 | Ref m_DirectoryIcon; 19 | Ref m_FileIcon; 20 | 21 | 22 | }; 23 | } 24 | #endif //RCENGINE_CONTENTBROWSERPANEL_H 25 | -------------------------------------------------------------------------------- /RcEditor/src/Panels/SceneHierarchyPanel.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/8/21. 3 | // 4 | #pragma once 5 | 6 | #include "RcEngine/Core/Core.h" 7 | 8 | #include "RcEngine/Core/Log.h" 9 | #include "RcEngine/Scene/Entity.h" 10 | 11 | 12 | #ifndef RCENGINE_CLION_SCENEHIERARCHYPANEL_H 13 | #define RCENGINE_CLION_SCENEHIERARCHYPANEL_H 14 | #include "RcEngine/Scene/Scene.h" 15 | namespace RcEngine{ 16 | class SceneHierarchyPanel{ 17 | public: 18 | SceneHierarchyPanel()= default; 19 | SceneHierarchyPanel(const Ref& scene); 20 | 21 | void SetContext(const Ref& scene); 22 | 23 | void OnImGuiRender(); 24 | 25 | Entity GetSelectedEntity() const{return m_Selected;}; 26 | 27 | private: 28 | void DrawEntityNode(Entity entity); 29 | void DrawComponents(Entity entitySelection); 30 | private: 31 | Ref m_Scene; 32 | Entity m_Selected; 33 | friend class Scene; 34 | }; 35 | } 36 | #endif //RCENGINE_CLION_SCENEHIERARCHYPANEL_H 37 | -------------------------------------------------------------------------------- /RcEditor/src/RcEditorApp.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/6/21. 3 | // 4 | 5 | #include 6 | 7 | #include "EditorLayer.h" 8 | 9 | namespace RcEngine { 10 | class RcEditor : public Application { 11 | public: 12 | RcEditor() 13 | : Application("Rc Engine Editor"){ 14 | PushLayer(new EditorLayer()); 15 | }; 16 | 17 | ~RcEditor() {}; 18 | }; 19 | 20 | Application *CreateApplication() { 21 | return new RcEditor(); 22 | } 23 | } -------------------------------------------------------------------------------- /RcEditor/src/ViewPanel.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 10/29/21. 3 | // 4 | 5 | #include "ViewPanel.h" 6 | -------------------------------------------------------------------------------- /RcEditor/src/ViewPanel.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 10/29/21. 3 | // 4 | #pragma once 5 | #include "RcEngine.h" 6 | #include "Panels/SceneHierarchyPanel.h" 7 | #include "Panels/ContentBrowserPanel.h" 8 | #include "EditorLayer.h" 9 | 10 | #ifndef RCENGINE_VIEWPORT_H 11 | #define RCENGINE_VIEWPORT_H 12 | namespace RcEngine{ 13 | class ViewPanel : public Layer{ 14 | public: 15 | ViewPanel(const Ref& scene = nullptr); 16 | virtual ~ViewPanel() = default; 17 | 18 | virtual void OnAttach() override; 19 | virtual void OnDetach() override; 20 | 21 | void ProcessInput(); 22 | void DrawGizmos(); 23 | 24 | void OnUpdate(Timestep ts) override; 25 | virtual void OnImGuiRender() override; 26 | void OnEvent(Event& e) override; 27 | 28 | bool isFocused(){return m_isFocused;} 29 | 30 | void SetContext(const Ref cxt); 31 | Ref& GetContext(){return m_Context;} 32 | private: 33 | bool m_isFocused = true; 34 | Ref m_Context; 35 | }; 36 | } 37 | #endif //RCENGINE_VIEWPORT_H 38 | -------------------------------------------------------------------------------- /RcEngine/external/RcNetwork/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rc_network" 3 | version = "0.1.0" 4 | edition = "2018" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | tokio = "1.6.0" 10 | libc = "0.2.0" 11 | #steamworks = "0.7.0" 12 | simplelog = "0.7.5" 13 | serde = "1.0.126" 14 | log = "0.4.14" 15 | chrono = "0.4.19" 16 | 17 | [lib] 18 | crate-type = ["staticlib"] 19 | 20 | [profile.dev] 21 | opt-level = 3 22 | -------------------------------------------------------------------------------- /RcEngine/external/RcNetwork/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod util; 2 | 3 | extern crate libc; 4 | use libc::{c_int, size_t}; 5 | use crate::util::client::tcp_client; 6 | use crate::util::server::tcp_server; 7 | 8 | //Entry point 9 | #[no_mangle] 10 | pub extern "C" fn rc_entry(){ 11 | println!("Entrypoint rc_network"); 12 | } 13 | #[no_mangle] 14 | pub extern "C" fn rc_tcp_client(){ 15 | tcp_client(); 16 | } 17 | #[no_mangle] 18 | pub extern "C" fn rc_tcp_server(){ 19 | tcp_server(); 20 | } -------------------------------------------------------------------------------- /RcEngine/external/RcNetwork/src/steam/mod.rs: -------------------------------------------------------------------------------- 1 | use steamworks::AppId; 2 | use steamworks::Client; 3 | use steamworks::FriendFlags; 4 | use steamworks::PersonaStateChange; 5 | 6 | -------------------------------------------------------------------------------- /RcEngine/external/RcNetwork/src/util/client.rs: -------------------------------------------------------------------------------- 1 | use std::net::TcpStream; 2 | use std::str; 3 | use std::io::{self, BufRead, BufReader,Write}; 4 | 5 | pub fn tcp_client(){ 6 | let mut stream = TcpStream::connect("127.0.0.1:8888") 7 | .expect("Could not connect to server"); 8 | loop{ 9 | let mut input = String::new(); 10 | let mut buffer: Vec = Vec::new(); 11 | 12 | io::stdin().read_line(&mut input) 13 | .expect("failed to read from stdin"); 14 | 15 | stream.write(input.as_bytes()) 16 | .expect("Failed to write to server"); 17 | 18 | let mut reader = BufReader::new(&stream); 19 | 20 | reader.read_until(b'\n', &mut buffer) 21 | .expect("Could not read into buffer"); 22 | print!("{}", str::from_utf8(&buffer) 23 | .expect("Could not write buffer as string")); 24 | } 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /RcEngine/external/RcNetwork/src/util/logger.rs: -------------------------------------------------------------------------------- 1 | extern crate chrono; 2 | extern crate log; 3 | 4 | 5 | use std::fs; 6 | use std::io::{Write, Error}; 7 | use log::{Record, LevelFilter, Metadata}; 8 | use std::fs::File; 9 | use self::log::Log; 10 | use simplelog::Config; 11 | 12 | 13 | pub struct FileLogger{ 14 | log_file: String, 15 | filter_level: LevelFilter, 16 | } 17 | 18 | impl FileLogger{ 19 | pub fn new(log_file: &str, filter_level: LevelFilter)-> Self{ 20 | Self{ 21 | log_file: log_file.to_owned(), 22 | filter_level, 23 | } 24 | } 25 | } 26 | 27 | impl log::Log for FileLogger{ 28 | fn enabled(&self, metadata:&Metadata)->bool{ 29 | metadata.level() <= self.filter_level 30 | } 31 | 32 | fn log(&self, record: &Record) { 33 | if self.enabled(record.metadata()){ 34 | let mut retries = 0; 35 | let mut file = loop{ 36 | let file = fs::OpenOptions::new() 37 | .create(true) 38 | .append(true) 39 | .open(&self.log_file); 40 | let file = match file { 41 | Ok(f) => f, 42 | Err(e)=>{ 43 | if retries >= 10{ 44 | eprintln!("Could not write to log file: {}",retries); 45 | return; 46 | } 47 | retries+=1; 48 | std::thread::sleep(std::time::Duration::from_micros(5)); 49 | continue; 50 | }, 51 | }; 52 | break file; 53 | }; 54 | let dt = chrono::Local::now(); 55 | let time = dt.format("%Y-%m-%d %H:%M:%S"); 56 | 57 | if let Err(e) = writeln!(file, "[{}] [{}] {}", time, record.level(),record.args()){ 58 | eprintln!("Couldn't write to log file: {}",e); 59 | } 60 | 61 | } 62 | } 63 | 64 | fn flush(&self) {} 65 | } 66 | impl simplelog::SharedLogger for FileLogger{ 67 | fn level(&self) -> LevelFilter { 68 | todo!() 69 | } 70 | 71 | fn config(&self) -> Option<&Config> { 72 | todo!() 73 | } 74 | 75 | fn as_log(self: Box) -> Box { 76 | todo!() 77 | } 78 | } -------------------------------------------------------------------------------- /RcEngine/external/RcNetwork/src/util/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod client; 2 | pub mod server; 3 | pub mod logger; -------------------------------------------------------------------------------- /RcEngine/external/RcNetwork/src/util/server.rs: -------------------------------------------------------------------------------- 1 | use std::net::{TcpListener,TcpStream}; 2 | use std::thread; 3 | 4 | use std::io::{Read,Write,Error}; 5 | use std::collections::HashMap; 6 | 7 | fn handle_client(mut stream: TcpStream) -> Result<(), Error>{ 8 | println!("Incoming connection from: {}", stream.peer_addr()?); 9 | let mut buf = [0;512]; 10 | loop{ 11 | let bytes_read = stream.read(&mut buf)?; 12 | if bytes_read ==0 {return Ok(());} 13 | stream.write(&buf[..bytes_read])?; 14 | } 15 | } 16 | pub fn tcp_server(){ 17 | 18 | let listener = TcpListener::bind("0.0.0.0:8888") 19 | .expect("Could not bind socket"); 20 | // new thread here to prevent lockup 21 | thread::spawn(move||{ 22 | println!("server activated"); 23 | for stream in listener.incoming(){ 24 | match stream{ 25 | Err(e) => { 26 | eprintln!("failed: {}", e) 27 | } 28 | Ok(stream)=>{ 29 | 30 | thread::spawn(move||{ 31 | handle_client(stream) 32 | .unwrap_or_else(|error|eprintln!("{:?}",error)) 33 | }); 34 | } 35 | }; 36 | } 37 | }); 38 | } -------------------------------------------------------------------------------- /RcEngine/external/entt/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017-2021 Michele Caini 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copy of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copy or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /RcEngine/external/glad/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.19) 2 | project(glad) 3 | 4 | add_library(glad include/glad/glad.h src/glad.c) 5 | target_include_directories(glad PUBLIC $(CMAKE_CURRENT_SOURCE_DIR)) -------------------------------------------------------------------------------- /RcEngine/macros.cmake: -------------------------------------------------------------------------------- 1 | # finds and adds sources files in a folder 2 | macro(addPath dir) 3 | set(tmp_files "") 4 | set(glob_config GLOB) 5 | if(${ARGC} GREATER 1 AND "${ARGV1}" STREQUAL "REC") 6 | set(glob_config GLOB_RECURSE) 7 | endif() 8 | set(mac_files "") 9 | if(APPLE) 10 | set(mac_files ${dir}/*.mm ${dir}/*.m) 11 | endif() 12 | file(${glob_config} tmp_files 13 | ${dir}/*.cpp 14 | ${dir}/*.c 15 | ${dir}/*.cc 16 | ${dir}/*.h 17 | ${mac_files} 18 | #${dir}/*.asm 19 | ) 20 | foreach(entry ${BLACKLIST}) 21 | list(REMOVE_ITEM tmp_files ${dir}/${entry}) 22 | endforeach() 23 | LIST(APPEND ${PROJECT_NAME}_files "${tmp_files}") 24 | LIST(APPEND ${PROJECT_NAME}_paths "${dir}") 25 | message(STATUS "addPath ${PROJECT_NAME} : ${tmp_files}") 26 | endmacro() 27 | 28 | macro(addFile filename) 29 | LIST(APPEND ${PROJECT_NAME}_files "${filename}") 30 | message(STATUS "addFile ${PROJECT_NAME} : ${filename}") 31 | endmacro() 32 | 33 | # finds and adds sources files in a folder recursively 34 | macro(addPathRec dir) 35 | addPath("${dir}" "REC") 36 | endmacro() 37 | 38 | macro(addFramework framework) 39 | if (APPLE) 40 | addLib("-framework ${framework}") 41 | endif() 42 | endmacro() 43 | 44 | macro(addLibPath dir) 45 | link_directories(${dir}) 46 | endmacro() 47 | 48 | macro(addInclude incPath) 49 | if(TARGET ${PROJECT_NAME}) 50 | set_property(TARGET ${PROJECT_NAME} APPEND PROPERTY INCLUDE_DIRECTORIES "${incPath}") 51 | else() 52 | list(APPEND ${PROJECT_NAME}_includes ${incPath}) 53 | endif() 54 | endmacro() 55 | 56 | macro(addLib libs) 57 | foreach(lib ${libs}) 58 | # check if we can build it ourselfs 59 | if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}.cmake") 60 | addLibSrc("${CMAKE_CURRENT_SOURCE_DIR}/libraries/${lib}.cmake") 61 | endif() 62 | # then link against it 63 | # two possibilities: a) target already known, so add it directly, or b) target not yet known, so add it to its cache 64 | if(TARGET ${PROJECT_NAME}) 65 | target_link_libraries(${PROJECT_NAME} "${lib}") 66 | else() 67 | list(APPEND ${PROJECT_NAME}_libs ${lib}) 68 | endif() 69 | endforeach() 70 | endmacro() -------------------------------------------------------------------------------- /RcEngine/sndfile.cmake: -------------------------------------------------------------------------------- 1 | 2 | # - Try to find libsndfile 3 | # Once done, this will define 4 | # 5 | # LIBSNDFILE_FOUND - system has libsndfile 6 | # LIBSNDFILE_INCLUDE_DIRS - the libsndfile include directories 7 | # LIBSNDFILE_LIBRARIES - link these to use libsndfile 8 | 9 | # Use pkg-config to get hints about paths 10 | find_package(PkgConfig QUIET) 11 | if(PKG_CONFIG_FOUND) 12 | pkg_check_modules(LIBSNDFILE_PKGCONF sndfile) 13 | endif(PKG_CONFIG_FOUND) 14 | 15 | # Include dir 16 | find_path(LIBSNDFILE_INCLUDE_DIR 17 | NAMES sndfile.h 18 | PATHS ${LIBSNDFILE_PKGCONF_INCLUDE_DIRS} 19 | ) 20 | 21 | # Library 22 | find_library(LIBSNDFILE_LIBRARY 23 | NAMES sndfile libsndfile-1 24 | PATHS ${LIBSNDFILE_PKGCONF_LIBRARY_DIRS} 25 | ) 26 | 27 | find_package(PackageHandleStandardArgs) 28 | find_package_handle_standard_args(LibSndFile DEFAULT_MSG LIBSNDFILE_LIBRARY LIBSNDFILE_INCLUDE_DIR) 29 | 30 | if(LIBSNDFILE_FOUND) 31 | set(LIBSNDFILE_LIBRARIES ${LIBSNDFILE_LIBRARY}) 32 | set(LIBSNDFILE_INCLUDE_DIRS ${LIBSNDFILE_INCLUDE_DIR}) 33 | message(STATUS "sndfile include dirs path: ${LIBSNDFILE_INCLUDE_DIRS}") 34 | message(STATUS "sndfile libs path: ${LIBSNDFILE_LIBRARIES}") 35 | endif(LIBSNDFILE_FOUND) 36 | 37 | mark_as_advanced(LIBSNDFILE_LIBRARY LIBSNDFILE_LIBRARIES LIBSNDFILE_INCLUDE_DIR LIBSNDFILE_INCLUDE_DIRS) 38 | 39 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Mac/MacInput.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/24/21. 3 | // 4 | 5 | #include "MacInput.h" 6 | #include "rcpch.h" 7 | #include "RcEngine/Core/Application.h" 8 | 9 | #include 10 | 11 | namespace RcEngine{ 12 | 13 | Input* Input::s_Instance = new MacInput(); 14 | 15 | bool MacInput::IsKeyPressedImpl(int keycode) { 16 | auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); 17 | 18 | auto state = glfwGetKey(window, keycode); 19 | 20 | return state == GLFW_PRESS || state == GLFW_REPEAT; 21 | } 22 | 23 | float MacInput::GetMouseXImpl() { 24 | auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); 25 | double xpos, ypos = 0.0; 26 | glfwGetCursorPos(window,&xpos,&ypos); 27 | return (float)xpos; 28 | } 29 | float MacInput::GetMouseYImpl() { 30 | auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); 31 | double xpos, ypos = 0.0; 32 | glfwGetCursorPos(window,&xpos,&ypos); 33 | return (float)ypos; 34 | } 35 | std::pair MacInput::GetMousePosImpl() { 36 | auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); 37 | double xpos, ypos = 0.0; 38 | glfwGetCursorPos(window,&xpos,&ypos); 39 | return {(float)xpos, (float)ypos}; 40 | } 41 | bool MacInput::IsMouseButtonPressedImpl(int button) { 42 | auto window = static_cast(Application::Get().GetWindow().GetNativeWindow()); 43 | 44 | auto state = glfwGetMouseButton(window, button); 45 | return state == GLFW_PRESS; 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Mac/MacInput.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/24/21. 3 | // 4 | 5 | #pragma once 6 | #include "RcEngine/Core/Input.h" 7 | namespace RcEngine{ 8 | class MacInput: public Input{ 9 | protected: 10 | virtual bool IsKeyPressedImpl(int keycode) override; 11 | 12 | 13 | virtual float GetMouseXImpl() override; 14 | virtual float GetMouseYImpl() override; 15 | virtual std::pair GetMousePosImpl() override; 16 | 17 | virtual bool IsMouseButtonPressedImpl(int button) override; 18 | }; 19 | } -------------------------------------------------------------------------------- /RcEngine/src/Platform/Mac/MacUtils.mm: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/10/21. 3 | // 4 | #include "Platform/MacUtils.h" 5 | #import 6 | 7 | namespace RcEngine{ 8 | std::string FileDialogs::OpenFile(const char *filter) { 9 | @autoreleasepool { 10 | NSString *convertedString = [[NSString alloc] initWithCString:filter encoding:NSUTF8StringEncoding]; 11 | 12 | // Sets modal properties before window is shown 13 | // Generic NSOpenPanel is being used to pick files 14 | NSOpenPanel *panel = [NSOpenPanel openPanel]; 15 | panel.canChooseFiles = YES; 16 | panel.canChooseDirectories = YES; 17 | panel.canCreateDirectories = YES; 18 | 19 | // Captures response value from "modal" window 20 | NSModalResponse response = [panel runModal]; 21 | 22 | //[convertedString release]; 23 | if (response == NSModalResponseOK) { 24 | //If okay response return filepath 25 | return std::string([[panel.URL path] UTF8String]); 26 | } else { 27 | // else return empty string 28 | return std::string([@"" UTF8String]); 29 | } 30 | } 31 | } 32 | std::string FileDialogs::SaveFile(const char *filter) { 33 | @autoreleasepool { 34 | 35 | NSString *convertedString = [[NSString alloc] initWithCString:filter encoding:NSUTF8StringEncoding]; 36 | 37 | // Sets modal properties before window is shown 38 | //The window type specifically is a NSSavePanel 39 | NSSavePanel *panel = [NSSavePanel savePanel]; 40 | panel.title = @"Save Scene As..."; 41 | panel.nameFieldStringValue = @"Scene1.rc"; 42 | panel.showsHiddenFiles = YES; 43 | panel.canCreateDirectories = YES; 44 | 45 | // Captures response value from "modal" window 46 | NSModalResponse response = [panel runModal]; 47 | 48 | //[convertedString release]; 49 | if (response == NSModalResponseOK) { 50 | //If okay response return filepath 51 | return std::string([[panel.URL path] UTF8String]); 52 | } else { 53 | // else return empty string 54 | return std::string([@"" UTF8String]); 55 | } 56 | } 57 | 58 | } 59 | void FileDialogs::OpenExplorer(const char *path) { 60 | //convert input path to NSString 61 | NSString *convertedString = [[NSString alloc] initWithCString: path encoding:NSUTF8StringEncoding]; 62 | //convert NSString to NSURL filepath for NSWorkspace to open in finder 63 | NSURL *xmlURL =[NSURL fileURLWithPath: convertedString]; 64 | // create NSWorkspace panel 65 | [[NSWorkspace sharedWorkspace] openURL:xmlURL]; 66 | } 67 | } -------------------------------------------------------------------------------- /RcEngine/src/Platform/Mac/MacWindow.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/22/21. 3 | // 4 | 5 | #define GLFW_INCLUDE_VULKAN 6 | #include "RcEngine/Core/Window.h" 7 | #include "RcEngine/Renderer/GraphicsContext.h" 8 | 9 | #include 10 | #include 11 | 12 | namespace RcEngine{ 13 | class MacWindow: public Window{ 14 | public: 15 | MacWindow(const WindowProps & props); 16 | virtual ~MacWindow(); 17 | 18 | void OnUpdate() override; 19 | 20 | inline unsigned int GetWidth() const override {return m_Data.Width; } 21 | inline unsigned int GetHeight() const override {return m_Data.Height; } 22 | 23 | //Window attributes 24 | 25 | inline void SetEventCallback(const EventCallbackfn& callback) override {m_Data.EventCallback = callback; } 26 | void SetVSync(bool enabled) override; 27 | bool IsVsync() const override ; 28 | 29 | virtual void* GetNativeWindow() const override{ return m_Window; } 30 | private: 31 | virtual void Init(const WindowProps& props); 32 | virtual void Shutdown(); 33 | private: 34 | GLFWwindow* m_Window; 35 | Scope m_Context; 36 | 37 | struct WindowData{ 38 | std::string Title; 39 | unsigned int Width, Height; 40 | bool VSync; 41 | 42 | EventCallbackfn EventCallback; 43 | }; 44 | WindowData m_Data; 45 | }; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Mac/processordetection.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/12/21. 3 | // 4 | #pragma once 5 | 6 | #include "Platform/processordetection.h" 7 | #include 8 | namespace RcEngine{ 9 | template< typename T> 10 | int getCTLValue(const char key[], T * dest){ 11 | size_t len =0; 12 | int err; 13 | 14 | err = sysctlbyname(key,nullptr,&len, nullptr,0); 15 | if(!err){ 16 | RC_CORE_ASSERT((len == sizeof(T)), "Mis-matched destination type for SYSCTL() read.\n"); 17 | err = sysctlbyname(key,dest,&len, nullptr,0); 18 | } 19 | return err; 20 | } 21 | 22 | std::string ProcessorDetectionBase::getCPUString() { 23 | char buffer[64]; 24 | size_t bufferlen = 64; 25 | sysctlbyname("machdep.cpu.brand_string", &buffer, &bufferlen, nullptr, 0); 26 | return buffer; 27 | } 28 | 29 | int32_t ProcessorDetectionBase::getCPUMaxFreq() { 30 | int32_t freq; 31 | size_t bufferlen = sizeof(freq); 32 | // TODO: deal with M1 issue 33 | sysctlbyname("hw.cpufrequency_max", &freq, &bufferlen, nullptr, 0); 34 | return freq; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/MacUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/10/21. 3 | // 4 | #pragma once 5 | #include "rcpch.h" 6 | #include "RcEngine/Utils/PlatformUtils.h" -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/MetalBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Created by Tristan Zippert on 7/13/21. 3 | 4 | Header for C++ Metal buffer wrapper 5 | */ 6 | #pragma once 7 | #include "MetalResource.h" 8 | #include "RcEngine/Core/Core.h" 9 | #include "RcEngine/Renderer/Buffer.h" 10 | 11 | namespace RcEngine{ 12 | class MetalVertexBuffer: public VertexBuffer{ 13 | public: 14 | MetalVertexBuffer(float* vertices, uint32_t size); 15 | MetalVertexBuffer(uint32_t count); 16 | 17 | ~MetalVertexBuffer() override; 18 | 19 | void Bind() const override; 20 | 21 | void Unbind() const override; 22 | 23 | void SetData(const void *data, uint32_t size) override; 24 | 25 | void SetLayout(const BufferLayout &layout) override; 26 | 27 | const BufferLayout &GetLayout() const override; 28 | public: 29 | 30 | CPPMetalInternal::Buffer objCObj() const; 31 | private: 32 | id m_device; 33 | BufferLayout m_Layout; 34 | 35 | void *m_contentsPtr; 36 | id m_VertexBuffer; 37 | id m_IndexBuffer; 38 | }; 39 | 40 | } -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/MetalBuffer.mm: -------------------------------------------------------------------------------- 1 | #include "MetalBuffer.h" 2 | 3 | 4 | namespace RcEngine { 5 | 6 | MetalVertexBuffer::MetalVertexBuffer(float *vertices, uint32_t size) { 7 | 8 | } 9 | 10 | MetalVertexBuffer::MetalVertexBuffer(uint32_t count) { 11 | 12 | } 13 | 14 | MetalVertexBuffer::~MetalVertexBuffer() { 15 | 16 | } 17 | 18 | void MetalVertexBuffer::Bind() const { 19 | 20 | } 21 | 22 | void MetalVertexBuffer::Unbind() const { 23 | 24 | } 25 | 26 | void MetalVertexBuffer::SetData(const void *data, uint32_t size) { 27 | 28 | } 29 | 30 | void MetalVertexBuffer::SetLayout(const BufferLayout &layout) { 31 | 32 | } 33 | 34 | const BufferLayout &MetalVertexBuffer::GetLayout() const { 35 | return m_Layout; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/MetalShader.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/21/22. 3 | // 4 | 5 | #include "MetalShader.h" 6 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/MetalShader.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/21/22. 3 | // 4 | 5 | #ifndef RCGAMEENGINE_METALSHADER_H 6 | #define RCGAMEENGINE_METALSHADER_H 7 | 8 | #endif //RCGAMEENGINE_METALSHADER_H 9 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/metal-cpp/Foundation/Foundation.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Foundation/Foundation.hpp 4 | // 5 | // Copyright 2020-2021 Apple Inc. 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // 19 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | 21 | #pragma once 22 | 23 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | 25 | #include "NSArray.hpp" 26 | #include "NSAutoreleasePool.hpp" 27 | #include "NSBundle.hpp" 28 | #include "NSData.hpp" 29 | #include "NSDate.hpp" 30 | #include "NSDefines.hpp" 31 | #include "NSDictionary.hpp" 32 | #include "NSEnumerator.hpp" 33 | #include "NSError.hpp" 34 | #include "NSLock.hpp" 35 | #include "NSNotification.hpp" 36 | #include "NSNumber.hpp" 37 | #include "NSObject.hpp" 38 | #include "NSPrivate.hpp" 39 | #include "NSProcessInfo.hpp" 40 | #include "NSRange.hpp" 41 | #include "NSString.hpp" 42 | #include "NSTypes.hpp" 43 | #include "NSURL.hpp" 44 | 45 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 46 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/metal-cpp/Foundation/NSData.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Foundation/NSData.hpp 4 | // 5 | // Copyright 2020-2021 Apple Inc. 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // 19 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | 21 | #pragma once 22 | 23 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | 25 | #include "NSObject.hpp" 26 | #include "NSTypes.hpp" 27 | 28 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | 30 | namespace NS 31 | { 32 | class Data : public Copying 33 | { 34 | public: 35 | void* mutableBytes() const; 36 | UInteger length() const; 37 | }; 38 | } 39 | 40 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 41 | 42 | _NS_INLINE void* NS::Data::mutableBytes() const 43 | { 44 | return Object::sendMessage(this, _NS_PRIVATE_SEL(mutableBytes)); 45 | } 46 | 47 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 48 | 49 | _NS_INLINE NS::UInteger NS::Data::length() const 50 | { 51 | return Object::sendMessage(this, _NS_PRIVATE_SEL(length)); 52 | } 53 | 54 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 55 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/metal-cpp/Foundation/NSDate.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Foundation/NSDate.hpp 4 | // 5 | // See LICENSE.txt for this project licensing information. 6 | // 7 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 8 | 9 | #pragma once 10 | 11 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 12 | 13 | #include "NSDefines.hpp" 14 | #include "NSObject.hpp" 15 | #include "NSPrivate.hpp" 16 | #include "NSTypes.hpp" 17 | 18 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 19 | 20 | namespace NS 21 | { 22 | 23 | using TimeInterval = double; 24 | 25 | class Date : public Copying 26 | { 27 | public: 28 | static Date* dateWithTimeIntervalSinceNow(TimeInterval secs); 29 | }; 30 | 31 | } // NS 32 | 33 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 34 | 35 | _NS_INLINE NS::Date* NS::Date::dateWithTimeIntervalSinceNow(NS::TimeInterval secs) 36 | { 37 | return NS::Object::sendMessage(_NS_PRIVATE_CLS(NSDate), _NS_PRIVATE_SEL(dateWithTimeIntervalSinceNow_), secs); 38 | } 39 | 40 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/metal-cpp/Foundation/NSDefines.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Foundation/NSDefines.hpp 4 | // 5 | // Copyright 2020-2021 Apple Inc. 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // 19 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | 21 | #pragma once 22 | 23 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | 25 | #define _NS_WEAK_IMPORT __attribute__((weak_import)) 26 | #define _NS_EXPORT __attribute__((visibility("default"))) 27 | #define _NS_EXTERN extern "C" _NS_EXPORT 28 | #define _NS_INLINE inline __attribute__((always_inline)) 29 | #define _NS_PACKED __attribute__((packed)) 30 | 31 | #define _NS_CONST(type, name) _NS_EXTERN type const name; 32 | #define _NS_ENUM(type, name) enum name : type 33 | #define _NS_OPTIONS(type, name) \ 34 | using name = type; \ 35 | enum : name 36 | 37 | #define _NS_CAST_TO_UINT(value) static_cast(value) 38 | #define _NS_VALIDATE_SIZE(ns, name) static_assert(sizeof(ns::name) == sizeof(ns##name), "size mismatch " #ns "::" #name) 39 | #define _NS_VALIDATE_ENUM(ns, name) static_assert(_NS_CAST_TO_UINT(ns::name) == _NS_CAST_TO_UINT(ns##name), "value mismatch " #ns "::" #name) 40 | 41 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 42 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/metal-cpp/Foundation/NSObjCRuntime.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Foundation/NSObjCRuntime.hpp 4 | // 5 | // Copyright 2020-2021 Apple Inc. 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // 19 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | 21 | #pragma once 22 | 23 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | 25 | #include "NSDefines.hpp" 26 | #include "NSTypes.hpp" 27 | 28 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 29 | 30 | namespace NS 31 | { 32 | 33 | _NS_ENUM(Integer, ComparisonResult) { 34 | OrderedAscending = -1, 35 | OrderedSame = 0, 36 | OrderedDescending = 1, 37 | }; 38 | 39 | const Integer NotFound = IntegerMax; 40 | 41 | } 42 | 43 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 44 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/metal-cpp/Foundation/NSTypes.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Foundation/NSTypes.hpp 4 | // 5 | // Copyright 2020-2021 Apple Inc. 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // 19 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | 21 | #pragma once 22 | 23 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | 25 | #include "NSDefines.hpp" 26 | 27 | #include 28 | #include 29 | 30 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 31 | 32 | namespace NS 33 | { 34 | using TimeInterval = double; 35 | 36 | using Integer = std::intptr_t; 37 | using UInteger = std::uintptr_t; 38 | 39 | const Integer IntegerMax = INTPTR_MAX; 40 | const Integer IntegerMin = INTPTR_MIN; 41 | const UInteger UIntegerMax = UINTPTR_MAX; 42 | 43 | struct OperatingSystemVersion 44 | { 45 | Integer majorVersion; 46 | Integer minorVersion; 47 | Integer patchVersion; 48 | } _NS_PACKED; 49 | } 50 | 51 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 52 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/metal-cpp/Metal/MTLDefines.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Metal/MTLDefines.hpp 4 | // 5 | // Copyright 2020-2021 Apple Inc. 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // 19 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | 21 | #pragma once 22 | 23 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 24 | 25 | #include "../Foundation/NSDefines.hpp" 26 | 27 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 28 | 29 | #define _MTL_EXPORT _NS_EXPORT 30 | #define _MTL_EXTERN _NS_EXTERN 31 | #define _MTL_INLINE _NS_INLINE 32 | #define _MTL_PACKED _NS_PACKED 33 | 34 | #define _MTL_CONST(type, name) _NS_CONST(type, name) 35 | #define _MTL_ENUM(type, name) _NS_ENUM(type, name) 36 | #define _MTL_OPTIONS(type, name) _NS_OPTIONS(type, name) 37 | 38 | #define _MTL_VALIDATE_SIZE(ns, name) _NS_VALIDATE_SIZE(ns, name) 39 | #define _MTL_VALIDATE_ENUM(ns, name) _NS_VALIDATE_ENUM(ns, name) 40 | 41 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 42 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/metal-cpp/Metal/MTLFence.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Metal/MTLFence.hpp 4 | // 5 | // Copyright 2020-2021 Apple Inc. 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // 19 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | 21 | #pragma once 22 | 23 | #include "MTLDefines.hpp" 24 | #include "MTLHeaderBridge.hpp" 25 | #include "MTLPrivate.hpp" 26 | 27 | #include 28 | 29 | namespace MTL 30 | { 31 | class Fence : public NS::Referencing 32 | { 33 | public: 34 | class Device* device() const; 35 | 36 | NS::String* label() const; 37 | void setLabel(const NS::String* label); 38 | }; 39 | 40 | } 41 | 42 | // property: device 43 | _MTL_INLINE MTL::Device* MTL::Fence::device() const 44 | { 45 | return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); 46 | } 47 | 48 | // property: label 49 | _MTL_INLINE NS::String* MTL::Fence::label() const 50 | { 51 | return Object::sendMessage(this, _MTL_PRIVATE_SEL(label)); 52 | } 53 | 54 | _MTL_INLINE void MTL::Fence::setLabel(const NS::String* label) 55 | { 56 | Object::sendMessage(this, _MTL_PRIVATE_SEL(setLabel_), label); 57 | } 58 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Metal/metal-cpp/Metal/MTLFunctionHandle.hpp: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 2 | // 3 | // Metal/MTLFunctionHandle.hpp 4 | // 5 | // Copyright 2020-2021 Apple Inc. 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); 8 | // you may not use this file except in compliance with the License. 9 | // You may obtain a copy of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, 15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | // See the License for the specific language governing permissions and 17 | // limitations under the License. 18 | // 19 | //------------------------------------------------------------------------------------------------------------------------------------------------------------- 20 | 21 | #pragma once 22 | 23 | #include "MTLDefines.hpp" 24 | #include "MTLHeaderBridge.hpp" 25 | #include "MTLPrivate.hpp" 26 | 27 | #include 28 | 29 | #include "MTLLibrary.hpp" 30 | 31 | namespace MTL 32 | { 33 | class FunctionHandle : public NS::Referencing 34 | { 35 | public: 36 | MTL::FunctionType functionType() const; 37 | 38 | NS::String* name() const; 39 | 40 | class Device* device() const; 41 | }; 42 | 43 | } 44 | 45 | // property: functionType 46 | _MTL_INLINE MTL::FunctionType MTL::FunctionHandle::functionType() const 47 | { 48 | return Object::sendMessage(this, _MTL_PRIVATE_SEL(functionType)); 49 | } 50 | 51 | // property: name 52 | _MTL_INLINE NS::String* MTL::FunctionHandle::name() const 53 | { 54 | return Object::sendMessage(this, _MTL_PRIVATE_SEL(name)); 55 | } 56 | 57 | // property: device 58 | _MTL_INLINE MTL::Device* MTL::FunctionHandle::device() const 59 | { 60 | return Object::sendMessage(this, _MTL_PRIVATE_SEL(device)); 61 | } 62 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLBuffer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/27/21. 3 | // 4 | #include "OpenGLBuffer.h" 5 | #include "rcpch.h" 6 | 7 | #include <../include/glad/glad.h> 8 | 9 | namespace RcEngine{ 10 | OpenGLVertexBuffer::OpenGLVertexBuffer(uint32_t count) { 11 | RC_PROFILE_FUNCTION(); 12 | glShadeModel(GL_FLAT); 13 | glGenBuffers(1, &m_RendererID); 14 | glBindBuffer(GL_ARRAY_BUFFER,m_RendererID); 15 | glBufferData(GL_ARRAY_BUFFER, count, nullptr, GL_DYNAMIC_DRAW); 16 | } 17 | OpenGLVertexBuffer::OpenGLVertexBuffer(float* vertices, uint32_t size) 18 | { 19 | RC_PROFILE_FUNCTION(); 20 | glGenBuffers(1, &m_RendererID); 21 | glBindBuffer(GL_ARRAY_BUFFER,m_RendererID); 22 | glBufferData(GL_ARRAY_BUFFER, size, vertices, GL_STATIC_DRAW); 23 | 24 | } 25 | OpenGLVertexBuffer::~OpenGLVertexBuffer(){ 26 | RC_PROFILE_FUNCTION(); 27 | glDeleteBuffers(1, &m_RendererID); 28 | } 29 | void OpenGLVertexBuffer::SetData(const void *data, uint32_t size) { 30 | glBindBuffer(GL_ARRAY_BUFFER, m_RendererID); 31 | glBufferSubData(GL_ARRAY_BUFFER,0, size ,data); 32 | } 33 | void OpenGLVertexBuffer::Bind() const { 34 | RC_PROFILE_FUNCTION(); 35 | glBindBuffer(GL_ARRAY_BUFFER,m_RendererID); 36 | } 37 | void OpenGLVertexBuffer::Unbind() const { 38 | RC_PROFILE_FUNCTION(); 39 | glBindBuffer(GL_ARRAY_BUFFER,0); 40 | } 41 | 42 | //----------------------------------------------------------------------------------- 43 | //Index Buffer----------------------------------------------------------------------- 44 | //----------------------------------------------------------------------------------- 45 | 46 | OpenGLIndexBuffer::OpenGLIndexBuffer(uint32_t *indices, uint32_t count) 47 | :m_Count(count){ 48 | RC_PROFILE_FUNCTION(); 49 | glGenBuffers(1, &m_RendererID); 50 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,m_RendererID); 51 | glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(uint32_t), indices, GL_STATIC_DRAW); 52 | } 53 | OpenGLIndexBuffer::~OpenGLIndexBuffer() { 54 | RC_PROFILE_FUNCTION(); 55 | glDeleteBuffers(1, &m_RendererID); 56 | } 57 | void OpenGLIndexBuffer::Bind() const { 58 | RC_PROFILE_FUNCTION(); 59 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_RendererID); 60 | } 61 | void OpenGLIndexBuffer::Unbind() const { 62 | RC_PROFILE_FUNCTION(); 63 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0); 64 | } 65 | } -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/27/21. 3 | // 4 | #pragma once 5 | 6 | #include "RcEngine/Renderer/Buffer.h" 7 | #define GL_SILENCE_DEPRECATION 8 | 9 | namespace RcEngine{ 10 | class OpenGLVertexBuffer: public VertexBuffer{ 11 | public: 12 | OpenGLVertexBuffer(float* vertices, uint32_t size); 13 | OpenGLVertexBuffer(uint32_t count); 14 | virtual ~OpenGLVertexBuffer(); 15 | 16 | virtual void Bind() const override; 17 | virtual void Unbind() const override; 18 | 19 | virtual void SetData(const void* data, uint32_t size) override; 20 | 21 | virtual void SetLayout(const BufferLayout& layout) override { m_Layout = layout; } 22 | virtual const BufferLayout& GetLayout() const override{return m_Layout;} 23 | private: 24 | uint32_t m_RendererID; 25 | BufferLayout m_Layout; 26 | }; 27 | 28 | class OpenGLIndexBuffer: public IndexBuffer{ 29 | public: 30 | OpenGLIndexBuffer(uint32_t* indices, uint32_t count); 31 | virtual ~OpenGLIndexBuffer(); 32 | 33 | virtual void Bind() const override; 34 | virtual void Unbind() const override; 35 | virtual uint32_t GetCount() const override{return m_Count; } 36 | private: 37 | uint32_t m_RendererID; 38 | uint32_t m_Count; 39 | }; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLContext.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/25/21. 3 | // 4 | #include "rcpch.h" 5 | #include "OpenGLContext.h" 6 | 7 | 8 | #include <../external/GLFW/include/GLFW/glfw3.h> 9 | #include <../include/glad/glad.h> 10 | 11 | namespace RcEngine{ 12 | OpenGLContext::OpenGLContext(GLFWwindow *windowHandle) 13 | :m_WindowHandle(windowHandle) 14 | { 15 | RC_CORE_ASSERT(m_WindowHandle, "Window is null"); 16 | 17 | } 18 | void OpenGLContext::Init() { 19 | RC_PROFILE_FUNCTION(); 20 | 21 | glfwMakeContextCurrent(m_WindowHandle); 22 | int status = gladLoadGLLoader((GLADloadproc) glfwGetProcAddress); 23 | RC_CORE_ASSERT(status, "failed to init glad loader"); 24 | 25 | RC_CORE_INFO(" Opengl Renderer: {0}",glGetString(GL_VENDOR)); 26 | RC_CORE_INFO(" Vendor {0}", glGetString(GL_VERSION)); 27 | } 28 | void OpenGLContext::SwapBuffers() { 29 | RC_PROFILE_FUNCTION(); 30 | glfwSwapBuffers(m_WindowHandle); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLContext.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/25/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Renderer/GraphicsContext.h" 6 | 7 | 8 | struct GLFWwindow; 9 | 10 | namespace RcEngine{ 11 | 12 | class OpenGLContext: public GraphicsContext{ 13 | public: 14 | OpenGLContext(GLFWwindow* windowHandle); 15 | 16 | 17 | virtual void Init() override; 18 | virtual void SwapBuffers() override; 19 | private: 20 | GLFWwindow* m_WindowHandle; 21 | }; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLFrameBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/5/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Renderer/FrameBuffer.h" 6 | 7 | #ifndef RCENGINE_CLION_OPENGLFRAMEBUFFER_H 8 | #define RCENGINE_CLION_OPENGLFRAMEBUFFER_H 9 | namespace RcEngine { 10 | class OpenGLFramebuffer : public FrameBuffer { 11 | public: 12 | OpenGLFramebuffer(const FrameBufferSpec &spec); 13 | 14 | virtual ~OpenGLFramebuffer(); 15 | 16 | void Invalidate(); 17 | 18 | virtual void Bind() override; 19 | 20 | virtual void UnBind() override; 21 | 22 | virtual int ReadPixel(uint32_t attachmentidx, int x, int y) override; 23 | 24 | 25 | virtual void Resize(uint32_t width, uint32_t height) override; 26 | 27 | virtual uint32_t GetColorAttachmentRendererID(uint32_t index) const override { 28 | RC_CORE_ASSERT(index < m_ColorAttachments.size(),""); 29 | return m_ColorAttachments[index]; } 30 | 31 | virtual uint32_t GetRendererID() const override{return m_RendererID;} 32 | 33 | virtual const FrameBufferSpec &GetSpecification() const override { return m_Specification; } 34 | 35 | private: 36 | uint32_t m_RendererID =0; 37 | FrameBufferSpec m_Specification; 38 | 39 | std::vector m_ColorAttachmentSpecs; 40 | FramebufferTextureSpec m_DepthAttachmentSpec = FrameBufferTextureFormat::None; 41 | 42 | std::vector m_ColorAttachments; 43 | uint32_t m_DepthAttachment = 0; 44 | }; 45 | 46 | } 47 | #endif //RCENGINE_CLION_OPENGLFRAMEBUFFER_H 48 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLRenderAPI.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/30/21. 3 | // 4 | 5 | #include "rcpch.h" 6 | #include "OpenGLRenderAPI.h" 7 | 8 | #include <../include/glad/glad.h> 9 | 10 | namespace RcEngine{ 11 | void OpenGLRenderAPI::Init() { 12 | RC_PROFILE_FUNCTION(); 13 | 14 | glEnable(GL_DEBUG_OUTPUT); 15 | 16 | glEnable(GL_DEPTH_TEST); 17 | glEnable(GL_BLEND); 18 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 19 | 20 | } 21 | void OpenGLRenderAPI::SetViewport(uint32_t x, uint32_t y,uint32_t width,uint32_t height) { 22 | glViewport(x,y,width, height); 23 | } 24 | 25 | void OpenGLRenderAPI::SetClearColor(const glm::vec4 &color) { 26 | glClearColor(color.r,color.g,color.b,color.a); 27 | } 28 | void OpenGLRenderAPI::Clear() { 29 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT); 30 | } 31 | void OpenGLRenderAPI::DrawIndexed(const Ref& vertexArray, uint32_t indexCount) { 32 | uint32_t count = indexCount ? vertexArray->GetIndexBuffer()->GetCount() : indexCount; 33 | glDrawElements(GL_TRIANGLES, 34 | count,GL_UNSIGNED_INT,nullptr); 35 | glBindTexture(GL_TEXTURE_2D,0); 36 | } 37 | } -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLRenderAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/30/21. 3 | // 4 | #pragma once 5 | 6 | #include "RcEngine/Renderer/RenderAPI.h" 7 | 8 | #ifndef RCENGINE_CLION_OPENGLRENDERAPI_H 9 | #define RCENGINE_CLION_OPENGLRENDERAPI_H 10 | 11 | namespace RcEngine{ 12 | class OpenGLRenderAPI: public RenderAPI{ 13 | virtual void Init() override; 14 | 15 | virtual void SetViewport(uint32_t x, uint32_t y,uint32_t width,uint32_t height) override; 16 | 17 | virtual void Clear() override; 18 | virtual void SetClearColor(const glm::vec4& color)override; 19 | 20 | virtual void DrawIndexed(const Ref& vertexArray, uint32_t indexCount =0) override; 21 | }; 22 | } 23 | 24 | #endif //RCENGINE_CLION_OPENGLRENDERAPI_H 25 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLShader.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/17/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Renderer/Shader.h" 6 | #include 7 | //#include 8 | typedef unsigned int GLenum; 9 | 10 | #ifndef RCENGINE_CLION_OPENGLSHADER_H 11 | #define RCENGINE_CLION_OPENGLSHADER_H 12 | 13 | typedef uint32_t RendererID; 14 | namespace RcEngine{ 15 | 16 | class OpenGLShader:public Shader{ 17 | public: 18 | OpenGLShader(const std::string& name, const std::string& vertexSrc, const std::string& fragmentSrc); 19 | OpenGLShader(const std::string& filepath); 20 | 21 | virtual ~OpenGLShader(); 22 | 23 | virtual const std::string& GetName() const override{ 24 | return m_Name; 25 | }; 26 | 27 | virtual void Bind() const override; 28 | virtual void Unbind() const override; 29 | 30 | virtual void SetFloat(const std::string& name, const float value) override; 31 | virtual void SetInt(const std::string& name, const int value) override; 32 | virtual void SetIntArray(const std::string& name, int* values, uint32_t count) override; 33 | 34 | virtual void SetFloat3(const std::string& name, const glm::vec3& value) override; 35 | virtual void SetFloat4(const std::string& name, const glm::vec4& value) override; 36 | virtual void SetMat4(const std::string& name, const glm::mat4& value) override; 37 | 38 | void UploadUniformInt(const std::string& name, const int value); 39 | void UploadUniformIntArray(const std::string &name, int* values, uint32_t count); 40 | 41 | void UploadUniformMat3(const std::string& name, const glm::mat3& matrix); 42 | void UploadUniformMat4(const std::string& name, const glm::mat4& matrix); 43 | 44 | void UploadUniformFloat(const std::string& name, const float values); 45 | void UploadUniformFloat2(const std::string& name, const glm::vec2& values); 46 | void UploadUniformFloat3(const std::string& name, const glm::vec3& values); 47 | void UploadUniformFloat4(const std::string& name, const glm::vec4& values); 48 | 49 | void UploadSampler(const char* name); 50 | private: 51 | std::string ReadFile(const std::string& filepath); 52 | std::unordered_map PreProcess(const std::string& source); 53 | void Compile(const std::unordered_map& shaderSource); 54 | private: 55 | RendererID m_RendererID; 56 | std::string m_Name; 57 | }; 58 | } 59 | 60 | #endif //RCENGINE_CLION_OPENGLSHADER_H 61 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLTexture.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/19/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Renderer/Texture.h" 6 | #include 7 | 8 | #ifndef RCENGINE_CLION_OPENGLTEXTURE_H 9 | #define RCENGINE_CLION_OPENGLTEXTURE_H 10 | 11 | 12 | namespace RcEngine{ 13 | class OpenGLTexture2D: public Texture2D { 14 | public: 15 | OpenGLTexture2D(uint32_t width, uint32_t height); 16 | OpenGLTexture2D(const char* path); 17 | 18 | void CreateCubeMap(bool with_mipmap); 19 | 20 | virtual ~OpenGLTexture2D(); 21 | 22 | virtual void SetData(void* data, uint32_t size, uint32_t slot =0) const override; 23 | 24 | virtual uint32_t GetHeight() const override{return m_Height;} 25 | virtual uint32_t GetWidth() const override{return m_Width;} 26 | virtual uint32_t GetRendererID() const override {return m_RendererID;} 27 | 28 | virtual void Bind(uint32_t slot = 0) const override; 29 | 30 | virtual bool operator==(const Texture& other) const override{ 31 | return m_RendererID == ((OpenGLTexture2D&)other).m_RendererID; 32 | } 33 | virtual std::string getPath() const override{return m_Path;} 34 | 35 | private: 36 | std::string m_Path; 37 | uint32_t m_Width, m_Height; 38 | uint32_t m_RendererID; 39 | GLenum m_InternalFormat, m_DataFormat; 40 | }; 41 | } 42 | 43 | 44 | #endif //RCENGINE_CLION_OPENGLTEXTURE_H 45 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLUniformBuffer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/2/21. 3 | // 4 | #include "rcpch.h" 5 | #include "OpenGLUniformBuffer.h" 6 | 7 | #include 8 | 9 | namespace RcEngine{ 10 | 11 | OpenGlUniformBuffer::OpenGlUniformBuffer(uint32_t size, uint32_t binding) { 12 | glGenBuffers(1, &m_RendererID); 13 | glBindBuffer(GL_UNIFORM_BUFFER,m_RendererID); 14 | glBufferData(GL_UNIFORM_BUFFER,size,nullptr,GL_DYNAMIC_DRAW); 15 | glBindBufferBase(GL_UNIFORM_BUFFER,binding,m_RendererID); 16 | 17 | } 18 | 19 | OpenGlUniformBuffer::~OpenGlUniformBuffer() { 20 | glDeleteBuffers(1,&m_RendererID); 21 | } 22 | 23 | void OpenGlUniformBuffer::SetData(const void *data, uint32_t size, uint32_t offset) { 24 | glBufferSubData(m_RendererID,offset,size,data); 25 | } 26 | } -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLUniformBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/2/21. 3 | // 4 | #pragma once 5 | 6 | #include "RcEngine/Renderer/UniformBuffer.h" 7 | 8 | #ifndef RCENGINE_OPENGLUNIFORMBUFFER_H 9 | #define RCENGINE_OPENGLUNIFORMBUFFER_H 10 | namespace RcEngine{ 11 | class OpenGlUniformBuffer: public UniformBuffer{ 12 | public: 13 | OpenGlUniformBuffer(uint32_t size, uint32_t binding); 14 | virtual ~OpenGlUniformBuffer(); 15 | 16 | virtual void SetData(const void* data, uint32_t size, uint32_t offset =0) override; 17 | private: 18 | uint32_t m_RendererID =0; 19 | }; 20 | } 21 | #endif //RCENGINE_OPENGLUNIFORMBUFFER_H 22 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/28/21. 3 | // 4 | 5 | #pragma once 6 | 7 | #include "rcpch.h" 8 | #include 9 | 10 | #include <../external/GLFW/include/GLFW/glfw3.h> 11 | 12 | namespace RcEngine{ 13 | class FileDialog{ 14 | public: 15 | static std::string OpenFile(const char* filter); 16 | static std::string SaveFile(const char* filter); 17 | }; 18 | class OpenGLUtils{ 19 | public: 20 | OpenGLUtils(); 21 | static void displayComputerShaderLimits(); 22 | static bool CheckOpenGLError(); 23 | 24 | static void checkOpenGLErrors(); 25 | 26 | static void PrintShaderLog(unsigned int shader); 27 | static void printProgramLog(int prog); 28 | 29 | static unsigned int loadTexture(const char *texImagePath); 30 | static unsigned int loadCubeMap(const char *mapDir); 31 | 32 | static std::string readShaderFile(const char* filepath); 33 | 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/OpenGL/OpenGLVertexArray.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/29/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Renderer/VertexArray.h" 6 | 7 | #ifndef RCENGINE_CLION_OPENGLVERTEXARRAY_H 8 | #define RCENGINE_CLION_OPENGLVERTEXARRAY_H 9 | 10 | namespace RcEngine{ 11 | class OpenGLVertexArray: public VertexArray{ 12 | public: 13 | OpenGLVertexArray(); 14 | virtual ~OpenGLVertexArray(); 15 | 16 | virtual void Bind() const override; 17 | 18 | virtual void Unbind() const override; 19 | 20 | virtual void AddVertexBuffer(const Ref& vertexBuffer)override ; 21 | virtual void SetIndexBuffer(const Ref& indexBuffer)override ; 22 | 23 | virtual const std::vector> & GetVertexBuffers() const override{return m_VertexBuffers;}; 24 | virtual const Ref & GetIndexBuffer() const override{return m_IndexBuffer;}; 25 | 26 | private: 27 | RendererID m_RendererID; 28 | uint32_t m_VertexBufferIndex = 0; 29 | std::vector> m_VertexBuffers; 30 | std::shared_ptr m_IndexBuffer; 31 | 32 | }; 33 | } 34 | 35 | 36 | #endif //RCENGINE_CLION_OPENGLVERTEXARRAY_H 37 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Vulkan/VKBuffer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/18/21. 3 | // 4 | #include "Platform/Vulkan/VKBuffer.h" 5 | #include "vulkan/vulkan_core.h" 6 | 7 | const std::vector validationLayers = { 8 | "VK_LAYER_KHRONOS_validation" 9 | }; 10 | 11 | #ifdef NDEBUG 12 | const bool enableValidationLayers = false; 13 | #else 14 | const bool enableValidationLayers = true; 15 | #endif 16 | 17 | namespace RcEngine{ 18 | 19 | } 20 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Vulkan/VKBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/18/21. 3 | // 4 | 5 | #ifndef RCENGINE_VKBUFFER_H 6 | #define RCENGINE_VKBUFFER_H 7 | #include "RcEngine/Renderer/Buffer.h" 8 | 9 | 10 | 11 | namespace RcEngine{ 12 | class VKVertexBuffer: public VertexBuffer{ 13 | 14 | }; 15 | class VKIndexBuffer: public IndexBuffer{ 16 | 17 | }; 18 | } 19 | 20 | #endif //RCENGINE_VKBUFFER_H 21 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Vulkan/VKTexture.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 1/23/22. 3 | // 4 | 5 | #include "VKTexture.h" 6 | #include 7 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Vulkan/VKTexture.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 1/23/22. 3 | // 4 | 5 | #ifndef RCENGINE_VKTEXTURE_H 6 | #define RCENGINE_VKTEXTURE_H 7 | #pragma once 8 | #include "vulkan/vulkan_core.h" 9 | #include "RcEngine/Renderer/Texture.h" 10 | 11 | 12 | namespace RcEngine{ 13 | struct UploadContext{ 14 | VkFence _uploadFence; 15 | VkCommandPool _commandPool; 16 | VkCommandBuffer _commandBuffer; 17 | }; 18 | class VKTexture2D : Texture2D{ 19 | public: 20 | VKTexture2D(uint32_t width, uint32_t height); 21 | VKTexture2D(const char* path); 22 | 23 | 24 | virtual ~VKTexture2D(); 25 | 26 | virtual void SetData(void* data, uint32_t size, uint32_t slot =0) const override; 27 | 28 | virtual uint32_t GetHeight() const override{return m_Height;} 29 | virtual uint32_t GetWidth() const override{return m_Width;} 30 | virtual uint32_t GetRendererID() const override {return m_RendererID;} 31 | 32 | virtual void Bind(uint32_t slot = 0) const override; 33 | 34 | virtual bool operator==(const Texture& other) const override{ 35 | return m_RendererID == ((VKTexture2D&)other).m_RendererID; 36 | } 37 | virtual std::string getPath() const override{return m_Path;} 38 | 39 | private: 40 | std::string m_Path; 41 | uint32_t m_Width, m_Height; 42 | uint32_t m_RendererID; 43 | UploadContext _uploadContext; 44 | }; 45 | } 46 | #endif //RCENGINE_VKTEXTURE_H 47 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Vulkan/VKUniformBuffer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 11/24/21. 3 | // 4 | 5 | #include "VKUniformBuffer.h" 6 | 7 | namespace RcEngine{ 8 | VulkanUniformBuffer::VulkanUniformBuffer(uint32_t size, uint32_t binding) { 9 | bindingDescription.binding = binding; 10 | bindingDescription.stride = size; 11 | bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; 12 | 13 | 14 | 15 | } 16 | VulkanUniformBuffer::~VulkanUniformBuffer() { 17 | 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /RcEngine/src/Platform/Vulkan/VKUniformBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 11/24/21. 3 | // 4 | 5 | #ifndef RCENGINE_VKUNIFORMBUFFER_H 6 | #define RCENGINE_VKUNIFORMBUFFER_H 7 | 8 | #include "RcEngine/Renderer/UniformBuffer.h" 9 | #include 10 | 11 | namespace RcEngine{ 12 | class VulkanUniformBuffer: public UniformBuffer{ 13 | VulkanUniformBuffer(uint32_t size, uint32_t binding); 14 | virtual ~VulkanUniformBuffer(); 15 | 16 | virtual void SetData(const void* data, uint32_t size, uint32_t offset =0) override; 17 | 18 | private: 19 | VkVertexInputBindingDescription bindingDescription; 20 | }; 21 | } 22 | #endif //RCENGINE_VKUNIFORMBUFFER_H 23 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Vulkan/VKUtils.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 11/24/21. 3 | // 4 | 5 | #include "VKUtils.h" 6 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Vulkan/VKUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 11/24/21. 3 | // 4 | 5 | #ifndef RCENGINE_VKUTILS_H 6 | #define RCENGINE_VKUTILS_H 7 | 8 | #endif //RCENGINE_VKUTILS_H 9 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Windows/WindowsWindow.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/23/21. 3 | // 4 | // 5 | // Created by Tristan Zippert on 5/22/21. 6 | // 7 | 8 | 9 | #include "RcEngine/Core/Window.h" 10 | #include "RcEngine/Renderer//GraphicsContext.h" 11 | 12 | #include 13 | #include 14 | 15 | namespace RcEngine{ 16 | class WindowsWindow: public Window{ 17 | public: 18 | WindowsWindow(const WindowProps & props); 19 | virtual ~WindowsWindow(); 20 | 21 | void OnUpdate() override; 22 | 23 | inline unsigned int GetWidth() const override {return m_Data.Width; } 24 | inline unsigned int GetHeight() const override {return m_Data.Height; } 25 | 26 | //Window attributes 27 | 28 | inline void SetEventCallback(const EventCallbackfn& callback) override {m_Data.EventCallback = callback; } 29 | void SetVSync(bool enabled) override; 30 | bool IsVsync() const override; 31 | 32 | virtual void* GetNativeWindow() const { return m_Window; } 33 | private: 34 | virtual void Init(const WindowProps& props); 35 | virtual void Shutdown(); 36 | private: 37 | GLFWwindow* m_Window; 38 | Scope m_Context; 39 | 40 | struct WindowData{ 41 | std::string Title; 42 | unsigned int Width, Height; 43 | bool VSync; 44 | 45 | EventCallbackfn EventCallback; 46 | }; 47 | WindowData m_Data; 48 | }; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /RcEngine/src/Platform/Windows/processordetection.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/13/21. 3 | // 4 | 5 | #pragma once 6 | #include "Platform/processordetection.h" 7 | 8 | namespace RcEngine{ 9 | std::string ProcessorDetectionBase::getCPUString() { 10 | std::string vendor; 11 | int reg[4]; 12 | __asm__ __volatile__ ("mov $0x80000002 , %eax\n\t"); 13 | __asm__ __volatile__ ( 14 | "cpuid" 15 | : "=a"(reg[0]),"=b"(reg[1]),"=c"(reg[2]),"=d"(reg[3]) 16 | ); 17 | for (int & i : reg) { 18 | vendor += std::string((const char *)&i, 4); 19 | } 20 | return vendor; 21 | } 22 | 23 | int32_t ProcessorDetectionBase::getCPUMaxFreq() { 24 | return 0; 25 | } 26 | } -------------------------------------------------------------------------------- /RcEngine/src/Platform/processordetection.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/11/21. 3 | // 4 | #pragma once 5 | #ifndef RCENGINE_PROCESSORDETECTION_H 6 | #define RCENGINE_PROCESSORDETECTION_H 7 | namespace RcEngine{ 8 | class ProcessorDetectionBase{ 9 | public: 10 | static std::string getCPUString(); 11 | static int32_t getCPUMaxFreq() ; 12 | }; 13 | } 14 | #endif //RCENGINE_PROCESSORDETECTION_H 15 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/20/21. 3 | // 4 | #pragma once 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | #include "RcEngine/Scene/Scene.h" 27 | #include "RcEngine/Scene/Entity.h" 28 | #include "RcEngine/Scene/ScriptableEntity.h" 29 | #include "RcEngine/Scene/Component.h" 30 | 31 | ///CORE//////////////////////////////// 32 | #include "RcEngine/Core/Application.h" 33 | #include "RcEngine/Core/Log.h" 34 | #include "RcEngine/Core/Layer.h" 35 | 36 | #include "RcEngine/Core/Timestep.h" 37 | #include "RcEngine/Core/MouseButtonCodes.h" 38 | #include "RcEngine/Core/keycodes.h" 39 | #include "RcEngine/Core/Input.h" 40 | /////////////////////////////////////// 41 | 42 | #include "RcEngine/ImGui/ImGuiLayer.h" 43 | 44 | ///Renderer//////////////////////////// 45 | #include "RcEngine/Renderer/Renderer.h" 46 | #include "RcEngine/Renderer/RenderCommand.h" 47 | #include "RcEngine/Renderer/RenderAPI.h" 48 | #include "RcEngine/Renderer/Buffer.h" 49 | #include "RcEngine/Renderer/FrameBuffer.h" 50 | 51 | #include "RcEngine/Renderer/Shader.h" 52 | #include "RcEngine/Renderer/VertexArray.h" 53 | #include "RcEngine/Renderer/GraphicsContext.h" 54 | #include "RcEngine/Renderer/OrthoCamera.h" 55 | #include "RcEngine/Renderer/Texture.h" 56 | #include "RcEngine/Renderer/SubTexture2D.h" 57 | #include "RcEngine/Renderer/OrthoCameraController.h" 58 | #include "RcEngine/Renderer/IsoCameraController.h" 59 | #include "RcEngine/Renderer/Renderer2D.h" 60 | #include "Platform/processordetection.h" 61 | /////////////////////////////////////// 62 | 63 | ///OPENGL////////////////////////////// 64 | #include "Platform/OpenGL/OpenGLUtils.h" 65 | /////////////////////////////////////// 66 | 67 | ///Network///////////////////////////// 68 | #include "RcEngine/Network/Network.h" 69 | /////////////////////////////////////// 70 | 71 | ///LUA///////////////////////////////// 72 | #include "RcEngine/Lua/luastate.h" 73 | /////////////////////////////////////// -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/Application.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/21/21. 3 | // 4 | #pragma once 5 | 6 | #include "Core.h" 7 | #include "LayerStack.h" 8 | #include "Window.h" 9 | #include "RcEngine/Events/ApplicationEvent.h" 10 | 11 | #include "RcEngine/ImGui/ImGuiLayer.h" 12 | 13 | #include "RcEngine/Renderer/Shader.h" 14 | #include "RcEngine/Renderer/Buffer.h" 15 | #include "RcEngine/Renderer/VertexArray.h" 16 | 17 | #include "RcEngine/Renderer/OrthoCamera.h" 18 | 19 | #include "RcEngine/Core/Timestep.h" 20 | 21 | namespace RcEngine{ 22 | class RC_API Application{ 23 | public: 24 | Application(const std::string& name = "RcEngine"); 25 | virtual ~Application(); 26 | 27 | void Run(); 28 | 29 | void OnEvent(Event& e); 30 | bool OnWindowClosed(WindowCloseEvent& e); 31 | bool OnWindowResize(WindowResizeEvent& e ); 32 | 33 | void PushLayer(Layer* layer); 34 | void PushOverlay(Layer* layer); 35 | 36 | inline static Application& Get() {return *s_Instance;} 37 | inline Window& GetWindow(){return *m_Window;} 38 | 39 | void Close(); 40 | 41 | ImGuiLayer* GetImGuiLayer() { return m_ImGuiLayer; } 42 | private: 43 | static Application* s_Instance; 44 | 45 | ImGuiLayer* m_ImGuiLayer; 46 | 47 | Ref m_Window; 48 | bool m_Running = true; 49 | LayerStack m_LayerStack; 50 | bool m_Minimized = false; 51 | float m_LastFrameTime= 0.0f; 52 | 53 | 54 | }; 55 | // Client defined 56 | Application* CreateApplication(); 57 | } 58 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/Assert.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/21/21. 3 | // 4 | #pragma once 5 | #include 6 | 7 | #ifdef RC_ENABLE_ASSERT 8 | #define RC_ASSERT(...) 9 | #define RC_CORE_ASSERT(...) 10 | #else 11 | #define RC_ASSERT(...) 12 | #define RC_CORE_ASSERT(...) 13 | #endif -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/Core.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/21/21. 3 | // 4 | #pragma once 5 | #include 6 | 7 | #ifdef _MSC_VER 8 | #define DEBUG_BREAK __debugbreak() 9 | #elif defined( __clang__ ) 10 | #if __has_builtin(__builtin_debugtrap) 11 | #define DEBUG_BREAK __builtin_debugtrap() 12 | #else 13 | #define DEBUG_BREAK __builtin_trap() 14 | #endif 15 | #elif defined( __GNUC__ ) 16 | #define DEBUG_BREAK __builtin_trap() 17 | #else 18 | #error "OS not recognized" 19 | #endif 20 | 21 | #ifdef _WIN32 22 | #ifdef _WIN64 23 | #define RC_PLATFORM_WINDOWS 24 | #else 25 | #error "x32-86 bit builds not supported" 26 | #endif 27 | #elif defined(__APPLE__) || defined(__MACH__) 28 | #include 29 | 30 | #if TARGET_IPHONE_SIMULATOR == 1 31 | #error "IOS/IPHONE not supported" 32 | #elif TARGET_OS_IPHONE 33 | #define RC_PLATFORM_IOS 34 | #error "IOS not supported" 35 | #elif TARGET_OS_MAC 36 | #define RC_PLATFORM_MAC 37 | #else 38 | #error "Unknown APPLE" 39 | #endif 40 | #endif 41 | 42 | #ifdef RC_PLATFORM_WINDOWS 43 | #ifdef RC_BUILD_DLL 44 | #define RC_API __declspec(dllexport) 45 | #else 46 | #define RC_API __declspec(dllimport) 47 | #endif 48 | #else 49 | #ifdef RC_BUILD_DLL 50 | #define RC_API __attribute__ ((visibility ("default"))) 51 | // #define DLL_LOCAL __attribute__ ((visibility ("hidden"))) 52 | #else 53 | #define RC_API 54 | // #define DLL_LOCAL 55 | #endif 56 | #endif 57 | 58 | #ifdef RC_DEBUG 59 | #define RC_ENABLE_ASSERTS 60 | #endif 61 | 62 | #ifdef RC_ENABLE_ASSERTS 63 | #define RC_ASSERT(x, ...) {if(!(x)){RC_ERROR("Assertion Failed: {0}",__VA_ARGS__); DEBUG_BREAK; }} 64 | #define RC_CORE_ASSERT(x, ...) {if(!(x)) {RC_CORE_ERROR("Assertion failed: {0}",__VA_ARGS__); DEBUG_BREAK;} } 65 | #else 66 | #define RC_ASSERT(x, ...) 67 | #define RC_CORE_ASSERT(x, ...) 68 | #endif 69 | 70 | #define RC_BIND_EVENT_TO_FUNCTION(fn) [this](auto&&... args) -> decltype(auto){return this->fn(std::forward(args)...);} 71 | 72 | namespace RcEngine{ 73 | template 74 | using Scope = std::unique_ptr; 75 | template 76 | constexpr Scope CreateScope(Args&& ...args){ 77 | return std::make_unique(std::forward(args)...); 78 | } 79 | template 80 | using Ref = std::shared_ptr; 81 | template 82 | using Ref = std::shared_ptr; 83 | 84 | template 85 | constexpr Ref CreateRef(Args&& ... args) 86 | { 87 | return std::make_shared(std::forward(args)...); 88 | } 89 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/EntryPoint.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/21/21. 3 | // 4 | #pragma once 5 | #include "RcEngine.h" 6 | #include "RcEngine/Core/Log.h" 7 | 8 | #ifdef RC_PLATFORM_WINDOWS 9 | extern RcEngine::Application* RcEngine::CreateApplication(); 10 | 11 | int main(int argc, char** argv){ 12 | RcEngine::Log::Init(); 13 | RC_CORE_WARN("Init log"); 14 | RC_PROFILE_BEGIN_SESSION("Startup","RCENGINE-Startup.json"); 15 | auto app = RcEngine::CreateApplication(); 16 | RC_PROFILE_END_SESSION(); 17 | RC_PROFILE_BEGIN_SESSION("Runtime","RCENGINE-runtime.json"); 18 | app->Run(); 19 | RC_PROFILE_END_SESSION(); 20 | RC_PROFILE_BEGIN_SESSION("Shutdown","RCENGINE-Shutdown.json"); 21 | delete app; 22 | RC_PROFILE_END_SESSION(); 23 | return 0; 24 | } 25 | #else 26 | extern RcEngine::Application* RcEngine::CreateApplication(); 27 | 28 | int main(int argc, char** argv){ 29 | RcEngine::Log::Init(); 30 | RC_CORE_WARN("Init log"); 31 | RC_PROFILE_BEGIN_SESSION("Startup","RCENGINE-Startup.json"); 32 | auto app = RcEngine::CreateApplication(); 33 | RC_PROFILE_END_SESSION(); 34 | RC_PROFILE_BEGIN_SESSION("Runtime","RCENGINE-runtime.json"); 35 | app->Run(); 36 | RC_PROFILE_END_SESSION(); 37 | RC_PROFILE_BEGIN_SESSION("Shutdown","RCENGINE-Shutdown.json"); 38 | delete app; 39 | RC_PROFILE_END_SESSION(); 40 | return 0; 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/Input.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/24/21. 3 | // 4 | 5 | #pragma once 6 | 7 | #include "RcEngine/Core/Core.h" 8 | 9 | namespace RcEngine{ 10 | class RC_API Input{ 11 | public: 12 | inline static bool IsKeyPressed(int keycode){return s_Instance->IsKeyPressedImpl(keycode);} 13 | 14 | inline static bool IsMouseButtonPressed(int button){return s_Instance->IsMouseButtonPressedImpl(button);} 15 | inline static float GetMouseX() {return s_Instance-> GetMouseXImpl();} 16 | inline static float GetMouseY() {return s_Instance->GetMouseYImpl(); } 17 | inline static std::pair GetMousePos() {return s_Instance->GetMousePosImpl(); } 18 | protected: 19 | virtual bool IsKeyPressedImpl(int keycode) =0; 20 | virtual bool IsMouseButtonPressedImpl(int button) = 0; 21 | virtual float GetMouseXImpl()=0; 22 | virtual float GetMouseYImpl()=0; 23 | virtual std::pair GetMousePosImpl()=0; 24 | 25 | 26 | private: 27 | static Input* s_Instance; 28 | }; 29 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/Layer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/23/21. 3 | // 4 | 5 | #include "Layer.h" 6 | #include "rcpch.h" 7 | 8 | namespace RcEngine{ 9 | Layer::Layer(const std::string& debugName) 10 | : m_DebugName(debugName){} 11 | 12 | Layer::~Layer(){ 13 | 14 | } 15 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/Layer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/23/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Core/Core.h" 6 | #include "RcEngine/Events/Event.h" 7 | #include "RcEngine/Core/Timestep.h" 8 | 9 | namespace RcEngine{ 10 | class RC_API Layer{ 11 | public: 12 | Layer(const std::string& name = "RCLayer"); 13 | virtual ~Layer(); 14 | 15 | virtual void OnAttach(){} 16 | virtual void OnDetach(){} 17 | virtual void OnUpdate(Timestep ts){} 18 | virtual void OnImGuiRender(){} 19 | 20 | virtual void OnEvent(Event& event){} 21 | 22 | inline const std::string& GetName() const{return m_DebugName; } 23 | 24 | protected: 25 | std::string m_DebugName; 26 | }; 27 | } 28 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/LayerStack.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/23/21. 3 | // 4 | 5 | #include "LayerStack.h" 6 | #include "rcpch.h" 7 | 8 | namespace RcEngine{ 9 | 10 | LayerStack::LayerStack(){ 11 | } 12 | 13 | LayerStack::~LayerStack(){ 14 | for (Layer* layer :m_Layers) 15 | delete layer; 16 | } 17 | void LayerStack::PushLayer(Layer* layer){ 18 | m_Layers.emplace(m_LayerInsertIndex + m_Layers.begin(), layer); 19 | m_LayerInsertIndex++; 20 | } 21 | void LayerStack::PopLayer(Layer *layer) { 22 | auto deletion = std::find(m_Layers.begin(),m_Layers.end(),layer); 23 | if(deletion != m_Layers.end()){ 24 | m_Layers.erase(deletion); 25 | m_LayerInsertIndex--; 26 | } 27 | } 28 | void LayerStack::PushOverlay(Layer *overlay) { 29 | //back to front starting at the main game layer 30 | m_Layers.emplace_back(overlay); 31 | } 32 | void LayerStack::PopOverlay(Layer *overlay) { 33 | auto delayer = std::find(m_Layers.begin(),m_Layers.end(),overlay); 34 | if(delayer != m_Layers.end()) 35 | m_Layers.erase(delayer); 36 | } 37 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/LayerStack.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/23/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Core/Core.h" 6 | #include "Layer.h" 7 | #include 8 | 9 | namespace RcEngine{ 10 | class RC_API LayerStack{ 11 | public: 12 | LayerStack(); 13 | ~LayerStack(); 14 | 15 | void PushLayer(Layer* layer); 16 | void PushOverlay(Layer* overlay); 17 | void PopLayer(Layer* layer); 18 | void PopOverlay(Layer* overlay); 19 | 20 | std::vector::iterator begin() { 21 | return m_Layers.begin(); 22 | } 23 | std::vector::iterator end() {return m_Layers.end();} 24 | private: 25 | std::vector m_Layers; 26 | unsigned int m_LayerInsertIndex=0; 27 | }; 28 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/Log.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/21/21. 3 | // 4 | #include 5 | #include 6 | #include 7 | #include "Log.h" 8 | 9 | 10 | namespace RcEngine{ 11 | std::shared_ptr Log::s_CoreLogger; 12 | std::shared_ptr Log::s_ClientLogger; 13 | std::shared_ptr Log::s_EditorConsoleLogger; 14 | 15 | void Log::Init() { 16 | spdlog::set_pattern("%^[%T] %n: %v%$"); 17 | s_CoreLogger = spdlog::stdout_color_mt("RCENGINE"); 18 | s_CoreLogger->set_level(spdlog::level::trace); 19 | 20 | s_ClientLogger = spdlog::stdout_color_mt("App"); 21 | s_ClientLogger->set_level(spdlog::level::trace); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/Log.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/21/21. 3 | // 4 | #pragma once 5 | 6 | #include "Core.h" 7 | #include 8 | #include "spdlog/fmt/ostr.h" 9 | #include "glm/gtx/string_cast.hpp" 10 | 11 | namespace RcEngine{ 12 | class RC_API Log{ 13 | public: 14 | static void Init(); 15 | 16 | inline static std::shared_ptr& GetCoreLogger(){return s_CoreLogger; } 17 | inline static std::shared_ptr& GetClientLogger(){return s_ClientLogger; } 18 | inline static std::shared_ptr& GetEditorConsoleLogger(){return s_EditorConsoleLogger;} 19 | private: 20 | static std::shared_ptr s_CoreLogger; 21 | static std::shared_ptr s_ClientLogger; 22 | static std::shared_ptr s_EditorConsoleLogger; 23 | }; 24 | } 25 | 26 | template 27 | inline OStream& operator << (OStream& os, const glm::vec& vector){ 28 | return os<< glm::to_string(vector); 29 | } 30 | template 31 | inline OStream& operator << (OStream& os, const glm::mat& matrix){ 32 | return os<< glm::to_string(matrix); 33 | } 34 | 35 | #define RC_CORE_ERROR(...) ::RcEngine::Log::GetClientLogger()->error(__VA_ARGS__) 36 | #define RC_CORE_WARN(...) ::RcEngine::Log::GetCoreLogger()->warn(__VA_ARGS__) 37 | #define RC_CORE_INFO(...) ::RcEngine::Log::GetCoreLogger()->info(__VA_ARGS__) 38 | #define RC_CORE_TRACE(...) ::RcEngine::Log::GetCoreLogger()->trace(__VA_ARGS__) 39 | //#define RC_CORE_FATAL(...) ::RcEngine::Log::GetCoreLogger()->error(__VA_ARGS__) 40 | 41 | //Client log macros 42 | 43 | #define RC_ERROR(...) ::RcEngine::Log::GetClientLogger()->error(__VA_ARGS__) 44 | #define RC_WARN(...) ::RcEngine::Log::GetClientLogger()->warn(__VA_ARGS__) 45 | #define RC_INFO(...) ::RcEngine::Log::GetClientLogger()->info(__VA_ARGS__) 46 | #define RC_TRACE(...) ::RcEngine::Log::GetClientLogger()->trace(__VA_ARGS__) 47 | //#define RC_FATAL(...) ::RcEngine::Log::GetClientLogger()->(__VA_ARGS__) 48 | 49 | //Editor Console logging macros 50 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/MouseButtonCodes.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/24/21. 3 | // 4 | 5 | #pragma once 6 | 7 | //from glfw.h 8 | #define RC_MOUSE_BUTTON_1 0 9 | #define RC_MOUSE_BUTTON_2 1 10 | #define RC_MOUSE_BUTTON_3 2 11 | #define RC_MOUSE_BUTTON_4 3 12 | #define RC_MOUSE_BUTTON_5 4 13 | #define RC_MOUSE_BUTTON_6 5 14 | #define RC_MOUSE_BUTTON_7 6 15 | #define RC_MOUSE_BUTTON_8 7 16 | #define RC_MOUSE_BUTTON_LAST RC_MOUSE_BUTTON_8 17 | #define RC_MOUSE_BUTTON_LEFT RC_MOUSE_BUTTON_1 18 | #define RC_MOUSE_BUTTON_RIGHT RC_MOUSE_BUTTON_2 19 | #define RC_MOUSE_BUTTON_MIDDLE RC_MOUSE_BUTTON_3 20 | 21 | namespace RcEngine{ 22 | using MouseCode = uint16_t; 23 | namespace Mouse{ 24 | enum: MouseCode{ 25 | // From glfw3.h 26 | Button0 = 0, 27 | Button1 = 1, 28 | Button2 = 2, 29 | Button3 = 3, 30 | Button4 = 4, 31 | Button5 = 5, 32 | Button6 = 6, 33 | Button7 = 7, 34 | 35 | ButtonLast = Button7, 36 | ButtonLeft = Button0, 37 | ButtonRight = Button1, 38 | ButtonMiddle = Button2 39 | }; 40 | } 41 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/Timestep.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/16/21. 3 | // 4 | #pragma once 5 | #ifndef RCENGINE_CLION_TIMESTEP_H 6 | #define RCENGINE_CLION_TIMESTEP_H 7 | 8 | namespace RcEngine{ 9 | class Timestep{ 10 | public: 11 | Timestep(float time=0.0f) 12 | :m_Time(time){ 13 | 14 | } 15 | float GetSeconds() const {return m_Time;} 16 | float GetMiliseconds() const {return m_Time * 1000.0f;} 17 | operator float() const {return m_Time;} 18 | private: 19 | float m_Time; 20 | }; 21 | } 22 | 23 | 24 | #endif //RCENGINE_CLION_TIMESTEP_H 25 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/UUID.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 10/14/21. 3 | // 4 | #include "rcpch.h" 5 | #include "UUID.h" 6 | 7 | #include 8 | #include 9 | 10 | static std::unordered_map m_map; 11 | 12 | static void AddToMap(){ 13 | m_map[RcEngine::UUID()] = "RcEngine"; 14 | } 15 | 16 | namespace RcEngine{ 17 | static std::random_device s_RandomDevice; 18 | static std::mt19937_64 s_Engine(s_RandomDevice()); 19 | static std::uniform_int_distribution s_UniformDistribution; 20 | 21 | UUID::UUID() 22 | : m_UUID(s_UniformDistribution(s_Engine)){ 23 | 24 | } 25 | 26 | UUID::UUID(uint64_t uuid) 27 | : m_UUID(uuid){ 28 | 29 | } 30 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/UUID.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 10/14/21. 3 | // 4 | #ifndef RCENGINE_UUID_H 5 | #define RCENGINE_UUID_H 6 | 7 | namespace RcEngine{ 8 | class UUID{ 9 | public: 10 | UUID(); 11 | UUID(uint64_t uuid); 12 | UUID(const UUID&) = default; 13 | 14 | operator uint64_t() const {return m_UUID;} 15 | private: 16 | uint64_t m_UUID; 17 | }; 18 | } 19 | namespace std{ 20 | template<> 21 | struct hash{ 22 | std::size_t operator() (const RcEngine::UUID& uuid)const{ 23 | return hash()((uint64_t)uuid); 24 | } 25 | }; 26 | } 27 | 28 | #endif //RCENGINE_UID_H 29 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/Window.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/6/21. 3 | // 4 | #include "rcpch.h" 5 | #include "RcEngine/Core/Window.h" 6 | 7 | #ifdef RC_PLATFORM_WINDOW 8 | #include "Platform/Windows/WindowsWindow.h" 9 | #endif 10 | 11 | #ifdef RC_PLATFORM_MAC 12 | #include "Platform/Mac/MacWindow.h" 13 | #endif 14 | 15 | namespace RcEngine{ 16 | Scope Window::Create(const WindowProps &props) { 17 | #ifdef RC_PLATFORM_WINDOWS 18 | return CreateScope(props); 19 | #endif 20 | 21 | #ifdef RC_PLATFORM_MAC 22 | return CreateScope(props); 23 | #endif 24 | 25 | RC_CORE_ASSERT(false, "Unknown platform!"); 26 | return nullptr; 27 | } 28 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Core/Window.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/22/21. 3 | // 4 | #pragma once 5 | #include "rcpch.h" 6 | 7 | #include "RcEngine/Core/Core.h" 8 | #include "RcEngine/Events/Event.h" 9 | 10 | namespace RcEngine{ 11 | struct WindowProps{ 12 | std::string Title; 13 | unsigned int Width; 14 | unsigned int Height; 15 | 16 | WindowProps(const std::string& title = "RC-ENGINE", 17 | unsigned int width = 1280, 18 | unsigned int height = 720) 19 | :Title(title),Width(width),Height(height){} 20 | }; 21 | class RC_API Window{ 22 | public: 23 | using EventCallbackfn = std::function; 24 | 25 | virtual ~Window(){} 26 | 27 | virtual void OnUpdate() = 0; 28 | 29 | virtual unsigned int GetWidth() const =0; 30 | virtual unsigned int GetHeight() const =0; 31 | 32 | //attributes 33 | virtual void SetEventCallback(const EventCallbackfn& callback) =0; 34 | virtual void SetVSync(bool enabled) =0; 35 | virtual bool IsVsync() const =0; 36 | static Scope Create(const WindowProps& props =WindowProps()); 37 | 38 | virtual void* GetNativeWindow() const = 0; 39 | }; 40 | } 41 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Editor/EditorConsole/EditorConsoleSink.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/20/21. 3 | // 4 | 5 | #ifndef RCENGINE_EDITORCONSOLESINK_H 6 | #define RCENGINE_EDITORCONSOLESINK_H 7 | 8 | #include "spdlog/sinks/base_sink.h" 9 | #include 10 | #include "RcEngine/Editor/EditorConsolePanel.h" 11 | 12 | namespace RcEngine{ 13 | class EditorConsoleSink: public spdlog::sinks::base_sink{ 14 | public: 15 | explicit EditorConsoleSink(uint32_t bufferCap) 16 | : m_MessageBufferCap(bufferCap), m_MessageBuffer(bufferCap){ 17 | } 18 | 19 | virtual ~EditorConsoleSink() = default; 20 | EditorConsoleSink(const EditorConsoleSink& other) = delete; 21 | EditorConsoleSink& operator =(const EditorConsoleSink& other) = delete; 22 | 23 | protected: 24 | void sink_it_(const spdlog::details::log_msg& msg) override{ 25 | spdlog::memory_buf_t formatted; 26 | spdlog::sinks::base_sink::formatter_->format(msg,formatted); 27 | m_MessageBuffer[m_MessageCount++] = ConsoleMessage(fmt::to_string(formatted,GetMessageCategory(msg.level))); 28 | 29 | if (m_MessageCount == m_MessageBufferCap) 30 | flush_(); 31 | } 32 | void flush_() override{ 33 | for(const auto& message: m_MessageBuffer){ 34 | if(message.GetCategory() == ConsoleMessage::Category::None) 35 | continue; 36 | 37 | EditorConsolePanel::PushMessage(message); 38 | } 39 | m_MessageCount =0; 40 | } 41 | private: 42 | static ConsoleMessage::Category GetMessageCategory(spdlog::level::level_enum level){ 43 | switch (level) { 44 | case spdlog::level::trace: 45 | case spdlog::level::debug: 46 | case spdlog::level::info: 47 | return ConsoleMessage::Category::Info; 48 | case spdlog::level::warn: 49 | return ConsoleMessage::Category::Warning; 50 | case spdlog::level::critical: 51 | return ConsoleMessage::Category::Error; 52 | } 53 | return ConsoleMessage::Category::None; 54 | } 55 | private: 56 | uint32_t m_MessageBufferCapacity; 57 | std::vector m_MessageBuffer; 58 | uint32_t m_MessageCount = 0; 59 | 60 | }; 61 | } 62 | 63 | #endif //RCENGINE_EDITORCONSOLESINK_H 64 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Editor/EditorConsolePanel.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/20/21. 3 | // 4 | 5 | #ifndef RCENGINE_EDITORCONSOLEPANEL_H 6 | #define RCENGINE_EDITORCONSOLEPANEL_H 7 | 8 | #endif //RCENGINE_EDITORCONSOLEPANEL_H 9 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Events/ApplicationEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/22/21. 3 | // 4 | 5 | #pragma once 6 | #include "Event.h" 7 | #include 8 | 9 | namespace RcEngine{ 10 | class RC_API WindowResizeEvent: public Event{ 11 | public: 12 | WindowResizeEvent(unsigned int width, unsigned int height) 13 | : m_Width(width), m_Height(height){} 14 | 15 | inline unsigned int GetWidth() const {return m_Width;} 16 | inline unsigned int GetHeight() const {return m_Height;} 17 | 18 | std::string ToString() const override{ 19 | std::stringstream stream; 20 | stream << "WindowResizeEvent(Width, Height): (" << m_Width << ", " << m_Height <<")"; 21 | return stream.str(); 22 | }; 23 | 24 | EVENT_CLASS_TYPE(WindowResize) 25 | 26 | EVENT_CLASS_CATEGORY(EventCategoryApplication) 27 | private: 28 | unsigned int m_Width, m_Height; 29 | }; 30 | class RC_API WindowCloseEvent : public Event{ 31 | public: 32 | WindowCloseEvent(){} 33 | 34 | EVENT_CLASS_CATEGORY(EventCategoryApplication) 35 | 36 | EVENT_CLASS_TYPE(WindowClose) 37 | }; 38 | class RC_API AppTickEvent: public Event{ 39 | public: 40 | AppTickEvent(){} 41 | 42 | EVENT_CLASS_TYPE(ApplicationTick) 43 | 44 | EVENT_CLASS_CATEGORY(EventCategoryApplication) 45 | }; 46 | class RC_API AppUpdateEvent: public Event{ 47 | public: 48 | AppUpdateEvent(){} 49 | 50 | EVENT_CLASS_TYPE(AppUpdate) 51 | 52 | EVENT_CLASS_CATEGORY(EventCategoryApplication) 53 | }; 54 | class RC_API AppRenderEvent: public Event{ 55 | public: 56 | AppRenderEvent(){} 57 | 58 | EVENT_CLASS_TYPE(AppRender) 59 | 60 | EVENT_CLASS_CATEGORY(EventCategoryApplication) 61 | }; 62 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Events/Event.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/22/21. 3 | // 4 | #pragma once 5 | 6 | #include "RcEngine/Core/Core.h" 7 | #include 8 | 9 | namespace RcEngine{ 10 | 11 | // Events arent buffered in any way and use a blocking system, in the future it should be 12 | // put into a Queue system 13 | 14 | enum class EventType{ 15 | None=0, WindowClose, WindowResize, WindowOnFocus,WindowOnLostFocus,WindowMoved, 16 | ApplicationTick, AppUpdate, AppRender, OnKeyPressed, OnKeyRelease, OnKeyTyped, 17 | MouseButtonPress, MouseButtonRelease, MouseMoved, MouseScrolled, 18 | }; 19 | 20 | // Bit-Shifted constant field values for bit masking 21 | enum EventCategory{ 22 | None = 0x00, 23 | EventCategoryApplication = 0x01, 24 | EventCategoryInput = 0x02, 25 | EventCategoryKeyboard = 0x04, 26 | EventCategoryMouse = 0x08, 27 | EventCategoryMouseButton= 0x10, 28 | }; 29 | 30 | #define EVENT_CLASS_TYPE(type) static EventType GetStaticType() {return EventType::type;} \ 31 | virtual EventType GetEventType() const override {return GetStaticType(); } \ 32 | virtual const char* GetName() const override {return #type; } 33 | 34 | #define EVENT_CLASS_CATEGORY(category) virtual int GetCategoryFlags() const override {return category;} 35 | 36 | class RC_API Event{ 37 | friend class EventDispatcher; 38 | public: 39 | virtual ~Event() = default; 40 | 41 | // Virtual for functions that have to be implemented 42 | virtual EventType GetEventType() const = 0; 43 | virtual const char* GetName() const = 0; 44 | virtual int GetCategoryFlags() const = 0; 45 | virtual std::string ToString() const {return GetName();} 46 | 47 | // Bitwise & used to check bitposition of EventCategory 48 | inline bool IsInCategory(EventCategory category){ 49 | return GetCategoryFlags() & category; 50 | } 51 | 52 | // check if event is already handled 53 | bool m_Handeled = false; 54 | }; 55 | 56 | class EventDispatcher{ 57 | template 58 | using EventFn = std::function; 59 | public: 60 | EventDispatcher(Event& event) 61 | :m_Event(event){} 62 | 63 | template 64 | bool Dispatch(const A& func){ 65 | if(m_Event.GetEventType() == T::GetStaticType()){ 66 | m_Event.m_Handeled = func(static_cast(m_Event)); 67 | return true; 68 | } 69 | return false; 70 | } 71 | private: 72 | Event& m_Event; 73 | }; 74 | inline std::ostream& operator<<(std::ostream& os, const Event& e){ 75 | return os << e.ToString(); 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Events/KeyEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/22/21. 3 | // 4 | #pragma once 5 | 6 | #include "Event.h" 7 | #include 8 | 9 | namespace RcEngine{ 10 | class RC_API KeyEvent: public Event{ 11 | public: 12 | inline int GetKeyCode() const{return m_KeyCode; } 13 | EVENT_CLASS_CATEGORY( EventCategoryKeyboard | EventCategoryInput) 14 | protected: 15 | KeyEvent(int keycode): m_KeyCode(keycode){} 16 | int m_KeyCode; 17 | }; 18 | class RC_API KeyPressedEvent 19 | : public KeyEvent{ 20 | public: 21 | KeyPressedEvent(int keycode, int repeat): KeyEvent(keycode), m_RepeatCount(repeat){} 22 | 23 | inline int GetRepeatCount() const {return m_RepeatCount;} 24 | 25 | std::string ToString() const override{ 26 | std::stringstream stream; 27 | stream << "Received KeyPressedEvent: " << m_KeyCode << " (" << m_RepeatCount << " many repeats)"; 28 | return stream.str(); 29 | } 30 | 31 | EVENT_CLASS_TYPE(OnKeyPressed); 32 | private: 33 | int m_RepeatCount; 34 | }; 35 | class RC_API KeyTypedEvent 36 | : public KeyEvent{ 37 | public: 38 | KeyTypedEvent(int keycode): KeyEvent(keycode){} 39 | 40 | 41 | std::string ToString() const override{ 42 | std::stringstream stream; 43 | stream << "Received KeyTypedEvent: " << m_KeyCode ; 44 | return stream.str(); 45 | } 46 | 47 | EVENT_CLASS_TYPE(OnKeyTyped); 48 | }; 49 | class RC_API KeyReleasedEvent: public KeyEvent{ 50 | 51 | public: 52 | KeyReleasedEvent(int keycode) 53 | : KeyEvent(keycode){} 54 | 55 | std::string ToString() const override{ 56 | std::stringstream stream; 57 | stream << "KeyReleasedEvent: " << m_KeyCode; 58 | return stream.str(); 59 | } 60 | EVENT_CLASS_TYPE(OnKeyRelease) 61 | }; 62 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Events/MouseEvent.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/22/21. 3 | // 4 | 5 | #pragma once 6 | 7 | #include "Event.h" 8 | #include 9 | 10 | namespace RcEngine{ 11 | 12 | class RC_API MouseMovedEvent: public Event{ 13 | public: 14 | MouseMovedEvent(float x, float y) 15 | : m_MouseX(x), m_MouseY(y){} 16 | inline float GetX() const {return m_MouseX; } 17 | inline float GetY() const {return m_MouseY; } 18 | 19 | std::string ToString() const override{ 20 | std::stringstream stream; 21 | stream << "MouseMovedEvent(X,Y): (" << m_MouseX << ", " << m_MouseY << ")"; 22 | return stream.str(); 23 | } 24 | 25 | EVENT_CLASS_TYPE(MouseMoved) 26 | 27 | EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput) 28 | private: 29 | float m_MouseX, m_MouseY; 30 | }; 31 | class RC_API MouseScrolledEvent: public Event{ 32 | public: 33 | MouseScrolledEvent(float xOffset, float yOffset) 34 | : m_XOffset(xOffset), m_YOffset(yOffset){} 35 | inline float GetXOffset() const {return m_XOffset;} 36 | inline float GetYOffset() const{return m_YOffset;} 37 | 38 | std::string ToString() const override{ 39 | std::stringstream stream; 40 | stream << "MouseScrolledEvent(X,Y): "<< GetXOffset() << ", " << GetYOffset(); 41 | return stream.str(); 42 | } 43 | 44 | EVENT_CLASS_TYPE(MouseScrolled) 45 | 46 | EVENT_CLASS_CATEGORY(EventCategoryMouse| EventCategoryInput) 47 | private: 48 | float m_XOffset, m_YOffset; 49 | }; 50 | class RC_API MouseButtonEvent: public Event{ 51 | public: 52 | inline int GetMouseButton() const {return m_Button;} 53 | EVENT_CLASS_CATEGORY(EventCategoryMouse | EventCategoryInput) 54 | protected: 55 | MouseButtonEvent(int button) 56 | : m_Button(button){} 57 | int m_Button; 58 | }; 59 | class RC_API MouseButtonPressedEvent: public MouseButtonEvent{ 60 | public: 61 | MouseButtonPressedEvent(int button) 62 | : MouseButtonEvent(button){} 63 | std::string ToString() const override{ 64 | std::stringstream stream; 65 | stream << "MouseButtonPressedEvent: " << m_Button; 66 | return stream.str(); 67 | } 68 | 69 | EVENT_CLASS_TYPE(MouseButtonPress) 70 | }; 71 | class RC_API MouseButtonReleasedEvent: public MouseButtonEvent{ 72 | public: 73 | MouseButtonReleasedEvent(int button) 74 | : MouseButtonEvent(button){} 75 | std::string ToString() const override{ 76 | std::stringstream stream; 77 | stream << "MouseButtonReleasedEvent: "<< m_Button; 78 | return stream.str(); 79 | } 80 | 81 | EVENT_CLASS_TYPE(MouseButtonRelease) 82 | }; 83 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/ImGui/ImGuiBuild.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/24/21. 3 | // 4 | 5 | #include "rcpch.h" 6 | 7 | #define IMGUI_IMPL_OPENGL_LOADER_GLAD 8 | 9 | #include "backends/imgui_impl_glfw.cpp" 10 | #include "backends/imgui_impl_opengl3.cpp" -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/ImGui/ImGuiLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/23/21. 3 | // 4 | 5 | #pragma once 6 | #include "RcEngine/Core/Layer.h" 7 | 8 | 9 | #include "RcEngine/Events/MouseEvent.h" 10 | #include "RcEngine/Events/ApplicationEvent.h" 11 | #include "RcEngine/Events/KeyEvent.h" 12 | 13 | namespace RcEngine{ 14 | class RC_API ImGuiLayer : public Layer{ 15 | 16 | private: 17 | float m_Time =0.0f; 18 | 19 | public: 20 | ImGuiLayer(); 21 | ~ImGuiLayer(); 22 | 23 | virtual void OnAttach() override; 24 | virtual void OnDetach() override; 25 | 26 | virtual void OnImGuiRender() override; 27 | 28 | void Begin(); 29 | void End(); 30 | 31 | void BlockEvents(bool block) { m_BlockEvents = block; } 32 | 33 | virtual void SetDarkThemeColors(); 34 | private: 35 | bool m_BlockEvents = true; 36 | }; 37 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Lua/luastate.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 12/31/21. 3 | // 4 | 5 | #include "luastate.h" 6 | #include "RcEngine/Scene/Component.h" 7 | #include "luautil.h" 8 | 9 | namespace LUtil{ 10 | 11 | LuaState::LuaState(std::string &filename) { 12 | 13 | } 14 | 15 | void LuaState::initLua() { 16 | 17 | } 18 | 19 | 20 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Lua/luastate.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 12/30/21. 3 | // 4 | 5 | #ifndef RCENGINE_LUASTATE_H 6 | #define RCENGINE_LUASTATE_H 7 | 8 | #include "sol/sol.hpp" 9 | #include 10 | #include 11 | 12 | 13 | #define SOL_SAFE_USERTYPE 1 14 | #define SOL_SAFE_REFERENCES 1 15 | #define SOL_SAFE_FUNCTION_CALLS 1 16 | #define SOL_SAFE_FUNCTION 1 17 | #define SOL_NO_NIL 0 18 | #define SOL_IN_DEBUG_DETECTED 0 19 | 20 | #define SOL_LUAJIT 1 21 | #define SOL_EXCEPTIONS_SAFE_PROPAGATION 0 22 | 23 | 24 | namespace LUtil{ 25 | // std::string getLuaVersion(); 26 | 27 | class LuaState{ 28 | public: 29 | 30 | LuaState(std::string& filename); 31 | ~LuaState(); 32 | 33 | void initLua(); 34 | 35 | }; 36 | } 37 | 38 | #endif //RCENGINE_LUASTATE_H 39 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Lua/luautil.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/17/22. 3 | // 4 | 5 | #ifndef RCGAMEENGINE_LUAUTIL_H 6 | #define RCGAMEENGINE_LUAUTIL_H 7 | #include 8 | #include 9 | namespace LuaUtil { 10 | class LuaUtil { 11 | LuaUtil(); 12 | ~LuaUtil(); 13 | 14 | using Vec2 = glm::vec2; 15 | using Vec3 = glm::vec3; 16 | using Vec4 = glm::vec4; 17 | 18 | sol::table initBasePackage(sol::state &); 19 | 20 | template 21 | void addVecMethods(sol::usertype &VecType); 22 | 23 | void addPackage(std::string packageName, sol::object package); 24 | 25 | private: 26 | std::map m_Compiled; 27 | std::map m_Packages; 28 | sol::state m_Lua; 29 | }; 30 | } 31 | #endif //RCGAMEENGINE_LUAUTIL_H 32 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Math/Math.h: -------------------------------------------------------------------------------- 1 | //From Cherno's Hazel engine 2 | #include 3 | 4 | #ifndef RCENGINE_MATH_H 5 | #define RCENGINE_MATH_H 6 | namespace RcEngine::Math{ 7 | bool DecomposeTransform(const glm::mat4& transform, glm::vec3& translation, glm::vec3& rotation, glm::vec3& scale); 8 | float Qsqrt(const float& x); 9 | } 10 | #endif //RCENGINE_MATH_H 11 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Network/Network.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/20/21. 3 | // 4 | extern "C" void rc_tcp_server(); 5 | extern "C" void rc_tcp_client(); 6 | extern "C" void rc_entry(); 7 | 8 | #pragma once 9 | 10 | #ifndef RCENGINE_CLION_NETWORK_H 11 | #define RCENGINE_CLION_NETWORK_H 12 | 13 | namespace RcEngine{ 14 | static void TcpServer(){ 15 | rc_tcp_server(); 16 | } 17 | static void TcpClient(){ 18 | rc_tcp_client(); 19 | } 20 | 21 | } 22 | #endif //RCENGINE_CLION_NETWORK_H 23 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/Buffer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/27/21. 3 | // 4 | #include "rcpch.h" 5 | #include "Buffer.h" 6 | 7 | #include "Renderer.h" 8 | #include "Platform/OpenGL/OpenGLBuffer.h" 9 | 10 | namespace RcEngine{ 11 | Ref VertexBuffer::Create(uint32_t size) { 12 | switch (Renderer::GetAPI()) { 13 | case RenderAPI::API::None: 14 | RC_CORE_ASSERT(false, "No Render API") 15 | return nullptr; 16 | case RenderAPI::API::OpenGL: 17 | //TODO: check OpenGL version 18 | return std::make_shared(size); 19 | case RenderAPI::API::Vulkan: 20 | RC_CORE_ASSERT(false, "Vulkan not currently supported"); 21 | return nullptr; 22 | } 23 | RC_CORE_ASSERT(false, "Renderer not defined"); 24 | return nullptr; 25 | } 26 | Ref VertexBuffer::Create(float* vertices, uint32_t size){ 27 | switch (Renderer::GetAPI()) { 28 | case RenderAPI::API::None: 29 | RC_CORE_ASSERT(false, "No Render API") 30 | return nullptr; 31 | case RenderAPI::API::OpenGL: 32 | //TODO: check OpenGL version 33 | return std::make_shared(vertices,size); 34 | case RenderAPI::API::Vulkan: 35 | RC_CORE_ASSERT(false, "Vulkan not currently supported"); 36 | return nullptr; 37 | } 38 | RC_CORE_ASSERT(false, "Renderer not defined"); 39 | return nullptr; 40 | } 41 | Ref IndexBuffer::Create(uint32_t* indices, uint32_t count){ 42 | switch (Renderer::GetAPI()) { 43 | case RenderAPI::API::None: 44 | RC_CORE_ASSERT(false, "No Render API"); 45 | return nullptr; 46 | case RenderAPI::API::OpenGL: 47 | return std::make_shared(indices,count); 48 | case RenderAPI::API::Vulkan: 49 | RC_CORE_ASSERT(false, "Vulkan not currently supported"); 50 | return nullptr; 51 | } 52 | RC_CORE_ASSERT(false, "Renderer not defined"); 53 | return nullptr; 54 | } 55 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/Camera.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/6/21. 3 | // 4 | #pragma once 5 | 6 | #ifndef RCENGINE_CLION_CAMERA_H 7 | #define RCENGINE_CLION_CAMERA_H 8 | 9 | #include 10 | 11 | namespace RcEngine{ 12 | class Camera{ 13 | public: 14 | Camera() = default; 15 | 16 | Camera(const glm::mat4& projection) 17 | :m_Projection(projection){} 18 | virtual ~Camera() = default; 19 | const glm::mat4& GetProjection() const{return m_Projection;} 20 | 21 | protected: 22 | glm::mat4 m_Projection = glm::mat4(1.0f); 23 | 24 | }; 25 | } 26 | 27 | #endif //RCENGINE_CLION_CAMERA_H 28 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/EditorCamera.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | #include "rcpch.h" 4 | #include "Camera.h" 5 | #include "RcEngine/Core/Timestep.h" 6 | #include "RcEngine/Events/Event.h" 7 | #include "RcEngine/Events/MouseEvent.h" 8 | 9 | #include 10 | 11 | namespace RcEngine{ 12 | class EditorCamera : public Camera 13 | { 14 | public: 15 | EditorCamera() = default; 16 | EditorCamera(float fov, float aspectRatio, float nearClip, float farClip); 17 | 18 | void OnUpdate(Timestep ts); 19 | void OnEvent(Event& e); 20 | 21 | inline float GetDistance() const { return m_Distance; } 22 | inline void SetDistance(float distance) { m_Distance = distance; } 23 | 24 | inline void SetViewportSize(float width, float height) { m_ViewportWidth = width; m_ViewportHeight = height; UpdateProjection(); } 25 | 26 | const glm::mat4& GetViewMatrix() const { return m_ViewMatrix; } 27 | glm::mat4 GetViewProjection() const { return m_Projection * m_ViewMatrix; } 28 | 29 | glm::vec3 GetUpDirection() const; 30 | glm::vec3 GetRightDirection() const; 31 | glm::vec3 GetForwardDirection() const; 32 | const glm::vec3& GetPosition() const { return m_Position; } 33 | glm::quat GetOrientation() const; 34 | 35 | bool OnMouseScroll(MouseScrolledEvent& e); 36 | 37 | float GetPitch() const { return m_Pitch; } 38 | float GetYaw() const { return m_Yaw; } 39 | private: 40 | void UpdateProjection(); 41 | void UpdateView(); 42 | 43 | void MousePan(const glm::vec2& delta); 44 | void MouseRotate(const glm::vec2& delta); 45 | void MouseZoom(float delta); 46 | 47 | glm::vec3 CalculatePosition() const; 48 | 49 | std::pair PanSpeed() const; 50 | float RotationSpeed() const; 51 | float ZoomSpeed() const; 52 | private: 53 | float m_FOV = 45.0f, m_AspectRatio = 1.778f, m_NearClip = 0.1f, m_FarClip = 1000.0f; 54 | 55 | glm::mat4 m_ViewMatrix; 56 | glm::vec3 m_Position = { 0.0f, 0.0f, 0.0f }; 57 | glm::vec3 m_FocalPoint = { 0.0f, 0.0f, 0.0f }; 58 | 59 | glm::vec2 m_InitialMousePosition = { 0.0f, 0.0f }; 60 | 61 | float m_Distance = 10.0f; 62 | float m_Pitch = 0.0f, m_Yaw = 0.0f; 63 | 64 | float m_ViewportWidth = 1280, m_ViewportHeight = 720; 65 | }; 66 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/FrameBuffer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/5/21. 3 | // 4 | 5 | #include "FrameBuffer.h" 6 | #include "rcpch.h" 7 | 8 | #include "RcEngine/Renderer/Renderer.h" 9 | 10 | #include "Platform/OpenGL/OpenGLFrameBuffer.h" 11 | 12 | namespace RcEngine{ 13 | Ref FrameBuffer::Create(const FrameBufferSpec &spec) { 14 | switch (Renderer::GetAPI()) { 15 | case RenderAPI::API::None: 16 | RC_CORE_ASSERT(false, "No Render API") 17 | return nullptr; 18 | case RenderAPI::API::OpenGL: 19 | //TODO: check OpenGL version 20 | return std::make_shared(spec); 21 | case RenderAPI::API::Vulkan: 22 | RC_CORE_ASSERT(false, "Vulkan not currently supported"); 23 | return nullptr; 24 | } 25 | RC_CORE_ASSERT(false, "Renderer not defined"); 26 | return nullptr; 27 | } 28 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/FrameBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/5/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Core/Core.h" 6 | 7 | #ifndef RCENGINE_CLION_FRAMEBUFFER_H 8 | #define RCENGINE_CLION_FRAMEBUFFER_H 9 | namespace RcEngine{ 10 | enum class FrameBufferTextureFormat{ 11 | None =0, 12 | RGBA8 = 1, 13 | RED_INT, 14 | RGBA16F, 15 | //stencil 16 | DEPTH24STENCIL8, 17 | //Defaults 18 | Depth = DEPTH24STENCIL8 19 | }; 20 | struct FramebufferTextureSpec{ 21 | FramebufferTextureSpec() = default; 22 | FramebufferTextureSpec(FrameBufferTextureFormat format) 23 | : TextureFormat(format){} 24 | 25 | FrameBufferTextureFormat TextureFormat = FrameBufferTextureFormat::None; 26 | }; 27 | struct FramebufferAttachmentSpec{ 28 | FramebufferAttachmentSpec() =default; 29 | FramebufferAttachmentSpec(std::initializer_list attachments) 30 | : Attachments(attachments){} 31 | std::vector Attachments; 32 | }; 33 | 34 | struct FrameBufferSpec 35 | { 36 | uint32_t Width, Height; 37 | FramebufferAttachmentSpec Attachments; 38 | uint32_t Samples = 1; 39 | 40 | bool SwapChainTarget = false; 41 | }; 42 | 43 | class FrameBuffer 44 | { 45 | public: 46 | virtual void Bind() = 0; 47 | virtual void UnBind() = 0; 48 | 49 | virtual int ReadPixel(uint32_t attachmentidx, int x, int y) =0; 50 | 51 | virtual void Resize(uint32_t width, uint32_t height) =0; 52 | 53 | virtual uint32_t GetColorAttachmentRendererID(uint32_t index=0) const = 0; 54 | 55 | 56 | 57 | virtual uint32_t GetRendererID() const = 0; 58 | 59 | virtual const FrameBufferSpec& GetSpecification() const = 0; 60 | 61 | static Ref Create(const FrameBufferSpec& spec); 62 | }; 63 | 64 | } 65 | 66 | #endif //RCENGINE_CLION_FRAMEBUFFER_H 67 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/GraphicsContext.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/26/21. 3 | // 4 | #include "rcpch.h" 5 | #include "RcEngine/Renderer/GraphicsContext.h" 6 | 7 | #include "RcEngine/Renderer/Renderer.h" 8 | #include "Platform/OpenGL/OpenGLContext.h" 9 | 10 | namespace RcEngine{ 11 | Scope GraphicsContext::Create(void* window) 12 | { 13 | switch (Renderer::GetAPI()) 14 | { 15 | case RenderAPI::API::None: RC_CORE_ASSERT(false, "RendererAPI::None is currently not supported!"); return nullptr; 16 | case RenderAPI::API::OpenGL: return CreateScope(static_cast(window)); 17 | } 18 | 19 | RC_CORE_ASSERT(false, "Unknown RendererAPI!"); 20 | return nullptr; 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/GraphicsContext.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/25/21. 3 | // 4 | #pragma once 5 | 6 | namespace RcEngine{ 7 | class GraphicsContext{ 8 | public: 9 | virtual ~GraphicsContext() = default; 10 | virtual void Init()=0; 11 | virtual void SwapBuffers() = 0; 12 | 13 | static Scope Create(void* window); 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/IsoCameraController.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/3/21. 3 | // 4 | #include "rcpch.h" 5 | 6 | #include "IsoCameraController.h" 7 | 8 | #include "RcEngine/Core/Input.h" 9 | #include "RcEngine/Core/keycodes.h" 10 | 11 | namespace RcEngine{ 12 | IsoCameraController::IsoCameraController(float aspect, bool rotation) 13 | : m_AspectRatio(aspect),m_Bounds({-m_AspectRatio * m_ZoomLevel, m_AspectRatio * m_ZoomLevel, -m_ZoomLevel,m_ZoomLevel}), 14 | m_Rotation(rotation){ 15 | 16 | } 17 | void IsoCameraController::OnEvent(Event &e) { 18 | RC_PROFILE_FUNCTION(); 19 | EventDispatcher dispatcher(e); 20 | dispatcher.Dispatch( 21 | RC_BIND_EVENT_TO_FUNCTION(IsoCameraController::OnMouseScrolled)); 22 | dispatcher.Dispatch( 23 | RC_BIND_EVENT_TO_FUNCTION(IsoCameraController::OnWindowResized)); 24 | 25 | } 26 | void IsoCameraController::OnUpdate(Timestep ts) { 27 | RC_PROFILE_FUNCTION(); 28 | if(Input::IsKeyPressed(RC_KEY_A)){ 29 | m_CameraPosition.x -= cos(glm::radians(m_CameraRotation)) * 30 | m_CameraTranslationSpeed*ts; 31 | } 32 | if(Input::IsKeyPressed(RC_KEY_D)){ 33 | m_CameraPosition.x += cos(glm::radians(m_CameraRotation))* 34 | m_CameraTranslationSpeed*ts; 35 | } 36 | if(Input::IsKeyPressed(RC_KEY_W)){ 37 | m_CameraPosition.y += m_CameraTranslationSpeed*ts; 38 | } 39 | if(Input::IsKeyPressed(RC_KEY_S)) 40 | m_CameraPosition.y -= m_CameraTranslationSpeed*ts; 41 | 42 | 43 | if(m_Rotation) { 44 | if (Input::IsKeyPressed(RC_KEY_LEFT)) 45 | m_CameraRotation -= m_CameraRotationSpeed * ts; 46 | if (Input::IsKeyPressed(RC_KEY_RIGHT)) 47 | m_CameraRotation += m_CameraRotationSpeed * ts; 48 | 49 | m_Camera.SetRotation(m_CameraRotation); 50 | } 51 | 52 | m_Camera.SetPosition(m_CameraPosition); 53 | m_CameraTranslationSpeed = m_ZoomLevel * 1.25f; 54 | 55 | } 56 | bool IsoCameraController::OnMouseScrolled(MouseScrolledEvent &e) { 57 | m_ZoomLevel -= e.GetYOffset() * 0.1f; 58 | m_ZoomLevel = std::max(m_ZoomLevel, 0.04f); 59 | m_Bounds = {-m_AspectRatio * m_ZoomLevel, m_AspectRatio * m_ZoomLevel, -m_ZoomLevel,m_ZoomLevel}; 60 | m_Camera.SetProjection(0,m_Bounds.Right,m_Bounds.Bottom,m_Bounds.Top); 61 | return false; 62 | } 63 | bool IsoCameraController::OnWindowResized(WindowResizeEvent &e) { 64 | m_AspectRatio = (float)e.GetWidth()/ e.GetHeight(); 65 | m_Camera.SetProjection(0,m_Bounds.Right,m_Bounds.Bottom,m_Bounds.Top); 66 | return false; 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/IsoCameraController.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/3/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Core/Timestep.h" 6 | #include "RcEngine/Renderer/OrthoCamera.h" 7 | 8 | #include "RcEngine/Events/ApplicationEvent.h" 9 | #include "RcEngine/Events/MouseEvent.h" 10 | 11 | #ifndef RCENGINE_CLION_ISOCAMERACONTROLLER_H 12 | #define RCENGINE_CLION_ISOCAMERACONTROLLER_H 13 | namespace RcEngine{ 14 | struct IsoCameraBounds{ 15 | float Left, Right; 16 | float Bottom,Top; 17 | 18 | float GetWidth(){return Right - Left;} 19 | float GetHeight(){return Top-Bottom;} 20 | }; 21 | 22 | class IsoCameraController{ 23 | public: 24 | IsoCameraController(float aspect, bool rotation= false); 25 | 26 | OrthoCamera& GetCamera(){return m_Camera;} 27 | const OrthoCamera& GetCamera() const {return m_Camera;} 28 | 29 | void OnUpdate(Timestep ts); 30 | void OnEvent(Event& e); 31 | 32 | void SetRotationSpeed(float speed){m_CameraRotationSpeed = speed;} 33 | float GetRotationSpeed(){return m_CameraRotationSpeed;} 34 | 35 | float GetZoomlevel() const {return m_ZoomLevel;} 36 | void SetZoomlevel(float level){m_ZoomLevel = level;} 37 | 38 | const IsoCameraBounds& GetBounds() const{return m_Bounds;} 39 | private: 40 | bool OnMouseScrolled(MouseScrolledEvent& e); 41 | bool OnWindowResized(WindowResizeEvent& e); 42 | private: 43 | float m_AspectRatio; 44 | float m_ZoomLevel = 1.0f; 45 | 46 | OrthoCamera m_Camera; 47 | 48 | bool m_Rotation; 49 | glm::vec3 m_CameraPosition = {0.0f,0.0f,0.0f}; 50 | float m_CameraRotation = 1.0f; //18.0f before 51 | 52 | float m_CameraTranslationSpeed =5.0f, m_CameraRotationSpeed = 9.0f; 53 | 54 | IsoCameraBounds m_Bounds; 55 | 56 | }; 57 | } 58 | #endif //RCENGINE_CLION_ISOCAMERACONTROLLER_H 59 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/MeshLoader.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/30/22. 3 | // 4 | 5 | #include "MeshLoader.h" 6 | #include "vulkan/vulkan.h" 7 | 8 | namespace RcEngine{ 9 | Mesh::Mesh(char *filename): m_filename(filename) {}; 10 | 11 | bool Mesh::MeshLoad() { 12 | std::string err; 13 | std::string warn; 14 | 15 | tinyobj::LoadObj(&attrib,&shapes,&materials,&warn,&err,m_filename, nullptr); 16 | 17 | if(!warn.empty()) 18 | RC_WARN(warn); 19 | 20 | if(!err.empty()) 21 | RC_CORE_ASSERT(!err.empty(),err); 22 | return false; 23 | 24 | for (size_t s = 0; s < shapes.size(); s ++) { 25 | size_t index_offset = 0; 26 | for(size_t f =0; f< shapes[s].mesh.num_face_vertices.size();f++){ 27 | int fv =3; 28 | 29 | for(size_t v=0; v < fv; v++){ 30 | tinyobj::index_t idx = shapes[s].mesh.indices[index_offset +v]; 31 | 32 | tinyobj::real_t ux = attrib.vertices[3 * idx.vertex_index +0]; 33 | tinyobj::real_t uy = attrib.vertices[3 * idx.vertex_index +1]; 34 | tinyobj::real_t vz = attrib.vertices[3 * idx.vertex_index +2]; 35 | 36 | tinyobj::real_t nx = attrib.normals[3 * idx.normal_index +0]; 37 | tinyobj::real_t ny = attrib.normals[3 * idx.normal_index +1]; 38 | tinyobj::real_t nz = attrib.normals[3 * idx.normal_index +2]; 39 | 40 | 41 | 42 | } 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/MeshLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/30/22. 3 | // 4 | 5 | #ifndef RCGAMEENGINE_MESHLOADER_H 6 | #define RCGAMEENGINE_MESHLOADER_H 7 | #include 8 | namespace RcEngine{ 9 | class Mesh{ 10 | Mesh(char* filename); 11 | ~Mesh() = default; 12 | bool MeshLoad(); 13 | private: 14 | char* m_filename; 15 | tinyobj::attrib_t attrib; 16 | std::vector shapes; 17 | std::vector materials; 18 | }; 19 | } 20 | #endif //RCGAMEENGINE_MESHLOADER_H 21 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/OrthoCamera.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/6/21. 3 | // 4 | #include "rcpch.h" 5 | #include "OrthoCamera.h" 6 | #include 7 | namespace RcEngine{ 8 | OrthoCamera::OrthoCamera(float left, float right, float bottom, float top) 9 | : m_ProjectionMatrix(glm::ortho(left,right,bottom,top,-1.0f, 1.0f)),m_ViewMatrix(1.0f){ 10 | RC_PROFILE_FUNCTION(); 11 | 12 | m_ViewProjectMatrix = m_ProjectionMatrix * m_ViewMatrix; 13 | } 14 | 15 | void OrthoCamera::SetProjection(float left, float right, float bottom, float top) { 16 | m_ProjectionMatrix = glm::ortho(left,right,bottom,top,-1.0f, 1.0f); 17 | m_ViewProjectMatrix = m_ProjectionMatrix * m_ViewMatrix; 18 | } 19 | 20 | void OrthoCamera::RecalculateView() { 21 | 22 | glm::mat4 transform = glm::translate(glm::mat4(1.0f), m_Position)* 23 | glm::rotate(glm::mat4(1.0f),m_Rotation, 24 | glm::vec3(0,0,1)); 25 | 26 | m_ViewMatrix = glm::inverse(transform); 27 | m_ViewProjectMatrix = m_ProjectionMatrix * m_ViewMatrix; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/OrthoCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/6/21. 3 | // 4 | #pragma once 5 | #include 6 | 7 | 8 | #ifndef RCENGINE_CLION_ORTHOCAMERA_H 9 | #define RCENGINE_CLION_ORTHOCAMERA_H 10 | namespace RcEngine{ 11 | class OrthoCamera{ 12 | public: 13 | OrthoCamera(float left=-1.0f, float right=1.0f, float bottom=-1.0f, float top=1.0f); 14 | void SetProjection(float left, float right, float bottom, float top); 15 | const glm::vec3& GetPosition() const{return m_Position;} 16 | 17 | 18 | void SetPosition(const glm::vec3& position){ 19 | m_Position = position; 20 | RecalculateView(); 21 | } 22 | 23 | float GetRotation() const {return m_Rotation;} 24 | 25 | void SetRotation(float rotation){ 26 | m_Rotation = rotation; 27 | RecalculateView(); 28 | } 29 | 30 | public: 31 | const glm::mat4& GetProjectionMatrix() const {return m_ProjectionMatrix;} 32 | const glm::mat4& GetViewMatrix() const{return m_ViewMatrix;} 33 | const glm::mat4& GetViewProjectMatrix() const{return m_ViewProjectMatrix;} 34 | private: 35 | void RecalculateView(); 36 | 37 | private: 38 | glm::mat4 m_ProjectionMatrix; 39 | glm::mat4 m_ViewMatrix; 40 | glm::mat4 m_ViewProjectMatrix; 41 | 42 | glm::vec3 m_Position = {0.0f, 0.0f, 0.0f}; 43 | float m_Rotation = 0.0f; 44 | }; 45 | } 46 | #endif //RCENGINE_CLION_ORTHOCAMERA_H 47 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/OrthoCameraController.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/23/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Core/Timestep.h" 6 | #include "RcEngine/Renderer/OrthoCamera.h" 7 | 8 | #include "RcEngine/Events/ApplicationEvent.h" 9 | #include "RcEngine/Events/MouseEvent.h" 10 | 11 | #ifndef RCENGINE_CLION_ORTHOCAMERACONTROLLER_H 12 | #define RCENGINE_CLION_ORTHOCAMERACONTROLLER_H 13 | namespace RcEngine{ 14 | struct OrthoCameraBounds{ 15 | float Left, Right; 16 | float Bottom,Top; 17 | 18 | float GetWidth(){return Right - Left;} 19 | float GetHeight(){return Top-Bottom;} 20 | }; 21 | 22 | class OrthoCameraController{ 23 | public: 24 | OrthoCameraController(float aspect, bool rotation= false); 25 | 26 | OrthoCamera& GetCamera(){return m_Camera;} 27 | const OrthoCamera& GetCamera() const {return m_Camera;} 28 | 29 | void OnUpdate(Timestep ts); 30 | void OnEvent(Event& e); 31 | 32 | void ResizeBounds(float width, float height); 33 | 34 | void SetRotationSpeed(float speed){m_CameraRotationSpeed = speed;} 35 | float GetRotationSpeed(){return m_CameraRotationSpeed;} 36 | 37 | float GetZoomlevel() const {return m_ZoomLevel;} 38 | void SetZoomlevel(float level){m_ZoomLevel = level; CalulateView();} 39 | 40 | const OrthoCameraBounds& GetBounds() const{return m_Bounds;} 41 | private: 42 | void CalulateView(); 43 | 44 | bool OnMouseScrolled(MouseScrolledEvent& e); 45 | bool OnWindowResized(WindowResizeEvent& e); 46 | private: 47 | float m_AspectRatio; 48 | float m_ZoomLevel = 1.0f; 49 | 50 | OrthoCameraBounds m_Bounds; 51 | OrthoCamera m_Camera; 52 | 53 | bool m_Rotation; 54 | glm::vec3 m_CameraPosition = {0.0f,0.0f,0.0f}; 55 | float m_CameraRotation = 1.0f; //18.0f before 56 | 57 | float m_CameraTranslationSpeed =5.0f, m_CameraRotationSpeed = 9.0f; 58 | 59 | }; 60 | } 61 | #endif //RCENGINE_CLION_ORTHOCAMERACONTROLLER_H 62 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/ProjectionCamera.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/24/21. 3 | // 4 | #pragma once 5 | #ifndef RCENGINE_CLION_PROJECTIONCAMERA_H 6 | #define RCENGINE_CLION_PROJECTIONCAMERA_H 7 | #include "rcpch.h" 8 | #include "Camera.h" 9 | 10 | namespace RcEngine{ 11 | class ProjectionCamera : public Camera{ 12 | public: 13 | ProjectionCamera() = default; 14 | ProjectionCamera(float fov, float aspectRatio, float nearClip, float FarClip); 15 | 16 | void SetProjection(float fov, float aspectRatio, float nearClip, float FarClip); 17 | 18 | 19 | const glm::mat4& GetViewMatrix() const { return m_ViewMatrix; } 20 | glm::mat4 GetViewProjection() const { return m_Projection * m_ViewMatrix; } 21 | 22 | 23 | float GetPitch() const { return m_Pitch; } 24 | float GetYaw() const { return m_Yaw; } 25 | 26 | void SetWidthHeight(); 27 | 28 | void setRotationSpeed(float speed); 29 | float RotationSpeed() const {return m_RotationSpeed;} 30 | 31 | 32 | glm::vec3 GetUpDirection() const; 33 | glm::vec3 GetRightDirection() const; 34 | glm::vec3 GetForwardDirection() const; 35 | const glm::vec3& GetPosition() const { return m_CameraPosition; } 36 | glm::quat GetOrientation() const; 37 | 38 | 39 | private: 40 | void RecalculateView(); 41 | glm::vec3 CalculatePosition() const; 42 | void Rotate(const glm::vec2& delta); 43 | 44 | void UpdateView(); 45 | 46 | private: 47 | float m_FOV = 1.04724f,m_AspectRatio = 1.778f; 48 | float m_NearClip = 0.1f, m_FarClip = 1000.0f; 49 | 50 | glm::mat4 m_ViewMatrix; 51 | 52 | glm::vec3 m_CameraPosition = {0.0f,0.0f,0.0f}; 53 | glm::vec3 m_FocalPoint = { 0.0f, 0.0f, 0.0f }; 54 | 55 | float m_Pitch = 0.0f, m_Yaw = 0.0f; 56 | float m_Width = 1280, m_Height = 720; 57 | 58 | float m_Distance = 10.0f; 59 | float m_RotationSpeed = 0.8f; 60 | 61 | }; 62 | } 63 | #endif //RCENGINE_CLION_PROJECTIONCAMERA_H 64 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/RenderAPI.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/30/21. 3 | // 4 | 5 | #include "rcpch.h" 6 | #include "RenderAPI.h" 7 | 8 | #include "Platform/OpenGL/OpenGLRenderAPI.h" 9 | 10 | namespace RcEngine{ 11 | RenderAPI::API RenderAPI::s_API = RenderAPI::API::OpenGL; 12 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/RenderAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/30/21. 3 | // 4 | 5 | #pragma once 6 | #include 7 | #include "VertexArray.h" 8 | 9 | namespace RcEngine{ 10 | class RenderAPI{ 11 | public: 12 | enum class API{ 13 | None=0, 14 | OpenGL = 1, 15 | Vulkan = 2, 16 | Metal = 3, 17 | }; 18 | 19 | public: 20 | virtual void Init() =0; 21 | virtual void Clear() =0; 22 | 23 | virtual void SetClearColor(const glm::vec4 &color) =0; 24 | virtual void SetViewport(uint32_t x, uint32_t y,uint32_t width,uint32_t height) =0; 25 | 26 | virtual void DrawIndexed(const Ref& vertexArray, uint32_t indexCount =0) =0; 27 | inline static API GetAPI(){return s_API;} 28 | inline static void SetAPI(API api){s_API = api;} 29 | private: 30 | static API s_API; 31 | }; 32 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/RenderCommand.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/30/21. 3 | // 4 | #include "rcpch.h" 5 | #include "RenderCommand.h" 6 | 7 | #include "Platform/OpenGL/OpenGLRenderAPI.h" 8 | 9 | namespace RcEngine{ 10 | RenderAPI* RenderCommand::s_RenderAPI = new OpenGLRenderAPI; 11 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/RenderCommand.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/30/21. 3 | // 4 | #pragma once 5 | 6 | #include "RenderAPI.h" 7 | 8 | #ifndef RCENGINE_CLION_RENDERCOMMAND_H 9 | #define RCENGINE_CLION_RENDERCOMMAND_H 10 | 11 | namespace RcEngine{ 12 | class RenderCommand{ 13 | public: 14 | inline static void Init(){ 15 | s_RenderAPI->Init(); 16 | } 17 | 18 | inline static void SetClearColor(const glm::vec4& color){ 19 | s_RenderAPI->SetClearColor(color); 20 | } 21 | inline static void Clear(){ 22 | s_RenderAPI->Clear(); 23 | } 24 | inline static void DrawIndexed(const Ref& vertexArray, uint32_t count = 0){ 25 | s_RenderAPI->DrawIndexed(vertexArray,count); 26 | } 27 | inline static void SetViewport(uint32_t x, uint32_t y,uint32_t width,uint32_t height){ 28 | s_RenderAPI->SetViewport(x,y,width, height); 29 | } 30 | private: 31 | static RenderAPI* s_RenderAPI; 32 | }; 33 | 34 | } 35 | 36 | #endif //RCENGINE_CLION_RENDERCOMMAND_H 37 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/Renderer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/27/21. 3 | // 4 | #include "rcpch.h" 5 | #include "Renderer.h" 6 | #include "RenderCommand.h" 7 | 8 | #include "Platform/OpenGL/OpenGLShader.h" 9 | 10 | #include "Renderer2D.h" 11 | 12 | namespace RcEngine{ 13 | Renderer::SceneData* Renderer::m_SceneData = new Renderer::SceneData; 14 | 15 | void Renderer::Init() { 16 | RenderCommand::Init(); 17 | Renderer2D::Init(); 18 | } 19 | void Renderer::OnWindowResize(uint32_t width, uint32_t height) { 20 | RenderCommand::SetViewport(0,0,width, height); 21 | } 22 | 23 | void Renderer::BeginScene(OrthoCamera& camera) { 24 | m_SceneData->ViewProjectionMatrix = camera.GetViewProjectMatrix(); 25 | } 26 | void Renderer::EndScene() { 27 | 28 | } 29 | void Renderer::Submit( 30 | const Ref& shader, 31 | const Ref& vertexArray, 32 | const glm::mat4& transform) { 33 | 34 | shader->Bind(); 35 | 36 | shader->SetMat4("u_ViewProjection",m_SceneData->ViewProjectionMatrix); 37 | shader->SetMat4("u_Transform", transform); 38 | 39 | 40 | vertexArray->Bind(); 41 | RenderCommand::DrawIndexed(vertexArray); 42 | } 43 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/Renderer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/27/21. 3 | // 4 | #pragma once 5 | #include "RenderCommand.h" 6 | #include "RenderAPI.h" 7 | #include "OrthoCamera.h" 8 | #include "Shader.h" 9 | 10 | 11 | namespace RcEngine{ 12 | class Renderer{ 13 | public: 14 | 15 | static void Init(); 16 | static void OnWindowResize(uint32_t width, uint32_t height); 17 | 18 | static void BeginScene(OrthoCamera& camera); 19 | 20 | static void EndScene(); 21 | 22 | static void Submit(const Ref& shader, 23 | const Ref& vertexArray, 24 | const glm::mat4& transform = glm::mat4(1.0f)); 25 | 26 | inline static RenderAPI::API GetAPI(){return RenderAPI::GetAPI(); } 27 | inline static void SetAPI(RenderAPI::API api){ RenderAPI::SetAPI(api);} 28 | private: 29 | struct SceneData{ 30 | glm::mat4 ViewProjectionMatrix; 31 | }; 32 | static SceneData* m_SceneData; 33 | }; 34 | } 35 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/Renderer3D.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/28/21. 3 | // 4 | #pragma once 5 | 6 | #include "RcEngine/Renderer/Camera.h" 7 | #include "RcEngine/Renderer/Texture.h" 8 | #include "RcEngine/Renderer/ProjectionCamera.h" 9 | #include "RcEngine/Renderer/EditorCamera.h" 10 | 11 | #ifndef RCENGINE_RENDERER3D_H 12 | #define RCENGINE_RENDERER3D_H 13 | 14 | namespace RcEngine{ 15 | class Renderer3D{ 16 | public: 17 | static void Init(); 18 | static void Shutdown(); 19 | 20 | //TODO: implement perspective camera 21 | static void BeginScene(const ProjectionCamera& camera); 22 | static void BeginScene(const EditorCamera& camera); 23 | static void BeginScene(const Camera& camera, const glm::mat4 transform); 24 | 25 | static void EndScene(); 26 | static void Flush(); 27 | 28 | }; 29 | } 30 | 31 | #endif //RCENGINE_RENDERER3D_H 32 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/Shader.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/26/21. 3 | // 4 | #include "rcpch.h" 5 | #include "Shader.h" 6 | 7 | #include "Renderer.h" 8 | #include "Platform/OpenGL/OpenGLShader.h" 9 | 10 | namespace RcEngine{ 11 | Ref Shader::Create(const std::string& filepath) { 12 | switch (Renderer::GetAPI()) { 13 | case RenderAPI::API::None: 14 | RC_CORE_ASSERT(false, "No Render API"); 15 | return nullptr; 16 | case RenderAPI::API::OpenGL: 17 | //TODO: check OpenGL version 18 | return std::make_shared(filepath); 19 | case RenderAPI::API::Vulkan: 20 | RC_CORE_ASSERT(false, "Vulkan not currently supported"); 21 | return nullptr; 22 | } 23 | RC_CORE_ASSERT(false, "Shader not defined"); 24 | return nullptr; 25 | } 26 | 27 | Ref Shader::Create(const std::string& name, const std::string& vertexSrc, const std::string& fragmentSrc) { 28 | switch (Renderer::GetAPI()) { 29 | case RenderAPI::API::None: 30 | RC_CORE_ASSERT(false, "No Render API"); 31 | return nullptr; 32 | case RenderAPI::API::OpenGL: 33 | //TODO: check OpenGL version 34 | return std::make_shared(name, vertexSrc, fragmentSrc); 35 | case RenderAPI::API::Vulkan: 36 | RC_CORE_ASSERT(false, "Vulkan not currently supported"); 37 | return nullptr; 38 | } 39 | RC_CORE_ASSERT(false, "Shader not defined"); 40 | return nullptr; 41 | } 42 | void ShaderLibrary::Add(const std::string &name, const Ref &shader) { 43 | RC_CORE_ASSERT(!Exists(name), "Shader already bound"); 44 | m_Shader[name] = shader; 45 | } 46 | void ShaderLibrary::Add(const Ref &shader) { 47 | auto& name = shader->GetName(); 48 | Add(name,shader); 49 | } 50 | Ref ShaderLibrary::Load(const std::string &filepath) { 51 | auto shader = Shader::Create(filepath); 52 | Add(shader); 53 | return shader; 54 | } 55 | Ref ShaderLibrary::Load(const std::string &name, const std::string &filepath) { 56 | auto shader = Shader::Create(filepath); 57 | Add(shader); 58 | return shader; 59 | } 60 | Ref ShaderLibrary::Get(const std::string &name) { 61 | RC_CORE_ASSERT(Exists(name), "Shader already bound"); 62 | return m_Shader[name]; 63 | } 64 | bool ShaderLibrary::Exists(const std::string &name) { 65 | return m_Shader.find(name) != m_Shader.end(); 66 | } 67 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/Shader.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/26/21. 3 | // 4 | #pragma once 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | typedef uint32_t RendererID; 11 | namespace RcEngine{ 12 | 13 | class Shader{ 14 | public: 15 | virtual ~Shader() = default; 16 | virtual void Bind() const =0; 17 | virtual void Unbind() const =0; 18 | 19 | virtual void SetFloat(const std::string& name, const float value)=0; 20 | virtual void SetInt(const std::string& name, const int value)=0; 21 | virtual void SetIntArray(const std::string& name, int* values, uint32_t count)=0; 22 | virtual void SetFloat3(const std::string& name, const glm::vec3& value) =0; 23 | virtual void SetFloat4(const std::string& name,const glm::vec4& value) =0; 24 | virtual void SetMat4(const std::string& name, const glm::mat4& value)=0; 25 | 26 | virtual const std::string& GetName() const =0; 27 | 28 | static Ref Create(const std::string& name, const std::string& vertexSrc, const std::string& fragmentSrc); 29 | static Ref Create(const std::string& filepath); 30 | }; 31 | class ShaderLibrary{ 32 | public: 33 | void Add(const Ref& shader); 34 | void Add(const std::string& name, const Ref& shader); 35 | Ref Load(const std::string& filepath); 36 | Ref Load(const std::string& name, const std::string& filepath); 37 | 38 | Ref Get(const std::string& name); 39 | 40 | bool Exists(const std::string& name); 41 | private: 42 | std::unordered_map> m_Shader; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/SubTexture2D.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/4/21. 3 | // 4 | 5 | #include "rcpch.h" 6 | #include "SubTexture2D.h" 7 | 8 | namespace RcEngine{ 9 | SubTexture2D::SubTexture2D(const Ref &texture, const glm::vec2 &min, const glm::vec2 &max) 10 | : m_Texture(texture){ 11 | m_TexCoords[0] = {min.x, min.y}; 12 | m_TexCoords[1] = {max.x, min.y}; 13 | m_TexCoords[2] = {max.x, max.y}; 14 | m_TexCoords[3] = {min.x, max.y}; 15 | } 16 | Ref SubTexture2D::CreateFromCoords(const Ref& texture, 17 | const glm::vec2& coords, const glm::vec2& cellSize, 18 | const glm::vec2& spriteSize) { 19 | 20 | glm::vec2 min = {(coords.x *cellSize.x)/texture->GetWidth(),(coords.y*cellSize.y)/texture->GetHeight()}; 21 | glm::vec2 max = {((coords.x+spriteSize.x)*cellSize.x)/texture->GetWidth(),((coords.y+spriteSize.y)*cellSize.y)/texture->GetHeight()}; 22 | 23 | return CreateRef(texture,min,max); 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/SubTexture2D.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/4/21. 3 | // 4 | #pragma once 5 | 6 | #include "Texture.h" 7 | #include 8 | 9 | #ifndef RCENGINE_CLION_SUBTEXTURE2D_H 10 | #define RCENGINE_CLION_SUBTEXTURE2D_H 11 | namespace RcEngine{ 12 | class SubTexture2D{ 13 | public: 14 | SubTexture2D(const Ref& texture, const glm::vec2& min, 15 | const glm::vec2& max); 16 | 17 | const Ref GetTexture() const {return m_Texture;} 18 | const glm::vec2* GetTexCoords() const{return m_TexCoords;} 19 | 20 | 21 | static Ref CreateFromCoords(const Ref& texture, 22 | const glm::vec2& coords, const glm::vec2& cellSize, 23 | const glm::vec2& spriteSize = {1,1}); 24 | private: 25 | 26 | Ref m_Texture; 27 | 28 | glm::vec2 m_TexCoords[4]; 29 | 30 | }; 31 | } 32 | #endif //RCENGINE_CLION_SUBTEXTURE2D_H 33 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/Texture.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/19/21. 3 | // 4 | 5 | #include "rcpch.h" 6 | #include "Texture.h" 7 | #include "Renderer.h" 8 | #include "Platform/OpenGL/OpenGLTexture.h" 9 | 10 | namespace RcEngine{ 11 | Ref Texture2D::Create(const char* path) { 12 | switch (Renderer::GetAPI()) { 13 | case RenderAPI::API::None: 14 | RC_CORE_ASSERT(false, "No Render API"); 15 | return nullptr; 16 | case RenderAPI::API::OpenGL: 17 | //TODO: check OpenGL version 18 | return std::make_shared(path); 19 | case RenderAPI::API::Vulkan: 20 | RC_CORE_ASSERT(false, "Vulkan not currently supported"); 21 | return nullptr; 22 | } 23 | RC_CORE_ASSERT(false, "Renderer not defined"); 24 | return nullptr; 25 | } 26 | Ref Texture2D::Create(uint32_t width, uint32_t height) { 27 | switch (Renderer::GetAPI()) { 28 | case RenderAPI::API::None: 29 | RC_CORE_ASSERT(false, "No Render API"); 30 | return nullptr; 31 | case RenderAPI::API::OpenGL: 32 | //TODO: check OpenGL version 33 | return std::make_shared(width,height); 34 | case RenderAPI::API::Vulkan: 35 | RC_CORE_ASSERT(false, "Vulkan not currently supported"); 36 | return nullptr; 37 | } 38 | RC_CORE_ASSERT(false, "Renderer not defined"); 39 | return nullptr; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/Texture.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/19/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Core/Core.h" 6 | 7 | #ifndef RCENGINE_CLION_TEXTURE_H 8 | #define RCENGINE_CLION_TEXTURE_H 9 | 10 | namespace RcEngine{ 11 | class Texture{ 12 | public: 13 | virtual ~Texture() = default; 14 | virtual uint32_t GetWidth() const =0; 15 | virtual uint32_t GetHeight() const= 0; 16 | 17 | virtual uint32_t GetRendererID() const =0; 18 | 19 | virtual void Bind(uint32_t slot = 0) const =0; 20 | virtual void SetData(void* data, uint32_t size, uint32_t slot =0) const =0; 21 | virtual std::string getPath() const =0; 22 | 23 | virtual bool operator==(const Texture& otherTexture) const = 0; 24 | protected: 25 | static std::string m_Path; 26 | }; 27 | class Texture2D: public Texture{ 28 | public: 29 | static Ref Create(const char* path); 30 | static Ref Create(uint32_t width, uint32_t height); 31 | }; 32 | } 33 | 34 | #endif //RCENGINE_CLION_TEXTURE_H 35 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/UniformBuffer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/2/21. 3 | // 4 | #include "rcpch.h" 5 | #include "UniformBuffer.h" 6 | 7 | #include "RcEngine/Renderer/Renderer.h" 8 | #include "Platform/OpenGL/OpenGLUniformBuffer.h" 9 | 10 | namespace RcEngine{ 11 | 12 | Ref UniformBuffer::Create(uint32_t size, uint32_t binding) { 13 | switch (Renderer::GetAPI()){ 14 | case RenderAPI::API::None: RC_CORE_ASSERT(false,"No Renderer API defined"); 15 | return nullptr; 16 | case RenderAPI::API::OpenGL: return CreateRef(size,binding); 17 | case RenderAPI::API::Vulkan: RC_CORE_ASSERT(false,"Vulkan not implemented"); 18 | return nullptr; 19 | case RenderAPI::API::Metal:RC_CORE_ASSERT(false,"Metal not implemented"); 20 | return nullptr; 21 | } 22 | RC_CORE_ASSERT(false, "Unknown RendererAPI "); 23 | return nullptr; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/UniformBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 8/2/21. 3 | // 4 | #pragma once 5 | 6 | #include "RcEngine/Core/Core.h" 7 | 8 | #ifndef RCENGINE_UNIFORMBUFFER_H 9 | #define RCENGINE_UNIFORMBUFFER_H 10 | namespace RcEngine{ 11 | class UniformBuffer{ 12 | public: 13 | virtual ~UniformBuffer(){}; 14 | virtual void SetData(const void* data, uint32_t size, uint32_t offset =0) =0; 15 | 16 | static Ref Create(uint32_t size, uint32_t binding); 17 | }; 18 | } 19 | #endif //RCENGINE_UNIFORMBUFFER_H 20 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/VertexArray.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/29/21. 3 | // 4 | 5 | #include "rcpch.h" 6 | #include "VertexArray.h" 7 | 8 | #include "Renderer.h" 9 | #include "RenderAPI.h" 10 | 11 | #include "Platform/OpenGL/OpenGLVertexArray.h" 12 | 13 | namespace RcEngine{ 14 | Ref VertexArray::Create() { 15 | switch (Renderer::GetAPI()) { 16 | case RenderAPI::API::None: 17 | RC_CORE_ASSERT(false, "No Render API"); 18 | return nullptr; 19 | case RenderAPI::API::OpenGL: 20 | //TODO: check OpenGL version 21 | return std::make_shared(); 22 | case RenderAPI::API::Vulkan: 23 | RC_CORE_ASSERT(false, "Vulkan not currently supported"); 24 | return nullptr; 25 | } 26 | RC_CORE_ASSERT(false, "Renderer not defined"); 27 | return nullptr; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Renderer/VertexArray.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/29/21. 3 | // 4 | #pragma once 5 | #include 6 | #include "RcEngine/Renderer/Buffer.h" 7 | 8 | #ifndef RCENGINE_CLION_VERTEXARRAY_H 9 | #define RCENGINE_CLION_VERTEXARRAY_H 10 | 11 | namespace RcEngine { 12 | class VertexArray { 13 | public: 14 | 15 | virtual ~VertexArray() {} 16 | 17 | virtual void Bind() const = 0; 18 | 19 | virtual void Unbind() const = 0; 20 | 21 | virtual void AddVertexBuffer(const Ref& vertexBuffer) =0; 22 | virtual void SetIndexBuffer(const Ref& indexBuffer)=0; 23 | 24 | virtual const std::vector> & GetVertexBuffers() const =0; 25 | virtual const Ref & GetIndexBuffer() const =0; 26 | 27 | 28 | static Ref Create(); 29 | }; 30 | } 31 | 32 | #endif //RCENGINE_CLION_VERTEXARRAY_H 33 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Scene/Entity.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/7/21. 3 | // 4 | 5 | #include "rcpch.h" 6 | #include "Entity.h" 7 | 8 | namespace RcEngine{ 9 | Entity::Entity(entt::entity handle, Scene* scene) 10 | : m_EntityHandle(handle), m_Scene(scene){ 11 | 12 | } 13 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Scene/Entity.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/7/21. 3 | // 4 | #pragma once 5 | 6 | #include "Scene.h" 7 | #include "RcEngine/Core/UUID.h" 8 | #include "Component.h" 9 | #include "external/entt/include/entt.hpp" 10 | 11 | #ifndef RCENGINE_CLION_ENTITY_H 12 | #define RCENGINE_CLION_ENTITY_H 13 | namespace RcEngine{ 14 | class Entity{ 15 | public: 16 | Entity() = default; 17 | Entity(entt::entity handle, Scene* scene); 18 | Entity(const Entity& other) = default; 19 | 20 | template 21 | T& AddComponent(Args&&... args){ 22 | RC_CORE_ASSERT(!HasComponent(), "Entity already has component"); 23 | T& component = m_Scene->m_Registry.template emplace(m_EntityHandle,std::forward(args)...); 24 | m_Scene->OnAdded(*this,component); 25 | return component; 26 | } 27 | 28 | template 29 | T& GetComponent(){ 30 | RC_CORE_ASSERT(HasComponent(), "Entity does not have component"); 31 | return m_Scene->m_Registry.get(m_EntityHandle); 32 | } 33 | 34 | template 35 | bool HasComponent(){ 36 | return m_Scene->m_Registry.any_of(m_EntityHandle); 37 | } 38 | template 39 | bool RemoveComponent(){ 40 | RC_CORE_ASSERT(HasComponent(), "Entity does not have component"); 41 | m_Scene->m_Registry.remove(m_EntityHandle); 42 | } 43 | 44 | UUID GetUUID() {return GetComponent().ID;} 45 | 46 | operator bool() const{return m_EntityHandle != entt::null;} 47 | 48 | operator uint32_t() const {return (uint32_t)m_EntityHandle;} 49 | 50 | operator entt::entity() const{return m_EntityHandle;} 51 | 52 | bool operator==(const Entity& other) const{return m_EntityHandle== other.m_EntityHandle && m_Scene == other.m_Scene;} 53 | bool operator!=(const Entity& other)const { 54 | return !(*this == other); 55 | } 56 | private: 57 | entt::entity m_EntityHandle{ entt::null }; 58 | Scene* m_Scene = nullptr; // 12 byte Entity 59 | }; 60 | } 61 | #endif //RCENGINE_CLION_ENTITY_H 62 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Scene/Scene.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/6/21. 3 | // 4 | #pragma once 5 | #include "RcEngine/Core/Timestep.h" 6 | #include "Component.h" 7 | #include "../entt/include/entt.hpp" 8 | 9 | #include "RcEngine/Renderer/EditorCamera.h" 10 | 11 | 12 | #ifndef RCENGINE_CLION_SCENE_H 13 | #define RCENGINE_CLION_SCENE_H 14 | 15 | class b2World; 16 | namespace RcEngine{ 17 | class Entity; 18 | class Scene{ 19 | public: 20 | Scene(); 21 | ~Scene(); 22 | 23 | static Ref Copy(Ref other); 24 | 25 | Entity CreateEntity(const std::string& name=std::string()); 26 | void DestroyEntity(Entity entity); 27 | Entity DuplicateEntity(Entity& other); 28 | 29 | void OnRuntimeStart(); 30 | void OnRuntimeStop(); 31 | 32 | void OnSimulationStart(); 33 | void OnSimulationStop(); 34 | 35 | void OnUpdateRuntime(Timestep ts); 36 | void OnUpdateSimulation(Timestep ts, EditorCamera& camera); 37 | void OnUpdateEditor(Timestep ts, EditorCamera& camera); 38 | 39 | void OnViewportReSize(uint32_t width, uint32_t height); 40 | 41 | Entity GetPrimaryCameraEntity(); 42 | Entity CreateEntityWithUUID(UUID uuid, const std::string& name); 43 | Entity CloneEntityWithUUID(UUID uuid, Entity& other); 44 | 45 | private: 46 | template 47 | void OnAdded(Entity entity, T& component); 48 | 49 | void OnPhysics2DStart(); 50 | void OnPhysics2DStop(); 51 | void RenderScene(EditorCamera& camera); 52 | private: 53 | uint32_t m_ViewportWidth = 0,m_ViewportHeight = 0; 54 | 55 | entt::registry m_Registry; 56 | 57 | b2World* m_world = nullptr; 58 | 59 | friend class Entity; 60 | friend class SceneSerializer; 61 | friend class SceneHierarchyPanel; 62 | 63 | }; 64 | } 65 | #endif //RCENGINE_CLION_SCENE_H 66 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Scene/SceneCamera.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/7/21. 3 | // 4 | #include "rcpch.h" 5 | #include "SceneCamera.h" 6 | 7 | #include 8 | 9 | namespace RcEngine{ 10 | SceneCamera::SceneCamera() { 11 | RecalculateProjection(); 12 | } 13 | void SceneCamera::SetViewPortSize(uint32_t width, 14 | uint32_t height) { 15 | RC_CORE_ASSERT("width and height greater than zero", width > 0 && height > 0); 16 | m_AspectRatio = (float)width / (float)height; 17 | RecalculateProjection(); 18 | } 19 | void SceneCamera::SetOrthographic(float size, 20 | float nearClip, float farClip) { 21 | m_ProjectionType = ProjectionType::Ortho; 22 | 23 | m_OrthographicSize = size; 24 | m_OrthographicNear = nearClip; 25 | m_OrthographicFar = farClip; 26 | RecalculateProjection(); 27 | 28 | } 29 | void SceneCamera::SetIsometric(float size, float nearClip, float farclip) { 30 | m_ProjectionType = ProjectionType::Iso; 31 | 32 | m_OrthographicSize = size; 33 | m_OrthographicNear = nearClip; 34 | m_OrthographicFar = farclip; 35 | RecalculateProjection(); 36 | } 37 | void SceneCamera::SetPerspective(float fov, float nearclip, float farclip) { 38 | m_ProjectionType = ProjectionType::Perspective; 39 | m_PerspectiveFov = fov; 40 | m_PerspectiveNear = nearclip; 41 | m_PerspectiveFar = farclip; 42 | 43 | RecalculateProjection(); 44 | } 45 | 46 | void SceneCamera::RecalculateProjection() { 47 | if(m_ProjectionType == ProjectionType::Perspective){ 48 | m_Projection = glm::perspective(m_PerspectiveFov, m_AspectRatio, m_PerspectiveNear,m_PerspectiveFar); 49 | } 50 | if(m_ProjectionType == ProjectionType::Ortho){ 51 | float orthoLeft= -m_OrthographicSize * m_AspectRatio * 0.5f; 52 | float orthoRight =m_OrthographicSize * m_AspectRatio * 0.5f; 53 | float orthoBottom = -m_OrthographicSize * 0.5f; 54 | float orthoTop = m_OrthographicSize * 0.5f; 55 | 56 | 57 | m_Projection = glm::ortho(orthoLeft, orthoRight, orthoBottom,orthoTop, 58 | m_OrthographicNear, m_OrthographicFar); 59 | } 60 | if(m_ProjectionType == ProjectionType::Iso){ 61 | float isoleft= 0; 62 | float isoright =m_OrthographicSize * m_AspectRatio * 0.5f; 63 | float isobottom = -m_OrthographicSize * 0.5f; 64 | float isotop = m_OrthographicSize * 0.5f; 65 | 66 | m_Projection = glm::ortho(isoleft, isoright, isobottom,isotop, 67 | m_IsometricNear, m_IsometricFar); 68 | } 69 | 70 | } 71 | } 72 | 73 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Scene/SceneSerializer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/9/21. 3 | // 4 | #pragma once 5 | #include "Scene.h" 6 | 7 | #ifndef RCENGINE_SCENESERIALIZER_H 8 | #define RCENGINE_SCENESERIALIZER_H 9 | 10 | 11 | namespace RcEngine{ 12 | class SceneSerializer{ 13 | public: 14 | SceneSerializer (const Ref& scene); 15 | 16 | void Serialize(const std::string& filepath); 17 | bool SerializeRuntime(const std::string& filepath); 18 | 19 | bool DeSerialize(const std::string& filepath); 20 | static bool DeSerializeRuntime(const std::string& filepath); 21 | 22 | void SerializeExport(const std::string& filepath); 23 | private: 24 | Ref m_Scene; 25 | }; 26 | } 27 | 28 | #endif //RCENGINE_SCENESERIALIZER_H 29 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Scene/ScriptableEntity.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/8/21. 3 | // 4 | #pragma once 5 | #include "Entity.h" 6 | 7 | #ifndef RCENGINE_CLION_SCRIPTABLEENTITY_H 8 | #define RCENGINE_CLION_SCRIPTABLEENTITY_H 9 | namespace RcEngine{ 10 | class ScriptableEntity{ 11 | public: 12 | virtual ~ScriptableEntity(){}; 13 | 14 | template 15 | T& GetComponent(){ 16 | 17 | return m_Entity.template GetComponent(); 18 | } 19 | protected: 20 | virtual void OnCreate(){}; 21 | virtual void OnDestroy(){} 22 | virtual void OnUpdate(Timestep ts){}; 23 | private: 24 | Entity m_Entity; 25 | friend class Scene; 26 | }; 27 | } 28 | #endif //RCENGINE_CLION_SCRIPTABLEENTITY_H 29 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Sound/SoundBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/13/22. 3 | // 4 | 5 | #ifndef RCGAMEENGINE_SOUNDBUFFER_H 6 | #define RCGAMEENGINE_SOUNDBUFFER_H 7 | #include "AL/al.h" 8 | #include "sndfile.h" 9 | 10 | namespace RcEngine{ 11 | class SoundBuffer{ 12 | public: 13 | SoundBuffer(const char* filename); 14 | ~SoundBuffer(); 15 | 16 | ALint Source(){return a_Source;} 17 | 18 | bool isPlaying(){return Playing;} 19 | 20 | void Play(); 21 | void Pause(); 22 | 23 | void PlayPause(){ 24 | if(Playing){ 25 | Play(); 26 | }else{ 27 | Pause(); 28 | } 29 | Playing = !Playing; 30 | }; 31 | void Stop(); 32 | 33 | void UpdateBuffer(); 34 | 35 | std::string getPath(){return m_Path;} 36 | 37 | void SetGain(const float& val); 38 | void Duration(float& val); 39 | 40 | private: 41 | ALuint a_Source; 42 | ALint m_state; 43 | 44 | static const int BUFFER_SAMPLES = 8192; 45 | static const int NUM_BUFFERS = 4; 46 | 47 | ALuint a_Buffers[NUM_BUFFERS]; 48 | 49 | SNDFILE * p_sndfile; 50 | SF_INFO p_Sinfo; 51 | short* membuf; 52 | ALenum Format; 53 | 54 | bool Playing = false; 55 | 56 | std::string m_Path; 57 | }; 58 | } 59 | #endif //RCGAMEENGINE_SOUNDBUFFER_H 60 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Sound/SoundDevice.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/23/22. 3 | // 4 | 5 | #include "SoundDevice.h" 6 | #include 7 | #include 8 | #include 9 | #include "RcEngine/Core/Core.h" 10 | 11 | 12 | 13 | namespace RcEngine{ 14 | static SoundDevice* _instance = nullptr; 15 | 16 | SoundDevice::SoundDevice() { 17 | p_ALCDevice = alcOpenDevice(nullptr); 18 | 19 | RC_ASSERT(p_ALCDevice,"Failed to get Sound Device"); 20 | 21 | p_ALCContext = alcCreateContext(p_ALCDevice, nullptr); 22 | RC_ASSERT(p_ALCContext,"Failed to set context"); 23 | 24 | RC_ASSERT(alcMakeContextCurrent(p_ALCContext),"Failed to make context current"); 25 | 26 | const ALCchar * name = nullptr; 27 | if(alcIsExtensionPresent(p_ALCDevice,"ALC_ENUMERATE_ALL_EXT")) 28 | name = alcGetString(p_ALCDevice,ALC_ALL_DEVICES_SPECIFIER); 29 | if(!name|| alcGetError(p_ALCDevice)!= AL_NO_ERROR) 30 | name = alcGetString(p_ALCDevice,ALC_DEVICE_SPECIFIER); 31 | RC_INFO("Opened %s",name); 32 | 33 | } 34 | SoundDevice::~SoundDevice() { 35 | alcMakeContextCurrent(nullptr); 36 | alcDestroyContext(p_ALCContext); 37 | alcCloseDevice(p_ALCDevice); 38 | } 39 | float SoundDevice::GetGain() { 40 | float curr_gain; 41 | alGetListenerf(AL_GAIN,&curr_gain); 42 | return curr_gain; 43 | } 44 | void SoundDevice::GetOrientation(float &ori) { 45 | alGetListenerfv(AL_ORIENTATION,&ori); 46 | } 47 | void SoundDevice::GetLocation(float &x, float &y, float &z) { 48 | alGetListener3f(AL_POSITION,&x,&y,&z); 49 | } 50 | void SoundDevice::SetLocation(const float &x, const float &y, const float &z) { 51 | alListener3f(AL_POSITION,x,y,z); 52 | } 53 | 54 | void SoundDevice::SetGain(const float &val) { 55 | float newVol = val; 56 | if (newVol < 0.f) 57 | newVol = 0.f; 58 | else if (newVol > 5.f) 59 | newVol = 5.f; 60 | 61 | alListenerf(AL_GAIN, newVol); 62 | } 63 | SoundDevice* SoundDevice::Get(){ 64 | Init(); 65 | return _instance; 66 | } 67 | void SoundDevice::Init() { 68 | if(_instance == nullptr) 69 | _instance = new SoundDevice(); 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Sound/SoundDevice.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/23/22. 3 | // 4 | 5 | #ifndef RCGAMEENGINE_SOUNDDEVICE_H 6 | #define RCGAMEENGINE_SOUNDDEVICE_H 7 | #include "AL/alc.h" 8 | 9 | 10 | #define SD_INIT SoundDEvice::Init() 11 | #define LISTENER SoundDevice::Get() 12 | 13 | namespace RcEngine{ 14 | class SoundDevice{ 15 | public: 16 | static SoundDevice* Get(); 17 | static void Init(); 18 | 19 | void GetLocation(float &x, float &y, float &z); 20 | 21 | void GetOrientation(float &ori); 22 | float GetGain(); 23 | 24 | void SetLocation(const float &x, const float &y, const float &z); 25 | 26 | void SetGain(const float& val); 27 | 28 | private: 29 | SoundDevice(); 30 | ~SoundDevice(); 31 | 32 | ALCdevice* p_ALCDevice; 33 | ALCcontext* p_ALCContext; 34 | }; 35 | } 36 | 37 | #endif //RCGAMEENGINE_SOUNDDEVICE_H 38 | -------------------------------------------------------------------------------- /RcEngine/src/RcEngine/Utils/PlatformUtils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/9/21. 3 | // 4 | #pragma once 5 | #include 6 | 7 | #ifndef RCENGINE_PLATFORMUTILS_H 8 | #define RCENGINE_PLATFORMUTILS_H 9 | namespace RcEngine{ 10 | class FileDialogs{ 11 | public: 12 | static std::string OpenFile(const char* filter); 13 | static std::string SaveFile(const char* filter); 14 | static void OpenExplorer(const char* path); 15 | }; 16 | 17 | } 18 | #endif //RCENGINE_PLATFORMUTILS_H 19 | -------------------------------------------------------------------------------- /RcEngine/src/rcpch.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/20/21. 3 | // 4 | #include "rcpch.h" -------------------------------------------------------------------------------- /RcEngine/src/rcpch.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 5/20/21. 3 | // 4 | #pragma once 5 | 6 | // Included headers for RcEngine applications 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "RcEngine/Core/Log.h" 22 | #include "RcEngine/Core/Core.h" 23 | #include "RcEngine/Core/Layer.h" 24 | 25 | ///Renderer//////////////////////////// 26 | #include "RcEngine/Renderer/Renderer.h" 27 | #include "RcEngine/Renderer/Buffer.h" 28 | #include "RcEngine/Renderer/Shader.h" 29 | /////////////////////////////////////// 30 | 31 | #include "RcEngine/Debug/Instrumentor.h" 32 | 33 | #ifdef RC_PLATFORM_WINDOWS 34 | #include 35 | #endif 36 | -------------------------------------------------------------------------------- /RcGame/Assets/Game/Textures/CC_City_Exterior_A2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcGame/Assets/Game/Textures/CC_City_Exterior_A2.png -------------------------------------------------------------------------------- /RcGame/Assets/Game/Textures/CC_City_Exterior_B.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcGame/Assets/Game/Textures/CC_City_Exterior_B.png -------------------------------------------------------------------------------- /RcGame/Assets/Game/Textures/TILESET-LICENCE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcGame/Assets/Game/Textures/TILESET-LICENCE.txt -------------------------------------------------------------------------------- /RcGame/Assets/Shaders/FlatColor.glsl: -------------------------------------------------------------------------------- 1 | #type vertex 2 | #version 410 core 3 | 4 | layout(location = 0) in vec3 a_Position; 5 | 6 | uniform mat4 u_ViewProjection; 7 | uniform mat4 u_Transform; 8 | 9 | out vec3 v_Position; 10 | void main() 11 | { 12 | v_Position = a_Position; 13 | gl_Position = u_ViewProjection * u_Transform * vec4(a_Position, 1.0); 14 | } 15 | 16 | #type fragment 17 | #version 410 core 18 | 19 | layout(location = 0) out vec4 color; 20 | 21 | in vec3 v_Position; 22 | 23 | uniform vec4 u_Color; 24 | 25 | void main() 26 | { 27 | color = u_Color; 28 | } -------------------------------------------------------------------------------- /RcGame/Assets/Shaders/FlatColorFrag.glsl: -------------------------------------------------------------------------------- 1 | #version 410 core 2 | 3 | layout(location = 0) out vec4 color; 4 | 5 | in vec3 v_Position; 6 | 7 | uniform vec3 u_Color; 8 | uniform sampler2D u_Sample; 9 | 10 | void main() 11 | { 12 | color = vec4(u_Color, 1.0); 13 | } -------------------------------------------------------------------------------- /RcGame/Assets/Shaders/FlatColorShader.glsl: -------------------------------------------------------------------------------- 1 | #version 410 core 2 | 3 | layout(location = 0) in vec3 a_Position; 4 | 5 | uniform mat4 u_ViewProjection; 6 | uniform mat4 u_Transform; 7 | 8 | out vec3 v_Position; 9 | void main() 10 | { 11 | v_Position = a_Position; 12 | gl_Position = u_ViewProjection * u_Transform * vec4(a_Position, 1.0); 13 | } -------------------------------------------------------------------------------- /RcGame/Assets/Shaders/FragShader.glsl: -------------------------------------------------------------------------------- 1 | #version 410 core 2 | 3 | layout(location=0) out vec4 color; 4 | 5 | in vec4 v_Color; 6 | 7 | void main(void) 8 | { 9 | color = v_Color; 10 | 11 | } -------------------------------------------------------------------------------- /RcGame/Assets/Shaders/TextureShader.glsl: -------------------------------------------------------------------------------- 1 | #version 410 core 2 | 3 | layout(location = 0) in vec3 a_Position; 4 | layout(location = 1) in vec2 a_TexCoord; 5 | uniform mat4 u_ViewProjection; 6 | uniform mat4 u_Transform; 7 | out vec2 v_TexCoord; 8 | void main() 9 | { 10 | v_TexCoord = a_TexCoord; 11 | gl_Position = u_ViewProjection * u_Transform * vec4(a_Position, 1.0); 12 | } -------------------------------------------------------------------------------- /RcGame/Assets/Shaders/TextureShaderFrag.glsl: -------------------------------------------------------------------------------- 1 | #version 410 core 2 | 3 | layout(location = 0) out vec4 color; 4 | in vec2 v_TexCoord; 5 | 6 | uniform sampler2D u_Texture; 7 | void main() 8 | { 9 | color = texture(u_Texture, v_TexCoord); 10 | } -------------------------------------------------------------------------------- /RcGame/Assets/Shaders/VertShader.glsl: -------------------------------------------------------------------------------- 1 | #version 410 core 2 | 3 | out vec4 color; 4 | 5 | 6 | layout(location =0) in vec3 a_Position; 7 | layout(location =1) in vec4 a_Color; 8 | 9 | uniform mat4 u_ViewProjection; 10 | uniform mat4 u_Transform; 11 | 12 | out vec3 v_Position; 13 | out vec4 v_Color; 14 | 15 | void main(void) 16 | { 17 | v_Position = a_Position; 18 | v_Color= vec4(a_Position, 1.0) * 0.5 + vec4(0.5, 0.5, 0.5, 0.5); 19 | 20 | v_Color = a_Color; 21 | gl_Position = u_ViewProjection * u_Transform * vec4(v_Position,1.0); 22 | } -------------------------------------------------------------------------------- /RcGame/Assets/textures/Default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcGame/Assets/textures/Default.jpg -------------------------------------------------------------------------------- /RcGame/Assets/textures/Tiles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcGame/Assets/textures/Tiles.png -------------------------------------------------------------------------------- /RcGame/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.19) 2 | 3 | project(RcGame) 4 | set(CMAKE_CXX_STANDARD 17) 5 | 6 | 7 | set(SOURCE_FILES 8 | RcApp.cpp RcGame2D.cpp RcGame2D.h ParticleSystem.h ParticleSystem.cpp) 9 | 10 | #Windows App configuration--------------------------------- 11 | if(WIN32) 12 | add_definitions(-DRC_PLATFORM_WINDOWS) 13 | file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Assets DESTINATION ${CMAKE_BINARY_DIR}) 14 | 15 | add_executable (RcGame ${SOURCE_FILES}) 16 | elseif(UNIX AND NOT APPLE) 17 | add_definitions(-DRC_PLATFORM_UNIX) 18 | file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Assets DESTINATION ${CMAKE_BINARY_DIR}) 19 | 20 | add_executable (RcGame ${SOURCE_FILES}) 21 | endif(WIN32) 22 | #---------------------------------------------------------- 23 | 24 | #Apple App Icon configuration 25 | if(APPLE) 26 | set(MACOSX_BUNDLE_ICON_FILE AppImage.icns ) 27 | set(RCGAME_ICON ${CMAKE_CURRENT_SOURCE_DIR}/media/AppImage.icns) 28 | set(UI_OS_EXTRAS ${RCGAME_ICON}) 29 | 30 | set(CPACK_BUNDLE_ICON ${RCGAME_ICON}) 31 | set(CPACK_PACKAGE_ICON ${RCGAME_ICON}) 32 | 33 | set(ASSETS ${CMAKE_CURRENT_SOURCE_DIR}/Assets) 34 | set_source_files_properties(${RcGame_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) 35 | file( COPY ${ASSETS} DESTINATION "RcGame.app/Contents/Resources/" ) 36 | 37 | # code signing--------------------------------------------- 38 | set(RCGAME_MACOSX_CODESIGN_CERT "" CACHE STRING "Name of the Apple Developer to sign application") 39 | MARK_AS_ADVANCED(RCGAME_MACOSX_CODESIGN_CERT) 40 | set(CPACK_BUNDLE_APPLE_CERT_APP ${RCGAME_MACOSX_CODESIGN_CERT}) 41 | #---------------------------------------------------------- 42 | 43 | add_executable (RcGame MACOSX_BUNDLE ${RCGAME_ICON} ${SOURCE_FILES}) 44 | 45 | endif(APPLE) 46 | #---------------------------------------------------------- 47 | 48 | include_directories ("${CMAKE_SOURCE_DIR}/RcEngine/src") 49 | include_directories ("${CMAKE_SOURCE_DIR}/RcEngine/external/glm/glm") 50 | include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/RcEngine/entt/include") 51 | 52 | 53 | target_link_libraries(RcGame rcengine) -------------------------------------------------------------------------------- /RcGame/ParticleSystem.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 7/2/21. 3 | // 4 | #pragma once 5 | #include "RcEngine.h" 6 | 7 | #ifndef RCENGINE_CLION_PARTICLESYSTEM_H 8 | #define RCENGINE_CLION_PARTICLESYSTEM_H 9 | struct ParticleProps{ 10 | glm::vec2 Position; 11 | glm::vec2 Velocity, VelocityVariation; 12 | glm::vec4 ColorBegin, ColorEnd; 13 | float SizeBegin, SizeEnd, SizeVariation; 14 | float LifeTime = 4.0f; 15 | }; 16 | class ParticleSystem{ 17 | public: 18 | ParticleSystem(uint32_t maxParticles= 100000); 19 | 20 | void OnUpdate(RcEngine::Timestep ts); 21 | void OnRender(RcEngine::OrthoCamera& camera); 22 | 23 | void Emit(const ParticleProps& particleProps); 24 | private: 25 | struct Particle{ 26 | glm::vec2 Position; 27 | glm::vec2 Velocity; 28 | glm::vec4 ColorBegin, ColorEnd; 29 | float Rotation = 0.0f; 30 | float SizeBegin, SizeEnd; 31 | 32 | float LifeTime = 1.0f; 33 | float LifeRemaining = 0.0f; 34 | 35 | bool Active = false; 36 | }; 37 | std::vector m_ParticlePool; 38 | uint32_t m_PoolIndex =0; 39 | 40 | GLuint m_QuadVA = 0; 41 | std::unique_ptr m_ParticleShader; 42 | GLint m_ParticleShaderViewProj, m_ParticleShaderTransform, m_ParticleShaderColor; 43 | }; 44 | 45 | 46 | #endif //RCENGINE_CLION_PARTICLESYSTEM_H 47 | -------------------------------------------------------------------------------- /RcGame/RcGame2D.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Tristan Zippert on 6/24/21. 3 | // 4 | #pragma once 5 | #include "RcEngine.h" 6 | 7 | #include "ParticleSystem.h" 8 | 9 | #ifndef RCENGINE_CLION_RCGAME2D_H 10 | #define RCENGINE_CLION_RCGAME2D_H 11 | class RcGame2D : public RcEngine::Layer{ 12 | public: 13 | RcGame2D(); 14 | virtual ~RcGame2D() = default; 15 | 16 | virtual void OnAttach() override; 17 | virtual void OnDetach() override; 18 | 19 | void OnUpdate(RcEngine::Timestep ts) override; 20 | virtual void OnImGuiRender() override; 21 | void OnEvent(RcEngine::Event& e) override; 22 | private: 23 | RcEngine::OrthoCameraController m_CameraController; 24 | 25 | RcEngine::Ref m_FlatColorShader; 26 | RcEngine::Ref m_SquareVA; 27 | 28 | float m_TextureTile = 1.0f, m_Rotation =0.0f; 29 | 30 | glm::vec4 m_SquareColor = {0.8f,0.0f,0.0f,1.0f}; 31 | glm::vec4 m_TextureColor = {0.2f,0.3f,0.8f,1.0f}; 32 | 33 | ParticleSystem m_ParticleSystem; 34 | ParticleProps m_Particle; 35 | 36 | RcEngine::Ref m_BaseTexture; 37 | RcEngine::Ref m_SpriteSheet; 38 | RcEngine::Ref m_BackgroundSheet; 39 | RcEngine::Ref m_Sprite, m_Background; 40 | 41 | struct ProfileResult{ 42 | const char* Name; 43 | float time; 44 | }; 45 | std::vector m_Profiler; 46 | 47 | uint32_t m_MapWidth,m_MapHeight; 48 | 49 | std::unordered_map> s_TextureMap; 50 | 51 | }; 52 | #endif //RCENGINE_CLION_RCGAME2D_H 53 | -------------------------------------------------------------------------------- /RcGame/media/AppImage.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcGame/media/AppImage.icns -------------------------------------------------------------------------------- /RcGame/media/AppImage.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcGame/media/AppImage.ico -------------------------------------------------------------------------------- /RcGame/media/AppImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triscuitcircuit/rcengine/aed79bf7c3a035adbf30cc7be9abd223608b4a80/RcGame/media/AppImage.png -------------------------------------------------------------------------------- /cmake/FindFLAC.cmake: -------------------------------------------------------------------------------- 1 | # - Find FLAC 2 | # Find the native FLAC includes and libraries 3 | # 4 | # FLAC_INCLUDE_DIRS - where to find FLAC headers. 5 | # FLAC_LIBRARIES - List of libraries when using libFLAC. 6 | # FLAC_FOUND - True if libFLAC found. 7 | # FLAC_DEFINITIONS - FLAC compile definitons 8 | 9 | if (FLAC_INCLUDE_DIR) 10 | # Already in cache, be silent 11 | set (FLAC_FIND_QUIETLY TRUE) 12 | endif () 13 | 14 | find_package (Ogg QUIET) 15 | 16 | find_package (PkgConfig QUIET) 17 | pkg_check_modules(PC_FLAC QUIET flac) 18 | 19 | set(FLAC_VERSION ${PC_FLAC_VERSION}) 20 | 21 | find_path (FLAC_INCLUDE_DIR FLAC/stream_decoder.h 22 | HINTS 23 | ${PC_FLAC_INCLUDEDIR} 24 | ${PC_FLAC_INCLUDE_DIRS} 25 | ${FLAC_ROOT} 26 | ) 27 | 28 | # MSVC built libraries can name them *_static, which is good as it 29 | # distinguishes import libraries from static libraries with the same extension. 30 | find_library (FLAC_LIBRARY 31 | NAMES 32 | FLAC 33 | libFLAC 34 | libFLAC_dynamic 35 | libFLAC_static 36 | HINTS 37 | ${PC_FLAC_LIBDIR} 38 | ${PC_FLAC_LIBRARY_DIRS} 39 | ${FLAC_ROOT} 40 | ) 41 | 42 | # Handle the QUIETLY and REQUIRED arguments and set FLAC_FOUND to TRUE if 43 | # all listed variables are TRUE. 44 | include (FindPackageHandleStandardArgs) 45 | find_package_handle_standard_args (FLAC 46 | REQUIRED_VARS 47 | FLAC_LIBRARY 48 | FLAC_INCLUDE_DIR 49 | Ogg_FOUND 50 | VERSION_VAR 51 | FLAC_VERSION 52 | ) 53 | 54 | if (FLAC_FOUND) 55 | set (FLAC_INCLUDE_DIRS ${FLAC_INCLUDE_DIR}) 56 | set (FLAC_LIBRARIES ${FLAC_LIBRARY} ${OGG_LIBRARIES}) 57 | if (NOT TARGET FLAC::FLAC) 58 | add_library(FLAC::FLAC UNKNOWN IMPORTED) 59 | set_target_properties(FLAC::FLAC PROPERTIES 60 | INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}" 61 | IMPORTED_LOCATION "${FLAC_LIBRARY}" 62 | INTERFACE_LINK_LIBRARIES Ogg::ogg 63 | ) 64 | endif () 65 | endif () 66 | 67 | mark_as_advanced(FLAC_INCLUDE_DIR FLAC_LIBRARY) 68 | -------------------------------------------------------------------------------- /cmake/FindOgg.cmake: -------------------------------------------------------------------------------- 1 | # - Find ogg 2 | # Find the native ogg includes and libraries 3 | # 4 | # OGG_INCLUDE_DIRS - where to find ogg.h, etc. 5 | # OGG_LIBRARIES - List of libraries when using ogg. 6 | # OGG_FOUND - True if ogg found. 7 | 8 | if (OGG_INCLUDE_DIR) 9 | # Already in cache, be silent 10 | set(OGG_FIND_QUIETLY TRUE) 11 | endif () 12 | 13 | find_package (PkgConfig QUIET) 14 | pkg_check_modules (PC_OGG QUIET ogg>=1.3.0) 15 | 16 | set (OGG_VERSION ${PC_OGG_VERSION}) 17 | 18 | find_path (OGG_INCLUDE_DIR ogg/ogg.h 19 | HINTS 20 | ${PC_OGG_INCLUDEDIR} 21 | ${PC_OGG_INCLUDE_DIRS} 22 | ${OGG_ROOT} 23 | ) 24 | # MSVC built ogg may be named ogg_static. 25 | # The provided project files name the library with the lib prefix. 26 | find_library (OGG_LIBRARY 27 | NAMES 28 | ogg 29 | ogg_static 30 | libogg 31 | libogg_static 32 | HINTS 33 | ${PC_OGG_LIBDIR} 34 | ${PC_OGG_LIBRARY_DIRS} 35 | ${OGG_ROOT} 36 | ) 37 | # Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND 38 | # to TRUE if all listed variables are TRUE. 39 | include (FindPackageHandleStandardArgs) 40 | find_package_handle_standard_args (Ogg 41 | REQUIRED_VARS 42 | OGG_LIBRARY 43 | OGG_INCLUDE_DIR 44 | VERSION_VAR 45 | OGG_VERSION 46 | ) 47 | 48 | if (OGG_FOUND) 49 | set (OGG_LIBRARIES ${OGG_LIBRARY}) 50 | set (OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR}) 51 | 52 | if(NOT TARGET Ogg::ogg) 53 | add_library(Ogg::ogg UNKNOWN IMPORTED) 54 | set_target_properties(Ogg::ogg PROPERTIES 55 | INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}" 56 | IMPORTED_LOCATION "${OGG_LIBRARIES}" 57 | ) 58 | endif () 59 | endif () 60 | 61 | mark_as_advanced (OGG_INCLUDE_DIR OGG_LIBRARY) 62 | -------------------------------------------------------------------------------- /cmake/FindOpus.cmake: -------------------------------------------------------------------------------- 1 | # - Find opus 2 | # Find the native opus includes and libraries 3 | # 4 | # OPUS_INCLUDE_DIRS - where to find opus.h, etc. 5 | # OPUS_LIBRARIES - List of libraries when using opus. 6 | # OPUS_FOUND - True if Opus found. 7 | 8 | if (OPUS_INCLUDE_DIR) 9 | # Already in cache, be silent 10 | set(OPUS_FIND_QUIETLY TRUE) 11 | endif () 12 | 13 | find_package (Ogg QUIET) 14 | 15 | find_package (PkgConfig QUIET) 16 | pkg_check_modules(PC_OPUS QUIET opus>=1.1) 17 | 18 | set (OPUS_VERSION ${PC_OPUS_VERSION}) 19 | 20 | find_path (OPUS_INCLUDE_DIR opus/opus.h 21 | HINTS 22 | ${PC_OPUS_INCLUDEDIR} 23 | ${PC_OPUS_INCLUDE_DIRS} 24 | ${OPUS_ROOT} 25 | ) 26 | 27 | # MSVC built opus may be named opus_static. 28 | # The provided project files name the library with the lib prefix. 29 | 30 | find_library (OPUS_LIBRARY 31 | NAMES 32 | opus 33 | opus_static 34 | libopus 35 | libopus_static 36 | HINTS 37 | ${PC_OPUS_LIBDIR} 38 | ${PC_OPUS_LIBRARY_DIRS} 39 | ${OPUS_ROOT} 40 | ) 41 | 42 | # Handle the QUIETLY and REQUIRED arguments and set OPUS_FOUND 43 | # to TRUE if all listed variables are TRUE. 44 | include(FindPackageHandleStandardArgs) 45 | find_package_handle_standard_args (Opus 46 | REQUIRED_VARS 47 | OPUS_LIBRARY 48 | OPUS_INCLUDE_DIR 49 | OGG_FOUND 50 | VERSION_VAR 51 | OPUS_VERSION 52 | ) 53 | 54 | if (OPUS_FOUND) 55 | set (OPUS_LIBRARIES ${OPUS_LIBRARY}) 56 | set (OPUS_INCLUDE_DIRS ${OPUS_INCLUDE_DIR}) 57 | 58 | if (NOT TARGET Opus::opus) 59 | add_library (Opus::opus UNKNOWN IMPORTED) 60 | set_target_properties (Opus::opus PROPERTIES 61 | INTERFACE_INCLUDE_DIRECTORIES "${OPUS_INCLUDE_DIRS}" 62 | IMPORTED_LOCATION "${OPUS_LIBRARIES}" 63 | ) 64 | endif () 65 | endif () 66 | 67 | mark_as_advanced(OPUS_INCLUDE_DIR OPUS_LIBRARY) 68 | -------------------------------------------------------------------------------- /scripts/generate-VSproj.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | pushd ..\ 3 | MD visual-studio-build 4 | pushd visual-studio-build 5 | call cmake .. -G "Visual Studio 16 2019" 6 | popd 7 | popd 8 | PAUSE 9 | -------------------------------------------------------------------------------- /scripts/generate-cmake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo building Cmake 3 | cd .. 4 | mkdir cmake-build 5 | cd cmake-build || exit 6 | cmake .. -------------------------------------------------------------------------------- /scripts/generate-xcode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo building Xcode 3 | cd .. 4 | mkdir xcode-build 5 | cd xcode-build || exit 6 | cmake -G Xcode .. 7 | -------------------------------------------------------------------------------- /scripts/jenkins/jenkins-cmake.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir cmake-build 3 | cd cmake-build || exit 4 | cmake .. --------------------------------------------------------------------------------