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 7671003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:57:00+00:00 2026-05-31T15:57:00+00:00

We’re trying to port a C++ application to Android. We think that using NativeActivity

  • 0

We’re trying to port a C++ application to Android. We think that using NativeActivity should be easiest, and let all OpenGL/EGL-stuff be done natively.

Right now, we’re passing the ANativeWindow-pointer that we get from the android_app struct in android_native_app_glue.h through the application so that it can be used when the window is initialized. Here’s a few relevant lines from this code (stripped from debug-code):

bool OpenGLWindowES::Initialize(EGLNativeWindowType wnd, EGLNativeDisplayType dsp,
                            EGLint redSize, EGLint greenSize, EGLint blueSize, EGLint             alphaSize, EGLint depthSize, bool bMultiSample)
{
    m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if(m_display == EGL_NO_DISPLAY)
    {
        return false;
    }

    EGLint iMajorVersion, iMinorVersion;
    if (!eglInitialize(m_display, &iMajorVersion, &iMinorVersion))
    {
        return false;
    }

    eglBindAPI(EGL_OPENGL_ES_API);
    bool ecc = eglChooseConfig(m_display, attribs, &m_config, 1, &iConfigs);
    if (!ecc || (iConfigs != 1))
    {
        return false;
    }

    EGLint format;
    eglGetConfigAttrib(m_display, m_config, EGL_NATIVE_VISUAL_ID, &format);
    ANativeWindow_setBuffersGeometry(wnd, 0, 0, format);
    m_windowSurface = eglCreateWindowSurface(m_display, m_config, wnd, NULL);
    //etc
}    

This code proceeds with creating a context, makecurrent etc, but we don’t get that far. We get a segmentation fault on eglCreateWindowSurface and since the display and config seem to be initialized correctly, this can only mean a problem with the ANativeWindow* (tyepdef’d to a EGLNativeWindowType). Error message:

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000058

We also get a segmentation fault if we call for example:

ANativeWindow_getHeight(wnd);

So the question is, what can cause a segmentation fault at this point? wnd is not null, we’ve checked this before, so it should be initalized somehow and should be ready to use. Did we miss something before calling this function, or can there be some problem with the pointer?

EDIT: We’re currently wondering if this can have something to do with the APP_CMD_INIT_WINDOW command not being sent or received properly (we haven’t implemented any command handling at all yet so we’re looking into this).

  • 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-31T15:57:01+00:00Added an answer on May 31, 2026 at 3:57 pm

    Are you entirely sure that the window is correctly initialized?

    The ANativeWindow pointer in the app struct is not automatically set when passed into the native entry point. It is provided by the main Android thread at a later point and will then be sent to the app via the callback system that app_glue has set up.

    You need to handle the calls sent to the android_app yourself, in the native_activity example in the NDK they do it like this:

    int ident;
    int events;
    struct android_poll_source* source;
    
    // If not animating, we will block forever waiting for events.
    // If animating, we loop until all events are read, then continue
    // to draw the next frame of animation.
    while ((ident=ALooper_pollAll(engine.animating ? 0 : -1, NULL, &events,
            (void**)&source)) >= 0) {
    
        // Process this event.
        if (source != NULL) {
            source->process(state, source);
        }
        ....
    }
    

    You probably need something like this in your main rendering loop, this will allow app_glue to automatically set the window correctly when it gets it from the main thread.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
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
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

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.