/extlibs/SFML/src/SFML/Window/Linux/GlxContext.hpp

https://bitbucket.org/hugoruscitti/pilascpp · C++ Header · 126 lines · 28 code · 16 blank · 82 comment · 0 complexity · 41577695f190fc84473840ef6fff71c6 MD5 · raw file

  1. ////////////////////////////////////////////////////////////
  2. //
  3. // SFML - Simple and Fast Multimedia Library
  4. // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
  5. //
  6. // This software is provided 'as-is', without any express or implied warranty.
  7. // In no event will the authors be held liable for any damages arising from the use of this software.
  8. //
  9. // Permission is granted to anyone to use this software for any purpose,
  10. // including commercial applications, and to alter it and redistribute it freely,
  11. // subject to the following restrictions:
  12. //
  13. // 1. The origin of this software must not be misrepresented;
  14. // you must not claim that you wrote the original software.
  15. // If you use this software in a product, an acknowledgment
  16. // in the product documentation would be appreciated but is not required.
  17. //
  18. // 2. Altered source versions must be plainly marked as such,
  19. // and must not be misrepresented as being the original software.
  20. //
  21. // 3. This notice may not be removed or altered from any source distribution.
  22. //
  23. ////////////////////////////////////////////////////////////
  24. #ifndef SFML_GLXCONTEXT_HPP
  25. #define SFML_GLXCONTEXT_HPP
  26. ////////////////////////////////////////////////////////////
  27. // Headers
  28. ////////////////////////////////////////////////////////////
  29. #include <SFML/Window/GlContext.hpp>
  30. #include <X11/Xlib.h>
  31. #include <GL/glx.h>
  32. namespace sf
  33. {
  34. namespace priv
  35. {
  36. ////////////////////////////////////////////////////////////
  37. /// \brief Linux (GLX) implementation of OpenGL contexts
  38. ///
  39. ////////////////////////////////////////////////////////////
  40. class GlxContext : public GlContext
  41. {
  42. public :
  43. ////////////////////////////////////////////////////////////
  44. /// \brief Create a new context, not associated to a window
  45. ///
  46. /// \param shared Context to share the new one with (can be NULL)
  47. ///
  48. ////////////////////////////////////////////////////////////
  49. GlxContext(GlxContext* shared);
  50. ////////////////////////////////////////////////////////////
  51. /// \brief Create a new context attached to a window
  52. ///
  53. /// \param shared Context to share the new one with (can be NULL)
  54. /// \param owner Pointer to the owner window
  55. /// \param bitsPerPixel Pixel depth (in bits per pixel)
  56. /// \param settings Creation parameters
  57. ///
  58. ////////////////////////////////////////////////////////////
  59. GlxContext(GlxContext* shared, const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings);
  60. ////////////////////////////////////////////////////////////
  61. /// \brief Destructor
  62. ///
  63. ////////////////////////////////////////////////////////////
  64. ~GlxContext();
  65. ////////////////////////////////////////////////////////////
  66. /// \brief Activate the context as the current target
  67. /// for rendering
  68. ///
  69. /// \return True on success, false if any error happened
  70. ///
  71. ////////////////////////////////////////////////////////////
  72. virtual bool MakeCurrent();
  73. ////////////////////////////////////////////////////////////
  74. /// \brief Display what has been rendered to the context so far
  75. ///
  76. ////////////////////////////////////////////////////////////
  77. virtual void Display();
  78. ////////////////////////////////////////////////////////////
  79. /// \brief Enable or disable vertical synchronization
  80. ///
  81. /// Activating vertical synchronization will limit the number
  82. /// of frames displayed to the refresh rate of the monitor.
  83. /// This can avoid some visual artifacts, and limit the framerate
  84. /// to a good value (but not constant across different computers).
  85. ///
  86. /// \param enabled : True to enable v-sync, false to deactivate
  87. ///
  88. ////////////////////////////////////////////////////////////
  89. virtual void UseVerticalSync(bool enabled);
  90. private :
  91. ////////////////////////////////////////////////////////////
  92. /// \brief Create the context
  93. ///
  94. /// \param shared Context to share the new one with (can be NULL)
  95. /// \param bitsPerPixel Pixel depth, in bits per pixel
  96. /// \param settings Creation parameters
  97. ///
  98. ////////////////////////////////////////////////////////////
  99. void CreateContext(GlxContext* shared, unsigned int bitsPerPixel, const ContextSettings& settings);
  100. ////////////////////////////////////////////////////////////
  101. // Member data
  102. ////////////////////////////////////////////////////////////
  103. ::Display* myDisplay; ///< Connection to the X server
  104. ::Window myWindow; ///< Window to which the context is attached
  105. GLXContext myContext; ///< OpenGL context
  106. bool myOwnsWindow; ///< Do we own the window associated to the context?
  107. };
  108. } // namespace priv
  109. } // namespace sf
  110. #endif // SFML_GLXCONTEXT_HPP