/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 #ifndef Status
00038 #define Status int
00039 #endif 
00040     #include <X11/Xlib.h>
00041     #include <X11/Xutil.h>
00042 //  #include <X11/extensions/Xrandr.h>
00043     #include <sys/time.h>
00044     #include <X11/keysym.h>
00045 #else
00046     #define StructureNotifyMask 0
00047     #define VisibilityChangeMask 0
00048     #define FocusChangeMask 0
00049     #define CWBackPixel 0
00050     #define CWBorderPixel 0
00051     #define CWColormap 0
00052     #define CWEventMask 0
00053     #define NotUseful 0
00054     #define CWSaveUnder 0
00055     #define CWBackingStore 0
00056     #define CWOverrideRedirect 0
00057     #define InputOutput 0
00058     #define NormalState 0
00059     #define StateHint 0
00060     #define InputHint 0
00061     #define USPosition 0
00062     #define ClientMessage 0
00063     #define SubstructureRedirectMask 0
00064     #define SubstructureNotifyMask 0
00065     #define CurrentTime 0
00066     #define VisualIDMask 0
00067     #define AllocNone 0
00068 
00069     enum X11Bool
00070     {
00071         False
00072         ,
00073         True
00074     };
00075     class NotPointerAtom{};
00076     typedef NotPointerAtom * Atom;
00077 
00078     class Display{};
00079     class XErrorEvent{};
00080     class XRRScreenConfiguration{};
00081     class Rotation{};
00082     class Visual{};
00083     #define Window  NativeWindowType
00084 
00085     struct XVisualInfo{int visualid, visual, depth;};
00086     struct XRRScreenSize{int width, height;};
00087     struct XWMHints{int initial_state, input, flags;};
00088     struct XSizeHints{int flags;};
00089     struct XWindowAttributes{NativeWindowType root; int x, y, width, height;};
00090     struct XSetWindowAttributes{int background_pixel, border_pixel, colormap, event_mask, backing_store, save_under, override_redirect;};
00091     struct XTextProperty{int * value;};
00092     struct StrangeData{StrangeData(){}StrangeData(Atom atom){}StrangeData(int num){}};
00093     struct XClientMessageEventData{StrangeData l[3];};
00094     struct XClientMessageEvent{int type, serial, send_event, format; XClientMessageEventData data ; NativeWindowType window; Atom message_type;};
00095     struct XEvent{};
00096 
00097 
00098     void XStringListToTextProperty(char ** prop, int num, XTextProperty * textProp);
00099     Window DefaultRootWindow(Display* nativeDisplayType);
00100     bool XQueryExtension(Display* nativeDisplayType, char * name, int * dummy0, int * dummy2, int * dummy3);
00101     XRRScreenConfiguration * XRRGetScreenInfo(Display* nativeDisplayType, Window window );
00102     int XRRConfigCurrentConfiguration(XRRScreenConfiguration * config, Rotation * rotation);
00103     XRRScreenSize * XRRConfigSizes(XRRScreenConfiguration * config, int * nSizes);
00104     int XRRConfigCurrentRate(XRRScreenConfiguration * config);
00105     short * XRRConfigRates(XRRScreenConfiguration * config, int sizeID, int * nRates);
00106     void XRRFreeScreenConfigInfo(XRRScreenConfiguration * config);
00107     int DefaultScreen(NativeDisplayType nativeDisplayType);
00108     int DisplayWidth(Display* nativeDisplayType, int screen);
00109     int DisplayHeight(Display* nativeDisplayType, int screen);
00110     Display* XOpenDisplay(int num);
00111     void XCloseDisplay(Display* nativeDisplayType);
00112     Atom XInternAtom(Display* nativeDisplayType, char * name, X11Bool isTrue);;
00113     char * DisplayString(NativeDisplayType nativeDisplayType);
00114     const char * XDisplayName(char * name);
00115     Visual * DefaultVisual(Display* nativeDisplayType,  int screen);
00116     int XVisualIDFromVisual(Visual *v);
00117     void XRRSetScreenConfigAndRate(Display* nativeDisplayType, XRRScreenConfiguration * config, Window window, int size, Rotation rotation, int mode, int currentTime );
00118     XVisualInfo * XGetVisualInfo(Display* nativeDisplayType,  int mask, XVisualInfo * info, int * n);
00119     typedef int (*XErrorHandler)(Display *, XErrorEvent*);
00120     XErrorHandler XSetErrorHandler(XErrorHandler xErrorHandler);
00121     void XDestroyWindow(Display* nativeDisplayType, Window nativeWindowType);
00122     bool XGetWindowAttributes(Display* nativeDisplayType, Window nativeWindowType, XWindowAttributes * xWindowAttributes);
00123     int XCreateColormap(Display* nativeDisplayType, Window nativeWindowType, int visual, int allocNone);
00124     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);
00125     void XFree(void *data);
00126     XWMHints * XAllocWMHints();
00127     XSizeHints * XAllocSizeHints();
00128     void XSetWMProperties(Display* nativeDisplayType, Window nativeWindowType,XTextProperty * titleprop, char * dummy1, char * dummy2, int num, XSizeHints *sizeHints, XWMHints *wmHints, char * dummy3);
00129     void XSetWMProtocols(Display* nativeDisplayType, Window nativeWindowType, Atom * atom, int num);
00130     void XMapWindow(Display* nativeDisplayType, Window nativeWindowType);
00131     void XFlush(Display* nativeDisplayType);
00132     void XMoveWindow(Display* nativeDisplayType, Window nativeWindowType, int left, int top);
00133     void XResizeWindow(Display* nativeDisplayType, Window nativeWindowType, int left, int top);
00134     void XQueryTree(Display* nativeDisplayType, Window nativeWindowType, Window * root, Window *parent, Window **children, unsigned int * nChildren);
00135     void XSendEvent(Display* nativeDisplayType, Window nativeWindowType, int dummy1, int mask, XEvent* xevent);
00136 #endif
00137 
00138 
00139 namespace Ogre {
00140     class _OgrePrivate X11EGLSupport : public EGLSupport
00141     {
00142         protected:
00143 
00144             //removed createEGLWindow because it was easier to just use
00145             // new X11EGLWindow in the code to get the native version.
00146             //virtual EGLWindow* createEGLWindow( EGLSupport * support);
00147 
00148         public:
00149             X11EGLSupport();
00150             virtual ~X11EGLSupport();
00151 
00152 //          virtual GLES2PBuffer* createPBuffer(PixelComponentType format,
00153 //              size_t width, size_t height);
00154 
00155             virtual void switchMode(uint& width, uint& height, short& frequency);
00156             String getDisplayName(void);
00157 
00158             NativeDisplayType getNativeDisplay(void);
00159             XVisualInfo *getVisualFromFBConfig(::EGLConfig glConfig);
00160             Atom mAtomDeleteWindow;
00161             Atom mAtomFullScreen;
00162             Atom mAtomState;
00163 
00164             // This just sets the native variables needed by EGLSupport::getGLDisplay
00165             //Then it calls EGLSupport::getDLDisplay to do the rest of the work.
00166             EGLDisplay getGLDisplay();
00167 
00168             //Moved this here from EGLSupport because maybe it should be more native.
00169                     RenderWindow* newWindow(const String& name,
00170                                         unsigned int width, unsigned int height,
00171                                         bool fullScreen,
00172                                         const NameValuePairList *miscParams = 0);
00173 
00174     };
00175 }
00176 
00177 #endif
00178 

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 Sun Sep 2 2012 07:27:24