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.

  • \$\begingroup\$ If your problem lays on arguments, why didn't you paste the declarations? \$\endgroup\$ – kaoD Apr 7 '12 at 19:58
  • \$\begingroup\$ @kaoD .. just posted it. \$\endgroup\$ – ThreaderSlash Apr 7 '12 at 20:44
  • \$\begingroup\$ You're missing mDisplay declaration, but I guess it's not a pointer, like lFormat, right? \$\endgroup\$ – kaoD Apr 7 '12 at 20:50
  • \$\begingroup\$ @kaoD .. just posted it. \$\endgroup\$ – ThreaderSlash Apr 7 '12 at 21:07
  • \$\begingroup\$ Yep, it's not a pointer. Just check my answer. \$\endgroup\$ – kaoD Apr 7 '12 at 21:08

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.

| improve this answer | |
  • \$\begingroup\$ I tried your suggestion :: mSurface = eglCreateWindowSurface(&mDisplay, &lConfig, mApplication->window, NULL); /// but the problem did go away yet. \$\endgroup\$ – ThreaderSlash Apr 7 '12 at 21:09
  • \$\begingroup\$ @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 *) \$\endgroup\$ – kaoD Apr 7 '12 at 21:20
  • \$\begingroup\$ @kaoD... sorry for that. Now it is posted. \$\endgroup\$ – ThreaderSlash Apr 7 '12 at 21:28
  • \$\begingroup\$ @ThreaderSlash I don't need mApplication, I need window... \$\endgroup\$ – kaoD Apr 7 '12 at 21:29
  • \$\begingroup\$ this is the window: struct android_app {ANativeWindow* window;}; android_app* mApplication; \$\endgroup\$ – ThreaderSlash Apr 7 '12 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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