include/EGL/X11/OgreX11EGLSupport.h
Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004 (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2008 Renato Araujo Oliveira Filho <renatox@gmail.com>
00008 Copyright (c) 2000-2012 Torus Knot Software Ltd
00009 
00010 Permission is hereby granted, free of charge, to any person obtaining a copy
00011 of this software and associated documentation files (the "Software"), to deal
00012 in the Software without restriction, including without limitation the rights
00013 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00014 copies of the Software, and to permit persons to whom the Software is
00015 furnished to do so, subject to the following conditions:
00016 
00017 The above copyright notice and this permission notice shall be included in
00018 all copies or substantial portions of the Software.
00019 
00020 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00021 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00022 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00023 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00024 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00025 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00026 THE SOFTWARE.
00027 -----------------------------------------------------------------------------
00028 */
00029 
00030 #ifndef __X11EGLSupport_H__
00031 #define __X11EGLSupport_H__
00032 
00033 
00034 #include "OgreEGLSupport.h"
00035 
00036 #if (OGRE_PLATFORM == OGRE_PLATFORM_LINUX)
00037     #include <X11/Xutil.h>
00038     #include <X11/extensions/Xrandr.h>
00039     #include <X11/Xutil.h>
00040     #include <sys/time.h>
00041     #include <X11/Xlib.h>
00042     #include <X11/keysym.h>
00043     #include <X11/extensions/Xrandr.h>
00044 #else
00045     #define StructureNotifyMask 0
00046     #define VisibilityChangeMask 0
00047     #define FocusChangeMask 0
00048     #define CWBackPixel 0
00049     #define CWBorderPixel 0
00050     #define CWColormap 0
00051     #define CWEventMask 0
00052     #define NotUseful 0
00053     #define CWSaveUnder 0
00054     #define CWBackingStore 0
00055     #define CWOverrideRedirect 0
00056     #define InputOutput 0
00057     #define NormalState 0
00058     #define StateHint 0
00059     #define InputHint 0
00060     #define USPosition 0
00061     #define ClientMessage 0
00062     #define SubstructureRedirectMask 0
00063     #define SubstructureNotifyMask 0
00064     #define CurrentTime 0
00065     #define VisualIDMask 0
00066     #define AllocNone 0
00067 
00068     enum X11Bool
00069     {
00070         False
00071         ,
00072         True
00073     };
00074     class NotPointerAtom{};
00075     typedef NotPointerAtom * Atom;
00076 
00077     class Display{};
00078     class XErrorEvent{};
00079     class XRRScreenConfiguration{};
00080     class Rotation{};
00081     class Visual{};
00082     #define Window  NativeWindowType
00083 
00084     struct XVisualInfo{int visualid, visual, depth;};
00085     struct XRRScreenSize{int width, height;};
00086     struct XWMHints{int initial_state, input, flags;};
00087     struct XSizeHints{int flags;};
00088     struct XWindowAttributes{NativeWindowType root; int x, y, width, height;};
00089     struct XSetWindowAttributes{int background_pixel, border_pixel, colormap, event_mask, backing_store, save_under, override_redirect;};
00090     struct XTextProperty{int * value;};
00091     struct StrangeData{StrangeData(){}StrangeData(Atom atom){}StrangeData(int num){}};
00092     struct XClientMessageEventData{StrangeData l[3];};
00093     struct XClientMessageEvent{int type, serial, send_event, format; XClientMessageEventData data ; NativeWindowType window; Atom message_type;};
00094     struct XEvent{};
00095 
00096 
00097     void XStringListToTextProperty(char ** prop, int num, XTextProperty * textProp);
00098     Window DefaultRootWindow(Display* nativeDisplayType);
00099     bool XQueryExtension(Display* nativeDisplayType, char * name, int * dummy0, int * dummy2, int * dummy3);
00100     XRRScreenConfiguration * XRRGetScreenInfo(Display* nativeDisplayType, Window window );
00101     int XRRConfigCurrentConfiguration(XRRScreenConfiguration * config, Rotation * rotation);
00102     XRRScreenSize * XRRConfigSizes(XRRScreenConfiguration * config, int * nSizes);
00103     int XRRConfigCurrentRate(XRRScreenConfiguration * config);
00104     short * XRRConfigRates(XRRScreenConfiguration * config, int sizeID, int * nRates);
00105     void XRRFreeScreenConfigInfo(XRRScreenConfiguration * config);
00106     int DefaultScreen(NativeDisplayType nativeDisplayType);
00107     int DisplayWidth(Display* nativeDisplayType, int screen);
00108     int DisplayHeight(Display* nativeDisplayType, int screen);
00109     Display* XOpenDisplay(int num);
00110     void XCloseDisplay(Display* nativeDisplayType);
00111     Atom XInternAtom(Display* nativeDisplayType, char * name, X11Bool isTrue);;
00112     char * DisplayString(NativeDisplayType nativeDisplayType);
00113     const char * XDisplayName(char * name);
00114     Visual * DefaultVisual(Display* nativeDisplayType,  int screen);
00115     int XVisualIDFromVisual(Visual *v);
00116     void XRRSetScreenConfigAndRate(Display* nativeDisplayType, XRRScreenConfiguration * config, Window window, int size, Rotation rotation, int mode, int currentTime );
00117     XVisualInfo * XGetVisualInfo(Display* nativeDisplayType,  int mask, XVisualInfo * info, int * n);
00118     typedef int (*XErrorHandler)(Display *, XErrorEvent*);
00119     XErrorHandler XSetErrorHandler(XErrorHandler xErrorHandler);
00120     void XDestroyWindow(Display* nativeDisplayType, Window nativeWindowType);
00121     bool XGetWindowAttributes(Display* nativeDisplayType, Window nativeWindowType, XWindowAttributes * xWindowAttributes);
00122     int XCreateColormap(Display* nativeDisplayType, Window nativeWindowType, int visual, int allocNone);
00123     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);
00124     void XFree(void *data);
00125     XWMHints * XAllocWMHints();
00126     XSizeHints * XAllocSizeHints();
00127     void XSetWMProperties(Display* nativeDisplayType, Window nativeWindowType,XTextProperty * titleprop, char * dummy1, char * dummy2, int num, XSizeHints *sizeHints, XWMHints *wmHints, char * dummy3);
00128     void XSetWMProtocols(Display* nativeDisplayType, Window nativeWindowType, Atom * atom, int num);
00129     void XMapWindow(Display* nativeDisplayType, Window nativeWindowType);
00130     void XFlush(Display* nativeDisplayType);
00131     void XMoveWindow(Display* nativeDisplayType, Window nativeWindowType, int left, int top);
00132     void XResizeWindow(Display* nativeDisplayType, Window nativeWindowType, int left, int top);
00133     void XQueryTree(Display* nativeDisplayType, Window nativeWindowType, Window * root, Window *parent, Window **children, unsigned int * nChildren);
00134     void XSendEvent(Display* nativeDisplayType, Window nativeWindowType, int dummy1, int mask, XEvent* xevent);
00135 #endif
00136 
00137 
00138 namespace Ogre {
00139     class _OgrePrivate X11EGLSupport : public EGLSupport
00140     {
00141         protected:
00142 
00143             //removed createEGLWindow because it was easier to just use
00144             // new X11EGLWindow in the code to get the native version.
00145             //virtual EGLWindow* createEGLWindow( EGLSupport * support);
00146 
00147         public:
00148             X11EGLSupport();
00149             virtual ~X11EGLSupport();
00150 
00151             virtual GLESPBuffer* createPBuffer(PixelComponentType format,
00152                 size_t width, size_t height);
00153 
00154             virtual void switchMode(uint& width, uint& height, short& frequency);
00155             String getDisplayName(void);
00156 
00157             NativeDisplayType getNativeDisplay(void);
00158             XVisualInfo *getVisualFromFBConfig(::EGLConfig glConfig);
00159             Atom mAtomDeleteWindow;
00160             Atom mAtomFullScreen;
00161             Atom mAtomState;
00162 
00163             // This just sets the native variables needed by EGLSupport::getGLDisplay
00164             //Then it calls EGLSupport::getDLDisplay to do the rest of the work.
00165             EGLDisplay getGLDisplay();
00166 
00167             //Moved this here from EGLSupport because maybe it should be more native.
00168                     RenderWindow* newWindow(const String& name,
00169                                         unsigned int width, unsigned int height,
00170                                         bool fullScreen,
00171                                         const NameValuePairList *miscParams = 0);
00172 
00173     };
00174 }
00175 
00176 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 2012 21:48:53