0
\$\begingroup\$

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 *) '

--x--

Here is the declaration:

    android_app* mApplication;

    EGLDisplay mDisplay;
    EGLint lFormat, lNumConfigs, lErrorResult;
    EGLConfig lConfig;
    // Defines display requirements. 16bits mode here.
    const EGLint lAttributes[] = {
        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
        EGL_BLUE_SIZE, 5, EGL_GREEN_SIZE, 6, EGL_RED_SIZE, 5,
        EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_RENDER_BUFFER, EGL_BACK_BUFFER,
        EGL_NONE
    };
    // 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);

--x--

Hope someone here can shed some light on it.

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

1 Answer 1

0
\$\begingroup\$

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.

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.