NativeScript and WebGL - how to do it


Hello everyone, I have a question regarding NativeScript and OpenGL
We have an angular application with webGL stuff, that we want to port to mobile, but I’m not sure how to handle webgl with nativeScript
We write raw webgl so there is almost a perfect mapping between our webgl calls and native opengl ES calls.
I understand nativeScript does not convert webgl calls to native calls so we will have to do it ourselves and that’s not a problem, but I’m trying to understand how this fits conceptually in the “nativeScript way”.
Do we have to write some sort of native openGL plugin that would interface with nativeScript?

I’m trying to understand the target architecture


all the best



btw here is our angular application we want to port to mobile with nativeScript:

(currently it’s angular1 but we are porting it to angular2 before making the move with nativeScript)


You don’t have to write a plugin so to speak. You can communicate with the native APIs directly in your js code, for Android: I haven’t used OpenGL myself so I don’t have direct experience with the API but hopefully knowing you don’t need a “plugin” helps. However, the benefit of wrapping into a plugin is then in your code base you use the plugins api that you create in your code so you don’t have to write platform checks before calling the different native apis. Hope that makes some sense :slight_smile:


many thanks for your answer, if I understand correctly, from nativeScript we can simply call the native platform graphics API directly?
If yes that’s awesome


no guarantees the openGL will work from my word :slight_smile: but yes, you can call native apis direct. It’s the greatest thing in the world :thumbsup:. That is how all of the plugins and the core work. For example: this is a plugin I worked on and just called the Android snackbar. If this wasn’t in a plugin and I had the android library pulled into my app, you could do the same in your app code. Like var snackBar = .... just the same.