00001 // Filename: glxGraphicsPipe.h 00002 // Created by: mike (09Jan97) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef GLXGRAPHICSPIPE_H 00020 #define GLXGRAPHICSPIPE_H 00021 00022 #include "pandabase.h" 00023 #include "graphicsPipe.h" 00024 00025 class glxGraphicsWindow; 00026 class FrameBufferProperties; 00027 00028 #ifdef CPPPARSER 00029 // A simple hack so interrogate can parse this file. 00030 typedef int Display; 00031 typedef int Window; 00032 typedef int XErrorEvent; 00033 typedef int XVisualInfo; 00034 typedef int Atom; 00035 #else 00036 #include <X11/Xlib.h> 00037 #include <GL/glx.h> 00038 #endif // CPPPARSER 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Class : glxGraphicsPipe 00042 // Description : This graphics pipe represents the interface for 00043 // creating OpenGL graphics windows on an X-based 00044 // (e.g. Unix) client. 00045 //////////////////////////////////////////////////////////////////// 00046 class glxGraphicsPipe : public GraphicsPipe { 00047 public: 00048 glxGraphicsPipe(const string &display = string()); 00049 virtual ~glxGraphicsPipe(); 00050 00051 virtual string get_interface_name() const; 00052 static PT(GraphicsPipe) pipe_constructor(); 00053 00054 INLINE Display *get_display() const; 00055 INLINE int get_screen() const; 00056 INLINE Window get_root() const; 00057 00058 INLINE Atom get_wm_delete_window() const; 00059 00060 protected: 00061 virtual PT(GraphicsStateGuardian) make_gsg(const FrameBufferProperties &properties); 00062 virtual PT(GraphicsWindow) make_window(GraphicsStateGuardian *gsg); 00063 00064 private: 00065 XVisualInfo *choose_visual(FrameBufferProperties &properties) const; 00066 XVisualInfo *try_for_visual(int framebuffer_mode, 00067 int want_depth_bits, int want_color_bits) const; 00068 00069 static void install_error_handlers(); 00070 static int error_handler(Display *display, XErrorEvent *error); 00071 static int io_error_handler(Display *display); 00072 00073 Display *_display; 00074 int _screen; 00075 Window _root; 00076 00077 Atom _wm_protocols; 00078 Atom _wm_delete_window; 00079 00080 typedef int ErrorHandlerFunc(Display *, XErrorEvent *); 00081 typedef int IOErrorHandlerFunc(Display *); 00082 static bool _error_handlers_installed; 00083 static ErrorHandlerFunc *_prev_error_handler; 00084 static IOErrorHandlerFunc *_prev_io_error_handler; 00085 00086 public: 00087 static TypeHandle get_class_type() { 00088 return _type_handle; 00089 } 00090 static void init_type() { 00091 GraphicsPipe::init_type(); 00092 register_type(_type_handle, "glxGraphicsPipe", 00093 GraphicsPipe::get_class_type()); 00094 } 00095 virtual TypeHandle get_type() const { 00096 return get_class_type(); 00097 } 00098 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00099 00100 private: 00101 static TypeHandle _type_handle; 00102 }; 00103 00104 #include "glxGraphicsPipe.I" 00105 00106 #endif