Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoGLCacheContextElement.h
Go to the documentation of this file.
1 #ifndef COIN_SOGLCACHECONTEXTELEMENT_H
2 #define COIN_SOGLCACHECONTEXTELEMENT_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/elements/SoSubElement.h>
37 
38 // This shouldn't strictly be necessary, but the OSF1/cxx compiler
39 // complains if this is left out, while using the "friend class
40 // SoGLDisplayList" statement in the class definition.
41 class SoGLDisplayList;
42 
43 typedef void SoScheduleDeleteCB(void * closure, uint32_t contextid);
44 
45 // *************************************************************************
46 
47 class COIN_DLL_API SoGLCacheContextElement : public SoElement {
48  typedef SoElement inherited;
49 
50  SO_ELEMENT_HEADER(SoGLCacheContextElement);
51 
52 public:
53  static void initClass(void);
54 protected:
55  virtual ~SoGLCacheContextElement();
56 
57 public:
58  virtual void init(SoState * state);
59 
60  virtual SbBool matches(const SoElement * elt) const;
61  virtual SoElement * copyMatchInfo(void) const;
62  static void set(SoState * state, int context,
63  SbBool twopasstransparency,
64  SbBool remoterendering);
65  static int get(SoState * state);
66  static int getExtID(const char * str);
67  static void getOpenGLVersion(SoState * state, int & major, int & minor);
68  static SbBool extSupported(SoState * state, int extid);
69  static SbBool areMipMapsFast(SoState * state);
70  enum {
71  DO_AUTO_CACHE = 1,
72  DONT_AUTO_CACHE
73  };
74  static void shouldAutoCache(SoState * state, int bits);
75  static void setAutoCacheBits(SoState * state, int bits);
76  static int resetAutoCacheBits(SoState * state);
77  static SbBool getIsRemoteRendering(SoState * state);
78 
79  static uint32_t getUniqueCacheContext(void);
80 
81  static void scheduleDeleteCallback(const uint32_t contextid,
82  SoScheduleDeleteCB * cb,
83  void * closure);
84 
85  static void incNumShapes(SoState * state);
86  static int getNumShapes(SoState * state);
87  static void incNumSeparators(SoState * state);
88  static int getNumSeparators(SoState * state);
89 
90 private:
91  friend class SoGLDisplayList;
92  static void scheduleDelete(SoState * state, SoGLDisplayList * dl);
93  static void cleanupContext(uint32_t contextid, void * closure);
94 
95 private:
96  int context;
97  SbBool twopass;
98  int autocachebits;
99  int numshapes;
100  int numseparators;
101 
102  enum { RENDERING_UNSET, RENDERING_SET_DIRECT, RENDERING_SET_INDIRECT };
103  int rendering;
104  SbBool isDirectRendering(SoState * state) const;
105 };
106 
107 // *************************************************************************
108 
109 // For compatibility with client code originally written with SGI/TGS
110 // Inventor:
111 #ifndef COIN_INTERNAL
112 #include <Inventor/elements/SoGLDisplayList.h>
113 #endif // ! COIN_INTERNAL
114 
115 #endif // !COIN_SOGLCACHECONTEXTELEMENT_H
static void initClass(void)
Definition: SoElement.cpp:506
virtual SbBool matches(const SoElement *element) const =0
Definition: SoElement.cpp:608
The SoGLCacheContextElement class handles the OpenGL cache for a context.
Definition: SoGLCacheContextElement.h:47
SoElement is the abstract base class for all elements.
Definition: SoElement.h:43
The SoState class manages the Coin scenegraph traversal state data.
Definition: SoState.h:44
virtual void init(SoState *state)
Definition: SoElement.cpp:552
virtual SoElement * copyMatchInfo(void) const =0
The SoGLDisplayList class stores and manages OpenGL display lists.
Definition: SoGLDisplayList.h:43