├── .gitignore ├── .travis.yml ├── .vimrc ├── AUTHORS ├── CMakeLists.txt ├── LICENSE ├── README.md ├── appveyor.yml ├── code ├── Modules │ ├── Assets │ │ ├── CMakeLists.txt │ │ ├── Gfx │ │ │ ├── MeshBuilder.cc │ │ │ ├── MeshBuilder.h │ │ │ ├── MeshLoader.cc │ │ │ ├── MeshLoader.h │ │ │ ├── OmshParser.cc │ │ │ ├── OmshParser.h │ │ │ ├── ShapeBuilder.cc │ │ │ ├── ShapeBuilder.h │ │ │ ├── TextureLoader.cc │ │ │ ├── TextureLoader.h │ │ │ ├── VertexWriter.cc │ │ │ └── VertexWriter.h │ │ └── UnitTests │ │ │ ├── MeshBuilderTest.cc │ │ │ ├── ShapeBuilderTest.cc │ │ │ └── VertexWriterTest.cc │ ├── CMakeLists.txt │ ├── Core │ │ ├── App.cc │ │ ├── App.h │ │ ├── AppState.h │ │ ├── Args.cc │ │ ├── Args.h │ │ ├── Assertion.h │ │ ├── CMakeLists.txt │ │ ├── Class.h │ │ ├── Config.h │ │ ├── Containers │ │ │ ├── Array.h │ │ │ ├── ArrayMap.h │ │ │ ├── Buffer.h │ │ │ ├── HashSet.h │ │ │ ├── InlineArray.h │ │ │ ├── KeyValuePair.h │ │ │ ├── Map.h │ │ │ ├── Queue.h │ │ │ ├── README.md │ │ │ ├── Set.h │ │ │ ├── Slice.h │ │ │ ├── StaticArray.h │ │ │ └── elementBuffer.h │ │ ├── Core.cc │ │ ├── Core.h │ │ ├── Creator.h │ │ ├── Log.cc │ │ ├── Log.h │ │ ├── Logger.cc │ │ ├── Logger.h │ │ ├── Main.h │ │ ├── Memory │ │ │ ├── Memory.cc │ │ │ └── Memory.h │ │ ├── Ptr.h │ │ ├── README.md │ │ ├── RefCounted.h │ │ ├── RunLoop.cc │ │ ├── RunLoop.h │ │ ├── StackTrace.cc │ │ ├── StackTrace.h │ │ ├── String │ │ │ ├── ConvertUTF.c │ │ │ ├── ConvertUTF.h │ │ │ ├── README.md │ │ │ ├── String.cc │ │ │ ├── String.h │ │ │ ├── StringAtom.cc │ │ │ ├── StringAtom.h │ │ │ ├── StringBuilder.cc │ │ │ ├── StringBuilder.h │ │ │ ├── StringConverter.cc │ │ │ ├── StringConverter.h │ │ │ ├── WideString.cc │ │ │ ├── WideString.h │ │ │ ├── readme.txt │ │ │ ├── stringAtomBuffer.cc │ │ │ ├── stringAtomBuffer.h │ │ │ ├── stringAtomTable.cc │ │ │ └── stringAtomTable.h │ │ ├── Threading │ │ │ ├── ThreadLocalData.cc │ │ │ ├── ThreadLocalData.h │ │ │ └── ThreadLocalPtr.h │ │ ├── Time │ │ │ ├── Clock.cc │ │ │ ├── Clock.h │ │ │ ├── Duration.h │ │ │ └── TimePoint.h │ │ ├── Trace.cc │ │ ├── Trace.h │ │ ├── Types.h │ │ ├── UnitTests │ │ │ ├── ArgsTest.cc │ │ │ ├── ArrayMapTest.cc │ │ │ ├── ArrayTest.cc │ │ │ ├── BufferTest.cc │ │ │ ├── ClockTest.cc │ │ │ ├── CreationTest.cc │ │ │ ├── CreatorTest.cc │ │ │ ├── DurationTest.cc │ │ │ ├── HashSetTest.cc │ │ │ ├── InlineArrayTest.cc │ │ │ ├── LogTest.cc │ │ │ ├── MapTest.cc │ │ │ ├── MemoryTest.cc │ │ │ ├── PtrTest.cc │ │ │ ├── QueueTest.cc │ │ │ ├── RttiTest.cc │ │ │ ├── RunLoopTest.cc │ │ │ ├── SetTest.cc │ │ │ ├── SliceTest.cc │ │ │ ├── StackTraceTest.cc │ │ │ ├── StaticArrayTest.cc │ │ │ ├── StringAtomTest.cc │ │ │ ├── StringBuilderTest.cc │ │ │ ├── StringConverterTest.cc │ │ │ ├── StringTest.cc │ │ │ ├── TimePointTest.cc │ │ │ ├── WideStringTest.cc │ │ │ └── elementBufferTest.cc │ │ ├── precompiled.h │ │ └── private │ │ │ ├── android │ │ │ ├── androidBridge.cc │ │ │ ├── androidBridge.h │ │ │ ├── android_native_app_glue.c │ │ │ └── android_native_app_glue.h │ │ │ ├── ios │ │ │ ├── iosBridge.h │ │ │ └── iosBridge.mm │ │ │ ├── osx │ │ │ ├── osxBridge.h │ │ │ ├── osxBridge.mm │ │ │ └── osxInputDefs.h │ │ │ ├── posix │ │ │ └── precompiled.h │ │ │ └── windows │ │ │ ├── StackWalker.cc │ │ │ ├── StackWalker.h │ │ │ └── precompiled.h │ ├── Dbg │ │ ├── CMakeLists.txt │ │ ├── Dbg.cc │ │ ├── Dbg.h │ │ ├── DbgTypes.h │ │ └── private │ │ │ ├── DebugShaders.glsl │ │ │ ├── debugFont.cc │ │ │ ├── debugTextRenderer.cc │ │ │ └── debugTextRenderer.h │ ├── Gfx │ │ ├── CMakeLists.txt │ │ ├── Gfx.cc │ │ ├── Gfx.h │ │ ├── GfxConfig.h │ │ ├── GfxTypes.cc │ │ ├── GfxTypes.h │ │ ├── MeshLoaderBase.cc │ │ ├── MeshLoaderBase.h │ │ ├── README.md │ │ ├── TextureLoaderBase.cc │ │ ├── TextureLoaderBase.h │ │ ├── UnitTests │ │ │ ├── DDSLoadTest.cc │ │ │ ├── MeshFactoryTest.cc │ │ │ ├── MeshSetupTest.cc │ │ │ ├── RenderEnumsTest.cc │ │ │ ├── RenderSetupTest.cc │ │ │ ├── ShapeBuilderTest.h │ │ │ ├── TestShaderLibrary.glsl │ │ │ ├── TextureFactoryTest.cc │ │ │ ├── TextureSetupTest.cc │ │ │ ├── VertexLayoutTest.cc │ │ │ └── glTypesTest.cc │ │ ├── doc │ │ │ ├── Meshes.md │ │ │ ├── Pipelines.md │ │ │ ├── RenderBackends.md │ │ │ ├── RenderLoop.md │ │ │ ├── RenderPasses.md │ │ │ ├── Resources.md │ │ │ ├── Shaders.md │ │ │ └── Textures.md │ │ └── private │ │ │ ├── d3d11 │ │ │ ├── d3d11DisplayMgr.cc │ │ │ ├── d3d11DisplayMgr.h │ │ │ ├── d3d11Factory.cc │ │ │ ├── d3d11Factory.h │ │ │ ├── d3d11Renderer.cc │ │ │ ├── d3d11Renderer.h │ │ │ ├── d3d11Resource.cc │ │ │ ├── d3d11Resource.h │ │ │ ├── d3d11Types.cc │ │ │ ├── d3d11Types.h │ │ │ ├── d3d11_decl.h │ │ │ └── d3d11_impl.h │ │ │ ├── displayMgr.h │ │ │ ├── displayMgrBase.cc │ │ │ ├── displayMgrBase.h │ │ │ ├── egl │ │ │ ├── eglDisplayMgr.cc │ │ │ └── eglDisplayMgr.h │ │ │ ├── emsc │ │ │ ├── emscDisplayMgr.cc │ │ │ └── emscDisplayMgr.h │ │ │ ├── flextgl │ │ │ ├── flextGL.c │ │ │ ├── flextGL.h │ │ │ ├── flextgl.sh │ │ │ └── flextgl_profile.txt │ │ │ ├── gfxFactory.h │ │ │ ├── gfxFactoryBase.cc │ │ │ ├── gfxFactoryBase.h │ │ │ ├── gfxPointers.h │ │ │ ├── gfxResourceContainer.cc │ │ │ ├── gfxResourceContainer.h │ │ │ ├── gl │ │ │ ├── glCaps.cc │ │ │ ├── glCaps.h │ │ │ ├── glFactory.cc │ │ │ ├── glFactory.h │ │ │ ├── glRenderer.cc │ │ │ ├── glRenderer.h │ │ │ ├── glResource.cc │ │ │ ├── glResource.h │ │ │ ├── glTypes.cc │ │ │ ├── glTypes.h │ │ │ ├── gl_decl.h │ │ │ └── gl_impl.h │ │ │ ├── glfw │ │ │ ├── glfwDisplayMgr.cc │ │ │ └── glfwDisplayMgr.h │ │ │ ├── ios │ │ │ ├── iosDisplayMgr.h │ │ │ └── iosDisplayMgr.mm │ │ │ ├── mtl │ │ │ ├── mtlDisplayMgr.h │ │ │ ├── mtlDisplayMgr.mm │ │ │ ├── mtlFactory.h │ │ │ ├── mtlFactory.mm │ │ │ ├── mtlRenderer.h │ │ │ ├── mtlRenderer.mm │ │ │ ├── mtlResource.h │ │ │ ├── mtlResource.mm │ │ │ ├── mtlTypes.h │ │ │ ├── mtlTypes.mm │ │ │ ├── mtl_decl.h │ │ │ └── mtl_impl.h │ │ │ ├── renderer.h │ │ │ ├── resource.h │ │ │ ├── resourceBase.cc │ │ │ ├── resourceBase.h │ │ │ ├── resourcePools.h │ │ │ └── win │ │ │ ├── winDisplayMgr.cc │ │ │ ├── winDisplayMgr.h │ │ │ ├── winInputDefs.h │ │ │ └── win_decl.h │ ├── HttpFS │ │ ├── CMakeLists.txt │ │ ├── HTTPFileSystem.cc │ │ ├── HTTPFileSystem.h │ │ ├── README.md │ │ ├── UnitTests │ │ │ └── HTTPFileSystemTest.cc │ │ └── private │ │ │ ├── baseURLLoader.cc │ │ │ ├── baseURLLoader.h │ │ │ ├── curl │ │ │ ├── curlURLLoader.cc │ │ │ └── curlURLLoader.h │ │ │ ├── emsc │ │ │ ├── emscURLLoader.cc │ │ │ └── emscURLLoader.h │ │ │ ├── osx │ │ │ ├── osxURLLoader.h │ │ │ └── osxURLLoader.mm │ │ │ ├── urlLoader.h │ │ │ └── win │ │ │ ├── winURLLoader.cc │ │ │ └── winURLLoader.h │ ├── IO │ │ ├── CMakeLists.txt │ │ ├── FileSystemBase.cc │ │ ├── FileSystemBase.h │ │ ├── IO.cc │ │ ├── IO.h │ │ ├── IOTypes.cc │ │ ├── IOTypes.h │ │ ├── README.md │ │ ├── UnitTests │ │ │ ├── IOFacadeTest.cc │ │ │ ├── IOStatusTest.cc │ │ │ ├── URLBuilderTest.cc │ │ │ ├── URLTest.cc │ │ │ ├── assignRegistryTest.cc │ │ │ └── schemeRegistryTest.cc │ │ └── private │ │ │ ├── assignRegistry.cc │ │ │ ├── assignRegistry.h │ │ │ ├── ioPointers.h │ │ │ ├── ioRequests.h │ │ │ ├── ioRouter.cc │ │ │ ├── ioRouter.h │ │ │ ├── ioWorker.cc │ │ │ ├── ioWorker.h │ │ │ ├── loadQueue.cc │ │ │ ├── loadQueue.h │ │ │ ├── schemeRegistry.cc │ │ │ └── schemeRegistry.h │ ├── Input │ │ ├── CMakeLists.txt │ │ ├── Input.cc │ │ ├── Input.h │ │ ├── InputTypes.cc │ │ ├── InputTypes.h │ │ ├── README.md │ │ └── private │ │ │ ├── android │ │ │ ├── androidInputMgr.cc │ │ │ └── androidInputMgr.h │ │ │ ├── emsc │ │ │ ├── emscInputMgr.cc │ │ │ └── emscInputMgr.h │ │ │ ├── gestureDetectors.cc │ │ │ ├── gestureDetectors.h │ │ │ ├── glfw │ │ │ ├── glfwInputMgr.cc │ │ │ └── glfwInputMgr.h │ │ │ ├── inputDevices.cc │ │ │ ├── inputDevices.h │ │ │ ├── inputDispatcher.cc │ │ │ ├── inputDispatcher.h │ │ │ ├── inputMgr.h │ │ │ ├── inputMgrBase.cc │ │ │ ├── inputMgrBase.h │ │ │ ├── ios │ │ │ ├── iosInputMgr.h │ │ │ └── iosInputMgr.mm │ │ │ ├── osx │ │ │ ├── osxInputMgr.cc │ │ │ └── osxInputMgr.h │ │ │ ├── raspi │ │ │ ├── raspiInputMgr.cc │ │ │ └── raspiInputMgr.h │ │ │ └── win │ │ │ ├── winInputMgr.cc │ │ │ └── winInputMgr.h │ ├── LocalFS │ │ ├── CMakeLists.txt │ │ ├── LocalFileSystem.cc │ │ ├── LocalFileSystem.h │ │ ├── README.md │ │ ├── UnitTests │ │ │ ├── FSWrapperTest.cc │ │ │ └── LocalFileSystemTest.cc │ │ └── private │ │ │ ├── dummy │ │ │ ├── dummyFSWrapper.cc │ │ │ └── dummyFSWrapper.h │ │ │ ├── fsWrapper.h │ │ │ ├── posix │ │ │ ├── posixFSWrapper.cc │ │ │ └── posixFSWrapper.h │ │ │ └── whereami │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── whereami.c │ │ │ ├── whereami.h │ │ │ └── whereami_oryol.cc │ └── Resource │ │ ├── CMakeLists.txt │ │ ├── Id.h │ │ ├── Locator.cc │ │ ├── Locator.h │ │ ├── README.md │ │ ├── ResourceBase.h │ │ ├── ResourceContainerBase.cc │ │ ├── ResourceContainerBase.h │ │ ├── ResourceInfo.h │ │ ├── ResourceLabel.h │ │ ├── ResourceLoader.cc │ │ ├── ResourceLoader.h │ │ ├── ResourcePool.h │ │ ├── ResourcePoolInfo.h │ │ ├── ResourceRegistry.cc │ │ ├── ResourceRegistry.h │ │ ├── ResourceState.h │ │ ├── SetupAndData.h │ │ └── UnitTests │ │ ├── IdTest.cc │ │ ├── LocatorTest.cc │ │ ├── ResourcePoolTest.cc │ │ ├── StateTest.cc │ │ └── resourceRegistryTest.cc ├── Pre.cc ├── Pre.h └── Samples │ ├── ArrayTexture │ ├── ArrayTexture.cc │ ├── ArrayTexture.jpg │ ├── CMakeLists.txt │ └── shaders.glsl │ ├── BlendTest │ ├── BlendTest.cc │ ├── BlendTest.jpg │ ├── CMakeLists.txt │ └── shaders.glsl │ ├── CMakeLists.txt │ ├── Clear │ ├── CMakeLists.txt │ ├── Clear.cc │ └── Clear.jpg │ ├── CoreHello │ ├── CMakeLists.txt │ └── CoreHello.cc │ ├── DDSCubeMap │ ├── CMakeLists.txt │ ├── DDSCubeMap.cc │ ├── DDSCubeMap.jpg │ └── shaders.glsl │ ├── DDSTextureLoading │ ├── CMakeLists.txt │ ├── DDSTextureLoading.cc │ ├── DDSTextureLoading.jpg │ └── shaders.glsl │ ├── DebugText │ ├── CMakeLists.txt │ ├── DebugText.cc │ └── DebugText.jpg │ ├── DrawCallPerf │ ├── CMakeLists.txt │ ├── DrawCallPerf.cc │ ├── DrawCallPerf.jpg │ └── shaders.glsl │ ├── FullscreenQuad │ ├── CMakeLists.txt │ ├── FullscreenQuad.cc │ ├── FullscreenQuad.jpg │ └── shaders.glsl │ ├── GPUParticles │ ├── CMakeLists.txt │ ├── GPUParticles.cc │ ├── GPUParticles.jpg │ └── shaders.glsl │ ├── GamepadExplorer │ ├── CMakeLists.txt │ ├── GamepadExplorer.cc │ └── GamepadExplorer.jpg │ ├── IOQueueSample │ ├── CMakeLists.txt │ └── IOQueueSample.cc │ ├── InfiniteSpheres │ ├── CMakeLists.txt │ ├── InfiniteSpheres.cc │ ├── InfiniteSpheres.jpg │ └── shaders.glsl │ ├── Instancing │ ├── CMakeLists.txt │ ├── Instancing.cc │ ├── Instancing.jpg │ └── shaders.glsl │ ├── MultipleRenderTarget │ ├── CMakeLists.txt │ ├── MultipleRenderTarget.cc │ ├── MultipleRenderTarget.jpg │ └── shaders.glsl │ ├── NativeTexture │ ├── CMakeLists.txt │ ├── NativeTexture.cc │ ├── NativeTexture.jpg │ └── shaders.glsl │ ├── PackedNormals │ ├── CMakeLists.txt │ ├── PackedNormals.cc │ ├── PackedNormals.jpg │ └── shaders.glsl │ ├── PrimitiveTypes │ ├── CMakeLists.txt │ ├── PrimitiveTypes.cc │ ├── PrimitiveTypes.jpg │ └── shaders.glsl │ ├── Quad │ ├── CMakeLists.txt │ ├── Quad.cc │ ├── Quad.jpg │ └── shaders.glsl │ ├── RenderToCubeMap │ ├── CMakeLists.txt │ ├── RenderToCubeMap.cc │ ├── RenderToCubeMap.jpg │ └── shaders.glsl │ ├── ResourceStress │ ├── CMakeLists.txt │ ├── ResourceStress.cc │ └── shaders.glsl │ ├── Sensors │ ├── CMakeLists.txt │ ├── Sensors.cc │ └── shaders.glsl │ ├── SeparateBuffers │ ├── CMakeLists.txt │ ├── SeparateBuffers.cc │ ├── SeparateBuffers.jpg │ └── shaders.glsl │ ├── Shapes │ ├── CMakeLists.txt │ ├── Shapes.cc │ ├── Shapes.jpg │ └── shaders.glsl │ ├── SimpleRenderTarget │ ├── CMakeLists.txt │ ├── SimpleRenderTarget.cc │ ├── SimpleRenderTarget.jpg │ └── shaders.glsl │ ├── TestInput │ ├── CMakeLists.txt │ ├── TestInput.cc │ ├── TestInput.jpg │ └── shaders.glsl │ ├── TextureFloat │ ├── CMakeLists.txt │ ├── TextureFloat.cc │ ├── TextureFloat.jpg │ └── shaders.glsl │ ├── Triangle │ ├── CMakeLists.txt │ ├── Triangle.cc │ ├── Triangle.jpg │ └── shaders.glsl │ ├── VertexTexture │ ├── CMakeLists.txt │ ├── VertexTexture.cc │ ├── VertexTexture.jpg │ └── shaders.glsl │ └── VolumeTexture │ ├── CMakeLists.txt │ ├── VolumeTexture.cc │ ├── VolumeTexture.jpg │ └── shaders.glsl ├── data ├── RomeChurch │ ├── negx.jpg │ ├── negy.jpg │ ├── negz.jpg │ ├── posx.jpg │ ├── posy.jpg │ ├── posz.jpg │ └── readme.txt ├── httptest.txt └── lok256.jpg ├── doc ├── BUILD.md ├── DESIGN-MANIFESTO.md ├── GfxResourceTour.md ├── LINKS.md ├── NEWS.md ├── OVERVIEW.md ├── README.md ├── ShaderGenerators.md ├── doxygen.conf ├── planning │ └── asset_planning.md ├── stringatoms.md └── unit_testing.md ├── fips ├── fips-files ├── configs │ ├── d3d11-win64-vs2017-debug.yml │ ├── d3d11-win64-vs2017-release.yml │ ├── d3d11-win64-vscode-debug.yml │ ├── d3d11-win64-vstudio-debug.yml │ ├── d3d11-win64-vstudio-release.yml │ ├── linux-make-unittest.yml │ ├── metal-ios-xcode-debug.yml │ ├── metal-ios-xcode-release.yml │ ├── metal-osx-make-debug.yml │ ├── metal-osx-make-release.yml │ ├── metal-osx-ninja-debug.yml │ ├── metal-osx-ninja-release.yml │ ├── metal-osx-vscode-debug.yml │ ├── metal-osx-xcode-debug.yml │ ├── metal-osx-xcode-release.yml │ ├── oryol-emsc-unittest.yml │ ├── oryol-osx-unittest-headless.yml │ ├── osx-make-unittest.yml │ ├── wasmasmjs-make-release.yml │ ├── wayland-linux-clion-debug.yml │ ├── wayland-linux-clion-release.yml │ ├── wayland-linux-eclipse-debug.yml │ ├── wayland-linux-eclipse-profiling.yml │ ├── wayland-linux-eclipse-release.yml │ ├── wayland-linux-eclipse-unittest.yml │ ├── wayland-linux-make-debug.yml │ ├── wayland-linux-make-profiling.yml │ ├── wayland-linux-make-release.yml │ ├── wayland-linux-make-unittest.yml │ ├── wayland-linux-ninja-debug.yml │ ├── wayland-linux-ninja-profiling.yml │ ├── wayland-linux-ninja-release.yml │ ├── wayland-linux-vscode-debug.yml │ ├── wayland-linux-vscode-release.yml │ ├── wayland-linux-vscode-unittest.yml │ ├── webgl2-emsc-ninja-release.yml │ └── webgl2-wasm-ninja-release.yml ├── generators │ ├── README.md │ ├── Shader.py │ ├── SpriteSheet.py │ └── util │ │ ├── __init__.py │ │ ├── glslcompiler.py │ │ ├── hlslcompiler.py │ │ ├── metalcompiler.py │ │ ├── png.py │ │ └── shdc.py ├── include.cmake └── verbs │ ├── testrunner.py │ ├── wasmtest.py │ └── webpage.py ├── fips.cmd ├── fips.yml ├── tools ├── GLSLReferenceCompiler.txt ├── NVIDIA_Texture_Tools_LICENSE.txt ├── NVIDIA_Texture_Tools_README.txt ├── PowerVR_SDK_End_User_Licence_Agreement.txt ├── README.md ├── __init__.py ├── linux │ ├── PVRTexToolCLI │ ├── glslangValidator │ ├── nvassemble │ ├── nvcompress │ ├── nvddsinfo │ ├── oryol-export │ └── oryol-shdc ├── osx │ ├── PVRTexToolCLI │ ├── astcenc │ ├── composite │ ├── convert │ ├── etcpack │ ├── glslangValidator │ ├── nvassemble │ ├── nvcompress │ ├── nvddsinfo │ ├── oryol-export │ ├── oryol-shdc │ ├── spirv-cross │ └── spirv-remap ├── raspi │ ├── glslangValidator │ └── oryol-shdc ├── texexport.py └── win32 │ ├── PVRTexToolCLI.exe │ ├── glslangValidator.exe │ ├── ninja.exe │ ├── nvassemble.exe │ ├── nvcompress.exe │ ├── nvddsinfo.exe │ ├── oryol-export.exe │ ├── oryol-shdc.exe │ └── spirv-cross.exe └── web ├── about.html ├── dummy.jpg ├── emsc.html ├── emsc.js ├── ext_samples.jpg ├── favicon.png ├── index.html ├── style.css ├── wasm.html ├── wasm.js └── wasmsuite-readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vscode/ 3 | bin/ 4 | vagrant/.vagrant 5 | doc/html 6 | build/*-*-* 7 | build/*/*-*-* 8 | build/*.json 9 | build/webpage 10 | sdks/ 11 | configs/.selected 12 | *.txt.user 13 | *.swp 14 | CMakeLists.txt.user* 15 | .idea/ 16 | #>fips 17 | # this area is managed by fips, do not edit 18 | .fips-* 19 | *.pyc 20 | # 11 | 12 | " override :make for compilation 13 | set makeprg=python\ fips\ make 14 | 15 | " CtrlP ignore patterns 16 | let g:ctrlp_custom_ignore = '.pyc\|lib\|bin\|sdks\|doc/html' 17 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | The following authors have all licensed their contributions to Oryol 2 | under the licensing terms detailed in LICENSE. 3 | 4 | (Authors keep copyright of their contributions, of course; they just grant 5 | a license to everyone to use it as detailed in LICENSE.) 6 | 7 | Andre 'Floh' Weissflog (floooh@gmail.com) 8 | Bruce Mitchener (bruce.mitchener@gmail.com) 9 | Martin Gerhardy (martin.gerhardy@gmail.com) 10 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # oryol cmake root file 3 | # 4 | # See BUILD.md for details how to build oryol. 5 | #------------------------------------------------------------------------------- 6 | cmake_minimum_required(VERSION 2.8) 7 | 8 | get_filename_component(FIPS_ROOT_DIR "../fips" ABSOLUTE) 9 | include("${FIPS_ROOT_DIR}/cmake/fips.cmake") 10 | 11 | fips_setup(PROJECT oryol) 12 | fips_include_directories(code) 13 | fips_include_directories(code/Modules) 14 | fips_ide_group(Modules) 15 | fips_add_subdirectory(code/Modules) 16 | if (ORYOL_SAMPLES) 17 | fips_ide_group(Samples) 18 | fips_include_directories(code/Samples) 19 | # also find out-of-source generated headers 20 | fips_include_directories(${CMAKE_BINARY_DIR}/code/Samples) 21 | fips_add_subdirectory(code/Samples) 22 | endif() 23 | fips_finish() 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Andre Weissflog 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # https://ci.appveyor.com/project/floooh/oryol 2 | --- 3 | branches: 4 | except: 5 | - gh-pages 6 | 7 | clone_depth: 3 8 | 9 | # just perform builds for now, don't run tests 10 | build_script: 11 | - cmd: c:/Python36/python.exe fips build win64-vstudio-debug 12 | - cmd: c:/Python36/python.exe fips build d3d11-win64-vstudio-debug 13 | 14 | -------------------------------------------------------------------------------- /code/Modules/Assets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_module(Assets) 2 | fips_vs_warning_level(3) 3 | fips_dir(Gfx) 4 | fips_files( 5 | MeshBuilder.cc MeshBuilder.h 6 | ShapeBuilder.cc ShapeBuilder.h 7 | VertexWriter.cc VertexWriter.h 8 | TextureLoader.cc TextureLoader.h 9 | OmshParser.cc OmshParser.h 10 | MeshLoader.cc MeshLoader.h 11 | ) 12 | fips_end_module() 13 | 14 | oryol_begin_unittest(Assets) 15 | fips_vs_warning_level(3) 16 | fips_dir(UnitTests) 17 | fips_files( 18 | MeshBuilderTest.cc 19 | ShapeBuilderTest.cc 20 | VertexWriterTest.cc 21 | ) 22 | fips_deps(Gfx Assets) 23 | oryol_end_unittest() 24 | 25 | 26 | -------------------------------------------------------------------------------- /code/Modules/Assets/Gfx/MeshLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::MeshLoader 5 | @ingroup Assets 6 | @brief standard mesh loader for loading .omsh files 7 | 8 | NOTE: .omsh files are created by the oryol-exporter tool 9 | in the project https://github.com/floooh/oryol-tools 10 | */ 11 | #include "Gfx/MeshLoaderBase.h" 12 | #include "IO/private/ioRequests.h" 13 | 14 | namespace Oryol { 15 | 16 | class MeshLoader : public MeshLoaderBase { 17 | OryolClassDecl(MeshLoader); 18 | public: 19 | /// constructor without success-callback 20 | MeshLoader(const MeshSetup& setup); 21 | /// constructor with success callback 22 | MeshLoader(const MeshSetup& setup, LoadedFunc onLoaded); 23 | /// destructor 24 | ~MeshLoader(); 25 | /// start loading, return a resource id 26 | virtual Id Start() override; 27 | /// continue loading, return resource state (Pending, Valid, Failed) 28 | virtual ResourceState::Code Continue() override; 29 | /// cancel the load process 30 | virtual void Cancel() override; 31 | private: 32 | Id resId; 33 | Ptr ioRequest; 34 | }; 35 | 36 | } // namespace Oryol 37 | -------------------------------------------------------------------------------- /code/Modules/Assets/Gfx/TextureLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::TextureLoader 5 | @ingroup Assets 6 | @brief standard texture loader for most block-compressed texture file formats 7 | */ 8 | #include "Gfx/TextureLoaderBase.h" 9 | #include "IO/private/ioRequests.h" 10 | 11 | namespace gliml { 12 | class context; 13 | } 14 | 15 | namespace Oryol { 16 | 17 | class TextureLoader : public TextureLoaderBase { 18 | OryolClassDecl(TextureLoader); 19 | public: 20 | /// constructor without success-callback 21 | TextureLoader(const TextureSetup& setup); 22 | /// constructor with success callback 23 | TextureLoader(const TextureSetup& setup, LoadedFunc onLoaded); 24 | /// destructor 25 | ~TextureLoader(); 26 | /// start loading, return a resource id 27 | virtual Id Start() override; 28 | /// continue loading, return resource state (Pending, Valid, Failed) 29 | virtual ResourceState::Code Continue() override; 30 | /// cancel the load process 31 | virtual void Cancel() override; 32 | 33 | private: 34 | /// convert gliml context attrs into a TextureSetup object 35 | TextureSetup buildSetup(const TextureSetup& blueprint, const gliml::context* ctx, const uint8_t* data); 36 | 37 | Id resId; 38 | Ptr ioRequest; 39 | }; 40 | 41 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/Assets/Gfx/VertexWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::VertexWriter 5 | @ingroup Assets 6 | @brief efficiently write packed vertex components 7 | */ 8 | #include "Core/Types.h" 9 | #include "Gfx/GfxTypes.h" 10 | 11 | namespace Oryol { 12 | 13 | class VertexWriter { 14 | public: 15 | /// write 1D generic vertex component with run-time pack-format selection 16 | static uint8_t* Write(uint8_t* dst, VertexFormat::Code fmt, float x); 17 | /// write 2D generic vertex component with run-time pack-format selection 18 | static uint8_t* Write(uint8_t* dst, VertexFormat::Code fmt, float x, float y); 19 | /// write 3D generic vertex component with run-time pack-format selection 20 | static uint8_t* Write(uint8_t* dst, VertexFormat::Code fmt, float x, float y, float z); 21 | /// write 4D generic vertex component with run-time pack-format selection 22 | static uint8_t* Write(uint8_t* dst, VertexFormat::Code fmt, float x, float y, float z, float w); 23 | }; 24 | 25 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # oryol modules 3 | #------------------------------------------------------------------------------- 4 | fips_add_subdirectory(Core) 5 | fips_add_subdirectory(IO) 6 | fips_add_subdirectory(HttpFS) 7 | fips_add_subdirectory(LocalFS) 8 | fips_add_subdirectory(Gfx) 9 | fips_add_subdirectory(Resource) 10 | fips_add_subdirectory(Assets) 11 | fips_add_subdirectory(Dbg) 12 | fips_add_subdirectory(Input) 13 | -------------------------------------------------------------------------------- /code/Modules/Core/AppState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::AppState 5 | @ingroup Core 6 | @brief application states 7 | */ 8 | namespace Oryol { 9 | 10 | class AppState { 11 | public: 12 | /// app state enum 13 | enum Code { 14 | Init, 15 | Running, 16 | Cleanup, 17 | Destroy, 18 | Blocked, 19 | 20 | NumAppStates, 21 | InvalidAppState, 22 | }; 23 | 24 | /// convert to string 25 | static const char* ToString(Code c) { 26 | switch (c) { 27 | case Init: return "Init"; 28 | case Running: return "Running"; 29 | case Cleanup: return "Cleanup"; 30 | case Destroy: return "Destroy"; 31 | case Blocked: return "Blocked"; 32 | default: return "InvalidAppState"; 33 | } 34 | }; 35 | }; 36 | 37 | } // namespace Oryol 38 | -------------------------------------------------------------------------------- /code/Modules/Core/Core.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @defgroup Core Core 5 | @brief Oryol core functionality 6 | 7 | @class Oryol::Core 8 | @ingroup Core 9 | @brief Core module facade 10 | */ 11 | #include "Core/Types.h" 12 | #include "Core/RunLoop.h" 13 | 14 | namespace Oryol { 15 | 16 | class Core { 17 | public: 18 | /// setup the Core module 19 | static void Setup(); 20 | /// discard the Core module 21 | static void Discard(); 22 | /// check if Core module has been setup 23 | static bool IsValid(); 24 | 25 | /// get pointer to the per-thread 'before-frame' runloop 26 | static class RunLoop* PreRunLoop(); 27 | /// get pointer to the per-thread 'after-frame' runloop 28 | static class RunLoop* PostRunLoop(); 29 | 30 | /// called when a thread is entered 31 | static void EnterThread(); 32 | /// called before a thread is left 33 | static void LeaveThread(); 34 | /// test if we are on the main thread 35 | static bool IsMainThread(); 36 | }; 37 | 38 | } // namespace Oryol 39 | -------------------------------------------------------------------------------- /code/Modules/Core/Creator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @file Core/Creator.h 5 | @brief class annotation macro for Creator method 6 | 7 | A creator object is a function object for deferred object creation. 8 | The class annotation macro OryolClassCreator adds a static method 9 | Creator(), which returns a creator object for that class. 10 | */ 11 | #include "Core/Ptr.h" 12 | #include 13 | 14 | #if defined(__GNUC__) && !defined(__clang__) 15 | /** WORKAROUND for GCC bug 'lambda argument pack' **/ 16 | #define OryolClassCreator(TYPE) \ 17 | public:\ 18 | static std::function()> Creator() {\ 19 | return [] { return Create(); };\ 20 | }; 21 | #else 22 | #define OryolClassCreator(TYPE) \ 23 | public:\ 24 | template static std::function()> Creator(ARGS... args) {\ 25 | return [args...] { return Create(args...); };\ 26 | }; 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /code/Modules/Core/Logger.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // Logger.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "Core/Logger.h" 6 | 7 | namespace Oryol { 8 | 9 | //------------------------------------------------------------------------------ 10 | Logger::Logger() { 11 | // empty 12 | } 13 | 14 | //------------------------------------------------------------------------------ 15 | Logger::~Logger() { 16 | // empty 17 | } 18 | 19 | //------------------------------------------------------------------------------ 20 | void 21 | Logger::VPrint(Log::Level /*l*/, const char* /*msg*/, va_list /*args*/) { 22 | // we can't do an o_error() here since it would recurse 23 | } 24 | 25 | //------------------------------------------------------------------------------ 26 | /** 27 | */ 28 | void 29 | Logger::AssertMsg(const char* /*cond*/, const char* /*msg*/, const char* /*file*/, int /*line*/, const char* /*func*/) { 30 | // we can't do an o_error() here since it would recurse 31 | } 32 | 33 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/Core/Logger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::Logger 5 | @ingroup Core 6 | @brief base class for implementing custom loggers 7 | 8 | Derive from this class and override its methods in order to implement 9 | a custom logging functionality. 10 | 11 | @see Log 12 | */ 13 | #include "Core/Log.h" 14 | #include "Core/RefCounted.h" 15 | 16 | namespace Oryol { 17 | 18 | class Logger : public RefCounted { 19 | OryolClassDecl(Logger); 20 | public: 21 | /// constructor 22 | Logger(); 23 | /// destructor 24 | ~Logger(); 25 | /// generic vprint-style method 26 | virtual void VPrint(Log::Level l, const char* msg, va_list args); 27 | /// print an assert message 28 | virtual void AssertMsg(const char* cond, const char* msg, const char* file, int line, const char* func); 29 | }; 30 | 31 | } // namespace Oryol 32 | -------------------------------------------------------------------------------- /code/Modules/Core/StackTrace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::StackTrace 5 | @brief low-level helper functions to dump a stack trace 6 | */ 7 | #include "Core/Types.h" 8 | 9 | namespace Oryol { 10 | 11 | class StackTrace { 12 | public: 13 | /// write stack trace into buf as human-readable string 14 | static void Dump(char* buf, int bufSize); 15 | }; 16 | 17 | } // namespace Oryol 18 | -------------------------------------------------------------------------------- /code/Modules/Core/String/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | The accompanying C source code file "ConvertUTF.c" and the associated header 3 | file "ConvertUTF.h" provide for conversion between various transformation 4 | formats of Unicode characters. The following conversions are supported: 5 | 6 | UTF-32 to UTF-16 7 | UTF-32 to UTF-8 8 | UTF-16 to UTF-32 9 | UTF-16 to UTF-8 10 | UTF-8 to UTF-16 11 | UTF-8 to UTF-32 12 | 13 | In addition, there is a test harness which runs various tests. 14 | 15 | The files "CVTUTF7.C" and "CVTUTF7.H" are for archival and historical purposes 16 | only. They have not been updated to Unicode 3.0 or later and should be 17 | considered obsolescent. "CVTUTF7.C" contains two functions that can convert 18 | between UCS2 (i.e., the BMP characters only) and UTF-7. Surrogates are 19 | not supported, the code has not been tested, and should be considered 20 | unsuitable for general purpose use. 21 | 22 | Please submit any bug reports about these programs here: 23 | 24 | http://www.unicode.org/unicode/reporting.html 25 | 26 | Version 1.0: initial version. 27 | 28 | Version 1.1: corrected some minor problems; added stricter checks. 29 | 30 | Version 1.2: corrected switch statements associated with "extraBytesToRead" 31 | in 4 & 5 byte cases, in functions for conversion from UTF8. 32 | Note: formally, the 4 & 5 byte cases are illegal in the latest 33 | UTF8, but the table and this code has always catered for those, 34 | cases since at one time they were legal. 35 | 36 | Version 1.3: Updated UTF-8 legality check; 37 | updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions 38 | Updated UTF-8 legality tests in harness.c 39 | 40 | 41 | Last update: October 19, 2004 42 | 43 | 44 | -------------------------------------------------------------------------------- /code/Modules/Core/String/stringAtomBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /* 4 | private class, do not use 5 | 6 | A growable buffer for raw string data for the StringAtom system. 7 | */ 8 | #include "Core/Types.h" 9 | #include "Core/Containers/Array.h" 10 | 11 | namespace Oryol { 12 | 13 | class stringAtomTable; 14 | 15 | class stringAtomBuffer { 16 | public: 17 | // header data for a single entry (string data starts at end of header) 18 | struct Header { 19 | // default constructor 20 | Header() : table(0), hash(0), length(0), str(0) { }; 21 | /// constructor 22 | Header(const stringAtomTable* t, int32_t hsh, int len, const char* s) : table(t), hash(hsh), length(len), str(s) { }; 23 | 24 | const stringAtomTable* table; 25 | int32_t hash; 26 | int length; 27 | const char* str; 28 | }; 29 | 30 | /// destructor 31 | ~stringAtomBuffer(); 32 | /// add a new string to the buffer, return pointer to start of header 33 | const Header* AddString(stringAtomTable* table, int32_t hash, const char* str); 34 | /// allocate a new chunk 35 | void allocChunk(); 36 | 37 | static const int chunkSize = (1<<14); // careful with this: each thread has its own stringbuffer! 38 | Array chunks; 39 | int8_t* curPointer = 0; // this is always aligned to min(sizeof(header), ORYOL_MAX_PLATFORM_ALIGN) 40 | }; 41 | 42 | } // namespace Oryol 43 | -------------------------------------------------------------------------------- /code/Modules/Core/String/stringAtomTable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /* 4 | private class, do not use 5 | 6 | A thread-local StringAtom table. 7 | */ 8 | #include "Core/Types.h" 9 | #include "Core/String/stringAtomBuffer.h" 10 | #include "Core/Containers/HashSet.h" 11 | #include "Core/Threading/ThreadLocalPtr.h" 12 | 13 | namespace Oryol { 14 | 15 | class stringAtomTable { 16 | public: 17 | /// access to thread-local stringAtomTable (created on demand) 18 | static stringAtomTable* threadLocalPtr(); 19 | /// compute hash value for string 20 | static int32_t HashForString(const char* str); 21 | /// find a matching buffer header in the table 22 | const stringAtomBuffer::Header* Find(int32_t hash, const char* str) const; 23 | /// add a string to the atom table 24 | const stringAtomBuffer::Header* Add(int32_t hash, const char* str); 25 | 26 | static ORYOL_THREADLOCAL_PTR(stringAtomTable) ptr; 27 | 28 | /// a bucket entry 29 | struct Entry { 30 | /// default constructor 31 | Entry() : header(0) { }; 32 | /// constructor with header ptr 33 | Entry(const stringAtomBuffer::Header* h) : header(h) { }; 34 | /// equality operator 35 | bool operator==(const Entry& rhs) const; 36 | /// less-then operator 37 | bool operator<(const Entry& rhs) const; 38 | 39 | const stringAtomBuffer::Header* header; 40 | }; 41 | 42 | /// hash function for bucket entry 43 | struct Hasher { 44 | int32_t operator()(const Entry& e) const { 45 | return e.header->hash; 46 | }; 47 | }; 48 | stringAtomBuffer buffer; 49 | HashSet table; 50 | }; 51 | 52 | } // namespace Oryol 53 | -------------------------------------------------------------------------------- /code/Modules/Core/Threading/ThreadLocalData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::ThreadLocalData 5 | @brief manage a thread-local pointer table via pthread keys 6 | 7 | ThreadLocalData and ThreadLocalPtr enable thread-local support 8 | on platforms where the compiler doesn't have a thread-local keyword 9 | (only on iOS so far). 10 | */ 11 | #include "Core/Types.h" 12 | #if ORYOL_THREADLOCAL_PTHREAD 13 | #include "Core/Assertion.h" 14 | #include 15 | #include 16 | 17 | namespace Oryol { 18 | 19 | class ThreadLocalData { 20 | public: 21 | /// setup once from main-thread 22 | static void SetupOnce(); 23 | 24 | /// allocate a new slot 25 | static int Alloc(); 26 | /// associate slot index with a pointer 27 | static void Set(int slotIndex, void* ptr); 28 | /// get pointer associated with slot 29 | static void* Get(int slotIndex); 30 | 31 | private: 32 | /// get pointer to thread-local pointer-table 33 | static void** PointerTable(); 34 | 35 | static const int MaxNumSlots = 1024; 36 | static pthread_key_t key; 37 | static std::atomic curSlot; 38 | }; 39 | 40 | //------------------------------------------------------------------------------ 41 | inline void* 42 | ThreadLocalData::Get(int slotIndex) { 43 | o_assert_range_dbg(slotIndex, MaxNumSlots); 44 | void** table = PointerTable(); 45 | return table[slotIndex]; 46 | } 47 | 48 | } // namespace Oryol 49 | #endif // ORYOL_COMPILER_HAS_THREADLOCAL 50 | -------------------------------------------------------------------------------- /code/Modules/Core/Time/Clock.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // Clock.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "Clock.h" 6 | #if ORYOL_EMSCRIPTEN 7 | #include 8 | #elif ORYOL_WINDOWS 9 | #include 10 | #else 11 | #include 12 | #endif 13 | 14 | namespace Oryol { 15 | 16 | #if ORYOL_WINDOWS 17 | // query perf-freq before any threads can start 18 | // and capture a start count 19 | struct _perf { 20 | _perf() { 21 | ::QueryPerformanceFrequency(&this->freq); 22 | ::QueryPerformanceCounter(&this->start); 23 | }; 24 | LARGE_INTEGER freq; 25 | LARGE_INTEGER start; 26 | } perf; 27 | #endif 28 | 29 | //------------------------------------------------------------------------------ 30 | TimePoint 31 | Clock::Now() { 32 | #if ORYOL_EMSCRIPTEN 33 | // get int64 time in microseconds (emscripten_now is ms) 34 | int64_t t = int64_t(emscripten_get_now() * 1000); 35 | #elif ORYOL_WINDOWS 36 | // VisualStudio2013's chrono::high_resolution_clock isn't actually high_resolution 37 | // VisualStudio2015: in VS2015-final this is fixed (might want to use std::chrono if 38 | // VS version is >= VS2015? 39 | LARGE_INTEGER perfCount; 40 | QueryPerformanceCounter(&perfCount); 41 | int64_t t = ((perfCount.QuadPart - perf.start.QuadPart) * 1000000) / perf.freq.QuadPart; 42 | #else 43 | using namespace std; 44 | auto now = chrono::high_resolution_clock::now(); 45 | int64_t t = chrono::duration_cast(now.time_since_epoch()).count(); 46 | #endif 47 | return TimePoint(t); 48 | } 49 | 50 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/Core/Time/Clock.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::Clock 5 | @ingroup Core 6 | @brief high-resolution time source 7 | 8 | The most important method of Clock is Now() which returns the 9 | current point in time. The time values returned by Clock have 10 | no relation to the "wall-clock-time". 11 | */ 12 | #include "Core/Time/TimePoint.h" 13 | 14 | namespace Oryol { 15 | 16 | class Clock { 17 | public: 18 | /// get current point in time 19 | static TimePoint Now(); 20 | /// get duration between Now and another TimePoint 21 | static Duration Since(const TimePoint& t); 22 | /// get duration between Now and TimePoint in the past, and set TimePoint to Now 23 | static Duration LapTime(TimePoint& inOutTimepoint); 24 | }; 25 | 26 | //------------------------------------------------------------------------------ 27 | inline Duration 28 | Clock::Since(const TimePoint& t) { 29 | return Now().Since(t); 30 | } 31 | 32 | //------------------------------------------------------------------------------ 33 | inline Duration 34 | Clock::LapTime(TimePoint& inOutTimepoint) { 35 | TimePoint now = Clock::Now(); 36 | Duration dur = now.Since(inOutTimepoint); 37 | inOutTimepoint = now; 38 | return dur; 39 | } 40 | 41 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/Core/Trace.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // Trace.cc 3 | //------------------------------------------------------------------------------ 4 | #if ORYOL_PROFILING 5 | #include "Pre.h" 6 | #include "Trace.h" 7 | 8 | namespace Oryol { 9 | 10 | //------------------------------------------------------------------------------ 11 | Trace::Trace() { 12 | #if ORYOL_USE_REMOTERY 13 | rmt_CreateGlobalInstance(&this->rmt); 14 | rmt_SetCurrentThreadName("MainThread"); 15 | #elif ORYOL_USE_EMSCTRACE 16 | emscripten_trace_configure("http://localhost:5000/", "OryolApp"); 17 | #endif 18 | } 19 | 20 | //------------------------------------------------------------------------------ 21 | Trace::~Trace() { 22 | #if ORYOL_USE_REMOTERY 23 | rmt_DestroyGlobalInstance(this->rmt); 24 | this->rmt = nullptr; 25 | #elif ORYOL_USE_EMSCTRACE 26 | emscripten_trace_close(); 27 | #endif 28 | } 29 | 30 | } // namespace Oryol 31 | #endif 32 | -------------------------------------------------------------------------------- /code/Modules/Core/Types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @file Core/Types.h 5 | @brief defines basic data types for Oryol 6 | */ 7 | #include 8 | 9 | namespace Oryol { 10 | 11 | // those typedefs are obsolete, don't use 12 | typedef int8_t int8; 13 | typedef uint8_t uint8; 14 | typedef int16_t int16; 15 | typedef uint16_t uint16; 16 | typedef int32_t int32; 17 | typedef uint32_t uint32; 18 | typedef int64_t int64; 19 | typedef uint64_t uint64; 20 | typedef float float32; 21 | typedef double float64; 22 | typedef intptr_t intptr; 23 | typedef uintptr_t uintptr; 24 | typedef unsigned char uchar; 25 | 26 | static const int32_t InvalidIndex = -1; 27 | static const int32_t EndOfString = -1; 28 | static const int32_t EndOfFile = -1; 29 | static const int32_t EndOfRange = -1; 30 | 31 | } // namespace Oryol 32 | 33 | -------------------------------------------------------------------------------- /code/Modules/Core/UnitTests/ClockTest.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // ClockTest.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "UnitTest++/src/UnitTest++.h" 6 | #include "Core/Time/Clock.h" 7 | #include "Core/Log.h" 8 | #include 9 | 10 | using namespace Oryol; 11 | 12 | TEST(ClockTest) { 13 | TimePoint t0 = Clock::Now(); 14 | double a = 0.0, b = 0.0; 15 | for (int i = 0; i < 1000000; i++) { 16 | a += std::sin(b) + std::cos(b); 17 | b += 0.1; 18 | } 19 | CHECK(a > 0.0); 20 | Duration d0 = Clock::Since(t0); 21 | TimePoint t1 = Clock::Now(); 22 | CHECK(t1 > t0); 23 | Log::Info("duration (sec): %f\n", d0.AsSeconds()); 24 | Log::Info("duration (ms): %f\n", d0.AsMilliSeconds()); 25 | Log::Info("duration (us): %f\n", d0.AsMicroSeconds()); 26 | } -------------------------------------------------------------------------------- /code/Modules/Core/UnitTests/LogTest.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // LogTest.cc 3 | // Test Log class. 4 | //------------------------------------------------------------------------------ 5 | #include "Pre.h" 6 | #include "UnitTest++/src/UnitTest++.h" 7 | #include "Core/Log.h" 8 | #include "Core/Logger.h" 9 | 10 | using namespace Oryol; 11 | 12 | class MyLogger : public Logger { 13 | OryolClassDecl(MyLogger); 14 | 15 | /// generic vprint-style method 16 | virtual void VPrint(Log::Level l, const char* msg, va_list args) override { 17 | printf("In MyLogger::VPrint(): "); 18 | vprintf(msg, args); 19 | }; 20 | }; 21 | 22 | void test_vinfo(const char* msg, ...) { 23 | va_list args; 24 | va_start(args, msg); 25 | Log::VInfo(msg, args); 26 | va_end(args); 27 | } 28 | 29 | void test_log() { 30 | Log::Dbg("Dbg log msg %d '%s'\n", 2, "Bla"); 31 | Log::Info("Info log msg %f %d\n", 0.1, 4); 32 | Log::Warn("Warning log msg %d %d\n", 2, 3); 33 | Log::Error("Error log msg %d\n", 10); 34 | } 35 | 36 | TEST(LogTest) { 37 | 38 | test_log(); 39 | Log::SetLogLevel(Log::Level::Dbg); 40 | test_log(); 41 | Log::SetLogLevel(Log::Level::Info); 42 | test_log(); 43 | Log::SetLogLevel(Log::Level::Warn); 44 | test_log(); 45 | Log::SetLogLevel(Log::Level::Error); 46 | test_log(); 47 | Log::SetLogLevel(Log::Level::None); 48 | test_log(); 49 | Log::SetLogLevel(Log::Level::Dbg); 50 | 51 | test_vinfo("Log::VInfo %d %d %d...\n", 1, 2, 3); 52 | 53 | Log::AddLogger(MyLogger::Create()); 54 | test_log(); 55 | } 56 | 57 | 58 | -------------------------------------------------------------------------------- /code/Modules/Core/UnitTests/RunLoopTest.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // ArrayMapTest.cc 3 | // Test ArrayMap class. 4 | //------------------------------------------------------------------------------ 5 | #include "Pre.h" 6 | #include "UnitTest++/src/UnitTest++.h" 7 | #include "Core/RunLoop.h" 8 | 9 | using namespace Oryol; 10 | 11 | TEST(RunLoopTest) { 12 | RunLoop runLoop; 13 | int x = 0; 14 | int y = 0; 15 | auto id0 = runLoop.Add([&x]() { x++; }); 16 | runLoop.Run(); 17 | CHECK(x == 1); 18 | CHECK(y == 0); 19 | auto id1 = runLoop.Add([&y]() { y+=2; }); 20 | runLoop.Run(); 21 | CHECK(x == 2); 22 | CHECK(y == 2); 23 | runLoop.Remove(id0); 24 | runLoop.Run(); 25 | CHECK(x == 2); 26 | CHECK(y == 4); 27 | runLoop.Remove(id1); 28 | runLoop.Run(); 29 | CHECK(x == 2); 30 | CHECK(y == 4); 31 | } 32 | -------------------------------------------------------------------------------- /code/Modules/Core/UnitTests/StackTraceTest.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // StackTraceTest.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "UnitTest++/src/UnitTest++.h" 6 | #include "Core/StackTrace.h" 7 | #include "Core/Log.h" 8 | #include "Core/Assertion.h" 9 | 10 | using namespace Oryol; 11 | 12 | TEST(StackTrace) { 13 | char buf[4096]; 14 | StackTrace::Dump(buf, sizeof(buf)); 15 | Log::Info("%s", buf); 16 | CHECK(buf[0] != 0); // ok that's a lame check, but stack trace format differs between platforms 17 | } 18 | 19 | -------------------------------------------------------------------------------- /code/Modules/Core/UnitTests/TimePointTest.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // TimePointTest.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "UnitTest++/src/UnitTest++.h" 6 | #include "Core/Time/TimePoint.h" 7 | #include "Core/Time/Duration.h" 8 | 9 | using namespace Oryol; 10 | 11 | TEST(TimePointTest) { 12 | TimePoint t0; 13 | CHECK(t0.getRaw() == 0); 14 | TimePoint t1; 15 | CHECK(t0 == t1); 16 | TimePoint t2(1000); 17 | CHECK(t2.getRaw() == 1000); 18 | TimePoint t3(t2); 19 | CHECK(t3 == t2); 20 | CHECK(t3 != t0); 21 | CHECK(t0 < t3); 22 | CHECK(t3 > t0); 23 | CHECK(t0 <= t3); 24 | CHECK(t3 >= t0); 25 | CHECK(t2 <= t3); 26 | CHECK(t3 >= t2); 27 | TimePoint t4(2000); 28 | Duration d0 = t4 - t3; 29 | CHECK(d0.getRaw() == 1000); 30 | CHECK((t3 + d0) == t4); 31 | CHECK((d0 + t3) == t4); 32 | CHECK((t4 - d0) == t3); 33 | } -------------------------------------------------------------------------------- /code/Modules/Core/precompiled.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Core/precompiled.h 5 | 6 | Standard system includes for various platforms. 7 | */ 8 | #include "Core/Config.h" 9 | #if ORYOL_POSIX 10 | #include "Core/private/posix/precompiled.h" 11 | #elif ORYOL_WINDOWS 12 | #include "Core/private/windows/precompiled.h" 13 | #else 14 | #error "Invalid platform!" 15 | #endif 16 | -------------------------------------------------------------------------------- /code/Modules/Core/private/android/androidBridge.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::androidBrigde 5 | @ingroup _priv 6 | @brief Android bridge class between Oryol app and native activity glue 7 | */ 8 | #include "Core/Types.h" 9 | #include "android/sensor.h" 10 | #include 11 | 12 | struct android_app; 13 | 14 | namespace Oryol { 15 | class App; 16 | 17 | namespace _priv { 18 | class androidBridge { 19 | public: 20 | /// constructor 21 | androidBridge(); 22 | /// destructor 23 | ~androidBridge(); 24 | /// return ptr to global androidBridge object 25 | static androidBridge* ptr(); 26 | /// setup the bridge with pointer to App object 27 | void setup(App* app); 28 | /// discard the object 29 | void discard(); 30 | /// return true if the object has been setup 31 | bool isValid() const; 32 | /// set sensor event callback 33 | void setSensorEventCallback(std::function cb); 34 | /// called in App::StartMainLoop 35 | void onStart(); 36 | /// called in a loop by App::StartMainLoop 37 | bool onFrame(); 38 | /// called at end of start main loop 39 | void onStop(); 40 | 41 | static void onAppCmd(struct android_app* app, int32_t cmd); 42 | 43 | static androidBridge* self; 44 | bool valid; 45 | bool hasWindow; 46 | bool hasFocus; 47 | App* app; 48 | ASensorManager* sensorManager; 49 | const ASensor* accelSensor; 50 | const ASensor* gyroSensor; 51 | ASensorEventQueue* sensorEventQueue; 52 | std::function sensorEventCallback; 53 | }; 54 | } // namespace _priv 55 | } // namespace Oryol 56 | -------------------------------------------------------------------------------- /code/Modules/Core/private/posix/precompiled.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @file core/posix/precompiled.h 5 | 6 | Standard includes for POSIX platforms. 7 | NOTE: keep as many headers out of here as possible, at least 8 | on compilers which don't have pre-compiled-headers turned on. 9 | */ 10 | 11 | // this is a workaround when using clang with the GNU std lib, 12 | // this fails without __STRICT_ANSI__ because clang doesn't 13 | // know the __float128 type 14 | #if __clang__ && ORYOL_LINUX && !defined(__STRICT_ANSI__) 15 | #define __STRICT_ANSI__ 16 | #endif 17 | 18 | #include 19 | -------------------------------------------------------------------------------- /code/Modules/Core/private/windows/StackWalker.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Modules/Core/private/windows/StackWalker.cc -------------------------------------------------------------------------------- /code/Modules/Core/private/windows/precompiled.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @file core/windows/precompiled.h 5 | 6 | Standard includes for Windows platform. 7 | */ 8 | #include 9 | -------------------------------------------------------------------------------- /code/Modules/Dbg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_module(Dbg) 2 | fips_vs_warning_level(3) 3 | fips_files(Dbg.cc Dbg.h) 4 | fips_dir(private) 5 | fips_files(debugFont.cc debugTextRenderer.cc debugTextRenderer.h) 6 | oryol_shader(DebugShaders.glsl) 7 | fips_deps(Core Gfx) 8 | fips_end_module() 9 | 10 | -------------------------------------------------------------------------------- /code/Modules/Dbg/Dbg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @defgroup Dbg Dbg 5 | @brief debug visualization and services 6 | 7 | @class Oryol::Dbg 8 | @ingroup Dbg 9 | @brief Dbg module facade 10 | */ 11 | #include "Core/Types.h" 12 | #include "Dbg/DbgTypes.h" 13 | 14 | namespace Oryol { 15 | 16 | class Dbg { 17 | public: 18 | /// setup the Debug module 19 | static void Setup(const DbgSetup& setup=DbgSetup()); 20 | /// discard the Debug module 21 | static void Discard(); 22 | /// return true if Debug module is valid 23 | static bool IsValid(); 24 | 25 | /// set global text scale 26 | static void TextScale(float x, float y); 27 | /// add debug text (7-bit ASCII) 28 | static void Print(const char* text); 29 | /// add debug text (7-bit ASCII only) 30 | static void PrintF(const char* text, ...) __attribute__((format(printf, 1, 2))); 31 | /// add cursor positioning tag 32 | static void CursorPos(uint8_t x, uint8_t y); 33 | /// add color tag 34 | static void TextColor(float r, float g, float b, float a); 35 | /// add a color tag as float[4] array 36 | static void TextColor(const float (&c)[4]); 37 | /// draw the debug text buffer (call one per frame) 38 | static void DrawTextBuffer(); 39 | }; 40 | 41 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/Dbg/DbgTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::DbgSetup 5 | @brief setup parameters for the Dbg module 6 | */ 7 | #include "Core/Types.h" 8 | 9 | namespace Oryol { 10 | 11 | class DbgSetup { 12 | public: 13 | /// number of text columns on whole screen 14 | int NumTextColumns = 120; 15 | /// number of text lines on whole screen 16 | int NumTextRows = 80; 17 | /// initial text scale, x dimension 18 | float TextScaleX = 1.0f; 19 | /// initial text scale, y dimension 20 | float TextScaleY = 1.0f; 21 | }; 22 | 23 | } // namespace Oryol 24 | -------------------------------------------------------------------------------- /code/Modules/Dbg/private/DebugShaders.glsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // Debug module shaders 3 | //------------------------------------------------------------------------------ 4 | 5 | //------------------------------------------------------------------------------ 6 | // text vertex shader 7 | // 8 | @vs vsDbgText 9 | uniform vsParams { 10 | vec2 glyphSize; 11 | }; 12 | 13 | in vec4 position; 14 | in vec4 color0; 15 | out vec2 uv; 16 | out vec4 color; 17 | 18 | void main() { 19 | vec2 screenPos = position.xy * glyphSize; 20 | screenPos.x -= 1.0; 21 | screenPos.y = 1.0 - screenPos.y; 22 | gl_Position = vec4(screenPos, 0.5, 1.0); 23 | uv = position.zw * vec2(8.0 / 1024.0, 1.0); // one glyph is 8 pixels wide 24 | color = color0; 25 | } 26 | @end 27 | 28 | //------------------------------------------------------------------------------ 29 | // text fragment shader 30 | // 31 | @fs fsDbgText 32 | uniform sampler2D tex; 33 | in vec2 uv; 34 | in vec4 color; 35 | out vec4 fragColor; 36 | void main() { 37 | fragColor = texture(tex, uv).xxxx * color; 38 | } 39 | @end 40 | 41 | @program DbgTextShader vsDbgText fsDbgText 42 | -------------------------------------------------------------------------------- /code/Modules/Gfx/MeshLoaderBase.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // MeshLoaderBase.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "MeshLoaderBase.h" 6 | 7 | namespace Oryol { 8 | 9 | //------------------------------------------------------------------------------ 10 | MeshLoaderBase::MeshLoaderBase(const MeshSetup& setup_) : 11 | setup(setup_) { 12 | // empty 13 | } 14 | 15 | //------------------------------------------------------------------------------ 16 | MeshLoaderBase::MeshLoaderBase(const MeshSetup& setup_, LoadedFunc loadedFunc) : 17 | setup(setup_), 18 | onLoaded(loadedFunc) { 19 | // empty 20 | } 21 | 22 | //------------------------------------------------------------------------------ 23 | class Locator 24 | MeshLoaderBase::Locator() const { 25 | return this->setup.Locator; 26 | } 27 | 28 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/Gfx/MeshLoaderBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::MeshLoaderBase 5 | @ingroup Gfx 6 | @brief base class for Gfx mesh loaders 7 | */ 8 | #include "Resource/ResourceLoader.h" 9 | #include "Gfx/GfxTypes.h" 10 | #include 11 | 12 | namespace Oryol { 13 | 14 | class MeshLoaderBase : public ResourceLoader { 15 | OryolClassDecl(MeshLoaderBase); 16 | public: 17 | /// optional callback when loading has succeeded 18 | typedef std::function LoadedFunc; 19 | 20 | /// constructor 21 | MeshLoaderBase(const MeshSetup& setup); 22 | /// constructor with success callback 23 | MeshLoaderBase(const MeshSetup& setup, LoadedFunc onLoaded); 24 | /// return resource locator 25 | virtual class Locator Locator() const override; 26 | 27 | protected: 28 | MeshSetup setup; 29 | std::function onLoaded; 30 | }; 31 | 32 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/Gfx/README.md: -------------------------------------------------------------------------------- 1 | ## Gfx Module 2 | 3 | ### Overview 4 | 5 | The Oryol Gfx module is a thin portability wrapper for 3D-APIs and 6 | shader languages. The feature set is defined roughly by GLES3 (WebGL2) 7 | with a fallback to GLES2 (WebGL). The programming model is 8 | similar to Metal, but with even more simplified resource 9 | management. 10 | 11 | ### Platform/API support matrix 12 | 13 | Platform |GL3.3|GLES3|Metal|D3D11 14 | -----------|-----|-----|-----|----- 15 | OSX 10.11+ |YES |--- |YES |--- 16 | iOS 9.x+ |--- |YES |YES |--- 17 | Window7+ |YES |--- |--- |YES 18 | Linux |YES |--- |--- |--- 19 | Android |--- |YES |--- |--- 20 | HTML5 |--- |YES |--- |--- 21 | RaspberryPi|--- |YES |--- |--- 22 | 23 | ### Sample Code 24 | 25 | The most important and detailed documentation of the Gfx module 26 | is the Samples source code. 27 | 28 | Looking at those four samples should give you most of the 29 | information necessary to work with the Gfx module: 30 | 31 | * [Clear Sample](../../Samples/Clear/Clear.cc) 32 | * [Triangle Sample](../../Samples/Triangle/Triangle.cc) 33 | * [Shapes Sample](../../Samples/Shapes/Shapes.cc) 34 | * [Texture Loading](../../Samples/DDSCubeMap/DDSCubeMap.cc) 35 | * [Offscreen Render Targets](../../Samples/SimpleRenderTarget/SimpleRenderTarget.cc) 36 | 37 | ### Topics 38 | 39 | * [Rendering Backends](doc/RenderBackends.md) 40 | * [A Simple Render Loop](doc/RenderLoop.md) 41 | * [Resource Objects](doc/Resources.md) 42 | * [Meshes](doc/Meshes.md) 43 | * [Textures](doc/Textures.md) 44 | * [Render Passes](doc/RenderPasses.md) 45 | * [Shaders](doc/Shaders.md) 46 | * [Pipeline Objects](doc/Pipelines.md) 47 | 48 | -------------------------------------------------------------------------------- /code/Modules/Gfx/TextureLoaderBase.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // TextureLoaderBase.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "TextureLoaderBase.h" 6 | 7 | namespace Oryol { 8 | 9 | //------------------------------------------------------------------------------ 10 | TextureLoaderBase::TextureLoaderBase(const TextureSetup& setup_) : 11 | setup(setup_) { 12 | // empty 13 | } 14 | 15 | //------------------------------------------------------------------------------ 16 | TextureLoaderBase::TextureLoaderBase(const TextureSetup& setup_, LoadedFunc loadedFunc) : 17 | setup(setup_), 18 | onLoaded(loadedFunc) 19 | { 20 | // empty 21 | } 22 | 23 | //------------------------------------------------------------------------------ 24 | class Locator 25 | TextureLoaderBase::Locator() const { 26 | return this->setup.Locator; 27 | } 28 | 29 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/Gfx/TextureLoaderBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::TextureLoaderBase 5 | @ingroup Gfx 6 | @brief base class for Gfx texture loaders 7 | */ 8 | #include "Resource/ResourceLoader.h" 9 | #include "Gfx/GfxTypes.h" 10 | #include 11 | 12 | namespace Oryol { 13 | 14 | class TextureLoaderBase : public ResourceLoader { 15 | OryolClassDecl(TextureLoaderBase); 16 | public: 17 | /// optional callback when loading has succeeded 18 | typedef std::function LoadedFunc; 19 | 20 | /// constructor 21 | TextureLoaderBase(const TextureSetup& setup); 22 | /// constructor 23 | TextureLoaderBase(const TextureSetup& setup, LoadedFunc onLoaded); 24 | /// return resource locator 25 | virtual class Locator Locator() const override; 26 | 27 | protected: 28 | TextureSetup setup; 29 | std::function onLoaded; 30 | }; 31 | 32 | } // namespace Oryol 33 | 34 | -------------------------------------------------------------------------------- /code/Modules/Gfx/UnitTests/RenderSetupTest.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // RenderSetupTest.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "UnitTest++/src/UnitTest++.h" 6 | #include "Core/Core.h" 7 | #include "Gfx/Gfx.h" 8 | 9 | using namespace Oryol; 10 | 11 | //------------------------------------------------------------------------------ 12 | TEST(RenderSetupTest) { 13 | 14 | #if !ORYOL_UNITTESTS_HEADLESS 15 | Core::Setup(); 16 | Gfx::Setup(GfxSetup::Window(400, 300, "Oryol Test")); 17 | 18 | CHECK(Gfx::GfxSetup().Width == 400); 19 | CHECK(Gfx::GfxSetup().Height == 300); 20 | CHECK(Gfx::GfxSetup().ColorFormat == PixelFormat::RGBA8); 21 | CHECK(Gfx::GfxSetup().DepthFormat == PixelFormat::DEPTHSTENCIL); 22 | CHECK(Gfx::GfxSetup().Title == "Oryol Test"); 23 | CHECK(Gfx::GfxSetup().Windowed == true); 24 | 25 | CHECK(Gfx::DisplayAttrs().WindowWidth >= 400); 26 | CHECK(Gfx::DisplayAttrs().WindowHeight >= 300); 27 | CHECK(Gfx::DisplayAttrs().WindowPosX >= 0); 28 | CHECK(Gfx::DisplayAttrs().WindowPosY >= 0); 29 | CHECK(Gfx::DisplayAttrs().FramebufferWidth >= 400); 30 | CHECK(Gfx::DisplayAttrs().FramebufferHeight >= 300); 31 | CHECK(Gfx::DisplayAttrs().ColorPixelFormat == PixelFormat::RGBA8); 32 | CHECK(Gfx::DisplayAttrs().DepthPixelFormat == PixelFormat::DEPTHSTENCIL); 33 | CHECK(Gfx::DisplayAttrs().SwapInterval == 1); 34 | CHECK(Gfx::DisplayAttrs().WindowTitle == "Oryol Test"); 35 | CHECK(Gfx::DisplayAttrs().Windowed == true); 36 | 37 | Gfx::Discard(); 38 | Core::Discard(); 39 | #endif 40 | } 41 | 42 | -------------------------------------------------------------------------------- /code/Modules/Gfx/UnitTests/ShapeBuilderTest.h: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /code/Modules/Gfx/UnitTests/TestShaderLibrary.glsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // test.shd 3 | //------------------------------------------------------------------------------ 4 | 5 | /* 6 | Bla Bla Bla 7 | */ 8 | 9 | @block TransformUtil 10 | vec4 myTransform(mat4 mvp, vec4 pos) 11 | { 12 | return mvp * pos; 13 | } 14 | @end 15 | 16 | @block FSUtil 17 | vec4 myColor(vec4 nrm, vec4 texColor) 18 | { 19 | return ((nrm * 0.5) + 0.5) * 0.75 + texColor * texColor * texColor; 20 | } 21 | @end 22 | 23 | @vs MyVertexShader 24 | @include TransformUtil 25 | uniform vsParams { 26 | mat4 mvp; 27 | }; 28 | in vec4 position; 29 | in vec4 normal; 30 | in vec2 texcoord0; 31 | out vec4 nrm; 32 | out vec2 uv; 33 | void main() { 34 | gl_Position = myTransform(mvp, position); 35 | nrm = normal; 36 | uv = texcoord0; 37 | } 38 | @end 39 | 40 | @fs MyFragmentShader 41 | @include FSUtil 42 | uniform sampler2D tex; 43 | in vec4 nrm; 44 | in vec2 uv; 45 | out vec4 fragColor; 46 | void main() { 47 | vec4 texColor = texture(tex, uv * vec2(5.0, 3.0)); 48 | fragColor = myColor(nrm, texColor); 49 | } 50 | @end 51 | 52 | @program MyShader MyVertexShader MyFragmentShader 53 | 54 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/d3d11/d3d11_decl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @file d3d11_decl.h 5 | @brief D3D11 forward declarations 6 | 7 | Try to use this as much as possible in headers instead of including 8 | the full d3d11 headers. 9 | */ 10 | #include "Gfx/private/win/win_decl.h" 11 | 12 | struct IDXGISwapChain; 13 | struct IDXGISwapChain1; 14 | struct DXGI_SWAP_CHAIN_DESC; 15 | struct DXGI_SWAP_CHAIN_DESC1; 16 | 17 | struct ID3D11Device; 18 | struct ID3D11DeviceContext; 19 | struct ID3D11Resource; 20 | struct ID3D11Texture2D; 21 | struct ID3D11Texture3D; 22 | struct ID3D11ShaderResourceView; 23 | struct ID3D11RenderTargetView; 24 | struct ID3D11DepthStencilView; 25 | struct ID3D11Buffer; 26 | struct ID3D11VertexShader; 27 | struct ID3D11PixelShader; 28 | struct ID3D11InputLayout; 29 | struct ID3D11RasterizerState; 30 | struct ID3D11DepthStencilState; 31 | struct ID3D11BlendState; 32 | struct ID3D11SamplerState; 33 | typedef struct D3D11_TEXTURE2D_DESC D3D11_TEXTURE2D_DESC; 34 | 35 | enum D3D11_USAGE; 36 | typedef enum DXGI_FORMAT DXGI_FORMAT; 37 | typedef enum D3D11_CULL_MODE D3D11_CULL_MODE; 38 | typedef enum D3D11_COMPARISON_FUNC D3D11_COMPARISON_FUNC; 39 | typedef enum D3D11_STENCIL_OP D3D11_STENCIL_OP; 40 | typedef enum D3D11_BLEND D3D11_BLEND; 41 | typedef enum D3D11_BLEND_OP D3D11_BLEND_OP; 42 | typedef enum D3D11_INPUT_CLASSIFICATION D3D11_INPUT_CLASSIFICATION; 43 | typedef enum D3D11_FILTER D3D11_FILTER; 44 | typedef enum D3D11_TEXTURE_ADDRESS_MODE D3D11_TEXTURE_ADDRESS_MODE; 45 | typedef enum D3D_PRIMITIVE_TOPOLOGY D3D_PRIMITIVE_TOPOLOGY; 46 | typedef D3D_PRIMITIVE_TOPOLOGY D3D11_PRIMITIVE_TOPOLOGY; 47 | typedef struct D3D11_SUBRESOURCE_DATA D3D11_SUBRESOURCE_DATA; 48 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/d3d11/d3d11_impl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @file d3d11_impl.h 5 | @brief includes the D3D11 headers 6 | 7 | Include this file in sources, and d3d11_decl.h in headers. 8 | */ 9 | #define NOMINMAX 10 | #include -------------------------------------------------------------------------------- /code/Modules/Gfx/private/displayMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::displayMgr 5 | @ingroup _priv 6 | @brief create and manage the app window and GL context 7 | 8 | The display manager object manages application window and 9 | GL context creation, and usually processes host window system 10 | events (such as input events) and forwards them to Oryol. 11 | */ 12 | #if ORYOL_D3D11 13 | #include "Gfx/private/d3d11/d3d11DisplayMgr.h" 14 | namespace Oryol { 15 | namespace _priv { 16 | class displayMgr : public d3d11DisplayMgr { }; 17 | } } 18 | #elif ORYOL_METAL 19 | #include "Gfx/private/mtl/mtlDisplayMgr.h" 20 | namespace Oryol { 21 | namespace _priv { 22 | class displayMgr : public mtlDisplayMgr { }; 23 | } } 24 | #elif (ORYOL_ANDROID || ORYOL_RASPBERRYPI) 25 | #include "Gfx/private/egl/eglDisplayMgr.h" 26 | namespace Oryol { 27 | namespace _priv { 28 | class displayMgr : public eglDisplayMgr { }; 29 | } } 30 | #elif (ORYOL_WINDOWS || ORYOL_MACOS || ORYOL_LINUX) 31 | #include "Gfx/private/glfw/glfwDisplayMgr.h" 32 | namespace Oryol { 33 | namespace _priv { 34 | class displayMgr : public glfwDisplayMgr { }; 35 | } } 36 | #elif ORYOL_EMSCRIPTEN 37 | #include "Gfx/private/emsc/emscDisplayMgr.h" 38 | namespace Oryol { 39 | namespace _priv { 40 | class displayMgr : public emscDisplayMgr { }; 41 | } } 42 | #elif ORYOL_IOS 43 | #include "Gfx/private/ios/iosDisplayMgr.h" 44 | namespace Oryol { 45 | namespace _priv { 46 | class displayMgr : public iosDisplayMgr { }; 47 | } } 48 | #else 49 | #include "Gfx/private/displayMgrBase.h" 50 | namespace Oryol { 51 | namespace _priv { 52 | class displayMgr : public displayMgrBase { }; 53 | } } 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/egl/eglDisplayMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::eglDisplayMgr 5 | @ingroup _priv 6 | @brief display manager class for EGL platforms 7 | */ 8 | #include "Gfx/private/displayMgrBase.h" 9 | #include "Gfx/private/gl/gl_decl.h" 10 | #include 11 | 12 | namespace Oryol { 13 | namespace _priv { 14 | 15 | class eglDisplayMgr : public displayMgrBase { 16 | public: 17 | /// constructor 18 | eglDisplayMgr(); 19 | /// destructor 20 | ~eglDisplayMgr(); 21 | 22 | /// setup the display system, must happen before rendering 23 | void SetupDisplay(const GfxSetup& GfxSetup, const gfxPointers& ptrs); 24 | /// discard the display, rendering cannot happen after 25 | void DiscardDisplay(); 26 | /// present the current rendered frame 27 | void Present(); 28 | 29 | /// bind the default frame buffer 30 | void glBindDefaultFramebuffer(); 31 | 32 | EGLDisplay eglDisplay; 33 | EGLConfig eglConfig; 34 | EGLSurface eglSurface; 35 | EGLContext eglContext; 36 | }; 37 | 38 | } // namespace _priv 39 | } // namespace Oryol 40 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/emsc/emscDisplayMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::emscDisplayMgr 5 | @ingroup _priv 6 | @brief display manager class for emscripten platform 7 | */ 8 | #include "Gfx/private/displayMgrBase.h" 9 | #include 10 | 11 | namespace Oryol { 12 | 13 | // emscripten-specific soft-fullscreen control functions 14 | extern "C" { 15 | extern void enter_soft_fullscreen(); 16 | extern void leave_soft_fullscreen(); 17 | extern bool is_soft_fullscreen_active(); 18 | } 19 | 20 | namespace _priv { 21 | 22 | class emscDisplayMgr : public displayMgrBase { 23 | public: 24 | /// constructor 25 | emscDisplayMgr(); 26 | /// destructor 27 | ~emscDisplayMgr(); 28 | 29 | /// setup the display system, must happen before rendering 30 | void SetupDisplay(const GfxSetup& gfxSetup, const gfxPointers& ptrs); 31 | /// discard the display, rendering cannot happen after 32 | void DiscardDisplay(); 33 | 34 | /// bind the default frame buffer 35 | void glBindDefaultFramebuffer(); 36 | /// emscripten callback when canvas size has changed (for soft-fullscreen) 37 | static EM_BOOL emscCanvasSizeChanged(int eventType, const void* reserved, void* userData); 38 | /// emscripten callback when window size has changed (for HTMLUseCanvasSize) 39 | static EM_BOOL emscWindowSizeChanged(int eventType, const EmscriptenUiEvent* uiEvent, void* userData); 40 | 41 | static emscDisplayMgr* self; 42 | int storedCanvasWidth; 43 | int storedCanvasHeight; 44 | EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx; 45 | }; 46 | 47 | } // namespace _priv 48 | } // namespace Oryol 49 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/flextgl/flextgl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # helper bash script to generate gl files 3 | # 4 | python3 ../../../../../flextgl/flextGLgen.py -T glfw3 -D . flextgl_profile.txt 5 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/flextgl/flextgl_profile.txt: -------------------------------------------------------------------------------- 1 | # 2 | # oryol flextGL profile for desktop platforms 3 | # 4 | version 3.3 core 5 | extension ARB_debug_output optional 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/gfxFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | #if ORYOL_OPENGL 4 | #include "Gfx/private/gl/glFactory.h" 5 | #elif ORYOL_D3D11 6 | #include "Gfx/private/d3d11/d3d11Factory.h" 7 | #elif ORYOL_METAL 8 | #include "Gfx/private/mtl/mtlFactory.h" 9 | #else 10 | #error "Platform not yet supported!" 11 | #endif 12 | 13 | namespace Oryol { 14 | namespace _priv { 15 | #if ORYOL_OPENGL 16 | class gfxFactory : public glFactory { }; 17 | #elif ORYOL_D3D11 18 | class gfxFactory : public d3d11Factory { }; 19 | #elif ORYOL_METAL 20 | class gfxFactory : public mtlFactory { }; 21 | #endif 22 | 23 | } // namespace _priv 24 | } // namespace Oryol 25 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/gfxFactoryBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::gfxFactoryBase 5 | @ingroup _priv 6 | @brief base class for Gfx resource factories 7 | */ 8 | #include "Resource/ResourceState.h" 9 | #include "Gfx/private/gfxPointers.h" 10 | #include "Gfx/GfxTypes.h" 11 | 12 | namespace Oryol { 13 | namespace _priv { 14 | 15 | class pipeline; 16 | class renderPass; 17 | 18 | class gfxFactoryBase { 19 | public: 20 | /// destructor 21 | ~gfxFactoryBase(); 22 | 23 | /// setup the factory 24 | void setup(const gfxPointers& ptrs); 25 | /// discard the factory 26 | void discard(); 27 | /// optional garbage-collect released resources (not implemented on all platforms) 28 | void garbageCollect(); 29 | /// initialize pipeline object 30 | ResourceState::Code initPipeline(pipeline& pip); 31 | /// destroy pipeline object 32 | void destroyPipeline(pipeline& pip); 33 | /// initialize renderPass object 34 | ResourceState::Code initRenderPass(renderPass& rp); 35 | /// destroy renderPass object 36 | void destroyRenderPass(renderPass& rp); 37 | 38 | gfxPointers pointers; 39 | bool isValid = false; 40 | }; 41 | 42 | } // namespace _priv 43 | } // namespace Oryol 44 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/gfxPointers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::gfxPointers 5 | @ingroup _privv 6 | @brief pointers to the internal Gfx module objects 7 | 8 | This is used to internally communicate pointers to Gfx 'singletons', instead 9 | of the typical singleton macros (which would expose the pointers to the outside world). 10 | */ 11 | #include "Core/Types.h" 12 | 13 | namespace Oryol { 14 | 15 | namespace _priv { 16 | 17 | class renderer; 18 | class displayMgr; 19 | class gfxResourceContainer; 20 | class meshPool; 21 | class shaderPool; 22 | class texturePool; 23 | class pipelinePool; 24 | class renderPassPool; 25 | 26 | struct gfxPointers { 27 | class renderer* renderer = nullptr; 28 | class displayMgr* displayMgr = nullptr; 29 | class gfxResourceContainer* resContainer = nullptr; 30 | class meshPool* meshPool = nullptr; 31 | class shaderPool* shaderPool = nullptr; 32 | class texturePool* texturePool = nullptr; 33 | class pipelinePool* pipelinePool = nullptr; 34 | class renderPassPool* renderPassPool = nullptr; 35 | }; 36 | 37 | } // namespace _priv 38 | } // namespace Oryol 39 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/gl/gl_decl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | Minimal GL declaration file. Include this in headers for fast compilation 5 | and move actual GL code out of headers. 6 | */ 7 | 8 | #ifndef GL_VERSION_1_1 9 | typedef unsigned int GLenum; 10 | typedef unsigned int GLbitfield; 11 | typedef unsigned int GLuint; 12 | typedef int GLint; 13 | typedef int GLsizei; 14 | typedef unsigned char GLboolean; 15 | typedef signed char GLbyte; 16 | typedef short GLshort; 17 | typedef unsigned char GLubyte; 18 | typedef unsigned short GLushort; 19 | typedef unsigned long GLulong; 20 | typedef float GLfloat; 21 | typedef float GLclampf; 22 | typedef double GLdouble; 23 | typedef double GLclampd; 24 | typedef void GLvoid; 25 | #ifndef GL_INVALID_INDEX 26 | #define GL_INVALID_INDEX 0xFFFFFFFFu 27 | #endif 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/ios/iosDisplayMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::iosDisplayMgr 5 | @ingroup _priv 6 | @brief display manager for IOS 7 | */ 8 | #include "Gfx/private/displayMgrBase.h" 9 | #include "Gfx/private/gl/gl_decl.h" 10 | #include "Core/private/ios/iosBridge.h" 11 | 12 | namespace Oryol { 13 | namespace _priv { 14 | 15 | class iosDisplayMgr : public displayMgrBase { 16 | public: 17 | /// constructor 18 | iosDisplayMgr(); 19 | /// destructor 20 | ~iosDisplayMgr(); 21 | 22 | /// setup the display system, must happen before rendering 23 | void SetupDisplay(const GfxSetup& gfxSetup, const gfxPointers& ptrs); 24 | /// discard the display, rendering cannot happen after 25 | void DiscardDisplay(); 26 | /// present the current rendered frame 27 | void Present(); 28 | 29 | /// bind the default frame buffer 30 | void glBindDefaultFramebuffer(); 31 | 32 | static iosDisplayMgr* self; 33 | GLuint glDefaultFramebuffer; 34 | GLint glFramebufferWidth; 35 | GLint glFramebufferHeight; 36 | }; 37 | 38 | } // namespace _priv 39 | } // namespace Oryol 40 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/mtl/mtlDisplayMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::mtlDisplayMgr 5 | @ingroup _priv 6 | @brief Metal implementation of displayMgr 7 | */ 8 | #include "Gfx/private/displayMgrBase.h" 9 | 10 | namespace Oryol { 11 | namespace _priv { 12 | 13 | class mtlDisplayMgr : public displayMgrBase { 14 | public: 15 | /// constructor 16 | mtlDisplayMgr(); 17 | /// destructor 18 | ~mtlDisplayMgr(); 19 | 20 | /// setup the display system, must happen before rendering 21 | void SetupDisplay(const GfxSetup& setup, const gfxPointers& ptrs); 22 | /// discard the display, rendering cannot happen after 23 | void DiscardDisplay(); 24 | /// check whether the window system requests to quit the application 25 | bool QuitRequested() const; 26 | 27 | /// configure the app window 28 | void configureWindow(const GfxSetup& setup); 29 | /// callback for window-resize 30 | #if ORYOL_MACOS 31 | static void onFramebufferSize(int w, int h); 32 | #endif 33 | /// ptr to self for onFramebufferSize 34 | static mtlDisplayMgr* self; 35 | }; 36 | 37 | } // namespace _priv 38 | } // namespace Oryol 39 | 40 | 41 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/mtl/mtl_decl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @file mtl_decl.h 5 | @brief Metal Objective-C++ declarations 6 | */ 7 | #if ORYOL_IOS 8 | #include "Core/private/ios/iosBridge.h" 9 | namespace Oryol { 10 | namespace _priv { 11 | typedef iosBridge osBridge; 12 | } } 13 | #else 14 | #include "Core/private/osx/osxBridge.h" 15 | namespace Oryol { 16 | namespace _priv { 17 | typedef osxBridge osBridge; 18 | } } 19 | #endif 20 | #if !defined(__OBJC__) 21 | typedef void* CAMetalLayer; 22 | typedef void* CAMetalDrawable; 23 | typedef void* MTLDevice; 24 | typedef void* MTLCommandQueue; 25 | typedef void* MTLRenderPassDescriptor; 26 | typedef void* MTLRenderCommandEncoder; 27 | typedef void* MTLTexture; 28 | typedef void* MTLBuffer; 29 | typedef void* MTLLibrary; 30 | typedef void* MTLFunction; 31 | typedef void* MTLRenderPipelineState; 32 | typedef void* MTLTexture; 33 | typedef void* MTLSamplerState; 34 | #endif 35 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/mtl/mtl_impl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @file mtl_impl.h 5 | @brief actually include Metal headers, only include in Obj-C code! 6 | */ 7 | #if !defined(__OBJC__) 8 | #error "Must be included from Objective-C++" 9 | #endif 10 | #include "Gfx/private/mtl/mtl_decl.h" 11 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/renderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::renderer 5 | @ingroup _priv 6 | @brief main rendering API wrapper 7 | */ 8 | #if ORYOL_OPENGL 9 | #include "Gfx/private/gl/glRenderer.h" 10 | namespace Oryol { 11 | namespace _priv { 12 | class renderer : public glRenderer { }; 13 | } } 14 | #elif ORYOL_D3D11 15 | #include "Gfx/private/d3d11/d3d11Renderer.h" 16 | namespace Oryol { 17 | namespace _priv { 18 | class renderer : public d3d11Renderer { }; 19 | } } 20 | #elif ORYOL_METAL 21 | #include "Gfx/private/mtl/mtlRenderer.h" 22 | namespace Oryol { 23 | namespace _priv { 24 | class renderer : public mtlRenderer { }; 25 | } } 26 | #else 27 | #error "Target platform not yet supported!" 28 | #endif 29 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/resourceBase.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // resourceBase.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "resourceBase.h" 6 | 7 | namespace Oryol { 8 | namespace _priv { 9 | 10 | //------------------------------------------------------------------------------ 11 | void 12 | shaderBase::Clear() { 13 | this->Setup = ShaderSetup(); 14 | } 15 | 16 | //------------------------------------------------------------------------------ 17 | void 18 | textureBase::Clear() { 19 | this->Setup = TextureSetup(); 20 | this->textureAttrs = TextureAttrs(); 21 | } 22 | 23 | //------------------------------------------------------------------------------ 24 | void 25 | meshBase::Clear() { 26 | this->Setup = MeshSetup(); 27 | this->vertexBufferAttrs = VertexBufferAttrs(); 28 | this->indexBufferAttrs = IndexBufferAttrs(); 29 | this->primGroups.Fill(PrimitiveGroup()); 30 | this->numPrimGroups = 0; 31 | } 32 | 33 | //------------------------------------------------------------------------------ 34 | void 35 | pipelineBase::Clear() { 36 | this->Setup = PipelineSetup(); 37 | this->shd = nullptr; 38 | } 39 | 40 | //------------------------------------------------------------------------------ 41 | void 42 | renderPassBase::Clear() { 43 | this->Setup = PassSetup(); 44 | this->colorTextures.Fill(nullptr); 45 | this->depthStencilTexture = nullptr; 46 | } 47 | 48 | } // namespace _priv 49 | } // namespace Oryol 50 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/resourcePools.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @file Gfx/Resource/resourcePools.h 5 | @ingroup _priv 6 | @brief Gfx module resource pool classes 7 | */ 8 | #include "Resource/ResourcePool.h" 9 | #include "Gfx/private/resource.h" 10 | 11 | namespace Oryol { 12 | namespace _priv { 13 | 14 | class pipelinePool : public ResourcePool { }; 15 | class meshPool : public ResourcePool { }; 16 | class shaderPool : public ResourcePool { }; 17 | class texturePool : public ResourcePool { }; 18 | class renderPassPool : public ResourcePool { }; 19 | 20 | } // namespace _priv 21 | } // namespace Oryol 22 | -------------------------------------------------------------------------------- /code/Modules/Gfx/private/win/win_decl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @file win_decl.h 5 | @brief Windows forward declarations 6 | */ 7 | #if defined(_WIN64) 8 | typedef __int64 INT_PTR, *PINT_PTR; 9 | typedef unsigned __int64 UINT_PTR, *PUINT_PTR; 10 | typedef __int64 LONG_PTR, *PLONG_PTR; 11 | typedef unsigned __int64 ULONG_PTR, *PULONG_PTR; 12 | #define __int3264 __int64 13 | #else 14 | typedef int INT_PTR, *PINT_PTR; 15 | typedef unsigned int UINT_PTR, *PUINT_PTR; 16 | typedef long LONG_PTR, *PLONG_PTR; 17 | typedef unsigned long ULONG_PTR, *PULONG_PTR; 18 | #define __int3264 __int32 19 | #endif 20 | 21 | typedef void* HANDLE; 22 | typedef unsigned long DWORD; 23 | struct HWND__; 24 | typedef HWND__* HWND; 25 | typedef UINT_PTR WPARAM; 26 | typedef LONG_PTR LPARAM; 27 | typedef LONG_PTR LRESULT; 28 | typedef ULONG_PTR SIZE_T, *PSIZE_T; -------------------------------------------------------------------------------- /code/Modules/HttpFS/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # oryol HttpFS module 3 | #------------------------------------------------------------------------------- 4 | fips_begin_module(HttpFS) 5 | fips_vs_warning_level(3) 6 | fips_files( 7 | HTTPFileSystem.cc HTTPFileSystem.h 8 | ) 9 | fips_dir(private) 10 | fips_files( 11 | urlLoader.h 12 | baseURLLoader.cc baseURLLoader.h 13 | ) 14 | if (ORYOL_USE_LIBCURL) 15 | fips_dir(private/curl) 16 | fips_files(curlURLLoader.cc curlURLLoader.h) 17 | elseif (FIPS_OSX) 18 | fips_dir(private/osx) 19 | fips_files(osxURLLoader.mm osxURLLoader.h) 20 | elseif (FIPS_WINDOWS) 21 | fips_dir(private/win) 22 | fips_files(winURLLoader.cc winURLLoader.h) 23 | elseif (FIPS_EMSCRIPTEN) 24 | fips_dir(private/emsc) 25 | fips_files(emscURLLoader.cc emscURLLoader.h) 26 | endif() 27 | 28 | fips_deps(IO Core) 29 | if (FIPS_WINDOWS) 30 | fips_libs(WinHttp) 31 | endif() 32 | if (FIPS_ANDROID OR FIPS_LINUX OR FIPS_MACOS) 33 | fips_libs(curl zlib) 34 | endif() 35 | if (FIPS_LINUX) 36 | fips_libs(rt) 37 | endif() 38 | fips_end_module() 39 | 40 | oryol_begin_unittest(HTTP) 41 | fips_vs_warning_level(3) 42 | fips_dir(UnitTests) 43 | fips_files(HTTPFileSystemTest.cc) 44 | fips_deps(IO HttpFS Core) 45 | fips_frameworks_osx(Foundation) 46 | oryol_end_unittest() 47 | -------------------------------------------------------------------------------- /code/Modules/HttpFS/HTTPFileSystem.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // HTTPFileSystem.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "HTTPFileSystem.h" 6 | 7 | namespace Oryol { 8 | 9 | //------------------------------------------------------------------------------ 10 | void 11 | HTTPFileSystem::onMsg(const Ptr& ioReq) { 12 | Ptr ioReadRequest = ioReq->DynamicCast(); 13 | if (ioReadRequest.isValid()) { 14 | this->loader.doRequest(ioReadRequest); 15 | } 16 | } 17 | 18 | } // namespace Oryol 19 | -------------------------------------------------------------------------------- /code/Modules/HttpFS/HTTPFileSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @defgroup HTTP HTTP 5 | @brief HTTP services, and a HTTP based filesystem 6 | 7 | @class Oryol::HTTPFileSystem 8 | @ingroup HTTP 9 | @brief implements a simple HTTP-based filesystem 10 | @see HTTPClient, FileSystem 11 | 12 | @todo: HTTPFileSystem description 13 | */ 14 | #include "IO/FileSystemBase.h" 15 | #include "Core/Creator.h" 16 | #include "HttpFS/private/urlLoader.h" 17 | 18 | namespace Oryol { 19 | 20 | class HTTPFileSystem : public FileSystemBase { 21 | OryolClassDecl(HTTPFileSystem); 22 | OryolClassCreator(HTTPFileSystem); 23 | public: 24 | /// called when IO message should be handled 25 | virtual void onMsg(const Ptr& ioReq) override; 26 | 27 | private: 28 | _priv::urlLoader loader; 29 | }; 30 | 31 | } // namespace Oryol 32 | 33 | -------------------------------------------------------------------------------- /code/Modules/HttpFS/README.md: -------------------------------------------------------------------------------- 1 | ## HttpFS Module 2 | 3 | The HttpFS module implements a filesystem plugin to load data from 4 | web servers. 5 | 6 | The HTTP filesystem needs to be registered with the IO module before 7 | it can be used, the best way to do this is when the IO module is 8 | setup. It also makes sense to define one or several path assigns. 9 | 10 | ```cpp 11 | #include "IO/IO.h" 12 | #include "HttpFS/HTTPFileSystem.h" 13 | ... 14 | 15 | AppState::Code 16 | MyApp::OnInit() { 17 | IOSetup ioSetup; 18 | ioSetup.FileSystems.Add("http", HttpFileSystem::Creator()); 19 | ioSetup.Assigns.Add("data", "http://floooh.github.com/oryol/data"); 20 | IO::Setup(ioSetup); 21 | ... 22 | } 23 | ``` 24 | 25 | A few things to note: 26 | 27 | - IOSetup.FileSystems takes a filesystem **Creator** object, not a filesystem object, this is because (depending on platform) multiple filesystem objects may be created (one per IO thread) 28 | - the URL scheme "http" is usually used with the HTTPFileSystem, but you can choose any scheme you want 29 | - on the HTML5 platform, the host address part of an URL is discarded, data will always be loaded from the same location where the main page is hosted, this is because of cross-origin restrictions 30 | 31 | After the HTTPFileSystem has been setup, data can be loaded as usual, refer to the [IO module documentation](../IO/README.md) for more details. -------------------------------------------------------------------------------- /code/Modules/HttpFS/UnitTests/HTTPFileSystemTest.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // HTTPFileSystemTest.cc 3 | // Test HTTP file system functionality. 4 | //------------------------------------------------------------------------------ 5 | #include "Pre.h" 6 | #include "UnitTest++/src/UnitTest++.h" 7 | #include "Core/Core.h" 8 | #include "Core/RunLoop.h" 9 | #include "HttpFS/HTTPFileSystem.h" 10 | #include "IO/IO.h" 11 | 12 | using namespace Oryol; 13 | 14 | #if !ORYOL_EMSCRIPTEN && !ORYOL_UNITTESTS_HEADLESS 15 | TEST(HTTPFileSystemTest) { 16 | Core::Setup(); 17 | 18 | // setup an IO facade, and associate http: with the HTTPFileSystem 19 | IOSetup ioSetup; 20 | ioSetup.FileSystems.Add("http", HTTPFileSystem::Creator()); 21 | IO::Setup(ioSetup); 22 | 23 | // asynchronously load the index.html file 24 | Ptr req = IO::LoadFile("http://www.flohofwoe.net/index.html"); 25 | 26 | // trigger the runloop until the request has been handled 27 | while (!req->Handled) { 28 | Core::PreRunLoop()->Run(); 29 | } 30 | 31 | // check what we got 32 | CHECK(req->Status == IOStatus::OK); 33 | CHECK(!req->Data.Empty()); 34 | CHECK(req->Data.Size() > 0); 35 | if (req->Data.Size() > 0) { 36 | String content((const char*)req->Data.Data(), 0, req->Data.Size()); 37 | Log::Info("%s\n", content.AsCStr()); 38 | } 39 | req = 0; 40 | 41 | IO::Discard(); 42 | Core::Discard(); 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /code/Modules/HttpFS/private/baseURLLoader.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // baseURLLoader.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "baseURLLoader.h" 6 | 7 | namespace Oryol { 8 | namespace _priv { 9 | 10 | //------------------------------------------------------------------------------ 11 | bool 12 | baseURLLoader::doRequest(const Ptr& ioReq) { 13 | // process one IO request, implement the actual downloading 14 | // in a subclass, we only handle the cancelled flag here 15 | if (ioReq->Cancelled) { 16 | ioReq->Status = IOStatus::Cancelled; 17 | ioReq->Handled = true; 18 | return false; 19 | } 20 | else { 21 | return true; 22 | } 23 | } 24 | 25 | } // namespace _priv 26 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/HttpFS/private/baseURLLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::baseURLLoader 5 | @ingroup _priv 6 | @brief base class for platform specific URL loaders 7 | @see urlLoader, HTTPClient 8 | */ 9 | #include "IO/private/ioRequests.h" 10 | 11 | namespace Oryol { 12 | namespace _priv { 13 | 14 | class baseURLLoader { 15 | public: 16 | /// process one HTTPRequest 17 | bool doRequest(const Ptr& ioRequest); 18 | }; 19 | } // namespace _priv 20 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/HttpFS/private/curl/curlURLLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::curlURLLoader 5 | @ingroup _priv 6 | @brief urlLoader implementation on top of curl 7 | @see urlLoader 8 | */ 9 | #include "HttpFS/private/baseURLLoader.h" 10 | 11 | namespace Oryol { 12 | namespace _priv { 13 | 14 | class curlURLLoader : public baseURLLoader { 15 | public: 16 | /// constructor 17 | curlURLLoader(); 18 | /// destructor 19 | ~curlURLLoader(); 20 | /// process one request 21 | bool doRequest(const Ptr& req); 22 | 23 | /// setup curl session 24 | void setupCurlSession(); 25 | /// discard the curl session 26 | void discardCurlSession(); 27 | /// process one request (internal) 28 | void doRequestInternal(const Ptr& req); 29 | /// curl write-data callback 30 | static size_t curlWriteDataCallback(char* ptr, size_t size, size_t nmemb, void* userData); 31 | /// curl header-data callback 32 | static size_t curlHeaderCallback(char* ptr, size_t size, size_t nmenb, void* userData); 33 | 34 | void* curlSession; 35 | char* curlError; 36 | }; 37 | 38 | } // namespace _priv 39 | } // namespace Oryol 40 | -------------------------------------------------------------------------------- /code/Modules/HttpFS/private/emsc/emscURLLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::emscURLLoader 5 | @ingroup _priv 6 | @brief emscripten implementation of URL loader 7 | @see urlLoader 8 | */ 9 | #include "HttpFS/private/baseURLLoader.h" 10 | 11 | namespace Oryol { 12 | namespace _priv { 13 | 14 | class emscURLLoader : public baseURLLoader { 15 | public: 16 | /// process one request 17 | bool doRequest(const Ptr& req); 18 | 19 | /// start the next, called from doWork 20 | void startRequest(const Ptr& req); 21 | /// success callback 22 | static void onLoaded(unsigned int handle, void* userData, void* buffer, unsigned int size); 23 | /// failure callback 24 | static void onFailed(unsigned int handle, void* userData, int errorCode, const char *statusDescription); 25 | }; 26 | 27 | } // namespace _priv 28 | } // namespace Oryol 29 | -------------------------------------------------------------------------------- /code/Modules/HttpFS/private/osx/osxURLLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::osxURLLoader 5 | @ingroup _priv 6 | @brief OSX implementation of URLLoader 7 | @see urlLoader, HTTPClient 8 | */ 9 | #include "HttpFS/private/baseURLLoader.h" 10 | 11 | namespace Oryol { 12 | namespace _priv { 13 | 14 | class osxURLLoader : public baseURLLoader { 15 | public: 16 | /// constructor 17 | osxURLLoader(); 18 | /// process one HTTPRequest 19 | bool doRequest(const Ptr& ioRequest); 20 | 21 | /// handle a single request, synchronously 22 | void doRequestInternal(const Ptr& ioRequest); 23 | }; 24 | 25 | } // namespace _priv 26 | } // namespace Oryol 27 | -------------------------------------------------------------------------------- /code/Modules/HttpFS/private/urlLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::urlLoader 5 | @ingroup _priv 6 | @brief processes a HTTP request and returns HTTP response 7 | @see HTTPClient 8 | */ 9 | #if ORYOL_USE_LIBCURL 10 | #include "HttpFS/private/curl/curlURLLoader.h" 11 | namespace Oryol { 12 | namespace _priv { 13 | class urlLoader : public curlURLLoader {}; 14 | } } 15 | #elif ORYOL_OSX 16 | #include "HttpFS/private/osx/osxURLLoader.h" 17 | namespace Oryol { 18 | namespace _priv { 19 | class urlLoader : public osxURLLoader {}; 20 | } } 21 | #elif ORYOL_WINDOWS 22 | #include "HttpFS/private/win/winURLLoader.h" 23 | namespace Oryol { 24 | namespace _priv { 25 | class urlLoader : public winURLLoader {}; 26 | } } 27 | #elif ORYOL_EMSCRIPTEN 28 | #include "HttpFS/private/emsc/emscURLLoader.h" 29 | namespace Oryol { 30 | namespace _priv { 31 | class urlLoader : public emscURLLoader {}; 32 | } } 33 | #else 34 | #include "HttpFS/private/baseURLLoader.h" 35 | namespace Oryol { 36 | namespace _priv { 37 | class urlLoader : public baseURLLoader {}; 38 | } } 39 | #endif 40 | -------------------------------------------------------------------------------- /code/Modules/HttpFS/private/win/winURLLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::winURLLoader 5 | @ingroup _priv 6 | @brief Windows implementation of URLLoader 7 | @see urlLoader HTTPClient 8 | 9 | The winURLLoader will keep an internal pool of open HTTP connections 10 | which will expire after a couple of seconds. 11 | */ 12 | #include "HttpFS/private/baseURLLoader.h" 13 | #include "Core/String/StringBuilder.h" 14 | #include 15 | 16 | // don't include windows headers here 17 | typedef void* HINTERNET; 18 | 19 | namespace Oryol { 20 | namespace _priv { 21 | 22 | class winURLLoader : public baseURLLoader { 23 | public: 24 | /// constructor, calls InternetOpen() 25 | winURLLoader(); 26 | /// destructor, calls InternetCloseHandle() 27 | ~winURLLoader(); 28 | /// process one HTTPRequest 29 | bool doRequest(const Ptr& ioRequest); 30 | 31 | /// process a single HTTP request 32 | void doRequestInternal(const Ptr& req); 33 | /// open connection, or get already open connection 34 | HINTERNET obtainConnection(const URL& url); 35 | /// garbage collect expired connections (called from doWork) 36 | void garbageCollectConnections(); 37 | 38 | static const std::chrono::seconds connectionMaxAge; // disconnect after 10 seconds 39 | HINTERNET hSession; 40 | struct connection { 41 | HINTERNET hConnection; 42 | std::chrono::steady_clock::time_point timeStamp; 43 | }; 44 | Map connections; 45 | StringBuilder stringBuilder; 46 | }; 47 | 48 | } // namespace _priv 49 | } // namespace Oryol 50 | -------------------------------------------------------------------------------- /code/Modules/IO/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # oryol IO module 3 | #------------------------------------------------------------------------------- 4 | fips_begin_module(IO) 5 | fips_vs_warning_level(3) 6 | fips_files( 7 | IO.cc IO.h 8 | IOTypes.cc IOTypes.h 9 | FileSystemBase.cc FileSystemBase.h 10 | ) 11 | fips_dir(private) 12 | fips_files( 13 | assignRegistry.cc assignRegistry.h 14 | schemeRegistry.cc schemeRegistry.h 15 | loadQueue.cc loadQueue.h 16 | ioPointers.h 17 | ioRequests.h 18 | ioWorker.cc ioWorker.h 19 | ioRouter.cc ioRouter.h 20 | ) 21 | fips_deps(Core) 22 | fips_end_module() 23 | 24 | oryol_begin_unittest(IO) 25 | fips_vs_warning_level(3) 26 | fips_dir(UnitTests) 27 | fips_files( 28 | IOFacadeTest.cc 29 | IOStatusTest.cc 30 | URLBuilderTest.cc 31 | URLTest.cc 32 | assignRegistryTest.cc 33 | schemeRegistryTest.cc 34 | ) 35 | fips_deps(IO Core) 36 | oryol_end_unittest() 37 | -------------------------------------------------------------------------------- /code/Modules/IO/FileSystemBase.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // FileSystemBase.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "FileSystemBase.h" 6 | #include "Core/Log.h" 7 | 8 | namespace Oryol { 9 | 10 | //------------------------------------------------------------------------------ 11 | FileSystemBase::~FileSystemBase() { 12 | // empty 13 | } 14 | 15 | //------------------------------------------------------------------------------ 16 | void 17 | FileSystemBase::init(const StringAtom& scheme_) { 18 | this->scheme = scheme_; 19 | } 20 | 21 | //------------------------------------------------------------------------------ 22 | void 23 | FileSystemBase::initLane() { 24 | // this is called per IO lane 25 | } 26 | 27 | //------------------------------------------------------------------------------ 28 | void 29 | FileSystemBase::onMsg(const Ptr& ioReq) { 30 | o_warn("FileSystem::onMsg(): message not handled by FileSystem!\n"); 31 | } 32 | 33 | } // namespace Oryol 34 | -------------------------------------------------------------------------------- /code/Modules/IO/FileSystemBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::FileSystemBase 5 | @ingroup IO 6 | @brief base-class for FileSystem handlers 7 | 8 | Subclasses of FileSystem provide a specific file-system implementation 9 | (e.g. HttpFileSystem, HostFileSystem, etc). 10 | */ 11 | #include "Core/String/StringAtom.h" 12 | #include "Core/RefCounted.h" 13 | #include "IO/private/ioRequests.h" 14 | 15 | namespace Oryol { 16 | 17 | class FileSystemBase : public RefCounted { 18 | OryolClassDecl(FileSystemBase); 19 | public: 20 | /// destructor 21 | virtual ~FileSystemBase(); 22 | 23 | /// called once on main-thread 24 | virtual void init(const StringAtom& scheme); 25 | /// called per IO-lane 26 | virtual void initLane(); 27 | /// called when IO message should be handled 28 | virtual void onMsg(const Ptr& ioReq); 29 | 30 | StringAtom scheme; 31 | }; 32 | 33 | } // namespace Oryol 34 | -------------------------------------------------------------------------------- /code/Modules/IO/UnitTests/assignRegistryTest.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // assignRegistryTest.cc 3 | // Test assignRegistry singleton 4 | //------------------------------------------------------------------------------ 5 | #include "Pre.h" 6 | #include "UnitTest++/src/UnitTest++.h" 7 | #include "IO/private/assignRegistry.h" 8 | #include "Core/Ptr.h" 9 | 10 | using namespace Oryol; 11 | using namespace Oryol::_priv; 12 | 13 | TEST(assignRegistryTest) { 14 | 15 | assignRegistry reg; 16 | 17 | reg.SetAssign("home:", "c:/program files/bla/"); 18 | reg.SetAssign("bla:", "home:"); 19 | reg.SetAssign("blub:", "bla:blub/"); 20 | 21 | CHECK(reg.HasAssign("home:")); 22 | CHECK(reg.HasAssign("bla:")); 23 | CHECK(reg.HasAssign("blub:")); 24 | CHECK(!reg.HasAssign("blob:")); 25 | CHECK(reg.LookupAssign("home:") == "c:/program files/bla/"); 26 | CHECK(reg.LookupAssign("bla:") == "home:"); 27 | CHECK(reg.LookupAssign("blub:") == "bla:blub/"); 28 | CHECK(reg.LookupAssign("blob:") == ""); 29 | 30 | String res = reg.ResolveAssigns("blub:"); 31 | CHECK(res == "c:/program files/bla/blub/"); 32 | reg.SetAssign("home:", "http://www.flohofwoe.net/"); 33 | res = reg.ResolveAssigns("blub:"); 34 | CHECK(res == "http://www.flohofwoe.net/blub/"); 35 | } 36 | -------------------------------------------------------------------------------- /code/Modules/IO/private/assignRegistry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /* 4 | @class Oryol::_priv::assignRegistry 5 | @ingroup _priv 6 | @brief central registry for assign definitions 7 | 8 | Central registry for assign definitions. Assigns are 9 | path aliases (google for AmigaOS assign). 10 | */ 11 | #include "Core/Containers/Map.h" 12 | #include "Core/String/String.h" 13 | 14 | namespace Oryol { 15 | namespace _priv { 16 | 17 | class assignRegistry { 18 | public: 19 | /// add or replace an assign definition 20 | void SetAssign(const String& assign, const String& path); 21 | /// check if an assign exists 22 | bool HasAssign(const String& assign) const; 23 | /// lookup an assign (return empty string if not exists) 24 | String LookupAssign(const String& assign) const; 25 | /// resolve assigns in the provided string 26 | String ResolveAssigns(const String& str) const; 27 | 28 | /// setup the standard assigns 29 | void setStandardAssigns(); 30 | 31 | Map assigns; 32 | }; 33 | 34 | } // namespace _priv 35 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/IO/private/ioPointers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::ioPointers 5 | @ingroup _priv 6 | @brief grant access to central IO module objects 7 | */ 8 | #include "Core/Types.h" 9 | 10 | namespace Oryol { 11 | namespace _priv { 12 | 13 | class assignRegistry; 14 | class schemeRegistry; 15 | 16 | struct ioPointers { 17 | class assignRegistry* assignRegistry; 18 | class schemeRegistry* schemeRegistry; 19 | }; 20 | 21 | } // namespace _priv 22 | } // namespace Oryol 23 | -------------------------------------------------------------------------------- /code/Modules/IO/private/ioRouter.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // ioRouter.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "ioRouter.h" 6 | 7 | namespace Oryol { 8 | namespace _priv { 9 | 10 | //------------------------------------------------------------------------------ 11 | void 12 | ioRouter::setup(const ioPointers& ptrs) { 13 | for (auto& worker : this->workers) { 14 | worker.start(ptrs); 15 | } 16 | } 17 | 18 | //------------------------------------------------------------------------------ 19 | void 20 | ioRouter::discard() { 21 | for (auto& worker : this->workers) { 22 | worker.stop(); 23 | } 24 | } 25 | 26 | //------------------------------------------------------------------------------ 27 | void 28 | ioRouter::doWork() { 29 | for (auto& worker : this->workers) { 30 | worker.doWork(); 31 | } 32 | } 33 | 34 | //------------------------------------------------------------------------------ 35 | void 36 | ioRouter::put(const Ptr& msg) { 37 | if (msg->IsA()) { 38 | // notifyWorker messages must be distributed to all workers 39 | for (auto& worker : this->workers) { 40 | worker.put(msg); 41 | } 42 | } 43 | else { 44 | // for all other messages, use a round-robin dispatch 45 | this->curWorker = (this->curWorker + 1) % NumWorkers; 46 | this->workers[this->curWorker].put(msg); 47 | } 48 | } 49 | 50 | } // namespace _priv 51 | } // namespace Oryol 52 | 53 | 54 | -------------------------------------------------------------------------------- /code/Modules/IO/private/ioRouter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::ioRouter 5 | @ingroup IO 6 | @brief route IO requests to ioWorkers 7 | */ 8 | #include "Core/Containers/StaticArray.h" 9 | #include "IO/private/ioPointers.h" 10 | #include "IO/private/ioWorker.h" 11 | 12 | namespace Oryol { 13 | namespace _priv { 14 | 15 | class ioRouter { 16 | public: 17 | /// setup the router 18 | void setup(const ioPointers& ptrs); 19 | /// discard the router 20 | void discard(); 21 | /// route a ioMsg to one or more workers 22 | void put(const Ptr& msg); 23 | /// perform per-frame work 24 | void doWork(); 25 | 26 | static const int NumWorkers = 4; 27 | int curWorker = 0; 28 | StaticArray workers; 29 | }; 30 | 31 | } // namespace _priv 32 | } // namespace Oryol 33 | 34 | -------------------------------------------------------------------------------- /code/Modules/IO/private/schemeRegistry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::schemeRegistry 5 | @ingroup _priv 6 | @brief: associates URL schemes with FileSystem implementation 7 | */ 8 | #include "Core/String/StringAtom.h" 9 | #include "Core/Containers/Map.h" 10 | #include "Core/Creator.h" 11 | #include "IO/FileSystemBase.h" 12 | #include 13 | #include 14 | 15 | namespace Oryol { 16 | namespace _priv { 17 | 18 | class schemeRegistry { 19 | public: 20 | /// associate URL scheme with filesystem 21 | void RegisterFileSystem(const StringAtom& scheme, std::function()> fsCreator); 22 | /// unregister a filesystem 23 | void UnregisterFileSystem(const StringAtom& scheme); 24 | /// test if a filesystem has been registered 25 | bool IsFileSystemRegistered(const StringAtom& scheme) const; 26 | /// return a new filesystem instance 27 | Ptr CreateFileSystem(const StringAtom& scheme) const; 28 | 29 | Map()>> registry; 30 | }; 31 | 32 | } // namespace _priv 33 | } // namespace Oryol 34 | -------------------------------------------------------------------------------- /code/Modules/Input/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # oryol Input module 3 | #------------------------------------------------------------------------------- 4 | fips_begin_module(Input) 5 | fips_vs_warning_level(3) 6 | fips_files( 7 | Input.cc Input.h 8 | InputTypes.h InputTypes.cc 9 | ) 10 | fips_dir(private) 11 | fips_files( 12 | gestureDetectors.h gestureDetectors.cc 13 | inputDispatcher.cc inputDispatcher.h 14 | inputDevices.h inputDevices.cc 15 | inputMgrBase.h inputMgrBase.cc 16 | inputMgr.h 17 | ) 18 | if (FIPS_ANDROID) 19 | fips_dir(private/android) 20 | fips_files(androidInputMgr.cc androidInputMgr.h) 21 | endif() 22 | if (FIPS_EMSCRIPTEN) 23 | fips_dir(private/emsc) 24 | fips_files(emscInputMgr.cc emscInputMgr.h) 25 | endif() 26 | if (FIPS_IOS) 27 | fips_dir(private/ios) 28 | fips_files(iosInputMgr.mm iosInputMgr.h) 29 | fips_frameworks_osx(CoreMotion) 30 | endif() 31 | if (ORYOL_OPENGL) 32 | if (FIPS_RASPBERRYPI) 33 | fips_dir(private/raspi) 34 | fips_files(raspiInputMgr.cc raspiInputMgr.h) 35 | elseif (FIPS_MACOS OR FIPS_WINDOWS OR FIPS_LINUX) 36 | fips_dir(private/glfw) 37 | fips_files(glfwInputMgr.cc glfwInputMgr.h) 38 | endif() 39 | endif() 40 | if (FIPS_MACOS AND ORYOL_METAL) 41 | fips_dir(private/osx) 42 | fips_files(osxInputMgr.cc osxInputMgr.h) 43 | endif() 44 | if (ORYOL_D3D11) 45 | fips_dir(private/win) 46 | fips_files(winInputMgr.cc winInputMgr.h) 47 | endif() 48 | fips_deps(Core Gfx) 49 | fips_end_module() 50 | 51 | -------------------------------------------------------------------------------- /code/Modules/Input/private/android/androidInputMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::androidInputMgr 5 | @brief input manager for Android 6 | */ 7 | #include "Input/private/inputMgrBase.h" 8 | #include "Core/private/android/androidBridge.h" 9 | #include "Core/RunLoop.h" 10 | 11 | class android_app; 12 | class AInputEvent; 13 | 14 | namespace Oryol { 15 | namespace _priv { 16 | 17 | class androidInputMgr : public inputMgrBase { 18 | public: 19 | /// constructor 20 | androidInputMgr(); 21 | /// destructor 22 | ~androidInputMgr(); 23 | 24 | /// setup the input manager 25 | void setup(const InputSetup& setup); 26 | /// discard the input manager 27 | void discard(); 28 | 29 | /// callback method from global android_app object 30 | static int32_t onInputEvent(struct android_app* app, AInputEvent* event); 31 | /// sensor event callback 32 | static void onSensorEvent(const ASensorEvent* event); 33 | 34 | RunLoop::Id runLoopId; 35 | bool highDPI; 36 | }; 37 | 38 | } // namespace _priv 39 | } // namespace Oryol 40 | -------------------------------------------------------------------------------- /code/Modules/Input/private/inputDispatcher.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // inputDispatcher.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "inputDispatcher.h" 6 | 7 | namespace Oryol { 8 | namespace _priv { 9 | 10 | //------------------------------------------------------------------------------ 11 | inputDefs::callbackId 12 | inputDispatcher::subscribeEvents(inputDefs::inputEventCallback handler) { 13 | inputDefs::callbackId id = ++this->uniqueIdCounter; 14 | this->inputEventHandlers.Add(id, handler); 15 | return id; 16 | } 17 | 18 | //------------------------------------------------------------------------------ 19 | void 20 | inputDispatcher::unsubscribeEvents(inputDefs::callbackId id) { 21 | if (this->inputEventHandlers.Contains(id)) { 22 | this->inputEventHandlers.Erase(id); 23 | } 24 | } 25 | 26 | //------------------------------------------------------------------------------ 27 | void 28 | inputDispatcher::notifyEvent(const InputEvent& ie) { 29 | for (const auto& entry : this->inputEventHandlers) { 30 | entry.Value()(ie); 31 | } 32 | } 33 | 34 | //------------------------------------------------------------------------------ 35 | PointerLockMode::Code 36 | inputDispatcher::notifyPointerLock(const InputEvent& ie) { 37 | if (this->pointerLockHandler) { 38 | return this->pointerLockHandler(ie); 39 | } 40 | else { 41 | return PointerLockMode::DontCare; 42 | } 43 | } 44 | 45 | } // namespace _priv 46 | } // namespace Oryol 47 | -------------------------------------------------------------------------------- /code/Modules/Input/private/inputDispatcher.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::inputDispatcher 5 | @brief dispatch input module events 6 | */ 7 | #include "Input/InputTypes.h" 8 | #include "Core/Containers/Map.h" 9 | 10 | namespace Oryol { 11 | namespace _priv { 12 | 13 | class inputDispatcher { 14 | public: 15 | inputDefs::callbackId subscribeEvents(inputDefs::inputEventCallback handler); 16 | void unsubscribeEvents(inputDefs::callbackId id); 17 | void notifyEvent(const InputEvent& event); 18 | PointerLockMode::Code notifyPointerLock(const InputEvent& event); 19 | 20 | inputDefs::callbackId uniqueIdCounter = 0; 21 | Map inputEventHandlers; 22 | inputDefs::pointerLockCallback pointerLockHandler; 23 | }; 24 | 25 | } // namespace _priv 26 | } // namespace Oryol 27 | -------------------------------------------------------------------------------- /code/Modules/Input/private/inputMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::inputMgr 5 | @ingroup _priv 6 | @brief frontend inputMgr class 7 | */ 8 | #if ORYOL_D3D11 9 | #include "Input/private/win/winInputMgr.h" 10 | namespace Oryol { 11 | namespace _priv { 12 | class inputMgr : public winInputMgr { }; 13 | } } 14 | #elif ORYOL_MACOS && ORYOL_METAL 15 | #include "Input/private/osx/osxInputMgr.h" 16 | namespace Oryol { 17 | namespace _priv { 18 | class inputMgr : public osxInputMgr { }; 19 | } } 20 | #elif ORYOL_RASPBERRYPI 21 | #include "Input/private/raspi/raspiInputMgr.h" 22 | namespace Oryol { 23 | namespace _priv { 24 | class inputMgr : public raspiInputMgr { }; 25 | } } 26 | #elif (ORYOL_WINDOWS || ORYOL_MACOS || ORYOL_LINUX) 27 | #include "Input/private/glfw/glfwInputMgr.h" 28 | namespace Oryol { 29 | namespace _priv { 30 | class inputMgr : public glfwInputMgr { }; 31 | } } 32 | #elif ORYOL_EMSCRIPTEN 33 | #include "Input/private/emsc/emscInputMgr.h" 34 | namespace Oryol { 35 | namespace _priv { 36 | class inputMgr : public emscInputMgr { }; 37 | } } 38 | #elif ORYOL_ANDROID 39 | #include "Input/private/android/androidInputMgr.h" 40 | namespace Oryol { 41 | namespace _priv { 42 | class inputMgr : public androidInputMgr { }; 43 | } } 44 | #elif ORYOL_IOS 45 | #include "Input/private/ios/iosInputMgr.h" 46 | namespace Oryol { 47 | namespace _priv { 48 | class inputMgr : public iosInputMgr { }; 49 | } } 50 | #else 51 | #include "Input/private/inputMgrBase.h" 52 | namespace Oryol { 53 | namespace _priv { 54 | class inputMgr : public inputMgrBase { }; 55 | } } 56 | #endif 57 | -------------------------------------------------------------------------------- /code/Modules/Input/private/inputMgrBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::inputMgrBase 5 | @ingroup _priv 6 | @brief base class for platform-specific input managers 7 | */ 8 | #include "Input/InputTypes.h" 9 | #include "Input/private/inputDevices.h" 10 | #include "Input/private/gestureDetectors.h" 11 | #include "Input/private/inputDispatcher.h" 12 | 13 | namespace Oryol { 14 | namespace _priv { 15 | 16 | class inputMgrBase { 17 | public: 18 | inputMgrBase(); 19 | ~inputMgrBase(); 20 | 21 | void setup(const InputSetup& setup); 22 | void discard(); 23 | bool isValid() const; 24 | void reset(); 25 | void addGamepadMapping(const StringAtom& id, const GamepadMapping& mapping); 26 | const GamepadMapping& lookupGamepadMapping(const StringAtom& id) const; 27 | void onTouchEvent(const touchEvent& event); 28 | 29 | class keyboardDevice keyboard; 30 | class mouseDevice mouse; 31 | class touchpadDevice touchpad; 32 | class sensorDevice sensors; 33 | StaticArray gamepad; 34 | 35 | 36 | bool valid = false; 37 | InputSetup inputSetup; 38 | inputDispatcher dispatcher; 39 | tapDetector singleTapDetector; 40 | tapDetector doubleTapDetector; 41 | class panDetector panDetector; 42 | class pinchDetector pinchDetector; 43 | GamepadMapping defaultGamepadMapping; 44 | Map gamepadMappings; 45 | }; 46 | 47 | } // namespace _priv 48 | } // namespace Oryol 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /code/Modules/Input/private/ios/iosInputMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::iosInputMgr 5 | @brief input manager for iOS 6 | */ 7 | #include "Input/private/inputMgrBase.h" 8 | #include "Core/private/ios/iosBridge.h" 9 | #include "Core/RunLoop.h" 10 | 11 | namespace Oryol { 12 | namespace _priv { 13 | 14 | class iosInputMgr : public inputMgrBase { 15 | public: 16 | /// constructor 17 | iosInputMgr(); 18 | /// destructor 19 | ~iosInputMgr(); 20 | 21 | /// setup the object 22 | void setup(const InputSetup& setup); 23 | /// discard the object 24 | void discard(); 25 | 26 | /// sample motion data 27 | void sampleMotionData(); 28 | 29 | ORYOL_OBJC_ID inputDelegate; 30 | ORYOL_OBJC_ID motionManager; 31 | RunLoop::Id resetRunLoopId; 32 | RunLoop::Id motionRunLoopId; 33 | }; 34 | 35 | } // namespace _priv 36 | } // namespace Oryol 37 | -------------------------------------------------------------------------------- /code/Modules/Input/private/osx/osxInputMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::osxInputMgr 5 | @ingroup _priv 6 | @brief input manager wrapper for OSX without GLFW 7 | */ 8 | #include "Input/private/inputMgrBase.h" 9 | 10 | namespace Oryol { 11 | namespace _priv { 12 | 13 | class osxInputMgr : public inputMgrBase { 14 | public: 15 | /// constructor 16 | osxInputMgr(); 17 | /// destructor 18 | ~osxInputMgr(); 19 | 20 | /// setup the input manager 21 | void setup(const InputSetup& setup); 22 | /// discard the input manager 23 | void discard(); 24 | 25 | /// setup the key mapping table 26 | void setupKeyTable(); 27 | /// setup glfw input callbacks 28 | void setupCallbacks(); 29 | /// discard glfw input callbacks 30 | void discardCallbacks(); 31 | /// map GLFW key code to Oryol key code 32 | Key::Code mapKey(int osxBridgeKey) const; 33 | 34 | /// GLFW key callback 35 | static void keyCallback(int key, int scancode, int action, int mods); 36 | /// GLFW char callback 37 | static void charCallback(uint32_t unicode); 38 | /// GLFW mouse button callback 39 | static void mouseButtonCallback(int button, int action, int mods); 40 | /// GLFW cursor position callback 41 | static void cursorPosCallback(double x, double y); 42 | /// GLFW cursor enter callback 43 | static void cursorEnterCallback(bool entered); 44 | /// GLFW scroll callback 45 | static void scrollCallback(double xOffset, double yOffset); 46 | 47 | static osxInputMgr* self; 48 | int runLoopId; 49 | }; 50 | 51 | } // namespace _priv 52 | } // namespace Oryol 53 | 54 | -------------------------------------------------------------------------------- /code/Modules/Input/private/raspi/raspiInputMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::raspiInputMgr 5 | @ingroup _priv 6 | @brief input manager for Raspberry Pi using /dev/input 7 | */ 8 | #include "Input/private/inputMgrBase.h" 9 | #include "Core/RunLoop.h" 10 | 11 | namespace Oryol { 12 | namespace _priv { 13 | 14 | class raspiInputMgr : public inputMgrBase { 15 | public: 16 | /// constructor 17 | raspiInputMgr(); 18 | /// destructor 19 | ~raspiInputMgr(); 20 | 21 | /// setup the input manager 22 | void setup(const InputSetup& setup); 23 | /// discard the input manager 24 | void discard(); 25 | 26 | /// open mouse and keyboard device file under /dev/input 27 | bool openDevices(); 28 | /// close mouse and keyboard device 29 | void closeDevices(); 30 | /// per-frame poll input 31 | void pollInput(); 32 | /// update max mouse coords, this depends on display resolution 33 | void updateMaxMouseCoords(); 34 | /// called on key event 35 | void onKey(unsigned short code, int val); 36 | /// called when mouse button is pressed 37 | void onMouseButton(unsigned short code, int val); 38 | /// called when mouse moved 39 | void onMouseMove(unsigned short code, int val); 40 | 41 | /// translate raw Linux key code to Oryol key code 42 | Key::Code mapKey(unsigned short code); 43 | /// translate raw Linux key code to ASCII wchar_t (hardwired) 44 | wchar_t mapChar(unsigned short code, bool shift); 45 | 46 | RunLoop::Id runLoopId; 47 | int kbdFd; 48 | int mouseFd; 49 | bool leftShift; 50 | bool rightShift; 51 | 52 | static const int mouseSensitivity = 1; 53 | int maxMouseX; 54 | int maxMouseY; 55 | int curMouseX; 56 | int curMouseY; 57 | }; 58 | 59 | } // namespace _priv 60 | } // namespace Oryol 61 | -------------------------------------------------------------------------------- /code/Modules/LocalFS/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # Oryol LocalFS module 3 | #------------------------------------------------------------------------------- 4 | fips_begin_module(LocalFS) 5 | fips_vs_warning_level(3) 6 | if (FIPS_MSVC) 7 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 8 | endif() 9 | fips_files( 10 | LocalFileSystem.cc LocalFileSystem.h 11 | ) 12 | fips_dir(private) 13 | fips_files(fsWrapper.h) 14 | fips_dir(private/whereami) 15 | if (NOT FIPS_EMSCRIPTEN) 16 | fips_files(whereami_oryol.cc whereami.h) 17 | endif() 18 | # web-platforms don't have a LocalFS implementation 19 | if (FIPS_EMSCRIPTEN) 20 | fips_dir(private/dummy) 21 | fips_files(dummyFSWrapper.cc dummyFSWrapper.h) 22 | else() 23 | fips_dir(private/posix) 24 | fips_files(posixFSWrapper.cc posixFSWrapper.h) 25 | endif() 26 | fips_deps(IO Core) 27 | fips_end_module() 28 | 29 | oryol_begin_unittest(LocalFS) 30 | fips_vs_warning_level(3) 31 | fips_dir(UnitTests) 32 | fips_files( 33 | LocalFileSystemTest.cc 34 | FSWrapperTest.cc 35 | ) 36 | fips_deps(LocalFS) 37 | oryol_end_unittest() 38 | -------------------------------------------------------------------------------- /code/Modules/LocalFS/LocalFileSystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @defgroup LocalFS LocalFS 5 | @brief access to the local disk file system 6 | 7 | @class Oryol::LocalFileSystem 8 | @ingroup LocalFS 9 | @brief FileSystem subclass to access the local host file system 10 | */ 11 | #include "IO/FileSystemBase.h" 12 | #include "Core/Creator.h" 13 | 14 | namespace Oryol { 15 | 16 | class LocalFileSystem : public FileSystemBase { 17 | OryolClassDecl(LocalFileSystem); 18 | OryolClassCreator(LocalFileSystem); 19 | public: 20 | /// called once on main-thread 21 | virtual void init(const StringAtom& scheme) override; 22 | /// called when IO message should be handled 23 | virtual void onMsg(const Ptr& ioReq) override; 24 | 25 | private: 26 | /// handle IORead msg 27 | void onRead(const Ptr& ioRead); 28 | /// handle IOWrite msg 29 | void onWrite(const Ptr& ioWrite); 30 | }; 31 | 32 | } // namespace Oryol 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /code/Modules/LocalFS/README.md: -------------------------------------------------------------------------------- 1 | ## LocalFS Module 2 | 3 | The LocalFS module implements a filesystem plugin to load data from 4 | the local disc via the C POSIX file functions (fopen, fread, etc). 5 | 6 | Before it can be used, the LocalFS filesystem must be registered 7 | with the IO module, the best time to do this is during setup: 8 | 9 | ```cpp 10 | #include "IO/IO.h" 11 | #include "LocalFS/LocalFileSystem.h" 12 | ... 13 | 14 | AppState::Code 15 | MyApp::OnInit() { 16 | IOSetup ioSetup; 17 | ioSetup.FileSystems.Add("file", LocalFileSystem::Creator()); 18 | IO::Setup(ioSetup); 19 | ... 20 | } 21 | ``` 22 | 23 | The LocalFileSystem initializes two path assigns: 24 | 25 | - **root:** this is the directory where the executable is located 26 | - **cwd:** this is the current working directory (aquired with the getcwd() function) 27 | 28 | After setup, data can be loaded as usual, refer to the [IO module documentation](../IO/README.md) for more details. -------------------------------------------------------------------------------- /code/Modules/LocalFS/private/dummy/dummyFSWrapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::dummyFSWrapper 5 | @ingroup _priv 6 | @brief empty filesystem wrapper class 7 | */ 8 | #include "Core/Types.h" 9 | #include "Core/String/String.h" 10 | 11 | namespace Oryol { 12 | namespace _priv { 13 | 14 | class dummyFSWrapper { 15 | public: 16 | /// file-handle typedef 17 | typedef int handle; 18 | /// invalid file handle 19 | static const handle invalidHandle = 0; 20 | 21 | /// open file for reading 22 | static handle openRead(const char* path); 23 | /// open file for writing 24 | static handle openWrite(const char* path); 25 | /// write to file, return number of bytes actually written 26 | static int write(handle f, const void* ptr, int numBytes); 27 | /// read from file, return number of bytes actually read 28 | static int read(handle f, void* ptr, int numBytes); 29 | /// seek from start of file 30 | static bool seek(handle f, int offset); 31 | /// get file size 32 | static int size(handle f); 33 | /// close file 34 | static void close(handle f); 35 | 36 | /// get path to own executable 37 | static String getExecutableDir(); 38 | /// get current directory 39 | static String getCwd(); 40 | }; 41 | 42 | } // namespace _priv 43 | } // namespace Oryol 44 | -------------------------------------------------------------------------------- /code/Modules/LocalFS/private/fsWrapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::fsWrapper 5 | @ingroup _priv 6 | @brief file-system wrapper frontend class 7 | */ 8 | 9 | #if ORYOL_EMSCRIPTEN 10 | #include "LocalFS/private/dummy/dummyFSWrapper.h" 11 | namespace Oryol { 12 | namespace _priv { 13 | class fsWrapper : public dummyFSWrapper { }; 14 | } } 15 | #else 16 | #include "LocalFS/private/posix/posixFSWrapper.h" 17 | namespace Oryol { 18 | namespace _priv { 19 | class fsWrapper : public posixFSWrapper { }; 20 | } } 21 | #endif 22 | -------------------------------------------------------------------------------- /code/Modules/LocalFS/private/posix/posixFSWrapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::_priv::posixFSWrapper 5 | @ingroup _priv 6 | @brief wrap local filesystem function on POSIX systems 7 | */ 8 | #include "Core/Types.h" 9 | #include "Core/String/String.h" 10 | 11 | namespace Oryol { 12 | namespace _priv { 13 | 14 | class posixFSWrapper { 15 | public: 16 | /// file-handle typedef 17 | typedef void* handle; 18 | /// invalid file handle 19 | static const handle invalidHandle; 20 | 21 | /// open file for reading 22 | static handle openRead(const char* path); 23 | /// open file for writing 24 | static handle openWrite(const char* path); 25 | /// write to file, return number of bytes actually written 26 | static int write(handle f, const void* ptr, int numBytes); 27 | /// read from file, return number of bytes actually read 28 | static int read(handle f, void* ptr, int numBytes); 29 | /// seek from start of file 30 | static bool seek(handle f, int offset); 31 | /// get file size 32 | static int size(handle f); 33 | /// close file 34 | static void close(handle f); 35 | 36 | /// get path to own executable 37 | static String getExecutableDir(); 38 | /// get current directory 39 | static String getCwd(); 40 | }; 41 | 42 | } // namespace _priv 43 | } // namespace Oryol 44 | 45 | -------------------------------------------------------------------------------- /code/Modules/LocalFS/private/whereami/LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 3 | Version 2, December 2004 4 | 5 | Copyright (C) 2004 Sam Hocevar 6 | 7 | Everyone is permitted to copy and distribute verbatim or modified 8 | copies of this license document, and changing it is allowed as long 9 | as the name is changed. 10 | 11 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 12 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 13 | 14 | 0. You just DO WHAT THE FUCK YOU WANT TO. 15 | 1. Bla bla bla 16 | 2. Montesqieu et camembert, vive la France, zut alors! 17 | 18 | -------------------------------------------------------------------------------- 19 | 20 | WTFPLv2 is very permissive, see http://www.wtfpl.net/faq/ 21 | 22 | However, if this WTFPLV2 is REALLY a blocker and is the reason you can't use 23 | this project, contact me and I'll dual license it. 24 | 25 | -------------------------------------------------------------------------------- 26 | -------------------------------------------------------------------------------- /code/Modules/LocalFS/private/whereami/whereami_oryol.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // whereami_oryol.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "Core/Memory/Memory.h" 6 | 7 | #define WAI_MALLOC(size) Oryol::Memory::Alloc(size) 8 | #define WAI_FREE(p) Oryol::Memory::Free(p) 9 | #define WAI_REALLOC(p,size) Oryol::Memory::ReAlloc(p,size) 10 | 11 | #include "whereami.h" 12 | #include "whereami.c" 13 | 14 | -------------------------------------------------------------------------------- /code/Modules/Resource/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # oryol Resource module 3 | #------------------------------------------------------------------------------- 4 | fips_begin_module(Resource) 5 | fips_vs_warning_level(3) 6 | fips_files( 7 | Id.h 8 | Locator.cc Locator.h 9 | ResourceLabel.h 10 | ResourceState.h 11 | ResourceLoader.cc ResourceLoader.h 12 | ResourcePool.h 13 | SetupAndData.h 14 | ResourceContainerBase.cc ResourceContainerBase.h 15 | ResourceRegistry.cc ResourceRegistry.h 16 | ResourceBase.h 17 | ) 18 | fips_deps(Core) 19 | fips_end_module() 20 | 21 | oryol_begin_unittest(Resource) 22 | fips_vs_warning_level(3) 23 | fips_dir(UnitTests) 24 | fips_files( 25 | IdTest.cc 26 | LocatorTest.cc 27 | ResourcePoolTest.cc 28 | resourceRegistryTest.cc 29 | StateTest.cc 30 | ) 31 | fips_deps(Resource Core) 32 | oryol_end_unittest() 33 | -------------------------------------------------------------------------------- /code/Modules/Resource/Locator.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // Locator.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "Locator.h" 6 | 7 | namespace Oryol { 8 | 9 | //------------------------------------------------------------------------------ 10 | Locator::Locator(const StringAtom& loc) : 11 | location(loc), 12 | signature(DefaultSignature) { 13 | // empty 14 | } 15 | 16 | //------------------------------------------------------------------------------ 17 | Locator::Locator(const char* loc) : 18 | location(loc), 19 | signature(DefaultSignature) { 20 | // empty 21 | } 22 | 23 | //------------------------------------------------------------------------------ 24 | Locator::Locator(const StringAtom& loc, uint32_t sig) : 25 | location(loc), 26 | signature(sig) { 27 | // empty 28 | } 29 | 30 | //------------------------------------------------------------------------------ 31 | Locator::Locator(const char* loc, uint32_t sig) : 32 | location(loc), 33 | signature(sig) { 34 | // empty 35 | } 36 | 37 | //------------------------------------------------------------------------------ 38 | Locator 39 | Locator::NonShared() { 40 | return Locator(StringAtom(), NonSharedSignature); 41 | } 42 | 43 | //------------------------------------------------------------------------------ 44 | Locator 45 | Locator::NonShared(const StringAtom& loc) { 46 | return Locator(loc, NonSharedSignature); 47 | } 48 | 49 | } // namespace Locator 50 | -------------------------------------------------------------------------------- /code/Modules/Resource/ResourceBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::ResourceBase 5 | @ingroup Resource 6 | @brief resource base class 7 | 8 | This is the generic Oryol resource base class. Resources usually manage 9 | some external data object (like textures, vertices, animations, ...) 10 | which can be shared, can be created synchronously or asynchronously. 11 | Resources generally live in ResourcePools, and only a maximum number 12 | of resources of the same type can exist at one time. The creation 13 | of a resource is controlled by a matching Setup object, which holds 14 | all information required to create a resource object. 15 | */ 16 | #include "Core/Assertion.h" 17 | #include "Resource/Id.h" 18 | #include "Resource/ResourceState.h" 19 | 20 | namespace Oryol { 21 | 22 | class ResourceBase { 23 | public: 24 | /// the resource id 25 | class Id Id; 26 | /// current resource state 27 | ResourceState::Code State = ResourceState::Initial; 28 | /// frame count of last state change 29 | int StateStartFrame = 0; 30 | }; 31 | 32 | } // namespace Oryol 33 | 34 | -------------------------------------------------------------------------------- /code/Modules/Resource/ResourceContainerBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::ResourceContainerBase 5 | @ingroup Resource 6 | @brief base class for resource containers 7 | 8 | A resource container manages creation, pooling, querying and 9 | discard for different types of related resources. Modules like 10 | the Gfx module typically derive a single ResourceContainer subclass 11 | to wrap their different resource types. 12 | */ 13 | #include "Core/Types.h" 14 | #include "Core/Containers/Array.h" 15 | #include "Resource/ResourceRegistry.h" 16 | #include "Resource/ResourceLabel.h" 17 | 18 | namespace Oryol { 19 | 20 | class ResourceContainerBase { 21 | public: 22 | /// destructor 23 | ~ResourceContainerBase(); 24 | 25 | /// setup the resource container 26 | void Setup(int labelStackCapacity, int registryCapacity); 27 | /// discard the resource container 28 | void Discard(); 29 | /// return true if valid 30 | bool IsValid() const; 31 | /// peek top of label stack 32 | ResourceLabel PeekLabel() const; 33 | /// generate new resource label and push on label stack 34 | ResourceLabel PushLabel(); 35 | /// push explicit resource label on label stack 36 | void PushLabel(ResourceLabel label); 37 | /// pop resource label from label stack 38 | ResourceLabel PopLabel(); 39 | /// lookup a resource Id by Locator 40 | Id Lookup(const Locator& locator) const; 41 | 42 | Array labelStack; 43 | ResourceRegistry registry; 44 | uint32_t curLabelCount = 0; 45 | bool valid = false; 46 | }; 47 | 48 | } // namespace Oryol 49 | -------------------------------------------------------------------------------- /code/Modules/Resource/ResourceInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::ResourceInfo 5 | @ingroup Resource 6 | @brief queryable information about a resource 7 | */ 8 | #include "Resource/ResourceState.h" 9 | 10 | namespace Oryol { 11 | 12 | class ResourceInfo { 13 | public: 14 | /// current state of the resource 15 | ResourceState::Code State = ResourceState::InvalidState; 16 | /// age of current state in number of frame 17 | int StateAge = 0; 18 | }; 19 | 20 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/Resource/ResourceLoader.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // ResourceLoader.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "ResourceLoader.h" 6 | 7 | namespace Oryol { 8 | 9 | //------------------------------------------------------------------------------ 10 | class Locator 11 | ResourceLoader::Locator() const { 12 | class Locator loc; 13 | return loc; 14 | } 15 | 16 | //------------------------------------------------------------------------------ 17 | Id 18 | ResourceLoader::Start() { 19 | return Id::InvalidId(); 20 | } 21 | 22 | //------------------------------------------------------------------------------ 23 | ResourceState::Code 24 | ResourceLoader::Continue() { 25 | return ResourceState::InvalidState; 26 | } 27 | 28 | //------------------------------------------------------------------------------ 29 | void 30 | ResourceLoader::Cancel() { 31 | // empty 32 | } 33 | 34 | } // namespace Oryol 35 | -------------------------------------------------------------------------------- /code/Modules/Resource/ResourceLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::ResourceLoader 5 | @ingroup Resource 6 | @brief base class for resource loaders 7 | */ 8 | #include "Core/RefCounted.h" 9 | #include "Resource/Id.h" 10 | #include "Resource/Locator.h" 11 | #include "Resource/ResourceState.h" 12 | 13 | namespace Oryol { 14 | 15 | class ResourceLoader : public RefCounted { 16 | OryolClassDecl(ResourceLoader); 17 | public: 18 | /// return resource locator 19 | virtual class Locator Locator() const; 20 | /// start loading, return a resource id 21 | virtual Id Start(); 22 | /// continue loading, return resource state (Pending, Valid, Failed) 23 | virtual ResourceState::Code Continue(); 24 | /// cancel the resource loading process 25 | virtual void Cancel(); 26 | }; 27 | 28 | } // namespace Oryol 29 | -------------------------------------------------------------------------------- /code/Modules/Resource/ResourcePoolInfo.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::ResourcePoolInfo 5 | @ingroup Resource 6 | @brief detailed resource pool information 7 | 8 | Note the querying resource pool information is relatively slow 9 | since the function must iterate over all slots. 10 | */ 11 | #include "Core/Containers/StaticArray.h" 12 | #include "Resource/ResourceState.h" 13 | 14 | namespace Oryol { 15 | 16 | class ResourcePoolInfo { 17 | public: 18 | /// constructor 19 | ResourcePoolInfo() { 20 | this->NumSlotsByState.Fill(0); 21 | } 22 | 23 | /// number of resource slots by their state 24 | StaticArray NumSlotsByState; 25 | /// resource type of the pool 26 | uint16_t ResourceType = Id::InvalidType; 27 | /// overall number of slots 28 | int NumSlots = 0; 29 | /// number of used slots 30 | int NumUsedSlots = 0; 31 | /// number of free slots 32 | int NumFreeSlots = 0; 33 | }; 34 | 35 | } // namespace Oryol 36 | -------------------------------------------------------------------------------- /code/Modules/Resource/ResourceState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::ResourceState 5 | @ingroup Resource 6 | @brief current state of a resource object 7 | 8 | These are the states a resource object goes through during its lifetime: 9 | 10 | * Initial: resource object has just been created 11 | * Setup: resource object has a valid Setup object, but is not loaded 12 | * Pending: asynchronous loading is underway 13 | * Valid: resource is valid and can be used 14 | * Failed: resource creation has failed 15 | 16 | Resources can be unloaded, which changes the state from Valid back 17 | to Setup, and then be loaded again. 18 | */ 19 | namespace Oryol { 20 | 21 | class ResourceState { 22 | public: 23 | /// state codes 24 | enum Code { 25 | Initial, ///< resource has just been created 26 | Setup, ///< the resource has a setup object, but is not loaded 27 | Pending, ///< resource is pending (asynchronous loading) 28 | Valid, ///< resource has become valid 29 | Failed, ///< resource creation has failed 30 | 31 | NumStates, 32 | InvalidState, 33 | }; 34 | 35 | /// convert resource State to string 36 | static const char* ToString(Code c) { 37 | switch (c) { 38 | case Initial: return "Initial"; 39 | case Setup: return "Setup"; 40 | case Pending: return "Pending"; 41 | case Valid: return "Valid"; 42 | case Failed: return "Failed"; 43 | default: return "InvalidState"; 44 | } 45 | } 46 | }; 47 | 48 | } // namespace Oryol 49 | 50 | -------------------------------------------------------------------------------- /code/Modules/Resource/SetupAndData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | //------------------------------------------------------------------------------ 3 | /** 4 | @class Oryol::SetupAndData 5 | @ingroup Resource 6 | @brief holds a setup and a data buffer object 7 | 8 | This is used to transfer both a resource setup object and 9 | a stream object to resource creation functions. 10 | */ 11 | #include "Core/Containers/Buffer.h" 12 | 13 | namespace Oryol { 14 | 15 | template class SetupAndData { 16 | public: 17 | /// default constructor 18 | SetupAndData() { }; 19 | /// construct from Setup and Stream object 20 | SetupAndData(const SETUP& setup, Buffer&& data) : 21 | Setup(setup), 22 | Data(std::move(data)) { 23 | // empty 24 | }; 25 | /// move construct 26 | SetupAndData(SetupAndData&& rhs) { 27 | this->Setup = std::move(rhs.Setup); 28 | this->Data = std::move(rhs.Data); 29 | }; 30 | /// move assignment 31 | void operator=(SetupAndData&& rhs) { 32 | this->Setup = std::move(rhs.Setup); 33 | this->Data = std::move(rhs.Data); 34 | }; 35 | 36 | /// disable copy constructor 37 | SetupAndData(const SetupAndData& rhs) = delete; 38 | /// disable copy assignment 39 | void operator=(const SetupAndData& rhs) = delete; 40 | 41 | /// embedded setup object 42 | SETUP Setup; 43 | /// embedded data buffer 44 | Buffer Data; 45 | }; 46 | 47 | } // namespace Oryol -------------------------------------------------------------------------------- /code/Modules/Resource/UnitTests/IdTest.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // IdTest.cc 3 | // Test resource Id 4 | //------------------------------------------------------------------------------ 5 | #include "Pre.h" 6 | #include "UnitTest++/src/UnitTest++.h" 7 | #include "Resource/Id.h" 8 | 9 | using namespace Oryol; 10 | 11 | TEST(IdTest) { 12 | Id id; 13 | CHECK(!id.IsValid()); 14 | CHECK(Id::InvalidUniqueStamp == id.UniqueStamp); 15 | CHECK(Id::InvalidSlotIndex == id.SlotIndex); 16 | CHECK(Id::InvalidType == id.Type); 17 | CHECK(id == Id::InvalidId()); 18 | 19 | Id id1(1, 2, 3); 20 | CHECK(id1.IsValid()); 21 | CHECK(id != id1); 22 | CHECK(id1.UniqueStamp == 1); 23 | CHECK(id1.SlotIndex == 2); 24 | CHECK(id1.Type == 3); 25 | 26 | // copy-constructor 27 | Id id2(id1); 28 | CHECK(id1 == id2); 29 | CHECK(id2.IsValid()); 30 | CHECK(id2.UniqueStamp == 1); 31 | CHECK(id2.SlotIndex == 2); 32 | CHECK(id2.Type == 3); 33 | 34 | // assignment 35 | Id id3; 36 | id3 = id1; 37 | CHECK(id3 == id1); 38 | CHECK(id3.IsValid()); 39 | CHECK(id3.UniqueStamp == 1); 40 | CHECK(id3.SlotIndex == 2); 41 | CHECK(id3.Type == 3); 42 | 43 | // invalidation 44 | id3.Invalidate(); 45 | CHECK(id == id3); 46 | CHECK(Id::InvalidUniqueStamp == id3.UniqueStamp); 47 | CHECK(Id::InvalidSlotIndex == id3.SlotIndex); 48 | CHECK(Id::InvalidType == id3.Type); 49 | CHECK(id3 == Id::InvalidId()); 50 | 51 | // comparison 52 | id3 = Id(0, 1, 2); 53 | CHECK(id3.IsValid()); 54 | CHECK(id3.UniqueStamp == 0); 55 | CHECK(id3.SlotIndex == 1); 56 | CHECK(id3.Type == 2); 57 | CHECK(id3 < id2); 58 | } 59 | -------------------------------------------------------------------------------- /code/Modules/Resource/UnitTests/StateTest.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // StateTest.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "UnitTest++/src/UnitTest++.h" 6 | #include "Resource/ResourceState.h" 7 | #include "Core/String/String.h" 8 | 9 | using namespace Oryol; 10 | 11 | TEST(StateTest) { 12 | CHECK(ResourceState::NumStates == 5); 13 | CHECK(String(ResourceState::ToString(ResourceState::Initial)) == "Initial"); 14 | CHECK(String(ResourceState::ToString(ResourceState::Setup)) == "Setup"); 15 | CHECK(String(ResourceState::ToString(ResourceState::Pending)) == "Pending"); 16 | CHECK(String(ResourceState::ToString(ResourceState::Valid)) == "Valid"); 17 | CHECK(String(ResourceState::ToString(ResourceState::Failed)) == "Failed"); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /code/Pre.cc: -------------------------------------------------------------------------------- 1 | #include "Pre.h" -------------------------------------------------------------------------------- /code/Pre.h: -------------------------------------------------------------------------------- 1 | #include "Core/precompiled.h" -------------------------------------------------------------------------------- /code/Samples/ArrayTexture/ArrayTexture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/ArrayTexture/ArrayTexture.jpg -------------------------------------------------------------------------------- /code/Samples/ArrayTexture/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(ArrayTexture windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(ArrayTexture.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Dbg Assets) 6 | oryol_add_web_sample(ArrayTexture "Demonstrate array texture usage" "emscripten" ArrayTexture.jpg "ArrayTexture/ArrayTexture.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/ArrayTexture/shaders.glsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // ArrayTexture sample shaders. 3 | //------------------------------------------------------------------------------ 4 | 5 | @vs vs 6 | uniform vsParams { 7 | mat4 mvp; 8 | vec2 uvOffset0; 9 | vec2 uvOffset1; 10 | vec2 uvOffset2; 11 | }; 12 | 13 | in vec4 position; 14 | in vec2 texcoord0; 15 | out vec3 uv0; 16 | out vec3 uv1; 17 | out vec3 uv2; 18 | 19 | void main() { 20 | gl_Position = mvp * position; 21 | uv0 = vec3(texcoord0 + uvOffset0, 0.0); 22 | uv1 = vec3(texcoord0 + uvOffset1, 1.0); 23 | uv2 = vec3(texcoord0 + uvOffset2, 2.0); 24 | } 25 | @end 26 | 27 | //------------------------------------------------------------------------------ 28 | @fs fs 29 | uniform sampler2DArray tex; 30 | in vec3 uv0; 31 | in vec3 uv1; 32 | in vec3 uv2; 33 | out vec4 fragColor; 34 | 35 | void main() { 36 | vec4 c0 = texture(tex, uv0); 37 | vec4 c1 = texture(tex, uv1); 38 | vec4 c2 = texture(tex, uv2); 39 | fragColor = vec4(c0.xyz + c1.xyz + c2.xyz, 1.0); 40 | } 41 | @end 42 | 43 | @program Shader vs fs 44 | -------------------------------------------------------------------------------- /code/Samples/BlendTest/BlendTest.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/BlendTest/BlendTest.jpg -------------------------------------------------------------------------------- /code/Samples/BlendTest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(BlendTest windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(BlendTest.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets) 6 | oryol_add_web_sample(BlendTest "Test BlendState implementation" "emscripten,android" BlendTest.jpg "BlendTest/BlendTest.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/BlendTest/shaders.glsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // background shader 3 | // 4 | @vs backgroundVS 5 | in vec4 position; 6 | in vec2 texcoord0; 7 | out vec2 uv0; 8 | 9 | void main() { 10 | gl_Position = position; 11 | uv0 = texcoord0; 12 | } 13 | @end 14 | 15 | @fs backgroundFS 16 | in vec2 uv0; 17 | void main() { 18 | vec2 xy = fract(uv0 * 32.0) * 0.5 + 0.25; 19 | float f = xy.x * xy.y; 20 | gl_FragColor = vec4(f, f, f, 1.0); 21 | } 22 | @end 23 | 24 | @program BGShader backgroundVS backgroundFS 25 | 26 | //------------------------------------------------------------------------------ 27 | // triangle shader 28 | // 29 | @vs triangleVS 30 | uniform params { 31 | vec4 translate; 32 | }; 33 | in vec4 position; 34 | in vec4 color0; 35 | out vec4 color; 36 | 37 | void main() { 38 | gl_Position = position + translate; 39 | color = color0; 40 | } 41 | @end 42 | 43 | @fs triangleFS 44 | in vec4 color; 45 | out vec4 fragColor; 46 | void main() { 47 | fragColor = color; 48 | } 49 | @end 50 | 51 | @program TriShader triangleVS triangleFS 52 | -------------------------------------------------------------------------------- /code/Samples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_add_subdirectory(Clear) 2 | fips_add_subdirectory(Triangle) 3 | fips_add_subdirectory(Quad) 4 | fips_add_subdirectory(Shapes) 5 | fips_add_subdirectory(PackedNormals) 6 | fips_add_subdirectory(PrimitiveTypes) 7 | fips_add_subdirectory(BlendTest) 8 | fips_add_subdirectory(SeparateBuffers) 9 | fips_add_subdirectory(SimpleRenderTarget) 10 | fips_add_subdirectory(MultipleRenderTarget) 11 | fips_add_subdirectory(RenderToCubeMap) 12 | fips_add_subdirectory(InfiniteSpheres) 13 | fips_add_subdirectory(TextureFloat) 14 | fips_add_subdirectory(DrawCallPerf) 15 | fips_add_subdirectory(Instancing) 16 | fips_add_subdirectory(GPUParticles) 17 | fips_add_subdirectory(FullscreenQuad) 18 | fips_add_subdirectory(VertexTexture) 19 | fips_add_subdirectory(VolumeTexture) 20 | fips_add_subdirectory(ArrayTexture) 21 | fips_add_subdirectory(DDSTextureLoading) 22 | fips_add_subdirectory(DDSCubeMap) 23 | fips_add_subdirectory(DebugText) 24 | fips_add_subdirectory(TestInput) 25 | fips_add_subdirectory(GamepadExplorer) 26 | fips_add_subdirectory(NativeTexture) 27 | fips_add_subdirectory(ResourceStress) 28 | fips_add_subdirectory(CoreHello) 29 | fips_add_subdirectory(Sensors) 30 | fips_add_subdirectory(IOQueueSample) 31 | -------------------------------------------------------------------------------- /code/Samples/Clear/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(Clear windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(Clear.cc Clear.jpg) 4 | fips_deps(Gfx) 5 | oryol_add_web_sample(Clear "Just call glClear in a loop" "emscripten" Clear.jpg "Clear/Clear.cc") 6 | fips_end_app() 7 | -------------------------------------------------------------------------------- /code/Samples/Clear/Clear.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // Clear.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "Core/Main.h" 6 | #include "Gfx/Gfx.h" 7 | #include "glm/glm.hpp" 8 | 9 | using namespace Oryol; 10 | 11 | class ClearApp : public App { 12 | public: 13 | AppState::Code OnRunning(); 14 | AppState::Code OnInit(); 15 | AppState::Code OnCleanup(); 16 | 17 | PassAction passAction; 18 | }; 19 | OryolMain(ClearApp); 20 | 21 | //------------------------------------------------------------------------------ 22 | AppState::Code 23 | ClearApp::OnInit() { 24 | Gfx::Setup(GfxSetup::Window(400, 300, "Oryol Clear Sample")); 25 | return App::OnInit(); 26 | } 27 | 28 | //------------------------------------------------------------------------------ 29 | AppState::Code 30 | ClearApp::OnRunning() { 31 | 32 | // render one frame 33 | Gfx::BeginPass(this->passAction); 34 | Gfx::EndPass(); 35 | Gfx::CommitFrame(); 36 | 37 | // update the clear color for next frame 38 | this->passAction.Color[0] += glm::vec4(0.01f, 0.005f, 0.0025f, 0.0f); 39 | this->passAction.Color[0] = glm::mod(this->passAction.Color[0], glm::vec4(1.0f)); 40 | this->passAction.Color[0].w = 1.0f; 41 | 42 | // continue running or quit? 43 | return Gfx::QuitRequested() ? AppState::Cleanup : AppState::Running; 44 | } 45 | 46 | //------------------------------------------------------------------------------ 47 | AppState::Code 48 | ClearApp::OnCleanup() { 49 | Gfx::Discard(); 50 | return App::OnCleanup(); 51 | } 52 | -------------------------------------------------------------------------------- /code/Samples/Clear/Clear.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/Clear/Clear.jpg -------------------------------------------------------------------------------- /code/Samples/CoreHello/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(CoreHello cmdline) 2 | fips_vs_warning_level(3) 3 | fips_files(CoreHello.cc) 4 | fips_deps(Core) 5 | oryol_add_web_sample(CoreHello "Low-level hello world sample" "emscripten" none "CoreHello/CoreHello.cc") 6 | fips_end_app() 7 | -------------------------------------------------------------------------------- /code/Samples/CoreHello/CoreHello.cc: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // CoreHello.cc 3 | //------------------------------------------------------------------------------ 4 | #include "Pre.h" 5 | #include "Core/Main.h" 6 | #include 7 | 8 | using namespace Oryol; 9 | 10 | class CoreHelloApp : public App { 11 | public: 12 | virtual void onFrame() { 13 | if (0 == (this->frameCount++ % 10)) { 14 | Log::Info("Hello World %d!\n", this->frameCount); 15 | } 16 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 17 | App::onFrame(); 18 | } 19 | int frameCount = 0; 20 | }; 21 | OryolMain(CoreHelloApp); 22 | -------------------------------------------------------------------------------- /code/Samples/DDSCubeMap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(DDSCubeMap windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(DDSCubeMap.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Assets Gfx HttpFS) 6 | oryol_add_web_sample(DDSCubeMap "Load and display DDS DXT1 cube map" "emscripten" DDSCubeMap.jpg "DDSCubeMap/DDSCubeMap.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/DDSCubeMap/DDSCubeMap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/DDSCubeMap/DDSCubeMap.jpg -------------------------------------------------------------------------------- /code/Samples/DDSCubeMap/shaders.glsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // DDSCubeMap sample shaders. 3 | //------------------------------------------------------------------------------ 4 | @vs vs 5 | uniform vsParams { 6 | mat4 mvp; 7 | }; 8 | in vec4 position; 9 | in vec3 normal; 10 | out vec3 nrm; 11 | 12 | void main() { 13 | gl_Position = mvp * position; 14 | nrm = normal; 15 | } 16 | @end 17 | 18 | @fs fs 19 | uniform samplerCube tex; 20 | in vec3 nrm; 21 | 22 | void main() { 23 | gl_FragColor = texture(tex, nrm); 24 | } 25 | @end 26 | 27 | @program Shader vs fs 28 | -------------------------------------------------------------------------------- /code/Samples/DDSTextureLoading/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(DDSTextureLoading windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(DDSTextureLoading.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Assets Gfx HttpFS) 6 | oryol_add_web_sample(DDSTextureLoading "Load and render various DDS texture formats" "emscripten" DDSTextureLoading.jpg "DDSTextureLoading/DDSTextureLoading.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/DDSTextureLoading/DDSTextureLoading.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/DDSTextureLoading/DDSTextureLoading.jpg -------------------------------------------------------------------------------- /code/Samples/DDSTextureLoading/shaders.glsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // DDSTextureLoading sample shaders. 3 | //------------------------------------------------------------------------------ 4 | 5 | @vs vs 6 | uniform vsParams { 7 | mat4 mvp; 8 | }; 9 | in vec4 position; 10 | in vec2 texcoord0; 11 | out vec2 uv; 12 | 13 | void main() { 14 | gl_Position = mvp * position; 15 | uv = texcoord0; 16 | } 17 | @end 18 | 19 | @fs fs 20 | uniform sampler2D tex; 21 | in vec2 uv; 22 | out vec4 fragColor; 23 | void main() { 24 | fragColor = vec4(texture(tex, uv).xyz, 1.0); 25 | } 26 | @end 27 | 28 | @program Shader vs fs 29 | -------------------------------------------------------------------------------- /code/Samples/DebugText/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(DebugText windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(DebugText.cc) 4 | fips_deps(Core Gfx Dbg) 5 | oryol_add_web_sample(DebugText "Demonstrate debug text rendering" "emscripten" DebugText.jpg "DebugText/DebugText.cc") 6 | fips_end_app() 7 | -------------------------------------------------------------------------------- /code/Samples/DebugText/DebugText.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/DebugText/DebugText.jpg -------------------------------------------------------------------------------- /code/Samples/DrawCallPerf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(DrawCallPerf windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(DrawCallPerf.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets Dbg Input) 6 | oryol_add_web_sample(DrawCallPerf "Measure draw call performance" "emscripten" DrawCallPerf.jpg "DrawCallPerf/DrawCallPerf.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/DrawCallPerf/DrawCallPerf.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/DrawCallPerf/DrawCallPerf.jpg -------------------------------------------------------------------------------- /code/Samples/DrawCallPerf/shaders.glsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // DrawCallPerf sample shaders 3 | //------------------------------------------------------------------------------ 4 | 5 | @vs vs 6 | uniform perFrameParams { 7 | mat4 mvp; 8 | }; 9 | uniform perParticleParams { 10 | vec4 translate; 11 | }; 12 | in vec4 position; 13 | in vec4 color0; 14 | out vec4 color; 15 | void main() { 16 | gl_Position = mvp * (position + translate); 17 | color = color0; 18 | } 19 | @end 20 | 21 | @fs fs 22 | in vec4 color; 23 | out vec4 fragColor; 24 | void main() { 25 | fragColor = color; 26 | } 27 | @end 28 | 29 | @program Shader vs fs 30 | -------------------------------------------------------------------------------- /code/Samples/FullscreenQuad/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(FullscreenQuad windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(FullscreenQuad.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx) 6 | oryol_add_web_sample(FullscreenQuad "Fullscreen quad with some distance field ray-marching" "emscripten" FullscreenQuad.jpg "FullscreenQuad/FullscreenQuad.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/FullscreenQuad/FullscreenQuad.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/FullscreenQuad/FullscreenQuad.jpg -------------------------------------------------------------------------------- /code/Samples/GPUParticles/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(GPUParticles windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(GPUParticles.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets Dbg) 6 | oryol_add_web_sample(GPUParticles "Fully GPU driven 3D particles" "emscripten" GPUParticles.jpg "GPUParticles/GPUParticles.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/GPUParticles/GPUParticles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/GPUParticles/GPUParticles.jpg -------------------------------------------------------------------------------- /code/Samples/GamepadExplorer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(GamepadExplorer windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(GamepadExplorer.cc) 4 | fips_deps(Gfx Dbg Input) 5 | oryol_add_web_sample(GamepadExplorer "Show raw gamepad input" "emscripten" GamepadExplorer.jpg "GamepadExplorer/GamepadExplorer.cc") 6 | fips_end_app() 7 | -------------------------------------------------------------------------------- /code/Samples/GamepadExplorer/GamepadExplorer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/GamepadExplorer/GamepadExplorer.jpg -------------------------------------------------------------------------------- /code/Samples/IOQueueSample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(IOQueueSample windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(IOQueueSample.cc) 4 | fips_deps(IO HttpFS) 5 | oryol_add_web_sample(IOQueueSample "Asynchronous file loading with IOQueue" "emscripten" none "IOQueueSample/IOQueueSample.cc") 6 | fips_end_app() 7 | -------------------------------------------------------------------------------- /code/Samples/InfiniteSpheres/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(InfiniteSpheres windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(InfiniteSpheres.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets) 6 | oryol_add_web_sample(InfiniteSpheres "Infinite recursive spheres" "emscripten" InfiniteSpheres.jpg "InfiniteSpheres/InfiniteSpheres.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/InfiniteSpheres/InfiniteSpheres.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/InfiniteSpheres/InfiniteSpheres.jpg -------------------------------------------------------------------------------- /code/Samples/InfiniteSpheres/shaders.glsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // Shaders for the InfiniteSpheres sample 3 | //------------------------------------------------------------------------------ 4 | 5 | @vs vs 6 | uniform vsParams { 7 | mat4 mvp; 8 | }; 9 | 10 | in vec4 position; 11 | in vec4 normal; 12 | in vec2 texcoord0; 13 | out vec4 nrm; 14 | out vec2 uv; 15 | void main() { 16 | gl_Position = mvp * position; 17 | nrm = normal; 18 | uv = texcoord0; 19 | } 20 | @end 21 | 22 | @fs fs 23 | uniform sampler2D tex; 24 | in vec4 nrm; 25 | in vec2 uv; 26 | out vec4 fragColor; 27 | void main() { 28 | vec4 texColor = texture(tex, uv * vec2(5.0, 3.0)); 29 | fragColor = ((nrm * 0.5) + 0.5) * 0.75 + texColor * texColor * texColor * texColor; 30 | } 31 | @end 32 | 33 | @program Shader vs fs 34 | -------------------------------------------------------------------------------- /code/Samples/Instancing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(Instancing windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(Instancing.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets Dbg Input) 6 | oryol_add_web_sample(Instancing "Instanced rendering" "emscripten" Instancing.jpg "Instancing/Instancing.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/Instancing/Instancing.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/Instancing/Instancing.jpg -------------------------------------------------------------------------------- /code/Samples/Instancing/shaders.glsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // Instancing sample shaders 3 | //------------------------------------------------------------------------------ 4 | 5 | @vs vs 6 | uniform vsParams { 7 | mat4 mvp; 8 | }; 9 | in vec4 position; 10 | in vec4 color0; 11 | in vec4 instance0; 12 | out vec4 color; 13 | void main() { 14 | gl_Position = mvp * (position + instance0); 15 | color = color0; 16 | } 17 | @end 18 | 19 | @fs fs 20 | in vec4 color; 21 | out vec4 fragColor; 22 | void main() { 23 | fragColor = color; 24 | } 25 | @end 26 | 27 | @program Shader vs fs 28 | -------------------------------------------------------------------------------- /code/Samples/MultipleRenderTarget/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(MultipleRenderTarget windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(MultipleRenderTarget.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Dbg Assets) 6 | oryol_add_web_sample(MultipleRenderTarget "Demonstrate MRT rendering" "emscripten" MultipleRenderTarget.jpg "MultipleRenderTarget/MultipleRenderTarget.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/MultipleRenderTarget/MultipleRenderTarget.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/MultipleRenderTarget/MultipleRenderTarget.jpg -------------------------------------------------------------------------------- /code/Samples/NativeTexture/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(NativeTexture windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(NativeTexture.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Dbg Assets) 6 | oryol_add_web_sample(NativeTexture "Demonstrates native 3D-API texture usage" "emscripten" NativeTexture.jpg "NativeTexture/NativeTexture.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/NativeTexture/NativeTexture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/NativeTexture/NativeTexture.jpg -------------------------------------------------------------------------------- /code/Samples/NativeTexture/shaders.glsl: -------------------------------------------------------------------------------- 1 | @vs vs 2 | uniform vsParams { 3 | mat4 mvp; 4 | }; 5 | in vec4 position; 6 | in vec2 texcoord0; 7 | out vec2 uv; 8 | 9 | void main() { 10 | gl_Position = mvp * position; 11 | uv = texcoord0; 12 | } 13 | @end 14 | 15 | @fs fs 16 | uniform sampler2D tex; 17 | in vec2 uv; 18 | out vec4 fragColor; 19 | void main() { 20 | fragColor = vec4(texture(tex, uv).xyz, 1.0); 21 | } 22 | @end 23 | 24 | @program Shader vs fs 25 | -------------------------------------------------------------------------------- /code/Samples/PackedNormals/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(PackedNormals windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(PackedNormals.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets) 6 | oryol_add_web_sample(PackedNormals "Shapes with packed vertex normals" "emscripten" PackedNormals.jpg "PackedNormals/PackedNormals.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/PackedNormals/PackedNormals.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/PackedNormals/PackedNormals.jpg -------------------------------------------------------------------------------- /code/Samples/PackedNormals/shaders.glsl: -------------------------------------------------------------------------------- 1 | @vs vs 2 | uniform params { 3 | mat4 mvp; 4 | }; 5 | 6 | in vec4 position; 7 | in vec4 normal; 8 | out vec4 nrm; 9 | 10 | void main() { 11 | gl_Position = mvp * position; 12 | nrm = normal; 13 | } 14 | @end 15 | 16 | @fs fs 17 | in vec4 nrm; 18 | out vec4 fragColor; 19 | void main() { 20 | fragColor = vec4(nrm.xyz * 0.5 + 0.5, 1.0); 21 | } 22 | @end 23 | 24 | @program Shader vs fs 25 | -------------------------------------------------------------------------------- /code/Samples/PrimitiveTypes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(PrimitiveTypes windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(PrimitiveTypes.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets Dbg Input) 6 | oryol_add_web_sample(PrimitiveTypes "Test Gfx primitive types" "emscripten" "PrimitiveTypes.jpg" "PrimitiveTypes/PrimitiveTypes.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/PrimitiveTypes/PrimitiveTypes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/PrimitiveTypes/PrimitiveTypes.jpg -------------------------------------------------------------------------------- /code/Samples/PrimitiveTypes/shaders.glsl: -------------------------------------------------------------------------------- 1 | @vs vs 2 | uniform params { 3 | mat4 mvp; 4 | float psize; 5 | }; 6 | 7 | in vec4 position; 8 | in vec4 color0; 9 | out vec4 color; 10 | 11 | void main() { 12 | gl_Position = mvp * position; 13 | gl_PointSize = psize; 14 | color = color0; 15 | } 16 | @end 17 | 18 | @fs fs 19 | in vec4 color; 20 | out vec4 fragColor; 21 | void main() { 22 | fragColor = color; 23 | } 24 | @end 25 | 26 | @program Shader vs fs 27 | -------------------------------------------------------------------------------- /code/Samples/Quad/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(Quad windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(Quad.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx) 6 | oryol_add_web_sample(Quad "Render a quad with vertex-indices" "emscripten" Quad.jpg "Quad/Quad.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/Quad/Quad.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/Quad/Quad.jpg -------------------------------------------------------------------------------- /code/Samples/Quad/shaders.glsl: -------------------------------------------------------------------------------- 1 | @vs vs 2 | in vec4 position; 3 | in vec4 color0; 4 | out vec4 color; 5 | void main() { 6 | gl_Position = position; 7 | color = color0; 8 | } 9 | @end 10 | 11 | @fs fs 12 | in vec4 color; 13 | out vec4 fragColor; 14 | void main() { 15 | fragColor = color; 16 | } 17 | @end 18 | 19 | @program Shader vs fs 20 | -------------------------------------------------------------------------------- /code/Samples/RenderToCubeMap/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(RenderToCubeMap windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(RenderToCubeMap.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets Input) 6 | oryol_add_web_sample(RenderToCubeMap "Render to cubemap faces" "emscripten" RenderToCubeMap.jpg "RenderToCubeMap/RenderToCubeMap.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/RenderToCubeMap/RenderToCubeMap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/RenderToCubeMap/RenderToCubeMap.jpg -------------------------------------------------------------------------------- /code/Samples/ResourceStress/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(ResourceStress windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(ResourceStress.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets HttpFS Dbg) 6 | oryol_add_web_sample(ResourceStress "Resource loading stresstest" "emscripten" none "ResourceStress/ResourceStress.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/ResourceStress/shaders.glsl: -------------------------------------------------------------------------------- 1 | @vs vs 2 | uniform vsParams { 3 | mat4 mvp; 4 | }; 5 | in vec4 position; 6 | in vec2 texcoord0; 7 | out vec2 uv; 8 | 9 | void main() { 10 | gl_Position = mvp * position; 11 | uv = texcoord0; 12 | } 13 | @end 14 | 15 | @fs fs 16 | uniform sampler2D tex; 17 | in vec2 uv; 18 | void main() { 19 | gl_FragColor = vec4(texture(tex, uv).xyz, 1.0); 20 | } 21 | @end 22 | 23 | @program Shader vs fs 24 | -------------------------------------------------------------------------------- /code/Samples/Sensors/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(Sensors windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(Sensors.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets Dbg Input) 6 | oryol_add_web_sample(Sensors "Device sensors sample" "emscripten" none "Sensors/Sensors.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/Sensors/shaders.glsl: -------------------------------------------------------------------------------- 1 | @vs vs 2 | uniform vsParams { 3 | mat4 mvp; 4 | }; 5 | 6 | in vec4 position; 7 | in vec4 normal; 8 | out vec4 nrm; 9 | 10 | void main() { 11 | gl_Position = mvp * position; 12 | nrm = normal; 13 | } 14 | @end 15 | 16 | @fs fs 17 | in vec4 nrm; 18 | out vec4 fragColor; 19 | void main() { 20 | fragColor = nrm * 0.5 + 0.5; 21 | } 22 | @end 23 | 24 | @program Shader vs fs 25 | -------------------------------------------------------------------------------- /code/Samples/SeparateBuffers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(SeparateBuffers windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(SeparateBuffers.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets) 6 | oryol_add_web_sample(SeparateBuffers "Test rendering from separate vertex buffers" "emscripten" SeparateBuffers.jpg "SeparateBuffers/SeparateBuffers.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/SeparateBuffers/SeparateBuffers.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/SeparateBuffers/SeparateBuffers.jpg -------------------------------------------------------------------------------- /code/Samples/SeparateBuffers/shaders.glsl: -------------------------------------------------------------------------------- 1 | @vs vs 2 | uniform params { 3 | mat4 mvp; 4 | }; 5 | 6 | in vec4 position; 7 | in vec3 color0; 8 | out vec3 color; 9 | 10 | void main() { 11 | gl_Position = mvp * position; 12 | color = color0; 13 | } 14 | @end 15 | 16 | @fs fs 17 | in vec3 color; 18 | out vec4 fragColor; 19 | void main() { 20 | fragColor = vec4(color, 1.0); 21 | } 22 | @end 23 | 24 | @program Shader vs fs 25 | -------------------------------------------------------------------------------- /code/Samples/Shapes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(Shapes windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(Shapes.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets) 6 | oryol_add_web_sample(Shapes "Shapes with random vertex colors, created with ShapeBuilder class" "emscripten" Shapes.jpg "Shapes/Shapes.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/Shapes/Shapes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/Shapes/Shapes.jpg -------------------------------------------------------------------------------- /code/Samples/Shapes/shaders.glsl: -------------------------------------------------------------------------------- 1 | @vs vs 2 | uniform params { 3 | mat4 mvp; 4 | }; 5 | 6 | in vec4 position; 7 | in vec4 color0; 8 | out vec4 color; 9 | 10 | void main() { 11 | gl_Position = mvp * position; 12 | color = color0; 13 | } 14 | @end 15 | 16 | @fs fs 17 | in vec4 color; 18 | out vec4 fragColor; 19 | void main() { 20 | fragColor = color; 21 | } 22 | @end 23 | 24 | @program Shader vs fs 25 | -------------------------------------------------------------------------------- /code/Samples/SimpleRenderTarget/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(SimpleRenderTarget windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(SimpleRenderTarget.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets) 6 | oryol_add_web_sample(SimpleRenderTarget "Demonstrate simple offscreen rendering" "emscripten" SimpleRenderTarget.jpg "SimpleRenderTarget/SimpleRenderTarget.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/SimpleRenderTarget/SimpleRenderTarget.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/SimpleRenderTarget/SimpleRenderTarget.jpg -------------------------------------------------------------------------------- /code/Samples/SimpleRenderTarget/shaders.glsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // Vertex and fragment shaders for rendering into the offscreen render target 3 | // 4 | @vs offscreenVS 5 | uniform vsParams { 6 | mat4 mvp; 7 | }; 8 | 9 | in vec4 position; 10 | in vec4 normal; 11 | out vec4 nrm; 12 | 13 | void main() { 14 | gl_Position = mvp * position; 15 | nrm = normal; 16 | } 17 | @end 18 | 19 | @fs offscreenFS 20 | in vec4 nrm; 21 | out vec4 fragColor; 22 | void main() { 23 | fragColor = vec4(nrm.xyz * 0.5 + 0.5, 1.0); 24 | } 25 | @end 26 | 27 | @program OffscreenShader offscreenVS offscreenFS 28 | 29 | //------------------------------------------------------------------------------ 30 | // Vertex and fragment shaders for rendering into the frame buffer. 31 | // 32 | @vs displayVS 33 | uniform vsParams { 34 | mat4 mvp; 35 | }; 36 | 37 | in vec4 position; 38 | in vec4 normal; 39 | in vec2 texcoord0; 40 | out vec2 uv; 41 | out vec4 nrm; 42 | 43 | void main() { 44 | gl_Position = mvp * position; 45 | uv = texcoord0; 46 | nrm = normalize(mvp * normal); 47 | } 48 | @end 49 | 50 | @fs displayFS 51 | uniform sampler2D tex; 52 | in vec2 uv; 53 | in vec4 nrm; 54 | out vec4 fragColor; 55 | void main() { 56 | vec4 c = texture(tex, uv * vec2(20.0, 10.0)); 57 | float l = clamp(dot(nrm.xyz, normalize(vec3(1.0, 1.0, -1.0))), 0.0, 1.0) * 2.0; 58 | fragColor = vec4(c.xyz * (l + 0.25), 1.0); 59 | } 60 | @end 61 | 62 | @program DisplayShader displayVS displayFS 63 | 64 | -------------------------------------------------------------------------------- /code/Samples/TestInput/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(TestInput windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(TestInput.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets Dbg Input) 6 | oryol_add_web_sample(TestInput "Test Input module functionality" "emscripten" TestInput.jpg "TestInput/TestInput.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/TestInput/TestInput.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/TestInput/TestInput.jpg -------------------------------------------------------------------------------- /code/Samples/TestInput/shaders.glsl: -------------------------------------------------------------------------------- 1 | @vs vs 2 | uniform vsParams { 3 | mat4 mvp; 4 | }; 5 | in vec4 position; 6 | in vec4 normal; 7 | out vec4 nrm; 8 | 9 | void main() { 10 | gl_Position = mvp * position; 11 | nrm = normal; 12 | } 13 | @end 14 | 15 | @fs fs 16 | in vec4 nrm; 17 | out vec4 fragColor; 18 | void main() { 19 | fragColor = vec4(nrm.xyz * 0.5 + 0.5, 1.0); 20 | } 21 | @end 22 | 23 | @program Shader vs fs 24 | -------------------------------------------------------------------------------- /code/Samples/TextureFloat/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(TextureFloat windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(TextureFloat.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Dbg) 6 | oryol_add_web_sample(TextureFloat "RGB plasma using float render texture" "emscripten" TextureFloat.jpg "TextureFloat/TextureFloat.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/TextureFloat/TextureFloat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/TextureFloat/TextureFloat.jpg -------------------------------------------------------------------------------- /code/Samples/Triangle/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(Triangle windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(Triangle.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx) 6 | oryol_add_web_sample(Triangle "The canonical triangle demo" "emscripten" Triangle.jpg "Triangle/Triangle.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/Triangle/Triangle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/Triangle/Triangle.jpg -------------------------------------------------------------------------------- /code/Samples/Triangle/shaders.glsl: -------------------------------------------------------------------------------- 1 | @vs vs 2 | in vec4 position; 3 | in vec4 color0; 4 | out vec4 color; 5 | void main() { 6 | gl_Position = position; 7 | color = color0; 8 | } 9 | @end 10 | 11 | @fs fs 12 | in vec4 color; 13 | out vec4 fragColor; 14 | void main() { 15 | fragColor = color; 16 | } 17 | @end 18 | 19 | @program Shader vs fs 20 | -------------------------------------------------------------------------------- /code/Samples/VertexTexture/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(VertexTexture windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(VertexTexture.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Assets Dbg) 6 | oryol_add_web_sample(VertexTexture "Vertex texture fetch from offscreen render target" "emscripten" VertexTexture.jpg "VertexTexture/VertexTexture.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/VertexTexture/VertexTexture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/VertexTexture/VertexTexture.jpg -------------------------------------------------------------------------------- /code/Samples/VolumeTexture/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | fips_begin_app(VolumeTexture windowed) 2 | fips_vs_warning_level(3) 3 | fips_files(VolumeTexture.cc) 4 | oryol_shader(shaders.glsl) 5 | fips_deps(Gfx Dbg Assets) 6 | oryol_add_web_sample(VolumeTexture "Demonstrate 3D texture usage" "emscripten" VolumeTexture.jpg "VolumeTexture/VolumeTexture.cc") 7 | fips_end_app() 8 | -------------------------------------------------------------------------------- /code/Samples/VolumeTexture/VolumeTexture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/code/Samples/VolumeTexture/VolumeTexture.jpg -------------------------------------------------------------------------------- /code/Samples/VolumeTexture/shaders.glsl: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // VolumeTexture sample shaders. 3 | //------------------------------------------------------------------------------ 4 | @vs vs 5 | uniform vsParams { 6 | mat4 mvp; 7 | vec4 modelEyePos; 8 | }; 9 | in vec4 position; 10 | out vec3 eyePos; 11 | out vec3 surfPos; 12 | void main() { 13 | gl_Position = mvp * position; 14 | eyePos = modelEyePos.xyz + vec3(0.5, 0.5, 0.5); 15 | surfPos = position.xyz + vec3(0.5, 0.5, 0.5); 16 | } 17 | @end 18 | 19 | //------------------------------------------------------------------------------ 20 | @fs fs 21 | uniform sampler3D tex; 22 | in vec3 eyePos; 23 | in vec3 surfPos; 24 | out vec4 fragColor; 25 | void main() { 26 | vec3 ep = eyePos; 27 | vec3 sp = surfPos; 28 | vec3 dir = normalize(sp - ep); 29 | float t = 0.0; 30 | vec4 c = vec4(0.0,0.0,0.0,0.0); 31 | for (int i = 0; i < 64; i++) { 32 | vec3 p = (sp + dir * t); 33 | c += texture(tex, p) * 0.02; 34 | t += 1.0 / 64.0; 35 | } 36 | fragColor = vec4(c.xyz, 1.0); 37 | } 38 | @end 39 | 40 | @program Shader vs fs 41 | -------------------------------------------------------------------------------- /data/RomeChurch/negx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/data/RomeChurch/negx.jpg -------------------------------------------------------------------------------- /data/RomeChurch/negy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/data/RomeChurch/negy.jpg -------------------------------------------------------------------------------- /data/RomeChurch/negz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/data/RomeChurch/negz.jpg -------------------------------------------------------------------------------- /data/RomeChurch/posx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/data/RomeChurch/posx.jpg -------------------------------------------------------------------------------- /data/RomeChurch/posy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/data/RomeChurch/posy.jpg -------------------------------------------------------------------------------- /data/RomeChurch/posz.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/data/RomeChurch/posz.jpg -------------------------------------------------------------------------------- /data/RomeChurch/readme.txt: -------------------------------------------------------------------------------- 1 | Author 2 | ====== 3 | 4 | This is the work of Emil Persson, aka Humus. 5 | http://www.humus.name 6 | 7 | 8 | 9 | License 10 | ======= 11 | 12 | This work is licensed under a Creative Commons Attribution 3.0 Unported License. 13 | http://creativecommons.org/licenses/by/3.0/ 14 | -------------------------------------------------------------------------------- /data/httptest.txt: -------------------------------------------------------------------------------- 1 | From Wikipedia, the free encyclopedia 2 | 3 | While there are no historical records, archaeological evidence shows that a fortress settlement existed between the Oka and Orlik Rivers as early as the 12th century, when the land was a part of the Principality of Chernigov. The name of the fortress is unknown; it may not have been called Oryol at the time. In the 13th century the fortress became a part of the Zvenigorod district of the Karachev Principality. In the early 15th century, the territory was conquered by the Grand Duchy of Lithuania. The city was soon abandoned by its population, after being sacked either by Lithuanians or the Golden Horde. The territory became a part of the Tsardom of Russia in the 16th century. -------------------------------------------------------------------------------- /data/lok256.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/data/lok256.jpg -------------------------------------------------------------------------------- /doc/LINKS.md: -------------------------------------------------------------------------------- 1 | ### Useful Links ### 2 | 3 | Chromium Bug Tracker: https://code.google.com/p/chromium/issues/list 4 | 5 | Firefox Bug Tracker: https://bugzilla.mozilla.org/ 6 | 7 | Chromium Profiling: http://www.chromium.org/developers/how-tos/trace-event-profiling-tool/recording-tracing-runs 8 | 9 | Pacman Info: 10 | * http://home.comcast.net/~jpittman2/pacman/pacmandossier.html 11 | * http://umlautllama.com/projects/pacdocs/ 12 | * http://www.lomont.org/Software/Games/PacMan/PacmanEmulation.pdf 13 | 14 | On parallel-task systems: 15 | * https://software.intel.com/en-us/blogs/2010/08/20/nulstein-v2-plog-presenting-through-a-blog 16 | * https://software.intel.com/en-us/articles/do-it-yourself-game-task-scheduling 17 | * http://blog.molecular-matters.com/2015/08/24/job-system-2-0-lock-free-work-stealing-part-1-basics/ 18 | * http://www.enkisoftware.com/devlogpost-20150822-1-Implementing_a_lightweight_task_scheduler.html 19 | * https://github.com/dougbinks/enkiTS 20 | 21 | Audio libs: 22 | * http://sol.gfxile.net/soloud/ 23 | * https://github.com/andrewrk/libsoundio 24 | * https://github.com/neXyon/audaspace 25 | * https://www.music.mcgill.ca/~gary/rtaudio/ 26 | -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | Run 'doxygen doxygen.conf' in here to create HTML autodocs (WIP). 2 | 3 | -------------------------------------------------------------------------------- /fips: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """fips main entry""" 3 | import os 4 | import sys 5 | import subprocess 6 | proj_path = os.path.dirname(os.path.abspath(__file__)) 7 | fips_path = os.path.dirname(proj_path) + '/fips' 8 | if not os.path.isdir(fips_path) : 9 | print("\033[93m=== cloning fips build system to '{}':\033[0m".format(fips_path)) 10 | subprocess.call(['git', 'clone', 'https://github.com/floooh/fips.git', fips_path]) 11 | sys.path.insert(0,fips_path) 12 | try : 13 | from mod import fips 14 | except ImportError : 15 | print("\033[91m[ERROR]\033[0m failed to initialize fips build system in '{}'".format(proj_path)) 16 | sys.exit(10) 17 | fips.run(fips_path, proj_path, sys.argv) 18 | -------------------------------------------------------------------------------- /fips-files/configs/d3d11-win64-vs2017-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: win64 3 | generator: Visual Studio 15 Win64 4 | build_tool: cmake 5 | build_type: Debug 6 | defines: 7 | ORYOL_USE_D3D11: ON 8 | 9 | -------------------------------------------------------------------------------- /fips-files/configs/d3d11-win64-vs2017-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: win64 3 | generator: Visual Studio 15 Win64 4 | build_tool: cmake 5 | build_type: Release 6 | defines: 7 | ORYOL_USE_D3D11: ON 8 | 9 | -------------------------------------------------------------------------------- /fips-files/configs/d3d11-win64-vscode-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: win64 3 | generator-platform: x64 4 | build_tool: vscode_cmake 5 | build_type: Debug 6 | defines: 7 | ORYOL_USE_D3D11: ON 8 | 9 | -------------------------------------------------------------------------------- /fips-files/configs/d3d11-win64-vstudio-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: win64 3 | generator-platform: x64 4 | build_tool: cmake 5 | build_type: Debug 6 | defines: 7 | ORYOL_USE_D3D11: ON 8 | 9 | -------------------------------------------------------------------------------- /fips-files/configs/d3d11-win64-vstudio-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: win64 3 | generator-platform: x64 4 | build_tool: cmake 5 | build_type: Release 6 | defines: 7 | ORYOL_USE_D3D11: ON 8 | 9 | -------------------------------------------------------------------------------- /fips-files/configs/linux-make-unittest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Unix Makefiles 4 | build_tool: make 5 | build_type: Debug 6 | defines: 7 | FIPS_EXCEPTIONS: ON 8 | FIPS_UNITTESTS: ON 9 | FIPS_UNITTESTS_HEADLESS: ON 10 | -------------------------------------------------------------------------------- /fips-files/configs/metal-ios-xcode-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: ios 3 | generator: Xcode 4 | build_tool: xcodebuild 5 | build_type: Debug 6 | cmake-toolchain: ios.toolchain.cmake 7 | defines: 8 | ORYOL_USE_METAL: ON 9 | FIPS_IOS_USE_ARC: ON 10 | 11 | -------------------------------------------------------------------------------- /fips-files/configs/metal-ios-xcode-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: ios 3 | generator: Xcode 4 | build_tool: xcodebuild 5 | build_type: Release 6 | cmake-toolchain: ios.toolchain.cmake 7 | defines: 8 | ORYOL_USE_METAL: ON 9 | FIPS_IOS_USE_ARC: ON 10 | 11 | -------------------------------------------------------------------------------- /fips-files/configs/metal-osx-make-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: osx 3 | generator: Unix Makefiles 4 | build_tool: make 5 | build_type: Debug 6 | defines: 7 | ORYOL_USE_METAL: ON 8 | FIPS_OSX_USE_ARC: ON 9 | 10 | -------------------------------------------------------------------------------- /fips-files/configs/metal-osx-make-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: osx 3 | generator: Unix Makefiles 4 | build_tool: make 5 | build_type: Release 6 | defines: 7 | ORYOL_USE_METAL: ON 8 | FIPS_OSX_USE_ARC: ON 9 | 10 | 11 | -------------------------------------------------------------------------------- /fips-files/configs/metal-osx-ninja-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: osx 3 | generator: Ninja 4 | build_tool: ninja 5 | build_type: Debug 6 | defines: 7 | ORYOL_USE_METAL: ON 8 | FIPS_OSX_USE_ARC: ON 9 | 10 | -------------------------------------------------------------------------------- /fips-files/configs/metal-osx-ninja-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: osx 3 | generator: Ninja 4 | build_tool: ninja 5 | build_type: Release 6 | defines: 7 | ORYOL_USE_METAL: ON 8 | FIPS_OSX_USE_ARC: ON 9 | 10 | 11 | -------------------------------------------------------------------------------- /fips-files/configs/metal-osx-vscode-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: osx 3 | generator: Ninja 4 | build_tool: vscode_cmake 5 | build_type: Debug 6 | defines: 7 | ORYOL_USE_METAL: ON 8 | FIPS_OSX_USE_ARC: ON 9 | 10 | -------------------------------------------------------------------------------- /fips-files/configs/metal-osx-xcode-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: osx 3 | generator: Xcode 4 | build_tool: xcodebuild 5 | build_type: Debug 6 | defines: 7 | ORYOL_USE_METAL: ON 8 | FIPS_OSX_USE_ARC: ON 9 | 10 | -------------------------------------------------------------------------------- /fips-files/configs/metal-osx-xcode-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: osx 3 | generator: Xcode 4 | build_tool: xcodebuild 5 | build_type: Release 6 | defines: 7 | ORYOL_USE_METAL: ON 8 | FIPS_OSX_USE_ARC: ON 9 | 10 | 11 | -------------------------------------------------------------------------------- /fips-files/configs/oryol-emsc-unittest.yml: -------------------------------------------------------------------------------- 1 | # this demonstrates how to add a custom config to fips projects 2 | # usually you'll want to tweak cmake-options with such 3 | # custom settings 4 | --- 5 | platform: emscripten 6 | generator: Ninja 7 | build_tool: ninja 8 | build_type: Debug 9 | defines: 10 | FIPS_UNITTESTS: ON 11 | FIPS_UNITTESTS_HEADLESS: ON 12 | -------------------------------------------------------------------------------- /fips-files/configs/oryol-osx-unittest-headless.yml: -------------------------------------------------------------------------------- 1 | # a head-less OSX Xcode unittest config for travis-ci 2 | --- 3 | platform: osx 4 | generator: Xcode 5 | build_tool: xcodebuild 6 | build_type: Debug 7 | defines: 8 | FIPS_EXCEPTIONS: ON 9 | FIPS_UNITTESTS: ON 10 | FIPS_UNITTESTS_HEADLESS: ON 11 | -------------------------------------------------------------------------------- /fips-files/configs/osx-make-unittest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: osx 3 | generator: Unix Makefiles 4 | build_tool: make 5 | build_type: Debug 6 | defines: 7 | FIPS_EXCEPTIONS: ON 8 | FIPS_UNITTESTS: ON 9 | FIPS_UNITTESTS_HEADLESS: ON 10 | 11 | -------------------------------------------------------------------------------- /fips-files/configs/wasmasmjs-make-release.yml: -------------------------------------------------------------------------------- 1 | # this builds WebAssembly with asm.js fallback, mainly meant for 2 | # https://github.com/WebAssembly/build-suite 3 | --- 4 | platform: emscripten 5 | generator: Unix Makefiles 6 | build_tool: make 7 | build_type: Release 8 | cmake-toolchain: emscripten.toolchain.cmake 9 | defines: 10 | FIPS_NO_ASSERTS_IN_RELEASE: ON 11 | FIPS_EMSCRIPTEN_USE_WASM_ASMJS: ON 12 | 13 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-clion-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Unix Makefiles 4 | build_tool: clion 5 | build_type: Debug 6 | defines: 7 | FIPS_GLFW_WAYLAND: ON 8 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-clion-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Unix Makefiles 4 | build_tool: clion 5 | build_type: Release 6 | defines: 7 | FIPS_GLFW_WAYLAND: ON 8 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-eclipse-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Eclipse CDT4 - Unix Makefiles 4 | build_tool: make 5 | build_type: Debug 6 | defines: 7 | FIPS_GLFW_WAYLAND: ON 8 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-eclipse-profiling.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Eclipse CDT4 - Unix Makefiles 4 | build_tool: make 5 | build_type: Release 6 | defines: 7 | FIPS_PROFILING: ON 8 | FIPS_GLFW_WAYLAND: ON 9 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-eclipse-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Eclipse CDT4 - Unix Makefiles 4 | build_tool: make 5 | build_type: Release 6 | defines: 7 | FIPS_GLFW_WAYLAND: ON 8 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-eclipse-unittest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Eclipse CDT4 - Unix Makefiles 4 | build_tool: make 5 | build_type: Debug 6 | defines: 7 | FIPS_UNITTESTS: ON 8 | FIPS_UNITTESTS_HEADLESS: ON 9 | FIPS_GLFW_WAYLAND: ON 10 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-make-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Unix Makefiles 4 | build_tool: make 5 | build_type: Debug 6 | defines: 7 | FIPS_GLFW_WAYLAND: ON 8 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-make-profiling.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Unix Makefiles 4 | build_tool: make 5 | build_type: Release 6 | defines: 7 | FIPS_PROFILING: ON 8 | FIPS_GLFW_WAYLAND: ON 9 | 10 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-make-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Unix Makefiles 4 | build_tool: make 5 | build_type: Release 6 | defines: 7 | FIPS_GLFW_WAYLAND: ON 8 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-make-unittest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Unix Makefiles 4 | build_tool: make 5 | build_type: Debug 6 | defines: 7 | FIPS_UNITTESTS: ON 8 | FIPS_UNITTESTS_HEADLESS: ON 9 | FIPS_GLFW_WAYLAND: ON 10 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-ninja-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Ninja 4 | build_tool: ninja 5 | build_type: Debug 6 | defines: 7 | FIPS_GLFW_WAYLAND: ON 8 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-ninja-profiling.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Ninja 4 | build_tool: ninja 5 | build_type: Release 6 | defines: 7 | FIPS_PROFILING: ON 8 | FIPS_GLFW_WAYLAND: ON 9 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-ninja-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Ninja 4 | build_tool: ninja 5 | build_type: Release 6 | defines: 7 | FIPS_GLFW_WAYLAND: ON 8 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-vscode-debug.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Ninja 4 | build_tool: vscode_cmake 5 | build_type: Debug 6 | defines: 7 | FIPS_GLFW_WAYLAND: ON 8 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-vscode-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Ninja 4 | build_tool: vscode_cmake 5 | build_type: Release 6 | defines: 7 | FIPS_GLFW_WAYLAND: ON 8 | -------------------------------------------------------------------------------- /fips-files/configs/wayland-linux-vscode-unittest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: linux 3 | generator: Ninja 4 | build_tool: vscode_cmake 5 | build_type: Debug 6 | defines: 7 | FIPS_UNITTESTS: ON 8 | FIPS_GLFW_WAYLAND: ON 9 | -------------------------------------------------------------------------------- /fips-files/configs/webgl2-emsc-ninja-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: emscripten 3 | generator: Ninja 4 | build_tool: ninja 5 | build_type: Release 6 | cmake-toolchain: emscripten.toolchain.cmake 7 | defines: 8 | FIPS_NO_ASSERTS_IN_RELEASE: ON 9 | FIPS_EMSCRIPTEN_USE_WEBGL2: ON 10 | FIPS_EMSCRIPTEN_USE_CWRAP: ON 11 | 12 | -------------------------------------------------------------------------------- /fips-files/configs/webgl2-wasm-ninja-release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | platform: emscripten 3 | generator: Ninja 4 | build_tool: ninja 5 | build_type: Release 6 | cmake-toolchain: emscripten.toolchain.cmake 7 | defines: 8 | FIPS_NO_ASSERTS_IN_RELEASE: ON 9 | FIPS_EMSCRIPTEN_USE_WASM: ON 10 | FIPS_EMSCRIPTEN_USE_WEBGL2: ON 11 | FIPS_EMSCRIPTEN_USE_CWRAP: ON 12 | 13 | -------------------------------------------------------------------------------- /fips-files/generators/README.md: -------------------------------------------------------------------------------- 1 | Generators are python scripts which generate C/C++ source code from 2 | python files in the code directory. 3 | 4 | -------------------------------------------------------------------------------- /fips-files/generators/util/__init__.py: -------------------------------------------------------------------------------- 1 | # helper modules for Oryol code generators 2 | -------------------------------------------------------------------------------- /fips-files/generators/util/shdc.py: -------------------------------------------------------------------------------- 1 | ''' 2 | wrapper-script for the oryol-shdc tool (wrapper around SPIRV-Cross) 3 | ''' 4 | import subprocess, platform, os, sys 5 | import genutil as util 6 | 7 | #------------------------------------------------------------------------------- 8 | def getToolPath() : 9 | path = os.path.dirname(os.path.abspath(__file__)) 10 | if platform.system() == 'Windows' : 11 | path += '/../../../tools/win32/' 12 | elif platform.system() == 'Darwin' : 13 | path += '/../../../tools/osx/' 14 | elif platform.system() == 'Linux' : 15 | if os.uname()[1] == 'raspberrypi' : 16 | path += '/../../../tools/raspi/' 17 | else : 18 | path += '/../../../tools/linux/' 19 | else : 20 | error("Unknown host system {}".format(platform.system())) 21 | return path + 'oryol-shdc' 22 | 23 | #------------------------------------------------------------------------------- 24 | def run(cmd): 25 | child = subprocess.Popen(cmd, stderr=subprocess.PIPE) 26 | out = '' 27 | while True : 28 | out += bytes.decode(child.stderr.read()) 29 | if child.poll() != None : 30 | break 31 | for line in out.splitlines(): 32 | util.fmtError(line, False) 33 | if child.returncode != 0: 34 | exit(child.returncode) 35 | 36 | #------------------------------------------------------------------------------- 37 | def compile(input, base_path, slangs): 38 | util.setErrorLocation(input, 0) 39 | for slang in slangs: 40 | if 'glsl' in slang: 41 | src_slang = 'glsl' 42 | else: 43 | src_slang = slang 44 | src_path = '{}.{}.spv'.format(base_path, src_slang) 45 | dst_path = '{}.{}'.format(base_path, slang) 46 | tool = getToolPath() 47 | cmd = [tool, '-spirv', src_path, '-o', dst_path, '-lang', slang] 48 | run(cmd) -------------------------------------------------------------------------------- /fips-files/verbs/testrunner.py: -------------------------------------------------------------------------------- 1 | # build a config and run all application targets 2 | 3 | from mod import log, project 4 | 5 | #------------------------------------------------------------------------------- 6 | def run(fips_dir, proj_dir, args) : 7 | if len(args) > 0 : 8 | cfg_name = args[0] 9 | project.gen(fips_dir, proj_dir, cfg_name) 10 | project.build(fips_dir, proj_dir, cfg_name) 11 | success, targets = project.get_target_list(fips_dir, proj_dir, cfg_name) 12 | if success : 13 | app_targets = [tgt for tgt in targets if targets[tgt] == 'app'] 14 | for app in app_targets : 15 | project.run(fips_dir, proj_dir, cfg_name, app, None, None) 16 | else : 17 | log.error("config name expected!") 18 | 19 | #------------------------------------------------------------------------------- 20 | def help() : 21 | log.info(log.YELLOW + 22 | 'fips testrunner [config-name]\n' + 23 | log.DEF + 24 | ' build a config and run all app targets') 25 | -------------------------------------------------------------------------------- /fips.cmd: -------------------------------------------------------------------------------- 1 | @python fips %* 2 | 3 | 4 | -------------------------------------------------------------------------------- /fips.yml: -------------------------------------------------------------------------------- 1 | # 2 | # oryol 3 | # 4 | --- 5 | imports: 6 | gliml: 7 | git: https://github.com/floooh/gliml.git 8 | fips-glm: 9 | git: https://github.com/fips-libs/fips-glm.git 10 | fips-unittestpp: 11 | git: https://github.com/floooh/fips-unittestpp.git 12 | fips-zlib: 13 | git: https://github.com/fips-libs/fips-zlib.git 14 | fips-glfw: 15 | git: https://github.com/fips-libs/fips-glfw.git 16 | fips-libcurl: 17 | git: https://github.com/floooh/fips-libcurl.git 18 | fips-remotery: 19 | git: https://github.com/fips-libs/fips-remotery.git 20 | fips-vld: 21 | git: https://github.com/floooh/fips-vld.git 22 | 23 | exports: 24 | header-dirs : 25 | - code 26 | - code/Modules 27 | modules : 28 | # engine modules 29 | Core : code/Modules/Core 30 | IO : code/Modules/IO 31 | LocalFS : code/Modules/LocalFS 32 | HttpFS : code/Modules/HttpFS 33 | Gfx : code/Modules/Gfx 34 | Resource : code/Modules/Resource 35 | Assets : code/Modules/Assets 36 | Dbg : code/Modules/Dbg 37 | Input : code/Modules/Input 38 | 39 | -------------------------------------------------------------------------------- /tools/NVIDIA_Texture_Tools_LICENSE.txt: -------------------------------------------------------------------------------- 1 | NVIDIA Texture Tools 2.0 is licensed under the MIT license. 2 | 3 | Copyright (c) 2007 NVIDIA Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person 6 | obtaining a copy of this software and associated documentation 7 | files (the "Software"), to deal in the Software without 8 | restriction, including without limitation the rights to use, 9 | copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the 11 | Software is furnished to do so, subject to the following 12 | conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 | OTHER DEALINGS IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | This directory contains a bunch of precompiled 3rd-party tools. It is not a replacement for a proper tools pipeline. 2 | 3 | ### PowerVR Texture Tools 4 | 5 | The PVRTexToolCLI is part of the PowerVR Tools Package available here: 6 | 7 | http://community.imgtec.com/developers/powervr/installers/ 8 | 9 | Please note the End User License Agreement included as text file under oryol/tools, 10 | or here: 11 | 12 | http://community.imgtec.com/developers/powervr/sdk-end-user-licence-agreement/ 13 | 14 | Also this: 15 | 16 | https://twitter.com/powervrinsider/status/474155474959761408 17 | 18 | ### NVIDIA Texture Tools 19 | 20 | The tools **nvcompress**, **nvassemble**, **nvddsinfo** have been compiled from the 21 | repository at: 22 | 23 | https://github.com/floooh/nvidia-texture-tools 24 | 25 | which is a fork of 26 | 27 | https://github.com/casseveritt/nvidia-texture-tools 28 | 29 | The nvcompress tool has been enhanced slightly to support more uncompressed RGBA formats in WebGL/OpenGLES component order. 30 | 31 | ### GLSL Reference Compiler 32 | 33 | The **glslangValidator** has been compiled unchanged from the SVN repo at: 34 | 35 | https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang 36 | 37 | See [GLSLReferenceCompiler.txt](GLSLReferenceCompiler.txt) for details. 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /tools/__init__.py: -------------------------------------------------------------------------------- 1 | # empty 2 | -------------------------------------------------------------------------------- /tools/linux/PVRTexToolCLI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/linux/PVRTexToolCLI -------------------------------------------------------------------------------- /tools/linux/glslangValidator: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/linux/glslangValidator -------------------------------------------------------------------------------- /tools/linux/nvassemble: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/linux/nvassemble -------------------------------------------------------------------------------- /tools/linux/nvcompress: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/linux/nvcompress -------------------------------------------------------------------------------- /tools/linux/nvddsinfo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/linux/nvddsinfo -------------------------------------------------------------------------------- /tools/linux/oryol-export: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/linux/oryol-export -------------------------------------------------------------------------------- /tools/linux/oryol-shdc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/linux/oryol-shdc -------------------------------------------------------------------------------- /tools/osx/PVRTexToolCLI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/PVRTexToolCLI -------------------------------------------------------------------------------- /tools/osx/astcenc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/astcenc -------------------------------------------------------------------------------- /tools/osx/composite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/composite -------------------------------------------------------------------------------- /tools/osx/convert: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/convert -------------------------------------------------------------------------------- /tools/osx/etcpack: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/etcpack -------------------------------------------------------------------------------- /tools/osx/glslangValidator: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/glslangValidator -------------------------------------------------------------------------------- /tools/osx/nvassemble: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/nvassemble -------------------------------------------------------------------------------- /tools/osx/nvcompress: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/nvcompress -------------------------------------------------------------------------------- /tools/osx/nvddsinfo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/nvddsinfo -------------------------------------------------------------------------------- /tools/osx/oryol-export: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/oryol-export -------------------------------------------------------------------------------- /tools/osx/oryol-shdc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/oryol-shdc -------------------------------------------------------------------------------- /tools/osx/spirv-cross: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/spirv-cross -------------------------------------------------------------------------------- /tools/osx/spirv-remap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/osx/spirv-remap -------------------------------------------------------------------------------- /tools/raspi/glslangValidator: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/raspi/glslangValidator -------------------------------------------------------------------------------- /tools/raspi/oryol-shdc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/raspi/oryol-shdc -------------------------------------------------------------------------------- /tools/win32/PVRTexToolCLI.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/win32/PVRTexToolCLI.exe -------------------------------------------------------------------------------- /tools/win32/glslangValidator.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/win32/glslangValidator.exe -------------------------------------------------------------------------------- /tools/win32/ninja.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/win32/ninja.exe -------------------------------------------------------------------------------- /tools/win32/nvassemble.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/win32/nvassemble.exe -------------------------------------------------------------------------------- /tools/win32/nvcompress.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/win32/nvcompress.exe -------------------------------------------------------------------------------- /tools/win32/nvddsinfo.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/win32/nvddsinfo.exe -------------------------------------------------------------------------------- /tools/win32/oryol-export.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/win32/oryol-export.exe -------------------------------------------------------------------------------- /tools/win32/oryol-shdc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/win32/oryol-shdc.exe -------------------------------------------------------------------------------- /tools/win32/spirv-cross.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/tools/win32/spirv-cross.exe -------------------------------------------------------------------------------- /web/dummy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/web/dummy.jpg -------------------------------------------------------------------------------- /web/emsc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ${name} 6 | 7 | 8 | 9 | 10 | 11 |
${name}asm.js
12 |
13 | 14 | 23 | 24 |
25 | 26 | 27 |
28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /web/ext_samples.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/web/ext_samples.jpg -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/floooh/oryol/eb08cffe1b1cb6b05ed14ec692bca9372cef064e/web/favicon.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ${doctitle} 6 | 7 | 8 | 9 | 10 | 11 |
${title}${subtitle}
12 |
13 | 22 | 26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /web/wasmsuite-readme.md: -------------------------------------------------------------------------------- 1 | ### Oryol Samples 2 | 3 | This is the complete set of Oryol samples compiled to wasm, wast and asm.js 4 | with the original emscripten shell-html files which fall back to 5 | asm.js if wasm is not available. 6 | 7 | The samples are built with Binaryen, using the method "wasm-native,asmjs". 8 | 9 | Most samples require a WebGL canvas. 10 | 11 | The original sample web page is here: http://floooh.github.io/oryol/ 12 | 13 | #### Testing 14 | 15 | The easiest way to test the samples is to start a python web server 16 | inside this directory via **python -m SimpleHTTPServer**, 17 | point a web browser to http://localhost:8000 and click on one 18 | of the HTML files. 19 | 20 | This tries to load the wasm samples, and if these are not available 21 | falls back to asm.js. 22 | 23 | The only demo that runs out of the box in a vanilla JS engine is 'hello.js': 24 | 25 | ``` 26 | > node hello.js 27 | ``` 28 | 29 | #### How to build 30 | 31 | Best built on Linux or OSX (Windows might work but is not tested with 32 | WebAssembly builds). 33 | 34 | You need **make**, **cmake**, **python** (2.7.x recommended, 3.x should work too). 35 | 36 | Get Oryol and setup emscripten with WebAssembly support as described here: 37 | 38 | http://floooh.github.io/2016/03/17/oryol-webassembly.html 39 | 40 | Build everything from inside the oryol directory with: 41 | 42 | ``` 43 | > ./fips wasmtest build 44 | ... 45 | ``` 46 | 47 | Start a browser pointing to the build result with: 48 | 49 | ``` 50 | > ./fips wasmtest serve 51 | ... 52 | ``` 53 | 54 | To find the directory with the build result: 55 | 56 | ``` 57 | > cd ../fips-deploy/oryol-wasm-buildsuite/ 58 | ``` 59 | 60 | --------------------------------------------------------------------------------