Skip to content

Commit c66605b

Browse files
authored
Merge pull request #45 from Unity-Technologies/add-qnx-support
add QNX support
2 parents 4dfdedc + 811d7b4 commit c66605b

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ UnityProject/Logs
1919
PluginSource/build
2020
PluginSource/projects/Android/libs/*
2121
PluginSource/projects/Android/obj/*
22+
PluginSource/source/*.o

PluginSource/projects/QNX/Makefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# UNITY_QNX_TARGET_LIB allows to specify the path to the QNX target libraries
2+
# e.g. for imx8qm, use "~/qnx710/target/qnx7/aarch64le/usr/lib/graphics/iMX8QM/"
3+
UNITY_QNX_TARGET_LIB ?= $(QNX_TARGET)/aarch64le/usr/lib
4+
5+
# UNITY_QNX_GLES2_LIB allows to link against a device/driver-specific library
6+
# e.g. for imx8qm, use "GLESv2_viv"
7+
UNITY_QNX_GLES2_LIB ?= GLESv2
8+
9+
SRCDIR = ../../source
10+
SRCS = $(SRCDIR)/RenderingPlugin.cpp \
11+
$(SRCDIR)/RenderAPI.cpp \
12+
$(SRCDIR)/RenderAPI_OpenGLCoreES.cpp
13+
OBJS = ${SRCS:.cpp=.o}
14+
UNITY_DEFINES = -DUNITY_QNX=1
15+
CXXFLAGS = $(UNITY_DEFINES) -O2 -fPIC
16+
LDFLAGS = -shared -rdynamic -static-libstdc++ -Wl,-soname,RenderingPlugin -Wl,-L$(UNITY_QNX_TARGET_LIB) -Wl,-l$(UNITY_QNX_GLES2_LIB)
17+
LIBS =
18+
PLUGIN_SHARED = libRenderingPlugin.so
19+
CXX = ntoaarch64-g++
20+
21+
ifeq (, $(shell echo $(QNX_TARGET)))
22+
$(error "QNX_TARGET is not set.")
23+
endif
24+
25+
ifeq (, $(shell echo $(QNX_HOST)))
26+
$(error "QNX_HOST is not set.")
27+
endif
28+
29+
# Check if the CXX variable is set to a valid compiler
30+
ifeq (, $(shell which $(CXX)))
31+
$(error "No $(CXX) in PATH. Did you set '$$QNX_HOST/usr/bin' in your PATH?")
32+
endif
33+
34+
.cpp.o:
35+
$(CXX) $(CXXFLAGS) -c -o $@ $<
36+
37+
all: clean shared
38+
39+
cleanobjs:
40+
rm -f $(OBJS)
41+
42+
cleanlib:
43+
rm -f $(PLUGIN_SHARED)
44+
45+
clean: cleanobjs cleanlib
46+
47+
shared: $(OBJS)
48+
$(CXX) $(LDFLAGS) -o $(PLUGIN_SHARED) $(OBJS) $(LIBS)

PluginSource/source/PlatformBase.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#endif
2929
#elif defined(__ANDROID__)
3030
#define UNITY_ANDROID 1
31-
#elif defined(UNITY_METRO) || defined(UNITY_LINUX) || defined(UNITY_WEBGL) || defined (UNITY_EMBEDDED_LINUX) || defined (UNITY_EMBEDDED_LINUX_GL)
31+
#elif defined(UNITY_METRO) || defined(UNITY_LINUX) || defined(UNITY_WEBGL) || defined (UNITY_EMBEDDED_LINUX) || defined (UNITY_EMBEDDED_LINUX_GL) || defined (UNITY_QNX)
3232
// these are defined externally
3333
#elif defined(__EMSCRIPTEN__)
3434
// this is already defined in Unity 5.6
@@ -68,6 +68,9 @@
6868
#ifndef SUPPORT_VULKAN
6969
#define SUPPORT_VULKAN 0
7070
#endif
71+
#elif UNITY_QNX
72+
#define SUPPORT_OPENGL_UNIFIED 1
73+
#define SUPPORT_OPENGL_ES 1
7174
#endif
7275

7376
#if UNITY_IOS || UNITY_TVOS || UNITY_OSX

PluginSource/source/RenderAPI_OpenGLCoreES.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
# define GL_GLEXT_PROTOTYPES
3030
# include <GL/gl.h>
3131
#endif
32+
#elif UNITY_QNX
33+
# include <GLES2/gl2.h>
3234
#else
3335
# error Unknown platform
3436
#endif

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ Native code rendering is implemented for several platforms and graphics APIs:
3131
* WebGL (OpenGL ES)
3232
* Android (OpenGL ES, Vulkan)
3333
* iOS/tvOS (Metal; Simulator is supported if you use unity 2020+ and XCode 11+)
34-
* EmbeddedLinux (OpenGL, Open GLES)
34+
* EmbeddedLinux (OpenGL, OpenGL ES , Vulkan)
35+
* QNX (OpenGL ES)
3536
* ...more platforms might be coming soon, we just did not get around to adding project files yet.
3637

3738
Code is organized as follows:
@@ -43,6 +44,7 @@ Code is organized as follows:
4344
* `projects/Xcode`: Apple Xcode project file for Mac OS X plugin, Xcode 10.3 on macOS 10.14 was tested
4445
* `projects/GNUMake`: Makefile for Linux
4546
* `projects/EmbeddedLinux`: Windows .bat files to build plugins for different architectures
47+
* `projects/QNX`: Makefile for Linux requires QNX to be installed and environment variables to be set
4648
* `UnityProject` is the Unity (2023.1.15f1 was tested) project.
4749
* Single `scene` that contains the plugin sample scene.
4850

0 commit comments

Comments
 (0)