Developer Documentation
EnvMapNode.cc
1 /*===========================================================================*\
2  * *
3  * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39  * *
40 \*===========================================================================*/
41 
42 
43 
44 
45 
46 
47 //=============================================================================
48 //
49 // CLASS EnvMapNode - IMPLEMENTATION
50 //
51 //=============================================================================
52 
53 
54 //== INCLUDES =================================================================
55 
56 
57 #include "EnvMapNode.hh"
58 
59 
60 //== NAMESPACES ===============================================================
61 
62 
63 namespace ACG {
64 namespace SceneGraph {
65 
66 
67 //== IMPLEMENTATION ==========================================================
68 
69 
71  const std::string& _name ,
72  bool _texture_repeat,
73  GLint _texture_filter)
74  : TextureNode(_parent, _name,_texture_repeat,_texture_filter)
75 {}
76 
77 
78 //----------------------------------------------------------------------------
79 
80 
82 {
84 }
85 
86 
87 //----------------------------------------------------------------------------
88 
89 
90 void EnvMapNode::enter(GLState& _state, const DrawModes::DrawMode& _drawmode)
91 {
92  if (_drawmode==DrawModes::SOLID_ENV_MAPPED)
93  {
94  TextureNode::enter(_state, _drawmode);
95 
96  ACG::GLState::setTexGenMode(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
97  ACG::GLState::setTexGenMode(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
98  ACG::GLState::enable(GL_TEXTURE_GEN_S, false);
99  ACG::GLState::enable(GL_TEXTURE_GEN_T, false);
100  if (_state.compatibilityProfile())
101  ACG::GLState::enable(GL_TEXTURE_2D);
102  } else
103  TextureNode::enter( _state, _drawmode);
104 }
105 
106 
107 //----------------------------------------------------------------------------
108 
109 
110 void EnvMapNode::leave(GLState& _state, const DrawModes::DrawMode& _drawmode)
111 {
112  if (_drawmode==DrawModes::SOLID_ENV_MAPPED)
113  {
114  TextureNode::leave(_state, _drawmode);
115  ACG::GLState::disable(GL_TEXTURE_GEN_S, false);
116  ACG::GLState::disable(GL_TEXTURE_GEN_T, false);
117  if(_state.compatibilityProfile())
118  ACG::GLState::disable(GL_TEXTURE_2D);
119  } else
120  TextureNode::leave( _state, _drawmode);
121 }
122 
123 void EnvMapNode::enterPick(GLState& /*_state*/ , PickTarget /*_target*/, const DrawModes::DrawMode& /*_drawMode*/ ) {
124 
125 }
126 
127 void EnvMapNode::leavePick(GLState& /*_state*/, PickTarget /*_target*/, const DrawModes::DrawMode& /*_drawMode*/ ) {
128 }
129 
130 
131 //=============================================================================
132 } // namespace SceneGraph
133 } // namespace ACG
134 //=============================================================================
void leavePick(GLState &_state, PickTarget _target, const DrawModes::DrawMode &_drawMode) override
Do nothing in picking.
Definition: EnvMapNode.cc:127
static void enable(GLenum _cap, bool _warnRemoved=true)
replaces glEnable, but supports locking
Definition: GLState.cc:1507
void leave(GLState &_state, const DrawModes::DrawMode &_drawmode) override
restores original texture (or no-texture)
Definition: EnvMapNode.cc:110
DrawMode SOLID_ENV_MAPPED
draw environment mapped
Definition: DrawModes.cc:87
Namespace providing different geometric functions concerning angles.
void enter(GLState &_state, const DrawModes::DrawMode &_drawmode) override
set texture
Definition: EnvMapNode.cc:90
PickTarget
What target to use for picking.
Definition: PickTarget.hh:73
EnvMapNode(BaseNode *_parent=0, const std::string &_name="<EnvMapNode>", bool _texture_repeat=true, GLint _texture_filter=GL_LINEAR)
Default constructor. Applies all properties.
Definition: EnvMapNode.cc:70
static void disable(GLenum _cap, bool _warnRemoved=true)
replaces glDisable, but supports locking
Definition: GLState.cc:1527
void leave(GLState &_state, const DrawModes::DrawMode &_drawmode) override
Unbind Texture.
Definition: TextureNode.cc:530
DrawModes::DrawMode availableDrawModes() const override
add env mapping
Definition: EnvMapNode.cc:81
static void setTexGenMode(GLenum _coord, GLenum _name, GLint _param)
replaces glVertexPointer, supports locking
Definition: GLState.cc:2049
void enter(GLState &_state, const DrawModes::DrawMode &_drawmode) override
set default texture and states for the nodes children
Definition: TextureNode.cc:487
void enterPick(GLState &_state, PickTarget _target, const DrawModes::DrawMode &_drawMode) override
Do nothing in picking.
Definition: EnvMapNode.cc:123