Panda3D
|
00001 // Filename: eglGraphicsWindow.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 EGLGRAPHICSWINDOW_H 00016 #define EGLGRAPHICSWINDOW_H 00017 00018 #include "pandabase.h" 00019 00020 #include "eglGraphicsPipe.h" 00021 #include "graphicsWindow.h" 00022 #include "buttonHandle.h" 00023 #include "get_x11.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : eglGraphicsWindow 00027 // Description : An interface to the egl system for managing GLES 00028 // windows under X. 00029 //////////////////////////////////////////////////////////////////// 00030 class eglGraphicsWindow : public GraphicsWindow { 00031 public: 00032 eglGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, 00033 const string &name, 00034 const FrameBufferProperties &fb_prop, 00035 const WindowProperties &win_prop, 00036 int flags, 00037 GraphicsStateGuardian *gsg, 00038 GraphicsOutput *host); 00039 virtual ~eglGraphicsWindow(); 00040 00041 virtual bool move_pointer(int device, int x, int y); 00042 virtual bool begin_frame(FrameMode mode, Thread *current_thread); 00043 virtual void end_frame(FrameMode mode, Thread *current_thread); 00044 virtual void end_flip(); 00045 00046 virtual void process_events(); 00047 virtual void set_properties_now(WindowProperties &properties); 00048 00049 INLINE X11_Window get_xwindow() const; 00050 00051 protected: 00052 virtual void close_window(); 00053 virtual bool open_window(); 00054 00055 private: 00056 void set_wm_properties(const WindowProperties &properties, 00057 bool already_mapped); 00058 00059 void setup_colormap(XVisualInfo *visual); 00060 void handle_keystroke(XKeyEvent &event); 00061 void handle_keypress(XKeyEvent &event); 00062 void handle_keyrelease(XKeyEvent &event); 00063 00064 ButtonHandle get_button(XKeyEvent &key_event, bool allow_shift); 00065 ButtonHandle map_button(KeySym key); 00066 ButtonHandle get_mouse_button(XButtonEvent &button_event); 00067 00068 static Bool check_event(X11_Display *display, XEvent *event, char *arg); 00069 00070 void open_raw_mice(); 00071 void poll_raw_mice(); 00072 00073 private: 00074 X11_Display *_display; 00075 int _screen; 00076 X11_Window _xwindow; 00077 Colormap _colormap; 00078 XIC _ic; 00079 EGLDisplay _egl_display; 00080 EGLSurface _egl_surface; 00081 00082 long _event_mask; 00083 bool _awaiting_configure; 00084 Atom _wm_delete_window; 00085 Atom _net_wm_window_type; 00086 Atom _net_wm_window_type_splash; 00087 Atom _net_wm_window_type_fullscreen; 00088 Atom _net_wm_state; 00089 Atom _net_wm_state_fullscreen; 00090 Atom _net_wm_state_above; 00091 Atom _net_wm_state_below; 00092 Atom _net_wm_state_add; 00093 Atom _net_wm_state_remove; 00094 00095 struct MouseDeviceInfo { 00096 int _fd; 00097 int _input_device_index; 00098 string _io_buffer; 00099 }; 00100 pvector<MouseDeviceInfo> _mouse_device_info; 00101 00102 public: 00103 static TypeHandle get_class_type() { 00104 return _type_handle; 00105 } 00106 static void init_type() { 00107 GraphicsWindow::init_type(); 00108 register_type(_type_handle, "eglGraphicsWindow", 00109 GraphicsWindow::get_class_type()); 00110 } 00111 virtual TypeHandle get_type() const { 00112 return get_class_type(); 00113 } 00114 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00115 00116 private: 00117 static TypeHandle _type_handle; 00118 }; 00119 00120 #include "eglGraphicsWindow.I" 00121 00122 #endif