Visualization LibraryA lightweight C++ OpenGL middleware for 2D/3D graphics |
[Home] [Tutorials] [All Classes] [Grouped Classes] |
00001 /**************************************************************************************/ 00002 /* */ 00003 /* Visualization Library */ 00004 /* http://www.visualizationlibrary.com */ 00005 /* */ 00006 /* Copyright (c) 2005-2010, Michele Bosi */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without modification, */ 00010 /* are permitted provided that the following conditions are met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, this */ 00013 /* list of conditions and the following disclaimer. */ 00014 /* */ 00015 /* - Redistributions in binary form must reproduce the above copyright notice, this */ 00016 /* list of conditions and the following disclaimer in the documentation and/or */ 00017 /* other materials provided with the distribution. */ 00018 /* */ 00019 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */ 00020 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */ 00021 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ 00022 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */ 00023 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ 00024 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */ 00025 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */ 00026 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ 00027 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */ 00028 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00029 /* */ 00030 /**************************************************************************************/ 00031 00032 #include <vlGraphics/UniformSet.hpp> 00033 00034 using namespace vl; 00035 00036 //----------------------------------------------------------------------------- 00037 void UniformSet::setUniform(Uniform* uniform, bool check_for_doubles) 00038 { 00039 VL_CHECK(uniform) 00040 if (uniform == NULL) 00041 return; 00042 if ( check_for_doubles ) 00043 { 00044 for(unsigned i=0; i<mUniforms.size(); ++i) 00045 { 00046 if (mUniforms[i]->name() == uniform->name()) 00047 { 00048 mUniforms[i] = uniform; 00049 return; 00050 } 00051 } 00052 } 00053 mUniforms.push_back( uniform ); 00054 } 00055 //----------------------------------------------------------------------------- 00056 void UniformSet::eraseUniform(const std::string& name) 00057 { 00058 for(unsigned i=0; i<mUniforms.size(); ++i) 00059 if (mUniforms[i]->name() == name) 00060 { 00061 mUniforms.erase( mUniforms.begin() + i ); 00062 return; 00063 } 00064 } 00065 //----------------------------------------------------------------------------- 00066 void UniformSet::eraseUniform(const Uniform* uniform) 00067 { 00068 for(unsigned i=0; i<mUniforms.size(); ++i) 00069 if (mUniforms[i] == uniform) 00070 { 00071 mUniforms.erase( mUniforms.begin() + i ); 00072 return; 00073 } 00074 } 00075 //----------------------------------------------------------------------------- 00076 Uniform* UniformSet::gocUniform(const std::string& name) 00077 { 00078 for(unsigned i=0; i<mUniforms.size(); ++i) 00079 if (mUniforms[i]->name() == name) 00080 return mUniforms[i].get(); 00081 ref<Uniform> uniform = new Uniform; 00082 uniform->setName( name ); 00083 mUniforms.push_back(uniform); 00084 return uniform.get(); 00085 } 00086 //----------------------------------------------------------------------------- 00087 Uniform* UniformSet::getUniform(const std::string& name) 00088 { 00089 for(unsigned i=0; i<mUniforms.size(); ++i) 00090 if (mUniforms[i]->name() == name) 00091 return mUniforms[i].get(); 00092 return NULL; 00093 } 00094 //----------------------------------------------------------------------------- 00095 const Uniform* UniformSet::getUniform(const std::string& name) const 00096 { 00097 for(unsigned i=0; i<mUniforms.size(); ++i) 00098 if (mUniforms[i]->name() == name) 00099 return mUniforms[i].get(); 00100 return NULL; 00101 } 00102 //-----------------------------------------------------------------------------