renderstack::uniform_mappings Class Reference

uniform mapping collection

#include <uniform_bindings.hpp>

Public Member Functions

void insert (std::string const &name_in_shader, enum logical_uniform u)
void insert (std::string shader_name, std::string parameter_name, enum uniform_type type, int count)
std::string const & name (enum logical_uniform u) const
enum logical_uniform logical_uniform (std::string const &name_in_shader) const
void bind_uniforms (class uniform_bindings &bindings, class program &program, class uniform_source &source)
void bind_uniforms (class uniform_bindings &bindings, class program &program, class uniform_parameter_source &source)

Detailed Description

Definition at line 154 of file uniform_bindings.hpp.


Member Function Documentation

void renderstack::uniform_mappings::insert ( std::string const &  name_in_shader,
enum logical_uniform  u 
) [inline]

Definition at line 157 of file uniform_bindings.hpp.

00158     {
00159         m_string_to_uniform.insert(std::make_pair(name_in_shader, u));
00160         m_uniform_to_string.insert(std::make_pair(u, name_in_shader));
00161     }

void renderstack::uniform_mappings::insert ( std::string  shader_name,
std::string  parameter_name,
enum uniform_type  type,
int  count 
) [inline]

Definition at line 162 of file uniform_bindings.hpp.

00168     {
00169         std::tr1::shared_ptr<uniform_mapping> m(
00170             new uniform_mapping(shader_name, parameter_name, type, count)
00171         );
00172         m_parameter_mappings.push_back(m);
00173     }

std::string const & renderstack::uniform_mappings::name ( enum logical_uniform  u  )  const

Definition at line 156 of file uniform_bindings.cpp.

00159 {
00160     std::map<enum logical_uniform, std::string>::const_iterator i = m_uniform_to_string.find(u);
00161     if(i != m_uniform_to_string.end())
00162     {
00163         return (*i).second;
00164     }
00165     else
00166     {
00167         throw std::exception();
00168     }
00169 }

enum logical_uniform renderstack::uniform_mappings::logical_uniform ( std::string const &  name_in_shader  )  const

Definition at line 171 of file uniform_bindings.cpp.

00172 {
00173     std::map<std::string, enum logical_uniform>::const_iterator i = m_string_to_uniform.find(name);
00174     if(i != m_string_to_uniform.end())
00175     {
00176         return (*i).second;
00177     }
00178     else
00179     {
00180         return logical_uniform_generic_uniform;
00181     }
00182 }

void renderstack::uniform_mappings::bind_uniforms ( class uniform_bindings bindings,
class program program,
class uniform_source source 
)

Definition at line 184 of file uniform_bindings.cpp.

00189 {
00190     for(
00191         std::map<
00192             std::string, 
00193             enum logical_uniform
00194         >::const_iterator i = m_string_to_uniform.begin();
00195         i != m_string_to_uniform.end();
00196         ++i
00197     )
00198     {
00199         std::string const    &name = (*i).first;
00200         enum logical_uniform lu    = (*i).second;
00201 
00202         if(program.has_uniform(name) == true)
00203         {
00204             int gl_slot = program.uniform(name).gl_slot();
00205             if(gl_slot < 0)
00206             {
00207                 continue;
00208             }
00209             if(source.connect(bindings, lu, gl_slot) == true)
00210             {
00211 #if 0
00212                 ::rs_log("bound %s slot %d\n", name.c_str(), gl_slot);
00213 #endif
00214             }
00215         }
00216 
00217     }
00218 }

void renderstack::uniform_mappings::bind_uniforms ( class uniform_bindings bindings,
class program program,
class uniform_parameter_source source 
)

Definition at line 221 of file uniform_bindings.cpp.

00226 {
00227     for(
00228         std::vector<std::tr1::shared_ptr<uniform_mapping> >::const_iterator i = m_parameter_mappings.begin();
00229         i != m_parameter_mappings.end();
00230         ++i
00231     )
00232     {
00233         std::tr1::shared_ptr<uniform_mapping> mapping = *i;
00234         void *value_source = source.parameter(mapping->parameter_name);
00235 
00236         if(
00237             (program.has_uniform(mapping->shader_name) == true) &&
00238             (value_source != NULL)
00239         )
00240         {
00241             int gl_slot = program.uniform(mapping->shader_name).gl_slot();
00242             if(gl_slot < 0)
00243             {
00244                 continue;
00245             }
00246             bindings.add(
00247                 mapping->type,
00248                 gl_slot,
00249                 mapping->count,
00250                 value_source
00251             );
00252 #if 0
00253             ::rs_log("source bound %s slot %d count %d\n", mapping->shader_name.c_str(), gl_slot, mapping->count);
00254 #endif
00255         }
00256 
00257     }
00258 }


The documentation for this class was generated from the following files:
Generated on Sun Apr 11 12:23:12 2010 for RenderStack by  doxygen 1.6.3