csplugincommon/opengl/glcanvascommon.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 1998 by Jorrit Tyberghein 00003 (C) 2012 by Frank Richter 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_GLCANVASCOMMON_H__ 00021 #define __CS_GLCANVASCOMMON_H__ 00022 00027 #if defined(CS_OPENGL_PATH) 00028 #include CS_HEADER_GLOBAL(CS_OPENGL_PATH,gl.h) 00029 #else 00030 #include <GL/gl.h> 00031 #endif 00032 00033 #include "iutil/event.h" 00034 #include "csplugincommon/iopengl/canvas.h" 00035 #include "csutil/scf.h" 00036 #include "csplugincommon/canvas/canvascommon.h" 00037 #include "driverdb.h" 00038 00039 #include "csextern_gl.h" 00040 00044 namespace CS 00045 { 00046 namespace PluginCommon 00047 { 00048 namespace GL 00049 { 00053 class CS_CSPLUGINCOMMON_GL_EXPORT CanvasCommonBase : 00054 public virtual PluginCommon::CanvasCommonBase, 00055 public virtual iOpenGLCanvas 00056 { 00057 public: 00058 enum GLPixelFormatValue 00059 { 00060 glpfvColorBits = 0, 00061 glpfvAlphaBits, 00062 glpfvDepthBits, 00063 glpfvStencilBits, 00064 glpfvAccumColorBits, 00065 glpfvAccumAlphaBits, 00066 glpfvMultiSamples, 00067 00068 glpfvValueCount 00069 }; 00070 typedef int GLPixelFormat[glpfvValueCount]; 00071 protected: 00072 class CS_CSPLUGINCOMMON_GL_EXPORT csGLPixelFormatPicker 00073 { 00074 CanvasCommonBase* parent; 00075 00076 /* 00077 size_t nextValueIndices[glpfvValueCount]; 00078 csArray<int> values[glpfvValueCount]; 00079 00080 00081 char* order; 00082 size_t orderPos; 00083 size_t orderNum;*/ 00084 00085 // Hold properties for a single pixelformat property 00086 struct PixelFormatPropertySet 00087 { 00088 GLPixelFormatValue valueType; 00089 size_t nextIndex; 00090 size_t firstIndex; 00091 csArray<int> possibleValues; 00092 }; 00093 00094 /* Pixel format properties, however this is _not_ indexed by 00095 GLPixelFormatValue but sorted by order */ 00096 PixelFormatPropertySet pixelFormats[glpfvValueCount]; 00097 00098 // Remapping table from real GLPixelFormatValue to index in table above 00099 size_t pixelFormatIndexTable[glpfvValueCount]; 00100 00101 GLPixelFormat currentValues; 00102 bool currentValid; 00103 00104 void ReadStartValues (iConfigFile* config); 00105 void ReadPickerValues (iConfigFile* config); 00106 void ReadPickerValue (const char* valuesStr, csArray<int>& values); 00107 void SetInitialIndices (); 00108 void SetupIndexTable (const char* orderStr); 00109 bool PickNextFormat (); 00110 public: 00111 csGLPixelFormatPicker (CanvasCommonBase* parent); 00112 ~csGLPixelFormatPicker (); 00113 00114 void Reset(); 00115 bool GetNextFormat (GLPixelFormat& format); 00116 }; 00117 friend class csGLPixelFormatPicker; 00118 00119 GLPixelFormat currentFormat; 00120 00121 void GetPixelFormatString (const GLPixelFormat& format, csString& str); 00122 00123 void Report (int severity, const char* msg, ...); 00124 public: 00129 CanvasCommonBase (); 00130 00132 virtual ~CanvasCommonBase (); 00133 00134 /* 00135 * You must supply all the functions not supplied here, such as 00136 * SetMouseCursor etc. Note also that even though Initialize, Open, 00137 * and Close are supplied here, you must still override these functions 00138 * for your own subclass to make system-specific calls for creating and 00139 * showing windows, etc. 00140 */ 00141 00142 virtual bool CanvasOpen (); 00143 00144 virtual void CanvasClose (); 00145 00146 bool CanvasResize (int width, int height); 00147 00150 int GetMultiSamples() { return currentFormat[glpfvMultiSamples]; } 00152 }; 00153 } // namespace GL 00154 } // namespace PluginCommon 00155 } // namespace CS 00156 00159 #endif // __CS_GLCANVASCOMMON_H__
Generated for Crystal Space 2.1 by doxygen 1.6.1
