OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
/include/EGL/X11/OgreX11EGLSupport.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2008 Renato Araujo Oliveira Filho <renatox@gmail.com>
8 Copyright (c) 2000-2014 Torus Knot Software Ltd
9 
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16 
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 THE SOFTWARE.
27 -----------------------------------------------------------------------------
28 */
29 
30 #ifndef __X11EGLSupport_H__
31 #define __X11EGLSupport_H__
32 
33 
34 #include "OgreEGLSupport.h"
35 
36 #if (OGRE_PLATFORM == OGRE_PLATFORM_LINUX)
37 #ifndef Status
38 #define Status int
39 #endif
40  #include <X11/Xlib.h>
41  #include <X11/Xutil.h>
42 // #include <X11/extensions/Xrandr.h>
43  #include <sys/time.h>
44  #include <X11/keysym.h>
45 #else
46  #define StructureNotifyMask 0
47  #define VisibilityChangeMask 0
48  #define FocusChangeMask 0
49  #define CWBackPixel 0
50  #define CWBorderPixel 0
51  #define CWColormap 0
52  #define CWEventMask 0
53  #define NotUseful 0
54  #define CWSaveUnder 0
55  #define CWBackingStore 0
56  #define CWOverrideRedirect 0
57  #define InputOutput 0
58  #define NormalState 0
59  #define StateHint 0
60  #define InputHint 0
61  #define USPosition 0
62  #define ClientMessage 0
63  #define SubstructureRedirectMask 0
64  #define SubstructureNotifyMask 0
65  #define CurrentTime 0
66  #define VisualIDMask 0
67  #define AllocNone 0
68 
69  enum X11Bool
70  {
71  False
72  ,
73  True
74  };
75  class NotPointerAtom{};
76  typedef NotPointerAtom * Atom;
77 
78  class Display{};
79  class XErrorEvent{};
80  class XRRScreenConfiguration{};
81  class Rotation{};
82  class Visual{};
83  #define Window NativeWindowType
84 
85  struct XVisualInfo{int visualid, visual, depth;};
86  struct XRRScreenSize{int width, height;};
87  struct XWMHints{int initial_state, input, flags;};
88  struct XSizeHints{int flags;};
89  struct XWindowAttributes{NativeWindowType root; int x, y, width, height;};
90  struct XSetWindowAttributes{int background_pixel, border_pixel, colormap, event_mask, backing_store, save_under, override_redirect;};
91  struct XTextProperty{int * value;};
92  struct StrangeData{StrangeData(){}StrangeData(Atom atom){}StrangeData(int num){}};
93  struct XClientMessageEventData{StrangeData l[3];};
94  struct XClientMessageEvent{int type, serial, send_event, format; XClientMessageEventData data ; NativeWindowType window; Atom message_type;};
95  struct XEvent{};
96 
97 
98  void XStringListToTextProperty(char ** prop, int num, XTextProperty * textProp);
99  Window DefaultRootWindow(Display* nativeDisplayType);
100  bool XQueryExtension(Display* nativeDisplayType, char * name, int * dummy0, int * dummy2, int * dummy3);
101  XRRScreenConfiguration * XRRGetScreenInfo(Display* nativeDisplayType, Window window );
102  int XRRConfigCurrentConfiguration(XRRScreenConfiguration * config, Rotation * rotation);
103  XRRScreenSize * XRRConfigSizes(XRRScreenConfiguration * config, int * nSizes);
104  int XRRConfigCurrentRate(XRRScreenConfiguration * config);
105  short * XRRConfigRates(XRRScreenConfiguration * config, int sizeID, int * nRates);
106  void XRRFreeScreenConfigInfo(XRRScreenConfiguration * config);
107  int DefaultScreen(NativeDisplayType nativeDisplayType);
108  int DisplayWidth(Display* nativeDisplayType, int screen);
109  int DisplayHeight(Display* nativeDisplayType, int screen);
110  Display* XOpenDisplay(int num);
111  void XCloseDisplay(Display* nativeDisplayType);
112  Atom XInternAtom(Display* nativeDisplayType, char * name, X11Bool isTrue);;
113  char * DisplayString(NativeDisplayType nativeDisplayType);
114  const char * XDisplayName(char * name);
115  Visual * DefaultVisual(Display* nativeDisplayType, int screen);
116  int XVisualIDFromVisual(Visual *v);
117  void XRRSetScreenConfigAndRate(Display* nativeDisplayType, XRRScreenConfiguration * config, Window window, int size, Rotation rotation, int mode, int currentTime );
118  XVisualInfo * XGetVisualInfo(Display* nativeDisplayType, int mask, XVisualInfo * info, int * n);
119  typedef int (*XErrorHandler)(Display *, XErrorEvent*);
120  XErrorHandler XSetErrorHandler(XErrorHandler xErrorHandler);
121  void XDestroyWindow(Display* nativeDisplayType, Window nativeWindowType);
122  bool XGetWindowAttributes(Display* nativeDisplayType, Window nativeWindowType, XWindowAttributes * xWindowAttributes);
123  int XCreateColormap(Display* nativeDisplayType, Window nativeWindowType, int visual, int allocNone);
124  Window XCreateWindow(Display* nativeDisplayType, Window nativeWindowType, int left, int top, int width, int height, int dummy1, int depth, int inputOutput, int visual, int mask, XSetWindowAttributes * xSetWindowAttributes);
125  void XFree(void *data);
126  XWMHints * XAllocWMHints();
127  XSizeHints * XAllocSizeHints();
128  void XSetWMProperties(Display* nativeDisplayType, Window nativeWindowType,XTextProperty * titleprop, char * dummy1, char * dummy2, int num, XSizeHints *sizeHints, XWMHints *wmHints, char * dummy3);
129  void XSetWMProtocols(Display* nativeDisplayType, Window nativeWindowType, Atom * atom, int num);
130  void XMapWindow(Display* nativeDisplayType, Window nativeWindowType);
131  void XFlush(Display* nativeDisplayType);
132  void XMoveWindow(Display* nativeDisplayType, Window nativeWindowType, int left, int top);
133  void XResizeWindow(Display* nativeDisplayType, Window nativeWindowType, int left, int top);
134  void XQueryTree(Display* nativeDisplayType, Window nativeWindowType, Window * root, Window *parent, Window **children, unsigned int * nChildren);
135  void XSendEvent(Display* nativeDisplayType, Window nativeWindowType, int dummy1, int mask, XEvent* xevent);
136 #endif
137 
138 
139 namespace Ogre {
140  class _OgrePrivate X11EGLSupport : public EGLSupport
141  {
142  protected:
143 
144  //removed createEGLWindow because it was easier to just use
145  // new X11EGLWindow in the code to get the native version.
146  //virtual EGLWindow* createEGLWindow( EGLSupport * support);
147 
148  public:
149  X11EGLSupport();
150  virtual ~X11EGLSupport();
151 
152 // virtual GLES2PBuffer* createPBuffer(PixelComponentType format,
153 // size_t width, size_t height);
154 
155  virtual void switchMode(uint& width, uint& height, short& frequency);
156  String getDisplayName(void);
157 
158  NativeDisplayType getNativeDisplay(void);
159  XVisualInfo *getVisualFromFBConfig(::EGLConfig glConfig);
160  Atom mAtomDeleteWindow;
161  Atom mAtomFullScreen;
162  Atom mAtomState;
163 
164  // This just sets the native variables needed by EGLSupport::getGLDisplay
165  //Then it calls EGLSupport::getDLDisplay to do the rest of the work.
166  EGLDisplay getGLDisplay();
167 
168  //Moved this here from EGLSupport because maybe it should be more native.
169  RenderWindow* newWindow(const String& name,
170  unsigned int width, unsigned int height,
171  bool fullScreen,
172  const NameValuePairList *miscParams = 0);
173 
174  };
175 }
176 
177 #endif
178 
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:580
#define _OgrePrivate
Definition: OgrePlatform.h:256
String DisplayString
_StringBase String
Definition: OgreCommon.h:53
unsigned int uint