Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7029737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:34:40+00:00 2026-05-28T00:34:40+00:00

I’m trying to make an NDK-based game work on Android ICS. It worked fine

  • 0

I’m trying to make an NDK-based game work on Android ICS. It worked fine on Honeycomb and Gingerbread.

The game uses some 2D rendering, some 3D rendering, switching between the two at various stages of execution. (This is not negotiable due to third-party code.) We’re using ANativeWindow_lock()/ANativeWindow_unlockAndPost() for the 2D rendering, and eglCreateWindowSurface()/gl*()/eglSwapBuffers() for the 3D rendering.

On Honeycomb and Gingerbread this all worked fine. On ICS, eglCreateWindowSurface() fails with the following messages in the log:

E/SurfaceTexture( 1765): [com.fnord/com.fnord.MyActivity] connect: already connected (cur=2, req=1)
E/libEGL  ( 5466): EGLNativeWindowType 0x29e9b8 already connected to another API
E/libEGL  ( 5466): eglCreateWindowSurface:374 error 300b (EGL_BAD_NATIVE_WINDOW)
E/libEGL  ( 5466): call to OpenGL ES API with no current context (logged once per thread)

Looking at the source code it seems pretty obvious that eglCreateWindowSurface() is failing because something’s got the native window open for 2D rendering and it won’t let me change it to 3D without somehow releasing the surface first. However, the ANativeWindow API doesn’t seem to have any obvious way to do this.

Has anyone else run into this, and what’s the solution?

Updated

So I’ve rewritten my 2D rendering code to use OpenGL primitives instead (upload backbuffer to a texture, render texture via a pair of triangles, swapbuffers). This works up to a point. Now what’s happening is that the 2D rendering works fine; then I destroy the surface, create a new one in preparation for 3D rendering, and the second call to eglCreateWindowSurface() fails. This time, with:

E/SurfaceTexture( 1869): [com.fnord/com.fnord.MyActivity] connect: already connected (cur=1, req=1)

…and it throws an EGL error of AEGL_BAD_NATIVE_WINDOW.

Note that the new surface is created with precisely the same attributes as the old one. I’ve even tried making sure I call eglTerminate() / eglInitialize() between the two calls to eglCreateWindowSurface().

Is it the case that I can use each ANativeWindow precisely once? If so, doesn’t that fail Khronos’ EGL conformance tests? Is there a way to get NativeActivity to recreate the window, then?

Updated updated

Turns out that the last problem was caused by me failing to call eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT) before destroying the context and surface. This was causing the destruction to be delayed until the thread unbound the context and surface, which of course it wasn’t, so causing the call to eglCreateWindowSurface() to legitimately fail (you can’t have two window surfaces on the same native window).

This is a bit counterintuitive, because one would assume that calling eglTerminate() would destroy all EGL resources, but allowed for by the spec. Be warned!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:34:41+00:00Added an answer on May 28, 2026 at 12:34 am

    This is not a supported use case. The fact that it worked before was just luck for you and it could fail on some devices. You can work around this by rendering either the 2D or 3D content in a different window, or render the 2D content in a Bitmap that you then use as a GL texture, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.