00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef GLCONTEXTSAVE_H 00011 #define GLCONTEXTSAVE_H 00012 00013 class QGLContext; 00014 class QGLWidget; 00015 00016 /** 00017 * A class for saving and restoring the current OpenGL context. 00018 * When created, the GlContextSave object records the current OpenGL context. 00019 * When destroyed, it makes the recorded context current again, regardless of 00020 * changes that have occurred while the GlContextSave object existed. 00021 */ 00022 class GlContextSave 00023 { 00024 public: 00025 /** 00026 * Records the current OpenGL context. 00027 */ 00028 GlContextSave(); 00029 00030 /** 00031 * Records the current OpenGL context and makes the specified context current. 00032 * 00033 * @param pWidget 00034 * The widget containing the context to make current. 00035 * If \c NULL is specified, the current context will not be changed. 00036 */ 00037 GlContextSave(QGLWidget* pWidget); 00038 00039 /** 00040 * Records the current OpenGL context and makes the specified context current. 00041 * 00042 * @param pContext 00043 * The context to make current. If \c NULL is specified, the current context will not be changed. 00044 */ 00045 GlContextSave(QGLContext* pContext); 00046 00047 /** 00048 * Restores the current OpenGL context to the one that the constructor 00049 * recorded. 00050 */ 00051 ~GlContextSave(); 00052 00053 private: 00054 GlContextSave(const GlContextSave& rhs); 00055 GlContextSave& operator=(const GlContextSave& rhs); 00056 00057 QGLContext* const mpCurrentContext; 00058 }; 00059 00060 #endif