1 #ifndef OGRE_GLXGLSupport_H 2 #define OGRE_GLXGLSupport_H 3 4 #include "OgreGLSupport.h" 5 6 #include <GL/glew.h> 7 #include <GL/glxew.h> 8 9 namespace Ogre { 10 11 class _OgrePrivate GLXGLSupport : public GLSupport 12 { 13 public: 14 GLXGLSupport(); 15 ~GLXGLSupport(); 16 17 Atom mAtomDeleteWindow; 18 Atom mAtomFullScreen; 19 Atom mAtomState; 20 21 /** @copydoc GLSupport::addConfig */ 22 void addConfig(void); 23 24 /** @copydoc GLSupport::validateConfig */ 25 String validateConfig(void); 26 27 /** @copydoc GLSupport::setConfigOption */ 28 void setConfigOption(const String &name, const String &value); 29 30 /// @copydoc GLSupport::createWindow 31 RenderWindow* createWindow(bool autoCreateWindow, GLRenderSystem* renderSystem, const String& windowTitle); 32 33 /// @copydoc RenderSystem::createRenderWindow 34 RenderWindow* newWindow(const String &name, unsigned int width, unsigned int height, 35 bool fullScreen, const NameValuePairList *miscParams = 0); 36 37 /// @copydoc GLSupport::createPBuffer 38 GLPBuffer* createPBuffer(PixelComponentType format, size_t width, size_t height); 39 40 /** @copydoc GLSupport::start */ 41 void start(); 42 43 /** @copydoc GLSupport::stop */ 44 void stop(); 45 46 /** @copydoc GLSupport::initialiseExtensions */ 47 void initialiseExtensions(); 48 49 /** @copydoc GLSupport::getProcAddress */ 50 void* getProcAddress(const String& procname); 51 52 // The remaining functions are internal to the GLX Rendersystem: 53 54 /** 55 * Get the name of the display and screen used for rendering 56 * 57 * Ogre normally opens its own connection to the X server 58 * and renders onto the screen where the user logged in 59 * 60 * However, if Ogre is passed a current GL context when the first 61 * RenderTarget is created, then it will connect to the X server 62 * using the same connection as that GL context and direct all 63 * subsequent rendering to the screen targeted by that GL context. 64 * 65 * @return Display name. 66 */ 67 String getDisplayName (void); 68 69 /** 70 * Get the Display connection used for rendering 71 * 72 * This function establishes the initial connection when necessary. 73 * 74 * @return Display connection 75 */ 76 Display* getGLDisplay(void); 77 78 /** 79 * Get the Display connection used for window management & events 80 * 81 * @return Display connection 82 */ 83 Display* getXDisplay(void); 84 85 /** 86 * Switch video modes 87 * 88 * @param width Receiver for requested and final width 89 * @param height Receiver for requested and final drawable height 90 * @param frequency Receiver for requested and final drawable frequency 91 */ 92 void switchMode (uint& width, uint& height, short& frequency); 93 94 /** 95 * Switch back to original video mode 96 */ 97 void switchMode (void); 98 99 /** 100 * Loads an icon from an Ogre resource into the X Server. This currently only 101 * works for 24 and 32 bit displays. The image must be findable by the Ogre 102 * resource system, and of format PF_A8R8G8B8. 103 * 104 * @param name Name of image to load 105 * @param pix Receiver for the output pixmap 106 * @param mask Receiver for the output mask (alpha bitmap) 107 * @return true on success 108 */ 109 bool loadIcon(const String &name, Pixmap *pix, Pixmap *mask); 110 111 /** 112 * Get the GLXFBConfig used to create a GLXContext 113 * 114 * @param context GLXContext 115 * @return GLXFBConfig used to create the context 116 */ 117 GLXFBConfig getFBConfigFromContext (::GLXContext context); 118 119 /** 120 * Get the GLXFBConfig used to create a GLXDrawable. 121 * Caveat: GLX version 1.3 is needed when the drawable is a GLXPixmap 122 * 123 * @param drawable GLXDrawable 124 * @param width Receiver for the drawable width 125 * @param height Receiver for the drawable height 126 * @return GLXFBConfig used to create the drawable 127 */ 128 GLXFBConfig getFBConfigFromDrawable (GLXDrawable drawable, unsigned int *width, unsigned int *height); 129 130 /** 131 * Select an FBConfig given a list of required and a list of desired properties 132 * 133 * @param minAttribs FBConfig attributes that must be provided with minimum values 134 * @param maxAttribs FBConfig attributes that are desirable with maximum values 135 * @return GLXFBConfig with attributes or 0 when unsupported. 136 */ 137 GLXFBConfig selectFBConfig(const int *minAttribs, const int *maxAttribs); 138 139 /** 140 * Gets a GLXFBConfig compatible with a VisualID 141 * 142 * Some platforms fail to implement glXGetFBconfigFromVisualSGIX as 143 * part of the GLX_SGIX_fbconfig extension, but this portable 144 * alternative suffices for the creation of compatible contexts. 145 * 146 * @param visualid VisualID 147 * @return FBConfig for VisualID 148 */ 149 GLXFBConfig getFBConfigFromVisualID(VisualID visualid); 150 151 /** 152 * Portable replacement for glXChooseFBConfig 153 */ 154 GLXFBConfig* chooseFBConfig(const GLint *attribList, GLint *nElements); 155 156 /** 157 * Portable replacement for glXCreateNewContext 158 */ 159 ::GLXContext createNewContext(GLXFBConfig fbConfig, GLint renderType, ::GLXContext shareList, GLboolean direct) const; 160 161 /** 162 * Portable replacement for glXGetFBConfigAttrib 163 */ 164 GLint getFBConfigAttrib(GLXFBConfig fbConfig, GLint attribute, GLint *value); 165 166 /** 167 * Portable replacement for glXGetVisualFromFBConfig 168 */ 169 XVisualInfo* getVisualFromFBConfig(GLXFBConfig fbConfig); 170 171 private: 172 /** 173 * Initialise GLXEW without requiring a current GL context 174 */ 175 void initialiseGLXEW(void); 176 177 /** 178 * Refresh config options to reflect dependencies 179 */ 180 void refreshConfig(void); 181 182 Display* mGLDisplay; // used for GL/GLX commands 183 Display* mXDisplay; // used for other X commands and events 184 bool mIsExternalDisplay; 185 186 typedef std::pair<uint, uint> ScreenSize; 187 typedef short Rate; 188 typedef std::pair<ScreenSize, Rate> VideoMode; 189 typedef std::vector<VideoMode> VideoModes; 190 191 VideoModes mVideoModes; 192 VideoMode mOriginalMode; 193 VideoMode mCurrentMode; 194 195 StringVector mSampleLevels; 196 }; 197 198 #if OGRE_THREAD_SUPPORT == 1 199 GLXEWContext* glxewGetContext(); 200 #endif 201 } 202 203 #endif // OGRE_GLXGLSupport_H 204