diff --git a/dtool/Config.pp b/dtool/Config.pp index 5d2f2343f6..605b092c09 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -637,7 +637,7 @@ #define X11_IPATH #define X11_LPATH /usr/X11R6/lib #define X11_LIBS X11 -#defer HAVE_X11 $[libtest $[X11_LPATH],$[X11_LIBS]] +#defer HAVE_X11 $[and $[IS_LINUX],$[libtest $[X11_LPATH],$[X11_LIBS]]] // How about GLX? #define GLX_IPATH diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index 860ea44dd8..06e5be5d7a 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -126,6 +126,11 @@ //#else //#print - Did not find SDL //#endif +#if $[HAVE_X11] +#print + X11 +#else +#print - Did not find X11 +#endif #if $[HAVE_MESA] #print + Mesa #else @@ -310,6 +315,9 @@ $[cdefine HAVE_TINYDISPLAY] /* Define if we have the SDL library. */ $[cdefine HAVE_SDL] +/* Define if we have X11. */ +$[cdefine HAVE_X11] + /* Define if we want to compile the threading code. */ $[cdefine HAVE_THREADS] diff --git a/panda/src/tinydisplay/Sources.pp b/panda/src/tinydisplay/Sources.pp index caef08ae7a..548e51f9cc 100644 --- a/panda/src/tinydisplay/Sources.pp +++ b/panda/src/tinydisplay/Sources.pp @@ -30,6 +30,7 @@ tinyWinGraphicsWindow.h tinyWinGraphicsWindow.I \ tinyXGraphicsPipe.I tinyXGraphicsPipe.h \ tinyXGraphicsWindow.h tinyXGraphicsWindow.I \ + tinyOffscreenGraphicsPipe.I tinyOffscreenGraphicsPipe.h \ tinyOsxGraphicsPipe.I tinyOsxGraphicsPipe.h \ tinyOsxGraphicsWindow.h tinyOsxGraphicsWindow.I \ $[if $[IS_OSX],tinyOsxGraphicsWindow.mm,] \ @@ -55,6 +56,7 @@ tinyGeomMunger.cxx \ tinyGraphicsBuffer.cxx \ tinyGraphicsStateGuardian.cxx \ + tinyOffscreenGraphicsPipe.cxx \ tinyOsxGraphicsPipe.cxx \ tinySDLGraphicsPipe.cxx \ tinySDLGraphicsWindow.cxx \ diff --git a/panda/src/tinydisplay/config_tinydisplay.cxx b/panda/src/tinydisplay/config_tinydisplay.cxx index 221cf821c3..887a735e10 100644 --- a/panda/src/tinydisplay/config_tinydisplay.cxx +++ b/panda/src/tinydisplay/config_tinydisplay.cxx @@ -21,6 +21,7 @@ #include "tinyOsxGraphicsWindow.h" #include "tinySDLGraphicsPipe.h" #include "tinySDLGraphicsWindow.h" +#include "tinyOffscreenGraphicsPipe.h" #include "tinyGraphicsBuffer.h" #include "tinyGraphicsStateGuardian.h" #include "tinyGeomMunger.h" @@ -122,12 +123,12 @@ init_libtinydisplay() { GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr(); -#ifdef IS_LINUX +#ifdef HAVE_X11 TinyXGraphicsPipe::init_type(); TinyXGraphicsWindow::init_type(); selection->add_pipe_type(TinyXGraphicsPipe::get_class_type(), TinyXGraphicsPipe::pipe_constructor); - ps->set_system_tag("TinyPanda", "native_window_system", "X"); + ps->set_system_tag("TinyPanda", "native_window_system", "X11"); #endif #ifdef WIN32 @@ -153,6 +154,11 @@ init_libtinydisplay() { TinySDLGraphicsPipe::pipe_constructor); ps->set_system_tag("TinyPanda", "SDL", "SDL"); #endif + + TinyOffscreenGraphicsPipe::init_type(); + selection->add_pipe_type(TinyOffscreenGraphicsPipe::get_class_type(), + TinyOffscreenGraphicsPipe::pipe_constructor); + ps->set_system_tag("TinyPanda", "", ""); } //////////////////////////////////////////////////////////////////// @@ -163,10 +169,6 @@ init_libtinydisplay() { int get_pipe_type_tinydisplay() { -#ifdef IS_LINUX - return TinyXGraphicsPipe::get_class_type().get_index(); -#endif - #ifdef WIN32 return TinyWinGraphicsPipe::get_class_type().get_index(); #endif @@ -175,9 +177,13 @@ get_pipe_type_tinydisplay() { return TinyOsxGraphicsPipe::get_class_type().get_index(); #endif +#ifdef HAVE_X11 + return TinyXGraphicsPipe::get_class_type().get_index(); +#endif + #ifdef HAVE_SDL return TinySDLGraphicsPipe::get_class_type().get_index(); #endif - return 0; + return TinyOffscreenGraphicsPipe::get_class_type().get_index(); } diff --git a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.I b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.I new file mode 100644 index 0000000000..d700413a14 --- /dev/null +++ b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.I @@ -0,0 +1,14 @@ +// Filename: tinyOffscreenGraphicsPipe.I +// Created by: drose (09Feb09) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + diff --git a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx new file mode 100644 index 0000000000..2c491e0717 --- /dev/null +++ b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.cxx @@ -0,0 +1,98 @@ +// Filename: tinyOffscreenGraphicsPipe.cxx +// Created by: drose (09Feb09) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#include "pandabase.h" + +#include "tinyOffscreenGraphicsPipe.h" +#include "tinyGraphicsStateGuardian.h" +#include "tinyGraphicsBuffer.h" +#include "config_tinydisplay.h" +#include "frameBufferProperties.h" + +TypeHandle TinyOffscreenGraphicsPipe::_type_handle; + +//////////////////////////////////////////////////////////////////// +// Function: TinyOffscreenGraphicsPipe::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +TinyOffscreenGraphicsPipe:: +TinyOffscreenGraphicsPipe() { + _supported_types = OT_buffer | OT_texture_buffer; + _is_valid = true; +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyOffscreenGraphicsPipe::Destructor +// Access: Public, Virtual +// Description: +//////////////////////////////////////////////////////////////////// +TinyOffscreenGraphicsPipe:: +~TinyOffscreenGraphicsPipe() { +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyOffscreenGraphicsPipe::get_interface_name +// Access: Published, Virtual +// Description: Returns the name of the rendering interface +// associated with this GraphicsPipe. This is used to +// present to the user to allow him/her to choose +// between several possible GraphicsPipes available on a +// particular platform, so the name should be meaningful +// and unique for a given platform. +//////////////////////////////////////////////////////////////////// +string TinyOffscreenGraphicsPipe:: +get_interface_name() const { + return "TinyPanda"; +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyOffscreenGraphicsPipe::pipe_constructor +// Access: Public, Static +// Description: This function is passed to the GraphicsPipeSelection +// object to allow the user to make a default +// TinyOffscreenGraphicsPipe. +//////////////////////////////////////////////////////////////////// +PT(GraphicsPipe) TinyOffscreenGraphicsPipe:: +pipe_constructor() { + return new TinyOffscreenGraphicsPipe; +} + +//////////////////////////////////////////////////////////////////// +// Function: TinyOffscreenGraphicsPipe::make_output +// Access: Protected, Virtual +// Description: Creates a new window on the pipe, if possible. +//////////////////////////////////////////////////////////////////// +PT(GraphicsOutput) TinyOffscreenGraphicsPipe:: +make_output(const string &name, + const FrameBufferProperties &fb_prop, + const WindowProperties &win_prop, + int flags, + GraphicsStateGuardian *gsg, + GraphicsOutput *host, + int retry, + bool &precertify) { + // Only thing to try: a TinyGraphicsBuffer + + if (retry == 0) { + if (((flags&BF_require_parasite)!=0)|| + ((flags&BF_require_window)!=0)) { + return NULL; + } + return new TinyGraphicsBuffer(this, name, fb_prop, win_prop, flags, gsg, host); + } + + // Nothing else left to try. + return NULL; +} diff --git a/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.h b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.h new file mode 100644 index 0000000000..c3f8057294 --- /dev/null +++ b/panda/src/tinydisplay/tinyOffscreenGraphicsPipe.h @@ -0,0 +1,68 @@ +// Filename: tinyOffscreenGraphicsPipe.h +// Created by: drose (09Feb09) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) Carnegie Mellon University. All rights reserved. +// +// All use of this software is subject to the terms of the revised BSD +// license. You should have received a copy of this license along +// with this source code in a file named "LICENSE." +// +//////////////////////////////////////////////////////////////////// + +#ifndef TINYOFFSCREENGRAPHICSPIPE_H +#define TINYOFFSCREENGRAPHICSPIPE_H + +#include "pandabase.h" + +#include "graphicsWindow.h" +#include "graphicsPipe.h" +#include "tinyGraphicsStateGuardian.h" + +class FrameBufferProperties; + +//////////////////////////////////////////////////////////////////// +// Class : TinyOffscreenGraphicsPipe +// Description : This graphics pipe creates offscreen buffers only, +// but is completely platform-independent. +//////////////////////////////////////////////////////////////////// +class EXPCL_TINYDISPLAY TinyOffscreenGraphicsPipe : public GraphicsPipe { +public: + TinyOffscreenGraphicsPipe(); + virtual ~TinyOffscreenGraphicsPipe(); + + virtual string get_interface_name() const; + static PT(GraphicsPipe) pipe_constructor(); + +protected: + virtual PT(GraphicsOutput) make_output(const string &name, + const FrameBufferProperties &fb_prop, + const WindowProperties &win_prop, + int flags, + GraphicsStateGuardian *gsg, + GraphicsOutput *host, + int retry, + bool &precertify); +public: + static TypeHandle get_class_type() { + return _type_handle; + } + static void init_type() { + GraphicsPipe::init_type(); + register_type(_type_handle, "TinyOffscreenGraphicsPipe", + GraphicsPipe::get_class_type()); + } + virtual TypeHandle get_type() const { + return get_class_type(); + } + virtual TypeHandle force_init_type() {init_type(); return get_class_type();} + +private: + static TypeHandle _type_handle; +}; + +#include "tinyOffscreenGraphicsPipe.I" + +#endif diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx index b425e320dc..05bbb2b8a0 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.cxx @@ -13,7 +13,7 @@ //////////////////////////////////////////////////////////////////// #include "pandabase.h" -#ifdef IS_LINUX +#ifdef HAVE_X11 #include "tinyXGraphicsPipe.h" #include "tinyXGraphicsWindow.h" @@ -341,4 +341,4 @@ io_error_handler(Display *display) { return 0; } -#endif // IS_LINUX +#endif // HAVE_X11 diff --git a/panda/src/tinydisplay/tinyXGraphicsPipe.h b/panda/src/tinydisplay/tinyXGraphicsPipe.h index a7db0bd6af..aeca76e61d 100644 --- a/panda/src/tinydisplay/tinyXGraphicsPipe.h +++ b/panda/src/tinydisplay/tinyXGraphicsPipe.h @@ -17,7 +17,7 @@ #include "pandabase.h" -#ifdef IS_LINUX +#ifdef HAVE_X11 #include "graphicsWindow.h" #include "graphicsPipe.h" @@ -136,6 +136,6 @@ private: #include "tinyXGraphicsPipe.I" -#endif // IS_LINUX +#endif // HAVE_X11 #endif diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx index ebfc29e3a7..a5e4e232e0 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.cxx +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.cxx @@ -14,7 +14,7 @@ #include "pandabase.h" -#ifdef IS_LINUX +#ifdef HAVE_X11 #include "tinyXGraphicsWindow.h" #include "tinyGraphicsStateGuardian.h" @@ -1643,5 +1643,5 @@ create_ximage() { 32, 0); } -#endif // IS_LINUX +#endif // HAVE_X11 diff --git a/panda/src/tinydisplay/tinyXGraphicsWindow.h b/panda/src/tinydisplay/tinyXGraphicsWindow.h index 42de1b1d3e..33ac5c16a4 100644 --- a/panda/src/tinydisplay/tinyXGraphicsWindow.h +++ b/panda/src/tinydisplay/tinyXGraphicsWindow.h @@ -17,7 +17,7 @@ #include "pandabase.h" -#ifdef IS_LINUX +#ifdef HAVE_X11 #include "tinyXGraphicsPipe.h" #include "graphicsWindow.h" @@ -127,7 +127,7 @@ private: #include "tinyXGraphicsWindow.I" -#endif // IS_LINUX +#endif // HAVE_X11 #endif diff --git a/panda/src/tinydisplay/tinydisplay_composite2.cxx b/panda/src/tinydisplay/tinydisplay_composite2.cxx index 77a828653b..1d71c075aa 100755 --- a/panda/src/tinydisplay/tinydisplay_composite2.cxx +++ b/panda/src/tinydisplay/tinydisplay_composite2.cxx @@ -4,6 +4,7 @@ #include "tinyOsxGraphicsPipe.h" #include "tinyGraphicsStateGuardian.cxx" +#include "tinyOffscreenGraphicsPipe.cxx" #include "tinyOsxGraphicsPipe.cxx" #include "tinySDLGraphicsPipe.cxx" #include "tinySDLGraphicsWindow.cxx"