OGLES 2原生Android:eglCreateWindowSurface参数

OGLES 2 Native Android: eglCreateWindowSurface Arguments

本文关键字:eglCreateWindowSurface 参数 Android 原生 OGLES      更新时间:2023-10-16

我有一个有趣的事件,一个应用程序正在Android的原生NDK C++上使用OpenGL ES进行开发。该程序编译和运行都没有问题。然而,如果我决定进行单元测试并调试代码,它会发出以下消息:

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

这与以下代码快照的最后一行有关:

    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);

我已经看了OGLES的参考资料,但我尝试的所有不同的东西都还没有成功。

将"mApplication->window"替换为"EGLNativeWindowType window"解决了问题。

相关文章:
  • 没有找到相关文章