Browse Source

egldisplay: make pbuffers resizeable

rdb 2 years ago
parent
commit
f5d5340ad3

+ 24 - 0
panda/src/egldisplay/eglGraphicsBuffer.cxx

@@ -120,6 +120,30 @@ end_frame(FrameMode mode, Thread *current_thread) {
   }
 }
 
+/**
+ *
+ */
+void eglGraphicsBuffer::
+set_size(int x, int y) {
+  nassertv_always(_gsg != nullptr);
+
+  if (_size.get_x() != x || _size.get_y() != y) {
+    eglDestroySurface(_egl_display, _pbuffer);
+
+    int attrib_list[] = {
+      EGL_WIDTH, x,
+      EGL_HEIGHT, y,
+      EGL_NONE
+    };
+
+    eglGraphicsStateGuardian *eglgsg;
+    DCAST_INTO_V(eglgsg, _gsg);
+    _pbuffer = eglCreatePbufferSurface(eglgsg->_egl_display, eglgsg->_fbconfig, attrib_list);
+  }
+
+  set_size_and_recalc(x, y);
+}
+
 /**
  * Closes the buffer right now.  Called from the window thread.
  */

+ 2 - 0
panda/src/egldisplay/eglGraphicsBuffer.h

@@ -36,6 +36,8 @@ public:
   virtual bool begin_frame(FrameMode mode, Thread *current_thread);
   virtual void end_frame(FrameMode mode, Thread *current_thread);
 
+  virtual void set_size(int x, int y);
+
 protected:
   virtual void close_buffer();
   virtual bool open_buffer();

+ 0 - 1
panda/src/egldisplay/eglGraphicsPipe.cxx

@@ -323,7 +323,6 @@ make_output(const std::string &name,
   if (retry == 2) {
     if (((flags&BF_require_parasite)!=0)||
         ((flags&BF_require_window)!=0)||
-        ((flags&BF_resizeable)!=0)||
         ((flags&BF_size_track_host)!=0)) {
       return nullptr;
     }