Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make OpenGL ES calls from your C++ and Java code?

I have an application that will be taking advantage of the NDK do to high graphics requirements and a terrain generation library that I wrote in c++. My question is if I already made my GUI with the SDK and I make a random opengl call in java such as GLES20.glEnable(GL_CULL_FACE); and then proceed to call glEnable(GL_DEPTH_TEST); in C++ via JNI would there be any known errors/build issues? In the case that someone wonders why I am asking this and/or thinks it is a stupid question it is because in desktop OpenGL there is an existing OpenGL context (though GLFW took care of most of this). I am concerned if OpenGL ES also has an existing context. If so, would making OpenGL ES calls from both java and C++ write to previously stated context?

like image 472
SemperAmbroscus Avatar asked Dec 16 '14 22:12

SemperAmbroscus


Video Answer


1 Answers

In OpenGL you're always dealing with context, yes. The critical parts for you are

  • when and how is your OpenGL context bound in the Java parts?
  • is the OpenGL context kept current when calling into native code.

Practically all Java calls to OpenGL go into native code any way. So if you write parts of your program with the NDK and call into these parts in the same way as you'd call directly into OpenGL, then a OpenGL context will be current and be usable.

like image 197
datenwolf Avatar answered Sep 30 '22 14:09

datenwolf