| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /********************************************************************** 00002 VRS - The Virtual Rendering System 00003 Copyright (C) 2001 Computer Graphics Systems Group at the 00004 Hasso-Plattner-Institute, Potsdam, Germany. 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 This library is distributed in the hope that it will be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 See the GNU Lesser General Public License for more details. 00013 You should have received a copy of the GNU Lesser+ General Public 00014 License along with this library; if not, write to the FreeSoftware 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA, 02111-1307, USA. 00016 **********************************************************************/ 00017 // $Id: offscreencanvasgl.h 6632 2009-01-15 10:55:19Z Manuel_Wellmann $ 00018 // $Date: 2009-01-15 11:55:19 +0100 (Thu, 15 Jan 2009) $ 00019 // $Revision: 6632 $ 00020 // $State$ 00021 // $Author: Manuel_Wellmann $ 00022 // 00023 // $Log$ 00024 // Revision 1.14 2005/01/03 01:43:09 klimetschek 00025 // - modified win32 project layout, splitted vrs.vcproj into vrs_container, vrs_core, vrs_sg, vrs_image, vrs_opengl and vrs_io 00026 // - removed vrs.vcproj 00027 // minor things: 00028 // - added all glutexamples to vrs4glut.sln 00029 // - fixed some problems in glutexamples 00030 // - removed all project references from all VS projects (using solution wide project dependencies instead) 00031 // 00032 // Revision 1.13 2004/11/03 14:45:06 saar 00033 // Class comment changed (Doxygen style) 00034 // 00035 // Revision 1.12 2004/03/12 16:28:40 baumann 00036 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00037 // 00038 // Revision 1.11 2003/12/11 15:11:07 kirsch 00039 // made prepareRedisplay() and finishRedisplay() public 00040 // 00041 // Revision 1.10 2003/11/07 14:19:25 kirsch 00042 // removed leading underscore from include guards 00043 // 00044 // Revision 1.9 2003/10/27 13:40:38 skirsch 00045 // added canvas query functionality to the engine, restructured canvas redisplay, and added dpi query functionality to the canvas 00046 // 00047 // Revision 1.8 2003/10/21 16:25:29 baumann 00048 // callback removed from method largeScaleSnapshot(); using VRS::Progress instead 00049 // 00050 // Revision 1.7 2002/11/01 11:43:05 kirsch 00051 // windows impl and includes cleanup 00052 // 00053 // Revision 1.6 2002/10/24 15:49:19 kirsch 00054 // added missing getProperties-method 00055 // 00056 // Revision 1.5 2002/10/24 14:15:25 kirsch 00057 // made canvas width and height unsigned 00058 // added getProperties to GLCanvas and subclasses 00059 // 00060 // Revision 1.4 2002/09/25 11:41:53 baumann 00061 // using GLCanvas:: prefix for CanvasProperties 00062 // 00063 // Revision 1.3 2002/09/24 11:18:20 baumann 00064 // - renamed GLCanvas::copy() to GLCanvas::snapshot() 00065 // - renamed GLCanvas::renderToImage() to GLCanvas::largeScaleSnapshot() 00066 // - argument "format" changed to "buffer" using GLCanvas::RGB_BUFFER, 00067 // GLCanvas::RGBA_BUFFER, GLCanvas::STENCIL_BUFFER, or GLCanvas::DEPTH_BUFFER 00068 // as possible values (for methods GLCanvas::snapshot() and 00069 // GLCanvas::largeScaleSnapshot()) 00070 // - argument "frontBuffer" changed to "readBuffer" using GLCanvas::CURRENT_BUFFER, 00071 // GLCanvas::FRONT_BUFFER, and GLCanvas::BACK_BUFFER as possible values (for 00072 // methods GLCanvas::snapshot() and GLCanvas::largeScaleSnapshot()) 00073 // - methods FrameBufferGL::getFormat() and FrameBufferGL::setFormat() renamed 00074 // to FrameBufferGL::getBuffer() and FrameBufferGL::setBuffer() using the 00075 // same values described above 00076 // - method EngineGL::captureFrame() removed (use one of the GLCanvas::snapshot() 00077 // methods instead) 00078 // 00079 // Revision 1.2 2002/09/19 07:44:19 kirsch 00080 // added GLCanvas::create() and GLCanvas::destroy() 00081 // all sub-classes use those methods to create and destroy engine and processor 00082 // 00083 // Revision 1.1 2002/08/22 14:41:55 baumann 00084 // renamed class OffscreenCanvas to OffscreenCanvasGL 00085 // and moved it from "vrs/sg" to "vrs/opengl" 00086 // 00087 // Revision 1.16 2002/08/22 14:07:54 baumann 00088 // using new method GLCanvas::largeScaleSnapshot() 00089 // 00090 // Revision 1.15 2002/06/28 09:47:10 baumann 00091 // class Texture, TextureOldGL and TexturePainterOldGL removed 00092 // 00093 // Revision 1.14 2002/05/26 12:07:41 baumann 00094 // method prepare() is now public (was private) 00095 // 00096 // Revision 1.13 2002/03/03 21:44:26 kosta 00097 // VRS_TYPEINFO-macro rewritten 00098 // 00099 // Revision 1.12 2002/02/19 10:34:20 kosta 00100 // undone all changes since 2002-02-15 00101 // 00102 // Revision 1.9 2002/01/15 16:25:55 kosta 00103 // macros rewritten for a better namespace support 00104 // 00105 // Revision 1.8 2002/01/07 07:33:02 kirsch 00106 // Removed Windows-style line endings 00107 // 00108 // Revision 1.7 2002/01/04 13:09:43 doellner 00109 // Redesign of canvas classes. Studio merged into Canvas, and removed. 00110 // 00111 // Revision 1.6 2001/11/13 16:36:31 kirsch 00112 // changed line feed to unix style (removed control-M) 00113 // 00114 // Revision 1.5 2001/08/29 12:09:10 kirsch 00115 // removed background color from canvas, use BackgroundGL instead 00116 // 00117 // Revision 1.4 2001/08/27 08:44:40 kersting 00118 // added OpenGLCanvas base class 00119 // 00120 // Revision 1.3 2001/07/30 13:14:00 kirsch 00121 // fixed typos in comments 00122 // 00123 // Revision 1.2 2001/07/02 10:14:29 kersting 00124 // changes due to enum definition 00125 // 00126 // Revision 1.1.1.1 2001/06/08 08:09:21 kirsch 00127 // imported alpha-version by olli 00128 // 00129 00130 #ifndef VRS_OPENGL_OFFSCREENCANVASGL_H_ 00131 #define VRS_OPENGL_OFFSCREENCANVASGL_H_ 00132 00133 #include <vrs/opengl/glcanvas.h> 00134 00135 namespace VRS { 00136 00137 class Image; 00138 00140 class VRS_CORE_API OffscreenCanvasImplBase : public SharedObj 00141 { 00142 public: 00143 virtual bool isInitialized() const = 0; 00144 virtual void destroyContext() = 0; 00145 virtual void makeContextCurrent() = 0; 00146 virtual void releaseContext() = 0; 00147 virtual void createContext(unsigned int width, unsigned int height) = 0; 00148 00149 virtual unsigned int width() const = 0; 00150 virtual unsigned int height() const = 0; 00151 00152 VRS_TYPEINFO(OffscreenCanvasImplBase, SharedObj); 00153 }; 00154 00156 class VRS_CORE_API OffscreenCanvasFactoryBase : public SharedObj 00157 { 00158 public: 00159 virtual SO<OffscreenCanvasImplBase> create() const = 0; 00160 00161 VRS_TYPEINFO(OffscreenCanvasFactoryBase, SharedObj); 00162 }; 00163 00165 00172 class VRS_CORE_API OffscreenCanvasGL : public GLCanvas { 00173 public: 00174 OffscreenCanvasGL(unsigned int width, unsigned int height, bool luminanceOnly = false); 00175 OffscreenCanvasGL(Image* targetImage); 00176 virtual ~OffscreenCanvasGL(); 00177 00178 virtual Image* getTarget() const; 00179 virtual void setTarget(Image* targetImage); 00183 virtual bool prepareRedisplay(); 00184 virtual void finishRedisplay(); 00185 00186 virtual void makeContextCurrent(); 00187 virtual void releaseContext(); 00189 00190 virtual void setSize(unsigned int width, unsigned int height); 00191 virtual unsigned int getWidth() const; 00192 virtual unsigned int getHeight() const; 00195 virtual int getProperties() const; 00198 virtual bool largeScaleSnapshot(Image* destination, 00199 GLCanvas::CanvasProperties buffer = GLCanvas::RGB_BUFFER); 00200 00202 static void setOffscreenCanvasFactory( 00203 const SO<OffscreenCanvasFactoryBase>& factory); 00204 00206 static SO<OffscreenCanvasFactoryBase> getOffscreenCanvasFactory(); 00207 00208 VRS_TYPEINFO(OffscreenCanvasGL, GLCanvas); 00209 00210 00211 00212 private: 00213 SO<Image> target_; 00214 unsigned int width_; 00215 unsigned int height_; 00216 bool mapped_; 00217 bool luminanceOnly_; 00218 00219 SO<OffscreenCanvasImplBase> impl_; 00220 00221 static SO<OffscreenCanvasImplBase> createImpl(); 00222 static SO<OffscreenCanvasFactoryBase> g_factory; 00223 }; 00224 00225 } // namespace VRS 00226 00227 #endif // VRS_OPENGL_OFFSCREENCANVASGL_H_