Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime error: call to OpenGL ES API with no current context #17

Closed
liming0791 opened this issue Jan 3, 2017 · 2 comments
Closed

Runtime error: call to OpenGL ES API with no current context #17

liming0791 opened this issue Jan 3, 2017 · 2 comments

Comments

@liming0791
Copy link

liming0791 commented Jan 3, 2017

I try to port PTAMM to android, whitch uses OpenGL API. When the application run, I got the following log information about LIBGL :

I/LIBGL: LIBGL:loaded: libGLESv1_CM.so
I/LIBGL: LIBGL:loaded: libEGL.so
E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
D/libEGL: eglInitialize EGLDisplay = 0xff96769c
I/LIBGL: LIBGL: Extension GL_OES_blend_subtract detected and used
I/LIBGL: LIBGL: Extension GL_OES_blend_func_separate detected and used
I/LIBGL: LIBGL: Extension GL_OES_blend_equation_separate detected and used
I/LIBGL: LIBGL: Extension GL_EXT_blend_minmax detected and used
I/LIBGL: LIBGL: Extension GL_OES_point_sprite detected and used
I/LIBGL: LIBGL: Extension GL_OES_point_size_array detected
I/LIBGL: LIBGL: Extension GL_OES_element_index_uint detected
I/LIBGL: LIBGL: Extension GL_OES_framebuffer_object detected and used
I/LIBGL: LIBGL: Extension GL_OES_packed_depth_stencil detected and used
I/LIBGL: LIBGL: Extension GL_OES_depth24 detected and used
I/LIBGL: LIBGL: Extension GL_OES_rgb8_rgba8 detected and used
I/LIBGL: LIBGL: Extension GL_EXT_texture_format_BGRA8888 detected
I/LIBGL: LIBGL: Extension GL_OES_texture_cube_map detected and used
I/LIBGL: LIBGL: Max texture size: 16384
I/LIBGL: LIBGL: Texture Units: 8, Max lights: 8
I/LIBGL: LIBGL: Implementation Read is GL_RGBA/GL_UNSIGNED_BYTE
I/LIBGL: LIBGL: Current folder is:/

About the app, related native code :

void ARDriver::MakeFrameBuffer()
{
  // Needs nvidia drivers >= 97.46
  cout << "  ARDriver: Creating FBO... ";

  glGenTextures(1, &mnFrameBufferTex);
  glBindTexture(GL_TEXTURE_RECTANGLE_ARB,mnFrameBufferTex);
  glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0,
	       GL_RGBA, mirFBSize.x, mirFBSize.y, 0,
	       GL_RGBA, GL_UNSIGNED_BYTE, NULL);
  glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

  GLuint DepthBuffer;
  glGenRenderbuffersEXT(1, &DepthBuffer);
  glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthBuffer);
  glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, mirFBSize.x, mirFBSize.y);

  glGenFramebuffersEXT(1, &mnFrameBuffer);
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mnFrameBuffer);
  glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
			    GL_TEXTURE_RECTANGLE_ARB, mnFrameBufferTex, 0);
  glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
  			       GL_RENDERBUFFER_EXT, DepthBuffer);

  CheckFramebufferStatus();
  cout << " .. created FBO." << endl;
  glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}

static bool CheckFramebufferStatus()
{
  GLenum n;
  n = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
  if(n == GL_FRAMEBUFFER_COMPLETE_EXT)
    return true; // All good
  
  cout << "glCheckFrameBufferStatusExt returned an error." << endl;
  return false;
}

And the related log:

ARDriver: Creating FBO... glCheckFrameBufferStatusExt returned an error.
.. created FBO.

I don't know what is wrong. Error when LIBGL initializing ? Or the way I call OpenGL API ?

@ptitSeb
Copy link
Owner

ptitSeb commented Jan 3, 2017

I haven't checked the entire source code but I suspect the issue is with the GLES 1.1 context creation.

There is a limit of gl4es on Android for now: there is no real glX support, so gl4es is not abble to create the GLES 1.1 context by itself.
Most (all?) existing use of gl4es on Android use SDL or SDL2 and let it create that context.

So you have to create a GLES 1.1 context before calling any gl function in your Android app.

(the gl itself looks fine and should run in gl4es)

@liming0791
Copy link
Author

@ptitSeb
Finally, I find the problem has nothing to do with the GLES 1.1 context creation.

I use GLSurfaceView in JAVA code to create GLES 1.1 context.

Although the error log shows every time when the app runs :

E/libEGL: call to OpenGL ES API with no current context (logged once per thread)
E/libEGL: call to OpenGL ES API with no current context (logged once per thread)

In fact the opengl functions can work fine.

The problem is some other bugs and have nothing to do with gl4es.

Sorry about that ...

Besides, I find that GL_TEXTURE_RECTANGLE_ARB does not work with gl4es, while GL_TEXTURE_2D works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants