2 // Copyright (C) 2007 by Martin Moracek
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <boost/utility.hpp>
30 #include <boost/array.hpp>
31 #include <boost/smart_ptr.hpp>
33 #include <tr1/unordered_map>
37 #include "renderer/texture.h"
41 // data types for uniform variables
54 // builtins for all shader types
55 enum InternalsType
{ // Semantic, annotations...
57 itSysTime
, // Time, type = "system"
59 itMVPMatrix
, // ModelViewProjection
60 itMVPMatrixInv
, // ModelViewProjection, inverse = true
61 itMVPMatrixTrans
, // ModelViewProjection, transpose=true
62 itMVPMatrixInvTrans
,// ModelViewProjection, inverse = true, transpose=true
63 itMVMatrix
, // ModelView
64 itMVMatrixInv
, // ModelView, inverse = true
65 itMVMatrixTrans
, // ModelView, transpose=true
66 itMVMatrixInvTrans
, // ModelView, transpose=true
67 itPMatrix
, // Projection
68 itPMatrixInv
, // Projection, inverse = true
69 itPMatrixTrans
, // Projection, transpose=true
70 itPMatrixInvTrans
, // Projection, transpose=true
72 itTMatrixInv
, // Texture, inverse = true
73 itTMatrixTrans
, // Texture, transpose=true
74 itTMatrixInvTrans
, // Texture, transpose=true
79 // variable declarations for general use
80 typedef boost::array
<float, 4> FxFVar
;
81 typedef boost::array
<int, 4> FxIVar
;
83 typedef cpair
<std::string
, FxFVar
> FxFPair
;
84 typedef cpair
<std::string
, FxIVar
> FxIPair
;
85 typedef cpair
<std::string
, TexturePtr
> FxSPair
;
87 typedef std::vector
<FxFPair
> FVarVector
;
88 typedef std::vector
<FxIPair
> IVarVector
;
89 typedef std::vector
<FxSPair
> SVarVector
;
99 void SetTexture(const std::string
& name
, const std::string
& var
);
100 void SetTexture(const std::string
& name
, const TexturePtr
& var
);
108 typedef boost::shared_ptr
<Effect
> EffectPtr
;
109 typedef boost::weak_ptr
<Effect
> EffectRef
;
111 class EffectFactory
{
113 const EffectPtr
CreateInstance(const std::string
& name
);
116 typedef std::tr1::unordered_map
<std::string
, EffectRef
> EffectMap
;
122 class Effect
: private boost::noncopyable
{
124 static EffectFactory
& Factory(void)
126 static EffectFactory fac
;