OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
StdMeshMaterialProgram Class Reference

#include <StdMeshMaterial.h>

Public Member Functions

 StdMeshMaterialProgram (const char *name, const StdMeshMaterialShader *fragment_shader, const StdMeshMaterialShader *vertex_shader, const StdMeshMaterialShader *geometry_shader)
 
bool AddParameterNames (const StdMeshMaterialShaderParameters &parameters)
 
bool IsCompiled () const
 
bool Compile (StdMeshMaterialLoader &loader)
 
const C4ShaderGetShader (int ssc) const
 
int GetParameterIndex (const char *name) const
 
const StdMeshMaterialShaderGetFragmentShader () const
 
const StdMeshMaterialShaderGetVertexShader () const
 
const StdMeshMaterialShaderGetGeometryShader () const
 

Detailed Description

Definition at line 159 of file StdMeshMaterial.h.

Constructor & Destructor Documentation

StdMeshMaterialProgram::StdMeshMaterialProgram ( const char *  name,
const StdMeshMaterialShader fragment_shader,
const StdMeshMaterialShader vertex_shader,
const StdMeshMaterialShader geometry_shader 
)

Definition at line 831 of file StdMeshMaterial.cpp.

831  :
832  Name(name), FragmentShader(fragment_shader), VertexShader(vertex_shader), GeometryShader(geometry_shader)
833 {
834  assert(FragmentShader != nullptr);
835  assert(VertexShader != nullptr);
836  // Geometry shader is optional (and not even implemented at the moment!)
837 }

Member Function Documentation

bool StdMeshMaterialProgram::AddParameterNames ( const StdMeshMaterialShaderParameters parameters)

Definition at line 839 of file StdMeshMaterial.cpp.

References StdMeshMaterialShaderParameters::NamedParameters.

Referenced by StdMeshMatManager::AddProgram().

840 {
841  // TODO: This is O(n^2) -- not optimal!
842  bool added = false;
843  for (unsigned int i = 0; i < parameters.NamedParameters.size(); ++i)
844  {
845  const std::vector<StdCopyStrBuf>::const_iterator iter = std::find(ParameterNames.begin(), ParameterNames.end(), parameters.NamedParameters[i].first);
846  if (iter == ParameterNames.end())
847  {
848  ParameterNames.push_back(parameters.NamedParameters[i].first);
849  added = true;
850  }
851  }
852 
853  return added;
854 }
std::vector< std::pair< StdCopyStrBuf, StdMeshMaterialShaderParameter > > NamedParameters

Here is the caller graph for this function:

bool StdMeshMaterialProgram::Compile ( StdMeshMaterialLoader loader)

Definition at line 914 of file StdMeshMaterial.cpp.

Referenced by StdMeshMatManager::AddProgram().

915 {
916 #ifndef USE_CONSOLE
917  if (!CompileShader(loader, Shader, 0)) return false;
918  if (!CompileShader(loader, ShaderMod2, C4SSC_MOD2)) return false;
919  if (!CompileShader(loader, ShaderLight, C4SSC_LIGHT)) return false;
920  if (!CompileShader(loader, ShaderLightMod2, C4SSC_LIGHT | C4SSC_MOD2)) return false;
921 #endif
922  return true;
923 }

Here is the caller graph for this function:

const StdMeshMaterialShader* StdMeshMaterialProgram::GetFragmentShader ( ) const
inline

Definition at line 171 of file StdMeshMaterial.h.

Referenced by StdMeshMaterialPass::ProgramInstance::ProgramInstance().

171 { return FragmentShader; }

Here is the caller graph for this function:

const StdMeshMaterialShader* StdMeshMaterialProgram::GetGeometryShader ( ) const
inline

Definition at line 173 of file StdMeshMaterial.h.

Referenced by StdMeshMaterialPass::ProgramInstance::ProgramInstance().

173 { return GeometryShader; }

Here is the caller graph for this function:

int StdMeshMaterialProgram::GetParameterIndex ( const char *  name) const

Definition at line 946 of file StdMeshMaterial.cpp.

References C4SSU_Count.

947 {
948 #ifndef USE_CONSOLE
949  std::vector<StdCopyStrBuf>::const_iterator iter = std::find(ParameterNames.begin(), ParameterNames.end(), name);
950  if(iter == ParameterNames.end()) return -1;
951  return C4SSU_Count + std::distance(ParameterNames.begin(), iter);
952 #else
953  return -1;
954 #endif
955 }
const C4Shader * StdMeshMaterialProgram::GetShader ( int  ssc) const

Definition at line 925 of file StdMeshMaterial.cpp.

926 {
927 #ifndef USE_CONSOLE
928  const C4Shader* shaders[4] = {
929  &Shader,
930  &ShaderMod2,
931  &ShaderLight,
932  &ShaderLightMod2
933  };
934 
935  int index = 0;
936  if(ssc & C4SSC_MOD2) index += 1;
937  if(ssc & C4SSC_LIGHT) index += 2;
938 
939  assert(index < 4);
940  return shaders[index];
941 #else
942  return nullptr;
943 #endif
944 }
const StdMeshMaterialShader* StdMeshMaterialProgram::GetVertexShader ( ) const
inline

Definition at line 172 of file StdMeshMaterial.h.

Referenced by StdMeshMaterialPass::ProgramInstance::ProgramInstance().

172 { return VertexShader; }

Here is the caller graph for this function:

bool StdMeshMaterialProgram::IsCompiled ( ) const
inline

Definition at line 165 of file StdMeshMaterial.h.

References C4Shader::Initialised().

Referenced by StdMeshMatManager::AddProgram().

165 { return Shader.Initialised(); }
bool Initialised() const
Definition: C4Shader.h:107

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: