CmGLXGLSupport.h 6.0 KB

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