# Native code (C++) rendering plugin example for Unity
This sample demonstrates how to render and do other graphics related things from a C++ plugin, via a
[native plugin interface](http://docs.unity3d.com/Manual/NativePluginInterface.html).
Unity versions:
* **2018.1+** use tip of default branch.
* 5.6, 5.5, 5.4: use corresponding `unity-x.x` tag.
The plugin itself does very few things:
* **Demonstrates basic plumbing**. How to initialize the graphics API, and how calls from Unity into plugin are made.
* **Draws a triangle**. A single colored rotating triangle in the middle of the screen. For each backend API, this shows bare basics of how to setup vertex data, setup
some shaders or render states, and do a draw call.
* **Changes Unity texture data**. Unity side passes a texture into the plugin, and the code changes the pixels of it each frame, with an animated "plasma" pattern. This
demonstrates how to work with [Texture.GetNativeTexturePtr](https://docs.unity3d.com/ScriptReference/Texture.GetNativeTexturePtr.html).
* **Changes Unity mesh vertex data**. Unity side passes a vertex buffer into the plugin, and the code changes the vertices each frame, with an animated "heightfield" pattern. This
demonstrates how to work with [Mesh.GetNativeVertexBufferPtr](https://docs.unity3d.com/ScriptReference/Mesh.GetNativeVertexBufferPtr.html).
Native code rendering is implemented for several platforms and graphics APIs:
* Windows (D3D11, D3D12, OpenGL, Vulkan)
* Note that Vulkan is not compiled in by default (requires Vulkan SDK); enable it by editing `#define SUPPORT_VULKAN 0`
to `1` under `UNITY_WIN` clause in `PlatformBase.h`
* macOS (Metal, OpenGL)
* Linux (OpenGL, Vulkan)
* Windows Store aka UWP (D3D11, D3D12)
* WebGL (OpenGL ES)
* Android (OpenGL ES, Vulkan)
* iOS/tvOS (Metal; Simulator is supported if you use unity 2020+ and XCode 11+)
* EmbeddedLinux (OpenGL, Open GLES)
* ...more platforms might be coming soon, we just did not get around to adding project files yet.
Code is organized as follows:
* `PluginSource` is source code & IDE project files for the C++ plugin.
* `source`: The source code itself. `RenderingPlugin.cpp` is the main logic, `RenderAPI*.*` files contain rendering implementations for different APIs.
* `projects/VisualStudio2015`: Visual Studio 2015 project files for regular Windows plugin
* `projects/UWPVisualStudio2015`: Visual Studio 2015 project files for Windows Store (UWP - Win10) plugin
* `projects/Xcode`: Apple Xcode project file for Mac OS X plugin, Xcode 10.3 on macOS 10.14 was tested
* `projects/GNUMake`: Makefile for Linux
* `projects/EmbeddedLinux`: Windows .bat files to build plugins for different architectures
* `UnityProject` is the Unity (2018.3.9 was tested) project.
* Single `scene` that contains the plugin sample scene.
### What license are the graphics samples shipped under?
Just like with most other samples, the license is MIT/X11.
没有合适的资源?快使用搜索试试~ 我知道了~
C++ Rendering Plugin example for Unity.zip
共111个文件
meta:35个
asset:18个
h:11个
需积分: 5 0 下载量 104 浏览量
2024-01-05
14:16:35
上传
评论
收藏 348KB ZIP 举报
温馨提示
C++ Rendering Plugin example for Unity
资源推荐
资源详情
资源评论
收起资源包目录
C++ Rendering Plugin example for Unity.zip (111个子文件)
ProjectSettings.asset 20KB
InputManager.asset 5KB
GraphicsSettings.asset 2KB
NavMeshLayers.asset 2KB
NavMeshAreas.asset 2KB
Physics2DSettings.asset 1KB
QualitySettings.asset 1003B
UnityConnectSettings.asset 812B
TagManager.asset 708B
DynamicsManager.asset 665B
EditorSettings.asset 479B
VFXManager.asset 273B
AudioManager.asset 213B
TimeManager.asset 175B
NetworkManager.asset 151B
EditorBuildSettings.asset 138B
PresetManager.asset 120B
ClusterInputManager.asset 114B
make_x64.bat 658B
make_arm64.bat 643B
make_x86.bat 559B
make_arm32.bat 553B
gl3w.c 82KB
RenderAPI_Vulkan.cpp 32KB
RenderAPI_D3D11.cpp 10KB
RenderingPlugin.cpp 9KB
RenderAPI_OpenGLCoreES.cpp 9KB
RenderAPI_D3D12.cpp 7KB
RenderAPI.cpp 1KB
RenderingPlugin.cpp 195B
UseRenderingPlugin.cs 5KB
MyBuildPostprocessor.cs 2KB
RenderingPlugin.def 259B
RenderingPlugin.dll 144KB
RenderingPlugin.dll 120KB
RenderingPlugin.dll 20KB
RenderingPlugin.dll 17KB
RenderingPlugin.dll 16KB
RenderingPlugin.dll 13KB
RenderingPlugin.dll 13KB
RenderingPlugin.dll 11KB
RenderingPlugin.vcxproj.filters 2KB
RenderingPlugin.vcxproj.filters 2KB
.gitignore 310B
glcorearb.h 242KB
gl3w.h 63KB
IUnityGraphicsVulkan.h 18KB
IUnityInterface.h 8KB
IUnityGraphicsD3D12.h 6KB
IUnityGraphics.h 3KB
RenderAPI.h 2KB
IUnityGraphicsMetal.h 2KB
PlatformBase.h 2KB
IUnityGraphicsD3D11.h 709B
IUnityGraphicsD3D9.h 368B
manifest.json 1KB
LICENSE 1KB
Makefile 547B
README.md 3KB
libRenderingPlugin.so.meta 1KB
libRenderingPlugin.so.meta 1KB
RenderingPlugin.dll.meta 1KB
RenderingPlugin.dll.meta 1KB
RenderingPlugin.cpp.meta 1006B
RenderingPlugin.bundle.meta 985B
RegisterPlugin.mm.meta 637B
RenderingPlugin.dll.meta 483B
RenderingPlugin.dll.meta 483B
RenderingPlugin.dll.meta 483B
RenderingPlugin.dll.meta 481B
RenderingPlugin.dll.meta 481B
RenderingPlugin.dll.meta 481B
x64.meta 191B
x86.meta 191B
ARM.meta 191B
x64.meta 191B
x86.meta 191B
ARM.meta 191B
SDK81.meta 191B
UWP.meta 191B
MyBuildPostprocessor.cs.meta 178B
iOS.meta 172B
WebGL.meta 172B
Contents.meta 172B
MacOS.meta 172B
UseRenderingPlugin.cs.meta 163B
Info.plist.meta 155B
RenderingPlugin.meta 155B
x86_64.meta 107B
Metro.meta 107B
x86.meta 107B
Editor.meta 107B
scene.unity.meta 60B
Plugins.meta 60B
Android.mk 661B
Application.mk 158B
RenderAPI_Metal.mm 8KB
RegisterPlugin.mm 673B
project.pbxproj 13KB
Info.plist 2KB
共 111 条
- 1
- 2
资源评论
Lei宝啊
- 粉丝: 1933
- 资源: 1331
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功