Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to debug and run OGLES on Native C++ in my Android device in order to implement a native 3D game for mobile smart phones. The point is that I got an error and see no reason for that. Here is the line from the code that the debugger complains:

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

And this is the error message:

    Invalid arguments ' Candidates are: 
        void * eglCreateWindowSurface(void *, void *, 
                                      unsigned long int, const int *) '


Here is the declaration:

    android_app* mApplication;

    EGLDisplay mDisplay;
    EGLint lFormat, lNumConfigs, lErrorResult;
    EGLConfig lConfig;
    // Defines display requirements. 16bits mode here.
    const EGLint lAttributes[] = {
    // Retrieves a display connection and initializes it.
    packt_Log_debug("Connecting to the display.");
    mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (mDisplay == EGL_NO_DISPLAY) goto ERROR;
    if (!eglInitialize(mDisplay, NULL, NULL)) goto ERROR;
    // Selects the first OpenGL configuration found.
    packt_Log_debug("Selecting a display config.");
    if(!eglChooseConfig(mDisplay, lAttributes, &lConfig, 1,
        &lNumConfigs) || (lNumConfigs <= 0)) goto ERROR;
    // Reconfigures the Android window with the EGL format.
    packt_Log_debug("Configuring window format.");
    if (!eglGetConfigAttrib(mDisplay, lConfig,
        EGL_NATIVE_VISUAL_ID, &lFormat)) goto ERROR;
    ANativeWindow_setBuffersGeometry(mApplication->window, 0, 0, lFormat);
    // Creates the display surface.
    packt_Log_debug("Initializing the display.");
    mSurface = eglCreateWindowSurface(mDisplay, lConfig, mApplication->window, NULL);


Hope someone here can shed some light on it.

share|improve this question
If your problem lays on arguments, why didn't you paste the declarations? – kaoD Apr 7 '12 at 19:58
@kaoD .. just posted it. – ThreaderSlash Apr 7 '12 at 20:44
You're missing mDisplay declaration, but I guess it's not a pointer, like lFormat, right? – kaoD Apr 7 '12 at 20:50
@kaoD .. just posted it. – ThreaderSlash Apr 7 '12 at 21:07
Yep, it's not a pointer. Just check my answer. – kaoD Apr 7 '12 at 21:08
up vote 0 down vote accepted

Your lFormat (and possibly mDisplay too) is not a pointer. You need to pass it as a pointer, using the reference operator (&) You might need to cast it too to match the void* on the function signature.

share|improve this answer
I tried your suggestion :: mSurface = eglCreateWindowSurface(&mDisplay, &lConfig, mApplication->window, NULL); /// but the problem did go away yet. – ThreaderSlash Apr 7 '12 at 21:09
@ThreaderSlash you didn't post mApplication->window declaration yet. You might have to cast NULL too (I'm not aware if C++ or any of your includes have NULL as a const int *) – kaoD Apr 7 '12 at 21:20
@kaoD... sorry for that. Now it is posted. – ThreaderSlash Apr 7 '12 at 21:28
@ThreaderSlash I don't need mApplication, I need window... – kaoD Apr 7 '12 at 21:29
this is the window: struct android_app {ANativeWindow* window;}; android_app* mApplication; – ThreaderSlash Apr 7 '12 at 21:37

Your Answer


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.