Debian Codegraph @

lib/database/src/so/elements/SoGLClipPlaneElement.c++

raw symbols SCIP
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * Copyright (C) 1990,91 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision: 1.1.1.1 $
44 |
45 | Classes:
46 | SoGLClipPlaneElement
47 |
48 | Author(s) : Paul S. Strauss
49 |
50 ______________ S I L I C O N G R A P H I C S I N C . ____________
51 _______________________________________________________________________
52 */
53
54 #include <GL/gl.h>
55 #include <Inventor/elements/SoGLClipPlaneElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoGLClipPlaneElement.h`/
56 #include <Inventor/misc/SoState.h>cxx . . $ `<file>/lib/database/include/Inventor/misc/SoState.h`/
57
58 // This holds the maximum number of concurrent GL clip planes
59 int SoGLClipPlaneElementcxx . . $ SoGLClipPlaneElement#::maxGLPlanescxx . . $ SoGLClipPlaneElement#maxGLPlanes. = -1;
60
61 SO_ELEMENT_SOURCEcxx . . $ `lib/database/include/Inventor/elements/SoSubElement.h:173:9`!(SoGLClipPlaneElement);
62
63 ////////////////////////////////////////////////////////////////////////
64 //
65 // Description:
66 // Destructor.
67 //
68 // Use: private
69
70 SoGLClipPlaneElementcxx . . $ SoGLClipPlaneElement#::~cxx . . $ SoGLClipPlaneElement#`~SoGLClipPlaneElement`(49f6e7a06ebc5aa8).SoGLClipPlaneElementcxx . . $ SoGLClipPlaneElement#()
71 //
72 ////////////////////////////////////////////////////////////////////////
73 {
74 }
75
76 ////////////////////////////////////////////////////////////////////////
77 //
78 // Description:
79 // Pops element, causing side effects in GL.
80 //
81 // Use: public
82
83 void
84 SoGLClipPlaneElementcxx . . $ SoGLClipPlaneElement#::popcxx . . $ SoGLClipPlaneElement#pop(90c797341866ebf4).(SoStatecxx . . $ SoState# *state, const SoElementcxx . . $ SoElement# *prevTopElement)
85 //
86 ////////////////////////////////////////////////////////////////////////
87 {
88 // Since popping this element has GL side effects, make sure any
89 // open caches capture it
90 capturecxx . . $ SoElement#capture(952d15a9fa93c099).(state);
91
92 // Disable clip planes created in previous elements. Note that the
93 // index into the planes array is identical to the GL clip plane
94 // id, for convenience.
95
96 const SoGLClipPlaneElementcxx . . $ SoGLClipPlaneElement# *prevElt =
97 (const SoGLClipPlaneElementcxx . . $ SoGLClipPlaneElement# *) prevTopElement;
98
99 int maxId = prevElt->getNumcxx . . $ SoClipPlaneElement#getNum(455f465bc33b4cdf).();
100 if (maxId > getMaxGLPlanescxx . . $ SoGLClipPlaneElement#getMaxGLPlanes(b126dc7c1de90089).())
101 maxId = getMaxGLPlanescxx . . $ SoGLClipPlaneElement#getMaxGLPlanes(b126dc7c1de90089).();
102
103 for (int i = prevElt->startIndexcxx . . $ SoClipPlaneElement#startIndex.; i < maxId; i++)
104 if (i < getMaxGLPlanescxx . . $ SoGLClipPlaneElement#getMaxGLPlanes(b126dc7c1de90089).())
105 glDisable((GLenum)(GL_CLIP_PLANE0cxx . . $ `<external>/11565930711847777359/gl.h:312:9`! + i));
106
107 // Do parent's pop stuff
108 SoClipPlaneElementcxx . . $ SoClipPlaneElement#::popcxx . . $ SoClipPlaneElement#pop(90c797341866ebf4).(state, prevTopElement);
109 }
110
111 ////////////////////////////////////////////////////////////////////////
112 //
113 // Description:
114 // Returns the maximum number of concurrent clipping planes supported
115 // by GL implementation.
116 //
117 // Use: protected, static
118
119 int
120 SoGLClipPlaneElementcxx . . $ SoGLClipPlaneElement#::getMaxGLPlanescxx . . $ SoGLClipPlaneElement#getMaxGLPlanes(b126dc7c1de90089).()
121 //
122 ////////////////////////////////////////////////////////////////////////
123 {
124 // Inquire GL if not already done
125 if (maxGLPlanescxx . . $ SoGLClipPlaneElement#maxGLPlanes. < 0) {
126 GLint max;
127 glGetIntegerv(GL_MAX_CLIP_PLANEScxx . . $ `<external>/11565930711847777359/gl.h:475:9`!, &max);
128 maxGLPlanescxx . . $ SoGLClipPlaneElement#maxGLPlanes. = (int) max;
129 }
130
131 return maxGLPlanescxx . . $ SoGLClipPlaneElement#maxGLPlanes.;
132 }
133
134 ////////////////////////////////////////////////////////////////////////
135 //
136 // Description:
137 // Adds clip plane to element and sends it to GL.
138 //
139 // Use: protected, virtual
140
141 void
142 SoGLClipPlaneElementcxx . . $ SoGLClipPlaneElement#::addToEltcxx . . $ SoGLClipPlaneElement#addToElt(b43e0644e367a739).(const SbPlanecxx . . $ SbPlane# &plane,
143 const SbMatrixcxx . . $ SbMatrix# &modelMatrix)
144 //
145 ////////////////////////////////////////////////////////////////////////
146 {
147 // Do normal stuff
148 SoClipPlaneElementcxx . . $ SoClipPlaneElement#::addToEltcxx . . $ SoClipPlaneElement#addToElt(b43e0644e367a739).(plane, modelMatrix);
149
150 // If we haven't run out of clipping planes, send this one to GL.
151 // Note that we send the plane in object space, since GL already
152 // will transform it by the current model matrix.
153 int planeId = getNumcxx . . $ SoClipPlaneElement#getNum(455f465bc33b4cdf).() - 1;
154 if (planeId < getMaxGLPlanescxx . . $ SoGLClipPlaneElement#getMaxGLPlanes(b126dc7c1de90089).()) {
155
156 const SbPlanecxx . . $ SbPlane# &objPlane = getcxx . . $ SoClipPlaneElement#get(3fa63512a8f66182).(planeId, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!);
157 const SbVec3fcxx . . $ SbVec3f# &norm = objPlane.getNormalcxx . . $ SbPlane#getNormal(b5c384c15c94bb12).();
158 GLdouble planeEquation[4];
159
160 planeEquation[0] = norm[cxx . . $ SbVec3f#`operator[]`(c60a38c584b9a5cc).0];
161 planeEquation[1] = norm[cxx . . $ SbVec3f#`operator[]`(c60a38c584b9a5cc).1];
162 planeEquation[2] = norm[cxx . . $ SbVec3f#`operator[]`(c60a38c584b9a5cc).2];
163 planeEquation[3] = -objPlane.getDistanceFromOrigincxx . . $ SbPlane#getDistanceFromOrigin(5036dfe8d4170af2).();
164
165 glClipPlane((GLenum)(GL_CLIP_PLANE0cxx . . $ `<external>/11565930711847777359/gl.h:312:9`! + planeId), planeEquation);
166
167 glEnable((GLenum)(GL_CLIP_PLANE0cxx . . $ `<external>/11565930711847777359/gl.h:312:9`! + planeId));
168 }
169 }