fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Shader / Variables / OSGShaderVariables.cpp
blobadc5a28d682e8f2059a455cd997c0d32bb156baf
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include "OSGShaderVariables.h"
45 OSG_BEGIN_NAMESPACE
47 void osgUniformShaderVariableSwitch(DrawEnv *pEnv,
48 ShaderVariable *pVar,
49 Int32 &loc,
50 UInt32 uiProgram,
51 bool warnUnknown)
53 switch(pVar->getTypeId())
55 case ShaderVariable::SHVTypeBool:
56 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
57 osgUniformShaderVariableBool (pEnv, pVar, loc, uiProgram,
58 warnUnknown );
59 break;
61 case ShaderVariable::SHVTypeInt:
62 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
63 osgUniformShaderVariableInt (pEnv, pVar, loc, uiProgram,
64 warnUnknown );
65 break;
67 case ShaderVariable::SHVTypeUInt:
68 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
69 osgUniformShaderVariableUInt (pEnv, pVar, loc, uiProgram,
70 warnUnknown );
71 break;
73 case ShaderVariable::SHVTypeReal:
74 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
75 osgUniformShaderVariableReal (pEnv, pVar, loc, uiProgram,
76 warnUnknown );
77 break;
79 case ShaderVariable::SHVTypeVec2f:
80 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
81 osgUniformShaderVariableVec2f (pEnv, pVar, loc, uiProgram,
82 warnUnknown );
83 break;
85 case ShaderVariable::SHVTypeVec3f:
86 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
87 osgUniformShaderVariableVec3f (pEnv, pVar, loc, uiProgram,
88 warnUnknown );
89 break;
91 case ShaderVariable::SHVTypeVec4f:
92 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
93 osgUniformShaderVariableVec4f (pEnv, pVar, loc, uiProgram,
94 warnUnknown );
95 break;
97 case ShaderVariable::SHVTypePnt2f:
98 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
99 osgUniformShaderVariablePnt2f (pEnv, pVar, loc, uiProgram,
100 warnUnknown );
101 break;
103 case ShaderVariable::SHVTypePnt3f:
104 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
105 osgUniformShaderVariablePnt3f (pEnv, pVar, loc, uiProgram,
106 warnUnknown );
107 break;
109 case ShaderVariable::SHVTypeMatrix:
110 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
111 osgUniformShaderVariableMatrix (pEnv, pVar, loc, uiProgram,
112 warnUnknown );
113 break;
115 case ShaderVariable::SHVTypeMInt:
116 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
117 osgUniformShaderVariableMInt (pEnv, pVar, loc, uiProgram,
118 warnUnknown );
119 break;
121 case ShaderVariable::SHVTypeMUInt:
122 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
123 osgUniformShaderVariableMUInt (pEnv, pVar, loc, uiProgram,
124 warnUnknown );
125 break;
127 case ShaderVariable::SHVTypeMReal:
128 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
129 osgUniformShaderVariableMReal (pEnv, pVar, loc, uiProgram,
130 warnUnknown );
131 break;
133 case ShaderVariable::SHVTypeMVec2f:
134 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
135 osgUniformShaderVariableMVec2f (pEnv, pVar, loc, uiProgram,
136 warnUnknown );
137 break;
139 case ShaderVariable::SHVTypeMVec3f:
140 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
141 osgUniformShaderVariableMVec3f (pEnv, pVar, loc, uiProgram,
142 warnUnknown );
143 break;
145 case ShaderVariable::SHVTypeMVec4f:
146 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
147 osgUniformShaderVariableMVec4f (pEnv, pVar, loc, uiProgram,
148 warnUnknown );
149 break;
151 case ShaderVariable::SHVTypeMMatrix:
152 osgUniformShaderVariableLocation(pEnv, pVar, loc, uiProgram);
153 osgUniformShaderVariableMMatrix (pEnv, pVar, loc, uiProgram,
154 warnUnknown );
155 break;
157 case ShaderVariable::SHVTypeUniformBlock:
158 osgUniformShaderUniformBlockLocation(pEnv, pVar, loc, uiProgram);
159 osgUniformShaderUniformBlockBinding (pEnv, pVar, loc, uiProgram,
160 warnUnknown );
161 break;
163 case ShaderVariable::SHVTypeShaderStorageBlock:
164 osgUniformShaderStorageBlockLocation(pEnv, pVar, loc, uiProgram);
165 osgUniformShaderStorageBlockBinding (pEnv, pVar, loc, uiProgram,
166 warnUnknown );
167 break;
169 case ShaderVariable::SHVTypeOSG:
170 // not handled here
171 break;
173 default:
174 SWARNING << "Variable '"
175 << pVar->getName() << "' has unknown type '"
176 << pVar->getTypeId() << "'."
177 << std::endl;
178 break;
182 OSG_END_NAMESPACE