Panda3D

eglGraphicsPipe.h

00001 // Filename: eglGraphicsPipe.h
00002 // Created by:  pro-rsoft (21May09)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef EGLGRAPHICSPIPE_H
00016 #define EGLGRAPHICSPIPE_H
00017 
00018 #include "pandabase.h"
00019 #include "graphicsWindow.h"
00020 #include "graphicsPipe.h"
00021 #include "lightMutex.h"
00022 #include "lightReMutex.h"
00023 #include "get_x11.h"
00024 
00025 #ifdef OPENGLES_2
00026   #include "gles2gsg.h"
00027   #include "pre_x11_include.h"
00028   #include <EGL/egl.h>
00029   #include "post_x11_include.h"
00030   #define NativeDisplayType EGLNativeDisplayType
00031   #define NativePixmapType EGLNativePixmapType
00032   #define NativeWindowType EGLNativeWindowType
00033 #else
00034   #include "glesgsg.h"
00035   #include "pre_x11_include.h"
00036   #include <GLES/egl.h>
00037   #include "post_x11_include.h"
00038 #endif
00039 
00040 class FrameBufferProperties;
00041 
00042 class eglGraphicsBuffer;
00043 class eglGraphicsPixmap;
00044 class eglGraphicsWindow;
00045 
00046 ////////////////////////////////////////////////////////////////////
00047 //       Class : eglGraphicsPipe
00048 // Description : This graphics pipe represents the interface for
00049 //               creating OpenGL ES graphics windows on an X-based
00050 //               (e.g. Unix) client.
00051 ////////////////////////////////////////////////////////////////////
00052 class eglGraphicsPipe : public GraphicsPipe {
00053 public:
00054   eglGraphicsPipe(const string &display = string());
00055   virtual ~eglGraphicsPipe();
00056 
00057   virtual string get_interface_name() const;
00058   static PT(GraphicsPipe) pipe_constructor();
00059 
00060   INLINE X11_Display *get_display() const;
00061   INLINE int get_screen() const;
00062   INLINE X11_Window get_root() const;
00063   INLINE XIM get_im() const;
00064 
00065   INLINE X11_Cursor get_hidden_cursor();
00066 
00067 public:
00068   virtual PreferredWindowThread get_preferred_window_thread() const;
00069 
00070 public:
00071   // Atom specifications.
00072   Atom _wm_delete_window;
00073   Atom _net_wm_window_type;
00074   Atom _net_wm_window_type_splash;
00075   Atom _net_wm_window_type_fullscreen;
00076   Atom _net_wm_state;
00077   Atom _net_wm_state_fullscreen;
00078   Atom _net_wm_state_above;
00079   Atom _net_wm_state_below;
00080   Atom _net_wm_state_add;
00081   Atom _net_wm_state_remove;
00082 
00083 protected:
00084   virtual PT(GraphicsOutput) make_output(const string &name,
00085                                          const FrameBufferProperties &fb_prop,
00086                                          const WindowProperties &win_prop,
00087                                          int flags,
00088                                          GraphicsEngine *engine,
00089                                          GraphicsStateGuardian *gsg,
00090                                          GraphicsOutput *host,
00091                                          int retry,
00092                                          bool &precertify);
00093 
00094 private:
00095   void make_hidden_cursor();
00096   void release_hidden_cursor();
00097 
00098   static void install_error_handlers();
00099   static int error_handler(X11_Display *display, XErrorEvent *error);
00100   static int io_error_handler(X11_Display *display);
00101 
00102   X11_Display *_display;
00103   int _screen;
00104   X11_Window _root;
00105   XIM _im;
00106   EGLDisplay _egl_display;
00107 
00108   X11_Cursor _hidden_cursor;
00109 
00110   typedef int ErrorHandlerFunc(X11_Display *, XErrorEvent *);
00111   typedef int IOErrorHandlerFunc(X11_Display *);
00112   static bool _error_handlers_installed;
00113   static ErrorHandlerFunc *_prev_error_handler;
00114   static IOErrorHandlerFunc *_prev_io_error_handler;
00115 
00116 public:
00117   // This Mutex protects any X library calls, which all have to be
00118   // single-threaded.  In particular, it protects eglMakeCurrent().
00119   static LightReMutex _x_mutex;
00120 
00121 public:
00122   static TypeHandle get_class_type() {
00123     return _type_handle;
00124   }
00125   static void init_type() {
00126     GraphicsPipe::init_type();
00127     register_type(_type_handle, "eglGraphicsPipe",
00128                   GraphicsPipe::get_class_type());
00129   }
00130   virtual TypeHandle get_type() const {
00131     return get_class_type();
00132   }
00133   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00134 
00135 private:
00136   static TypeHandle _type_handle;
00137 
00138   friend class eglGraphicsBuffer;
00139   friend class eglGraphicsPixmap;
00140   friend class eglGraphicsWindow;
00141 };
00142 
00143 #include "eglGraphicsPipe.I"
00144 
00145 #endif
 All Classes Functions Variables Enumerations