Panda3D
 All Classes Functions Variables Enumerations
eglGraphicsPipe.h
1 // Filename: eglGraphicsPipe.h
2 // Created by: pro-rsoft (21May09)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef EGLGRAPHICSPIPE_H
16 #define EGLGRAPHICSPIPE_H
17 
18 #include "pandabase.h"
19 #include "graphicsWindow.h"
20 #include "graphicsPipe.h"
21 #include "lightMutex.h"
22 #include "lightReMutex.h"
23 #include "get_x11.h"
24 
25 #ifdef OPENGLES_2
26  #include "gles2gsg.h"
27  #include "pre_x11_include.h"
28  #include <EGL/egl.h>
29  #include "post_x11_include.h"
30  #define NativeDisplayType EGLNativeDisplayType
31  #define NativePixmapType EGLNativePixmapType
32  #define NativeWindowType EGLNativeWindowType
33 #else
34  #include "glesgsg.h"
35  #include "pre_x11_include.h"
36  #include <GLES/egl.h>
37  #include "post_x11_include.h"
38 #endif
39 
41 
42 class eglGraphicsBuffer;
43 class eglGraphicsPixmap;
44 class eglGraphicsWindow;
45 
46 ////////////////////////////////////////////////////////////////////
47 // Class : eglGraphicsPipe
48 // Description : This graphics pipe represents the interface for
49 // creating OpenGL ES graphics windows on an X-based
50 // (e.g. Unix) client.
51 ////////////////////////////////////////////////////////////////////
52 class eglGraphicsPipe : public GraphicsPipe {
53 public:
54  eglGraphicsPipe(const string &display = string());
55  virtual ~eglGraphicsPipe();
56 
57  virtual string get_interface_name() const;
58  static PT(GraphicsPipe) pipe_constructor();
59 
60  INLINE X11_Display *get_display() const;
61  INLINE int get_screen() const;
62  INLINE X11_Window get_root() const;
63  INLINE XIM get_im() const;
64 
65  INLINE X11_Cursor get_hidden_cursor();
66 
67 public:
68  virtual PreferredWindowThread get_preferred_window_thread() const;
69 
70 public:
71  // Atom specifications.
72  Atom _wm_delete_window;
73  Atom _net_wm_window_type;
74  Atom _net_wm_window_type_splash;
75  Atom _net_wm_window_type_fullscreen;
76  Atom _net_wm_state;
77  Atom _net_wm_state_fullscreen;
78  Atom _net_wm_state_above;
79  Atom _net_wm_state_below;
80  Atom _net_wm_state_add;
81  Atom _net_wm_state_remove;
82 
83 protected:
84  virtual PT(GraphicsOutput) make_output(const string &name,
85  const FrameBufferProperties &fb_prop,
86  const WindowProperties &win_prop,
87  int flags,
88  GraphicsEngine *engine,
90  GraphicsOutput *host,
91  int retry,
92  bool &precertify);
93 
94 private:
95  void make_hidden_cursor();
96  void release_hidden_cursor();
97 
98  static void install_error_handlers();
99  static int error_handler(X11_Display *display, XErrorEvent *error);
100  static int io_error_handler(X11_Display *display);
101 
102  X11_Display *_display;
103  int _screen;
104  X11_Window _root;
105  XIM _im;
106  EGLDisplay _egl_display;
107 
108  X11_Cursor _hidden_cursor;
109 
110  typedef int ErrorHandlerFunc(X11_Display *, XErrorEvent *);
111  typedef int IOErrorHandlerFunc(X11_Display *);
112  static bool _error_handlers_installed;
113  static ErrorHandlerFunc *_prev_error_handler;
114  static IOErrorHandlerFunc *_prev_io_error_handler;
115 
116 public:
117  // This Mutex protects any X library calls, which all have to be
118  // single-threaded. In particular, it protects eglMakeCurrent().
119  static LightReMutex _x_mutex;
120 
121 public:
122  static TypeHandle get_class_type() {
123  return _type_handle;
124  }
125  static void init_type() {
126  GraphicsPipe::init_type();
127  register_type(_type_handle, "eglGraphicsPipe",
128  GraphicsPipe::get_class_type());
129  }
130  virtual TypeHandle get_type() const {
131  return get_class_type();
132  }
133  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
134 
135 private:
136  static TypeHandle _type_handle;
137 
138  friend class eglGraphicsBuffer;
139  friend class eglGraphicsPixmap;
140  friend class eglGraphicsWindow;
141 };
142 
143 #include "eglGraphicsPipe.I"
144 
145 #endif
X11_Window get_root() const
Returns the handle to the root window on the pipe&#39;s display.
XIM get_im() const
Returns the input method opened for the pipe, or NULL if the input method could not be opened for som...
A lightweight reentrant mutex.
Definition: lightReMutex.h:34
An interface to the egl system for managing GLES windows under X.
This graphics pipe represents the interface for creating OpenGL ES graphics windows on an X-based (e...
virtual string get_interface_name() const
Returns the name of the rendering interface associated with this GraphicsPipe.
virtual PreferredWindowThread get_preferred_window_thread() const
Returns an indication of the thread in which this GraphicsPipe requires its window processing to be p...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
Another offscreen buffer in the EGL environment.
X11_Cursor get_hidden_cursor()
Returns an invisible Cursor suitable for assigning to windows that have the cursor_hidden property se...
This is a base class for the various different classes that represent the result of a frame of render...
An offscreen buffer in the EGL environment.
int get_screen() const
Returns the X screen number associated with the pipe.
Encapsulates all the communication with a particular instance of a given rendering backend...
X11_Display * get_display() const
Returns a pointer to the X display associated with the pipe: the display on which to create the windo...
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...