Open Inventor Reference
MeVis/ThirdParty/Sources/Inventor/inventor/lib/database/include/Inventor/elements/SoGLCacheContextElement.h
Go to the documentation of this file.
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  |      This file defines the SoGLCacheContextElement class.
00048  |
00049  |   Author(s)          : Gavin Bell
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_CACHE_CONTEXT_ELEMENT
00056 #define  _SO_CACHE_CONTEXT_ELEMENT
00057 
00058 #include <Inventor/system/SbOpenGL.h>
00059 #include <Inventor/elements/SoSubElement.h>
00060 
00063 #define OIV_AUTO_CACHE_DEFAULT_MAX 100000
00064 
00102 
00113 
00114 SoEXTENDER class INVENTOR_API SoGLDisplayList {
00115 
00116   public:
00122     enum Type {
00123         DISPLAY_LIST,
00124         TEXTURE_OBJECT,
00125         VERTEX_BUFFER_OBJECT 
00126         };
00127     SoGLDisplayList(SoState *state, Type type, int numToAllocate=1);
00128 
00135     void ref();
00136     void unref(SoState *state = NULL);
00137 
00143     void open(SoState *state, int index = 0);
00144     void close(SoState *state);
00145 
00153     void call(SoState *state, int index = 0);
00154     void addDependency(SoState *state);
00155 
00159     Type getType() { return type; }
00160     int getNumAllocated() { return num; }
00161     GLuint getFirstIndex() { return startIndex; }
00162     int getContext() { return context; }
00163 
00164   private:
00165     ~SoGLDisplayList();
00166 
00167     Type type;
00168     GLuint startIndex;
00169     int num;
00170     int refCount;
00171     int context;
00172     
00173     friend class SoGLCacheContextElement;
00174 };
00175 
00176 class SbIntList;
00177 
00178 SoEXTENDER class INVENTOR_API SoGLCacheContextElement : public SoElement {
00179 
00180     SO_ELEMENT_HEADER(SoGLCacheContextElement);
00181 
00182   public:
00184     virtual void        init(SoState *state);
00185 
00197     static void         set(SoState *state, int context,
00198                             SbBool is2PassTransparency,
00199                             SbBool isRemoteRendering);
00200 
00202     static int          get(SoState *state);
00203 
00206 
00209     static int          getExtID(const char *str);
00210 
00212     static SbBool       extSupported(SoState *state, int ext);
00213 
00216     static SbBool       areMipMapsFast(SoState *state);
00217 
00219 
00226     enum {
00227         DO_AUTO_CACHE = 1,   
00228         DONT_AUTO_CACHE = 2
00229     };
00230 
00234     static void         shouldAutoCache(SoState *state, int bits)
00235     {
00236         SoGLCacheContextElement *elt = (SoGLCacheContextElement *)
00237             state->getElementNoPush(classStackIndex);
00238         elt->autoCacheBits |= bits;
00239     }
00240 
00242     static void         setAutoCacheBits(SoState *state, int bits)
00243         { ((SoGLCacheContextElement *)state->getElementNoPush(
00244             classStackIndex))->autoCacheBits = bits;
00245         }
00246 
00247     static int          resetAutoCacheBits(SoState *state)
00248         {
00249             SoGLCacheContextElement *elt = (SoGLCacheContextElement *)
00250                 state->getElementNoPush(classStackIndex);
00251             int result = elt->autoCacheBits;
00253             elt->autoCacheBits = elt->isRemoteRendering;
00254             
00255             return result;
00256         }
00257 
00258     static SbBool       getIsRemoteRendering(SoState *state)
00259         {
00260             const SoGLCacheContextElement *elt =
00261                 (const SoGLCacheContextElement *)
00262                     state->getConstElement(classStackIndex);
00263             return elt->isRemoteRendering;
00264         }
00265 
00267 
00269     virtual SbBool      matches(const SoElement *elt) const;
00270 
00272     virtual SoElement   *copyMatchInfo() const;
00273 
00275     virtual void        print(FILE *fp) const;
00276 
00277   SoINTERNAL public:
00278     static void         initClass();
00279 
00280   protected:
00281     int                 context;
00282     SbBool              is2PassTransp;
00283     SbBool              isRemoteRendering;
00284     int                 autoCacheBits;
00285 
00286     virtual ~SoGLCacheContextElement();
00287 
00288   private:
00297     static void         freeList(SoState *state,
00298                                  SoGLDisplayList *list);
00299 
00300     static SbPList *    waitingToBeFreed;       
00301     static SbPList *    extensionList;          
00302 
00303 friend class SoGLDisplayList;
00304 };
00305 
00306 #endif /* _SO_CACHE_CONTEXT_ELEMENT */