Skip to content

Commit 0390e67

Browse files
committed
Merge pull request #174 from InfinyTech3D/fix_X11_texture
[src] Update SofaGraphicsAPI to support X11 texture
1 parent be5584b commit 0390e67

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Core/Plugins/SofaUnityAPI/GraphicAPI/AbstractSofaGraphicCall.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using UnityEngine;
33
using System.Collections;
44
using System.Collections.Generic;
5+
using UnityEngine.Rendering;
56

67
namespace SofaUnityAPI
78
{
@@ -15,6 +16,8 @@ public abstract class AbtractSofaGraphicCall : MonoBehaviour
1516
protected abstract int InitCall();
1617
protected abstract void BeforeDestroy();
1718

19+
protected abstract bool checkGraphicsDeviceType();
20+
1821
public void RegisterID(int renderID)
1922
{
2023
m_registeredRenderIDList.Add(renderID);
@@ -28,10 +31,8 @@ public bool GLRenderEnded()
2831
//// MonoBehavior API
2932
IEnumerator Start()
3033
{
31-
string graphicVersion = SystemInfo.graphicsDeviceVersion;
32-
if (!graphicVersion.Contains("OpenGL")) // only openGL version is supported
34+
if (!checkGraphicsDeviceType())
3335
{
34-
Debug.LogError("SofaGraphicCall - XRay and Ultrasound rendering are only available with Unity in OpenGL mode.");
3536
yield break;
3637
}
3738

@@ -94,7 +95,6 @@ private IEnumerator CallWaitForEndOfFrame()
9495
{
9596
foreach (int renderID in m_registeredRenderIDList)
9697
{
97-
//Debug.Log("Calling renderID " + renderID);
9898
GL.IssuePluginEvent(SofaUnityAPI.SofaGraphicAPI.getRenderEventFunc(), renderID);
9999
}
100100
}

Core/Plugins/SofaUnityAPI/GraphicAPI/SofaGraphicAPI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public void Dispose()
2222
public static extern int AddRenderEvent_SetVirtualXRayTexture(System.IntPtr simuContext, System.IntPtr texture, int w, int h, string objectName);
2323

2424
[DllImport("ImagingUS")]
25-
public static extern int AddRenderEvent_SetImagingUSTexture(System.IntPtr simuContext, System.IntPtr texture, int w, int h, string objectName);
25+
public static extern int AddRenderEvent_SetImagingUSTexture(System.IntPtr simuContext, System.IntPtr texture, int w, int h, string objectName, int graphicsType);
2626

2727
[DllImport("SofaVerseAPI")]
2828
public static extern void clearUp(System.IntPtr simuContext);
2929

3030
[DllImport("SofaVerseAPI")]
3131
public static extern IntPtr getRenderEventFunc();
3232
}
33-
33+
3434
}

0 commit comments

Comments
 (0)