本文介绍了“在没有当前上下文的情况下调用OpenGL ES API";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每当我取消注释下面的最后一行时,Dalvik LogCat就是这样说的.因此,在此过程中的某个地方根本没有创建当前上下文.为什么?感谢您的帮助.
That's what the Dalvik LogCat is saying whenever I uncomment the last line, below. So somewhere along the way, a current context isn't being created at all. Why? Thanks for any help.
final EGL10 egl = (EGL10) EGLContext.getEGL();
final EGLDisplay eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
egl.eglInitialize(eglDisplay, version);
int[] configSpec = {
EGL10.EGL_NONE
};
final EGLConfig[] config = new EGLConfig[1];
int num_configs[] = new int[1];
egl.eglChooseConfig(eglDisplay, configSpec, config, 1, num_configs);
final EGLContext eglContext = egl.eglCreateContext(eglDisplay, config[0], EGL10.EGL_NO_CONTEXT, null);
final GL10 gl = (GL10) eglContext.getGL();
int b[] = new int[w * (h)];
IntBuffer ib = IntBuffer.wrap(b);
ib.position(0);
gl.glReadPixels(w, 0, w, h, GL10.GL_RGB,GL10.GL_UNSIGNED_BYTE, ib);
推荐答案
在调用任何OpenGL函数之前,应使用EGL.eglMakeCurrent.这将使上下文在线程中为当前状态.
You should use EGL.eglMakeCurrent before calling any OpenGL functions. This will make the context current in the thread.
这篇关于“在没有当前上下文的情况下调用OpenGL ES API";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!