How can i use eglCopyBuffers?

i


EGLint config_list[] = {
        EGL_RED_SIZE,       8,
        EGL_GREEN_SIZE,     8,
        EGL_BLUE_SIZE,      8,
        EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
        EGL_NONE
    };



EGLint num_config;

    
    g_dpy = GetDC(gHWND);

    display = eglGetDisplay(g_dpy);if (eglInitialize(display, NULL, NULL) == EGL_FALSE || eglGetError() != EGL_SUCCESS)
    {
        OutputError();
        printf("eglInitialize Error!
");return;
    }

    eglChooseConfig(display, config_list, &config, 1, &num_config);

    eglBindAPI(EGL_OPENGL_ES_API);

    surface = eglCreateWindowSurface( display, config, (NativeWindowType)(gHWND) , NULL);if ( surface == EGL_NO_SURFACE )
    {
      OutputError();
        printf("eglCreateWindowSurface Error!
");return ;
    }
.....

    bitmap = CreateCompatibleBitmap((HDC)g_dpy, width, height);

    glClearColor( 1.0f, 0.0f, 0.0f, 1.0f );        // RedglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    glFlush();
    eglCopyBuffers( display, surface , bitmap );  // Error  Unhandled exception at 0x770115de in objloader.exe: 0xC0000005: Access violation writing location 0x00000003.

Can I get some example code about eglCopyBuffers()??
help me.

Have you considered using glReadPixels? Note, reading back a render target is always really expensive from a performance point of view. Alternatively, you could do something that performs a little better with EGL images or EGL fences that don’t stall the GPU.