Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLQt/src/ICLQt/GLContext.h ** 00010 ** Module : ICLQt ** 00011 ** Authors: Christof Elbrechter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.GPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 00032 #pragma once 00033 00034 namespace icl{ 00035 namespace qt{ 00036 00038 00050 class GLContext{ 00051 public: 00053 typedef void* Handle; 00054 00055 protected: 00056 00058 Handle handle; 00059 00061 bool isGLX; 00062 00064 long unsigned int pbuffer; 00065 00067 Handle display; 00068 00070 static GLContext current_glx_context; 00071 00072 public: 00074 GLContext():handle(0),isGLX(0){} 00075 00077 00078 GLContext(Handle handle, bool isGLX, long unsigned int pbuffer=0, Handle display=0): 00079 handle(handle),isGLX(isGLX),pbuffer(pbuffer),display(display){} 00080 00082 static GLContext currentContext(); 00083 00085 00087 static void set_current_glx_context(Handle handle, long unsigned int pbuffer, Handle display); 00088 00089 // unsets the current GLXContext 00092 static void unset_current_glx_context(); 00093 00095 void makeCurrent() const; 00096 00097 00099 inline bool isNull() const { return !handle; } 00100 00102 inline operator bool() const { return !isNull(); } 00103 00104 00105 // lt comparison (for strict ordering) 00106 inline bool operator<(const GLContext &other) const{ 00107 if(isGLX == other.isGLX){ 00108 return handle < other.handle; 00109 }else return isGLX; 00110 } 00111 00113 inline bool operator==(const GLContext &other) const{ 00114 return handle == other.handle && isGLX == other.isGLX; 00115 } 00116 00117 }; 00118 } // namespace qt 00119 } 00120