Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

According to OGLES specification, we have the following definition:

EGLSurface eglCreateWindowSurface(EGLDisplay display,
                                  EGLConfig config,
                                  NativeWindowType native_window,
                                  EGLint const * attrib_list)

More details, here: http://www.khronos.org/opengles/documentation/opengles1_0/html/eglCreateWindowSurface.html

And also by definition:

int32_t ANativeWindow_setBuffersGeometry(ANativeWindow* window, int32_t width, 
                                         int32_t height, int32_t format);

More details, here: http://mobilepearls.com/labs/native-android-api

I am running Android Native App on OGLES 2 and debugging it in a Samsung Nexus device. For setting up the 3D scene graph environment, the following variables are defined:

struct android_app {
    ...
    ANativeWindow* window;
};
android_app* mApplication;
...
mApplication=&pApplication;

And to initialize the App, we run the commands in the code:

ANativeWindow_setBuffersGeometry(mApplication->window, 0, 0, lFormat);
mSurface = eglCreateWindowSurface(mDisplay, lConfig, 
                                  mApplication->window, NULL);

Funny to say is that, the command ANativeWindow_setBuffersGeometry behaves as expected and works fine according to its definition, accepting all the parameters sent to it. But the eglCreateWindowSurface does no accept the parameter mApplication->window, as it should accept according to its definition. Instead, it looks for the following input:

EGLNativeWindowType hWnd;
mSurface = eglCreateWindowSurface(mDisplay,lConfig,hWnd,NULL);

As an alternative, I considered to use instead:

NativeWindowType hWnd=android_createDisplaySurface();

But debugger says:

Function 'android_createDisplaySurface' could not be resolved

Is 'android_createDisplaySurface' compatible only for OGLES 1 and not for OGLES 2?

Can someone tell if there is a way to convert mApplication->window? In a way that the data from the android_app get accepted to the window surface?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Are you sure you are using egl.h header from Android NDK? In Android NDK EGLNativeWindowType is defined in eglplatform.h file (it is included from egl.h):

#elif defined(__ANDROID__) || defined(ANDROID)
#include <android/native_window.h>
...
typedef struct ANativeWindow*           EGLNativeWindowType;

As you can see EGLNativeWindowType has correct type - ANativeWindow*

share|improve this answer
    
If I use hWnd it does not complain, but the windowSurface does not work... I guess it expect to have the input instead from mApplication->window, which is initialized by android_app. But if I try to use mApplication->window as parameter for eglCreateWindowSurface, it complains that this parameter should be "unsigned long int". And this are my OGLES includes: <EGL/egl.h> <GLES/gl.h> <GLES/glext.h> <GLES2/gl2.h>. Any thoughts? –  ThreaderSlash Apr 9 '12 at 7:21
    
Something is wrong with your headers or includes. Even the official NDK sample (native-activity) uses window member of android_app structure for eglCreateWindowSurface argument (linke 101 of main.c file). At it works fine there. –  Mārtiņš Možeiko Apr 9 '12 at 17:11
    
@Martins... do you mean that "eglCreateWindowSurface(mDisplay, lConfig, mApplication->window, NULL)" should work with on complaints about the paramenter "mApplication->window"? –  ThreaderSlash Apr 9 '12 at 17:57
    
Yes, it should work fine (compile without any warnings or errors), if you use egl.h header from NDK and mApplication->window has ANativeWindow* type coming from android/native_window.h file. –  Mārtiņš Možeiko Apr 9 '12 at 18:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.