csplugincommon/opengl/glcommon2d.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 1998 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_GLCOMMON2D_H__ 00020 #define __CS_GLCOMMON2D_H__ 00021 00026 #if defined(CS_OPENGL_PATH) 00027 #include CS_HEADER_GLOBAL(CS_OPENGL_PATH,gl.h) 00028 #else 00029 #include <GL/gl.h> 00030 #endif 00031 00032 #include "csextern_gl.h" 00033 #include "csutil/scf.h" 00034 #include "csplugincommon/canvas/graph2d.h" 00035 #include "csplugincommon/iopengl/driverdb.h" 00036 #include "glfontcache.h" 00037 #include "glstates.h" 00038 #include "glextmanager.h" 00039 #include "glss.h" 00040 #include "driverdb.h" 00041 #include "glcanvascommon.h" 00042 00046 namespace CS 00047 { 00048 namespace PluginCommon 00049 { 00050 namespace GL 00051 { 00063 class CS_CSPLUGINCOMMON_GL_EXPORT Graphics2DCommon : 00064 public virtual CS::PluginCommon::Graphics2DCommon, 00065 public virtual iOpenGLDriverDatabase 00066 { 00067 protected: 00068 friend class ::csGLScreenShot; 00069 friend class ::csGLFontCache; 00070 00072 csGLStateCache* statecache; 00073 csGLStateCacheContext *statecontext; 00074 00075 bool hasRenderTarget; 00076 00078 void DecomposeColor (int iColor, GLubyte &oR, GLubyte &oG, GLubyte &oB, GLubyte &oA); 00080 void DecomposeColor (int iColor, float &oR, float &oG, float &oB, float &oA); 00082 void setGLColorfromint (int color); 00083 00084 csGLScreenShot* ssPool; 00085 00086 csGLScreenShot* GetScreenShot (); 00087 void RecycleScreenShot (csGLScreenShot* shot); 00088 00090 csGLExtensionManager ext; 00092 //int multiSamples; 00094 bool multiFavorQuality; 00096 csGLDriverDatabase driverdb; 00097 bool useCombineTE; 00098 00099 void Report (int severity, const char* msg, ...); 00100 00102 void OpenDriverDB (const char* phase = 0); 00103 00108 bool DrawLineNearClip (csVector3 & v1, csVector3 & v2); 00109 public: 00110 virtual const char* GetRendererString (const char* str); 00111 virtual const char* GetVersionString (const char* ver); 00112 00113 virtual const char* GetHWRenderer(); 00114 virtual const char* GetHWGLVersion(); 00115 virtual const char* GetHWVendor(); 00116 00121 Graphics2DCommon (); 00122 00124 virtual ~Graphics2DCommon (); 00125 00126 /* 00127 * You must supply all the functions not supplied here, such as 00128 * SetMouseCursor etc. Note also that even though Initialize, Open, 00129 * and Close are supplied here, you must still override these functions 00130 * for your own subclass to make system-specific calls for creating and 00131 * showing windows, etc. 00132 */ 00133 00135 virtual bool Initialize (iObjectRegistry *object_reg); 00136 00142 virtual bool Open (); 00143 00144 virtual void Close (); 00145 00146 virtual void SetClipRect (int xmin, int ymin, int xmax, int ymax); 00147 00152 virtual bool BeginDraw (); 00154 virtual void FinishDraw (); 00155 00157 virtual bool Resize (int width, int height); 00158 00159 00160 /* 00161 * the remaining functions here do not need to be overridden when 00162 * inheriting from this class 00163 */ 00164 00166 virtual void Clear (int color); 00167 00169 virtual void DrawLine (float x1, float y1, float x2, float y2, int color); 00171 virtual void DrawLineProjected (const csVector3& v1, const csVector3& v2, 00172 float fov, int color); 00174 virtual void DrawLineProjected (const csVector3& v1, const csVector3& v2, 00175 const CS::Math::Matrix4& projection, int color); 00177 virtual void DrawBoxProjected (const csBox3& box, const csTransform& object2camera, 00178 const CS::Math::Matrix4& projection, int color); 00180 virtual void DrawBox (int x, int y, int w, int h, int color); 00182 virtual void DrawPixel (int x, int y, int color); 00184 virtual void DrawPixels (csPixelCoord const* pixels, int num_pixels, 00185 int color); 00187 virtual void Blit (int x, int y, int w, int h, unsigned char const* data); 00188 00190 virtual void GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB); 00192 virtual void GetPixel (int x, int y, uint8 &oR, uint8 &oG, uint8 &oB, uint8 &oA); 00193 00195 virtual csPtr<iImage> ScreenShot (); 00196 00198 virtual bool GetDoubleBufferState () 00199 { return false; } 00201 virtual bool DoubleBuffer (bool Enable) 00202 { return !Enable; } 00203 00205 virtual bool PerformExtensionV (char const* command, va_list); 00206 00208 virtual bool DebugCommand (const char* cmd); 00209 00210 void SetViewport (int left, int top, int width, int height); 00211 00214 void ReadDatabase (iDocumentNode* dbRoot, 00215 int configPriority = iConfigManager::ConfigPriorityPlugin + 20, 00216 const char* phase = 0) 00217 { 00218 driverdb.Open (this, dbRoot, phase, configPriority); 00219 } 00221 }; 00222 } // namespace GL 00223 } // namespace PluginCommon 00224 } // namespace CS 00225 00239 class CS_CSPLUGINCOMMON_GL_EXPORT csGraphics2DGLCommon : 00240 public scfImplementationExt2<csGraphics2DGLCommon, 00241 csGraphics2D, 00242 scfFakeInterface<iOpenGLDriverDatabase>, 00243 scfFakeInterface<iOpenGLCanvas> >, 00244 public virtual CS::PluginCommon::GL::Graphics2DCommon, 00245 public virtual CS::PluginCommon::GL::CanvasCommonBase 00246 { 00247 protected: 00248 iGraphicsCanvas* GetCanvas() { return this; } 00249 public: 00254 csGraphics2DGLCommon (iBase *iParent); 00255 00257 virtual ~csGraphics2DGLCommon (); 00258 00259 /* 00260 * You must supply all the functions not supplied here, such as 00261 * SetMouseCursor etc. Note also that even though Initialize, Open, 00262 * and Close are supplied here, you must still override these functions 00263 * for your own subclass to make system-specific calls for creating and 00264 * showing windows, etc. 00265 */ 00266 00268 virtual bool Initialize (iObjectRegistry *object_reg); 00269 }; 00270 00271 #endif // __CS_GLCOMMON2D_H__
Generated for Crystal Space 2.1 by doxygen 1.6.1
