Howto share a GpuImage with other SharpEngine.Scene? #14
-
|
Hi, When doning this in my case, i get an error like this.. Must I use a GpuImage for textures? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
If you want to share GPU objects with two Scenes, they need to use the same VulkanDevice (usually set to the GpuDevice property). There are multiple ways how to do that. Another option is to create one SharpEnginSceneView object and after calling Initialize method (without parameters or with createOptions as a parameter) on it get the created VulkanDevice from the Scene.GpuDevice property. Then use the VulkanDevice from the GpuProperty to initialize the second SharpEngineSceneView. After that, you can use Ab4d.SharpEngine.Utilities.TextureLoader.CreateTexture to load the texture into GpuImage. Then use that GpuImage to create two StandardMaterials (one for each Scene). Note that you can share only low level GpuImage and GpuBuffer objects (GpuBuffer can be used for vertex and index buffers). Materials and Meshes can be used only on a single Scene. But this is usually not a problem, because Meshes and Materials usually do not have a lot of their own data (the majority of data is stored in the GpuImage or GpuBuffer). |
Beta Was this translation helpful? Give feedback.
-
|
Use the same VulkanDevie for both Scenes helps. |
Beta Was this translation helpful? Give feedback.
If you want to share GPU objects with two Scenes, they need to use the same VulkanDevice (usually set to the GpuDevice property).
There are multiple ways how to do that.
You can first manually create the VulkanDevice and then use that to create both Scene objects. If you are using SharpEngineSceneView, you can create two instances of SharpEngineSceneView and then call the Initialize method and pass VulkanDevice as a parameter.
Another option is to create one SharpEnginSceneView object and after calling Initialize method (without parameters or with createOptions as a parameter) on it get the created VulkanDevice from the Scene.GpuDevice property. Then use the VulkanDevice from the GpuPrope…