这个类是在Android下定义的:
public abstract class EGLObjectHandle {
private final long mHandle;
protected EGLObjectHandle(long handle) {
mHandle = handle;
}
public long getNativeHandle() {
return mHandle;
}
}
还有
public class EGLContext extends EGLObjectHandle {
private EGLContext(long handle) {
super(handle);
}
}
现在我的问题是我想用我的句柄创建一个 EGLContext。怎么做?在我使用以下功能执行此操作之前,但它在 PIE 上不再工作
private android.opengl.EGLContext createSharedEGLContextObj(long handle) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
Class<?> classType =Class.forName("android.opengl.EGLContext");
Class<?>[] types = new Class[] { long.class };
Constructor constructor=classType.getDeclaredConstructor(types);
constructor.setAccessible(true);
Object object=constructor.newInstance(handle);
return (android.opengl.EGLContext) object;
}
我需要一个EGLContext
,因为我需要将其传递给需要 EGLContext 参数的过程,例如:createEgl14( android.opengl.EGLContext sharedContext)
你几乎不能。根据Android限制,他们将JNI和反射限制为仅SDK接口。
我认为您的最后一个选择是请求一项新功能,他们将在其中更改构造函数对公众的可见性。