├── .editorconfig
├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── assets
├── animations
│ └── jump.dae
├── dummy.txt
├── models
│ ├── bunny.obj
│ ├── mannequin.dae
│ └── teapot.obj
└── textures
│ └── checkerboard.tga
├── init.sh
├── premake5.lua
├── res
├── Info.plist
└── readme
│ ├── animation.gif
│ ├── cube.gif
│ ├── model.gif
│ ├── postfx.gif
│ └── triangle.png
└── src
├── Orbit
├── Core
│ ├── Application
│ │ ├── Application.cpp
│ │ ├── Application.h
│ │ ├── Bootstrap.cpp
│ │ ├── Bootstrap.h
│ │ └── EntryPoint.h
│ ├── Container
│ │ ├── BinarySearchTree.h
│ │ └── Pair.h
│ ├── Core.h
│ ├── Debug
│ │ └── Trace.h
│ ├── Event
│ │ ├── EventDispatcher.h
│ │ ├── EventSubscription.cpp
│ │ └── EventSubscription.h
│ ├── IO
│ │ ├── Asset.cpp
│ │ ├── Asset.h
│ │ ├── IO.h
│ │ ├── Log.cpp
│ │ ├── Log.h
│ │ ├── Parser
│ │ │ ├── IParser.cpp
│ │ │ ├── IParser.h
│ │ │ ├── ITextParser.cpp
│ │ │ ├── ITextParser.h
│ │ │ ├── TGA
│ │ │ │ ├── TGAParser.cpp
│ │ │ │ └── TGAParser.h
│ │ │ └── XML
│ │ │ │ ├── XMLAttribute.h
│ │ │ │ ├── XMLElement.cpp
│ │ │ │ ├── XMLElement.h
│ │ │ │ ├── XMLParser.cpp
│ │ │ │ └── XMLParser.h
│ │ ├── Pipe.cpp
│ │ └── Pipe.h
│ ├── Input
│ │ ├── Input.cpp
│ │ ├── Input.h
│ │ ├── Key.cpp
│ │ └── Key.h
│ ├── Platform
│ │ ├── Android
│ │ │ ├── AndroidApp.cpp
│ │ │ ├── AndroidApp.h
│ │ │ ├── AndroidNativeAppGlue.cpp
│ │ │ └── AndroidNativeAppGlue.h
│ │ ├── Windows
│ │ │ ├── ComPtr.h
│ │ │ ├── Win32Error.cpp
│ │ │ └── Win32Error.h
│ │ ├── iOS
│ │ │ ├── UIApplicationDelegate.h
│ │ │ ├── UIApplicationDelegate.mm
│ │ │ ├── UIWindow.h
│ │ │ └── UIWindow.mm
│ │ └── macOS
│ │ │ ├── WindowDelegate.h
│ │ │ └── WindowDelegate.mm
│ ├── Private
│ │ └── WindowDetails.h
│ ├── Shape
│ │ ├── CubeShape.cpp
│ │ ├── CubeShape.h
│ │ ├── EquilateralTriangleShape.cpp
│ │ ├── EquilateralTriangleShape.h
│ │ ├── IShape.h
│ │ ├── SphereShape.cpp
│ │ └── SphereShape.h
│ ├── Time
│ │ ├── Clock.cpp
│ │ └── Clock.h
│ ├── Utility
│ │ ├── Bitmask.h
│ │ ├── Color.h
│ │ ├── HashView.h
│ │ ├── PredefinedColors.h
│ │ ├── Ref.h
│ │ ├── Selector.h
│ │ ├── Singleton.h
│ │ ├── Span.h
│ │ ├── StringConverting.h
│ │ ├── StringLiteral.h
│ │ └── Utility.h
│ └── Widget
│ │ ├── Console.cpp
│ │ ├── Console.h
│ │ ├── Point.cpp
│ │ ├── Point.h
│ │ ├── Window.cpp
│ │ └── Window.h
├── Graphics
│ ├── API
│ │ └── OpenGL
│ │ │ ├── GLSL.cpp
│ │ │ ├── GLSL.h
│ │ │ ├── OpenGL.cpp
│ │ │ ├── OpenGL.h
│ │ │ ├── OpenGLEnums.h
│ │ │ ├── OpenGLFunctions.h
│ │ │ ├── OpenGLVersion.cpp
│ │ │ └── OpenGLVersion.h
│ ├── Animation
│ │ ├── Animation.cpp
│ │ ├── Animation.h
│ │ ├── Joint.h
│ │ └── KeyFrame.h
│ ├── Buffer
│ │ ├── FrameBuffer.cpp
│ │ ├── FrameBuffer.h
│ │ ├── IndexBuffer.cpp
│ │ ├── IndexBuffer.h
│ │ ├── VertexBuffer.cpp
│ │ └── VertexBuffer.h
│ ├── Context
│ │ ├── RenderContext.cpp
│ │ └── RenderContext.h
│ ├── Debug
│ │ ├── DebugManager.cpp
│ │ └── DebugManager.h
│ ├── Geometry
│ │ ├── Face.h
│ │ ├── FaceRange.cpp
│ │ ├── FaceRange.h
│ │ ├── Geometry.cpp
│ │ ├── Geometry.h
│ │ ├── Mesh.cpp
│ │ ├── Mesh.h
│ │ ├── MeshFactory.cpp
│ │ ├── MeshFactory.h
│ │ ├── Model.cpp
│ │ ├── Model.h
│ │ ├── Vertex.h
│ │ ├── VertexLayout.cpp
│ │ ├── VertexLayout.h
│ │ ├── VertexRange.cpp
│ │ └── VertexRange.h
│ ├── Graphics.h
│ ├── Platform
│ │ └── iOS
│ │ │ ├── GLKViewDelegate.h
│ │ │ └── GLKViewDelegate.mm
│ ├── Private
│ │ ├── ConstantBufferDetails.h
│ │ ├── FrameBufferDetails.h
│ │ ├── IndexBufferDetails.h
│ │ ├── RenderContextDetails.h
│ │ ├── ShaderDetails.h
│ │ ├── Texture2DDetails.h
│ │ └── VertexBufferDetails.h
│ ├── Renderer
│ │ ├── BlendEquation.h
│ │ ├── DefaultRenderer.cpp
│ │ ├── DefaultRenderer.h
│ │ ├── IRenderer.cpp
│ │ ├── IRenderer.h
│ │ └── RenderCommand.h
│ ├── Shader
│ │ ├── Shader.cpp
│ │ ├── Shader.h
│ │ └── ShaderConstant.h
│ └── Texture
│ │ ├── Texture.cpp
│ │ ├── Texture.h
│ │ ├── Texture2D.cpp
│ │ └── Texture2D.h
├── Math
│ ├── Geometry
│ │ ├── Line.cpp
│ │ ├── Line.h
│ │ ├── LineSegment.cpp
│ │ ├── LineSegment.h
│ │ ├── Plane.cpp
│ │ ├── Plane.h
│ │ ├── Triangle3D.cpp
│ │ └── Triangle3D.h
│ ├── Literals.h
│ ├── Math.h
│ ├── Matrix
│ │ ├── Matrix4.cpp
│ │ └── Matrix4.h
│ └── Vector
│ │ ├── Vector2.cpp
│ │ ├── Vector2.h
│ │ ├── Vector3.cpp
│ │ ├── Vector3.h
│ │ ├── Vector4.cpp
│ │ ├── Vector4.h
│ │ └── VectorBase.h
├── Orbit.h
└── ShaderGen
│ ├── Generator
│ ├── IShader.cpp
│ ├── IShader.h
│ ├── MainFunction.h
│ ├── ShaderManager.cpp
│ └── ShaderManager.h
│ ├── ShaderGen.h
│ └── Variables
│ ├── Attribute.cpp
│ ├── Attribute.h
│ ├── DataType.h
│ ├── Float.cpp
│ ├── Float.h
│ ├── Mat4.cpp
│ ├── Mat4.h
│ ├── Sampler.cpp
│ ├── Sampler.h
│ ├── Swizzle.cpp
│ ├── Swizzle.h
│ ├── Uniform.cpp
│ ├── Uniform.h
│ ├── Variable.cpp
│ ├── Variable.h
│ ├── Varying.cpp
│ ├── Varying.h
│ ├── Vec2.cpp
│ ├── Vec2.h
│ ├── Vec3.cpp
│ ├── Vec3.h
│ ├── Vec4.cpp
│ └── Vec4.h
└── Samples
├── 00-Framework
└── Framework
│ ├── Camera.cpp
│ ├── Camera.h
│ ├── RenderQuad.cpp
│ └── RenderQuad.h
├── 01-Triangle
├── Android
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── gaztin
│ │ │ └── orbit
│ │ │ └── samples
│ │ │ └── triangle
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ └── strings.xml
├── TriangleShader.cpp
├── TriangleShader.h
└── main.cpp
├── 02-Cube
├── Android
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── gaztin
│ │ │ └── orbit
│ │ │ └── samples
│ │ │ └── cube
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ └── strings.xml
├── CubeShader.cpp
├── CubeShader.h
└── main.cpp
├── 03-Model
├── Android
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── gaztin
│ │ │ └── orbit
│ │ │ └── samples
│ │ │ └── model
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ └── strings.xml
├── ModelShader.cpp
├── ModelShader.h
└── main.cpp
├── 04-Animation
├── Android
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── gaztin
│ │ │ └── orbit
│ │ │ └── samples
│ │ │ └── animation
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ └── strings.xml
├── AnimationShader.cpp
├── AnimationShader.h
└── main.cpp
└── 05-PostFX
├── Android
├── AndroidManifest.xml
├── java
│ └── com
│ │ └── gaztin
│ │ └── orbit
│ │ └── samples
│ │ └── postfx
│ │ └── MainActivity.java
└── res
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ └── values
│ └── strings.xml
├── PostFXShader.cpp
├── PostFXShader.h
├── SceneShader.cpp
├── SceneShader.h
└── main.cpp
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = tab
5 | indent_size = 4
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .build-*/
2 | .codelite/
3 | .externalNativeBuild/
4 | .gradle/
5 | .idea/
6 | .vs/
7 | build/*/
8 | !build/android/
9 | build/android/mobile/build/
10 | build/android/wear/build/
11 |
12 | *.gradle
13 | *.iml
14 | *.sln
15 | *.xcworkspace
16 | *.workspace
17 |
18 | gradle/wrapper/gradle-wrapper.jar
19 | gradle/wrapper/gradle-wrapper.properties
20 | gradle.properties
21 | gradlew
22 | gradlew.bat
23 | local.properties
24 | Makefile
25 | premake5.exe
26 | premake5
27 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "third_party/premake-android-studio"]
2 | path = third_party/premake-android-studio
3 | url = https://github.com/Gaztin/premake-android-studio.git
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018 Sebastian Kylander https://gaztin.com/
2 |
3 | This software is provided 'as-is', without any express or implied warranty. In no event will
4 | the authors be held liable for any damages arising from the use of this software.
5 |
6 | Permission is granted to anyone to use this software for any purpose, including commercial
7 | applications, and to alter it and redistribute it freely, subject to the following restrictions:
8 |
9 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
10 | original software. If you use this software in a product, an acknowledgment in the product
11 | documentation would be appreciated but is not required.
12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
13 | being the original software.
14 | 3. This notice may not be removed or altered from any source distribution.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 💫Orbit
2 | This is a Work-In-Progress game engine using C++17
3 |
4 | # 🔧Building
5 | This project uses [Premake](https://premake.github.io/). It's a project generator configured with Lua scripts.
6 |
7 | The first thing you'll want to do is to run the `init.sh` script. This is a bash script that fetches/builds the premake executable that we'll use to generate our project files. If you are on Windows and don't have any way of running bash scripts, [simply download the latest executable from their website](https://premake.github.io/download.html) and put it in the root directory of the project.
8 |
9 | To generate files for your favorite IDE or build system, simply run the premake executable like so:
10 | `premake5.exe vs2019` (Windows)
11 | `./premake5 codelite` (Unix)
12 |
13 | [Click here for a list of generators.](https://github.com/premake/premake-core/wiki/Using-Premake)
14 |
15 | # 💉Samples
16 |
17 | **Triangle**
18 | 
19 | Obligatory triangle example (textured)
20 |
21 | **Cube**
22 | 
23 | This is the first 3D sample.
24 | Introduces a first-person free-flight camera and the usage of constant buffers and matrices.
25 |
26 | **Model**
27 | 
28 | Loads a teapot model from an OBJ file and renders it with a simple directional light.
29 |
30 | **Animation**
31 | 
32 | Loads a rigged mannequin model and a jump animation from separate COLLADA files and animates the model on a loop.
33 |
34 | **Post Effects**
35 | 
36 | Uses two render passes. The first one uses a regular scene shader to render a bunny to a separate framebuffer. The second pass uses another shader to sample on different points on the framebuffer and renders it to a fullscreen quad. The result is a distortion effect.
--------------------------------------------------------------------------------
/assets/dummy.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gaztin/Orbit/4589f3f0165d287482ab4b367f02633ea4e7c9a5/assets/dummy.txt
--------------------------------------------------------------------------------
/assets/textures/checkerboard.tga:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gaztin/Orbit/4589f3f0165d287482ab4b367f02633ea4e7c9a5/assets/textures/checkerboard.tga
--------------------------------------------------------------------------------
/res/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIconFile
12 | Icon.png
13 | CFBundleIdentifier
14 | com.gaztin.${PRODUCT_NAME:rfc1034identifier}
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | ${PRODUCT_NAME}
19 | CFBundlePackageType
20 | APPL
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 |
28 |
--------------------------------------------------------------------------------
/res/readme/animation.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gaztin/Orbit/4589f3f0165d287482ab4b367f02633ea4e7c9a5/res/readme/animation.gif
--------------------------------------------------------------------------------
/res/readme/cube.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gaztin/Orbit/4589f3f0165d287482ab4b367f02633ea4e7c9a5/res/readme/cube.gif
--------------------------------------------------------------------------------
/res/readme/model.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gaztin/Orbit/4589f3f0165d287482ab4b367f02633ea4e7c9a5/res/readme/model.gif
--------------------------------------------------------------------------------
/res/readme/postfx.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gaztin/Orbit/4589f3f0165d287482ab4b367f02633ea4e7c9a5/res/readme/postfx.gif
--------------------------------------------------------------------------------
/res/readme/triangle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gaztin/Orbit/4589f3f0165d287482ab4b367f02633ea4e7c9a5/res/readme/triangle.png
--------------------------------------------------------------------------------
/src/Orbit/Core/Application/Application.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #include "Application.h"
19 |
20 | #include "Orbit/Core/Platform/iOS/UIApplicationDelegate.h"
21 | #include "Orbit/Core/Time/Clock.h"
22 | #include "Orbit/Core/Widget/Console.h"
23 | #include "Orbit/Core/Widget/Window.h"
24 |
25 | #include
26 |
27 | ORB_NAMESPACE_BEGIN
28 |
29 | void ApplicationBase::RunInstance( void )
30 | {
31 | Console console;
32 |
33 | #if defined( ORB_OS_IOS )
34 |
35 | @autoreleasepool
36 | {
37 | UIApplicationMain( 0, nil, nil, NSStringFromClass( [ ORB_NAMESPACED_OBJC( UIApplicationDelegate ) class ] ) );
38 | }
39 |
40 | #else
41 |
42 | if( !Bootstrap::trampoline )
43 | return;
44 |
45 | // Start the engine clock
46 | Clock::Start();
47 |
48 | // Initialize application instance and create main window
49 | Window main_window = Window( 800, 600 );
50 | auto instance = std::static_pointer_cast< ApplicationBase >( Bootstrap::trampoline() );
51 |
52 | // Show main window
53 | main_window.Show();
54 |
55 | while( main_window.IsOpen() )
56 | {
57 | Clock::Update();
58 |
59 | main_window.PollEvents();
60 | instance->OnFrame();
61 | }
62 |
63 | #endif
64 |
65 | }
66 |
67 | ORB_NAMESPACE_END
68 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Application/Application.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Application/Bootstrap.h"
20 |
21 | #include
22 | #include
23 |
24 | ORB_NAMESPACE_BEGIN
25 |
26 | class ORB_API_CORE ApplicationBase
27 | {
28 | public:
29 |
30 | ApplicationBase( void ) = default;
31 | virtual ~ApplicationBase( void ) = default;
32 |
33 | public:
34 |
35 | virtual void OnFrame( void ) = 0;
36 |
37 | public:
38 |
39 | static void RunInstance( void );
40 |
41 | };
42 |
43 | template< typename Derived >
44 | class Application : private ApplicationBase, private Bootstrapper< Derived >
45 | {
46 | public:
47 |
48 | virtual ~Application( void ) = default;
49 |
50 | };
51 |
52 | ORB_NAMESPACE_END
53 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Application/Bootstrap.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #include "Bootstrap.h"
19 |
20 | ORB_NAMESPACE_BEGIN
21 |
22 | Bootstrap::Trampoline Bootstrap::trampoline = nullptr;
23 |
24 | ORB_NAMESPACE_END
25 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Application/Bootstrap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | #include
22 |
23 | ORB_NAMESPACE_BEGIN
24 |
25 | namespace Bootstrap
26 | {
27 | using Trampoline = std::shared_ptr< void >( * )( void );
28 |
29 | extern ORB_API_CORE Trampoline trampoline;
30 |
31 | template< typename T >
32 | #if defined( ORB_CC_CLANG ) || defined( ORB_CC_GCC )
33 | __attribute__(( constructor ))
34 | #endif // ORB_CC_CLANG || defined( ORB_CC_GCC )
35 | auto Load( void )
36 | {
37 | trampoline = []( void ){ return std::static_pointer_cast< void >( std::make_shared< T >() ); };
38 | return 0;
39 | }
40 | }
41 |
42 | template< typename T >
43 | class Bootstrapper
44 | {
45 | private:
46 |
47 | #if defined( ORB_CC_MSVC )
48 | static inline auto bootstrap_eval = Bootstrap::Load< T >();
49 | #elif defined( ORB_CC_CLANG ) || defined( ORB_CC_GCC ) // ORB_CC_MSVC
50 | using BootstrapDecl = decltype( Bootstrap::Load< T >() );
51 | #endif // ORB_CC_CLANG || ORB_CC_GCC
52 |
53 | };
54 |
55 | ORB_NAMESPACE_END
56 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Application/EntryPoint.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Application/Application.h"
20 |
21 | #if defined( ORB_OS_WINDOWS )
22 | # include
23 |
24 | INT WINAPI WinMain( HINSTANCE, HINSTANCE, PSTR, INT )
25 | {
26 | ORB_NAMESPACE ApplicationBase::RunInstance();
27 | return 0;
28 | }
29 |
30 | #elif defined( ORB_OS_LINUX ) || defined( ORB_OS_MACOS ) || defined( ORB_OS_IOS )
31 |
32 | int main( int, char*[] )
33 | {
34 | ORB_NAMESPACE ApplicationBase::RunInstance();
35 | return 0;
36 | }
37 |
38 | #elif defined( ORB_OS_ANDROID )
39 | # include "Orbit/Core/Platform/Android/AndroidApp.h"
40 | # include "Orbit/Core/Platform/Android/AndroidNativeAppGlue.h"
41 |
42 | void ORB_NAMESPACE AndroidMain( AndroidApp* app )
43 | {
44 | ORB_NAMESPACE AndroidOnly::app = app;
45 | ORB_NAMESPACE ApplicationBase::RunInstance();
46 | }
47 |
48 | extern "C" JNIEXPORT void ANativeActivity_onCreate( ANativeActivity* activity, void* saved_state, size_t saved_state_size )
49 | {
50 | activity->instance = ORB_NAMESPACE AndroidAppCreate( activity, saved_state, saved_state_size );
51 | }
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Core.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Orbit.h"
20 |
21 | #if defined( ORB_BUILD_CORE )
22 | # define ORB_API_CORE ORB_DLL_EXPORT
23 | #else // ORB_BUILD_CORE
24 | # define ORB_API_CORE ORB_DLL_IMPORT
25 | #endif // !ORB_BUILD_CORE
26 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Debug/Trace.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/IO/Log.h"
20 |
21 | ORB_NAMESPACE_BEGIN
22 |
23 | #if defined( NDEBUG )
24 | #define ORB_TRACE( STR, ... )
25 | #else // NDEBUG
26 | #define ORB_TRACE( STR, ... ) ORB_NAMESPACE LogDebug( STR, __VA_ARGS__ )
27 | #endif // !NDEBUG
28 |
29 | ORB_NAMESPACE_END
30 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Event/EventSubscription.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | #include
22 | #include
23 |
24 | ORB_NAMESPACE_BEGIN
25 |
26 | class ORB_API_CORE EventSubscription
27 | {
28 | public:
29 |
30 | struct Deleter
31 | {
32 | const void* user_data;
33 | void( *functor )( uint64_t id, const void* user_data );
34 | };
35 |
36 | public:
37 |
38 | EventSubscription( void );
39 | EventSubscription( uint64_t id, Deleter deleter );
40 | EventSubscription( const EventSubscription& other );
41 | EventSubscription( EventSubscription&& other );
42 | ~EventSubscription( void );
43 |
44 | public:
45 |
46 | EventSubscription& operator=( const EventSubscription& other );
47 | EventSubscription& operator=( EventSubscription&& other );
48 |
49 | private:
50 |
51 | struct ControlBlock
52 | {
53 | std::atomic_uint64_t ref_count;
54 | };
55 |
56 | private:
57 |
58 | uint64_t id_;
59 | Deleter deleter_;
60 | ControlBlock* control_block_;
61 |
62 | };
63 |
64 | ORB_NAMESPACE_END
65 |
--------------------------------------------------------------------------------
/src/Orbit/Core/IO/Asset.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | #include
22 | #include
23 |
24 | ORB_NAMESPACE_BEGIN
25 |
26 | class ORB_API_CORE Asset
27 | {
28 | public:
29 |
30 | explicit Asset( std::string_view path );
31 |
32 | public:
33 |
34 | const uint8_t* GetData( void ) const { return data_.data(); }
35 | size_t GetSize( void ) const { return data_.size(); }
36 |
37 | private:
38 |
39 | std::vector< uint8_t > data_;
40 |
41 | };
42 |
43 | ORB_NAMESPACE_END
44 |
--------------------------------------------------------------------------------
/src/Orbit/Core/IO/IO.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | #if defined( ORB_OS_WINDOWS )
22 | # include
23 | #endif // ORB_OS_WINDOWS
24 |
25 | ORB_NAMESPACE_BEGIN
26 |
27 | #if defined( ORB_OS_WINDOWS )
28 |
29 | using NativeFileHandle = HANDLE;
30 |
31 | inline const NativeFileHandle invalid_file_handle = INVALID_HANDLE_VALUE;
32 |
33 | #else // ORB_OS_WINDOWS
34 |
35 | using NativeFileHandle = int;
36 |
37 | constexpr NativeFileHandle invalid_file_handle = -1;
38 |
39 | #endif // !ORB_OS_WINDOWS
40 |
41 | ORB_NAMESPACE_END
42 |
--------------------------------------------------------------------------------
/src/Orbit/Core/IO/Parser/IParser.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #include "IParser.h"
19 |
20 | #include
21 |
22 | ORB_NAMESPACE_BEGIN
23 |
24 | IParser::IParser( ByteSpan data )
25 | : data_ { data.Copy() }
26 | , size_ { data.Size() }
27 | , offset_{ 0 }
28 | , good_ { false }
29 | {
30 | }
31 |
32 | void IParser::Skip( size_t size )
33 | {
34 | if( ( offset_ + size ) < size_ ) offset_ += size;
35 | else offset_ = size_;
36 | }
37 |
38 | void IParser::ReadBytes( void* dst, size_t count )
39 | {
40 | if( ( offset_ + count ) < size_ )
41 | {
42 | std::memcpy( dst, &data_[ offset_ ], count );
43 | offset_ += count;
44 | }
45 | else
46 | {
47 | std::memcpy( dst, &data_[ offset_ ], ( offset_ - size_ ) );
48 | offset_ = size_;
49 | }
50 | }
51 |
52 | bool IParser::IsEOF( void ) const
53 | {
54 | return ( offset_ == size_ );
55 | }
56 |
57 | ORB_NAMESPACE_END
58 |
--------------------------------------------------------------------------------
/src/Orbit/Core/IO/Parser/IParser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Utility/Span.h"
20 |
21 | #include
22 | #include
23 |
24 | ORB_NAMESPACE_BEGIN
25 |
26 | class ORB_API_CORE IParser
27 | {
28 | public:
29 |
30 | explicit IParser( ByteSpan data );
31 | virtual ~IParser( void ) = default;
32 |
33 | public:
34 |
35 | bool IsGood( void ) const { return good_; }
36 |
37 | protected:
38 |
39 | void Skip ( size_t size );
40 | void ReadBytes( void* dst, size_t count );
41 |
42 | protected:
43 |
44 | bool IsEOF( void ) const;
45 |
46 | protected:
47 |
48 | std::unique_ptr< uint8_t[] > data_;
49 |
50 | size_t size_;
51 | size_t offset_;
52 |
53 | bool good_;
54 |
55 | };
56 |
57 | ORB_NAMESPACE_END
58 |
--------------------------------------------------------------------------------
/src/Orbit/Core/IO/Parser/ITextParser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/IO/Parser/IParser.h"
20 |
21 | ORB_NAMESPACE_BEGIN
22 |
23 | class ORB_API_CORE ITextParser : public IParser
24 | {
25 | public:
26 |
27 | explicit ITextParser( ByteSpan data );
28 |
29 | protected:
30 |
31 | void SkipWhitespace ( void );
32 | std::string ReadAlphaNumeric( void );
33 | std::string ReadPrintable ( void );
34 | std::string ReadLiteral ( void );
35 |
36 | protected:
37 |
38 | std::string Peek( size_t length ) const;
39 |
40 | protected:
41 |
42 | bool ExpectString( std::string_view str );
43 |
44 | };
45 |
46 | ORB_NAMESPACE_END
47 |
--------------------------------------------------------------------------------
/src/Orbit/Core/IO/Parser/TGA/TGAParser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/IO/Parser/IParser.h"
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | ORB_NAMESPACE_BEGIN
26 |
27 | class ORB_API_CORE TGAParser : public IParser
28 | {
29 | public:
30 |
31 | explicit TGAParser( ByteSpan data );
32 |
33 | public:
34 |
35 | const uint32_t* ImageData( void ) const { return image_data_.get(); }
36 | uint16_t Width ( void ) const { return width_; }
37 | uint16_t Height ( void ) const { return height_; }
38 |
39 | private:
40 |
41 | uint32_t ReadTrueColor ( void );
42 | size_t ReadNextRLEPacket( uint32_t* dst );
43 |
44 | private:
45 |
46 | std::unique_ptr< uint32_t[] > image_data_;
47 |
48 | size_t bytes_per_pixel_;
49 |
50 | uint16_t width_;
51 | uint16_t height_;
52 |
53 | };
54 |
55 | ORB_NAMESPACE_END
56 |
--------------------------------------------------------------------------------
/src/Orbit/Core/IO/Parser/XML/XMLAttribute.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | #include
22 |
23 | ORB_NAMESPACE_BEGIN
24 |
25 | struct XMLAttribute
26 | {
27 | std::string name;
28 | std::string value;
29 | };
30 |
31 | ORB_NAMESPACE_END
32 |
--------------------------------------------------------------------------------
/src/Orbit/Core/IO/Parser/XML/XMLElement.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/IO/Parser/XML/XMLAttribute.h"
20 |
21 | #include
22 | #include
23 |
24 | ORB_NAMESPACE_BEGIN
25 |
26 | class ORB_API_CORE XMLElement
27 | {
28 | public:
29 |
30 | std::string_view Attribute( std::string_view key ) const;
31 |
32 | public:
33 |
34 | const XMLElement& ChildWithAttribute( std::string_view element, std::string_view attribute, std::string_view value ) const;
35 | size_t CountChildren ( std::string_view element ) const;
36 | bool IsValid ( void ) const;
37 |
38 | public:
39 |
40 | auto begin( void ) const { return children.begin(); }
41 | auto end ( void ) const { return children.end(); }
42 |
43 | public:
44 |
45 | const XMLElement& operator[]( std::string_view key ) const;
46 |
47 | public:
48 |
49 | std::string name;
50 | std::string content;
51 |
52 | std::vector< XMLAttribute > attributes;
53 | std::vector< XMLElement > children;
54 |
55 | };
56 |
57 | ORB_NAMESPACE_END
58 |
--------------------------------------------------------------------------------
/src/Orbit/Core/IO/Parser/XML/XMLParser.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/IO/Parser/XML/XMLElement.h"
20 | #include "Orbit/Core/IO/Parser/ITextParser.h"
21 |
22 | #include
23 |
24 | ORB_NAMESPACE_BEGIN
25 |
26 | class ORB_API_CORE XMLParser : public ITextParser
27 | {
28 | public:
29 |
30 | explicit XMLParser( ByteSpan data );
31 | ~XMLParser( void ) = default;
32 |
33 | public:
34 |
35 | const XMLElement& GetRootElement( void ) const { return root_element_; }
36 |
37 | private:
38 |
39 | std::string ReadName ( void );
40 | std::string ReadContent ( void );
41 | bool ParseElement( XMLElement* parent );
42 |
43 | private:
44 |
45 | XMLElement root_element_;
46 |
47 | };
48 |
49 | ORB_NAMESPACE_END
50 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Platform/Android/AndroidApp.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #include "AndroidApp.h"
19 |
20 | #if defined( ORB_OS_ANDROID )
21 | # include "Orbit/Core/Platform/Android/AndroidNativeAppGlue.h"
22 |
23 | ORB_NAMESPACE_BEGIN
24 |
25 | namespace AndroidOnly
26 | {
27 | AndroidApp* app = nullptr;
28 | }
29 |
30 | ORB_NAMESPACE_END
31 |
32 | #endif // ORB_OS_ANDROID
33 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Platform/Android/AndroidApp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Platform/Android/AndroidNativeAppGlue.h"
20 |
21 | #if defined( ORB_OS_ANDROID )
22 |
23 | ORB_NAMESPACE_BEGIN
24 |
25 | namespace AndroidOnly
26 | {
27 | extern ORB_API_CORE AndroidApp* app;
28 | }
29 |
30 | ORB_NAMESPACE_END
31 |
32 | #endif // ORB_OS_ANDROID
33 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Platform/Windows/Win32Error.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #include "Win32Error.h"
19 |
20 | #if defined( ORB_OS_WINDOWS )
21 | # include "Orbit/Core/IO/Log.h"
22 |
23 | # include
24 |
25 | ORB_NAMESPACE_BEGIN
26 |
27 | bool CheckHResult( HRESULT hresult, std::string_view statement, std::string_view file, uint32_t line )
28 | {
29 | if( FAILED( hresult ) )
30 | {
31 | LPSTR buffer;
32 |
33 | FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, hresult, 0, reinterpret_cast< LPSTR >( &buffer ), 0, nullptr );
34 | LogError( "[%s(%d)] { %s } failed with error: %s", file.data(), line, statement.data(), buffer );
35 |
36 | return false;
37 | }
38 |
39 | return true;
40 | }
41 |
42 | bool CheckSystemError( DWORD error, std::string_view statement, std::string_view file, uint32_t line )
43 | {
44 | return CheckHResult( HRESULT_FROM_WIN32( error ), statement, file, line );
45 | }
46 |
47 | ORB_NAMESPACE_END
48 |
49 | #endif // ORB_OS_WINDOWS
50 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Platform/Windows/Win32Error.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | #if defined( ORB_OS_WINDOWS )
22 | # include
23 |
24 | # include
25 |
26 | ORB_NAMESPACE_BEGIN
27 |
28 | extern ORB_API_CORE bool CheckHResult ( HRESULT hresult, std::string_view statement, std::string_view file, uint32_t line );
29 | extern ORB_API_CORE bool CheckSystemError( DWORD error, std::string_view statement, std::string_view file, uint32_t line );
30 |
31 | ORB_NAMESPACE_END
32 |
33 | #define ORB_CHECK_HRESULT( X ) ( ORB_NAMESPACE CheckHResult( ( X ), #X, __FILE__, __LINE__ ) )
34 | #define ORB_CHECK_SYSTEM_ERROR( X ) ( SetLastError( ERROR_SUCCESS ), ( X ), ORB_NAMESPACE CheckSystemError( GetLastError(), #X, __FILE__, __LINE__ ) )
35 |
36 | #endif // ORB_OS_WINDOWS
37 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Platform/iOS/UIApplicationDelegate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | #if defined( ORB_OS_IOS )
22 | # include "Orbit/Core/Application/Application.h"
23 | # include "Orbit/Core/Widget/Window.h"
24 |
25 | # include
26 |
27 | @interface ORB_NAMESPACED_OBJC( UIApplicationDelegate ) : UIResponder< UIApplicationDelegate >
28 | {
29 | std::shared_ptr< ORB_NAMESPACE ApplicationBase > application_instance;
30 | std::shared_ptr< ORB_NAMESPACE Window > main_window;
31 | }
32 |
33 | -( void )OnFrame:( CADisplayLink* )display_link;
34 |
35 | @end
36 |
37 | #endif // ORB_OS_IOS
38 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Platform/iOS/UIWindow.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | #if defined( ORB_OS_IOS )
22 | # include
23 |
24 | @interface ORB_NAMESPACED_OBJC( UIWindow ) : UIWindow
25 | {
26 | }
27 | @end
28 |
29 | #endif // ORB_OS_IOS
30 |
31 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Platform/macOS/WindowDelegate.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | #if defined( ORB_OS_MACOS )
22 | # include
23 |
24 | @interface ORB_NAMESPACED_OBJC( WindowDelegate ) : NSObject< NSWindowDelegate >
25 | {
26 | }
27 | @end
28 |
29 | #endif // ORB_OS_MACOS
30 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Shape/CubeShape.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #include "CubeShape.h"
19 |
20 | ORB_NAMESPACE_BEGIN
21 |
22 | CubeShape::CubeShape( float half_extent )
23 | : half_extent( half_extent )
24 | {
25 | }
26 |
27 | ORB_NAMESPACE_END
28 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Shape/CubeShape.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Shape/IShape.h"
20 |
21 | ORB_NAMESPACE_BEGIN
22 |
23 | class ORB_API_CORE CubeShape : public IShape
24 | {
25 | public:
26 |
27 | explicit CubeShape( float half_extent );
28 |
29 | public:
30 |
31 | ShapeType GetType( void ) const override { return ShapeType::Cube; }
32 |
33 | public:
34 |
35 | float half_extent;
36 |
37 | };
38 |
39 | ORB_NAMESPACE_END
40 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Shape/EquilateralTriangleShape.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #include "EquilateralTriangleShape.h"
19 |
20 | ORB_NAMESPACE_BEGIN
21 |
22 | EquilateralTriangleShape::EquilateralTriangleShape( float scale )
23 | : scale( scale )
24 | {
25 | }
26 |
27 | ORB_NAMESPACE_END
28 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Shape/EquilateralTriangleShape.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Shape/IShape.h"
20 |
21 | ORB_NAMESPACE_BEGIN
22 |
23 | class ORB_API_CORE EquilateralTriangleShape : public IShape
24 | {
25 | public:
26 |
27 | explicit EquilateralTriangleShape( float scale );
28 |
29 | public:
30 |
31 | ShapeType GetType( void ) const override { return ShapeType::EquilateralTriangle; }
32 |
33 | public:
34 |
35 | float scale;
36 |
37 | };
38 |
39 | ORB_NAMESPACE_END
40 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Shape/IShape.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | ORB_NAMESPACE_BEGIN
22 |
23 | enum class ShapeType
24 | {
25 | EquilateralTriangle,
26 | Cube,
27 | Sphere,
28 | };
29 |
30 | class ORB_API_CORE IShape
31 | {
32 | public:
33 |
34 | IShape( void ) = default;
35 | virtual ~IShape( void ) = default;
36 |
37 | public:
38 |
39 | virtual ShapeType GetType( void ) const = 0;
40 |
41 | };
42 |
43 | ORB_NAMESPACE_END
44 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Shape/SphereShape.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gaztin/Orbit/4589f3f0165d287482ab4b367f02633ea4e7c9a5/src/Orbit/Core/Shape/SphereShape.cpp
--------------------------------------------------------------------------------
/src/Orbit/Core/Shape/SphereShape.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Shape/IShape.h"
20 |
21 | ORB_NAMESPACE_BEGIN
22 |
23 | class ORB_API_CORE SphereShape : public IShape
24 | {
25 | public:
26 |
27 | explicit SphereShape( float radius );
28 |
29 | public:
30 |
31 | ShapeType GetType( void ) const override { return ShapeType::Sphere; }
32 |
33 | public:
34 |
35 | float radius;
36 |
37 | };
38 |
39 | ORB_NAMESPACE_END
40 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Time/Clock.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #include "Clock.h"
19 |
20 | #include
21 |
22 | ORB_NAMESPACE_BEGIN
23 |
24 | static std::chrono::high_resolution_clock::time_point start;
25 | static std::chrono::high_resolution_clock::time_point then;
26 | static std::chrono::high_resolution_clock::time_point now;
27 |
28 | float Clock::GetLife( void )
29 | {
30 | auto life_time = std::chrono::duration_cast< std::chrono::duration< float > >( now - start );
31 | return life_time.count();
32 | }
33 |
34 | float Clock::GetDelta( void )
35 | {
36 | auto delta_time = std::chrono::duration_cast< std::chrono::duration< float > >( now - then );
37 | return delta_time.count();
38 | }
39 |
40 | void Clock::Start( void )
41 | {
42 | start = std::chrono::high_resolution_clock::now();
43 | then = start;
44 | now = start;
45 | }
46 |
47 | void Clock::Update( void )
48 | {
49 | then = now;
50 | now = std::chrono::high_resolution_clock::now();
51 | }
52 |
53 | ORB_NAMESPACE_END
54 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Time/Clock.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | ORB_NAMESPACE_BEGIN
22 |
23 | namespace Clock
24 | {
25 | /** Returns the time (in seconds) since the engine was initialized */
26 | ORB_API_CORE float GetLife( void );
27 |
28 | /** Returns the time (in seconds) since the last frame */
29 | ORB_API_CORE float GetDelta( void );
30 |
31 | /** Starts the internal timer. Initializes Life and Delta to current time. */
32 | ORB_API_CORE void Start( void );
33 |
34 | /** Update the internal timer. Increments Life and refreshes Delta. */
35 | ORB_API_CORE void Update( void );
36 | };
37 |
38 | ORB_NAMESPACE_END
39 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Utility/Color.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | #include
22 |
23 | ORB_NAMESPACE_BEGIN
24 |
25 | class Color
26 | {
27 | public:
28 |
29 | constexpr Color( void )
30 | : r( 0.0f )
31 | , g( 0.0f )
32 | , b( 0.0f )
33 | , a( 1.0f )
34 | {
35 | }
36 |
37 | constexpr Color( float r, float g, float b, float a = 1.0f )
38 | : r( r )
39 | , g( g )
40 | , b( b )
41 | , a( a )
42 | {
43 | }
44 |
45 | public:
46 |
47 | constexpr float& operator[]( size_t i ) { return ( &r )[ i ]; }
48 | constexpr const float& operator[]( size_t i ) const { return ( &r )[ i ]; }
49 |
50 | public:
51 |
52 | static Color Random( void )
53 | {
54 | Color color;
55 | color.r = rand() / static_cast< float >( RAND_MAX );
56 | color.g = rand() / static_cast< float >( RAND_MAX );
57 | color.b = rand() / static_cast< float >( RAND_MAX );
58 |
59 | return color;
60 | }
61 |
62 | public:
63 |
64 | float r;
65 | float g;
66 | float b;
67 | float a;
68 |
69 | };
70 |
71 | ORB_NAMESPACE_END
72 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Utility/HashView.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Utility/Utility.h"
20 |
21 | #include
22 |
23 | ORB_NAMESPACE_BEGIN
24 |
25 | template< typename ValueType = size_t >
26 | class HashView
27 | {
28 | public:
29 |
30 | constexpr HashView( void )
31 | : value_{ }
32 | {
33 | }
34 |
35 | constexpr HashView( std::string_view str )
36 | : value_{ Hash( str ) }
37 | {
38 | }
39 |
40 | constexpr ValueType GetValue( void ) const { return value_; }
41 |
42 | private:
43 |
44 | /* FNV-1a hash function as per http://isthe.com/chongo/tech/comp/fnv/ */
45 | constexpr ValueType Hash( std::string_view str ) const
46 | {
47 | using HashTraits = HashTraitsFNV< sizeof( ValueType ) >;
48 |
49 | ValueType val = HashTraits::offset_basis;
50 |
51 | for( size_t i = 0; i < str.length(); ++i )
52 | {
53 | val ^= static_cast< ValueType >( str[ i ] );
54 | val *= HashTraits::prime;
55 | }
56 |
57 | return val;
58 | }
59 |
60 | private:
61 |
62 | ValueType value_;
63 |
64 | };
65 |
66 | ORB_NAMESPACE_END
67 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Utility/PredefinedColors.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Utility/Color.h"
20 |
21 | ORB_NAMESPACE_BEGIN
22 |
23 | constexpr Color Black = Color( 0.0f, 0.0f, 0.0f );
24 | constexpr Color White = Color( 1.0f, 1.0f, 1.0f );
25 | constexpr Color Red = Color( 1.0f, 0.0f, 0.0f );
26 | constexpr Color Green = Color( 0.0f, 1.0f, 0.0f );
27 | constexpr Color Blue = Color( 0.0f, 0.0f, 1.0f );
28 | constexpr Color Yellow = Color( 1.0f, 1.0f, 0.0f );
29 | constexpr Color Magenta = Color( 1.0f, 0.0f, 1.0f );
30 | constexpr Color Turquoise = Color( 0.0f, 1.0f, 1.0f );
31 |
32 | ORB_NAMESPACE_END
33 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Utility/Selector.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Container/BinarySearchTree.h"
20 | #include "Orbit/Core/Container/Pair.h"
21 |
22 | #include
23 |
24 | ORB_NAMESPACE_BEGIN
25 |
26 | template< typename KeyType, typename ValueType >
27 | class Selector
28 | {
29 | public:
30 |
31 | using PairType = Pair< KeyType, ValueType >;
32 |
33 | public:
34 |
35 | constexpr Selector( std::initializer_list< PairType > pairs )
36 | {
37 | for( const PairType& pair : pairs )
38 | tree_.Insert( pair );
39 | }
40 |
41 | public:
42 |
43 | constexpr ValueType operator[]( const KeyType& key ) const
44 | {
45 | if( const PairType* pair = tree_.Search( PairType( key, { } ) ); pair != nullptr )
46 | return pair->Value();
47 |
48 | return { };
49 | }
50 |
51 | private:
52 |
53 | BinarySearchTree< PairType > tree_;
54 |
55 | };
56 |
57 | ORB_NAMESPACE_END
58 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Utility/Singleton.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | #include
22 |
23 | ORB_NAMESPACE_BEGIN
24 |
25 | template< typename Derived >
26 | class ManualSingleton
27 | {
28 | public:
29 |
30 | static Derived& GetInstance( void )
31 | {
32 | assert( instance_ != nullptr );
33 | return *instance_;
34 | }
35 |
36 | static Derived* GetInstancePtr( void )
37 | {
38 | return instance_;
39 | }
40 |
41 | protected:
42 |
43 | ManualSingleton( void )
44 | {
45 | assert( instance_ == nullptr );
46 | instance_ = static_cast< Derived* >( this );
47 | }
48 |
49 | ~ManualSingleton( void )
50 | {
51 | assert( instance_ == this );
52 | instance_ = nullptr;
53 | }
54 |
55 | private:
56 |
57 | static Derived* instance_;
58 |
59 | };
60 |
61 | template< typename Derived >
62 | class Singleton
63 | {
64 | public:
65 |
66 | static Derived& GetInstance( void )
67 | {
68 | static Derived instance = { };
69 | return instance;
70 | }
71 |
72 | };
73 |
74 | template< typename Derived >
75 | Derived* ManualSingleton< Derived >::instance_ = nullptr;
76 |
77 | ORB_NAMESPACE_END
78 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Widget/Console.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #include "Console.h"
19 |
20 | #include "Orbit/Core/Platform/Windows/Win32Error.h"
21 |
22 | ORB_NAMESPACE_BEGIN
23 |
24 | Console::Console( void )
25 | {
26 |
27 | #if defined( ORB_OS_WINDOWS )
28 | AllocConsole();
29 | #endif // ORB_OS_WINDOWS
30 |
31 | }
32 |
33 | Console::~Console( void )
34 | {
35 |
36 | #if defined( ORB_OS_WINDOWS )
37 | ORB_CHECK_SYSTEM_ERROR( SetStdHandle( STD_OUTPUT_HANDLE, NULL ) );
38 | FreeConsole();
39 | #endif // ORB_OS_WINDOWS
40 |
41 | }
42 |
43 | ORB_NAMESPACE_END
44 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Widget/Console.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Utility/Singleton.h"
20 |
21 | ORB_NAMESPACE_BEGIN
22 |
23 | class ORB_API_CORE Console : public ManualSingleton< Console >
24 | {
25 | public:
26 |
27 | Console( void );
28 | ~Console( void );
29 |
30 | };
31 |
32 | ORB_NAMESPACE_END
33 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Widget/Point.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #include "Point.h"
19 |
20 | #include
21 |
22 | ORB_NAMESPACE_BEGIN
23 |
24 | Point::Point( void )
25 | : x{ 0 }
26 | , y{ 0 }
27 | {
28 | }
29 |
30 | Point::Point( int x, int y )
31 | : x{ x }
32 | , y{ y }
33 | {
34 | }
35 |
36 | Point::Point( float fx, float fy )
37 | : x{ static_cast< int >( std::round( fx ) ) }
38 | , y{ static_cast< int >( std::round( fy ) ) }
39 | {
40 | }
41 |
42 | Point::Point( double dx, double dy )
43 | : x( static_cast< int >( std::round( dx ) ) )
44 | , y( static_cast< int >( std::round( dy ) ) )
45 | {
46 | }
47 |
48 | Point& Point::operator+=( const Point& other )
49 | {
50 | x += other.x;
51 | y += other.y;
52 |
53 | return *this;
54 | }
55 |
56 | Point& Point::operator-=( const Point& other )
57 | {
58 | x -= other.x;
59 | y -= other.y;
60 |
61 | return *this;
62 | }
63 |
64 | Point Point::operator+( const Point& other ) const
65 | {
66 | return Point( x + other.x, y + other.y );
67 | }
68 |
69 | Point Point::operator-( const Point& other ) const
70 | {
71 | return Point( x - other.x, y - other.y );
72 | }
73 |
74 | ORB_NAMESPACE_END
75 |
--------------------------------------------------------------------------------
/src/Orbit/Core/Widget/Point.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Core.h"
20 |
21 | ORB_NAMESPACE_BEGIN
22 |
23 | class ORB_API_CORE Point
24 | {
25 | public:
26 |
27 | Point( void );
28 | Point( int x, int y );
29 | Point( float fx, float fy );
30 | Point( double dx, double dy );
31 |
32 | public:
33 |
34 | Point& operator+=( const Point& other );
35 | Point& operator-=( const Point& other );
36 |
37 | public:
38 |
39 | Point operator+( const Point& other ) const;
40 | Point operator-( const Point& other ) const;
41 |
42 | public:
43 |
44 | int x;
45 | int y;
46 |
47 | };
48 |
49 | ORB_NAMESPACE_END
50 |
--------------------------------------------------------------------------------
/src/Orbit/Graphics/API/OpenGL/GLSL.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Graphics/API/OpenGL/OpenGLVersion.h"
20 |
21 | #include
22 |
23 | ORB_NAMESPACE_BEGIN
24 |
25 | namespace GLSL
26 | {
27 | extern ORB_API_GRAPHICS std::string_view GetVersionDirective ( OpenGLVersion version );
28 | extern ORB_API_GRAPHICS std::string_view GetGLSLDefine ( void );
29 | extern ORB_API_GRAPHICS std::string_view GetShaderTypeDefine ( ShaderType shader_type );
30 | extern ORB_API_GRAPHICS std::string_view GetPrecision ( OpenGLVersion version );
31 | extern ORB_API_GRAPHICS std::string_view GetConstantsMacros ( OpenGLVersion version );
32 | extern ORB_API_GRAPHICS std::string_view GetVaryingMacro ( OpenGLVersion version, ShaderType shader_type );
33 | extern ORB_API_GRAPHICS std::string_view GetAttributeMacro ( OpenGLVersion version, ShaderType shader_type );
34 | extern ORB_API_GRAPHICS std::string_view GetOutColorMacro ( OpenGLVersion version );
35 | }
36 |
37 | ORB_NAMESPACE_END
38 |
--------------------------------------------------------------------------------
/src/Orbit/Graphics/API/OpenGL/OpenGL.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Graphics/Graphics.h"
20 |
21 | #if( ORB_HAS_OPENGL )
22 | # include "Orbit/Core/Utility/Bitmask.h"
23 |
24 | # include
25 | # include
26 | # include
27 | # include
28 |
29 | ORB_NAMESPACE_BEGIN
30 |
31 | using GLintptr = ptrdiff_t;
32 | using GLsizeiptr = size_t;
33 | using GLdouble = double;
34 | using GLchar = char;
35 | using GLint64 = int64_t;
36 | using GLsync = struct __GLsync*;
37 |
38 | extern ORB_API_GRAPHICS void* GetOpenGLProcAddress( std::string_view name );
39 | extern ORB_API_GRAPHICS void HandleOpenGLError ( GLenum err, std::string_view func );
40 |
41 | #define ORB_GL_CLAMP_TO_EDGE 0x812F
42 | #define ORB_GL_DEPTH24_STENCIL8 0x88F0
43 |
44 | ORB_NAMESPACE_END
45 |
46 | #endif // ORB_HAS_OPENGL
47 |
--------------------------------------------------------------------------------
/src/Orbit/Graphics/Animation/Animation.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020 Sebastian Kylander https://gaztin.com/
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty. In no event will
5 | * the authors be held liable for any damages arising from the use of this software.
6 | *
7 | * Permission is granted to anyone to use this software for any purpose, including commercial
8 | * applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 | *
10 | * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the
11 | * original software. If you use this software in a product, an acknowledgment in the product
12 | * documentation would be appreciated but is not required.
13 | * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
14 | * being the original software.
15 | * 3. This notice may not be removed or altered from any source distribution.
16 | */
17 |
18 | #pragma once
19 | #include "Orbit/Core/Utility/Span.h"
20 | #include "Orbit/Graphics/Animation/KeyFrame.h"
21 |
22 | #include