Panda3D
|
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 00024 #ifdef OPENGLES_2 00025 #include "gles2gsg.h" 00026 #include <EGL/egl.h> 00027 #define NativeDisplayType EGLNativeDisplayType 00028 #define NativePixmapType EGLNativePixmapType 00029 #define NativeWindowType EGLNativeWindowType 00030 #else 00031 #include "glesgsg.h" 00032 #include <GLES/egl.h> 00033 #endif 00034 00035 class FrameBufferProperties; 00036 00037 #ifdef CPPPARSER 00038 // A simple hack so interrogate can parse this file. 00039 typedef int Display; 00040 typedef int Window; 00041 typedef int XErrorEvent; 00042 typedef int XVisualInfo; 00043 typedef int Atom; 00044 typedef int Cursor; 00045 typedef int XIM; 00046 typedef int XIC; 00047 #else 00048 #include <X11/Xlib.h> 00049 00050 #endif // CPPPARSER 00051 00052 class eglGraphicsBuffer; 00053 class eglGraphicsPixmap; 00054 class eglGraphicsWindow; 00055 00056 //////////////////////////////////////////////////////////////////// 00057 // Class : eglGraphicsPipe 00058 // Description : This graphics pipe represents the interface for 00059 // creating OpenGL ES graphics windows on an X-based 00060 // (e.g. Unix) client. 00061 //////////////////////////////////////////////////////////////////// 00062 class eglGraphicsPipe : public GraphicsPipe { 00063 public: 00064 eglGraphicsPipe(const string &display = string()); 00065 virtual ~eglGraphicsPipe(); 00066 00067 virtual string get_interface_name() const; 00068 static PT(GraphicsPipe) pipe_constructor(); 00069 00070 INLINE Display *get_display() const; 00071 INLINE int get_screen() const; 00072 INLINE Window get_root() const; 00073 INLINE XIM get_im() const; 00074 00075 INLINE Cursor get_hidden_cursor(); 00076 00077 public: 00078 virtual PreferredWindowThread get_preferred_window_thread() const; 00079 00080 public: 00081 // Atom specifications. 00082 Atom _wm_delete_window; 00083 Atom _net_wm_window_type; 00084 Atom _net_wm_window_type_splash; 00085 Atom _net_wm_window_type_fullscreen; 00086 Atom _net_wm_state; 00087 Atom _net_wm_state_fullscreen; 00088 Atom _net_wm_state_above; 00089 Atom _net_wm_state_below; 00090 Atom _net_wm_state_add; 00091 Atom _net_wm_state_remove; 00092 00093 protected: 00094 virtual PT(GraphicsOutput) make_output(const string &name, 00095 const FrameBufferProperties &fb_prop, 00096 const WindowProperties &win_prop, 00097 int flags, 00098 GraphicsEngine *engine, 00099 GraphicsStateGuardian *gsg, 00100 GraphicsOutput *host, 00101 int retry, 00102 bool &precertify); 00103 00104 private: 00105 void make_hidden_cursor(); 00106 void release_hidden_cursor(); 00107 00108 static void install_error_handlers(); 00109 static int error_handler(Display *display, XErrorEvent *error); 00110 static int io_error_handler(Display *display); 00111 00112 Display *_display; 00113 int _screen; 00114 Window _root; 00115 XIM _im; 00116 EGLDisplay _egl_display; 00117 00118 Cursor _hidden_cursor; 00119 00120 typedef int ErrorHandlerFunc(Display *, XErrorEvent *); 00121 typedef int IOErrorHandlerFunc(Display *); 00122 static bool _error_handlers_installed; 00123 static ErrorHandlerFunc *_prev_error_handler; 00124 static IOErrorHandlerFunc *_prev_io_error_handler; 00125 00126 public: 00127 // This Mutex protects any X library calls, which all have to be 00128 // single-threaded. In particular, it protects eglMakeCurrent(). 00129 static LightReMutex _x_mutex; 00130 00131 public: 00132 static TypeHandle get_class_type() { 00133 return _type_handle; 00134 } 00135 static void init_type() { 00136 GraphicsPipe::init_type(); 00137 register_type(_type_handle, "eglGraphicsPipe", 00138 GraphicsPipe::get_class_type()); 00139 } 00140 virtual TypeHandle get_type() const { 00141 return get_class_type(); 00142 } 00143 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00144 00145 private: 00146 static TypeHandle _type_handle; 00147 00148 friend class eglGraphicsBuffer; 00149 friend class eglGraphicsPixmap; 00150 friend class eglGraphicsWindow; 00151 }; 00152 00153 #include "eglGraphicsPipe.I" 00154 00155 #endif