├── NuoWindowsFoundation ├── NuoUI │ ├── NuoRect.cpp │ ├── NuoMonitorScale.cpp │ ├── NuoMouse.h │ ├── NuoSlider.h │ ├── NuoMouse.cpp │ ├── NuoSlider.cpp │ ├── NuoProgressBar.h │ ├── NuoScrollView.h │ ├── NuoDropdownList.h │ ├── NuoProgressBar.cpp │ ├── NuoScrollView.cpp │ ├── NuoDropdownList.cpp │ ├── NuoWindowTypes.h │ ├── NuoView.h │ ├── NuoStrings.h │ ├── NuoOpenFileDialog.h │ ├── NuoView.cpp │ ├── FoundationResource.h │ ├── NuoAppInstance.h │ ├── NuoMonitorScale.h │ ├── DPIAware.manifest │ ├── NuoButton.h │ ├── NuoLabel.h │ ├── NuoDialog.h │ ├── NuoTimer.h │ ├── NuoListView.h │ ├── NuoTimer.cpp │ ├── NuoOpenFileDialog.cpp │ ├── NuoImage.h │ ├── NuoStrings.cpp │ ├── NuoFile.h │ ├── NuoButton.cpp │ ├── NuoAppInstance.cpp │ ├── NuoLabel.cpp │ ├── NuoMenu.h │ ├── NuoControl.h │ └── FoundationResource.rc ├── NuoModelLoader │ ├── tiny_obj_loader.cc │ ├── NuoModelLoader.h │ ├── NuoBounds.h │ ├── NuoModelLoaderGPU.h │ ├── NuoModelTextured.cpp │ ├── NuoModelLoaderGPU.cpp │ └── NuoMaterial.h ├── NuoDirect │ ├── NuoRenderPassTarget.h │ ├── NuoSize.h │ ├── NuoTexture.cpp │ ├── NuoTexture.h │ ├── NuoShader.h │ ├── NuoCommandQueue.h │ ├── NuoConstantBufferSwapChain.h │ ├── NuoResource.h │ ├── NuoResourceSwapChain.h │ ├── NuoVertexBuffer.h │ ├── NuoPipelineState.h │ ├── NuoConstantBufferSwapChain.cpp │ ├── NuoResourceSwapChain.cpp │ ├── NuoRenderTargetSwapChain.h │ ├── NuoFenceSwapChain.h │ ├── NuoDescriptorHeap.h │ ├── NuoCommandQueue.cpp │ ├── NuoResource.cpp │ ├── NuoRenderTargetSwapChain.cpp │ ├── NuoVertexBuffer.cpp │ ├── NuoSignature.h │ ├── NuoDevice.h │ ├── NuoDirectView.h │ ├── NuoRenderTarget.h │ └── NuoDescriptorHeap.cpp ├── NuoMeshes │ ├── NuoMeshBounds.cpp │ ├── NuoShaders │ │ ├── NuoTexturePixel.hlsl │ │ ├── NuoMeshTextured.h │ │ ├── NuoTextureVertex.hlsl │ │ ├── NuoMeshShaderType.h │ │ ├── NuoMeshScreenSpace.h │ │ ├── NuoMeshSimple.h │ │ ├── NuoMeshShadersCommon.h │ │ ├── NuoMeshSimpleVertex.hlsl │ │ ├── NuoMeshMaterialedVertex.hlsl │ │ ├── NuoMeshMaterialedPixel.hlsl │ │ ├── NuoMeshSimplePixel.hlsl │ │ └── NuoMeshMaterialed.h │ ├── NuoMeshBounds.h │ ├── NuoMeshSceneRoot.h │ ├── NuoMeshOptions.h │ ├── NuoCubeMesh.h │ ├── NuoCubeMesh.cpp │ ├── NuoMeshRotation.h │ ├── NuoMeshSceneRoot.cpp │ ├── NuoMeshCompound.h │ ├── NuoMeshMaterialed.h │ ├── NuoMeshRotation.cpp │ ├── NuoAuxilliaryMeshes │ │ └── NuoScreenSpaceMesh.h │ └── NuoMeshMaterialed.cpp ├── NuoShadowMap │ ├── NuoLightSource.cpp │ └── NuoLightSource.h ├── NuoUtilites │ ├── NuoDispatch.h │ ├── NuoTableExporter.h │ ├── NuoBackgroundTask.h │ ├── NuoModelArrow.h │ ├── NuoMathVector.cpp │ ├── NuoDispatch.cpp │ ├── NuoModelBoard.cpp │ ├── Win │ │ └── NuoMathVectorTypeTraitWin.hpp │ └── NuoBackgroundTask.cpp ├── NuoRender │ ├── NuoRenderPass.cpp │ ├── NuoRenderPipeline.h │ ├── NuoRenderPass.h │ ├── NuoRenderPipelinePass.cpp │ ├── NuoRenderPipelinePass.h │ └── NuoRenderPipeline.cpp └── NuoScripting │ └── NuoLua.h ├── NuoWindow ├── NuoWindow │ ├── NuoApp.h │ ├── small.ico │ ├── NuoWindow.ico │ ├── NuoWindow.rc │ ├── NuoWindow.vcxproj.user │ ├── targetver.h │ ├── framework.h │ ├── IconWindow.h │ ├── ListViewWindow.h │ ├── AppAboutDialog.h │ ├── AppAboutDialog.cpp │ ├── Resource.h │ ├── ListViewWindow.cpp │ └── IconWindow.cpp ├── Nuclear.png └── NuoWindow.sln ├── NuoDirect ├── NuoDirect │ ├── NuoDirect.h │ ├── small.ico │ ├── NuoDirect.aps │ ├── NuoDirect.ico │ ├── NuoDirect.rc │ ├── NuoDirect.vcxproj.user │ ├── targetver.h │ ├── framework.h │ ├── NuoDirectWindow.h │ ├── Resource.h │ ├── NuoDirectWindow.cpp │ ├── DirectView.h │ ├── shaders.hlsl │ └── NuoDirect.cpp └── NuoDirect.sln ├── lua ├── doc │ ├── logo.gif │ ├── osi-certified-72x60.png │ ├── index.css │ └── manual.css ├── Lua │ ├── LuaLib │ │ ├── LuaLib.cpp │ │ ├── LuaLib.vcxproj.user │ │ └── framework.h │ ├── LuaCmd │ │ ├── LuaCmd.vcxproj.user │ │ └── LuaCmd.vcxproj.filters │ └── Lua.sln ├── README └── src │ ├── lua.hpp │ ├── lundump.h │ ├── lprefix.h │ ├── lualib.h │ ├── lapi.h │ ├── lzio.c │ ├── lopnames.h │ ├── lzio.h │ ├── lstring.h │ ├── linit.c │ ├── lfunc.h │ ├── ldebug.h │ ├── ltable.h │ ├── ljumptab.h │ ├── lctype.h │ ├── lctype.c │ └── llex.h ├── NuoModelViewer ├── NuoModelViewer │ ├── ModelViewerMain.h │ ├── small.ico │ ├── NuoDirect.ico │ ├── NuoDirect.rc │ ├── ModelState │ │ ├── ModelState.h │ │ ├── ModelState.cpp │ │ ├── ModelViewConfiguration.h │ │ └── ModelViewConfiguration.cpp │ ├── Renderer │ │ ├── NotationRenderer.h │ │ ├── ModelSceneParameters.h │ │ ├── ModelViewerRenderer.h │ │ └── NotationLight.h │ ├── Resources │ │ └── NuoModelViewer.ico │ ├── NuoModelViewer.vcxproj.user │ ├── targetver.h │ ├── UserInterface │ │ ├── ModelOptionUpdate.h │ │ └── ModelOperationPanel.h │ ├── framework.h │ ├── Resource.h │ ├── ModelViewerWindow.h │ ├── ModelViewerMain.cpp │ └── ModelView.h └── NuoModelViewer.sln ├── README.md └── .gitignore /NuoWindowsFoundation/NuoUI/NuoRect.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoMonitorScale.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/NuoApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/NuoDirect.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | -------------------------------------------------------------------------------- /lua/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/lua/doc/logo.gif -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/ModelViewerMain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | -------------------------------------------------------------------------------- /NuoWindow/Nuclear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindow/Nuclear.png -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoDirect/NuoDirect/small.ico -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindow/NuoWindow/small.ico -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/NuoDirect.aps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoDirect/NuoDirect/NuoDirect.aps -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/NuoDirect.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoDirect/NuoDirect/NuoDirect.ico -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/NuoDirect.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoDirect/NuoDirect/NuoDirect.rc -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/NuoWindow.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindow/NuoWindow/NuoWindow.ico -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/NuoWindow.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindow/NuoWindow/NuoWindow.rc -------------------------------------------------------------------------------- /lua/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/lua/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoModelLoader/tiny_obj_loader.cc: -------------------------------------------------------------------------------- 1 | #define TINYOBJLOADER_IMPLEMENTATION 2 | #include "tiny_obj_loader.h" 3 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoMouse.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindowsFoundation/NuoUI/NuoMouse.h -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoSlider.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindowsFoundation/NuoUI/NuoSlider.h -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoModelViewer/NuoModelViewer/small.ico -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoMouse.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindowsFoundation/NuoUI/NuoMouse.cpp -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoSlider.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindowsFoundation/NuoUI/NuoSlider.cpp -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/NuoDirect.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoModelViewer/NuoModelViewer/NuoDirect.ico -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/NuoDirect.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoModelViewer/NuoModelViewer/NuoDirect.rc -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoProgressBar.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindowsFoundation/NuoUI/NuoProgressBar.h -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoScrollView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindowsFoundation/NuoUI/NuoScrollView.h -------------------------------------------------------------------------------- /lua/Lua/LuaLib/LuaLib.cpp: -------------------------------------------------------------------------------- 1 | // LuaLib.cpp : Defines the functions for the static library. 2 | // 3 | 4 | #include "framework.h" 5 | 6 | 7 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoDropdownList.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindowsFoundation/NuoUI/NuoDropdownList.h -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoProgressBar.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindowsFoundation/NuoUI/NuoProgressBar.cpp -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoScrollView.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindowsFoundation/NuoUI/NuoScrollView.cpp -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoDropdownList.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindowsFoundation/NuoUI/NuoDropdownList.cpp -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/ModelState/ModelState.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoModelViewer/NuoModelViewer/ModelState/ModelState.h -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoRenderPassTarget.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoWindowsFoundation/NuoDirect/NuoRenderPassTarget.h -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/ModelState/ModelState.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoModelViewer/NuoModelViewer/ModelState/ModelState.cpp -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/Renderer/NotationRenderer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoModelViewer/NuoModelViewer/Renderer/NotationRenderer.h -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/Resources/NuoModelViewer.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoModelViewer/NuoModelViewer/Resources/NuoModelViewer.ico -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NuoWindows 2 | 3 | Simple C++ class framework for Win32 and DirectX12 4 | 5 | # NuoModelViewer 6 | 7 | A renderer under construction, based on NuoWindows. 8 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/Renderer/ModelSceneParameters.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/middlefeng/NuoWindows/HEAD/NuoModelViewer/NuoModelViewer/Renderer/ModelSceneParameters.h -------------------------------------------------------------------------------- /lua/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.4.2, released on 13 Nov 2020. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /lua/Lua/LuaCmd/LuaCmd.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /lua/Lua/LuaLib/LuaLib.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/NuoDirect.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/NuoWindow.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/NuoModelViewer.vcxproj.user: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoWindowTypes.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __NUO_WINDOW_TYPES_H__ 4 | #define __NUO_WINDOW_TYPES_H__ 5 | 6 | enum NuoAlign 7 | { 8 | kNuoAlign_Left, 9 | kNuoAlign_Right, 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoSize.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __NUO_SIZE_H__ 3 | #define __NUO_SIZE_H__ 4 | 5 | 6 | #include "NuoUI/NuoRect.h" 7 | 8 | 9 | typedef NuoPoint NuoSize; 10 | 11 | 12 | #endif // !__NUO_SIZE_H__ 13 | -------------------------------------------------------------------------------- /lua/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoMeshBounds.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoMeshBounds.m 3 | // ModelViewer 4 | // 5 | // Created by Dong on 1/25/18. 6 | // Copyright © 2018 middleware. All rights reserved. 7 | // 8 | 9 | #include "NuoMeshBounds.h" 10 | 11 | -------------------------------------------------------------------------------- /lua/Lua/LuaLib/framework.h: -------------------------------------------------------------------------------- 1 | // header.h : include file for standard system include files, 2 | // or project specific include files 3 | // 4 | 5 | #pragma once 6 | 7 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | NuoModelViewer/Debug/ 2 | NuoWindow/NuoWindow/Debug/ 3 | NuoWindow/NuoWindow/NuoWindow.aps 4 | NuoDirect/Debug/ 5 | NuoDirect/NuoDirect/Debug/ 6 | NuoDirect/NuoDirect/Release/ 7 | NuoDirect/x64/Debug/ 8 | NuoDirect/x64/Release/ 9 | 10 | x64 11 | .vs 12 | 13 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoView.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "NuoControl.h" 5 | 6 | 7 | class NuoView; 8 | typedef std::shared_ptr PNuoView; 9 | 10 | 11 | class NuoView : public NuoControl 12 | { 13 | 14 | public: 15 | 16 | NuoView(const PNuoWindow& parent); 17 | 18 | void Init(); 19 | 20 | }; 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // // Including SDKDDKVer.h defines the highest available Windows platform. 4 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 5 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 6 | #include 7 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // // Including SDKDDKVer.h defines the highest available Windows platform. 4 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 5 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 6 | #include 7 | -------------------------------------------------------------------------------- /lua/doc/index.css: -------------------------------------------------------------------------------- 1 | ul { 2 | list-style-type: none ; 3 | } 4 | 5 | ul.contents { 6 | padding: 0 ; 7 | } 8 | 9 | table { 10 | border: none ; 11 | border-spacing: 0 ; 12 | border-collapse: collapse ; 13 | } 14 | 15 | td { 16 | vertical-align: top ; 17 | padding: 0 ; 18 | text-align: left ; 19 | line-height: 1.25 ; 20 | width: 15% ; 21 | } 22 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // // Including SDKDDKVer.h defines the highest available Windows platform. 4 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 5 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 6 | #include 7 | -------------------------------------------------------------------------------- /lua/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | color: gray ; 12 | float: right ; 13 | font-family: inherit ; 14 | font-style: normal ; 15 | font-size: small ; 16 | } 17 | 18 | h2:before { 19 | content: "" ; 20 | padding-right: 0em ; 21 | } 22 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoStrings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | std::wstring StringToUTF16(const std::string& s); 7 | std::string StringToUTF8(const std::wstring& s); 8 | 9 | std::string LastPathComponent(const std::string& s); 10 | std::string RemoveLastPathComponent(const std::string& s); 11 | 12 | std::wstring ErrorMessage(ID3DBlob* errorBlob); 13 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoTexturePixel.hlsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | #include "NuoMeshScreenSpace.h" 6 | 7 | 8 | Texture2D texSource : register(t0); 9 | SamplerState texSampler : register(s0); 10 | 11 | 12 | float4 main(NuoMeshScreenSpaceVertexShaderOutput inVertex) : SV_Target 13 | { 14 | float4 color = texSource.Sample(texSampler, inVertex._texCoord); 15 | return color; 16 | } 17 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoMeshTextured.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __NuoMeshTextured_h__ 4 | #define __NuoMeshTextured_h__ 5 | 6 | 7 | #include "NuoMeshShaderType.h" 8 | 9 | 10 | 11 | struct NuoMeshTexturedItem 12 | { 13 | float4 _position SHADER_SEMATIC(POSITION); 14 | float4 _normal SHADER_SEMATIC(NORMAL); 15 | float2 _texCoord SHADER_SEMATIC(TEX_COORD); 16 | }; 17 | 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoOpenFileDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | #include 5 | #include 6 | 7 | #include "NuoWindow.h" 8 | 9 | 10 | class NuoFileDialog 11 | { 12 | 13 | OPENFILENAME _ofn; 14 | wchar_t _szFile[256]; 15 | 16 | public: 17 | 18 | NuoFileDialog(); 19 | 20 | void Open(const PNuoWindow& owner); 21 | void Save(const PNuoWindow& owner); 22 | std::string FilePath() const; 23 | 24 | }; 25 | 26 | 27 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/UserInterface/ModelOptionUpdate.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelOptionUpdate.h 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 5/8/22. 6 | // Copyright © 2022 Dong Feng. All rights reserved. 7 | // 8 | 9 | 10 | 11 | #ifndef __MODEL_OPTION_UPDATE_H__ 12 | #define __MODEL_OPTION_UPDATE_H__ 13 | 14 | 15 | class ModelOptionUpdate 16 | { 17 | public: 18 | virtual void ModelOptionUpdated() = 0; 19 | }; 20 | 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/framework.h: -------------------------------------------------------------------------------- 1 | // header.h : include file for standard system include files, 2 | // or project specific include files 3 | // 4 | 5 | #pragma once 6 | 7 | #include "targetver.h" 8 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 9 | // Windows Header Files 10 | #include 11 | // C RunTime Header Files 12 | #include 13 | #include 14 | #include 15 | #include 16 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/framework.h: -------------------------------------------------------------------------------- 1 | // header.h : include file for standard system include files, 2 | // or project specific include files 3 | // 4 | 5 | #pragma once 6 | 7 | #include "targetver.h" 8 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 9 | // Windows Header Files 10 | #include 11 | // C RunTime Header Files 12 | #include 13 | #include 14 | #include 15 | #include 16 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoTextureVertex.hlsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #include "NuoMeshScreenSpace.h" 5 | 6 | 7 | 8 | NuoMeshScreenSpaceVertexShaderOutput main(NuoMeshScreenSpaceItem v) 9 | { 10 | NuoMeshScreenSpaceVertexShaderOutput outVertex; 11 | 12 | outVertex._position = v._position; 13 | outVertex._position.z = 1.0; 14 | outVertex._position.w = 1.0; 15 | outVertex._texCoord = v._texCoord.xy; 16 | 17 | return outVertex; 18 | } 19 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoMeshBounds.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoMeshBounds.h 3 | // ModelViewer 4 | // 5 | // Created by Dong on 1/25/18. 6 | // Copyright © 2018 middleware. All rights reserved. 7 | // 8 | 9 | #ifndef __MESH_BOUNDS_H__ 10 | #define __MESH_BOUNDS_H__ 11 | 12 | 13 | #include "NuoModelLoader/NuoBounds.h" 14 | 15 | 16 | class NuoMeshBounds 17 | { 18 | public: 19 | NuoBounds boundingBox; 20 | NuoSphere boundingSphere; 21 | }; 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/framework.h: -------------------------------------------------------------------------------- 1 | // header.h : include file for standard system include files, 2 | // or project specific include files 3 | // 4 | 5 | #pragma once 6 | 7 | #include "targetver.h" 8 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 9 | // Windows Header Files 10 | #include 11 | // C RunTime Header Files 12 | #include 13 | #include 14 | #include 15 | #include 16 | -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/NuoDirectWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NuoWindow.h" 4 | #include "DirectView.h" 5 | #include 6 | 7 | class NuoDirectWindow : public NuoWindow 8 | { 9 | 10 | std::function _onPaint; 11 | PDirectView _dxView; 12 | 13 | public: 14 | 15 | void Init(); 16 | 17 | NuoDirectWindow(const std::string& title); 18 | virtual void OnPaint(); 19 | 20 | }; 21 | 22 | 23 | 24 | typedef std::shared_ptr PNuoDirectWindow; 25 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoMeshShaderType.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __NUOMESHSHADERMESH_H__ 4 | #define __NUOMESHSHADERMESH_H__ 5 | 6 | #if __cplusplus 7 | 8 | #include 9 | 10 | typedef DirectX::XMVECTOR float4; 11 | typedef DirectX::XMFLOAT3 float3; 12 | typedef DirectX::XMFLOAT2 float2; 13 | 14 | typedef DirectX::XMMATRIX matrix; 15 | 16 | #define SHADER_SEMATIC(name) 17 | 18 | #else 19 | 20 | #define SHADER_SEMATIC(name) : name 21 | 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/IconWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NuoWindow.h" 4 | 5 | #include "NuoButton.h" 6 | #include "NuoLabel.h" 7 | 8 | 9 | class IconWindow : public NuoWindow 10 | { 11 | std::weak_ptr _appWindow; 12 | PNuoButton _loadButton; 13 | PNuoButton _saveButton; 14 | PNuoLabel _iconLabel; 15 | 16 | public: 17 | IconWindow(const PNuoWindow& appWindow); 18 | 19 | void Init(); 20 | NuoRect PreferredRect() const; 21 | }; 22 | 23 | 24 | typedef std::shared_ptr PIconWindow; 25 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/ListViewWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NuoWindow.h" 4 | 5 | #include "NuoButton.h" 6 | #include "NuoListView.h" 7 | 8 | 9 | 10 | class ListViewWindow : public NuoWindow 11 | { 12 | std::weak_ptr _appWindow; 13 | PNuoButton _loadButton; 14 | PNuoListView _listView; 15 | 16 | public: 17 | ListViewWindow(const PNuoWindow& appWindow); 18 | 19 | void Init(); 20 | NuoRect PreferredRect() const; 21 | }; 22 | 23 | 24 | typedef std::shared_ptr PListViewWindow; 25 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoShadowMap/NuoLightSource.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoLightSource.m 3 | // ModelViewer 4 | // 5 | // Created by middleware on 11/19/16. 6 | // Copyright © 2020 middleware. All rights reserved. 7 | // 8 | 9 | #include "NuoLightSource.h" 10 | 11 | 12 | NuoLightSource::NuoLightSource() 13 | : _lightDirection(NuoMatrixFloat44Identity), 14 | _lightingIrradiance(0), 15 | _lightingSpecular(0), 16 | _enableShadow(0), 17 | _shadowSoften(0), 18 | _shadowOccluderRadius(0), 19 | _shadowBias(0) 20 | { 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoView.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoView.h" 4 | #include "NuoAppInstance.h" 5 | #include 6 | 7 | NuoView::NuoView(const PNuoWindow& parent) 8 | : NuoControl("", parent) 9 | { 10 | _hWnd = CreateWindow(kClassName, L"", WS_VISIBLE | WS_CHILD, 11 | CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, parent->Handle(), nullptr, 12 | NuoAppInstance::GetInstance()->Instance(), nullptr); 13 | 14 | SetWindowLongPtr(_hWnd, kWindowPtr, (LONG_PTR)this); 15 | } 16 | 17 | 18 | 19 | void NuoView::Init() 20 | { 21 | } 22 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/AppAboutDialog.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include "NuoDialog.h" 5 | #include "NuoButton.h" 6 | #include "NuoLabel.h" 7 | 8 | 9 | class AppAboutDialog : public NuoDialog 10 | { 11 | 12 | PNuoLabel _label; 13 | PNuoLabel _labelCopyright; 14 | 15 | public: 16 | 17 | AppAboutDialog(const std::string& title); 18 | virtual ~AppAboutDialog(); 19 | 20 | virtual void InitDialog() override; 21 | virtual void UpdateLayout() override; 22 | 23 | }; 24 | 25 | 26 | typedef std::shared_ptr PAppAboutDialog; 27 | 28 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/FoundationResource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by FoundationResource.rc 4 | 5 | #define IDD_DIALOG_FOUNDATION 102 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 101 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoMeshScreenSpace.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __NuoMeshScreenSpace_h__ 4 | #define __NuoMeshScreenSpace_h__ 5 | 6 | 7 | #include "NuoMeshShaderType.h" 8 | 9 | 10 | 11 | struct NuoMeshScreenSpaceItem 12 | { 13 | float4 _position SHADER_SEMATIC(POSITION); 14 | float2 _texCoord SHADER_SEMATIC(TEX_COORD); 15 | }; 16 | 17 | struct NuoMeshScreenSpaceVertexShaderOutput 18 | { 19 | float2 _texCoord SHADER_SEMATIC(TEX_COORD); 20 | float4 _position SHADER_SEMATIC(SV_Position); 21 | }; 22 | 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoAppInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class NuoAppInstance 7 | { 8 | HINSTANCE _instance; 9 | int _cmdShow; 10 | 11 | static ULONG_PTR _gdiToken; 12 | 13 | NuoAppInstance(HINSTANCE hInstance, int cmdShow); 14 | 15 | public: 16 | 17 | static void Init(HINSTANCE hInstance, int cmdShow); 18 | static void UnInit(); 19 | static NuoAppInstance* GetInstance(); 20 | 21 | HINSTANCE Instance(); 22 | std::string ModulePath(); 23 | int CommandShow(); 24 | static void Exit(); 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoMeshSimple.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __NuoMeshSimple_h__ 4 | #define __NuoMeshSimple_h__ 5 | 6 | 7 | #include "NuoMeshShaderType.h" 8 | 9 | 10 | 11 | struct NuoMeshSimpleItem 12 | { 13 | float4 _position SHADER_SEMATIC(POSITION); 14 | float4 _normal SHADER_SEMATIC(NORMAL); 15 | }; 16 | 17 | struct NuoMeshSimpleVertexShaderOutput 18 | { 19 | float4 _position SHADER_SEMATIC(SV_Position); 20 | float3 _eye SHADER_SEMATIC(EYE_DIRECTION); 21 | float4 _normal SHADER_SEMATIC(NORMAL); 22 | }; 23 | 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoMonitorScale.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | 8 | template 9 | NuoPoint MonitorDPI(const NuoPoint& point) 10 | { 11 | POINT pt; 12 | pt.x = (LONG)point.X(); 13 | pt.y = (LONG)point.Y(); 14 | 15 | UINT dpiX, dpiY; 16 | HMONITOR monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); 17 | GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &dpiX, &dpiY); 18 | 19 | NuoPoint scaleF(1, 1); 20 | scaleF.SetX((double)dpiX / 100.0); 21 | scaleF.SetY((double)dpiY / 100.0); 22 | 23 | return scaleF; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoTexture.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoTexture.h" 4 | #include "NuoCommandBuffer.h" 5 | 6 | 7 | NuoTexture::NuoTexture() 8 | { 9 | } 10 | 11 | 12 | NuoTexture::~NuoTexture() 13 | { 14 | } 15 | 16 | 17 | 18 | void NuoTexture::Upload(const PNuoCommandBuffer& commandBuffer, const std::vector& data, 19 | std::vector& intermediate) 20 | { 21 | PNuoCommandEncoder encoder = commandBuffer->CreateRenderPassEncoder(); 22 | encoder->CopyTexture(data, intermediate, std::dynamic_pointer_cast(shared_from_this())); 23 | encoder->EndEncoding(); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoMeshSceneRoot.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "NuoMeshCompound.h" 12 | 13 | 14 | 15 | class NuoMesh; 16 | typedef std::shared_ptr PNuoMesh; 17 | 18 | 19 | 20 | class NuoMeshSceneRoot : public NuoMeshCompound 21 | { 22 | 23 | protected: 24 | 25 | public: 26 | 27 | NuoMeshSceneRoot(); 28 | NuoMeshSceneRoot(const std::vector& meshes); 29 | 30 | void ReplaceMesh(const PNuoMesh& older, const PNuoMesh& replacer); 31 | 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoMeshOptions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoMeshOption.h 3 | // ModelViewer 4 | // 5 | // Created by middleware on 9/15/16. 6 | // Copyright © 2016 middleware. All rights reserved. 7 | // 8 | 9 | 10 | #ifndef __NuoMeshOption_h__ 11 | #define __NuoMeshOption_h__ 12 | 13 | class NuoMeshOptions 14 | { 15 | public: 16 | bool _textured; 17 | bool _textureEmbedMaterialTransparency; 18 | bool _texturedBump; 19 | 20 | bool _basicMaterialized; 21 | bool _combineByMaterials; 22 | 23 | bool _physicallyReflection; 24 | 25 | unsigned int _frameCount; 26 | unsigned int _sampleCount; 27 | }; 28 | 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoShadowMap/NuoLightSource.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoLightSource.h 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 11/19/16. 6 | // Ported: 9/22/21 7 | // Copyright © 2021 Dong Feng. All rights reserved. 8 | // 9 | 10 | 11 | #ifndef __NUO_LIGHT_SOURCE_H__ 12 | #define __NUO_LIGHT_SOURCE_H__ 13 | 14 | 15 | #include "NuoMathVector.h" 16 | 17 | 18 | struct NuoLightSource 19 | { 20 | NuoMatrixFloat44 _lightDirection; 21 | 22 | float _lightingIrradiance; 23 | float _lightingSpecular; 24 | 25 | bool _enableShadow; 26 | float _shadowSoften; 27 | float _shadowOccluderRadius; 28 | float _shadowBias; 29 | 30 | NuoLightSource(); 31 | }; 32 | 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoTexture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "NuoResource.h" 12 | 13 | 14 | class NuoCommandBuffer; 15 | typedef std::shared_ptr PNuoCommandBuffer; 16 | 17 | 18 | 19 | class NuoTexture : public NuoResource 20 | { 21 | 22 | public: 23 | 24 | NuoTexture(); 25 | virtual ~NuoTexture(); 26 | 27 | void Upload(const PNuoCommandBuffer& commandBuffe, const std::vector& data, std::vector& intermediate); 28 | 29 | friend class NuoSwapChain; 30 | friend class NuoDevice; 31 | 32 | }; 33 | 34 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/DPIAware.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | true 11 | PerMonitorV2 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoButton.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "NuoRect.h" 11 | #include "NuoControl.h" 12 | 13 | 14 | class NuoDialog; 15 | typedef std::shared_ptr PNuoDialog; 16 | 17 | 18 | class NuoButton : public NuoControl 19 | { 20 | 21 | protected: 22 | 23 | NuoButton(const PNuoDialog& parent, int controlID); 24 | 25 | public: 26 | 27 | NuoButton(const PNuoWindow& parent, const std::string& title); 28 | virtual ~NuoButton(); 29 | 30 | void Init(int controlID); 31 | 32 | 33 | friend NuoDialog; 34 | 35 | }; 36 | 37 | 38 | typedef std::shared_ptr PNuoButton; 39 | 40 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoCubeMesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "NuoMeshes/NuoMesh.h" 13 | #include "NuoUtilites/NuoModelBoard.h" 14 | 15 | 16 | 17 | class NuoCubeMesh; 18 | typedef std::shared_ptr PNuoCubeMesh; 19 | 20 | 21 | class NuoCubeMesh : public NuoMeshSimple 22 | { 23 | 24 | public: 25 | 26 | NuoCubeMesh() = default; 27 | 28 | void Init(const PNuoCommandBuffer& commandBuffer, 29 | unsigned int frameCount, 30 | std::vector& intermediate, 31 | float width, float height, float depth, DXGI_FORMAT format); 32 | 33 | }; 34 | 35 | 36 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoMeshShadersCommon.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __MESH_SHADERS_COMMON_H__ 4 | #define __MESH_SHADERS_COMMON_H__ 5 | 6 | #include "NuoUniforms.h" 7 | 8 | 9 | struct Material 10 | { 11 | float3 diffuseColor; 12 | float3 specularColor; 13 | float specularPower; 14 | }; 15 | 16 | 17 | 18 | inline float3 specular_common(float3 materialSpecularColor, float materialSpecularPower, 19 | NuoLightParameterUniformField lightParams, 20 | float3 normal, float3 halfway, float cosTheta) 21 | { 22 | float cosNHPower = pow(saturate(dot(normal, halfway)), materialSpecularPower); 23 | return 0.5 * cosNHPower * cosTheta * lightParams.irradiance; 24 | } 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoCubeMesh.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoCubeMesh.h" 4 | #include "NuoAppInstance.h" 5 | 6 | #include "NuoDirect/NuoShader.h" 7 | #include "NuoDirect/NuoResourceSwapChain.h" 8 | 9 | #include "NuoStrings.h" 10 | #include "NuoFile.h" 11 | 12 | #include "NuoModelLoader/NuoModelLoader.h" 13 | 14 | 15 | 16 | void NuoCubeMesh::Init(const PNuoCommandBuffer& commandBuffer, 17 | unsigned int frameCount, 18 | std::vector& intermediate, 19 | float width, float height, float depth, DXGI_FORMAT format) 20 | { 21 | PNuoModelBoard board = std::make_shared(width, height, depth); 22 | board->CreateBuffer(); 23 | 24 | NuoMeshSimple::Init(commandBuffer, frameCount, intermediate, board, format); 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoLabel.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "NuoRect.h" 11 | #include "NuoControl.h" 12 | #include "NuoImage.h" 13 | 14 | 15 | class NuoDialog; 16 | typedef std::shared_ptr PNuoDialog; 17 | 18 | 19 | class NuoLabel : public NuoControl 20 | { 21 | 22 | PNuoImage _image; 23 | 24 | public: 25 | 26 | NuoLabel(const PNuoWindow& parent); 27 | virtual ~NuoLabel(); 28 | 29 | void Init(bool image); 30 | void SetImage(const PNuoImage& image); 31 | PNuoImage Image() const; 32 | 33 | virtual void SetText(const std::string& text) override; 34 | 35 | friend NuoDialog; 36 | 37 | }; 38 | 39 | 40 | typedef std::shared_ptr PNuoLabel; 41 | 42 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoMeshSimpleVertex.hlsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | #define __SHADER_REGISTERS__ 1 4 | 5 | #include "NuoUniforms.h" 6 | #include "NuoMeshSimple.h" 7 | 8 | 9 | NuoMeshSimpleVertexShaderOutput main(NuoMeshSimpleItem v) 10 | { 11 | NuoMeshSimpleVertexShaderOutput outVertex; 12 | 13 | float4 meshPosition = mul(meshUniforms.transform, v._position); 14 | float4 eyePosition = mul(uniforms.viewMatrixInverse, float4(0.0, 0.0, 0.0, 1.0)); 15 | 16 | outVertex._position = mul(uniforms.viewProjectionMatrix, meshPosition); 17 | outVertex._eye = eyePosition.xyz - meshPosition.xyz; 18 | 19 | matrix normalMatrix = meshUniforms.normalTransform; 20 | normalMatrix[3] = float4(0, 0, 0, 1); 21 | outVertex._normal = mul(normalMatrix, v._normal); 22 | 23 | return outVertex; 24 | } 25 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoShader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include "NuoDevice.h" 14 | 15 | class NuoShader; 16 | typedef std::shared_ptr PNuoShader; 17 | typedef std::weak_ptr WPNuoShader; 18 | 19 | 20 | class NuoShader 21 | { 22 | 23 | Microsoft::WRL::ComPtr _dxShaderBlob; 24 | 25 | 26 | public: 27 | 28 | enum Type 29 | { 30 | kNuoShader_Vertex, 31 | kNuoShader_Pixel, 32 | kNuoShader_Lib, 33 | }; 34 | 35 | NuoShader(const std::string& source, 36 | const std::string& name, 37 | NuoShader::Type type, const std::string entryPoint); 38 | 39 | D3D12_SHADER_BYTECODE ByteCode(); 40 | 41 | }; 42 | 43 | -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by NuoDirect.rc 4 | 5 | #define IDS_APP_TITLE 103 6 | 7 | #define IDR_MAINFRAME 128 8 | #define IDD_NUODIRECT_DIALOG 102 9 | #define IDD_ABOUTBOX 103 10 | #define IDM_ABOUT 104 11 | #define IDM_EXIT 105 12 | #define IDI_NUODIRECT 107 13 | #define IDI_SMALL 108 14 | #define IDC_NUODIRECT 109 15 | #define IDC_MYICON 2 16 | #ifndef IDC_STATIC 17 | #define IDC_STATIC -1 18 | #endif 19 | // Next default values for new objects 20 | // 21 | #ifdef APSTUDIO_INVOKED 22 | #ifndef APSTUDIO_READONLY_SYMBOLS 23 | 24 | #define _APS_NO_MFC 130 25 | #define _APS_NEXT_RESOURCE_VALUE 129 26 | #define _APS_NEXT_COMMAND_VALUE 32771 27 | #define _APS_NEXT_CONTROL_VALUE 1000 28 | #define _APS_NEXT_SYMED_VALUE 110 29 | #endif 30 | #endif 31 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoMeshRotation.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoMeshRotation.h 3 | // ModelViewer 4 | // 5 | // Created by middleware on 2/2/17. 6 | // Copyright © 2017 middleware. All rights reserved. 7 | // 8 | 9 | 10 | #ifndef __NUOMESHROTATION_H__ 11 | #define __NUOMESHROTATION_H__ 12 | 13 | 14 | #include "NuoMathVector.h" 15 | 16 | 17 | class NuoMeshRotation 18 | { 19 | 20 | private: 21 | float _radius; 22 | NuoMatrixFloat44 _cachedResult; 23 | 24 | void GenerateMatrices(); 25 | 26 | public: 27 | NuoVectorFloat3 _transformVector; 28 | NuoVectorFloat3 _axis; 29 | 30 | NuoMeshRotation(); 31 | NuoMeshRotation(const NuoMeshRotation& r); 32 | 33 | void SetRadius(float radius); 34 | float Radius() const { return _radius; } 35 | const NuoMatrixFloat44& RotationMatrix() const; 36 | 37 | }; 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoDialog.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | #include 6 | 7 | #include "NuoWindow.h" 8 | 9 | 10 | class NuoDialogProc; 11 | class NuoButton; 12 | 13 | class NuoDialog : public NuoWindow 14 | { 15 | long _x; 16 | long _y; 17 | long _cx; 18 | long _cy; 19 | 20 | std::shared_ptr _okButton; 21 | std::shared_ptr _cancelButton; 22 | 23 | bool _showCancel; 24 | 25 | public: 26 | 27 | NuoDialog(const std::string& title); 28 | 29 | void SetPosition(const NuoRect& pos); 30 | void SetPosition(long x, long y, long cx, long cy); 31 | void DoModal(const PNuoWindow& parent); 32 | 33 | virtual void InitDialog(); 34 | virtual void UpdateLayout(); 35 | 36 | void SetShowCancel(bool show); 37 | 38 | friend NuoDialogProc; 39 | 40 | }; 41 | 42 | 43 | typedef std::shared_ptr PNuoDialog; -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoTimer.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | class NuoWindow; 13 | typedef std::shared_ptr PNuoWindow; 14 | 15 | class NuoTimer; 16 | typedef std::shared_ptr PNuoTimer; 17 | typedef std::weak_ptr WPNuoTimer; 18 | 19 | 20 | class NuoTimer : std::enable_shared_from_this 21 | { 22 | public: 23 | 24 | typedef std::function Func; 25 | 26 | UINT_PTR _id; 27 | 28 | unsigned int _interval; 29 | Func _function; 30 | 31 | NuoTimer(unsigned int _interval, Func timerFunc); 32 | 33 | public: 34 | 35 | friend class NuoWindow; 36 | 37 | static PNuoTimer MakeTimer(unsigned int interval, Func timeFunc); 38 | virtual bool OnTimer(); 39 | 40 | virtual ~NuoTimer(); 41 | }; 42 | 43 | 44 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/AppAboutDialog.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "AppAboutDialog.h" 3 | 4 | 5 | AppAboutDialog::AppAboutDialog(const std::string& title) 6 | : NuoDialog(title) 7 | { 8 | } 9 | 10 | 11 | AppAboutDialog::~AppAboutDialog() 12 | { 13 | } 14 | 15 | 16 | void AppAboutDialog::InitDialog() 17 | { 18 | NuoDialog::InitDialog(); 19 | 20 | NuoRect pos(20, 20, 98, 15); 21 | 22 | _label = std::make_shared(shared_from_this()); 23 | _label->Init(false); 24 | _label->SetText("Nuo Window"); 25 | _label->SetPosition(pos, false); 26 | 27 | pos.SetY((pos.Y() + pos.H() + 6)); 28 | _labelCopyright = std::make_shared(shared_from_this()); 29 | _labelCopyright->Init(false); 30 | _labelCopyright->SetText("Copyright (c) 2020"); 31 | _labelCopyright->SetPosition(pos, false); 32 | 33 | SetShowCancel(false); 34 | } 35 | 36 | void AppAboutDialog::UpdateLayout() 37 | { 38 | NuoDialog::UpdateLayout(); 39 | } -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by NuoDirect.rc 4 | 5 | #define IDS_APP_TITLE 103 6 | 7 | #define IDR_MAINFRAME 128 8 | #define IDD_NUODIRECT_DIALOG 102 9 | #define IDD_ABOUTBOX 103 10 | #define IDM_ABOUT 104 11 | #define IDM_EXIT 105 12 | #define IDM_FILE_OPEN 501 13 | #define IDC_DEVICE_LIST 601 14 | #define IDI_NUODIRECT 107 15 | #define IDI_SMALL 108 16 | #define IDC_NUODIRECT 109 17 | #define IDC_MYICON 2 18 | #ifndef IDC_STATIC 19 | #define IDC_STATIC -1 20 | #endif 21 | // Next default values for new objects 22 | // 23 | #ifdef APSTUDIO_INVOKED 24 | #ifndef APSTUDIO_READONLY_SYMBOLS 25 | 26 | #define _APS_NO_MFC 130 27 | #define _APS_NEXT_RESOURCE_VALUE 129 28 | #define _APS_NEXT_COMMAND_VALUE 32771 29 | #define _APS_NEXT_CONTROL_VALUE 1000 30 | #define _APS_NEXT_SYMED_VALUE 110 31 | #endif 32 | #endif 33 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoMeshSceneRoot.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoMeshSceneRoot.h" 4 | 5 | 6 | NuoMeshSceneRoot::NuoMeshSceneRoot() 7 | : NuoMeshCompound({}) 8 | { 9 | } 10 | 11 | 12 | NuoMeshSceneRoot::NuoMeshSceneRoot(const std::vector& meshes) 13 | : NuoMeshCompound(meshes) 14 | { 15 | } 16 | 17 | 18 | void NuoMeshSceneRoot::ReplaceMesh(const PNuoMesh& meshOld, const PNuoMesh& replacer) 19 | { 20 | bool haveReplaced = false; 21 | 22 | // put the main model at the end of the draw queue, 23 | // for now it is the only one has transparency 24 | // 25 | 26 | for (unsigned int i = 0; i < _meshes.size(); ++i) 27 | { 28 | if (_meshes[i] == meshOld) 29 | { 30 | _meshes[i] = replacer; 31 | haveReplaced = true; 32 | 33 | break; 34 | } 35 | } 36 | 37 | if (!haveReplaced) 38 | _meshes.push_back(replacer); 39 | } 40 | 41 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoMeshMaterialedVertex.hlsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | #define __SHADER_REGISTERS__ 1 4 | 5 | #include "NuoUniforms.h" 6 | #include "NuoMeshMaterialed.h" 7 | 8 | 9 | 10 | NuoMaterialedBasicVertexOutput main(NuoMaterialedBasicItem v) 11 | { 12 | NuoMaterialedBasicVertexOutput outVertex; 13 | 14 | float4 meshPosition = mul(meshUniforms.transform, v._position); 15 | float4 eyePosition = mul(uniforms.viewMatrixInverse, float4(0.0, 0.0, 0.0, 1.0)); 16 | 17 | outVertex._position = mul(uniforms.viewProjectionMatrix, meshPosition); 18 | outVertex._eye = eyePosition.xyz - meshPosition.xyz; 19 | outVertex._diffuse = v._diffuse; 20 | outVertex._shinessDisolveIllum = v._shinessDisolveIllum; 21 | 22 | matrix normalMatrix = meshUniforms.normalTransform; 23 | normalMatrix[3] = float4(0, 0, 0, 1); 24 | outVertex._normal = mul(normalMatrix, v._normal); 25 | 26 | return outVertex; 27 | } 28 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoCommandQueue.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "NuoDirect/NuoDevice.h" 12 | 13 | class NuoCommandQueue; 14 | typedef std::shared_ptr PNuoCommandQueue; 15 | 16 | class NuoCommandBuffer; 17 | typedef std::shared_ptr PNuoCommandBuffer; 18 | 19 | 20 | class NuoCommandQueue : public std::enable_shared_from_this 21 | { 22 | 23 | PNuoDevice _device; 24 | 25 | Microsoft::WRL::ComPtr _dxQueue; 26 | std::vector _pendingCommandBuffers; 27 | 28 | public: 29 | 30 | NuoCommandQueue(const PNuoDevice& device); 31 | PNuoCommandBuffer CreateCommandBuffer(); 32 | 33 | PNuoDevice Device() const; 34 | void ReleasePendingCommandBuffers(); 35 | 36 | ID3D12CommandQueue* DxQueue() const; 37 | 38 | }; 39 | 40 | 41 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoListView.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "NuoRect.h" 11 | #include "NuoControl.h" 12 | #include "NuoImage.h" 13 | 14 | #include "NuoWindowTypes.h" 15 | 16 | 17 | class NuoDialog; 18 | class NuoListView; 19 | typedef std::shared_ptr PNuoListView; 20 | 21 | 22 | 23 | enum NuoListProperty 24 | { 25 | kNuoList_Checkbox = 1, 26 | kNuoList_Edit = 1 << 1, 27 | }; 28 | 29 | 30 | 31 | class NuoListView : public NuoControl 32 | { 33 | 34 | public: 35 | 36 | NuoListView(const PNuoWindow& parent); 37 | virtual ~NuoListView(); 38 | 39 | void Init(int controlID, int properties); 40 | void AddColumn(unsigned int index, const std::string& title, 41 | unsigned int width, NuoAlign align); 42 | void AddItem(unsigned int index, unsigned int col, const std::string& str); 43 | 44 | friend NuoDialog; 45 | 46 | }; 47 | 48 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by NuoWindow.rc 4 | 5 | #define IDS_APP_TITLE 103 6 | 7 | #define IDR_MAINFRAME 128 8 | #define IDD_NUOWINDOW_DIALOG 102 9 | #define IDD_ABOUTBOX 103 10 | #define IDM_ABOUT 104 11 | #define IDM_EXIT 105 12 | #define IDM_ICONTOOLS 201 13 | #define IDM_LISTVIEW 202 14 | 15 | #define IDB_LOADICON 301 16 | #define IDB_SAVEICON 302 17 | 18 | #define IDI_NUOWINDOW 107 19 | #define IDI_SMALL 108 20 | #define IDC_NUOWINDOW 109 21 | #define IDC_MYICON 2 22 | #ifndef IDC_STATIC 23 | #define IDC_STATIC -1 24 | #endif 25 | // Next default values for new objects 26 | // 27 | #ifdef APSTUDIO_INVOKED 28 | #ifndef APSTUDIO_READONLY_SYMBOLS 29 | 30 | #define _APS_NO_MFC 130 31 | #define _APS_NEXT_RESOURCE_VALUE 129 32 | #define _APS_NEXT_COMMAND_VALUE 32771 33 | #define _APS_NEXT_CONTROL_VALUE 1000 34 | #define _APS_NEXT_SYMED_VALUE 110 35 | #endif 36 | #endif 37 | -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/NuoDirectWindow.cpp: -------------------------------------------------------------------------------- 1 | // NuoDirect.cpp : Defines the entry point for the application. 2 | // 3 | 4 | #include "framework.h" 5 | #include "NuoDirectWindow.h" 6 | 7 | #include "NuoAppInstance.h" 8 | 9 | 10 | NuoDirectWindow::NuoDirectWindow(const std::string& title) 11 | : NuoWindow(title) 12 | { 13 | } 14 | 15 | 16 | void NuoDirectWindow::Init() 17 | { 18 | PNuoDevice currentDevice; 19 | std::set devices = NuoDevice::Devices(); 20 | for (auto device : devices) 21 | { 22 | std::string name = device->Name(); 23 | if (name.find("NVIDIA") != std::string::npos) 24 | currentDevice = device; 25 | } 26 | 27 | currentDevice->EnableDebugInfoQueue(); 28 | 29 | _dxView = std::make_shared(currentDevice, shared_from_this()); 30 | Add(_dxView); 31 | 32 | NuoInset margin(0, 0, 0, 200); 33 | _dxView->SetAutoPosition(kNuoControl_Stretch_ALL); 34 | _dxView->SetMargin(margin); 35 | } 36 | 37 | 38 | void NuoDirectWindow::OnPaint() 39 | { 40 | } 41 | 42 | -------------------------------------------------------------------------------- /lua/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | /* 22 | ** Encode major-minor version in one byte, one nibble for each 23 | */ 24 | #define MYINT(s) (s[0]-'0') /* assume one-digit numerals */ 25 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 26 | 27 | #define LUAC_FORMAT 0 /* this is the official format */ 28 | 29 | /* load one chunk; from lundump.c */ 30 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 31 | 32 | /* dump one chunk; from ldump.c */ 33 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 34 | void* data, int strip); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUtilites/NuoDispatch.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoDispatch.h 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 1/14/2021. 6 | // Copyright © 2021 middleware. All rights reserved. 7 | // 8 | 9 | #ifndef NuoDispatch_hpp 10 | #define NuoDispatch_hpp 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | 20 | class NuoDispatch 21 | { 22 | 23 | static NuoDispatch* _dispatch; 24 | 25 | std::thread _backthread; 26 | std::queue > _works; 27 | 28 | std::mutex _mutex; 29 | std::condition_variable _condition; 30 | 31 | std::atomic _running; 32 | 33 | NuoDispatch(); 34 | ~NuoDispatch(); 35 | 36 | public: 37 | 38 | static NuoDispatch* GetInstance(); 39 | 40 | void DispatchAsync(std::function work); 41 | 42 | private: 43 | 44 | void Execute(); 45 | 46 | static void BackThreadFunc(NuoDispatch* dispatch); 47 | 48 | }; 49 | 50 | 51 | 52 | #endif /* NuoDispatch_hpp */ 53 | -------------------------------------------------------------------------------- /lua/src/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/ModelState/ModelViewConfiguration.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelViewConfiguration.h 3 | // ModelViewer 4 | // 5 | // Created by Dong on 12/20/2020. 6 | // Copyright 2020 Dong FEng. All rights reserved. 7 | // 8 | 9 | #ifndef __MODEL_VIEW_CONFIGURATION_H__ 10 | #define __MODEL_VIEW_CONFIGURATION_H__ 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | 19 | class NuoDevice; 20 | typedef std::shared_ptr PNuoDevice; 21 | 22 | 23 | class ModelViewConfiguration 24 | { 25 | 26 | std::string _deviceName; 27 | std::string _path; 28 | 29 | std::map _devices; 30 | 31 | public: 32 | 33 | ModelViewConfiguration(const std::string& path); 34 | ~ModelViewConfiguration(); 35 | 36 | void Save(); 37 | 38 | PNuoDevice Device(); 39 | std::vector DeviceNames() const; 40 | void SelectDevice(const std::string& device); 41 | 42 | private: 43 | 44 | void Load(); 45 | void InitDeviceName(); 46 | 47 | }; 48 | 49 | 50 | #endif -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoMeshMaterialedPixel.hlsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | #define __SHADER_REGISTERS__ 1 4 | 5 | #include "NuoUniforms.h" 6 | #include "NuoMeshMaterialed.h" 7 | #include "NuoMeshShadersCommon.h" 8 | 9 | 10 | float4 main(NuoMaterialedBasicVertexOutput inVertex) : SV_Target 11 | { 12 | float3 lightVector = normalize(light.lightParams[0].direction.xyz); 13 | float3 normal = normalize(inVertex._normal.xyz); 14 | float cosTheta = saturate(dot(normal, lightVector)); 15 | float3 diffuseTerm = light.lightParams[0].irradiance * cosTheta * inVertex._diffuse; 16 | 17 | float3 eyeDirection = normalize(inVertex._eye); 18 | float3 halfway = normalize(lightVector + eyeDirection); 19 | 20 | float3 specularTerm = specular_common(inVertex._specular, inVertex._shinessDisolveIllum.x, 21 | light.lightParams[0], normal, halfway, cosTheta); 22 | 23 | float opacity = inVertex._shinessDisolveIllum.y; 24 | float3 colorForLights = diffuseTerm + specularTerm; 25 | 26 | return float4(colorForLights, opacity); 27 | } 28 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoTimer.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "NuoWindow.h" 3 | #include 4 | 5 | 6 | 7 | static std::map _sTimers; 8 | 9 | 10 | 11 | static void Timerproc(HWND hWnd, UINT msg, UINT_PTR id, DWORD Arg4) 12 | { 13 | if (msg == WM_TIMER) 14 | { 15 | auto pos = _sTimers.find(id); 16 | if (pos != _sTimers.end()) 17 | { 18 | PNuoTimer timer = pos->second; 19 | if (!timer->OnTimer()) 20 | { 21 | _sTimers.erase(pos); 22 | } 23 | } 24 | } 25 | } 26 | 27 | 28 | 29 | PNuoTimer NuoTimer::MakeTimer(unsigned int interval, Func timeFunc) 30 | { 31 | PNuoTimer timer = std::make_shared(interval, timeFunc); 32 | 33 | _sTimers.insert(std::make_pair(timer->_id, timer)); 34 | return timer; 35 | } 36 | 37 | 38 | 39 | NuoTimer::NuoTimer(unsigned int interval, Func timerFunc) 40 | : _interval(interval), 41 | _function(timerFunc) 42 | { 43 | _id = SetTimer(0, 0, _interval, Timerproc); 44 | } 45 | 46 | 47 | NuoTimer::~NuoTimer() 48 | { 49 | KillTimer(0, _id); 50 | } 51 | 52 | 53 | bool NuoTimer::OnTimer() 54 | { 55 | return _function(this); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUtilites/NuoTableExporter.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoTableExporter.hpp 3 | // ModelViewer 4 | // 5 | // Created by middleware on 12/6/16. 6 | // Copyright © 2016 middleware. All rights reserved. 7 | // 8 | 9 | #ifndef NuoTableExporter_hpp 10 | #define NuoTableExporter_hpp 11 | 12 | #include 13 | #include 14 | #include "NuoMathVector.h" 15 | 16 | class NuoTableExporter 17 | { 18 | private: 19 | std::string _result; 20 | unsigned long _indent; 21 | 22 | public: 23 | NuoTableExporter(); 24 | 25 | void StartTable(); 26 | void StartArrayIndex(size_t index); 27 | void StartEntry(const std::string& entryName); 28 | void SetEntryValueFloat(float value); 29 | void SetEntryValueBool(bool value); 30 | void SetEntryValueString(const std::string& value); 31 | void EndTable(); 32 | void EndEntry(bool extraLine); 33 | 34 | void SetMatrix(const NuoMatrixFloat44& matrix); 35 | 36 | const std::string& GetResult() const; 37 | 38 | private: 39 | 40 | void AppendByIndent(); 41 | }; 42 | 43 | #endif /* NuoTableExporter_hpp */ 44 | -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/DirectView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NuoWindow.h" 4 | #include "NuoTimer.h" 5 | 6 | #include "NuoDirect/NuoDirectView.h" 7 | #include "NuoMeshes/NuoCubeMesh.h" 8 | 9 | #include 10 | #include 11 | 12 | 13 | class DirectView; 14 | typedef std::shared_ptr PDirectView; 15 | 16 | 17 | class DirectView : public NuoDirectView 18 | { 19 | 20 | struct Vertex 21 | { 22 | DirectX::XMFLOAT3 position; 23 | 24 | DirectX::XMFLOAT4 color; 25 | }; 26 | 27 | PNuoPipelineState _pipeline; 28 | PNuoVertexBuffer _vertexBuffer; 29 | 30 | PNuoCubeMesh _mesh; 31 | 32 | PNuoTimer _refreshTimer; 33 | 34 | NuoMatrixFloat44 _modelTransfer; 35 | 36 | public: 37 | 38 | void Init(); 39 | 40 | DirectView(const PNuoDevice& device, const PNuoWindow& parent); 41 | 42 | virtual void Render(const PNuoCommandBuffer& commandBuffer) override; 43 | virtual void OnSize(unsigned int x, unsigned int y) override; 44 | 45 | virtual void OnMouseDown(short x, short y) override; 46 | virtual void OnMouseDrag(short x, short y, short deltaX, short deltaY) override; 47 | 48 | }; 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoOpenFileDialog.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "NuoStrings.h" 3 | #include "NuoOpenFileDialog.h" 4 | 5 | 6 | NuoFileDialog::NuoFileDialog() 7 | { 8 | memset(&_ofn, 0, sizeof(_ofn)); 9 | 10 | auto& ofn = _ofn; 11 | 12 | ofn.lStructSize = sizeof(_ofn); 13 | ofn.hwndOwner = NULL; 14 | ofn.lpstrFile = _szFile; 15 | ofn.lpstrFile[0] = '\0'; 16 | ofn.nMaxFile = sizeof(_szFile); 17 | ofn.lpstrFilter = L"All\0*.*\0"; 18 | ofn.nFilterIndex = 1; 19 | ofn.lpstrFileTitle = NULL; 20 | ofn.nMaxFileTitle = 0; 21 | ofn.lpstrInitialDir = NULL; 22 | ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; 23 | } 24 | 25 | 26 | void NuoFileDialog::Open(const PNuoWindow& owner) 27 | { 28 | _ofn.hwndOwner = owner->Handle(); 29 | 30 | GetOpenFileName(&_ofn); 31 | } 32 | 33 | 34 | void NuoFileDialog::Save(const PNuoWindow& owner) 35 | { 36 | _ofn.hwndOwner = owner->Handle(); 37 | 38 | GetSaveFileName(&_ofn); 39 | } 40 | 41 | 42 | 43 | std::string NuoFileDialog::FilePath() const 44 | { 45 | std::wstring wfile(_ofn.lpstrFile); 46 | 47 | if (!wfile.size()) 48 | return ""; 49 | 50 | std::string result = StringToUTF8(wfile); 51 | return result; 52 | } -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/ModelViewerWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NuoWindow.h" 4 | #include "ModelView.h" 5 | #include 6 | 7 | 8 | class ModelViewConfiguration; 9 | typedef std::shared_ptr PModelViewConfiguration; 10 | 11 | class NuoDropdownList; 12 | typedef std::shared_ptr PNuoDropdownList; 13 | 14 | class NuoProgressBar; 15 | typedef std::shared_ptr PNuoProgressBar; 16 | 17 | class ModelOperationPanel; 18 | typedef std::shared_ptr PModelOperationPanel; 19 | 20 | 21 | class ModelViewerWindow : public NuoWindow 22 | { 23 | 24 | std::function _onPaint; 25 | PModelView _dxView; 26 | 27 | PModelViewConfiguration _configuration; 28 | PNuoDropdownList _deviceList; 29 | PNuoProgressBar _loadingProgress; 30 | 31 | PModelOperationPanel _modelPanel; 32 | 33 | public: 34 | 35 | void Init(); 36 | void UpdateControls(); 37 | 38 | ModelViewerWindow(const std::string& title); 39 | virtual void OnPaint(); 40 | 41 | private: 42 | 43 | void OpenFile(); 44 | 45 | }; 46 | 47 | 48 | 49 | typedef std::shared_ptr PNuoDirectWindow; 50 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoConstantBufferSwapChain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "NuoResource.h" 12 | 13 | 14 | class NuoConstantBufferSwapChain; 15 | typedef std::shared_ptr PNuoConstantBufferSwapChain; 16 | typedef std::weak_ptr WPNuoConstantBufferSwapChain; 17 | 18 | class NuoDevice; 19 | typedef std::shared_ptr PNuoDevice; 20 | 21 | class NuoResourceSwapChain; 22 | typedef std::shared_ptr PNuoResourceSwapChain; 23 | 24 | class NuoDescriptorHeap; 25 | typedef std::shared_ptr PNuoDescriptorHeap; 26 | 27 | 28 | 29 | class NuoConstantBufferSwapChain 30 | { 31 | 32 | PNuoResourceSwapChain _resources; 33 | PNuoDescriptorHeap _cbvHeap; 34 | 35 | public: 36 | 37 | NuoConstantBufferSwapChain(const PNuoDevice& device, 38 | unsigned int frameCount, unsigned int size); 39 | 40 | void UpdateBuffer(void* data, unsigned long size, unsigned int inFlight); 41 | D3D12_GPU_VIRTUAL_ADDRESS Buffer(unsigned int inFlight); 42 | 43 | }; 44 | 45 | -------------------------------------------------------------------------------- /lua/Lua/LuaCmd/LuaCmd.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/shaders.hlsl: -------------------------------------------------------------------------------- 1 | //********************************************************* 2 | // 3 | // Copyright (c) Microsoft. All rights reserved. 4 | // This code is licensed under the MIT License (MIT). 5 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF 6 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY 7 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR 8 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. 9 | // 10 | //********************************************************* 11 | 12 | struct InputParamType 13 | { 14 | float4 color; 15 | }; 16 | 17 | ConstantBuffer InputParam : register(b0); 18 | 19 | 20 | struct PSInput 21 | { 22 | float4 position : SV_POSITION; 23 | float4 color : COLOR; 24 | }; 25 | 26 | 27 | struct VSInput 28 | { 29 | float4 position : POSITION; 30 | float4 color : COLOR; 31 | }; 32 | 33 | PSInput VSMain(VSInput vsInput /*float4 position : POSITION, float4 color : COLOR*/) 34 | { 35 | PSInput result; 36 | 37 | result.position = vsInput.position; 38 | result.color = vsInput.color * InputParam.color; 39 | 40 | return result; 41 | } 42 | 43 | float4 PSMain(PSInput input) : SV_TARGET 44 | { 45 | return input.color; 46 | } 47 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUtilites/NuoBackgroundTask.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoBackgroundTask.h 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 2/20/2021. 6 | // Copyright © 2021 middleware. All rights reserved. 7 | // 8 | 9 | #ifndef NuoBackgroundTask_hpp 10 | #define NuoBackgroundTask_hpp 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | 22 | class NuoTimer; 23 | typedef std::shared_ptr PNuoTimer; 24 | 25 | 26 | typedef std::function NuoTaskProgress; 27 | typedef std::function NuoTaskCompletion; 28 | typedef std::function NuoTask; 29 | 30 | 31 | class NuoBackgroundTask 32 | { 33 | 34 | NuoTask _work; 35 | PNuoTimer _timer; 36 | 37 | std::atomic _running; 38 | std::atomic _started; 39 | 40 | std::atomic _progress; 41 | 42 | public: 43 | 44 | NuoBackgroundTask(NuoTask work); 45 | 46 | bool Resume(float* progress); 47 | void Await(); 48 | 49 | static void BackgroundTask(NuoTask work, NuoTaskProgress progress, NuoTaskCompletion completion); 50 | 51 | }; 52 | 53 | 54 | 55 | #endif /* NuoDispatch_hpp */ 56 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoResource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | class NuoResource; 12 | typedef std::shared_ptr PNuoResource; 13 | typedef std::weak_ptr WPNuoResource; 14 | 15 | 16 | class NuoResource : public std::enable_shared_from_this 17 | { 18 | 19 | protected: 20 | 21 | Microsoft::WRL::ComPtr _dxResources; 22 | D3D12_RESOURCE_DESC _desc; 23 | D3D12_RESOURCE_STATES _state; 24 | void* _mapped; 25 | 26 | virtual void SetResource(Microsoft::WRL::ComPtr resource, D3D12_RESOURCE_STATES state); 27 | 28 | public: 29 | 30 | NuoResource(); 31 | virtual ~NuoResource(); 32 | ID3D12Resource* DxResource() const; 33 | 34 | unsigned long Width() const; 35 | unsigned long Height() const; 36 | unsigned long Size() const; 37 | 38 | DXGI_FORMAT Format() const; 39 | unsigned int SampleCount() const; 40 | 41 | void* Map(); 42 | void Unmap(); 43 | 44 | D3D12_RESOURCE_STATES State() const; 45 | void SetState(D3D12_RESOURCE_STATES state); 46 | 47 | friend class NuoSwapChain; 48 | friend class NuoDevice; 49 | 50 | }; 51 | 52 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoResourceSwapChain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "NuoResource.h" 12 | 13 | 14 | class NuoResourceSwapChain; 15 | typedef std::shared_ptr PNuoResourceSwapChain; 16 | typedef std::weak_ptr WPNuoResourceSwapChain; 17 | 18 | class NuoDevice; 19 | typedef std::shared_ptr PNuoDevice; 20 | 21 | class NuoRenderInFlight; 22 | typedef std::shared_ptr PNuoRenderInFlight; 23 | 24 | 25 | class NuoResourceSwapChain 26 | { 27 | 28 | std::vector _resources; 29 | unsigned long _size; 30 | 31 | public: 32 | 33 | NuoResourceSwapChain(const PNuoDevice& device, unsigned int frameCount, unsigned long size); 34 | NuoResourceSwapChain(const std::vector& resources); 35 | 36 | PNuoResource operator [] (unsigned int inFlight); 37 | unsigned int Count() const; 38 | 39 | void UpdateResource(void* data, unsigned long size, unsigned int inFlight); 40 | void UpdateResource(void* data, unsigned long size, const PNuoRenderInFlight& inFlight); 41 | D3D12_GPU_VIRTUAL_ADDRESS GPUAddress(unsigned int inFlight); 42 | 43 | }; 44 | 45 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoMeshCompound.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "NuoMesh.h" 12 | 13 | 14 | 15 | class NuoCommandBuffer; 16 | typedef std::shared_ptr PNuoCommandBuffer; 17 | 18 | 19 | 20 | class NuoMeshCompound : public NuoMesh 21 | { 22 | 23 | protected: 24 | 25 | std::vector _meshes; 26 | 27 | CommonFunc _commonFunc; 28 | 29 | public: 30 | 31 | NuoMeshCompound(const std::vector& meshes); 32 | 33 | void SetMeshes(const std::vector& meshes); 34 | 35 | virtual NuoMeshBounds WorldBounds(const NuoMatrixFloat44& transform) override; 36 | 37 | virtual std::vector InputDesc() override; 38 | virtual void MakePipelineState(const PNuoCommandBuffer& commandBuffer) override; 39 | 40 | virtual bool HasTransparency() const override; 41 | virtual void SetTransparency(bool transparency) override; 42 | 43 | virtual void UpdateUniform(unsigned int inFlight, const NuoMatrixFloat44& transform) override; 44 | virtual void DrawBegin(const PNuoCommandEncoder& encoder, CommonFunc func) override; 45 | virtual void Draw(const PNuoCommandEncoder& encoder) override; 46 | 47 | }; 48 | 49 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoModelLoader/NuoModelLoader.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoModelLoader.h 3 | // ModelViewer 4 | // 5 | // Created by middleware on 8/26/16. 6 | // Copyright © 2016 middleware. All rights reserved. 7 | // 8 | 9 | 10 | 11 | #ifndef __NUO_MODEL_LOADER__ 12 | #define __NUO_MODEL_LOADER__ 13 | 14 | #include "NuoModelBase.h" 15 | #include 16 | 17 | #include "NuoUtilites/NuoBackgroundTask.h" 18 | 19 | 20 | typedef std::shared_ptr PNuoModelBase; 21 | 22 | 23 | class NuoMeshOptions; 24 | class NuoModelLoader_Internal; 25 | 26 | 27 | class NuoModelLoader 28 | { 29 | 30 | public: 31 | 32 | NuoModelLoader(); 33 | ~NuoModelLoader(); 34 | 35 | void LoadModel(const std::string& path); 36 | 37 | /** 38 | * Create a renderable GPU mesh. A GPU mesh consists of the continuous buffer where the vertex data 39 | * is stored, the associated textures, and the associated pipeline state used for rendering. 40 | */ 41 | std::vector CreateMeshWithOptions(const NuoMeshOptions& options, NuoTaskProgress progressFunc); 42 | 43 | 44 | private: 45 | 46 | NuoModelLoader_Internal* _internal; 47 | 48 | }; 49 | 50 | 51 | typedef std::shared_ptr PNuoModelLoader; 52 | 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoVertexBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "NuoResource.h" 12 | 13 | class NuoVertexBuffer; 14 | typedef std::shared_ptr PNuoVertexBuffer; 15 | typedef std::weak_ptr WPNuoVertexBuffer; 16 | 17 | class NuoCommandBuffer; 18 | typedef std::shared_ptr PNuoCommandBuffer; 19 | typedef std::weak_ptr WPNuoCommandBuffer; 20 | 21 | 22 | class NuoVertexBuffer 23 | { 24 | PNuoResource _buffer; 25 | PNuoResource _indicies; 26 | 27 | D3D12_VERTEX_BUFFER_VIEW _vertexBufferView; 28 | D3D12_INDEX_BUFFER_VIEW _indiciesBufferView; 29 | 30 | public: 31 | 32 | NuoVertexBuffer(const PNuoCommandBuffer& commandBuffer, 33 | std::vector& intermediatePool, 34 | void* data, size_t size, size_t stride, 35 | uint32_t* indicies, size_t idiciesCount); 36 | 37 | NuoVertexBuffer(const PNuoResource& buffer, size_t stride); 38 | D3D12_VERTEX_BUFFER_VIEW* View(); 39 | D3D12_INDEX_BUFFER_VIEW* IndiciesView(); 40 | 41 | unsigned int Count() const; 42 | unsigned int IndiciesCount() const; 43 | 44 | private: 45 | 46 | void UpdateView(size_t stride); 47 | }; 48 | 49 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUtilites/NuoModelArrow.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoModelArrow.hpp 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 8/28/16. 6 | // Ported: 9/22/21. 7 | // Copyright © 2021 Dong Feng. All rights reserved. 8 | // 9 | 10 | #ifndef NuoModelArrow_hpp 11 | #define NuoModelArrow_hpp 12 | 13 | 14 | #include "NuoModelLoader/NuoModelBase.h" 15 | 16 | 17 | class NuoModelArrow : public NuoModelSimple 18 | { 19 | 20 | float _bodyLength; 21 | float _bodyRadius; 22 | float _headLength; 23 | float _headRadius; 24 | 25 | 26 | public: 27 | 28 | NuoModelArrow(float bodyLength, float bodyRadius, float headLength, float headRadius); 29 | 30 | void CreateBuffer(); 31 | 32 | private: 33 | 34 | NuoVectorFloat4 GetMiddleSurfaceVertex(size_t index, size_t type); 35 | NuoVectorFloat4 GetBodyVertex(size_t index, size_t type); 36 | NuoVectorFloat4 GetBodyNormal(size_t index); 37 | NuoVectorFloat4 GetEndVertex(size_t type); 38 | NuoVectorFloat4 GetHeadNormal(size_t index); 39 | 40 | void CreateEndSurface(); 41 | void CreateBodySurface(); 42 | void CreateMiddleSurface(); 43 | void CreateHeadSurface(); 44 | 45 | }; 46 | 47 | 48 | typedef std::shared_ptr PNuoModelArrow; 49 | 50 | 51 | 52 | #endif /* NuoModelArrow_hpp */ 53 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoMeshMaterialed.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | #include "NuoMesh.h" 14 | #include "NuoShaders/NuoMeshMaterialed.h" 15 | #include "NuoModelLoader/NuoModelMaterialedBasic.h" 16 | 17 | 18 | typedef std::shared_ptr PNuoModelMaterialed; 19 | 20 | 21 | class NuoMeshMaterialed : public NuoMeshBase 22 | { 23 | 24 | bool _hasTransparency; 25 | bool _physicallyReflection; 26 | 27 | protected: 28 | 29 | virtual std::vector InputDesc() override; 30 | 31 | public: 32 | 33 | NuoMeshMaterialed(); 34 | virtual ~NuoMeshMaterialed(); 35 | 36 | void Init(const PNuoCommandBuffer& commandBuffer, 37 | unsigned int frameCount, 38 | std::vector& intermediate, 39 | const PNuoModelMaterialed& model, 40 | DXGI_FORMAT format); 41 | 42 | virtual bool HasTransparency() const override; 43 | virtual void SetTransparency(bool transparency) override; 44 | virtual void SetPhysicallyReflection(bool physically); 45 | 46 | virtual void MakePipelineState(const PNuoCommandBuffer& commandBuffer) override; 47 | 48 | }; 49 | 50 | 51 | typedef std::shared_ptr PNuoMeshMaterialed; 52 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoRender/NuoRenderPass.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoRendererPass.cpp 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 3/29/21. 6 | // Copyright © 2021 Dong Feng. All rights reserved. 7 | // 8 | 9 | #include "NuoRenderPass.h" 10 | 11 | #include "NuoDirect/NuoRenderTarget.h" 12 | 13 | 14 | 15 | void NuoRenderPass::SetDrawableSize(const NuoSize& size) 16 | { 17 | if (_renderTarget) 18 | _renderTarget->SetDrawableSize(size); 19 | } 20 | 21 | 22 | 23 | bool NuoRenderPass::IsPipelinePass() const 24 | { 25 | return false; 26 | } 27 | 28 | 29 | PNuoCommandEncoder NuoRenderPass::RetainDefaultEncoder(const PNuoCommandBuffer& commandBuffer) 30 | { 31 | return RenderTarget()->RetainRenderPassEncoder(commandBuffer); 32 | } 33 | 34 | 35 | void NuoRenderPass::ReleaseDefaultEncoder() 36 | { 37 | RenderTarget()->ReleaseRenderPassEncoder(); 38 | } 39 | 40 | 41 | void NuoRenderPass::SetRenderTarget(const PNuoRenderTarget& renderTarget) 42 | { 43 | _renderTarget = renderTarget; 44 | } 45 | 46 | void NuoRenderPass::SetTransientRenderTarget(const WPNuoRenderTarget& renderTarget) 47 | { 48 | _renderTargetTransient = renderTarget; 49 | } 50 | 51 | 52 | PNuoRenderTarget NuoRenderPass::RenderTarget() 53 | { 54 | if (_renderTarget) 55 | return _renderTarget; 56 | 57 | auto transientTarget = _renderTargetTransient.lock(); 58 | return transientTarget; 59 | } 60 | 61 | 62 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoScripting/NuoLua.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoLua.h 3 | // ModelViewer 4 | // 5 | // Created by middleware on 12/17/16. 6 | // Copyright © 2016 middleware. All rights reserved. 7 | // 8 | 9 | 10 | #ifndef __NUO_LUA_H__ 11 | #define __NUO_LUA_H__ 12 | 13 | 14 | #include "NuoMathVector.h" 15 | #include 16 | #include 17 | 18 | struct lua_State; 19 | 20 | 21 | 22 | class NuoLua 23 | { 24 | 25 | lua_State* _luaState; 26 | 27 | public: 28 | 29 | typedef std::set KeySet; 30 | 31 | NuoLua(); 32 | ~NuoLua(); 33 | 34 | void LoadFile(const std::string& path); 35 | 36 | KeySet GetKeysFromTable(int index); 37 | 38 | void GetField(const std::string& key, int index); 39 | size_t GetArraySize(int index); 40 | void GetItem(int itemIndex, int index); 41 | void RemoveField(); 42 | 43 | float GetFieldAsNumber(const std::string& key, int index); 44 | std::string GetFieldAsString(const std::string& key, int index); 45 | bool GetFieldAsBool(const std::string& key, int index); 46 | 47 | bool GetArrayItemAsBool(size_t item, int index); 48 | float GetArrayItemAsNumber(size_t item, int index); 49 | std::string GetArrayItemAsString(size_t item, int index); 50 | 51 | NuoMatrixFloat44 GetMatrixFromTable(int index); 52 | 53 | bool IsNil(int index); 54 | 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoMeshRotation.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoMeshRotation.cpp 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 2/2/17. 6 | // Ported to Windows 12/7/20. 7 | // Copyright © 2020 Dong Feng. All rights reserved. 8 | // 9 | 10 | #include "NuoMeshRotation.h" 11 | 12 | 13 | 14 | NuoMeshRotation::NuoMeshRotation() 15 | : _transformVector(0, 0, 0), 16 | _axis(0, 0, 1.0), _radius(0) 17 | { 18 | GenerateMatrices(); 19 | } 20 | 21 | 22 | 23 | NuoMeshRotation::NuoMeshRotation(const NuoMeshRotation& rotation) 24 | : _transformVector(rotation._transformVector), 25 | _axis(rotation._axis), 26 | _radius(rotation._radius) 27 | { 28 | 29 | GenerateMatrices(); 30 | } 31 | 32 | 33 | void NuoMeshRotation::GenerateMatrices() 34 | { 35 | NuoMatrixFloat44 transMatrix = NuoMatrixTranslation(_transformVector); 36 | NuoMatrixFloat44 transMatrixInv = NuoMatrixTranslation(-_transformVector); 37 | NuoMatrixFloat44 rotationMatrix = NuoMatrixRotation(_axis.Normalize(), _radius); 38 | 39 | _cachedResult = (transMatrixInv * (rotationMatrix * transMatrix)); 40 | } 41 | 42 | 43 | 44 | void NuoMeshRotation::SetRadius(float radius) 45 | { 46 | _radius = radius; 47 | GenerateMatrices(); 48 | } 49 | 50 | 51 | 52 | const NuoMatrixFloat44& NuoMeshRotation::RotationMatrix() const 53 | { 54 | return _cachedResult; 55 | } 56 | 57 | 58 | -------------------------------------------------------------------------------- /lua/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_MATHLIBNAME "math" 39 | LUAMOD_API int (luaopen_math) (lua_State *L); 40 | 41 | #define LUA_DBLIBNAME "debug" 42 | LUAMOD_API int (luaopen_debug) (lua_State *L); 43 | 44 | #define LUA_LOADLIBNAME "package" 45 | LUAMOD_API int (luaopen_package) (lua_State *L); 46 | 47 | 48 | /* open all previous libraries */ 49 | LUALIB_API void (luaL_openlibs) (lua_State *L); 50 | 51 | 52 | 53 | #if !defined(lua_assert) 54 | #define lua_assert(x) ((void)0) 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoPipelineState.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | #include "NuoDevice.h" 13 | #include "NuoShader.h" 14 | #include "NuoSignature.h" 15 | 16 | class NuoPipelineState; 17 | typedef std::shared_ptr PNuoPipelineState; 18 | typedef std::weak_ptr WPNuoPipelineState; 19 | 20 | 21 | 22 | enum NuoBlendingMode 23 | { 24 | kNuoBlending_None, 25 | kNuoBlending_Alpha, 26 | kNuoBlending_Accumulate, 27 | }; 28 | 29 | 30 | enum NuoCullMode 31 | { 32 | kNuoCull_None, 33 | kNuoCull_Front, 34 | kNuoCull_Back, 35 | }; 36 | 37 | 38 | 39 | class NuoPipelineState 40 | { 41 | 42 | Microsoft::WRL::ComPtr _dxPipelineState; 43 | PNuoRootSignature _rootSignature; 44 | 45 | 46 | public: 47 | 48 | NuoPipelineState(const PNuoDevice& device, 49 | DXGI_FORMAT format, 50 | bool depthEnabled, bool depthWrite, 51 | unsigned int sampleCount, 52 | NuoBlendingMode blendingMode, 53 | NuoCullMode cullMode, 54 | const std::vector& inputDesc, 55 | const PNuoShader& vertex, 56 | const PNuoShader& pixel, 57 | const PNuoRootSignature& rootSignature); 58 | 59 | 60 | ID3D12PipelineState* DxPipeline() const; 61 | ID3D12RootSignature* DxRootSignature() const; 62 | 63 | }; 64 | 65 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoModelLoader/NuoBounds.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoBounds.hpp 3 | // ModelViewer 4 | // 5 | // Created by Dong on 1/25/18. 6 | // Copyright © 2018 middleware. All rights reserved. 7 | // 8 | 9 | #ifndef NuoBounds_hpp 10 | #define NuoBounds_hpp 11 | 12 | 13 | 14 | #include "NuoMathVector.h" 15 | 16 | 17 | /** 18 | * it's usually arbitrary to pick either the bounds (i.e. bounding box) or the sphere 19 | * to position objects to a subjectively comfortable place. 20 | * 21 | * when it comes to the near/far plane calcuation, bounds is more accurate as it utilize 22 | * z-buffer range to the objects' span maximally. 23 | */ 24 | 25 | 26 | 27 | class NuoSphere 28 | { 29 | 30 | public: 31 | 32 | NuoVectorFloat3 _center; 33 | float _radius; 34 | 35 | NuoSphere(); 36 | 37 | NuoSphere Union(const NuoSphere& sphere); 38 | NuoSphere Transform(const NuoMatrixFloat44& matrix) const; 39 | 40 | }; 41 | 42 | 43 | class NuoBounds 44 | { 45 | 46 | public: 47 | 48 | NuoVectorFloat3 _center; 49 | NuoVectorFloat3 _span; 50 | 51 | NuoBounds(); 52 | 53 | NuoBounds Transform(const NuoMatrixFloat44& matrix) const; 54 | 55 | NuoBounds Union(const NuoBounds& bounds) const; 56 | NuoBounds Union(const NuoVectorFloat3& point) const; 57 | float MaxDimension() const; 58 | 59 | NuoSphere Sphere() const; 60 | }; 61 | 62 | 63 | 64 | 65 | 66 | #endif /* NuoBounds_hpp */ 67 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoImage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | class NuoIcon; 11 | typedef std::shared_ptr PNuoIcon; 12 | 13 | class NuoReadStream; 14 | typedef std::shared_ptr PNuoReadStream; 15 | 16 | struct IWICBitmapSource; 17 | 18 | 19 | class NuoImage : public std::enable_shared_from_this 20 | { 21 | PNuoReadStream _iStream; 22 | Microsoft::WRL::ComPtr _bitmap; 23 | HBITMAP _hBitmap; 24 | bool _backgroundGrid; 25 | 26 | UINT _width; 27 | UINT _height; 28 | 29 | public: 30 | 31 | NuoImage(); 32 | ~NuoImage(); 33 | 34 | void Load(const std::string& path, int backgroundGrid); 35 | void LoadPNG(const std::string& path, int backgroundGrid); 36 | PNuoIcon Icon(); 37 | operator HBITMAP (); 38 | 39 | void CopyPixel(std::vector& data); 40 | 41 | UINT Width() const; 42 | UINT Height() const; 43 | 44 | private: 45 | 46 | void UpdateImageInfo(); 47 | 48 | }; 49 | 50 | typedef std::shared_ptr PNuoImage; 51 | 52 | 53 | class NuoIcon : public std::enable_shared_from_this 54 | { 55 | HICON _hIcon; 56 | 57 | NuoIcon(HICON icon); 58 | 59 | public: 60 | 61 | NuoIcon(int iconId); 62 | ~NuoIcon(); 63 | 64 | HICON Handle() const; 65 | void Save16(const std::string& path); 66 | void Save(const std::string& path); 67 | 68 | friend NuoImage; 69 | }; -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoConstantBufferSwapChain.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoConstantBufferSwapChain.h" 4 | 5 | #include "NuoDevice.h" 6 | #include "NuoResourceSwapChain.h" 7 | 8 | 9 | 10 | NuoConstantBufferSwapChain::NuoConstantBufferSwapChain(const PNuoDevice& device, 11 | unsigned int frameCount, unsigned int size) 12 | { 13 | std::vector resources; 14 | resources.resize(size); 15 | 16 | for (PNuoResource& resource : resources) 17 | resource = device->CreateUploadBuffer(size); 18 | 19 | _resources = std::make_shared(resources); 20 | 21 | _cbvHeap = device->CreateShaderDescriptorHeap(frameCount); 22 | for (UINT n = 0; n < frameCount; ++n) 23 | { 24 | D3D12_CPU_DESCRIPTOR_HANDLE cbvHandle = _cbvHeap->DxCPUHandle(n); 25 | 26 | D3D12_CONSTANT_BUFFER_VIEW_DESC desc; 27 | PNuoResource resource = resources[n]; 28 | desc.BufferLocation = resource->DxResource()->GetGPUVirtualAddress(); 29 | desc.SizeInBytes = resource->Size(); 30 | 31 | device->DxDevice()->CreateConstantBufferView(&desc, cbvHandle); 32 | } 33 | } 34 | 35 | 36 | void NuoConstantBufferSwapChain::UpdateBuffer(void* data, unsigned long size, unsigned int inFlight) 37 | { 38 | _resources->UpdateResource(data, size, inFlight); 39 | } 40 | 41 | 42 | D3D12_GPU_VIRTUAL_ADDRESS NuoConstantBufferSwapChain::Buffer(unsigned int inFlight) 43 | { 44 | return (*_resources)[inFlight]->DxResource()->GetGPUVirtualAddress(); 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /NuoDirect/NuoDirect/NuoDirect.cpp: -------------------------------------------------------------------------------- 1 | // NuoDirect.cpp : Defines the entry point for the application. 2 | // 3 | 4 | #include "framework.h" 5 | #include "NuoDirect.h" 6 | 7 | #include "NuoAppInstance.h" 8 | 9 | #include "NuoDirectWindow.h" 10 | #include "DirectView.h" 11 | 12 | 13 | int APIENTRY wWinMain(_In_ HINSTANCE hInstance, 14 | _In_opt_ HINSTANCE hPrevInstance, 15 | _In_ LPWSTR lpCmdLine, 16 | _In_ int nCmdShow) 17 | { 18 | UNREFERENCED_PARAMETER(hPrevInstance); 19 | UNREFERENCED_PARAMETER(lpCmdLine); 20 | 21 | NuoAppInstance::Init(hInstance, nCmdShow); 22 | NuoWindow::RegisterClass(); 23 | 24 | PNuoDirectWindow window = std::make_shared(" Nuo Direct"); 25 | window->Init(); 26 | 27 | auto exitFunc = []() 28 | { 29 | NuoAppInstance::Exit(); 30 | }; 31 | window->SetOnDestroy(exitFunc); 32 | window->Show(); 33 | window->Update(); 34 | 35 | HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_NUODIRECT)); 36 | 37 | MSG msg; 38 | 39 | // Main message loop: 40 | while (GetMessage(&msg, nullptr, 0, 0)) 41 | { 42 | if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 43 | { 44 | TranslateMessage(&msg); 45 | DispatchMessage(&msg); 46 | } 47 | } 48 | 49 | NuoAppInstance::UnInit(); 50 | 51 | return (int) msg.wParam; 52 | } 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoResourceSwapChain.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoResourceSwapChain.h" 4 | 5 | #include "NuoDevice.h" 6 | #include "NuoCommandBuffer.h" 7 | 8 | 9 | 10 | NuoResourceSwapChain::NuoResourceSwapChain(const PNuoDevice& device, unsigned int frameCount, unsigned long size) 11 | : _size(size) 12 | { 13 | _resources.resize(frameCount); 14 | 15 | for (PNuoResource& resource : _resources) 16 | resource = device->CreateUploadBuffer(size); 17 | } 18 | 19 | 20 | NuoResourceSwapChain::NuoResourceSwapChain(const std::vector& resources) 21 | { 22 | _resources.insert(_resources.begin(), resources.begin(), resources.end()); 23 | } 24 | 25 | 26 | PNuoResource NuoResourceSwapChain::operator [] (unsigned int inFlight) 27 | { 28 | return _resources[inFlight]; 29 | } 30 | 31 | unsigned int NuoResourceSwapChain::Count() const 32 | { 33 | return (unsigned int)_resources.size(); 34 | } 35 | 36 | 37 | void NuoResourceSwapChain::UpdateResource(void* data, unsigned long size, unsigned int inFlight) 38 | { 39 | void* dst = _resources[inFlight]->Map(); 40 | memcpy(dst, data, size); 41 | } 42 | 43 | 44 | void NuoResourceSwapChain::UpdateResource(void* data, unsigned long size, const PNuoRenderInFlight& inFlight) 45 | { 46 | UpdateResource(data, size, inFlight->InFlight()); 47 | } 48 | 49 | 50 | D3D12_GPU_VIRTUAL_ADDRESS NuoResourceSwapChain::GPUAddress(unsigned int inFlight) 51 | { 52 | return _resources[inFlight]->DxResource()->GetGPUVirtualAddress(); 53 | } 54 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoRender/NuoRenderPipeline.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoRenderPipeline.h 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 5/21/21. 6 | // Copyright © 2021 Dong Feng. All rights reserved. 7 | // 8 | 9 | #include 10 | #include 11 | 12 | #include "NuoDirect/NuoSize.h" 13 | 14 | 15 | 16 | class NuoRenderPass; 17 | typedef std::shared_ptr PNuoRenderPass; 18 | 19 | class NuoCommandBuffer; 20 | typedef std::shared_ptr PNuoCommandBuffer; 21 | 22 | class NuoRenderTarget; 23 | typedef std::shared_ptr PNuoRenderTarget; 24 | typedef std::weak_ptr WPNuoRenderTarget; 25 | 26 | 27 | 28 | class NuoRenderPipeline 29 | { 30 | 31 | /** 32 | * The passes of the view's rendering, responsible for maintain the model/scene state, 33 | * and the rendering. 34 | * 35 | * Note that the pipeline does the sequential rendering for all the passes but does not 36 | * own the passes (i.e. weak). The passes are constructed and owned by application 37 | */ 38 | std::vector _renderPasses; 39 | 40 | WPNuoRenderTarget _renderTarget; 41 | 42 | public: 43 | 44 | void RenderWithCommandBuffer(const PNuoCommandBuffer& commandBuffer); 45 | 46 | void SetRenderPasses(const std::vector& passes); 47 | void SetDrawableSize(const NuoSize& size); 48 | //void SetSampleCount(unsigned int sampleCount); 49 | 50 | void SetRenderTarget(const PNuoRenderTarget renderTarget); 51 | 52 | 53 | }; -------------------------------------------------------------------------------- /lua/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | 15 | /* Increments 'L->top', checking for stack overflows */ 16 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 17 | "stack overflow");} 18 | 19 | 20 | /* 21 | ** If a call returns too many multiple returns, the callee may not have 22 | ** stack space to accommodate all results. In this case, this macro 23 | ** increases its stack space ('L->ci->top'). 24 | */ 25 | #define adjustresults(L,nres) \ 26 | { if ((nres) <= LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 27 | 28 | 29 | /* Ensure the stack has at least 'n' elements */ 30 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 31 | "not enough elements in the stack") 32 | 33 | 34 | /* 35 | ** To reduce the overhead of returning from C functions, the presence of 36 | ** to-be-closed variables in these functions is coded in the CallInfo's 37 | ** field 'nresults', in a way that functions with no to-be-closed variables 38 | ** with zero, one, or "all" wanted results have no overhead. Functions 39 | ** with other number of wanted results, as well as functions with 40 | ** variables to be closed, have an extra check. 41 | */ 42 | 43 | #define hastocloseCfunc(n) ((n) < LUA_MULTRET) 44 | 45 | #define codeNresults(n) (-(n) - 3) 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoMeshSimplePixel.hlsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | #define __SHADER_REGISTERS__ 1 4 | 5 | #include "NuoUniforms.h" 6 | #include "NuoMeshSimple.h" 7 | #include "NuoMeshShadersCommon.h" 8 | 9 | 10 | 11 | static const Material material = 12 | { 13 | float3(0.6, 0.6, 0.6), 14 | float3(1.0, 1.0, 1.0), 15 | 100, 16 | }; 17 | 18 | 19 | float4 main(NuoMeshSimpleVertexShaderOutput inVertex) : SV_Target 20 | { 21 | float3 lightVector = normalize(light.lightParams[0].direction.xyz); 22 | float3 normal = normalize(inVertex._normal.xyz); 23 | float opacity = modelCharacterUniforms.opacity; 24 | 25 | /* for now, the notation render is the only user of the simple mesh. it uses accumulate 26 | * blending. in order to increase the salicency of specular, the diffuse color is scaled 27 | * down by the opacity, while specular remains unchanged. 28 | */ 29 | float cosTheta = saturate(dot(normal, lightVector)); 30 | float3 diffuseTerm = light.lightParams[0].irradiance * cosTheta * material.diffuseColor * opacity; 31 | 32 | float3 eyeDirection = normalize(inVertex._eye); 33 | float3 halfway = normalize(lightVector + eyeDirection); 34 | 35 | float3 specularTerm = specular_common(material.specularColor, material.specularPower, 36 | light.lightParams[0], normal, halfway, cosTheta); 37 | 38 | float3 colorForLights = diffuseTerm + specularTerm; 39 | 40 | return float4(colorForLights, opacity); 41 | } 42 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoStrings.cpp: -------------------------------------------------------------------------------- 1 | #include "NuoStrings.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | 9 | std::wstring StringToUTF16(const std::string& s) 10 | { 11 | int size = MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, nullptr, 0); 12 | wchar_t* result = new wchar_t[size]; 13 | 14 | MultiByteToWideChar(CP_UTF8, 0, s.c_str(), -1, result, size); 15 | std::wstring resultStr(result); 16 | 17 | delete[] result; 18 | 19 | return resultStr; 20 | } 21 | 22 | 23 | 24 | std::string StringToUTF8(const std::wstring& s) 25 | { 26 | int size = WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, nullptr, 0, nullptr, nullptr); 27 | char* result = new char[size]; 28 | 29 | WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, result, size, nullptr, nullptr); 30 | std::string resultStr(result); 31 | 32 | delete[] result; 33 | 34 | return resultStr; 35 | } 36 | 37 | 38 | std::string LastPathComponent(const std::string& s) 39 | { 40 | size_t delimitor = s.find_last_of("\\"); 41 | return s.substr(delimitor + 1); 42 | } 43 | 44 | 45 | std::string RemoveLastPathComponent(const std::string& s) 46 | { 47 | size_t delimitor = s.find_last_of("\\"); 48 | return s.substr(0, delimitor); 49 | } 50 | 51 | 52 | std::wstring ErrorMessage(ID3DBlob* errorBlob) 53 | { 54 | std::vector message; 55 | message.resize(1024, '\0'); 56 | 57 | sprintf_s(message.data(), message.size() - 1, "%s", (const char*)errorBlob->GetBufferPointer()); 58 | 59 | return StringToUTF16(message.data()); 60 | } 61 | -------------------------------------------------------------------------------- /NuoDirect/NuoDirect.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30517.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NuoDirect", "NuoDirect\NuoDirect.vcxproj", "{5D6EA2E8-F033-4239-8F2D-9E95173DFE0E}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {5D6EA2E8-F033-4239-8F2D-9E95173DFE0E}.Debug|x64.ActiveCfg = Debug|x64 17 | {5D6EA2E8-F033-4239-8F2D-9E95173DFE0E}.Debug|x64.Build.0 = Debug|x64 18 | {5D6EA2E8-F033-4239-8F2D-9E95173DFE0E}.Debug|x86.ActiveCfg = Debug|Win32 19 | {5D6EA2E8-F033-4239-8F2D-9E95173DFE0E}.Debug|x86.Build.0 = Debug|Win32 20 | {5D6EA2E8-F033-4239-8F2D-9E95173DFE0E}.Release|x64.ActiveCfg = Release|x64 21 | {5D6EA2E8-F033-4239-8F2D-9E95173DFE0E}.Release|x64.Build.0 = Release|x64 22 | {5D6EA2E8-F033-4239-8F2D-9E95173DFE0E}.Release|x86.ActiveCfg = Release|Win32 23 | {5D6EA2E8-F033-4239-8F2D-9E95173DFE0E}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {771B2E93-032E-4A6C-8612-DE53047E6923} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30406.217 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NuoWindow", "NuoWindow\NuoWindow.vcxproj", "{38C3A3A2-EF46-4020-9DA9-B12B2A49D831}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {38C3A3A2-EF46-4020-9DA9-B12B2A49D831}.Debug|x64.ActiveCfg = Debug|x64 17 | {38C3A3A2-EF46-4020-9DA9-B12B2A49D831}.Debug|x64.Build.0 = Debug|x64 18 | {38C3A3A2-EF46-4020-9DA9-B12B2A49D831}.Debug|x86.ActiveCfg = Debug|Win32 19 | {38C3A3A2-EF46-4020-9DA9-B12B2A49D831}.Debug|x86.Build.0 = Debug|Win32 20 | {38C3A3A2-EF46-4020-9DA9-B12B2A49D831}.Release|x64.ActiveCfg = Release|x64 21 | {38C3A3A2-EF46-4020-9DA9-B12B2A49D831}.Release|x64.Build.0 = Release|x64 22 | {38C3A3A2-EF46-4020-9DA9-B12B2A49D831}.Release|x86.ActiveCfg = Release|Win32 23 | {38C3A3A2-EF46-4020-9DA9-B12B2A49D831}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {04CC1CC1-1422-4208-9B09-68EEDE97FCE7} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | class NuoReadStream; 10 | typedef std::shared_ptr PNuoReadStream; 11 | 12 | class NuoWriteStream; 13 | typedef std::shared_ptr PNuoWriteStream; 14 | 15 | 16 | class NuoFile : public std::enable_shared_from_this 17 | { 18 | PNuoReadStream _stream; 19 | FILE* _file; 20 | std::string _path; 21 | 22 | public: 23 | NuoFile(const std::string& path); 24 | ~NuoFile(); 25 | 26 | void Write(void* buffer, size_t size); 27 | void Seek(size_t pos); 28 | size_t Size(); 29 | size_t Position(); 30 | void ReadTo(std::vector& content); 31 | 32 | bool Exists(); 33 | 34 | PNuoReadStream ReadStream(); 35 | void SaveStream(const PNuoWriteStream& stream, long size); 36 | FILE* FileHandle(bool read); 37 | }; 38 | 39 | 40 | class NuoReadStream : public std::enable_shared_from_this 41 | { 42 | Microsoft::WRL::ComPtr _iStream; 43 | NuoReadStream(const Microsoft::WRL::ComPtr& iStream); 44 | 45 | public: 46 | 47 | ~NuoReadStream(); 48 | Microsoft::WRL::ComPtr& Stream(); 49 | 50 | friend NuoFile; 51 | }; 52 | 53 | 54 | class NuoWriteStream : public std::enable_shared_from_this 55 | { 56 | Microsoft::WRL::ComPtr _iStream; 57 | HGLOBAL _hGlobal; 58 | HGLOBAL GlobalBuffer(); 59 | 60 | public: 61 | 62 | NuoWriteStream(); 63 | Microsoft::WRL::ComPtr& Stream(); 64 | 65 | friend NuoFile; 66 | }; 67 | 68 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/UserInterface/ModelOperationPanel.h: -------------------------------------------------------------------------------- 1 | // 2 | // ModelOperationPanel.h 3 | // ModelViewer 4 | // 5 | // Created by middleware on 4/29/22. 6 | // Copyright © 2022 Dong Feng. All rights reserved. 7 | // 8 | 9 | 10 | #ifndef __MODEL_OPERATION_PANEL_H__ 11 | #define __MODEL_OPERATION_PANEL_H__ 12 | 13 | 14 | #include "NuoUI/NuoView.h" 15 | 16 | 17 | class NuoScrollView; 18 | typedef std::shared_ptr PNuoScrollView; 19 | typedef std::weak_ptr WPNuoScrollView; 20 | 21 | class NuoSlider; 22 | typedef std::shared_ptr PNuoSlider; 23 | typedef std::weak_ptr WPNuoSlider; 24 | 25 | class NuoLabel; 26 | typedef std::weak_ptr WPNuoLabel; 27 | 28 | class ModelOptionUpdate; 29 | typedef std::weak_ptr WPModelOptionUpdate; 30 | typedef std::shared_ptr PModelOptionUpdate; 31 | 32 | 33 | class ModelOperationPanel : public NuoView 34 | { 35 | 36 | WPNuoScrollView _scrollView; 37 | 38 | WPNuoLabel _fieldOfViewLabel; 39 | WPNuoSlider _fieldOfView; 40 | 41 | WPModelOptionUpdate _optionUpdateDelegate; 42 | 43 | 44 | public: 45 | 46 | ModelOperationPanel(const PNuoWindow& parent); 47 | virtual ~ModelOperationPanel(); 48 | 49 | void Init(); // actual constructor where shared_from_this() is functioning 50 | 51 | virtual void SetPosition(const NuoRect& pos, bool activate) override; 52 | 53 | float FieldOfViewRadian(); 54 | 55 | void SetOptionUpdateDelegate(const PModelOptionUpdate& delegate); 56 | 57 | private: 58 | 59 | 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoButton.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "NuoButton.h" 3 | 4 | #include "NuoStrings.h" 5 | #include "NuoAppInstance.h" 6 | #include "NuoDialog.h" 7 | 8 | 9 | NuoButton::NuoButton(const PNuoWindow& parent, const std::string& title) 10 | : NuoControl(title, parent) 11 | { 12 | } 13 | 14 | 15 | NuoButton::NuoButton(const PNuoDialog& parent, int controlID) 16 | : NuoControl("", std::dynamic_pointer_cast(parent)) 17 | { 18 | _hWnd = GetDlgItem(parent->Handle(), controlID); 19 | } 20 | 21 | 22 | void NuoButton::Init(int controlID) 23 | { 24 | std::wstring wtitle = StringToUTF16(_title); 25 | PNuoWindow parent = _parent.lock(); 26 | 27 | _hWnd = CreateWindow(L"BUTTON", // Predefined class; Unicode assumed 28 | wtitle.c_str(), // Button text 29 | WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_FLAT | BS_PUSHBUTTON, // Styles 30 | 10, 10, 300, 40, // Button height 31 | parent->Handle(), // Parent window 32 | (HMENU)((long long)controlID), 33 | NuoAppInstance::GetInstance()->Instance(), 34 | NULL); 35 | 36 | _id = controlID; 37 | 38 | SetWindowLongPtr(_hWnd, kWindowPtr, (LONG_PTR)this); 39 | parent->Add(shared_from_this()); 40 | 41 | Update(); 42 | Show(); 43 | } 44 | 45 | 46 | NuoButton::~NuoButton() 47 | { 48 | if (_hWnd) 49 | { 50 | DestroyWindow(_hWnd); 51 | _hWnd = 0; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoRenderTargetSwapChain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "NuoDevice.h" 12 | #include "NuoResourceSwapChain.h" 13 | #include "NuoRenderTarget.h" 14 | #include "NuoDescriptorHeap.h" 15 | 16 | 17 | class NuoRenderTargetSwapChain; 18 | typedef std::shared_ptr PNuoRenderTargetSwapChain; 19 | typedef std::weak_ptr WPNuoRenderTargetSwapChain; 20 | 21 | 22 | 23 | class NuoRenderTargetSwapChain 24 | { 25 | // back buffers of the _renderTarget are not managed by _renderTarget itself 26 | // but by the swap-chain, so as the descriptor heap 27 | // 28 | // the heap is used only when _sampleCount is 1. when it is greater than 1, 29 | // the direct render target is the sample buffer managed within the _renderTarget 30 | // whose view is also managed from within. 31 | // 32 | PNuoDescriptorHeap _rtvHeap; 33 | PNuoResourceSwapChain _backBuffers; 34 | WPNuoDevice _device; 35 | PNuoRenderTarget _renderTarget; 36 | 37 | unsigned int _sampleCount; 38 | 39 | public: 40 | 41 | NuoRenderTargetSwapChain(const PNuoDevice& device, DXGI_FORMAT format, 42 | const PNuoResourceSwapChain& backBuffers, 43 | unsigned int sampleCount); 44 | 45 | PNuoRenderTarget RenderTarget(unsigned int inFlight); 46 | 47 | private: 48 | 49 | // used only when _sampleCount is 1 50 | // 51 | D3D12_CPU_DESCRIPTOR_HANDLE DxRenderTargetView(unsigned int inFlight); 52 | }; 53 | 54 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUtilites/NuoMathVector.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoMathVectorMac.cpp 3 | // ModelViewer 4 | // 5 | // Created by Dong on 5/11/18. 6 | // Copyright © 2018 middleware. All rights reserved. 7 | // 8 | 9 | #include "NuoMathVector.h" 10 | 11 | 12 | 13 | NuoMatrix NuoMatrixScale(const NuoVector& scale) 14 | { 15 | return DirectX::XMMatrixScaling(scale.x(), scale.y(), scale.z()); 16 | } 17 | 18 | 19 | 20 | NuoMatrix NuoMatrixRotationAround(NuoMatrix rotate, NuoVector center) 21 | { 22 | NuoVectorFloat3 transVec1 = -center; 23 | NuoMatrix trans1 = NuoMatrixTranslation(transVec1); 24 | NuoVectorFloat3 transVec2 = center; 25 | NuoMatrix trans2 = NuoMatrixTranslation(transVec2); 26 | 27 | return (trans2 * (rotate * trans1)); 28 | } 29 | 30 | 31 | NuoMatrix NuoMatrixLookAt(const NuoVector& eye, 32 | const NuoVector& center, 33 | const NuoVector& up) 34 | { 35 | DirectX::XMVECTOR aeye = NuoXMLoad(eye._vector); 36 | ((DirectX::XMVECTORF32*) &aeye)->f[3] = 1.0f; 37 | 38 | DirectX::XMVECTOR acenter = NuoXMLoad(center._vector); 39 | ((DirectX::XMVECTORF32*) &acenter)->f[3] = 1.0f; 40 | 41 | DirectX::XMVECTOR aup = NuoXMLoad(up._vector); 42 | 43 | return DirectX::XMMatrixLookAtRH(aeye, acenter, aup); 44 | } 45 | 46 | 47 | 48 | const NuoMatrix NuoMatrixFloat44Identity; 49 | const NuoMatrix NuoMatrixFloat34Identity; 50 | 51 | 52 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUtilites/NuoDispatch.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoDispatch.cpp 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 1/14/2021. 6 | // Copyright © 2021 middleware. All rights reserved. 7 | // 8 | 9 | #include "NuoDispatch.h" 10 | 11 | #include 12 | #include 13 | 14 | 15 | NuoDispatch* NuoDispatch::_dispatch = nullptr; 16 | 17 | 18 | 19 | void NuoDispatch::BackThreadFunc(NuoDispatch* dispatch) 20 | { 21 | while (dispatch->_running) 22 | { 23 | dispatch->Execute(); 24 | } 25 | } 26 | 27 | 28 | 29 | NuoDispatch* NuoDispatch::GetInstance() 30 | { 31 | if (!_dispatch) 32 | { 33 | _dispatch = new NuoDispatch(); 34 | } 35 | 36 | return _dispatch; 37 | } 38 | 39 | 40 | void NuoDispatch::DispatchAsync(std::function work) 41 | { 42 | { 43 | std::unique_lock locker(_mutex); 44 | _works.push(work); 45 | } 46 | 47 | _condition.notify_all(); 48 | } 49 | 50 | 51 | void NuoDispatch::Execute() 52 | { 53 | SetThreadDescription(GetCurrentThread(), L"Dispatch Thread"); 54 | 55 | std::function work; 56 | 57 | { 58 | std::unique_lock locker(_mutex); 59 | 60 | _condition.wait(locker, [this] 61 | { 62 | return _works.size() > 0; 63 | }); 64 | 65 | work = _works.front(); 66 | _works.pop(); 67 | } 68 | 69 | work(); 70 | } 71 | 72 | 73 | NuoDispatch::NuoDispatch() 74 | : _running(true) 75 | { 76 | _backthread = std::thread(BackThreadFunc, this); 77 | } 78 | 79 | 80 | NuoDispatch::~NuoDispatch() 81 | { 82 | _running = false; 83 | _backthread.join(); 84 | } 85 | 86 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoFenceSwapChain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | class NuoCommandQueue; 13 | typedef std::shared_ptr PNuoCommandQueue; 14 | 15 | class NuoDirectView; 16 | typedef std::shared_ptr PNuoDirectView; 17 | 18 | 19 | class NuoFenceSwapChain; 20 | typedef std::shared_ptr PNuoFenceSwapChain; 21 | typedef std::weak_ptr WPNuoFenceSwapChain; 22 | 23 | 24 | 25 | class NuoFenceSwapChain 26 | { 27 | 28 | Microsoft::WRL::ComPtr _fence; 29 | std::vector _fenceValues; 30 | 31 | HANDLE _fenceEvent; 32 | 33 | // used for multi-in-flight-frame rotation 34 | // 35 | UINT64 _currentFenceValue; 36 | 37 | public: 38 | 39 | NuoFenceSwapChain(unsigned int frameCount); 40 | ~NuoFenceSwapChain(); 41 | 42 | void WaitForGPU(const PNuoDirectView& view); 43 | void WaitForGPU(const PNuoCommandQueue& commandQueue); 44 | 45 | // present() calls the view to present the current buffer of its swap-chain 46 | // and puts GPU fence 47 | // 48 | // prepareFrame() checks the GPU fence to make sure a frame's supporting buffers 49 | // are not reused until its previous owner has been presented 50 | // 51 | void Present(const PNuoDirectView& view); 52 | void PrepareFrame(const PNuoDirectView& view); 53 | 54 | friend class NuoDevice; 55 | 56 | private: 57 | 58 | void WaitForGPU(const PNuoCommandQueue& commandQueue, unsigned int inFlight); 59 | 60 | }; 61 | 62 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/ModelViewerMain.cpp: -------------------------------------------------------------------------------- 1 | // NuoDirect.cpp : Defines the entry point for the application. 2 | // 3 | 4 | #include "framework.h" 5 | #include "ModelViewerMain.h" 6 | 7 | #include "NuoImage.h" 8 | #include "NuoAppInstance.h" 9 | 10 | #include "ModelViewerWindow.h" 11 | 12 | 13 | int APIENTRY wWinMain(_In_ HINSTANCE hInstance, 14 | _In_opt_ HINSTANCE hPrevInstance, 15 | _In_ LPWSTR lpCmdLine, 16 | _In_ int nCmdShow) 17 | { 18 | UNREFERENCED_PARAMETER(hPrevInstance); 19 | UNREFERENCED_PARAMETER(lpCmdLine); 20 | 21 | NuoAppInstance::Init(hInstance, nCmdShow); 22 | NuoWindow::RegisterClass(); 23 | 24 | PNuoDirectWindow window = std::make_shared(" Model Viewer"); 25 | window->Init(); 26 | 27 | PNuoIcon icon = std::make_shared(IDI_NUODIRECT); 28 | window->SetIcon(icon); 29 | 30 | auto exitFunc = []() 31 | { 32 | NuoAppInstance::Exit(); 33 | }; 34 | window->SetOnDestroy(exitFunc); 35 | window->Show(); 36 | window->Update(); 37 | 38 | HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_NUODIRECT)); 39 | 40 | MSG msg; 41 | 42 | // Main message loop: 43 | while (GetMessage(&msg, nullptr, 0, 0)) 44 | { 45 | if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 46 | { 47 | TranslateMessage(&msg); 48 | DispatchMessage(&msg); 49 | } 50 | } 51 | 52 | NuoAppInstance::UnInit(); 53 | 54 | return (int) msg.wParam; 55 | } 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoDescriptorHeap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | class NuoDevice; 12 | typedef std::shared_ptr PNuoDevice; 13 | 14 | 15 | class NuoDescriptorHeap; 16 | typedef std::shared_ptr PNuoDescriptorHeap; 17 | typedef std::weak_ptr WPNuoDescriptorHeap; 18 | 19 | class NuoTexture; 20 | typedef std::shared_ptr PNuoTexture; 21 | 22 | class NuoResource; 23 | typedef std::shared_ptr PNuoResource; 24 | 25 | 26 | enum NuoDescriptorType 27 | { 28 | kNuoDescriptor_RenderTarget, 29 | kNuoDescriptor_DepthStencil, 30 | kNuoDescriptor_ShaderResource 31 | }; 32 | 33 | 34 | 35 | class NuoDescriptorHeap 36 | { 37 | 38 | PNuoDevice _device; 39 | 40 | NuoDescriptorType _type; 41 | unsigned int _size; 42 | Microsoft::WRL::ComPtr _heap; 43 | 44 | private: 45 | 46 | NuoDescriptorHeap(NuoDescriptorType type); 47 | 48 | public: 49 | 50 | unsigned int Incremental(); 51 | 52 | D3D12_CPU_DESCRIPTOR_HANDLE DxCPUHandle(unsigned int inFlight); 53 | D3D12_GPU_DESCRIPTOR_HANDLE DxGPUHandle(unsigned int inFlight); 54 | D3D12_CPU_DESCRIPTOR_HANDLE DxHeapCPUHandle(); 55 | D3D12_GPU_DESCRIPTOR_HANDLE DxHeapGPUHandle(); 56 | 57 | void SetTexture(unsigned int index, const PNuoTexture& texture); 58 | void SetConstantBuffer(unsigned int index, const PNuoResource& buffer); 59 | 60 | ID3D12DescriptorHeap* DxHeap() const; 61 | 62 | friend class NuoDevice; 63 | 64 | }; 65 | 66 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoAppInstance.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "NuoAppInstance.h" 3 | #include "NuoStrings.h" 4 | 5 | #include 6 | 7 | 8 | static NuoAppInstance* gInstance = nullptr; 9 | 10 | ULONG_PTR NuoAppInstance::_gdiToken = 0; 11 | 12 | 13 | NuoAppInstance::NuoAppInstance(HINSTANCE hInstance, int cmdShow) 14 | : _instance(hInstance), 15 | _cmdShow(cmdShow) 16 | { 17 | } 18 | 19 | 20 | NuoAppInstance* NuoAppInstance::GetInstance() 21 | { 22 | return gInstance; 23 | } 24 | 25 | 26 | void NuoAppInstance::Init(HINSTANCE hInstance, int cmdShow) 27 | { 28 | gInstance = new NuoAppInstance(hInstance, cmdShow); 29 | 30 | SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); 31 | CoInitializeEx(0, COINIT_MULTITHREADED); 32 | OleInitialize(0); 33 | 34 | ULONG_PTR token; 35 | Gdiplus::GdiplusStartupInput gdiplusStartupInput; 36 | auto status = Gdiplus::GdiplusStartup(&_gdiToken, &gdiplusStartupInput, NULL); 37 | } 38 | 39 | 40 | void NuoAppInstance::UnInit() 41 | { 42 | Gdiplus::GdiplusShutdown(_gdiToken); 43 | _gdiToken = 0; 44 | 45 | OleUninitialize(); 46 | CoUninitialize(); 47 | } 48 | 49 | 50 | HINSTANCE NuoAppInstance::Instance() 51 | { 52 | return _instance; 53 | } 54 | 55 | 56 | int NuoAppInstance::CommandShow() 57 | { 58 | return _cmdShow; 59 | } 60 | 61 | 62 | std::string NuoAppInstance::ModulePath() 63 | { 64 | TCHAR szFileName[MAX_PATH]; 65 | GetModuleFileName(_instance, szFileName, MAX_PATH); 66 | 67 | std::string result = StringToUTF8(szFileName); 68 | return result; 69 | } 70 | 71 | 72 | void NuoAppInstance::Exit() 73 | { 74 | ::PostQuitMessage(0); 75 | } -------------------------------------------------------------------------------- /lua/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoModelLoader/NuoModelLoaderGPU.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoModelLoader.h 3 | // ModelViewer 4 | // 5 | // Created by middleware on 8/26/16. 6 | // Copyright © 2016 middleware. All rights reserved. 7 | // 8 | 9 | 10 | 11 | #ifndef __NUO_MODEL_LOADER_GPU__ 12 | #define __NUO_MODEL_LOADER_GPU__ 13 | 14 | 15 | #include "NuoModelBase.h" 16 | #include "NuoModelLoader.h" 17 | #include 18 | 19 | #include 20 | 21 | 22 | typedef std::shared_ptr PNuoModelBase; 23 | typedef std::function NuoModelLoaderProgress; 24 | 25 | class NuoCommandQueue; 26 | typedef std::shared_ptr PNuoCommandQueue; 27 | 28 | class NuoMeshCompound; 29 | typedef std::shared_ptr PNuoMeshCompound; 30 | 31 | class NuoResource; 32 | typedef std::shared_ptr PNuoResource; 33 | 34 | 35 | class NuoModelLoaderGPU 36 | { 37 | 38 | PNuoModelLoader _loader; 39 | 40 | DXGI_FORMAT _format; 41 | 42 | public: 43 | 44 | NuoModelLoaderGPU(const PNuoModelLoader& loader, DXGI_FORMAT format); 45 | ~NuoModelLoaderGPU(); 46 | 47 | /** 48 | * Create a renderable GPU mesh. A GPU mesh consists of the continuous buffer where the vertex data 49 | * is stored, the associated textures, and the associated pipeline state used for rendering. 50 | */ 51 | PNuoMeshCompound CreateMesh(const NuoMeshOptions& loadOption, 52 | const PNuoCommandQueue& commandQueue, 53 | NuoModelLoaderProgress progress); 54 | 55 | }; 56 | 57 | typedef std::shared_ptr PNuoModelLoaderGPU; 58 | 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoCommandQueue.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoCommandQueue.h" 4 | #include "NuoCommandBuffer.h" 5 | #include "NuoStrings.h" 6 | 7 | #include 8 | #include 9 | 10 | 11 | 12 | NuoCommandQueue::NuoCommandQueue(const PNuoDevice& device) 13 | : _device(device) 14 | { 15 | D3D12_COMMAND_QUEUE_DESC queueDesc = {}; 16 | queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; 17 | queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; 18 | 19 | _device->DxDevice()->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&_dxQueue)); 20 | } 21 | 22 | 23 | PNuoDevice NuoCommandQueue::Device() const 24 | { 25 | return _device; 26 | } 27 | 28 | 29 | void NuoCommandQueue::ReleasePendingCommandBuffers() 30 | { 31 | _pendingCommandBuffers.clear(); 32 | } 33 | 34 | 35 | PNuoCommandBuffer NuoCommandQueue::CreateCommandBuffer() 36 | { 37 | Microsoft::WRL::ComPtr allocator; 38 | 39 | HRESULT hr = Device()->DxDevice()->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, 40 | IID_PPV_ARGS(&allocator)); 41 | assert(hr == S_OK); 42 | 43 | PNuoCommandBuffer commandBuffer = std::make_shared(); 44 | commandBuffer->_commandAllocator = allocator; 45 | commandBuffer->_commandQueue = shared_from_this(); 46 | 47 | // this is not an in-flight command buffer 48 | commandBuffer->SetInFlight(0, 0); 49 | 50 | _pendingCommandBuffers.push_back(commandBuffer); 51 | 52 | return commandBuffer; 53 | } 54 | 55 | 56 | 57 | ID3D12CommandQueue* NuoCommandQueue::DxQueue() const 58 | { 59 | return _dxQueue.Get(); 60 | } 61 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoResource.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoResource.h" 4 | 5 | 6 | 7 | NuoResource::NuoResource() 8 | : _mapped(nullptr) 9 | { 10 | } 11 | 12 | NuoResource::~NuoResource() 13 | { 14 | Unmap(); 15 | } 16 | 17 | 18 | void NuoResource::SetResource(Microsoft::WRL::ComPtr resource, 19 | D3D12_RESOURCE_STATES state) 20 | { 21 | _dxResources = resource; 22 | _desc = _dxResources->GetDesc(); 23 | 24 | _state = state; 25 | } 26 | 27 | 28 | unsigned long NuoResource::Width() const 29 | { 30 | return (unsigned long)_desc.Width; 31 | } 32 | 33 | 34 | unsigned long NuoResource::Height() const 35 | { 36 | return (unsigned long)_desc.Height; 37 | } 38 | 39 | unsigned long NuoResource::Size() const 40 | { 41 | return (unsigned long)(_desc.Width * _desc.Height); 42 | } 43 | 44 | 45 | DXGI_FORMAT NuoResource::Format() const 46 | { 47 | return _desc.Format; 48 | } 49 | 50 | 51 | unsigned int NuoResource::SampleCount() const 52 | { 53 | return _desc.SampleDesc.Count; 54 | } 55 | 56 | 57 | void* NuoResource::Map() 58 | { 59 | if (!_mapped) 60 | { 61 | D3D12_RANGE readRange = { 0, 0 }; 62 | _dxResources->Map(0, &readRange, &_mapped); 63 | } 64 | 65 | return _mapped; 66 | } 67 | 68 | 69 | void NuoResource::Unmap() 70 | { 71 | if (!_mapped) 72 | return; 73 | 74 | _dxResources->Unmap(0, nullptr); 75 | _mapped = nullptr; 76 | } 77 | 78 | 79 | ID3D12Resource* NuoResource::DxResource() const 80 | { 81 | return _dxResources.Get(); 82 | } 83 | 84 | 85 | D3D12_RESOURCE_STATES NuoResource::State() const 86 | { 87 | return _state; 88 | } 89 | 90 | 91 | void NuoResource::SetState(D3D12_RESOURCE_STATES state) 92 | { 93 | _state = state; 94 | } 95 | 96 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoModelLoader/NuoModelTextured.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoModelTextured.cpp 3 | // ModelViewer 4 | // 5 | // Created by middleware on 9/5/16. 6 | // Copyright © 2016 middleware. All rights reserved. 7 | // 8 | 9 | #include "NuoModelTextured.h" 10 | #include "NuoMaterial.h" 11 | 12 | 13 | 14 | 15 | NuoItemTextured::NuoItemTextured() 16 | { 17 | _position = {}; 18 | _normal = {}; 19 | _texCoord = {}; 20 | } 21 | 22 | 23 | bool NuoItemTextured::operator == (const NuoItemTextured& i2) 24 | { 25 | return 26 | (_position == i2._position) && 27 | (_normal == i2._normal) && 28 | (_texCoord == i2._texCoord); 29 | } 30 | 31 | 32 | 33 | void NuoModelTextured::SetTexturePathOpacity(const std::string texPath) 34 | { 35 | } 36 | 37 | 38 | 39 | std::string NuoModelTextured::GetTexturePathOpacity() 40 | { 41 | return std::string(); 42 | } 43 | 44 | 45 | 46 | bool NuoModelTextured::HasTransparent() 47 | { 48 | return false; 49 | } 50 | 51 | 52 | void NuoModelTextured::GenerateTangents() 53 | { 54 | } 55 | 56 | 57 | void NuoModelTextured::SetTexturePathBump(const std::string texPath) 58 | { 59 | } 60 | 61 | 62 | std::string NuoModelTextured::GetTexturePathBump() 63 | { 64 | return std::string(); 65 | } 66 | 67 | 68 | 69 | 70 | void NuoModelTextured::AddMaterial(const NuoMaterial& material) 71 | { 72 | } 73 | 74 | 75 | 76 | std::shared_ptr NuoModelTextured::GetUnifiedMaterial() 77 | { 78 | return nullptr; 79 | } 80 | 81 | 82 | void NuoModelTextured::UpdateBufferWithUnifiedMaterial() 83 | { 84 | } 85 | 86 | 87 | 88 | NuoMaterial NuoModelTextured::GetMaterial(size_t primtiveIndex) const 89 | { 90 | return NuoMaterial(); 91 | } 92 | 93 | 94 | -------------------------------------------------------------------------------- /lua/src/lopnames.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopnames.h $ 3 | ** Opcode names 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #if !defined(lopnames_h) 8 | #define lopnames_h 9 | 10 | #include 11 | 12 | 13 | /* ORDER OP */ 14 | 15 | static const char *const opnames[] = { 16 | "MOVE", 17 | "LOADI", 18 | "LOADF", 19 | "LOADK", 20 | "LOADKX", 21 | "LOADFALSE", 22 | "LFALSESKIP", 23 | "LOADTRUE", 24 | "LOADNIL", 25 | "GETUPVAL", 26 | "SETUPVAL", 27 | "GETTABUP", 28 | "GETTABLE", 29 | "GETI", 30 | "GETFIELD", 31 | "SETTABUP", 32 | "SETTABLE", 33 | "SETI", 34 | "SETFIELD", 35 | "NEWTABLE", 36 | "SELF", 37 | "ADDI", 38 | "ADDK", 39 | "SUBK", 40 | "MULK", 41 | "MODK", 42 | "POWK", 43 | "DIVK", 44 | "IDIVK", 45 | "BANDK", 46 | "BORK", 47 | "BXORK", 48 | "SHRI", 49 | "SHLI", 50 | "ADD", 51 | "SUB", 52 | "MUL", 53 | "MOD", 54 | "POW", 55 | "DIV", 56 | "IDIV", 57 | "BAND", 58 | "BOR", 59 | "BXOR", 60 | "SHL", 61 | "SHR", 62 | "MMBIN", 63 | "MMBINI", 64 | "MMBINK", 65 | "UNM", 66 | "BNOT", 67 | "NOT", 68 | "LEN", 69 | "CONCAT", 70 | "CLOSE", 71 | "TBC", 72 | "JMP", 73 | "EQ", 74 | "LT", 75 | "LE", 76 | "EQK", 77 | "EQI", 78 | "LTI", 79 | "LEI", 80 | "GTI", 81 | "GEI", 82 | "TEST", 83 | "TESTSET", 84 | "CALL", 85 | "TAILCALL", 86 | "RETURN", 87 | "RETURN0", 88 | "RETURN1", 89 | "FORLOOP", 90 | "FORPREP", 91 | "TFORPREP", 92 | "TFORCALL", 93 | "TFORLOOP", 94 | "SETLIST", 95 | "CLOSURE", 96 | "VARARG", 97 | "VARARGPREP", 98 | "EXTRAARG", 99 | NULL 100 | }; 101 | 102 | #endif 103 | 104 | -------------------------------------------------------------------------------- /lua/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i)) 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ 41 | (buff)->buffsize, size), \ 42 | (buff)->buffsize = size) 43 | 44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 45 | 46 | 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 50 | 51 | 52 | 53 | /* --------- Private Part ------------------ */ 54 | 55 | struct Zio { 56 | size_t n; /* bytes still unread */ 57 | const char *p; /* current position in buffer */ 58 | lua_Reader reader; /* reader function */ 59 | void *data; /* additional data */ 60 | lua_State *L; /* Lua state (for reader) */ 61 | }; 62 | 63 | 64 | LUAI_FUNC int luaZ_fill (ZIO *z); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoLabel.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "NuoLabel.h" 3 | 4 | #include "NuoStrings.h" 5 | #include "NuoAppInstance.h" 6 | #include "NuoDialog.h" 7 | 8 | 9 | NuoLabel::NuoLabel(const PNuoWindow& parent) 10 | : NuoControl("", parent) 11 | { 12 | } 13 | 14 | 15 | void NuoLabel::Init(bool image) 16 | { 17 | PNuoWindow parent = _parent.lock(); 18 | 19 | int flag = WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_FLAT; 20 | if (image) 21 | flag |= SS_BITMAP; 22 | 23 | _hWnd = CreateWindow(L"STATIC", // Predefined class; Unicode assumed 24 | NULL, // Button text 25 | flag, // Styles 26 | 10, 10, 300, 40, // Button height 27 | parent->Handle(), // Parent window 28 | NULL, // No menu. 29 | NuoAppInstance::GetInstance()->Instance(), 30 | NULL); 31 | 32 | SetWindowLongPtr(_hWnd, kWindowPtr, (LONG_PTR)this); 33 | parent->Add(shared_from_this()); 34 | 35 | Update(); 36 | Show(); 37 | } 38 | 39 | 40 | void NuoLabel::SetText(const std::string& text) 41 | { 42 | std::wstring wtext = StringToUTF16(text); 43 | 44 | SetWindowText(_hWnd, wtext.c_str()); 45 | } 46 | 47 | 48 | void NuoLabel::SetImage(const PNuoImage& image) 49 | { 50 | _image = image; 51 | 52 | SendMessage(_hWnd, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)((HBITMAP)(*_image))); 53 | } 54 | 55 | 56 | PNuoImage NuoLabel::Image() const 57 | { 58 | return _image; 59 | } 60 | 61 | 62 | NuoLabel::~NuoLabel() 63 | { 64 | if (_hWnd) 65 | { 66 | DestroyWindow(_hWnd); 67 | _hWnd = 0; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoRender/NuoRenderPass.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoRendererPass.h 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 3/29/21. 6 | // Copyright © 2021 Dong Feng. All rights reserved. 7 | // 8 | 9 | #include 10 | #include "NuoDirect/NuoSize.h" 11 | 12 | 13 | class NuoCommandBuffer; 14 | typedef std::shared_ptr PNuoCommandBuffer; 15 | 16 | class NuoRenderTarget; 17 | typedef std::shared_ptr PNuoRenderTarget; 18 | typedef std::weak_ptr WPNuoRenderTarget; 19 | 20 | class NuoCommandEncoder; 21 | typedef std::shared_ptr PNuoCommandEncoder; 22 | 23 | 24 | class NuoRenderPass 25 | { 26 | 27 | protected: 28 | 29 | PNuoRenderTarget _renderTarget; 30 | 31 | /** 32 | * The transient target which is managed from outside 33 | */ 34 | WPNuoRenderTarget _renderTargetTransient; 35 | 36 | public: 37 | 38 | virtual void SetDrawableSize(const NuoSize& size); 39 | virtual void SetSampleCount(unsigned int sampleCount) = 0; 40 | 41 | /** 42 | * draw calls that target to their own target (e.g. shadow map texture) 43 | */ 44 | virtual void PredrawWithCommandBuffer(const PNuoCommandBuffer& commandBuffer) = 0; 45 | 46 | /** 47 | * draw calls that target to the *_renderTarget* 48 | */ 49 | virtual void DrawWithCommandBuffer(const PNuoCommandBuffer& commandBuffer) = 0; 50 | 51 | virtual bool IsPipelinePass() const; 52 | 53 | virtual PNuoCommandEncoder RetainDefaultEncoder(const PNuoCommandBuffer& commandBuffer); 54 | virtual void ReleaseDefaultEncoder(); 55 | 56 | void SetRenderTarget(const PNuoRenderTarget& renderTarget); 57 | void SetTransientRenderTarget(const WPNuoRenderTarget& renderTarget); 58 | PNuoRenderTarget RenderTarget(); 59 | 60 | }; 61 | 62 | 63 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoShaders/NuoMeshMaterialed.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __NuoMeshMaterialed_h__ 4 | #define __NuoMeshMaterialed_h__ 5 | 6 | 7 | #include "NuoMeshShaderType.h" 8 | 9 | 10 | 11 | struct NuoMaterialedTexturedBasicItem 12 | { 13 | float4 _position SHADER_SEMATIC(POSITION); 14 | float4 _normal SHADER_SEMATIC(NORMAL); 15 | float2 _texCoord SHADER_SEMATIC(TEX_COORD); 16 | 17 | float3 _diffuse SHADER_SEMATIC(DIFFUSE); 18 | float3 _ambient SHADER_SEMATIC(AMBIENT); 19 | float3 _specular SHADER_SEMATIC(SPECULAR); 20 | float3 _shinessDisolveIllum SHADER_SEMATIC(SHINESS_DISOLVE_ILLUM); 21 | }; 22 | 23 | 24 | struct NuoMaterialedBasicItem 25 | { 26 | float4 _position SHADER_SEMATIC(POSITION); 27 | float4 _normal SHADER_SEMATIC(NORMAL); 28 | 29 | float3 _diffuse SHADER_SEMATIC(DIFFUSE); 30 | float3 _ambient SHADER_SEMATIC(AMBIENT); 31 | float3 _specular SHADER_SEMATIC(SPECULAR); 32 | float3 _shinessDisolveIllum SHADER_SEMATIC(SHINESS_DISOLVE_ILLUM); 33 | }; 34 | 35 | 36 | struct NuoMaterialedBasicVertexOutput 37 | { 38 | float4 _position SHADER_SEMATIC(SV_Position); 39 | float3 _eye SHADER_SEMATIC(EYE_DIRECTION); 40 | float3 _normal SHADER_SEMATIC(NORMAL); 41 | 42 | float3 _diffuse SHADER_SEMATIC(DIFFUSE); 43 | float3 _ambient SHADER_SEMATIC(AMBIENT); 44 | float3 _specular SHADER_SEMATIC(SPECULAR); 45 | float3 _shinessDisolveIllum SHADER_SEMATIC(SHINESS_DISOLVE_ILLUM); 46 | }; 47 | 48 | 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | 12 | class NuoMenuItem; 13 | typedef std::shared_ptr PNuoMenuItem; 14 | 15 | class NuoMenu; 16 | typedef std::shared_ptr PNuoMenu; 17 | 18 | 19 | class NuoMenuBar 20 | { 21 | HMENU _hMenu; 22 | 23 | std::vector _menus; 24 | 25 | public: 26 | 27 | NuoMenuBar(); 28 | ~NuoMenuBar(); 29 | 30 | void AppendMenu(const PNuoMenu& menu); 31 | void Update(); 32 | HMENU Handle() const; 33 | 34 | bool DoAction(int id); 35 | }; 36 | 37 | 38 | 39 | class NuoMenu 40 | { 41 | HMENU _hMenu; 42 | 43 | std::vector _items; 44 | std::map _itemsMap; 45 | 46 | std::string _title; 47 | 48 | public: 49 | NuoMenu(const std::string& title); 50 | ~NuoMenu(); 51 | 52 | void AppenMenuItem(const PNuoMenuItem& item); 53 | void Update(); 54 | 55 | std::string Title() const; 56 | HMENU Handle() const; 57 | 58 | bool HasID(int id) const; 59 | void DoActionForID(int id); 60 | }; 61 | 62 | 63 | typedef std::function MenuAction; 64 | 65 | 66 | class NuoMenuItem : public std::enable_shared_from_this 67 | { 68 | std::string _text; 69 | 70 | public: 71 | enum Type 72 | { 73 | kMenuItem_String, 74 | kMenuItem_Separator 75 | }; 76 | 77 | NuoMenuItem(int id, const Type type); 78 | NuoMenuItem(int id, const std::string& text); 79 | 80 | Type MenuType() const; 81 | std::string Text() const; 82 | int ID() const; 83 | 84 | void SetAction(MenuAction action); 85 | void DoAction(); 86 | 87 | private: 88 | 89 | Type _type; 90 | int _id; 91 | 92 | MenuAction _action; 93 | }; -------------------------------------------------------------------------------- /lua/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | /* 16 | ** Memory-allocation error message must be preallocated (it cannot 17 | ** be created after memory is exhausted) 18 | */ 19 | #define MEMERRMSG "not enough memory" 20 | 21 | 22 | /* 23 | ** Size of a TString: Size of the header plus space for the string 24 | ** itself (including final '\0'). 25 | */ 26 | #define sizelstring(l) (offsetof(TString, contents) + ((l) + 1) * sizeof(char)) 27 | 28 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 29 | (sizeof(s)/sizeof(char))-1)) 30 | 31 | 32 | /* 33 | ** test whether a string is a reserved word 34 | */ 35 | #define isreserved(s) ((s)->tt == LUA_VSHRSTR && (s)->extra > 0) 36 | 37 | 38 | /* 39 | ** equality for short strings, which are always internalized 40 | */ 41 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_VSHRSTR, (a) == (b)) 42 | 43 | 44 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 45 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); 46 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 47 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 48 | LUAI_FUNC void luaS_clearcache (global_State *g); 49 | LUAI_FUNC void luaS_init (lua_State *L); 50 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 51 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, int nuvalue); 52 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 53 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 54 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); 55 | 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/NuoControl.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "NuoRect.h" 11 | #include "NuoWindow.h" 12 | 13 | 14 | enum NuoControlAutoPosition 15 | { 16 | kNuoControl_NoneAuto = 0x00, 17 | kNuoControl_RT, 18 | kNuoControl_R, 19 | kNuoControl_LB, 20 | kNuoControl_RB, 21 | 22 | kNuoControl_Stretch = 0x1000000, 23 | kNuoControl_Stretch_L = kNuoControl_Stretch | 0x0001, 24 | kNuoControl_Stretch_T = kNuoControl_Stretch | 0x0010, 25 | kNuoControl_Stretch_R = kNuoControl_Stretch | 0x0100, 26 | kNuoControl_Stretch_B = kNuoControl_Stretch | 0x1000, 27 | kNuoControl_Stretch_ALL = kNuoControl_Stretch_L | kNuoControl_Stretch_T | 28 | kNuoControl_Stretch_R | kNuoControl_Stretch_B 29 | }; 30 | 31 | 32 | typedef std::function CommandFunc; 33 | 34 | 35 | class NuoControl : public NuoWindow 36 | { 37 | 38 | protected: 39 | 40 | NuoControlAutoPosition _autoPosition; 41 | 42 | std::weak_ptr _parent; 43 | int _id; 44 | 45 | CommandFunc _commandFunc; 46 | 47 | NuoInset _parentMargin; 48 | 49 | public: 50 | 51 | NuoControl(const std::string& title, const PNuoWindow& parent); 52 | virtual ~NuoControl(); 53 | 54 | void SetFocus(); 55 | virtual NuoRect PositionDevice() override; 56 | virtual NuoRect Position(); 57 | virtual void SetPosition(const NuoRect& pos, bool activate); 58 | 59 | void SetAutoPosition(NuoControlAutoPosition autoPos); 60 | NuoControlAutoPosition AutoPosition() const; 61 | 62 | void SetMargin(const NuoInset& inset); 63 | 64 | int ID() const; 65 | 66 | virtual NuoRect AutoPosition(); 67 | 68 | virtual void OnCommand(int notification); 69 | virtual void SetOnCommand(const CommandFunc& func); 70 | }; 71 | 72 | 73 | typedef std::shared_ptr PNuoControl; 74 | 75 | -------------------------------------------------------------------------------- /lua/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | /* 12 | ** If you embed Lua in your program and need to open the standard 13 | ** libraries, call luaL_openlibs in your program. If you need a 14 | ** different set of libraries, copy this file to your project and edit 15 | ** it to suit your needs. 16 | ** 17 | ** You can also *preload* libraries, so that a later 'require' can 18 | ** open the library, which is already linked to the application. 19 | ** For that, do the following code: 20 | ** 21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); 22 | ** lua_pushcfunction(L, luaopen_modname); 23 | ** lua_setfield(L, -2, modname); 24 | ** lua_pop(L, 1); // remove PRELOAD table 25 | */ 26 | 27 | #include "lprefix.h" 28 | 29 | 30 | #include 31 | 32 | #include "lua.h" 33 | 34 | #include "lualib.h" 35 | #include "lauxlib.h" 36 | 37 | 38 | /* 39 | ** these libs are loaded by lua.c and are readily available to any Lua 40 | ** program 41 | */ 42 | static const luaL_Reg loadedlibs[] = { 43 | {LUA_GNAME, luaopen_base}, 44 | {LUA_LOADLIBNAME, luaopen_package}, 45 | {LUA_COLIBNAME, luaopen_coroutine}, 46 | {LUA_TABLIBNAME, luaopen_table}, 47 | {LUA_IOLIBNAME, luaopen_io}, 48 | {LUA_OSLIBNAME, luaopen_os}, 49 | {LUA_STRLIBNAME, luaopen_string}, 50 | {LUA_MATHLIBNAME, luaopen_math}, 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, 52 | {LUA_DBLIBNAME, luaopen_debug}, 53 | {NULL, NULL} 54 | }; 55 | 56 | 57 | LUALIB_API void luaL_openlibs (lua_State *L) { 58 | const luaL_Reg *lib; 59 | /* "require" functions from 'loadedlibs' and set results to global table */ 60 | for (lib = loadedlibs; lib->func; lib++) { 61 | luaL_requiref(L, lib->name, lib->func, 1); 62 | lua_pop(L, 1); /* remove lib */ 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoRender/NuoRenderPipelinePass.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoRenderPipelinePass.cpp 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 3/30/21. 6 | // Copyright © 2021 Dong Feng. All rights reserved. 7 | // 8 | 9 | #include "NuoRenderPipelinePass.h" 10 | #include "NuoMeshes/NuoAuxilliaryMeshes/NuoScreenSpaceMesh.h" 11 | 12 | 13 | 14 | NuoRenderPipelinePass::NuoRenderPipelinePass(const PNuoCommandBuffer& commandBuffer, 15 | unsigned int frameCount, 16 | std::vector& intermediate, 17 | DXGI_FORMAT format) 18 | { 19 | _textureMesh = std::make_shared(commandBuffer, 1); 20 | _textureMesh->Init(commandBuffer, frameCount, intermediate, format); 21 | } 22 | 23 | 24 | void NuoRenderPipelinePass::Init(const PNuoCommandBuffer& commandBuffer, unsigned int sampleCount) 25 | { 26 | _textureMesh->SetSampleCount(sampleCount); 27 | _textureMesh->MakePipelineState(commandBuffer); 28 | } 29 | 30 | 31 | void NuoRenderPipelinePass::SetSourceTextrue(const PNuoTexture& texture) 32 | { 33 | _textureMesh->SetTexture(nullptr, texture); 34 | } 35 | 36 | 37 | void NuoRenderPipelinePass::DrawWithCommandBuffer(const PNuoCommandBuffer& commandBuffer) 38 | { 39 | PNuoCommandEncoder encoder = RetainDefaultEncoder(commandBuffer); 40 | 41 | encoder->SetViewport(NuoViewport()); 42 | 43 | /** 44 | * clear depth. an alternate isto have TextureMesh write in the depth as 1.0 (which 45 | * it is not doing though) 46 | */ 47 | encoder->ClearDepth(); 48 | 49 | _textureMesh->DrawBegin(encoder, [](NuoCommandEncoder* encoder) {}); 50 | _textureMesh->Draw(encoder); 51 | 52 | ReleaseDefaultEncoder(); 53 | } 54 | 55 | 56 | bool NuoRenderPipelinePass::IsPipelinePass() const 57 | { 58 | return true; 59 | } 60 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoRenderTargetSwapChain.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoRenderTargetSwapChain.h" 4 | 5 | 6 | 7 | 8 | NuoRenderTargetSwapChain::NuoRenderTargetSwapChain(const PNuoDevice& device, DXGI_FORMAT format, 9 | const PNuoResourceSwapChain& backBuffers, 10 | unsigned int sampleCount) 11 | : _device(device), 12 | _backBuffers(backBuffers), 13 | _sampleCount(sampleCount) 14 | { 15 | PNuoResource backBuffer = (*_backBuffers)[0]; 16 | auto w = backBuffer->Width(); 17 | auto h = backBuffer->Height(); 18 | 19 | _rtvHeap = device->CreateRenderTargetHeap(_backBuffers->Count()); 20 | _renderTarget = std::make_shared(device, format, sampleCount, true, false); 21 | _renderTarget->SetDrawableSize(NuoSize(w, h)); 22 | 23 | if (sampleCount == 1) 24 | { 25 | for (UINT n = 0; n < _backBuffers->Count(); n++) 26 | { 27 | // retrieve the n-th handle from _rtvHeap 28 | D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = DxRenderTargetView(n); 29 | 30 | // create a rtv upon the handle for the n-th buffer in _resources 31 | PNuoResource resource = (*_backBuffers)[n]; 32 | 33 | device->DxDevice()->CreateRenderTargetView(resource->DxResource(), nullptr, rtvHandle); 34 | } 35 | } 36 | } 37 | 38 | 39 | PNuoRenderTarget NuoRenderTargetSwapChain::RenderTarget(unsigned int inFlight) 40 | { 41 | D3D12_CPU_DESCRIPTOR_HANDLE view; 42 | if (_sampleCount == 1) 43 | view = DxRenderTargetView(inFlight); 44 | 45 | _renderTarget->SetBackBuffer((*_backBuffers)[inFlight], view); 46 | 47 | return _renderTarget; 48 | } 49 | 50 | 51 | D3D12_CPU_DESCRIPTOR_HANDLE NuoRenderTargetSwapChain::DxRenderTargetView(unsigned int inFlight) 52 | { 53 | assert(_sampleCount == 1); 54 | 55 | return _rtvHeap->DxCPUHandle(inFlight); 56 | } 57 | 58 | 59 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/ListViewWindow.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "ListViewWindow.h" 3 | //#include 4 | #include 5 | 6 | #include "NuoOpenFileDialog.h" 7 | 8 | #include "resource.h" 9 | 10 | 11 | ListViewWindow::ListViewWindow(const PNuoWindow& appWindow) 12 | : NuoWindow("Icon Tools"), 13 | _appWindow(appWindow) 14 | { 15 | } 16 | 17 | 18 | void ListViewWindow::Init() 19 | { 20 | NuoRect rect(0, 0, 120, 24); 21 | NuoInset buttonInset(20, 20, 20, 20); 22 | 23 | _loadButton = std::make_shared(shared_from_this(), "Load ..."); 24 | _loadButton->Init(IDB_LOADICON); 25 | _loadButton->SetAutoPosition(kNuoControl_RT); 26 | _loadButton->SetPosition(rect, false); 27 | _loadButton->SetMargin(buttonInset); 28 | 29 | auto font = std::make_shared(16, "MS Shell Dlg"); 30 | font->SetItalic(false); 31 | font->SetLight(true); 32 | 33 | _loadButton->SetFont(font); 34 | 35 | _loadButton->SetOnCommand([this](int) 36 | { 37 | 38 | }); 39 | 40 | font = std::make_shared(14, "MS Shell Dlg"); 41 | 42 | NuoInset listInset(30, 20, 35, 165); 43 | _listView = std::make_shared(shared_from_this()); 44 | _listView->Init(IDM_LISTVIEW, kNuoList_Checkbox); 45 | _listView->SetAutoPosition(kNuoControl_Stretch_ALL); 46 | _listView->SetMargin(listInset); 47 | 48 | _listView->AddColumn(0, "Name", 150, kNuoAlign_Left); 49 | _listView->AddColumn(1, "Description", 350, kNuoAlign_Left); 50 | _listView->SetFont(font); 51 | 52 | _listView->AddItem(0, 0, "Windows"); _listView->AddItem(0, 1, "Microsoft desktop operating system."); 53 | } 54 | 55 | 56 | NuoRect ListViewWindow::PreferredRect() const 57 | { 58 | PNuoWindow appWindow = _appWindow.lock(); 59 | NuoRect appRect = appWindow->PositionDevice(); 60 | 61 | float scale = DPI(); 62 | NuoRect result(0, 0, 400 * scale, 300 * scale); 63 | result.SetX(appRect.X() + 30 * scale); 64 | result.SetY(appRect.Y() + 30 * scale); 65 | 66 | return result; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUtilites/NuoModelBoard.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoModelCube.cpp 3 | // ModelViewer 4 | // 5 | // Created by middleware on 5/22/17. 6 | // Copyright © 2017 middleware. All rights reserved. 7 | // 8 | 9 | #include "NuoModelBoard.h" 10 | #include "NuoModelLoader/NuoMaterial.h" 11 | 12 | 13 | 14 | 15 | NuoModelBoard::NuoModelBoard(float width, float height, float thickness) 16 | : NuoModelBoardBase(width, height, thickness), 17 | _diffuse(0.15f, 0.15f, 0.15f), _specular(0.f, 0.f, 0.f), 18 | _specularPower(1) 19 | { 20 | } 21 | 22 | 23 | void NuoModelBoard::AddTexCoord(size_t sourceIndex, const std::vector& texCoordBuffer) 24 | { 25 | } 26 | 27 | 28 | 29 | void NuoModelBoard::AddMaterial(const NuoMaterial& material) 30 | { 31 | } 32 | 33 | 34 | 35 | void NuoModelBoard::GenerateTangents() 36 | { 37 | } 38 | 39 | 40 | void NuoModelBoard::SetTexturePathDiffuse(const std::string texPath) 41 | { 42 | } 43 | 44 | 45 | 46 | std::string NuoModelBoard::GetTexturePathDiffuse() 47 | { 48 | return std::string(); 49 | } 50 | 51 | 52 | void NuoModelBoard::SetTexturePathOpacity(const std::string texPath) 53 | { 54 | } 55 | 56 | 57 | std::string NuoModelBoard::GetTexturePathOpacity() 58 | { 59 | return std::string(); 60 | } 61 | 62 | 63 | void NuoModelBoard::SetTexturePathBump(const std::string texPath) 64 | { 65 | } 66 | 67 | 68 | std::string NuoModelBoard::GetTexturePathBump() 69 | { 70 | return std::string(); 71 | } 72 | 73 | 74 | 75 | NuoMaterial NuoModelBoard::GetMaterial(size_t primtiveIndex) const 76 | { 77 | return NuoMaterial(); 78 | } 79 | 80 | 81 | 82 | bool NuoModelBoard::HasTransparent() 83 | { 84 | return false; 85 | } 86 | 87 | 88 | 89 | std::shared_ptr NuoModelBoard::GetUnifiedMaterial() 90 | { 91 | return nullptr; 92 | } 93 | 94 | 95 | 96 | void NuoModelBoard::UpdateBufferWithUnifiedMaterial() 97 | { 98 | } 99 | 100 | 101 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoAuxilliaryMeshes/NuoScreenSpaceMesh.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoScreenSpaceMesh.h 3 | // ModelViewer 4 | // 5 | // Created by Dong on 9/30/17. 6 | // Copyright © 2017 middleware. All rights reserved. 7 | // 8 | 9 | #include "NuoMeshes/NuoMesh.h" 10 | #include "NuoMeshes/NuoShaders/NuoMeshScreenSpace.h" 11 | 12 | 13 | typedef enum 14 | { 15 | kBlend_Alpha, 16 | kBlend_Accumulate, 17 | kBlend_None 18 | } 19 | ScreenSpaceBlendMode; 20 | 21 | 22 | class NuoScreenSpaceMesh : public NuoMeshBase 23 | { 24 | 25 | protected: 26 | 27 | virtual bool EnableDepth() override; 28 | 29 | public: 30 | 31 | void Init(const PNuoCommandBuffer& commandBuffer, 32 | unsigned int frameCount, 33 | std::vector& intermediate, 34 | DXGI_FORMAT format); 35 | 36 | virtual std::vector InputDesc() override; 37 | virtual PNuoRootSignature RootSignature(const PNuoCommandBuffer& commandBuffer) override; 38 | virtual void MakePipelineState(const PNuoCommandBuffer& commandBuffer) override; 39 | 40 | // screen-space meshes do not have a transform uniform. that requires an overriding 41 | // to the default mesh's Draw() 42 | // 43 | virtual void Draw(const PNuoCommandEncoder& encoder) override; 44 | 45 | }; 46 | 47 | 48 | class NuoTextureMesh : public NuoScreenSpaceMesh 49 | { 50 | 51 | private: 52 | 53 | PNuoTexture _texture; 54 | std::vector _paramHeap; 55 | 56 | public: 57 | 58 | NuoTextureMesh(const PNuoCommandBuffer& buffer, unsigned int frameCount); 59 | 60 | void SetTexture(const NuoRenderInFlight* inFlight, const PNuoTexture& texture); 61 | 62 | virtual bool HasTransparency() const override; 63 | virtual void SetTransparency(bool transparency) override; 64 | 65 | virtual PNuoRootSignature RootSignature(const PNuoCommandBuffer& commandBuffer) override; 66 | virtual void Draw(const PNuoCommandEncoder& encoder) override; 67 | 68 | }; 69 | 70 | 71 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/Renderer/ModelViewerRenderer.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __MODEL_VIEWER_RENDERER_H__ 4 | #define __MODEL_VIEWER_RENDERER_H__ 5 | 6 | #pragma once 7 | 8 | #include "NuoRender/NuoRenderPipelinePass.h" 9 | 10 | #include "NuoUtilites/NuoMathVector.h" 11 | 12 | #include 13 | 14 | 15 | class ModelState; 16 | typedef std::shared_ptr PModelState; 17 | 18 | class NuoResourceSwapChain; 19 | typedef std::shared_ptr PNuoResourceSwapChain; 20 | 21 | class NuoCommandBuffer; 22 | typedef std::shared_ptr PNuoCommandBuffer; 23 | 24 | class ModelSceneParameters; 25 | typedef std::shared_ptr PModelSceneParameters; 26 | 27 | 28 | 29 | class ModelRenderer : public NuoRenderPipelinePass 30 | { 31 | 32 | PModelState _modelState; 33 | 34 | PModelSceneParameters _sceneParameters; 35 | 36 | PNuoTextureMesh _textureMesh; 37 | PNuoResourceSwapChain _light; 38 | PNuoResourceSwapChain _mvp; 39 | 40 | PNuoRenderTarget _intermediateTarget; 41 | 42 | float _zoomDelta; 43 | float _rotationXDelta; 44 | float _rotationYDelta; 45 | float _transXDelta; 46 | float _transYDelta; 47 | 48 | public: 49 | 50 | ModelRenderer(const PNuoCommandBuffer& commandBuffer, unsigned int frameCount, 51 | std::vector& intermediate, DXGI_FORMAT format); 52 | 53 | PModelState State() const; 54 | 55 | void SetFieldOfView(float fieldOfView); 56 | 57 | virtual void SetDrawableSize(const NuoSize& size) override; 58 | virtual void SetSampleCount(unsigned int sampleCount) override; 59 | 60 | virtual void PredrawWithCommandBuffer(const PNuoCommandBuffer& commandBuffer) override; 61 | virtual void DrawWithCommandBuffer(const PNuoCommandBuffer& commandBuffer) override; 62 | 63 | void HandleDeltaPosition(); 64 | 65 | void SetZoomDelta(float z); 66 | void SetRotationDelta(float dx, float dy); 67 | void SetTransDelta(float dx, float dy); 68 | 69 | private: 70 | 71 | void UpdateUniformsForView(const PNuoCommandBuffer& commandBuffer); 72 | 73 | }; 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /lua/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast_int(offsetof(CClosure, upvalue)) + \ 15 | cast_int(sizeof(TValue)) * (n)) 16 | 17 | #define sizeLclosure(n) (cast_int(offsetof(LClosure, upvals)) + \ 18 | cast_int(sizeof(TValue *)) * (n)) 19 | 20 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** maximum number of upvalues in a closure (both C and Lua). (Value 27 | ** must fit in a VM register.) 28 | */ 29 | #define MAXUPVAL 255 30 | 31 | 32 | #define upisopen(up) ((up)->v != &(up)->u.value) 33 | 34 | 35 | #define uplevel(up) check_exp(upisopen(up), cast(StkId, (up)->v)) 36 | 37 | 38 | /* 39 | ** maximum number of misses before giving up the cache of closures 40 | ** in prototypes 41 | */ 42 | #define MAXMISS 10 43 | 44 | 45 | /* 46 | ** Special "status" for 'luaF_close' 47 | */ 48 | 49 | /* close upvalues without running their closing methods */ 50 | #define NOCLOSINGMETH (-1) 51 | 52 | /* close upvalues running all closing methods in protected mode */ 53 | #define CLOSEPROTECT (-2) 54 | 55 | 56 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 57 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nupvals); 58 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nupvals); 59 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 60 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 61 | LUAI_FUNC void luaF_newtbcupval (lua_State *L, StkId level); 62 | LUAI_FUNC int luaF_close (lua_State *L, StkId level, int status); 63 | LUAI_FUNC void luaF_unlinkupval (UpVal *uv); 64 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 65 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 66 | int pc); 67 | 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoRender/NuoRenderPipelinePass.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoRenderPipelinePass.h 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 3/30/21. 6 | // Copyright © 2021 Dong Feng. All rights reserved. 7 | // 8 | 9 | 10 | #ifndef __NUO_RENDER_PIPELINE_PASS_H__ 11 | #define __NUO_RENDER_PIPELINE_PASS_H__ 12 | 13 | 14 | 15 | #include "NuoRenderPass.h" 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | class NuoTextureMesh; 23 | typedef std::shared_ptr PNuoTextureMesh; 24 | 25 | class NuoTexture; 26 | typedef std::shared_ptr PNuoTexture; 27 | 28 | class NuoResource; 29 | typedef std::shared_ptr PNuoResource; 30 | 31 | 32 | /** 33 | * a render pass takes the result from its immediate previous 34 | * pass, draw it on the background, and leave its subclass draw method to 35 | * add additional objects 36 | * 37 | * also, it can take the source as an texture of a pixel format and draw it 38 | * to the target of another format, in that way serving as pixel format convertor. 39 | * 40 | * in the conversion-only case, or in a 2D only case, the sampleCount could be 41 | * set to 1 to turning off the MSAA 42 | */ 43 | 44 | class NuoRenderPipelinePass : public NuoRenderPass 45 | { 46 | 47 | PNuoTextureMesh _textureMesh; 48 | 49 | 50 | public: 51 | 52 | NuoRenderPipelinePass(const PNuoCommandBuffer& commandBuffer, 53 | unsigned int frameCount, 54 | std::vector& intermediate, 55 | DXGI_FORMAT format); 56 | 57 | void SetSourceTextrue(const PNuoTexture& texture); 58 | 59 | /** 60 | * draw calls that target to the *_renderTarget* 61 | */ 62 | virtual void DrawWithCommandBuffer(const PNuoCommandBuffer& commandBuffer) override; 63 | 64 | virtual bool IsPipelinePass() const override; 65 | 66 | protected: 67 | 68 | void Init(const PNuoCommandBuffer& commandBuffer, unsigned int sampleCount); 69 | 70 | }; 71 | 72 | typedef std::shared_ptr PNuoRenderPipelinePass; 73 | 74 | 75 | #endif // !__NUO_RENDER_PIPELINE_PASS_H__ 76 | -------------------------------------------------------------------------------- /lua/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast_int((pc) - (p)->code) - 1) 15 | 16 | 17 | /* Active Lua function (given call info) */ 18 | #define ci_func(ci) (clLvalue(s2v((ci)->func))) 19 | 20 | 21 | #define resethookcount(L) (L->hookcount = L->basehookcount) 22 | 23 | /* 24 | ** mark for entries in 'lineinfo' array that has absolute information in 25 | ** 'abslineinfo' array 26 | */ 27 | #define ABSLINEINFO (-0x80) 28 | 29 | LUAI_FUNC int luaG_getfuncline (const Proto *f, int pc); 30 | LUAI_FUNC const char *luaG_findlocal (lua_State *L, CallInfo *ci, int n, 31 | StkId *pos); 32 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 33 | const char *opname); 34 | LUAI_FUNC l_noret luaG_forerror (lua_State *L, const TValue *o, 35 | const char *what); 36 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 37 | const TValue *p2); 38 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 39 | const TValue *p2, 40 | const char *msg); 41 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 42 | const TValue *p2); 43 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 44 | const TValue *p2); 45 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 46 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 47 | TString *src, int line); 48 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 49 | LUAI_FUNC int luaG_traceexec (lua_State *L, const Instruction *pc); 50 | 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/Renderer/NotationLight.h: -------------------------------------------------------------------------------- 1 | // 2 | // NotationLight.h 3 | // ModelViewer 4 | // 5 | // Created by middleware on 11/13/16. 6 | // Ported: 9/23/21 7 | // Copyright © 2021 Dong Feng. All rights reserved. 8 | // 9 | 10 | 11 | #include "NuoUI/NuoRect.h" 12 | #include "NuoMeshes/NuoMeshBounds.h" 13 | #include "NuoShadowMap/NuoLightSource.h" 14 | #include "NuoMeshes/NuoMesh.h" 15 | 16 | #include 17 | #include 18 | 19 | 20 | class NuoCommandQueue; 21 | typedef std::shared_ptr PNuoCommandQueue; 22 | 23 | class NuoCommandBuffer; 24 | typedef std::shared_ptr PNuoCommandBuffer; 25 | 26 | class NuoCommandEncoder; 27 | typedef std::shared_ptr PNuoCommandEncoder; 28 | 29 | class NotationLightMesh; 30 | typedef std::shared_ptr PNotationLightMesh; 31 | 32 | class NuoResource; 33 | typedef std::shared_ptr PNuoResource; 34 | 35 | 36 | class NotationLight 37 | { 38 | PNuoCommandQueue _commandQueue; 39 | 40 | NuoLightSource _lightSourceDesc; 41 | PNotationLightMesh _lightVector; 42 | 43 | bool _selected; 44 | 45 | public: 46 | 47 | NotationLight(const PNuoCommandBuffer& commandBuffer, 48 | unsigned int frameCount, 49 | std::vector& intermediate, 50 | DXGI_FORMAT format, bool bold); 51 | 52 | NuoPoint HeadPointProjectedWithView(const NuoMatrixFloat44& view); 53 | 54 | void DrawWithRenderPass(const PNuoCommandEncoder& renderPass, 55 | NuoMesh::CommonFunc func); 56 | 57 | void UpdateLightTransform(const NuoMatrixFloat44& delta); 58 | 59 | void SetSelected(bool selected, 60 | const PNuoCommandBuffer& commandBuffer, 61 | std::vector& intermediate); 62 | 63 | void SetSelected(bool selected); 64 | 65 | NuoMeshBounds Bounds(); 66 | 67 | private: 68 | 69 | void UpdatePrivateUniform(const PNuoCommandBuffer& commandBuffer, 70 | std::vector& intermediate); 71 | 72 | void UpdateUniformsForView(const PNuoCommandEncoder& renderPass); 73 | 74 | }; 75 | 76 | 77 | typedef std::shared_ptr PNotationLight; 78 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoVertexBuffer.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoVertexBuffer.h" 4 | 5 | #include "NuoCommandBuffer.h" 6 | #include "NuoCommandQueue.h" 7 | 8 | 9 | NuoVertexBuffer::NuoVertexBuffer(const PNuoCommandBuffer& commandBuffer, 10 | std::vector& intermediatePool, 11 | void* data, size_t size, size_t stride, 12 | uint32_t* indicies, size_t indiciesCount) 13 | { 14 | PNuoDevice device = commandBuffer->CommandQueue()->Device(); 15 | 16 | auto intermediate = device->CreateBuffer(data, size); 17 | _buffer = device->CreatePrivateBuffer(size); 18 | intermediatePool.push_back(intermediate); 19 | commandBuffer->CopyResource(intermediate, _buffer); 20 | 21 | const size_t indiciesBufferSize = indiciesCount * sizeof(uint32_t); 22 | intermediate = device->CreateBuffer(indicies, indiciesBufferSize); 23 | _indicies = device->CreatePrivateBuffer(indiciesBufferSize); 24 | intermediatePool.push_back(intermediate); 25 | commandBuffer->CopyResource(intermediate, _indicies); 26 | 27 | UpdateView(stride); 28 | } 29 | 30 | 31 | NuoVertexBuffer::NuoVertexBuffer(const PNuoResource& buffer, size_t stride) 32 | : _buffer(buffer) 33 | { 34 | UpdateView(stride); 35 | } 36 | 37 | 38 | void NuoVertexBuffer::UpdateView(size_t stride) 39 | { 40 | _vertexBufferView.BufferLocation = _buffer->DxResource()->GetGPUVirtualAddress(); 41 | _vertexBufferView.SizeInBytes = _buffer->Size(); 42 | _vertexBufferView.StrideInBytes = (UINT)stride; 43 | 44 | _indiciesBufferView.BufferLocation = _indicies->DxResource()->GetGPUVirtualAddress(); 45 | _indiciesBufferView.Format = DXGI_FORMAT_R32_UINT; 46 | _indiciesBufferView.SizeInBytes = _indicies->Size(); 47 | } 48 | 49 | 50 | D3D12_VERTEX_BUFFER_VIEW* NuoVertexBuffer::View() 51 | { 52 | return &_vertexBufferView; 53 | } 54 | 55 | 56 | D3D12_INDEX_BUFFER_VIEW* NuoVertexBuffer::IndiciesView() 57 | { 58 | return &_indiciesBufferView; 59 | } 60 | 61 | 62 | unsigned int NuoVertexBuffer::Count() const 63 | { 64 | return _vertexBufferView.SizeInBytes / _vertexBufferView.StrideInBytes; 65 | } 66 | 67 | 68 | unsigned int NuoVertexBuffer::IndiciesCount() const 69 | { 70 | return _indiciesBufferView.SizeInBytes / sizeof(UINT32); 71 | } 72 | 73 | 74 | -------------------------------------------------------------------------------- /lua/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gval(n) (&(n)->i_val) 15 | #define gnext(n) ((n)->u.next) 16 | 17 | 18 | /* 19 | ** Clear all bits of fast-access metamethods, which means that the table 20 | ** may have any of these metamethods. (First access that fails after the 21 | ** clearing will set the bit again.) 22 | */ 23 | #define invalidateTMcache(t) ((t)->flags &= ~maskflags) 24 | 25 | 26 | /* true when 't' is using 'dummynode' as its hash part */ 27 | #define isdummy(t) ((t)->lastfree == NULL) 28 | 29 | 30 | /* allocated size for hash nodes */ 31 | #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) 32 | 33 | 34 | /* returns the Node, given the value of a table entry */ 35 | #define nodefromval(v) cast(Node *, (v)) 36 | 37 | 38 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 39 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 40 | TValue *value); 41 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 42 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 43 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 44 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 45 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 46 | LUAI_FUNC Table *luaH_new (lua_State *L); 47 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 48 | unsigned int nhsize); 49 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 50 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 51 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 52 | LUAI_FUNC lua_Unsigned luaH_getn (Table *t); 53 | LUAI_FUNC unsigned int luaH_realasize (const Table *t); 54 | 55 | 56 | #if defined(LUA_DEBUG) 57 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 58 | LUAI_FUNC int luaH_isdummy (const Table *t); 59 | #endif 60 | 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoSignature.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | #include "NuoDevice.h" 14 | #include "NuoShader.h" 15 | 16 | 17 | 18 | 19 | class NuoRootSignature 20 | { 21 | D3D12_ROOT_SIGNATURE_DESC1 _dxDesc; 22 | std::vector _parameters; 23 | std::vector _samplers; 24 | 25 | // store the ranges of all descriptor tables 26 | // 27 | // indices in this map might not be continous (so a map, instead of a vector, is used), because 28 | // the descriptor tables might coexist with other root-level parameters in arbitrary layout 29 | // 30 | std::map> _descriptorTableRanges; 31 | 32 | Microsoft::WRL::ComPtr _signature; 33 | D3D12_VERSIONED_ROOT_SIGNATURE_DESC _desc; 34 | 35 | PNuoDevice _device; 36 | 37 | public: 38 | 39 | NuoRootSignature(const PNuoDevice& device, 40 | D3D12_ROOT_SIGNATURE_FLAGS flags); 41 | 42 | void AddConstant(size_t size, unsigned int shaderRegister, unsigned int space, D3D12_SHADER_VISIBILITY visibility); 43 | void AddRootConstantBuffer(unsigned int shaderRegister, unsigned int space, D3D12_SHADER_VISIBILITY visibility); 44 | void AddRootResource(unsigned int shaderRegister, unsigned int space, D3D12_SHADER_VISIBILITY visibility); 45 | void AddSampler(unsigned int shaderRegister, unsigned int space, D3D12_SHADER_VISIBILITY visibility); 46 | 47 | int AddDescriptorTable(unsigned int rangeNum, D3D12_SHADER_VISIBILITY visibility); 48 | 49 | void AddTexturesToDescriptorTable(unsigned int tableIndex, unsigned int rangeIndex, unsigned int num, 50 | unsigned int shaderRegister, unsigned int space); 51 | 52 | ID3D12RootSignature* DxSignature(); 53 | 54 | private: 55 | 56 | void UpdateDesc(); 57 | void AddConstantView(unsigned int shaderRegister, unsigned int space, 58 | D3D12_SHADER_VISIBILITY visibility, D3D12_ROOT_PARAMETER_TYPE type); 59 | 60 | }; 61 | 62 | 63 | typedef std::shared_ptr PNuoRootSignature; 64 | typedef std::weak_ptr WPNuoRootSignature; 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /lua/src/ljumptab.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ljumptab.h $ 3 | ** Jump Table for the Lua interpreter 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #undef vmdispatch 9 | #undef vmcase 10 | #undef vmbreak 11 | 12 | #define vmdispatch(x) goto *disptab[x]; 13 | 14 | #define vmcase(l) L_##l: 15 | 16 | #define vmbreak vmfetch(); vmdispatch(GET_OPCODE(i)); 17 | 18 | 19 | static const void *const disptab[NUM_OPCODES] = { 20 | 21 | #if 0 22 | ** you can update the following list with this command: 23 | ** 24 | ** sed -n '/^OP_/\!d; s/OP_/\&\&L_OP_/ ; s/,.*/,/ ; s/\/.*// ; p' lopcodes.h 25 | ** 26 | #endif 27 | 28 | &&L_OP_MOVE, 29 | &&L_OP_LOADI, 30 | &&L_OP_LOADF, 31 | &&L_OP_LOADK, 32 | &&L_OP_LOADKX, 33 | &&L_OP_LOADFALSE, 34 | &&L_OP_LFALSESKIP, 35 | &&L_OP_LOADTRUE, 36 | &&L_OP_LOADNIL, 37 | &&L_OP_GETUPVAL, 38 | &&L_OP_SETUPVAL, 39 | &&L_OP_GETTABUP, 40 | &&L_OP_GETTABLE, 41 | &&L_OP_GETI, 42 | &&L_OP_GETFIELD, 43 | &&L_OP_SETTABUP, 44 | &&L_OP_SETTABLE, 45 | &&L_OP_SETI, 46 | &&L_OP_SETFIELD, 47 | &&L_OP_NEWTABLE, 48 | &&L_OP_SELF, 49 | &&L_OP_ADDI, 50 | &&L_OP_ADDK, 51 | &&L_OP_SUBK, 52 | &&L_OP_MULK, 53 | &&L_OP_MODK, 54 | &&L_OP_POWK, 55 | &&L_OP_DIVK, 56 | &&L_OP_IDIVK, 57 | &&L_OP_BANDK, 58 | &&L_OP_BORK, 59 | &&L_OP_BXORK, 60 | &&L_OP_SHRI, 61 | &&L_OP_SHLI, 62 | &&L_OP_ADD, 63 | &&L_OP_SUB, 64 | &&L_OP_MUL, 65 | &&L_OP_MOD, 66 | &&L_OP_POW, 67 | &&L_OP_DIV, 68 | &&L_OP_IDIV, 69 | &&L_OP_BAND, 70 | &&L_OP_BOR, 71 | &&L_OP_BXOR, 72 | &&L_OP_SHL, 73 | &&L_OP_SHR, 74 | &&L_OP_MMBIN, 75 | &&L_OP_MMBINI, 76 | &&L_OP_MMBINK, 77 | &&L_OP_UNM, 78 | &&L_OP_BNOT, 79 | &&L_OP_NOT, 80 | &&L_OP_LEN, 81 | &&L_OP_CONCAT, 82 | &&L_OP_CLOSE, 83 | &&L_OP_TBC, 84 | &&L_OP_JMP, 85 | &&L_OP_EQ, 86 | &&L_OP_LT, 87 | &&L_OP_LE, 88 | &&L_OP_EQK, 89 | &&L_OP_EQI, 90 | &&L_OP_LTI, 91 | &&L_OP_LEI, 92 | &&L_OP_GTI, 93 | &&L_OP_GEI, 94 | &&L_OP_TEST, 95 | &&L_OP_TESTSET, 96 | &&L_OP_CALL, 97 | &&L_OP_TAILCALL, 98 | &&L_OP_RETURN, 99 | &&L_OP_RETURN0, 100 | &&L_OP_RETURN1, 101 | &&L_OP_FORLOOP, 102 | &&L_OP_FORPREP, 103 | &&L_OP_TFORPREP, 104 | &&L_OP_TFORCALL, 105 | &&L_OP_TFORLOOP, 106 | &&L_OP_SETLIST, 107 | &&L_OP_CLOSURE, 108 | &&L_OP_VARARG, 109 | &&L_OP_VARARGPREP, 110 | &&L_OP_EXTRAARG 111 | 112 | }; 113 | -------------------------------------------------------------------------------- /lua/Lua/Lua.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30517.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LuaLib", "LuaLib\LuaLib.vcxproj", "{5BCC2242-37C1-4693-BB93-6137E698966D}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LuaCmd", "LuaCmd\LuaCmd.vcxproj", "{730C4FE7-D79A-49BC-8DDE-A6354726BB93}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Debug|x64.ActiveCfg = Debug|x64 19 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Debug|x64.Build.0 = Debug|x64 20 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Debug|x86.ActiveCfg = Debug|Win32 21 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Debug|x86.Build.0 = Debug|Win32 22 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Release|x64.ActiveCfg = Release|x64 23 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Release|x64.Build.0 = Release|x64 24 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Release|x86.ActiveCfg = Release|Win32 25 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Release|x86.Build.0 = Release|Win32 26 | {730C4FE7-D79A-49BC-8DDE-A6354726BB93}.Debug|x64.ActiveCfg = Debug|x64 27 | {730C4FE7-D79A-49BC-8DDE-A6354726BB93}.Debug|x64.Build.0 = Debug|x64 28 | {730C4FE7-D79A-49BC-8DDE-A6354726BB93}.Debug|x86.ActiveCfg = Debug|Win32 29 | {730C4FE7-D79A-49BC-8DDE-A6354726BB93}.Debug|x86.Build.0 = Debug|Win32 30 | {730C4FE7-D79A-49BC-8DDE-A6354726BB93}.Release|x64.ActiveCfg = Release|x64 31 | {730C4FE7-D79A-49BC-8DDE-A6354726BB93}.Release|x64.Build.0 = Release|x64 32 | {730C4FE7-D79A-49BC-8DDE-A6354726BB93}.Release|x86.ActiveCfg = Release|Win32 33 | {730C4FE7-D79A-49BC-8DDE-A6354726BB93}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {DD2C2A30-1AF1-46AB-8BF7-F2C32D52FB94} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoModelLoader/NuoModelLoaderGPU.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoModelLoaderGPU.m 3 | // ModelViewer 4 | // 5 | // Created by middleware on 11/29/20. 6 | // Copyright © 2020 middleware. All rights reserved. 7 | // 8 | 9 | #include "NuoModelLoaderGPU.h" 10 | 11 | 12 | #include "NuoMeshes/NuoMeshCompound.h" 13 | #include "NuoMeshes/NuoMeshBounds.h" 14 | 15 | 16 | 17 | NuoModelLoaderGPU::NuoModelLoaderGPU(const PNuoModelLoader& loader, DXGI_FORMAT format) 18 | : _loader(loader), _format(format) 19 | { 20 | } 21 | 22 | 23 | 24 | NuoModelLoaderGPU::~NuoModelLoaderGPU() 25 | { 26 | } 27 | 28 | 29 | 30 | PNuoMeshCompound NuoModelLoaderGPU::CreateMesh(const NuoMeshOptions& loadOption, 31 | const PNuoCommandQueue& commandQueue, 32 | NuoModelLoaderProgress progress) 33 | { 34 | std::vector intermediate; 35 | PNuoCommandBuffer commandBuffer = commandQueue->CreateCommandBuffer(); 36 | 37 | const float loadingPortionModelBuffer = loadOption._textured ? 0.70f : 0.85f; 38 | const float loadingPortionModelGPU = (1 - loadingPortionModelBuffer); 39 | 40 | auto progressFunc = [loadingPortionModelBuffer, progress](float progressValue) 41 | { 42 | progress(loadingPortionModelBuffer * progressValue); 43 | }; 44 | 45 | std::vector models = _loader->CreateMeshWithOptions(loadOption, 46 | progressFunc); 47 | 48 | std::vector result; 49 | size_t index = 0; 50 | for (auto& model : models) 51 | { 52 | PNuoMesh mesh = ::CreateMesh(loadOption, commandBuffer, model, _format, intermediate); 53 | 54 | NuoMeshBounds bounds; 55 | bounds.boundingBox = model->GetBoundingBox(); 56 | 57 | mesh->SetBoundsLocal(bounds); 58 | result.push_back(mesh); 59 | 60 | if (progress) 61 | progress(++index / (float)models.size() * loadingPortionModelGPU + loadingPortionModelBuffer); 62 | } 63 | 64 | commandBuffer->Commit(); 65 | commandBuffer->WaitUntilComplete(intermediate); 66 | 67 | PNuoMeshCompound resultObj = std::make_shared(result); 68 | 69 | return resultObj; 70 | } 71 | 72 | 73 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30517.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NuoModelViewer", "NuoModelViewer\NuoModelViewer.vcxproj", "{039D35D1-3468-4AAD-8CCB-85DFAA53AA8F}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LuaLib", "..\lua\Lua\LuaLib\LuaLib.vcxproj", "{5BCC2242-37C1-4693-BB93-6137E698966D}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {039D35D1-3468-4AAD-8CCB-85DFAA53AA8F}.Debug|x64.ActiveCfg = Debug|x64 19 | {039D35D1-3468-4AAD-8CCB-85DFAA53AA8F}.Debug|x64.Build.0 = Debug|x64 20 | {039D35D1-3468-4AAD-8CCB-85DFAA53AA8F}.Debug|x86.ActiveCfg = Debug|Win32 21 | {039D35D1-3468-4AAD-8CCB-85DFAA53AA8F}.Debug|x86.Build.0 = Debug|Win32 22 | {039D35D1-3468-4AAD-8CCB-85DFAA53AA8F}.Release|x64.ActiveCfg = Release|x64 23 | {039D35D1-3468-4AAD-8CCB-85DFAA53AA8F}.Release|x64.Build.0 = Release|x64 24 | {039D35D1-3468-4AAD-8CCB-85DFAA53AA8F}.Release|x86.ActiveCfg = Release|Win32 25 | {039D35D1-3468-4AAD-8CCB-85DFAA53AA8F}.Release|x86.Build.0 = Release|Win32 26 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Debug|x64.ActiveCfg = Debug|x64 27 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Debug|x64.Build.0 = Debug|x64 28 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Debug|x86.ActiveCfg = Debug|Win32 29 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Debug|x86.Build.0 = Debug|Win32 30 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Release|x64.ActiveCfg = Release|x64 31 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Release|x64.Build.0 = Release|x64 32 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Release|x86.ActiveCfg = Release|Win32 33 | {5BCC2242-37C1-4693-BB93-6137E698966D}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {5F4DD5D1-DC31-4C20-B604-0DBCAB54B70A} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoMeshes/NuoMeshMaterialed.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoMeshMaterialed.h" 4 | 5 | 6 | NuoMeshMaterialed::NuoMeshMaterialed() 7 | : _hasTransparency(false), 8 | _physicallyReflection(false) 9 | { 10 | } 11 | 12 | 13 | NuoMeshMaterialed::~NuoMeshMaterialed() 14 | { 15 | } 16 | 17 | 18 | void NuoMeshMaterialed::Init(const PNuoCommandBuffer& commandBuffer, 19 | unsigned int frameCount, 20 | std::vector& intermediate, 21 | const PNuoModelMaterialed& model, 22 | DXGI_FORMAT format) 23 | { 24 | _format = format; 25 | 26 | NuoMeshBase::Init(commandBuffer, frameCount, intermediate, 27 | (NuoMaterialedBasicItem*)model->Ptr(), 28 | model->GetVerticesNumber(), 29 | model->IndicesPtr(), 30 | model->IndicesCount()); 31 | } 32 | 33 | 34 | 35 | bool NuoMeshMaterialed::HasTransparency() const 36 | { 37 | return _hasTransparency; 38 | } 39 | 40 | 41 | void NuoMeshMaterialed::SetTransparency(bool transparency) 42 | { 43 | _hasTransparency = transparency; 44 | } 45 | 46 | 47 | void NuoMeshMaterialed::SetPhysicallyReflection(bool reflection) 48 | { 49 | _physicallyReflection = reflection; 50 | } 51 | 52 | 53 | void NuoMeshMaterialed::MakePipelineState(const PNuoCommandBuffer& commandBuffer) 54 | { 55 | _pipelineState = NuoMesh::MakePipelineState(commandBuffer, "NuoMeshMaterialedVertex", "NuoMeshMaterialedPixel"); 56 | } 57 | 58 | 59 | std::vector NuoMeshMaterialed::InputDesc() 60 | { 61 | std::vector inputElementDescs = 62 | { 63 | { "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, 64 | { "NORMAL", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 16, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, 65 | { "DIFFUSE", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 32, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, 66 | { "AMBIENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 44, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, 67 | { "SPECULAR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 56, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, 68 | { "SHINESS_DISOLVE_ILLUM", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 68, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }, 69 | }; 70 | 71 | return inputElementDescs; 72 | } 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/ModelView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NuoDirect/NuoDirectView.h" 4 | #include "NuoModelLoader/NuoModelLoader.h" 5 | 6 | #include "UserInterface/ModelOptionUpdate.h" 7 | 8 | #include 9 | #include 10 | 11 | 12 | class ModelView; 13 | typedef std::shared_ptr PModelView; 14 | 15 | class ModelState; 16 | typedef std::shared_ptr PModelState; 17 | 18 | class NuoTextureMesh; 19 | typedef std::shared_ptr PNuoTextureMesh; 20 | 21 | class NuoMesh; 22 | class NuoMeshSceneRoot; 23 | typedef std::shared_ptr PNuoMesh; 24 | typedef std::shared_ptr PNuoMeshSceneRoot; 25 | 26 | 27 | 28 | class ModelRenderer; 29 | typedef std::shared_ptr PModelRenderer; 30 | 31 | class NotationRenderer; 32 | typedef std::shared_ptr PNotationRenderer; 33 | 34 | 35 | class ModelOperationPanel; 36 | typedef std::weak_ptr WPModelOperationPanel; 37 | typedef std::shared_ptr PModelOperationPanel; 38 | 39 | 40 | class ModelView : public NuoDirectView, public ModelOptionUpdate 41 | { 42 | PNuoTimer _refreshTimer; 43 | 44 | bool _init; 45 | 46 | bool _trackingLighting; 47 | 48 | // renderers 49 | // 50 | 51 | PModelRenderer _modelRenderer; 52 | PNotationRenderer _notationRenderer; 53 | 54 | WPModelOperationPanel _modelPanel; 55 | 56 | public: 57 | 58 | ModelView(const PNuoDevice& device, const PNuoWindow& parent); 59 | 60 | PModelState State(); 61 | 62 | void Init(); 63 | void SetModelPanel(const PModelOperationPanel& panel); 64 | void SetupPipelineSettings(); 65 | 66 | void OpenFile(const std::string& path, NuoTaskProgress progress); 67 | void LoadMesh(const std::string& path, NuoTaskProgress progress); 68 | 69 | virtual void Render(const PNuoCommandBuffer& commandBuffer) override; 70 | virtual void OnSize(unsigned int x, unsigned int y) override; 71 | 72 | virtual void OnMouseDown(short x, short y) override; 73 | virtual void OnMouseDrag(short x, short y, short deltaX, short deltaY, const NuoMouseModifer& modifier) override; 74 | virtual void OnMouseUp(short x, short y) override; 75 | virtual bool OnScrollWheel(short keyState, short delta) override; 76 | 77 | 78 | // Interface ModelOptionUpdate 79 | 80 | virtual void ModelOptionUpdated() override; 81 | 82 | }; 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoModelLoader/NuoMaterial.h: -------------------------------------------------------------------------------- 1 | // 2 | // NuoMaterial.hpp 3 | // ModelViewer 4 | // 5 | // Created by middleware on 8/28/16. 6 | // Copyright © 2016 middleware. All rights reserved. 7 | // 8 | 9 | #ifndef NuoMaterial_hpp 10 | #define NuoMaterial_hpp 11 | 12 | #include 13 | #include "tiny_obj_loader.h" 14 | 15 | 16 | class NuoMaterial 17 | { 18 | public: 19 | int id; 20 | 21 | float ambient[3]; 22 | float diffuse[3]; 23 | float specular[3]; 24 | float transmittance[3]; 25 | float emission[3]; 26 | float shininess; 27 | float ior; // index of refraction 28 | float dissolve; // 1 == opaque; 0 == fully transparent 29 | // illumination model (see http://www.fileformat.info/format/material/) 30 | int illum; 31 | 32 | std::string ambient_texname; // map_Ka 33 | std::string diffuse_texname; // map_Kd 34 | std::string specular_texname; // map_Ks 35 | std::string specular_highlight_texname; // map_Ns 36 | std::string bump_texname; // map_bump, bump 37 | std::string displacement_texname; // disp 38 | std::string alpha_texname; // map_d 39 | 40 | // PBR extension 41 | // http://exocortex.com/blog/extending_wavefront_mtl_to_support_pbr 42 | float roughness; // [0, 1] default 0 43 | float metallic; // [0, 1] default 0 44 | float sheen; // [0, 1] default 0 45 | float clearcoat_thickness; // [0, 1] default 0 46 | float clearcoat_roughness; // [0, 1] default 0 47 | float anisotropy; // aniso. [0, 1] default 0 48 | float anisotropy_rotation; // anisor. [0, 1] default 0 49 | std::string roughness_texname; // map_Pr 50 | std::string metallic_texname; // map_Pm 51 | std::string sheen_texname; // map_Ps 52 | std::string emissive_texname; // map_Ke 53 | std::string normal_texname; // norm. For normal mapping. 54 | 55 | public: 56 | NuoMaterial(); 57 | NuoMaterial(const tinyobj::material_t& material, bool unique); 58 | 59 | bool operator < (const NuoMaterial& other) const; 60 | 61 | bool HasTextureDiffuse() const; 62 | bool HasTextureOpacity() const; 63 | bool HasTextureBump() const; 64 | }; 65 | 66 | 67 | 68 | #endif /* NuoMaterial_hpp */ 69 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoDevice.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "NuoUtilites/NuoMathVector.h" 12 | #include "NuoDirect/NuoDescriptorHeap.h" 13 | #include "NuoDirect/NuoFenceSwapChain.h" 14 | 15 | 16 | class NuoDevice; 17 | typedef std::shared_ptr PNuoDevice; 18 | typedef std::weak_ptr WPNuoDevice; 19 | 20 | class NuoResource; 21 | typedef std::shared_ptr PNuoResource; 22 | 23 | class NuoTexture; 24 | typedef std::shared_ptr PNuoTexture; 25 | 26 | 27 | class NuoDevice : public std::enable_shared_from_this 28 | { 29 | 30 | Microsoft::WRL::ComPtr _dxDevice; 31 | Microsoft::WRL::ComPtr _dxFactor; 32 | DXGI_ADAPTER_DESC1 _dxDesc; 33 | 34 | static std::set _devices; 35 | 36 | public: 37 | 38 | static std::set Devices(); 39 | 40 | void EnableDebugInfoQueue(); 41 | 42 | std::string Name() const; 43 | bool SupportRayTracing(); 44 | 45 | unsigned int RenderTargetDescriptorHandleIncrementSize() const; 46 | PNuoDescriptorHeap CreateRenderTargetHeap(unsigned int frameCount); 47 | 48 | unsigned int ShaderResourceDescriptorHandleIncrementSize() const; 49 | PNuoDescriptorHeap CreateShaderDescriptorHeap(unsigned int frameCount); 50 | 51 | PNuoDescriptorHeap CreateDepthStencilHeap(); 52 | 53 | PNuoFenceSwapChain CreateFenceSwapChain(unsigned int frameCount); 54 | PNuoResource CreateBuffer(void* data, size_t size); 55 | PNuoResource CreatePrivateBuffer(size_t size); 56 | PNuoResource CreateUploadBuffer(size_t size); 57 | PNuoResource CreateDepthStencil(size_t width, size_t height, unsigned int sampleCount); 58 | 59 | PNuoTexture CreateTexture(DXGI_FORMAT format, unsigned int width, unsigned int height, 60 | unsigned int sampleCount, const NuoVectorFloat4& clearColor); 61 | 62 | ID3D12Device* DxDevice() const; 63 | IDXGIFactory6* DxFactory() const; 64 | 65 | private: 66 | 67 | PNuoResource CreateBufferInternal(void* data, 68 | size_t width, size_t height, 69 | D3D12_RESOURCE_DIMENSION dimension, 70 | DXGI_FORMAT format, 71 | unsigned int sampleCount, 72 | D3D12_TEXTURE_LAYOUT layout, 73 | D3D12_RESOURCE_STATES state, 74 | D3D12_RESOURCE_FLAGS flags); 75 | 76 | }; 77 | 78 | 79 | -------------------------------------------------------------------------------- /NuoWindow/NuoWindow/IconWindow.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "IconWindow.h" 3 | #include 4 | 5 | #include "NuoOpenFileDialog.h" 6 | #include "NuoImage.h" 7 | 8 | #include "resource.h" 9 | 10 | 11 | IconWindow::IconWindow(const PNuoWindow& appWindow) 12 | : NuoWindow("Icon Tools"), 13 | _appWindow(appWindow) 14 | { 15 | } 16 | 17 | 18 | void IconWindow::Init() 19 | { 20 | NuoRect rect(0, 0, 120, 24); 21 | NuoInset buttonInset(20, 20, 20, 20); 22 | 23 | _loadButton = std::make_shared(shared_from_this(), "Load Image ..."); 24 | _loadButton->Init(IDB_LOADICON); 25 | _loadButton->SetAutoPosition(kNuoControl_RT); 26 | _loadButton->SetMargin(buttonInset); 27 | _loadButton->SetPosition(rect, false); 28 | 29 | _loadButton->SetOnCommand([this](int) 30 | { 31 | NuoFileDialog dlg; 32 | dlg.Open(this->shared_from_this()); 33 | 34 | std::string path = dlg.FilePath(); 35 | 36 | PNuoImage image = std::make_shared(); 37 | image->Load(path, this->DPI() * 20); 38 | 39 | this->_iconLabel->SetImage(image); 40 | }); 41 | 42 | rect.SetY(rect.H() + 20 + 8); 43 | _saveButton = std::make_shared(shared_from_this(), "Save Icon ..."); 44 | _saveButton->Init(IDB_SAVEICON); 45 | _saveButton->SetAutoPosition(kNuoControl_R); 46 | _saveButton->SetMargin(buttonInset); 47 | _saveButton->SetPosition(rect, false); 48 | 49 | _saveButton->SetOnCommand([this](int) 50 | { 51 | NuoFileDialog dlg; 52 | dlg.Save(this->shared_from_this()); 53 | 54 | std::string path = dlg.FilePath(); 55 | 56 | PNuoImage image = this->_iconLabel->Image(); 57 | PNuoIcon icon = image->Icon(); 58 | icon->Save(path); 59 | }); 60 | 61 | auto font = std::make_shared(16, "MS Shell Dlg"); 62 | font->SetItalic(false); 63 | font->SetLight(true); 64 | font->CreateFont(DPI()); 65 | _loadButton->SetFont(font); 66 | _saveButton->SetFont(font); 67 | 68 | NuoInset labelInset(30, 20, 35, 165); 69 | _iconLabel = std::make_shared(shared_from_this()); 70 | _iconLabel->Init(true); 71 | _iconLabel->SetAutoPosition(kNuoControl_Stretch_ALL); 72 | _iconLabel->SetMargin(labelInset); 73 | } 74 | 75 | 76 | NuoRect IconWindow::PreferredRect() const 77 | { 78 | PNuoWindow appWindow = _appWindow.lock(); 79 | NuoRect appRect = appWindow->PositionDevice(); 80 | 81 | float scale = DPI(); 82 | NuoRect result(0, 0, 400 * scale, 300 * scale); 83 | result.SetX(appRect.X() + 30 * scale); 84 | result.SetY(appRect.Y() + 30 * scale); 85 | 86 | return result; 87 | } 88 | 89 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoDirectView.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "NuoView.h" 12 | 13 | #include "NuoDirect/NuoDevice.h" 14 | #include "NuoDirect/NuoCommandQueue.h" 15 | #include "NuoDirect/NuoCommandBuffer.h" 16 | #include "NuoDirect/NuoResource.h" 17 | #include "NuoDirect/NuoRenderTarget.h" 18 | 19 | 20 | 21 | class NuoDirectView; 22 | typedef std::shared_ptr PNuoDirectView; 23 | typedef std::weak_ptr WPNuoDirectView; 24 | 25 | 26 | class NuoSwapChain; 27 | typedef std::shared_ptr PNuoSwapChain; 28 | 29 | class NuoRenderPipeline; 30 | typedef std::shared_ptr PNuoRenderPipeline; 31 | 32 | class NuoRenderPass; 33 | typedef std::shared_ptr PNuoRenderPass; 34 | 35 | 36 | class NuoDirectView : public NuoView 37 | { 38 | 39 | PNuoSwapChain _swapChain; 40 | PNuoCommandQueue _commandQueue; 41 | 42 | unsigned int _sampleCount; 43 | 44 | PNuoRenderPipeline _renderPipeline; 45 | 46 | public: 47 | 48 | NuoDirectView(const PNuoDevice& device, const PNuoWindow& parent); 49 | 50 | PNuoCommandQueue CommandQueue() const; 51 | 52 | void CreateSwapChain(unsigned int frameCount, 53 | unsigned int w, unsigned int h); 54 | 55 | /** 56 | * the code used to get the format by query it from a target (usually the 0th target in the 57 | * swap-chain). that method is problematic as it touch the swap-chain resources unncessary. 58 | * when a swap-chain is associated with some resources, it has to be presented and then 59 | * destroy all those resources associated with the previous frame, before some operation 60 | * (noticeably the buffer-resize) could be performed. 61 | */ 62 | DXGI_FORMAT Format(); 63 | 64 | void SetSampleCount(unsigned int sampleCount); 65 | 66 | PNuoRenderTarget RenderTarget(unsigned int inFlight); 67 | PNuoRenderTarget CurrentRenderTarget(); 68 | PNuoCommandBuffer CreateCommandBuffer(bool resetAllocator); 69 | 70 | void Present(); 71 | void PresentWithoutFence(); 72 | void WaitForGPU(); 73 | unsigned int CurrentBackBufferIndex(); 74 | unsigned int BuffersCount(); 75 | 76 | void SetRenderPasses(const std::vector& passes); 77 | void UpdateRenderPassesDrawable(); 78 | 79 | virtual void Render(const PNuoCommandBuffer& commandBuffer); 80 | 81 | virtual void OnPaint() override; 82 | virtual void OnSize(unsigned int x, unsigned int y) override; 83 | virtual void OnDestroy() override; 84 | 85 | }; 86 | 87 | 88 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoRender/NuoRenderPipeline.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoRenderPipeline.cpp 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 5/23/21. 6 | // Copyright © 2021 Dong Feng. All rights reserved. 7 | // 8 | 9 | #include "NuoRenderPipeline.h" 10 | #include "NuoRenderPipelinePass.h" 11 | 12 | #include "NuoDirect/NuoRenderPassTarget.h" 13 | 14 | 15 | 16 | void NuoRenderPipeline::RenderWithCommandBuffer(const PNuoCommandBuffer& commandBuffer) 17 | { 18 | // rendering that do not need the drawable (which is subject to the limit of 19 | // the render surface frame buffers, therefore might cause wait) 20 | // 21 | for (PNuoRenderPass pass : _renderPasses) 22 | { 23 | pass->PredrawWithCommandBuffer(commandBuffer); 24 | } 25 | 26 | // associate the source and destine texture of each step, along the course 27 | // of rendering each step 28 | // 29 | const size_t count = _renderPasses.size(); 30 | for (size_t i = 0; i < count; ++i) 31 | { 32 | const PNuoRenderPass renderStep = _renderPasses[i]; 33 | if (!renderStep->IsPipelinePass()) 34 | continue; 35 | 36 | PNuoRenderPipelinePass renderStepSuccessor; 37 | 38 | if (i < count - 1) 39 | renderStepSuccessor = std::dynamic_pointer_cast(_renderPasses[i + 1]); 40 | 41 | if (renderStepSuccessor) 42 | { 43 | PNuoRenderTarget interResult = renderStep->RenderTarget(); 44 | renderStepSuccessor->SetSourceTextrue(interResult->ResultTexture()); 45 | } 46 | else 47 | { 48 | renderStep->SetTransientRenderTarget(_renderTarget); 49 | } 50 | 51 | renderStep->DrawWithCommandBuffer(commandBuffer); 52 | } 53 | } 54 | 55 | 56 | void NuoRenderPipeline::SetRenderPasses(const std::vector& passes) 57 | { 58 | _renderPasses = passes; 59 | } 60 | 61 | 62 | void NuoRenderPipeline::SetDrawableSize(const NuoSize& size) 63 | { 64 | for (size_t i = 0; i < _renderPasses.size(); ++i) 65 | { 66 | PNuoRenderPass render = _renderPasses[i]; 67 | render->SetDrawableSize(size); 68 | } 69 | } 70 | 71 | 72 | void NuoRenderPipeline::SetRenderTarget(const PNuoRenderTarget renderTarget) 73 | { 74 | _renderTarget = renderTarget; 75 | } 76 | 77 | 78 | 79 | /* 80 | - (void)setSampleCount:(NSUInteger)sampleCount 81 | { 82 | for (size_t i = 0; i < [_renderPasses count]; ++i) 83 | { 84 | NuoRenderPass* render = _renderPasses[i]; 85 | [render setSampleCount:sampleCount]; 86 | } 87 | } 88 | 89 | 90 | 91 | @end 92 | */ 93 | -------------------------------------------------------------------------------- /lua/src/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua. 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | 65 | /* 66 | ** In ASCII, this 'ltolower' is correct for alphabetic characters and 67 | ** for '.'. That is enough for Lua needs. ('check_exp' ensures that 68 | ** the character either is an upper-case letter or is unchanged by 69 | ** the transformation, which holds for lower-case letters and '.'.) 70 | */ 71 | #define ltolower(c) \ 72 | check_exp(('A' <= (c) && (c) <= 'Z') || (c) == ((c) | ('A' ^ 'a')), \ 73 | (c) | ('A' ^ 'a')) 74 | 75 | 76 | /* one entry for each character and for -1 (EOZ) */ 77 | LUAI_DDEC(const lu_byte luai_ctype_[UCHAR_MAX + 2];) 78 | 79 | 80 | #else /* }{ */ 81 | 82 | /* 83 | ** use standard C ctypes 84 | */ 85 | 86 | #include 87 | 88 | 89 | #define lislalpha(c) (isalpha(c) || (c) == '_') 90 | #define lislalnum(c) (isalnum(c) || (c) == '_') 91 | #define lisdigit(c) (isdigit(c)) 92 | #define lisspace(c) (isspace(c)) 93 | #define lisprint(c) (isprint(c)) 94 | #define lisxdigit(c) (isxdigit(c)) 95 | 96 | #define ltolower(c) (tolower(c)) 97 | 98 | #endif /* } */ 99 | 100 | #endif 101 | 102 | -------------------------------------------------------------------------------- /lua/src/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | 20 | #if defined (LUA_UCID) /* accept UniCode IDentifiers? */ 21 | /* consider all non-ascii codepoints to be alphabetic */ 22 | #define NONA 0x01 23 | #else 24 | #define NONA 0x00 /* default */ 25 | #endif 26 | 27 | 28 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 29 | 0x00, /* EOZ */ 30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 31 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 34 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 35 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 36 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 37 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 38 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 39 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 40 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 41 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 42 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 43 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 44 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 45 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 46 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* 8. */ 47 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 48 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* 9. */ 49 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 50 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* a. */ 51 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 52 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* b. */ 53 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 54 | 0x00, 0x00, NONA, NONA, NONA, NONA, NONA, NONA, /* c. */ 55 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 56 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* d. */ 57 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 58 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, /* e. */ 59 | NONA, NONA, NONA, NONA, NONA, NONA, NONA, NONA, 60 | NONA, NONA, NONA, NONA, NONA, 0x00, 0x00, 0x00, /* f. */ 61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 62 | }; 63 | 64 | #endif /* } */ 65 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoRenderTarget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "NuoResource.h" 12 | #include "NuoCommandBuffer.h" 13 | #include "NuoSize.h" 14 | 15 | 16 | 17 | class NuoRenderTarget; 18 | typedef std::shared_ptr PNuoRenderTarget; 19 | typedef std::weak_ptr WPNuoRenderTarget; 20 | 21 | class NuoDevice; 22 | typedef std::shared_ptr PNuoDevice; 23 | 24 | 25 | 26 | class NuoRenderTarget : public std::enable_shared_from_this 27 | { 28 | 29 | protected: 30 | 31 | PNuoDevice _device; 32 | 33 | unsigned int _width; 34 | unsigned int _height; 35 | unsigned int _sampleCount; 36 | 37 | DXGI_FORMAT _format; 38 | bool _manageResource; 39 | bool _depthEnabled; 40 | 41 | PNuoTexture _resource; 42 | PNuoTexture _sampleResource; 43 | PNuoResource _backBuffer; 44 | 45 | D3D12_CPU_DESCRIPTOR_HANDLE _view; 46 | PNuoDescriptorHeap _rtvHeap; 47 | 48 | PNuoResource _depthResource; 49 | D3D12_CPU_DESCRIPTOR_HANDLE _depthView; 50 | PNuoDescriptorHeap _dsvHeap; 51 | 52 | unsigned int _encoderCount; 53 | PNuoCommandEncoder _renderPassEncoder; 54 | 55 | NuoVectorFloat4 _clearColor; 56 | 57 | public: 58 | 59 | NuoRenderTarget(const PNuoDevice& device, DXGI_FORMAT format, 60 | unsigned int sampleCount, bool depthEnabled, bool manageResource); 61 | 62 | virtual void SetClearColor(const NuoVectorFloat4& color); 63 | NuoVectorFloat4 ClearColor() const; 64 | 65 | virtual D3D12_CPU_DESCRIPTOR_HANDLE* View(); 66 | D3D12_CPU_DESCRIPTOR_HANDLE DepthView(); 67 | 68 | D3D12_GPU_VIRTUAL_ADDRESS TargetGPUAddress(); 69 | PNuoResource RenderBuffer() const; 70 | 71 | virtual PNuoTexture ResultTexture() const; 72 | virtual PNuoTexture ResultTexture(unsigned int index) const; 73 | 74 | virtual unsigned int AttachmentNumber() const; 75 | 76 | void SetBackBuffer(const PNuoResource& backBuffer, 77 | const D3D12_CPU_DESCRIPTOR_HANDLE& view); 78 | 79 | virtual PNuoCommandEncoder RetainRenderPassEncoder(const PNuoCommandBuffer& commandBuffer); 80 | virtual void ReleaseRenderPassEncoder(); 81 | 82 | DXGI_FORMAT Format() const; 83 | 84 | unsigned int SampleCount() const; 85 | void SetSampleCount(unsigned int sampleCount); 86 | 87 | NuoSize DrawableSize() const; 88 | virtual void SetDrawableSize(const NuoSize& size); 89 | 90 | unsigned int Width() const; 91 | unsigned int Height() const; 92 | 93 | protected: 94 | 95 | void CreateDepth(); 96 | void CreateTextures(); 97 | 98 | }; 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /lua/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include 11 | 12 | #include "lobject.h" 13 | #include "lzio.h" 14 | 15 | 16 | /* 17 | ** Single-char tokens (terminal symbols) are represented by their own 18 | ** numeric code. Other tokens start at the following value. 19 | */ 20 | #define FIRST_RESERVED (UCHAR_MAX + 1) 21 | 22 | 23 | #if !defined(LUA_ENV) 24 | #define LUA_ENV "_ENV" 25 | #endif 26 | 27 | 28 | /* 29 | * WARNING: if you change the order of this enumeration, 30 | * grep "ORDER RESERVED" 31 | */ 32 | enum RESERVED { 33 | /* terminal symbols denoted by reserved words */ 34 | TK_AND = FIRST_RESERVED, TK_BREAK, 35 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 36 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 37 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 38 | /* other terminal symbols */ 39 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 40 | TK_SHL, TK_SHR, 41 | TK_DBCOLON, TK_EOS, 42 | TK_FLT, TK_INT, TK_NAME, TK_STRING 43 | }; 44 | 45 | /* number of reserved words */ 46 | #define NUM_RESERVED (cast_int(TK_WHILE-FIRST_RESERVED + 1)) 47 | 48 | 49 | typedef union { 50 | lua_Number r; 51 | lua_Integer i; 52 | TString *ts; 53 | } SemInfo; /* semantics information */ 54 | 55 | 56 | typedef struct Token { 57 | int token; 58 | SemInfo seminfo; 59 | } Token; 60 | 61 | 62 | /* state of the lexer plus state of the parser when shared by all 63 | functions */ 64 | typedef struct LexState { 65 | int current; /* current character (charint) */ 66 | int linenumber; /* input line counter */ 67 | int lastline; /* line of last token 'consumed' */ 68 | Token t; /* current token */ 69 | Token lookahead; /* look ahead token */ 70 | struct FuncState *fs; /* current function (parser) */ 71 | struct lua_State *L; 72 | ZIO *z; /* input stream */ 73 | Mbuffer *buff; /* buffer for tokens */ 74 | Table *h; /* to avoid collection/reuse strings */ 75 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 76 | TString *source; /* current source name */ 77 | TString *envn; /* environment variable name */ 78 | } LexState; 79 | 80 | 81 | LUAI_FUNC void luaX_init (lua_State *L); 82 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 83 | TString *source, int firstchar); 84 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 85 | LUAI_FUNC void luaX_next (LexState *ls); 86 | LUAI_FUNC int luaX_lookahead (LexState *ls); 87 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 88 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 89 | 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUI/FoundationResource.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "FoundationResource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winres.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (United States) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 20 | #pragma code_page(1252) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource2.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Dialog 51 | // 52 | 53 | IDD_DIALOG_FOUNDATION DIALOGEX 0, 0, 311, 179 54 | STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU 55 | CAPTION "Dialog" 56 | FONT 8, "MS Shell Dlg", 400, 0, 0x1 57 | BEGIN 58 | DEFPUSHBUTTON "OK",IDOK,200,158,50,14,BS_FLAT 59 | PUSHBUTTON "Cancel",IDCANCEL,254,158,50,14,BS_FLAT 60 | END 61 | 62 | 63 | ///////////////////////////////////////////////////////////////////////////// 64 | // 65 | // DESIGNINFO 66 | // 67 | 68 | #ifdef APSTUDIO_INVOKED 69 | GUIDELINES DESIGNINFO 70 | BEGIN 71 | IDD_DIALOG_FOUNDATION, DIALOG 72 | BEGIN 73 | LEFTMARGIN, 7 74 | RIGHTMARGIN, 304 75 | TOPMARGIN, 7 76 | BOTTOMMARGIN, 172 77 | END 78 | END 79 | #endif // APSTUDIO_INVOKED 80 | 81 | 82 | ///////////////////////////////////////////////////////////////////////////// 83 | // 84 | // AFX_DIALOG_LAYOUT 85 | // 86 | 87 | IDD_DIALOG_FOUNDATION AFX_DIALOG_LAYOUT 88 | BEGIN 89 | 0 90 | END 91 | 92 | #endif // English (United States) resources 93 | ///////////////////////////////////////////////////////////////////////////// 94 | 95 | 96 | 97 | #ifndef APSTUDIO_INVOKED 98 | ///////////////////////////////////////////////////////////////////////////// 99 | // 100 | // Generated from the TEXTINCLUDE 3 resource. 101 | // 102 | 103 | 104 | ///////////////////////////////////////////////////////////////////////////// 105 | #endif // not APSTUDIO_INVOKED 106 | 107 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUtilites/Win/NuoMathVectorTypeTraitWin.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoMathVectorWin.hpp 3 | // ModelViewer 4 | // 5 | // Created by Dong on 11/4/2020. 6 | // Copyright © 2018 middleware. All rights reserved. 7 | // 8 | 9 | #ifndef NuoMathVectorTypeTrait_h 10 | #define NuoMathVectorTypeTrait_h 11 | 12 | #include 13 | 14 | 15 | template <> 16 | class VectorTrait 17 | { 18 | public: 19 | typedef DirectX::XMFLOAT2 _vectorType; 20 | }; 21 | 22 | 23 | template <> 24 | class VectorTrait 25 | { 26 | public: 27 | typedef DirectX::XMFLOAT3 _vectorType; 28 | typedef DirectX::XMFLOAT3X3 _matrixType; 29 | }; 30 | 31 | template <> 32 | class VectorTrait 33 | { 34 | public: 35 | typedef DirectX::XMVECTOR _vectorType; 36 | typedef DirectX::XMMATRIX _matrixType; 37 | }; 38 | 39 | 40 | bool operator == (const DirectX::XMVECTOR& v1, const DirectX::XMVECTOR& v2); 41 | bool operator == (const DirectX::XMFLOAT3& v1, const DirectX::XMFLOAT3& v2); 42 | bool operator == (const DirectX::XMFLOAT2& v1, const DirectX::XMFLOAT2& v2); 43 | 44 | 45 | DirectX::XMVECTOR NuoXMLoad(const DirectX::XMFLOAT3& vector); 46 | DirectX::XMVECTOR NuoXMLoad(const DirectX::XMFLOAT4& vector); 47 | float NuoXMDot(const DirectX::XMFLOAT3& v1, const DirectX::XMFLOAT3& v2); 48 | float NuoXMDot(const DirectX::XMVECTOR& v1, const DirectX::XMVECTOR& v2); 49 | DirectX::XMFLOAT3 NuoXMCross(const DirectX::XMFLOAT3& v1, const DirectX::XMFLOAT3& v2); 50 | DirectX::XMVECTOR NuoXMCross(const DirectX::XMVECTOR& v1, const DirectX::XMVECTOR& v2); 51 | DirectX::XMFLOAT3 NuoXMNormalize(const DirectX::XMFLOAT3& v); 52 | DirectX::XMVECTOR NuoXMNormalize(const DirectX::XMVECTOR& v); 53 | 54 | 55 | DirectX::XMFLOAT3 operator + (const DirectX::XMFLOAT3& v1, const DirectX::XMFLOAT3& v2); 56 | DirectX::XMFLOAT3 operator - (const DirectX::XMFLOAT3& v1, const DirectX::XMFLOAT3& v2); 57 | DirectX::XMFLOAT3 operator - (const DirectX::XMFLOAT3& v); 58 | DirectX::XMVECTOR operator + (const DirectX::XMVECTOR& v1, const DirectX::XMVECTOR& v2); 59 | DirectX::XMVECTOR operator - (const DirectX::XMVECTOR& v1, const DirectX::XMVECTOR& v2); 60 | DirectX::XMVECTOR operator - (const DirectX::XMVECTOR& v); 61 | DirectX::XMFLOAT3 operator / (const DirectX::XMFLOAT3& v, float div); 62 | DirectX::XMVECTOR operator / (const DirectX::XMVECTOR& v, float div); 63 | DirectX::XMFLOAT3 operator * (const DirectX::XMFLOAT3& v, float mul); 64 | DirectX::XMVECTOR operator * (const DirectX::XMVECTOR& v, float mul); 65 | 66 | DirectX::XMFLOAT3 operator * (const DirectX::XMFLOAT3X3& m, const DirectX::XMFLOAT3& v); 67 | DirectX::XMVECTOR operator * (const DirectX::XMMATRIX& m, const DirectX::XMVECTOR& v); 68 | 69 | float NuoTraitLength(const DirectX::XMFLOAT3& vector); 70 | float NuoTraitLength(const DirectX::XMVECTOR& vector); 71 | 72 | 73 | 74 | #endif /* NuoMathVectorMac_h */ 75 | -------------------------------------------------------------------------------- /NuoModelViewer/NuoModelViewer/ModelState/ModelViewConfiguration.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // ModelViewConfiguration.cpp 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 12/20/2020. 6 | // Copyright 2020 Dong Feng. All rights reserved. 7 | // 8 | 9 | #include "ModelViewConfiguration.h" 10 | 11 | #include "NuoFile.h" 12 | #include "NuoScripting/NuoLua.h" 13 | #include "NuoDirect/NuoDevice.h" 14 | #include "NuoUtilites/NuoTableExporter.h" 15 | 16 | 17 | ModelViewConfiguration::ModelViewConfiguration(const std::string& path) 18 | : _path(path) 19 | { 20 | Load(); 21 | 22 | if (_deviceName.empty()) 23 | { 24 | InitDeviceName(); 25 | } 26 | 27 | bool validDevice = false; 28 | 29 | auto devices = NuoDevice::Devices(); 30 | for (auto device : devices) 31 | { 32 | _devices.insert(std::make_pair(device->Name(), device)); 33 | if (device->Name() == _deviceName) 34 | validDevice = true; 35 | } 36 | 37 | // eGPU may be removed 38 | 39 | if (!validDevice) 40 | { 41 | InitDeviceName(); 42 | } 43 | } 44 | 45 | 46 | ModelViewConfiguration::~ModelViewConfiguration() 47 | { 48 | Save(); 49 | } 50 | 51 | 52 | PNuoDevice ModelViewConfiguration::Device() 53 | { 54 | return _devices[_deviceName]; 55 | } 56 | 57 | 58 | std::vector ModelViewConfiguration::DeviceNames() const 59 | { 60 | std::vector result; 61 | 62 | for (auto device : _devices) 63 | { 64 | if (device.second->SupportRayTracing()) 65 | result.push_back(device.first); 66 | } 67 | 68 | return result; 69 | } 70 | 71 | 72 | void ModelViewConfiguration::SelectDevice(const std::string& device) 73 | { 74 | _deviceName = device; 75 | } 76 | 77 | 78 | void ModelViewConfiguration::Load() 79 | { 80 | NuoFile file(_path); 81 | if (!file.Exists()) 82 | return; 83 | 84 | NuoLua lua; 85 | 86 | lua.LoadFile(_path); 87 | 88 | _deviceName = lua.GetFieldAsString("device", -1); 89 | } 90 | 91 | 92 | void ModelViewConfiguration::Save() 93 | { 94 | NuoTableExporter exporter; 95 | 96 | exporter.StartTable(); 97 | 98 | exporter.StartEntry("device"); 99 | exporter.SetEntryValueString(_deviceName); 100 | exporter.EndEntry(false); 101 | 102 | exporter.EndTable(); 103 | 104 | const std::string& content = exporter.GetResult(); 105 | 106 | NuoFile file(_path); 107 | file.Write((void*)content.c_str(), content.length()); 108 | } 109 | 110 | 111 | 112 | void ModelViewConfiguration::InitDeviceName() 113 | { 114 | auto devices = NuoDevice::Devices(); 115 | for (auto device : devices) 116 | { 117 | if (device->SupportRayTracing()) 118 | _deviceName = device->Name(); 119 | } 120 | } 121 | 122 | 123 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoUtilites/NuoBackgroundTask.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // NuoBackgroundTask.cpp 3 | // ModelViewer 4 | // 5 | // Created by Dong Feng on 2/20/2021. 6 | // Copyright © 2021 middleware. All rights reserved. 7 | // 8 | 9 | #include "NuoBackgroundTask.h" 10 | 11 | #include "NuoTimer.h" 12 | #include "NuoDispatch.h" 13 | 14 | 15 | NuoBackgroundTask::NuoBackgroundTask(NuoTask work) 16 | : _work(work), _started(false), _running(false), _progress(0) 17 | { 18 | } 19 | 20 | 21 | 22 | bool NuoBackgroundTask::Resume(float* progress) 23 | { 24 | if (!_started) 25 | { 26 | auto running = &_running; 27 | 28 | _timer = NuoTimer::MakeTimer(1, [running](NuoTimer* timer) 29 | { 30 | if (!(*running)) 31 | return false; 32 | }); 33 | 34 | auto progressRate = &_progress; 35 | auto work = _work; 36 | 37 | _running = true; 38 | 39 | NuoDispatch* dispatch = NuoDispatch::GetInstance(); 40 | dispatch->DispatchAsync([progressRate, running, work]() 41 | { 42 | work([progressRate](float progress) 43 | { 44 | *progressRate = progress; 45 | }); 46 | 47 | *running = false; 48 | }); 49 | 50 | _started = true; 51 | } 52 | 53 | MSG msg; 54 | 55 | // Main message loop: 56 | if (GetMessage(&msg, nullptr, 0, 0)) 57 | { 58 | TranslateMessage(&msg); 59 | DispatchMessage(&msg); 60 | } 61 | 62 | if (progress) 63 | *progress = _progress; 64 | 65 | return _running; 66 | } 67 | 68 | 69 | void NuoBackgroundTask::Await() 70 | { 71 | while (Resume(nullptr)); 72 | } 73 | 74 | 75 | void NuoBackgroundTask::BackgroundTask(NuoTask work, NuoTaskProgress progress, NuoTaskCompletion completion) 76 | { 77 | NuoDispatch* dispatch = NuoDispatch::GetInstance(); 78 | 79 | std::shared_ptr> running = std::make_shared>(); 80 | *running = true; 81 | 82 | std::shared_ptr> progressRate = std::make_shared>(0.0f); 83 | 84 | PNuoTimer timer = NuoTimer::MakeTimer(1, [progress, completion, progressRate, running](NuoTimer* timer) 85 | { 86 | if (*running) 87 | { 88 | progress(*progressRate); 89 | return true; 90 | } 91 | 92 | completion(); 93 | return false; 94 | }); 95 | 96 | dispatch->DispatchAsync([progressRate, running, work]() 97 | { 98 | work([progressRate](float progress) 99 | { 100 | *progressRate = progress; 101 | }); 102 | 103 | *running = false; 104 | }); 105 | } 106 | 107 | 108 | -------------------------------------------------------------------------------- /NuoWindowsFoundation/NuoDirect/NuoDescriptorHeap.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "NuoDescriptorHeap.h" 4 | 5 | 6 | #include "NuoTexture.h" 7 | #include "NuoDevice.h" 8 | 9 | 10 | 11 | NuoDescriptorHeap::NuoDescriptorHeap(NuoDescriptorType type) 12 | : _type(type), _size(0) 13 | { 14 | } 15 | 16 | 17 | 18 | unsigned int NuoDescriptorHeap::Incremental() 19 | { 20 | switch (_type) 21 | { 22 | case kNuoDescriptor_RenderTarget: 23 | return _device->RenderTargetDescriptorHandleIncrementSize(); 24 | case kNuoDescriptor_DepthStencil: 25 | return _device->DxDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV); 26 | case kNuoDescriptor_ShaderResource: 27 | return _device->ShaderResourceDescriptorHandleIncrementSize(); 28 | } 29 | return 0; 30 | } 31 | 32 | 33 | 34 | D3D12_CPU_DESCRIPTOR_HANDLE NuoDescriptorHeap::DxCPUHandle(unsigned int index) 35 | { 36 | D3D12_CPU_DESCRIPTOR_HANDLE cbvHandle(DxHeapCPUHandle()); 37 | SIZE_T offset = (UINT32)index * Incremental(); 38 | cbvHandle.ptr = (SIZE_T)((char*)cbvHandle.ptr + offset); 39 | 40 | return cbvHandle; 41 | } 42 | 43 | 44 | D3D12_GPU_DESCRIPTOR_HANDLE NuoDescriptorHeap::DxGPUHandle(unsigned int index) 45 | { 46 | D3D12_GPU_DESCRIPTOR_HANDLE cbvHandle(DxHeapGPUHandle()); 47 | SIZE_T offset = (UINT32)index * Incremental(); 48 | cbvHandle.ptr = (SIZE_T)((char*)cbvHandle.ptr + offset); 49 | 50 | return cbvHandle; 51 | } 52 | 53 | 54 | D3D12_CPU_DESCRIPTOR_HANDLE NuoDescriptorHeap::DxHeapCPUHandle() 55 | { 56 | return _heap->GetCPUDescriptorHandleForHeapStart(); 57 | } 58 | 59 | 60 | D3D12_GPU_DESCRIPTOR_HANDLE NuoDescriptorHeap::DxHeapGPUHandle() 61 | { 62 | return _heap->GetGPUDescriptorHandleForHeapStart(); 63 | } 64 | 65 | 66 | void NuoDescriptorHeap::SetTexture(unsigned int index, 67 | const PNuoTexture& texture) 68 | { 69 | D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; 70 | srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; 71 | srvDesc.Format = texture->Format(); 72 | srvDesc.ViewDimension = texture->SampleCount() > 1 ? D3D12_SRV_DIMENSION_TEXTURE2DMS : 73 | D3D12_SRV_DIMENSION_TEXTURE2D; 74 | srvDesc.Texture2D.MipLevels = 1; 75 | 76 | _device->DxDevice()->CreateShaderResourceView(texture->DxResource(), &srvDesc, DxCPUHandle(index)); 77 | } 78 | 79 | 80 | void NuoDescriptorHeap::SetConstantBuffer(unsigned int index, 81 | const PNuoResource& buffer) 82 | { 83 | D3D12_CONSTANT_BUFFER_VIEW_DESC desc; 84 | desc.BufferLocation = buffer->DxResource()->GetGPUVirtualAddress(); 85 | desc.SizeInBytes = buffer->Size(); 86 | 87 | _device->DxDevice()->CreateConstantBufferView(&desc, DxCPUHandle(index)); 88 | } 89 | 90 | 91 | ID3D12DescriptorHeap* NuoDescriptorHeap::DxHeap() const 92 | { 93 | return _heap.Get(); 94 | } 95 | 96 | --------------------------------------------------------------------------------