OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
StdMeshMaterial.cpp File Reference
Include dependency graph for StdMeshMaterial.cpp:

Go to the source code of this file.

Classes

class  StdMeshMaterialParserCtx
 
class  StdMeshMaterialSubLoader
 

Enumerations

enum  Token {
  TOKEN_IDTF, TOKEN_BRACE_OPEN, TOKEN_BRACE_CLOSE, TOKEN_COLON,
  TOKEN_EOF
}
 

Functions

void LoadShader (StdMeshMaterialParserCtx &ctx, StdMeshMaterialShaderType type)
 

Variables

StdMeshMatManager MeshMaterialManager
 

Enumeration Type Documentation

enum Token
Enumerator
TOKEN_IDTF 
TOKEN_BRACE_OPEN 
TOKEN_BRACE_CLOSE 
TOKEN_COLON 
TOKEN_EOF 

Definition at line 190 of file StdMeshMaterial.cpp.

Function Documentation

void LoadShader ( StdMeshMaterialParserCtx ctx,
StdMeshMaterialShaderType  type 
)

Definition at line 584 of file StdMeshMaterial.cpp.

References StdMeshMatManager::AddShader(), StdMeshMaterialParserCtx::AdvanceNonEOF(), StdMeshMaterialParserCtx::AdvanceRequired(), StdMeshMaterialParserCtx::Error(), StdMeshMaterialParserCtx::ErrorUnexpectedIdentifier(), StdStrBuf::getData(), StdStrBuf::getLength(), StdMeshMaterialParserCtx::Loader, StdMeshMaterialLoader::LoadShaderCode(), StdMeshMaterialParserCtx::Manager, StdMeshMatManager::SMM_ForceReload, TOKEN_BRACE_CLOSE, TOKEN_BRACE_OPEN, and TOKEN_IDTF.

Referenced by StdMeshMatManager::Parse().

585 {
586  StdStrBuf token_name;
587  StdStrBuf name, language;
588  ctx.AdvanceRequired(name, TOKEN_IDTF);
589  ctx.AdvanceRequired(language, TOKEN_IDTF);
590  ctx.AdvanceRequired(token_name, TOKEN_BRACE_OPEN);
591 
592  Token token;
593  StdCopyStrBuf source, code, syntax;
594  while ((token = ctx.AdvanceNonEOF(token_name)) == TOKEN_IDTF)
595  {
596  if(token_name == "source")
597  {
598  ctx.AdvanceRequired(source, TOKEN_IDTF);
599  code = ctx.Loader.LoadShaderCode(source.getData());
600  if(code.getLength() == 0)
601  ctx.Error(StdCopyStrBuf("Could not load shader code from '") + source + "'");
602  }
603  else if(token_name == "syntax")
604  {
605  ctx.AdvanceRequired(syntax, TOKEN_IDTF);
606  }
607  else
608  {
609  ctx.ErrorUnexpectedIdentifier(token_name);
610  }
611  }
612 
613  if (token != TOKEN_BRACE_CLOSE)
614  ctx.Error(StdCopyStrBuf("'") + token_name.getData() + "' unexpected");
615 
616  ctx.Manager.AddShader(source.getData(), name.getData(), language.getData(), type, code.getData(), StdMeshMatManager::SMM_ForceReload);
617 }
const char * getData() const
Definition: StdBuf.h:442
Token AdvanceRequired(StdStrBuf &name, Token expect)
void ErrorUnexpectedIdentifier(const StdStrBuf &identifier)
void Error(const StdStrBuf &message)
Token AdvanceNonEOF(StdStrBuf &name)
StdMeshMatManager & Manager
virtual StdStrBuf LoadShaderCode(const char *filename)=0
StdMeshMaterialLoader & Loader
size_t getLength() const
Definition: StdBuf.h:445
const StdMeshMaterialShader * AddShader(const char *filename, const char *name, const char *language, StdMeshMaterialShaderType type, const char *text, uint32_t load_flags)

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation