OGRE  1.8
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-2013 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  #include <X11/Xutil.h>
38  #include <X11/extensions/Xrandr.h>
39  #include <X11/Xutil.h>
40  #include <sys/time.h>
41  #include <X11/Xlib.h>
42  #include <X11/keysym.h>
43  #include <X11/extensions/Xrandr.h>
44 #else
45  #define StructureNotifyMask 0
46  #define VisibilityChangeMask 0
47  #define FocusChangeMask 0
48  #define CWBackPixel 0
49  #define CWBorderPixel 0
50  #define CWColormap 0
51  #define CWEventMask 0
52  #define NotUseful 0
53  #define CWSaveUnder 0
54  #define CWBackingStore 0
55  #define CWOverrideRedirect 0
56  #define InputOutput 0
57  #define NormalState 0
58  #define StateHint 0
59  #define InputHint 0
60  #define USPosition 0
61  #define ClientMessage 0
62  #define SubstructureRedirectMask 0
63  #define SubstructureNotifyMask 0
64  #define CurrentTime 0
65  #define VisualIDMask 0
66  #define AllocNone 0
67 
68  enum X11Bool
69  {
70  False
71  ,
72  True
73  };
74  class NotPointerAtom{};
75  typedef NotPointerAtom * Atom;
76 
77  class Display{};
78  class XErrorEvent{};
79  class XRRScreenConfiguration{};
80  class Rotation{};
81  class Visual{};
82  #define Window NativeWindowType
83 
84  struct XVisualInfo{int visualid, visual, depth;};
85  struct XRRScreenSize{int width, height;};
86  struct XWMHints{int initial_state, input, flags;};
87  struct XSizeHints{int flags;};
88  struct XWindowAttributes{NativeWindowType root; int x, y, width, height;};
89  struct XSetWindowAttributes{int background_pixel, border_pixel, colormap, event_mask, backing_store, save_under, override_redirect;};
90  struct XTextProperty{int * value;};
91  struct StrangeData{StrangeData(){}StrangeData(Atom atom){}StrangeData(int num){}};
92  struct XClientMessageEventData{StrangeData l[3];};
93  struct XClientMessageEvent{int type, serial, send_event, format; XClientMessageEventData data ; NativeWindowType window; Atom message_type;};
94  struct XEvent{};
95 
96 
97  void XStringListToTextProperty(char ** prop, int num, XTextProperty * textProp);
98  Window DefaultRootWindow(Display* nativeDisplayType);
99  bool XQueryExtension(Display* nativeDisplayType, char * name, int * dummy0, int * dummy2, int * dummy3);
100  XRRScreenConfiguration * XRRGetScreenInfo(Display* nativeDisplayType, Window window );
101  int XRRConfigCurrentConfiguration(XRRScreenConfiguration * config, Rotation * rotation);
102  XRRScreenSize * XRRConfigSizes(XRRScreenConfiguration * config, int * nSizes);
103  int XRRConfigCurrentRate(XRRScreenConfiguration * config);
104  short * XRRConfigRates(XRRScreenConfiguration * config, int sizeID, int * nRates);
105  void XRRFreeScreenConfigInfo(XRRScreenConfiguration * config);
106  int DefaultScreen(NativeDisplayType nativeDisplayType);
107  int DisplayWidth(Display* nativeDisplayType, int screen);
108  int DisplayHeight(Display* nativeDisplayType, int screen);
109  Display* XOpenDisplay(int num);
110  void XCloseDisplay(Display* nativeDisplayType);
111  Atom XInternAtom(Display* nativeDisplayType, char * name, X11Bool isTrue);;
112  char * DisplayString(NativeDisplayType nativeDisplayType);
113  const char * XDisplayName(char * name);
114  Visual * DefaultVisual(Display* nativeDisplayType, int screen);
115  int XVisualIDFromVisual(Visual *v);
116  void XRRSetScreenConfigAndRate(Display* nativeDisplayType, XRRScreenConfiguration * config, Window window, int size, Rotation rotation, int mode, int currentTime );
117  XVisualInfo * XGetVisualInfo(Display* nativeDisplayType, int mask, XVisualInfo * info, int * n);
118  typedef int (*XErrorHandler)(Display *, XErrorEvent*);
119  XErrorHandler XSetErrorHandler(XErrorHandler xErrorHandler);
120  void XDestroyWindow(Display* nativeDisplayType, Window nativeWindowType);
121  bool XGetWindowAttributes(Display* nativeDisplayType, Window nativeWindowType, XWindowAttributes * xWindowAttributes);
122  int XCreateColormap(Display* nativeDisplayType, Window nativeWindowType, int visual, int allocNone);
123  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);
124  void XFree(void *data);
125  XWMHints * XAllocWMHints();
126  XSizeHints * XAllocSizeHints();
127  void XSetWMProperties(Display* nativeDisplayType, Window nativeWindowType,XTextProperty * titleprop, char * dummy1, char * dummy2, int num, XSizeHints *sizeHints, XWMHints *wmHints, char * dummy3);
128  void XSetWMProtocols(Display* nativeDisplayType, Window nativeWindowType, Atom * atom, int num);
129  void XMapWindow(Display* nativeDisplayType, Window nativeWindowType);
130  void XFlush(Display* nativeDisplayType);
131  void XMoveWindow(Display* nativeDisplayType, Window nativeWindowType, int left, int top);
132  void XResizeWindow(Display* nativeDisplayType, Window nativeWindowType, int left, int top);
133  void XQueryTree(Display* nativeDisplayType, Window nativeWindowType, Window * root, Window *parent, Window **children, unsigned int * nChildren);
134  void XSendEvent(Display* nativeDisplayType, Window nativeWindowType, int dummy1, int mask, XEvent* xevent);
135 #endif
136 
137 
138 namespace Ogre {
140  {
141  protected:
142 
143  //removed createEGLWindow because it was easier to just use
144  // new X11EGLWindow in the code to get the native version.
145  //virtual EGLWindow* createEGLWindow( EGLSupport * support);
146 
147  public:
148  X11EGLSupport();
149  virtual ~X11EGLSupport();
150 
151  virtual GLESPBuffer* createPBuffer(PixelComponentType format,
152  size_t width, size_t height);
153 
154  virtual void switchMode(uint& width, uint& height, short& frequency);
155  String getDisplayName(void);
156 
157  NativeDisplayType getNativeDisplay(void);
158  XVisualInfo *getVisualFromFBConfig(::EGLConfig glConfig);
162 
163  // This just sets the native variables needed by EGLSupport::getGLDisplay
164  //Then it calls EGLSupport::getDLDisplay to do the rest of the work.
165  EGLDisplay getGLDisplay();
166 
167  //Moved this here from EGLSupport because maybe it should be more native.
168  RenderWindow* newWindow(const String& name,
169  unsigned int width, unsigned int height,
170  bool fullScreen,
171  const NameValuePairList *miscParams = 0);
172 
173  };
174 }
175 
176 #endif
Manages the target rendering window.
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:553
PixelComponentType
Pixel component format.
#define _OgrePrivate
Definition: OgrePlatform.h:234
UTFString DisplayString
_StringBase String
unsigned int uint