OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4DefAdditionalResourcesLoader Class Reference
Inheritance diagram for C4DefAdditionalResourcesLoader:
[legend]
Collaboration diagram for C4DefAdditionalResourcesLoader:
[legend]

Public Member Functions

 C4DefAdditionalResourcesLoader (C4Group &hGroup)
 
C4SurfaceLoadTexture (const char *filename) override
 
StdStrBuf LoadShaderCode (const char *filename) override
 
void AddShaderSlices (C4Shader &shader, int ssc) override
 

Detailed Description

Definition at line 40 of file C4Def.cpp.

Constructor & Destructor Documentation

C4DefAdditionalResourcesLoader::C4DefAdditionalResourcesLoader ( C4Group hGroup)
inline

Definition at line 43 of file C4Def.cpp.

43 : Group(hGroup) {}

Member Function Documentation

void C4DefAdditionalResourcesLoader::AddShaderSlices ( C4Shader shader,
int  ssc 
)
inlineoverridevirtual

Implements StdMeshMaterialLoader.

Definition at line 63 of file C4Def.cpp.

References C4Shader::AddDefine(), C4GraphicsResource::Files, GraphicsResource, C4Shader::LoadFragmentSlices(), and C4Shader::SetScriptCategories().

64  {
65 #ifndef USE_CONSOLE
66  // Add mesh-independent slices
67  shader.AddDefine("OPENCLONK");
68  shader.AddDefine("OC_MESH");
69 
70  if (ssc & C4SSC_MOD2) shader.AddDefine("OC_CLRMOD_MOD2");
71  if (ssc & C4SSC_LIGHT) shader.AddDefine("OC_DYNAMIC_LIGHT");
72 
73  // Note these are never set for meshes at the moment:
74  if (ssc & C4SSC_BASE) shader.AddDefine("OC_HAVE_BASE");
75  if (ssc & C4SSC_OVERLAY) shader.AddDefine("OC_HAVE_OVERLAY");
76 
77  shader.LoadFragmentSlices(&::GraphicsResource.Files, "CommonShader.glsl");
78  shader.LoadFragmentSlices(&::GraphicsResource.Files, "ObjectShader.glsl");
79 
80  // Categories for script shaders.
81  shader.SetScriptCategories({"Common", "Object"});
82 #endif
83  }
void SetScriptCategories(const std::vector< std::string > &categories)
Definition: C4Shader.cpp:100
bool LoadFragmentSlices(C4GroupSet *pGroupSet, const char *szFile)
Definition: C4Shader.cpp:90
void AddDefine(const char *name)
Definition: C4Shader.cpp:63
C4GraphicsResource GraphicsResource

Here is the call graph for this function:

StdStrBuf C4DefAdditionalResourcesLoader::LoadShaderCode ( const char *  filename)
inlineoverridevirtual

Implements StdMeshMaterialLoader.

Definition at line 56 of file C4Def.cpp.

References C4Group::LoadEntryString().

57  {
58  StdStrBuf ret;
59  if (!Group.LoadEntryString(filename, &ret)) return StdStrBuf();
60  return ret;
61  }
bool LoadEntryString(const char *szEntryName, StdStrBuf *Buf)
Definition: C4Group.cpp:1932

Here is the call graph for this function:

C4Surface* C4DefAdditionalResourcesLoader::LoadTexture ( const char *  filename)
inlineoverridevirtual

Implements StdMeshMaterialLoader.

Definition at line 45 of file C4Def.cpp.

References C4Group::AccessEntry(), C4SF_MipMap, GetExtension(), and C4Surface::Read().

46  {
47  if (!Group.AccessEntry(filename)) return nullptr;
48  C4Surface* surface = new C4Surface;
49  // Suppress error message here, StdMeshMaterial loader
50  // will show one.
51  if (!surface->Read(Group, GetExtension(filename), C4SF_MipMap))
52  { delete surface; surface = nullptr; }
53  return surface;
54  }
bool AccessEntry(const char *szWildCard, size_t *iSize=nullptr, char *sFileName=nullptr, bool NeedsToBeAGroup=false)
Definition: C4Group.cpp:1695
const int C4SF_MipMap
Definition: C4Surface.h:50
char * GetExtension(char *szFilename)
Definition: StdFile.cpp:121
bool Read(CStdStream &hGroup, const char *extension, int iFlags)

Here is the call graph for this function:


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