Results 1 to 2 of 2

Thread: how can i copy HBITMAP to EGLSurface or copy HDC to EGLDisplay?

  1. #1
    Newbie
    Join Date
    Mar 2014
    Posts
    2

    Unhappy how can i copy HBITMAP to EGLSurface or copy HDC to EGLDisplay?

    Environment : WinCE
    i'd like to copy the windows HDC to EGL.
    Code :
    GLint config_list[] = {
            EGL_RED_SIZE,       5,
            EGL_GREEN_SIZE,     6,
            EGL_BLUE_SIZE,      5,
            EGL_NONE
        };
     
        EGLint num_config;
     
     
        g_dpy = GetDC(gHWND);
     
        display = eglGetDisplay(g_dpy);
     
        if (eglInitialize(display, NULL, NULL) == EGL_FALSE || eglGetError() != EGL_SUCCESS)
        {
            printf("eglInitialize Error!\r\n");
            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 || eglGetError() != EGL_SUCCESS )
        {
            printf("eglCreateWindowSurface Error!\r\n");
            return ;
        }
     
        context = eglCreateContext( display, config, NULL,  NULL );
        if ( context == EGL_NO_CONTEXT || eglGetError() != EGL_SUCCESS )
        {
            printf("eglCreateContext Error!\r\n");
            return ;
        }
     
        if ( eglMakeCurrent( display, surface, surface, context ) == EGL_FALSE || eglGetError() != EGL_SUCCESS )
        {
            printf("eglMakeCurrent Error!\r\n");
            return;
        }

    then

    HDC memdc = CreateCompatibleDC( (HDC)display );
    HBITMAP bitmap = CreateCompatibleBitmap((HDC)display, width, height);
    SelectObject( memdc, bitmap );
    ...draw something
    BitBlt( (HDC)display, 0, 0, width, height, memdc, 0, 0, SRCCOPY );

    it dosen't work. memdc and hbitmap always 0x000000.
    help me. thansk

  2. #2
    Senior Member
    Join Date
    May 2008
    Posts
    104
    If your goal is to retrieve pixel data rendered by GLES and the bitblt is not working out, glReadPixels is likely a safe bet.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •