diff --git a/panda/src/osxdisplay/osxGraphicsBuffer.cxx b/panda/src/osxdisplay/osxGraphicsBuffer.cxx index 0dcf6ff73d..2f34f613ca 100644 --- a/panda/src/osxdisplay/osxGraphicsBuffer.cxx +++ b/panda/src/osxdisplay/osxGraphicsBuffer.cxx @@ -30,10 +30,12 @@ TypeHandle osxGraphicsBuffer::_type_handle; // Description: //////////////////////////////////////////////////////////////////// osxGraphicsBuffer:: -osxGraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg, +osxGraphicsBuffer(GraphicsPipe *pipe, const string &name, - int x_size, int y_size) : - GraphicsBuffer(pipe, gsg, name, x_size, y_size) + int x_size, int y_size, int flags, + GraphicsStateGuardian *gsg, + GraphicsOutput *host) : + GraphicsBuffer(pipe, name, x_size, y_size, flags, gsg, host) { osxGraphicsPipe *osx_pipe; DCAST_INTO_V(osx_pipe, _pipe); diff --git a/panda/src/osxdisplay/osxGraphicsBuffer.h b/panda/src/osxdisplay/osxGraphicsBuffer.h index 16947dadc9..e5e144f687 100644 --- a/panda/src/osxdisplay/osxGraphicsBuffer.h +++ b/panda/src/osxdisplay/osxGraphicsBuffer.h @@ -34,9 +34,11 @@ //////////////////////////////////////////////////////////////////// class EXPCL_PANDAGL osxGraphicsBuffer : public GraphicsBuffer { public: - osxGraphicsBuffer(GraphicsPipe *pipe, GraphicsStateGuardian *gsg, + osxGraphicsBuffer(GraphicsPipe *pipe, const string &name, - int x_size, int y_size); + int x_size, int y_size, int flags, + GraphicsStateGuardian *gsg, + GraphicsOutput *host); virtual ~osxGraphicsBuffer(); diff --git a/panda/src/osxdisplay/osxGraphicsPipe.cxx b/panda/src/osxdisplay/osxGraphicsPipe.cxx index 115a54204b..5734508f75 100644 --- a/panda/src/osxdisplay/osxGraphicsPipe.cxx +++ b/panda/src/osxdisplay/osxGraphicsPipe.cxx @@ -109,24 +109,74 @@ make_gsg(const FrameBufferProperties &properties, } //////////////////////////////////////////////////////////////////// -// Function: osxGraphicsPipe::make_window +// Function: osxGraphicsPipe::make_output // Access: Protected, Virtual // Description: Creates a new window on the pipe, if possible. //////////////////////////////////////////////////////////////////// -PT(GraphicsWindow) osxGraphicsPipe:: -make_window(GraphicsStateGuardian *gsg, const string &name) { - return new osxGraphicsWindow(this, gsg, name); +PT(GraphicsOutput) osxGraphicsPipe:: +make_output(const string &name, + int x_size, int y_size, int flags, + GraphicsStateGuardian *gsg, + GraphicsOutput *host, + int retry, + bool precertify) { + + if (!_is_valid) { + return NULL; + } + + osxGraphicsStateGuardian *osxgsg; + DCAST_INTO_R(osxgsg, gsg, NULL); + + // First thing to try: a osxGraphicsWindow + + if (retry == 0) { + if (((flags&BF_require_parasite)!=0)|| + ((flags&BF_refuse_window)!=0)|| + ((flags&BF_need_aux_rgba_MASK)!=0)|| + ((flags&BF_need_aux_hrgba_MASK)!=0)|| + ((flags&BF_need_aux_float_MASK)!=0)|| + ((flags&BF_size_track_host)!=0)|| + ((flags&BF_can_bind_color)!=0)|| + ((flags&BF_can_bind_every)!=0)) { + return NULL; + } + return new osxGraphicsWindow(this, name, x_size, y_size, flags, gsg, host); + } + + // // Second thing to try: a glGraphicsBuffer + // + // if (retry == 1) { + // if ((!support_render_texture)|| + // ((flags&BF_require_parasite)!=0)|| + // ((flags&BF_require_window)!=0)) { + // return NULL; + // } + // if (precertify) { + // if (!osxgsg->_supports_framebuffer_object) { + // return NULL; + // } + // } + // return new glGraphicsBuffer(this, name, x_size, y_size, flags, gsg, host); + // } + + // Third thing to try: an osxGraphicsBuffer + + if (retry == 2) { + if ((!support_render_texture)|| + ((flags&BF_require_parasite)!=0)|| + ((flags&BF_require_window)!=0)|| + ((flags&BF_need_aux_rgba_MASK)!=0)|| + ((flags&BF_need_aux_hrgba_MASK)!=0)|| + ((flags&BF_need_aux_float_MASK)!=0)|| + ((flags&BF_size_track_host)!=0)|| + ((flags&BF_can_bind_every)!=0)) { + return NULL; + } + return new osxGraphicsBuffer(this, name, x_size, y_size, flags, gsg, host); + } + + // Nothing else left to try. + return NULL; } -//////////////////////////////////////////////////////////////////// -// Function: osxGraphicsPipe::make_buffer -// Access: Protected, Virtual -// Description: Creates a new offscreen buffer on the pipe, if possible. -//////////////////////////////////////////////////////////////////// -PT(GraphicsBuffer) osxGraphicsPipe:: -make_buffer(GraphicsStateGuardian *gsg, const string &name, - int x_size, int y_size) { - return new osxGraphicsBuffer(this, gsg, name, x_size, y_size); -} - - diff --git a/panda/src/osxdisplay/osxGraphicsPipe.h b/panda/src/osxdisplay/osxGraphicsPipe.h index f86aaeeaf6..967632dc38 100644 --- a/panda/src/osxdisplay/osxGraphicsPipe.h +++ b/panda/src/osxdisplay/osxGraphicsPipe.h @@ -38,11 +38,13 @@ public: protected: virtual PT(GraphicsStateGuardian) make_gsg(const FrameBufferProperties &properties, GraphicsStateGuardian *share_with); - virtual PT(GraphicsWindow) make_window(GraphicsStateGuardian *gsg, - const string &name); - virtual PT(GraphicsBuffer) make_buffer(GraphicsStateGuardian *gsg, - const string &name, - int x_size, int y_size); + virtual PT(GraphicsOutput) make_output(const string &name, + int x_size, int y_size, int flags, + GraphicsStateGuardian *gsg, + GraphicsOutput *host, + int retry, + bool precertify); + private: public: static TypeHandle get_class_type() { diff --git a/panda/src/osxdisplay/osxGraphicsWindow.cxx b/panda/src/osxdisplay/osxGraphicsWindow.cxx index a84f520e5d..6a51c1f567 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.cxx +++ b/panda/src/osxdisplay/osxGraphicsWindow.cxx @@ -391,9 +391,13 @@ OSStatus osxGraphicsWindow::handleTextInput (EventHandlerCallRef myHandler, Even // Access: Public // Description: //////////////////////////////////////////////////////////////////// -osxGraphicsWindow::osxGraphicsWindow(GraphicsPipe *pipe, GraphicsStateGuardian *gsg, - const string &name) : - GraphicsWindow(pipe, gsg, name) , +osxGraphicsWindow:: +osxGraphicsWindow(GraphicsPipe *pipe, + const string &name, + int x_size, int y_size, int flags, + GraphicsStateGuardian *gsg, + GraphicsOutput *host) : + GraphicsWindow(pipe, name, x_size, y_size, flags, gsg, host), _osx_window(NULL), _is_fullsreen(false), #ifdef HACK_SCREEN_HASH_CONTEXT diff --git a/panda/src/osxdisplay/osxGraphicsWindow.h b/panda/src/osxdisplay/osxGraphicsWindow.h index cbd6383fbe..e098e429f6 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.h +++ b/panda/src/osxdisplay/osxGraphicsWindow.h @@ -39,8 +39,11 @@ OSStatus aglReportError (void); //////////////////////////////////////////////////////////////////// class osxGraphicsWindow : public GraphicsWindow { public: - osxGraphicsWindow(GraphicsPipe *pipe, GraphicsStateGuardian *gsg, - const string &name); + osxGraphicsWindow(GraphicsPipe *pipe, + const string &name, + int x_size, int y_size, int flags, + GraphicsStateGuardian *gsg, + GraphicsOutput *host); virtual ~osxGraphicsWindow(); virtual bool move_pointer(int device, int x, int y);