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 156 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 813 of file StdMeshMaterial.cpp.

813  :
814  Name(name), FragmentShader(fragment_shader), VertexShader(vertex_shader), GeometryShader(geometry_shader)
815 {
816  assert(FragmentShader != nullptr);
817  assert(VertexShader != nullptr);
818  // Geometry shader is optional (and not even implemented at the moment!)
819 }

Member Function Documentation

bool StdMeshMaterialProgram::AddParameterNames ( const StdMeshMaterialShaderParameters parameters)

Definition at line 821 of file StdMeshMaterial.cpp.

References StdMeshMaterialShaderParameters::NamedParameters.

Referenced by StdMeshMatManager::AddProgram().

822 {
823  // TODO: This is O(n^2) -- not optimal!
824  bool added = false;
825  for (const auto & NamedParameter : parameters.NamedParameters)
826  {
827  const std::vector<StdCopyStrBuf>::const_iterator iter = std::find(ParameterNames.begin(), ParameterNames.end(), NamedParameter.first);
828  if (iter == ParameterNames.end())
829  {
830  ParameterNames.push_back(NamedParameter.first);
831  added = true;
832  }
833  }
834 
835  return added;
836 }
std::vector< std::pair< StdCopyStrBuf, StdMeshMaterialShaderParameter > > NamedParameters

Here is the caller graph for this function:

bool StdMeshMaterialProgram::Compile ( StdMeshMaterialLoader loader)

Definition at line 896 of file StdMeshMaterial.cpp.

Referenced by StdMeshMatManager::AddProgram().

897 {
898 #ifndef USE_CONSOLE
899  if (!CompileShader(loader, Shader, 0)) return false;
900  if (!CompileShader(loader, ShaderMod2, C4SSC_MOD2)) return false;
901  if (!CompileShader(loader, ShaderLight, C4SSC_LIGHT)) return false;
902  if (!CompileShader(loader, ShaderLightMod2, C4SSC_LIGHT | C4SSC_MOD2)) return false;
903 #endif
904  return true;
905 }

Here is the caller graph for this function:

const StdMeshMaterialShader* StdMeshMaterialProgram::GetFragmentShader ( ) const
inline

Definition at line 168 of file StdMeshMaterial.h.

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

168 { return FragmentShader; }

Here is the caller graph for this function:

const StdMeshMaterialShader* StdMeshMaterialProgram::GetGeometryShader ( ) const
inline

Definition at line 170 of file StdMeshMaterial.h.

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

170 { return GeometryShader; }

Here is the caller graph for this function:

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

Definition at line 928 of file StdMeshMaterial.cpp.

References C4SSU_Count.

929 {
930 #ifndef USE_CONSOLE
931  std::vector<StdCopyStrBuf>::const_iterator iter = std::find(ParameterNames.begin(), ParameterNames.end(), name);
932  if(iter == ParameterNames.end()) return -1;
933  return C4SSU_Count + std::distance(ParameterNames.begin(), iter);
934 #else
935  return -1;
936 #endif
937 }
const C4Shader * StdMeshMaterialProgram::GetShader ( int  ssc) const

Definition at line 907 of file StdMeshMaterial.cpp.

908 {
909 #ifndef USE_CONSOLE
910  const C4Shader* shaders[4] = {
911  &Shader,
912  &ShaderMod2,
913  &ShaderLight,
914  &ShaderLightMod2
915  };
916 
917  int index = 0;
918  if(ssc & C4SSC_MOD2) index += 1;
919  if(ssc & C4SSC_LIGHT) index += 2;
920 
921  assert(index < 4);
922  return shaders[index];
923 #else
924  return nullptr;
925 #endif
926 }
const StdMeshMaterialShader* StdMeshMaterialProgram::GetVertexShader ( ) const
inline

Definition at line 169 of file StdMeshMaterial.h.

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

169 { return VertexShader; }

Here is the caller graph for this function:

bool StdMeshMaterialProgram::IsCompiled ( ) const
inline

Definition at line 162 of file StdMeshMaterial.h.

References C4Shader::Initialised().

Referenced by StdMeshMatManager::AddProgram().

162 { return Shader.Initialised(); }
bool Initialised() const
Definition: C4Shader.h:106

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: