Warning, /include/opencascade/Graphic3d_ShaderVariable.lxx is written in an unsupported language. File is not indexed.
0001 // Created on: 2013-09-25
0002 // Created by: Denis BOGOLEPOV
0003 // Copyright (c) 2013-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015
0016 // =======================================================================
0017 // function : As
0018 // purpose : Returns variable value casted to specified type
0019 // =======================================================================
0020 template <class T> inline
0021 T& Graphic3d_ValueInterface::As()
0022 {
0023 Graphic3d_UniformValue<T>* aPtr = dynamic_cast<Graphic3d_UniformValue<T>*> (this);
0024 return aPtr->Value;
0025 }
0026
0027 // =======================================================================
0028 // function : As
0029 // purpose : Returns variable value casted to specified type
0030 // =======================================================================
0031 template <class T> inline
0032 const T& Graphic3d_ValueInterface::As() const
0033 {
0034 const Graphic3d_UniformValue<T>* aPtr = dynamic_cast<const Graphic3d_UniformValue<T>*> (this);
0035 return aPtr->Value;
0036 }
0037
0038 // =======================================================================
0039 // function : TypeID
0040 // purpose : Returns unique identifier of value type
0041 // =======================================================================
0042 template <class T> inline
0043 Standard_Size Graphic3d_UniformValue<T>::TypeID() const
0044 {
0045 return Graphic3d_UniformValueTypeID<T>::ID;
0046 }
0047
0048 // =======================================================================
0049 // function : Create
0050 // purpose : Creates initialized shader variable
0051 // =======================================================================
0052 template<class T> inline
0053 Graphic3d_ShaderVariable* Graphic3d_ShaderVariable::Create (const TCollection_AsciiString& theName,
0054 const T& theValue)
0055 {
0056 Graphic3d_ShaderVariable* theVariable = new Graphic3d_ShaderVariable (theName);
0057 theVariable->myValue = new Graphic3d_UniformValue<T> (theValue);
0058 return theVariable;
0059 }