Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:58:15

0001 ////////////////////////////////////////////////////////////
0002 //
0003 // SFML - Simple and Fast Multimedia Library
0004 // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
0005 //
0006 // This software is provided 'as-is', without any express or implied warranty.
0007 // In no event will the authors be held liable for any damages arising from the use of this software.
0008 //
0009 // Permission is granted to anyone to use this software for any purpose,
0010 // including commercial applications, and to alter it and redistribute it freely,
0011 // subject to the following restrictions:
0012 //
0013 // 1. The origin of this software must not be misrepresented;
0014 //    you must not claim that you wrote the original software.
0015 //    If you use this software in a product, an acknowledgment
0016 //    in the product documentation would be appreciated but is not required.
0017 //
0018 // 2. Altered source versions must be plainly marked as such,
0019 //    and must not be misrepresented as being the original software.
0020 //
0021 // 3. This notice may not be removed or altered from any source distribution.
0022 //
0023 ////////////////////////////////////////////////////////////
0024 
0025 #ifndef SFML_GLRESOURCE_HPP
0026 #define SFML_GLRESOURCE_HPP
0027 
0028 ////////////////////////////////////////////////////////////
0029 // Headers
0030 ////////////////////////////////////////////////////////////
0031 #include <SFML/Window/Export.hpp>
0032 #include <SFML/System/NonCopyable.hpp>
0033 
0034 
0035 namespace sf
0036 {
0037 
0038 class Context;
0039 
0040 typedef void(*ContextDestroyCallback)(void*);
0041 
0042 ////////////////////////////////////////////////////////////
0043 /// \brief Base class for classes that require an OpenGL context
0044 ///
0045 ////////////////////////////////////////////////////////////
0046 class SFML_WINDOW_API GlResource
0047 {
0048 protected:
0049 
0050     ////////////////////////////////////////////////////////////
0051     /// \brief Default constructor
0052     ///
0053     ////////////////////////////////////////////////////////////
0054     GlResource();
0055 
0056     ////////////////////////////////////////////////////////////
0057     /// \brief Destructor
0058     ///
0059     ////////////////////////////////////////////////////////////
0060     ~GlResource();
0061 
0062     ////////////////////////////////////////////////////////////
0063     /// \brief Register a function to be called when a context is destroyed
0064     ///
0065     /// This is used for internal purposes in order to properly
0066     /// clean up OpenGL resources that cannot be shared between
0067     /// contexts.
0068     ///
0069     /// \param callback Function to be called when a context is destroyed
0070     /// \param arg      Argument to pass when calling the function
0071     ///
0072     ////////////////////////////////////////////////////////////
0073     static void registerContextDestroyCallback(ContextDestroyCallback callback, void* arg);
0074 
0075     ////////////////////////////////////////////////////////////
0076     /// \brief RAII helper class to temporarily lock an available context for use
0077     ///
0078     ////////////////////////////////////////////////////////////
0079     class SFML_WINDOW_API TransientContextLock : NonCopyable
0080     {
0081     public:
0082         ////////////////////////////////////////////////////////////
0083         /// \brief Default constructor
0084         ///
0085         ////////////////////////////////////////////////////////////
0086         TransientContextLock();
0087 
0088         ////////////////////////////////////////////////////////////
0089         /// \brief Destructor
0090         ///
0091         ////////////////////////////////////////////////////////////
0092         ~TransientContextLock();
0093     };
0094 };
0095 
0096 } // namespace sf
0097 
0098 
0099 #endif // SFML_GLRESOURCE_HPP
0100 
0101 ////////////////////////////////////////////////////////////
0102 /// \class sf::GlResource
0103 /// \ingroup window
0104 ///
0105 /// This class is for internal use only, it must be the base
0106 /// of every class that requires a valid OpenGL context in
0107 /// order to work.
0108 ///
0109 ////////////////////////////////////////////////////////////