PageRenderTime 14ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 25#ifndef SFML_GLXCONTEXT_HPP
 26#define SFML_GLXCONTEXT_HPP
 27
 28////////////////////////////////////////////////////////////
 29// Headers
 30////////////////////////////////////////////////////////////
 31#include <SFML/Window/GlContext.hpp>
 32#include <X11/Xlib.h>
 33#include <GL/glx.h>
 34
 35
 36namespace sf
 37{
 38namespace priv
 39{
 40////////////////////////////////////////////////////////////
 41/// \brief Linux (GLX) implementation of OpenGL contexts
 42///
 43////////////////////////////////////////////////////////////
 44class GlxContext : public GlContext
 45{
 46public :
 47
 48    ////////////////////////////////////////////////////////////
 49    /// \brief Create a new context, not associated to a window
 50    ///
 51    /// \param shared Context to share the new one with (can be NULL)
 52    ///
 53    ////////////////////////////////////////////////////////////
 54    GlxContext(GlxContext* shared);
 55
 56    ////////////////////////////////////////////////////////////
 57    /// \brief Create a new context attached to a window
 58    ///
 59    /// \param shared       Context to share the new one with (can be NULL)
 60    /// \param owner        Pointer to the owner window
 61    /// \param bitsPerPixel Pixel depth (in bits per pixel)
 62    /// \param settings     Creation parameters
 63    ///
 64    ////////////////////////////////////////////////////////////
 65    GlxContext(GlxContext* shared, const WindowImpl* owner, unsigned int bitsPerPixel, const ContextSettings& settings);
 66
 67    ////////////////////////////////////////////////////////////
 68    /// \brief Destructor
 69    ///
 70    ////////////////////////////////////////////////////////////
 71    ~GlxContext();
 72
 73    ////////////////////////////////////////////////////////////
 74    /// \brief Activate the context as the current target
 75    ///        for rendering
 76    ///
 77    /// \return True on success, false if any error happened
 78    ///
 79    ////////////////////////////////////////////////////////////
 80    virtual bool MakeCurrent();
 81
 82    ////////////////////////////////////////////////////////////
 83    /// \brief Display what has been rendered to the context so far
 84    ///
 85    ////////////////////////////////////////////////////////////
 86    virtual void Display();
 87
 88    ////////////////////////////////////////////////////////////
 89    /// \brief Enable or disable vertical synchronization
 90    ///
 91    /// Activating vertical synchronization will limit the number
 92    /// of frames displayed to the refresh rate of the monitor.
 93    /// This can avoid some visual artifacts, and limit the framerate
 94    /// to a good value (but not constant across different computers).
 95    ///
 96    /// \param enabled : True to enable v-sync, false to deactivate
 97    ///
 98    ////////////////////////////////////////////////////////////
 99    virtual void UseVerticalSync(bool enabled);
100
101private :
102
103    ////////////////////////////////////////////////////////////
104    /// \brief Create the context
105    ///
106    /// \param shared       Context to share the new one with (can be NULL)
107    /// \param bitsPerPixel Pixel depth, in bits per pixel
108    /// \param settings     Creation parameters
109    ///
110    ////////////////////////////////////////////////////////////
111    void CreateContext(GlxContext* shared, unsigned int bitsPerPixel, const ContextSettings& settings);
112
113    ////////////////////////////////////////////////////////////
114    // Member data
115    ////////////////////////////////////////////////////////////
116    ::Display* myDisplay;    ///< Connection to the X server
117    ::Window   myWindow;     ///< Window to which the context is attached
118    GLXContext myContext;    ///< OpenGL context
119    bool       myOwnsWindow; ///< Do we own the window associated to the context?
120};
121
122} // namespace priv
123
124} // namespace sf
125
126#endif // SFML_GLXCONTEXT_HPP