00001 /**************************************************************************\ 00002 * 00003 * This file is part of the Coin 3D visualization library. 00004 * Copyright (C) 1998-2002 by Systems in Motion. All rights reserved. 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * version 2.1 as published by the Free Software Foundation. See the 00009 * file LICENSE.LGPL at the root directory of the distribution for 00010 * more details. 00011 * 00012 * If you want to use Coin for applications not compatible with the 00013 * LGPL, please contact SIM to acquire a Professional Edition license. 00014 * 00015 * Systems in Motion, Prof Brochs gate 6, 7030 Trondheim, NORWAY 00016 * http://www.sim.no support@sim.no Voice: +47 22114160 Fax: +47 22207097 00017 * 00018 \**************************************************************************/ 00019 00020 #ifndef COIN_SOOFFSCREENRENDERER_H 00021 #define COIN_SOOFFSCREENRENDERER_H 00022 00023 #include <Inventor/SbViewportRegion.h> 00024 #include <Inventor/SbColor.h> 00025 #include <Inventor/lists/SbList.h> 00026 #include <Inventor/SbString.h> 00027 #include <Inventor/SbName.h> 00028 00029 #include <stdio.h> 00030 00031 class SoBase; 00032 class SoGLRenderAction; 00033 class SoNode; 00034 class SoPath; 00035 00036 00037 class COIN_DLL_API SoOffscreenRenderer { 00038 public: 00039 enum Components { 00040 LUMINANCE = 1, 00041 LUMINANCE_TRANSPARENCY = 2, 00042 RGB = 3, 00043 RGB_TRANSPARENCY = 4 00044 }; 00045 00046 SoOffscreenRenderer(const SbViewportRegion & viewportregion); 00047 SoOffscreenRenderer(SoGLRenderAction * action); 00048 ~SoOffscreenRenderer(); 00049 00050 static float getScreenPixelsPerInch(void); 00051 static SbVec2s getMaximumResolution(void); 00052 void setComponents(const Components components); 00053 Components getComponents(void) const; 00054 void setViewportRegion(const SbViewportRegion & region); 00055 const SbViewportRegion & getViewportRegion(void) const; 00056 void setBackgroundColor(const SbColor & color); 00057 const SbColor & getBackgroundColor(void) const; 00058 void setGLRenderAction(SoGLRenderAction * action); 00059 SoGLRenderAction * getGLRenderAction(void) const; 00060 SbBool render(SoNode * scene); 00061 SbBool render(SoPath * scene); 00062 unsigned char * getBuffer(void) const; 00063 00064 SbBool writeToRGB(FILE * fp) const; 00065 SbBool writeToPostScript(FILE * fp) const; 00066 SbBool writeToPostScript(FILE * fp, const SbVec2f & printsize) const; 00067 00068 SbBool writeToRGB(const char * filename) const; 00069 SbBool writeToPostScript(const char * filename) const; 00070 SbBool writeToPostScript(const char * filename, const SbVec2f & printsize) const; 00071 00072 SbBool isWriteSupported(const SbName & filetypeextension) const; 00073 int getNumWriteFiletypes(void) const; 00074 void getWriteFiletypeInfo(const int idx, 00075 SbList <SbName> & extlist, 00076 SbString & fullname, 00077 SbString & description); 00078 SbBool writeToFile(const SbString & filename, const SbName & filetypeextension) const; 00079 00080 private: 00081 SbBool renderFromBase(SoBase * base); 00082 void convertBuffer(void); 00083 00084 SbViewportRegion viewport; 00085 SbColor backgroundcolor; 00086 Components components; 00087 SoGLRenderAction * renderaction; 00088 SbBool didallocaction; 00089 class SoOffscreenInternalData * internaldata; 00090 unsigned char * buffer; 00091 }; 00092 00093 00094 #endif // !COIN_SOOFFSCREENRENDERER_H