Open Inventor Reference
|
00001 /* 00002 * 00003 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. 00004 * 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 * 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 * Lesser General Public License for more details. 00014 * 00015 * Further, this software is distributed without any warranty that it is 00016 * free of the rightful claim of any third person regarding infringement 00017 * or the like. Any license provided herein, whether implied or 00018 * otherwise, applies only to this software file. Patent licenses, if 00019 * any, provided herein do not apply to combinations of this program with 00020 * other software, or any other product whatsoever. 00021 * 00022 * You should have received a copy of the GNU Lesser General Public 00023 * License along with this library; if not, write to the Free Software 00024 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 * 00026 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 00027 * Mountain View, CA 94043, or: 00028 * 00029 * http://www.sgi.com 00030 * 00031 * For further information regarding this notice, see: 00032 * 00033 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ 00034 * 00035 */ 00036 00037 00038 /* 00039 * Copyright (C) 1990,91 Silicon Graphics, Inc. 00040 * 00041 _______________________________________________________________________ 00042 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00043 | 00044 | $Revision: 1.1.1.1 $ 00045 | 00046 | Description: 00047 | Defines the SoGLRenderAction class 00048 | 00049 | Author(s) : Paul S. Strauss 00050 | 00051 ______________ S I L I C O N G R A P H I C S I N C . ____________ 00052 _______________________________________________________________________ 00053 */ 00054 00055 #ifndef _SO_GL_RENDER_ACTION_ 00056 #define _SO_GL_RENDER_ACTION_ 00057 00058 #include <Inventor/system/SbSystem.h> 00059 #include <Inventor/SbViewportRegion.h> 00060 #include <Inventor/actions/SoSubAction.h> 00061 #include <Inventor/elements/SoShapeStyleElement.h> 00062 00063 class SbBox3f; 00064 class SoGetBoundingBoxAction; 00065 00067 typedef void SoGLRenderPassCB(void *userData); 00068 00069 00072 00084 00085 00086 class INVENTOR_API SoGLRenderAction : public SoAction { 00087 00088 SO_ACTION_HEADER(SoGLRenderAction); 00089 00090 public: 00091 00093 enum TransparencyType { 00094 SCREEN_DOOR, 00095 ADD, 00096 DELAYED_ADD, 00097 SORTED_OBJECT_ADD, 00098 BLEND, 00099 DELAYED_BLEND, 00100 SORTED_OBJECT_BLEND 00101 }; 00102 00104 enum AbortCode { 00105 CONTINUE, 00106 ABORT, 00107 PRUNE, 00108 DELAY 00109 }; 00110 00114 typedef AbortCode SoGLRenderAbortCB(void *userData); 00115 00118 SoGLRenderAction(const SbViewportRegion &viewportRegion); 00119 00120 00122 virtual ~SoGLRenderAction(); 00123 00125 void setViewportRegion(const SbViewportRegion &newRegion); 00126 00128 const SbViewportRegion &getViewportRegion() const { return vpRegion; } 00129 00131 void setUpdateArea(const SbVec2f &origin, 00132 const SbVec2f &size); 00139 void getUpdateArea(SbVec2f &origin, SbVec2f &size) const; 00140 00148 void setAbortCallback(SoGLRenderAbortCB *funcArg, 00149 void *userData) 00150 { abortCB = funcArg; abortData = userData; } 00151 00153 void setTransparencyType(TransparencyType type); 00158 TransparencyType getTransparencyType() const { return transpType; } 00159 00161 void setSmoothing(SbBool smooth); 00165 SbBool isSmoothing() const { return doSmooth; } 00166 00168 void setNumPasses(int num) { numPasses = num; } 00175 int getNumPasses() const { return numPasses; } 00176 00178 void setPassUpdate(SbBool flag) { passUpdate = flag; } 00182 SbBool isPassUpdate() const { return passUpdate; } 00183 00187 void setPassCallback(SoGLRenderPassCB *funcArg, void *userData) 00188 { passCB = funcArg; passData = userData; } 00189 00191 void setCacheContext(uint32_t context); 00195 uint32_t getCacheContext() const; 00196 00198 void setRenderingIsRemote(SbBool flag); 00205 SbBool getRenderingIsRemote() const; 00206 00208 virtual void invalidateState(); 00209 00210 SoEXTENDER public: 00212 int getCurPass() const { return curPass; } 00213 00215 SbBool abortNow() 00216 { return (hasTerminated() || (abortCB != NULL && checkAbort())); } 00217 00225 SbBool handleTransparency(SbBool isTransparent = FALSE); 00226 00227 00228 SoINTERNAL public: 00229 static void initClass(); 00230 00233 SbBool isDelaying() const { return sortObjs || delayObjs; } 00234 00238 void addDelayedPath(SoPath *path); 00239 00241 SbBool isRenderingDelayedPaths() const 00242 { return renderingDelPaths; } 00243 00244 int getCullTestResults() { return cullBits; } 00245 void setCullTestResults(int b) { cullBits = b; } 00246 00247 protected: 00249 virtual void beginTraversal(SoNode *node); 00250 00251 private: 00252 SbViewportRegion vpRegion; 00253 SbVec2f updateOrigin; 00254 SbVec2f updateSize; 00255 00256 00258 SoGLRenderAbortCB *abortCB; 00259 void *abortData; 00260 00262 TransparencyType transpType; 00263 SbBool doSmooth; 00264 int numPasses; 00265 int curPass; 00266 SbBool passUpdate; 00267 SoGLRenderPassCB *passCB; 00268 void *passData; 00269 00271 SbBool renderingTranspObjs; 00272 SbBool delayObjs; 00273 00274 SbBool sortObjs; 00275 SoPathList transpPaths; 00276 SoGetBoundingBoxAction *ba; 00277 SbBox3f *bboxes; 00278 int numBBoxes; 00279 00280 uint32_t cacheContext; 00281 SbBool remoteRendering; 00282 00284 SoPathList delayedPaths; 00285 SbBool renderingDelPaths; 00286 00290 enum flags { 00291 TRANSPARENCY_TYPE = 0x01, 00292 SMOOTHING = 0x02, 00293 ALL = 0x03 00294 }; 00295 uint32_t whatChanged; 00296 00298 void renderAllPasses(SoNode *node); 00299 00301 void renderPass(SoNode *node, int pass); 00302 00305 void renderTransparentObjs(); 00306 00308 void enableBlending(SbBool enable); 00309 00311 SbBool checkAbort(); 00312 00315 int cullBits; 00316 }; 00317 00318 #endif /* _SO_GL_RENDER_ACTION_ */