OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
StdMeshMaterial.cpp File Reference
#include "C4Include.h"
#include "C4ForbidLibraryCompilation.h"
#include "lib/StdMeshMaterial.h"
#include "lib/StdMeshUpdate.h"
#include "graphics/C4DrawGL.h"
#include <cctype>
#include <memory>
#include <math.h>
#include <sstream>
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 200 of file StdMeshMaterial.cpp.

Function Documentation

void LoadShader ( StdMeshMaterialParserCtx ctx,
StdMeshMaterialShaderType  type 
)

Definition at line 597 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().

598 {
599  StdStrBuf token_name;
600  StdStrBuf name, language;
601  ctx.AdvanceRequired(name, TOKEN_IDTF);
602  ctx.AdvanceRequired(language, TOKEN_IDTF);
603  ctx.AdvanceRequired(token_name, TOKEN_BRACE_OPEN);
604 
605  Token token;
606  StdCopyStrBuf source, code, syntax;
607  while ((token = ctx.AdvanceNonEOF(token_name)) == TOKEN_IDTF)
608  {
609  if(token_name == "source")
610  {
611  ctx.AdvanceRequired(source, TOKEN_IDTF);
612  code = ctx.Loader.LoadShaderCode(source.getData());
613  if(code.getLength() == 0)
614  ctx.Error(StdCopyStrBuf("Could not load shader code from '") + source + "'");
615  }
616  else if(token_name == "syntax")
617  {
618  ctx.AdvanceRequired(syntax, TOKEN_IDTF);
619  }
620  else
621  {
622  ctx.ErrorUnexpectedIdentifier(token_name);
623  }
624  }
625 
626  if (token != TOKEN_BRACE_CLOSE)
627  ctx.Error(StdCopyStrBuf("'") + token_name.getData() + "' unexpected");
628 
629  ctx.Manager.AddShader(source.getData(), name.getData(), language.getData(), type, code.getData(), StdMeshMatManager::SMM_ForceReload);
630 }
const char * getData() const
Definition: StdBuf.h:450
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:453
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