-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re #3746. A quick fix prventing calling a gl command outside OpenGL
- Loading branch information
1 parent
89987ea
commit ff67170
Showing
5 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
Code/Mantid/Framework/Geometry/inc/MantidGeometry/Rendering/OpenGLContext.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#ifndef OPENGL_CONTEXT_H | ||
#define OPENGL_CONTEXT_H | ||
|
||
#include "MantidGeometry/DllConfig.h" | ||
#include "MantidKernel/SingletonHolder.h" | ||
#include "MantidKernel/Logger.h" | ||
namespace Mantid | ||
{ | ||
|
||
namespace Geometry | ||
{ | ||
/** | ||
\class OpenGLContext | ||
\brief Keep infomation about the status of OpenGL. | ||
\author Roman Tolchenov, Tessella plc | ||
\date 14/11/2011 | ||
\version 1.0 | ||
This is a singleton class to keep information about the current status of OpenGL. | ||
The minimum information it should provide is whether OpenGL is avalable and it is safe and meaninful | ||
to issue an gl command. | ||
It is a quick fix solution to a problem that on some systems calling gl functions outside OpenGL context | ||
can crash Mantid. | ||
Copyright © 2008 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid> | ||
*/ | ||
class MANTID_GEOMETRY_DLL OpenGLContextImpl | ||
{ | ||
public: | ||
/// True if OpenGL is avalable | ||
bool isAvailable() const {return m_isOn;} | ||
/// Set avalability of OpenGL. Must be updated by the GL widget. | ||
void setAvalable(bool yes) {m_isOn = yes;} | ||
private: | ||
friend struct Mantid::Kernel::CreateUsingNew<OpenGLContextImpl>; | ||
|
||
OpenGLContextImpl(); ///< Constructor | ||
OpenGLContextImpl(const OpenGLContextImpl&); ///< Private copy constructor | ||
OpenGLContextImpl& operator=(const OpenGLContextImpl&); ///< Private assignment operator | ||
~OpenGLContextImpl(){} ///< Destructor | ||
|
||
bool m_isOn; ///< flag indicating whether OpenGL is avalable or not | ||
static Kernel::Logger& g_log; ///< The logger | ||
|
||
}; | ||
|
||
///Forward declaration of a specialisation of SingletonHolder for OpenGLContextImpl (needed for dllexport/dllimport) and a typedef for it. | ||
#ifdef _WIN32 | ||
// this breaks new namespace declaraion rules; need to find a better fix | ||
template class MANTID_GEOMETRY_DLL Mantid::Kernel::SingletonHolder<OpenGLContextImpl>; | ||
#endif /* _WIN32 */ | ||
typedef MANTID_GEOMETRY_DLL Mantid::Kernel::SingletonHolder<OpenGLContextImpl> OpenGLContext; | ||
|
||
} // NAMESPACE Geometry | ||
|
||
} // NAMESPACE Mantid | ||
|
||
#endif // OPENGL_CONTEXT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Code/Mantid/Framework/Geometry/src/Rendering/OpenGLContext.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "MantidGeometry/Rendering/OpenGLContext.h" | ||
|
||
namespace Mantid | ||
{ | ||
namespace Geometry | ||
{ | ||
|
||
Kernel::Logger& OpenGLContextImpl::g_log(Kernel::Logger::get("OpenGLContextImpl")); | ||
|
||
OpenGLContextImpl::OpenGLContextImpl(): | ||
m_isOn(false) | ||
{ | ||
} | ||
|
||
|
||
} // Geometry | ||
} // Mantid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters