Can I Dynamically Resize a Pbuffer Surface?

98 views
Skip to first unread message

Lingyi Kong

unread,
Nov 28, 2023, 6:28:57 AM11/28/23
to angleproject
I tried using the eglQuerySurfacePointerANGLE() function to share an OpenGL ES 3.0 texture handle with Direct3D (D3D). However, I noticed that the texture handle returned by this function has the same dimensions as the Pbuffer surface. Therefore, when I resize my D3D rendering window, I also want to dynamically resize my Pbuffer surface. 
However, I haven't found a function like eglResizeSurface(), and after searching on Google, it seems that I can only delete the original Pbuffer surface and create a new one. Will this approach have any performance implications? 
here is a simple code show how i initialize the opengl surface and context:

display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display, NULL, NULL);

const EGLint configAttributes[] = {EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT,
EGL_SURFACE_TYPE,                                                                                                                        EGL_PBUFFER_BIT,
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
   EGL_DEPTH_SIZE, 16,
   EGL_BIND_TO_TEXTURE_RGBA, EGL_TRUE,
   EGL_NONE};
EGLConfig config;
EGLint numConfigs;
eglChooseConfig(display, configAttributes, &config, 1, &numConfigs);

winwidth  = 800;
winheight  = 600;
const EGLint pbufferAttributes[] = {EGL_WIDTH, winwidth,
EGL_HEIGHT, winheight,
EGL_NONE};

pbufferSurface = eglCreatePbufferSurface(display, config, pbufferAttributes);
if (pbufferSurface == EGL_NO_SURFACE) {
std::cerr << "bad surface" << eglGetError() << std::endl;
}


const EGLint contextAttributes[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE};
EGLContext context  = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttributes);
eglMakeCurrent(display, pbufferSurface, pbufferSurface, context);

Any help would be greatly appreciated.
Reply all
Reply to author
Forward
0 new messages