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

#include <StdMeshMaterial.h>

Collaboration diagram for StdMeshMaterialPass:
[legend]

Classes

class  ProgramInstance
 
struct  ShaderInstance
 

Public Types

enum  CullHardwareType { CH_Clockwise, CH_CounterClockwise, CH_None }
 
enum  SceneBlendType {
  SB_One, SB_Zero, SB_DestColor, SB_SrcColor,
  SB_OneMinusDestColor, SB_OneMinusSrcColor, SB_DestAlpha, SB_SrcAlpha,
  SB_OneMinusDestAlpha, SB_OneMinusSrcAlpha
}
 
enum  DepthFunctionType {
  DF_AlwaysFail, DF_AlwaysPass, DF_Less, DF_LessEqual,
  DF_Equal, DF_NotEqual, DF_GreaterEqual, DF_Greater
}
 

Public Member Functions

 StdMeshMaterialPass ()
 
void Load (StdMeshMaterialParserCtx &ctx)
 
bool IsOpaque () const
 

Public Attributes

StdCopyStrBuf Name
 
std::vector
< StdMeshMaterialTextureUnit
TextureUnits
 
float Ambient [4]
 
float Diffuse [4]
 
float Specular [4]
 
float Emissive [4]
 
float Shininess
 
bool DepthCheck
 
bool DepthWrite
 
CullHardwareType CullHardware
 
SceneBlendType SceneBlendFactors [2]
 
DepthFunctionType AlphaRejectionFunction
 
float AlphaRejectionValue
 
bool AlphaToCoverage
 
ShaderInstance FragmentShader
 
ShaderInstance VertexShader
 
ShaderInstance GeometryShader
 
std::shared_ptr< ProgramInstanceProgram
 

Detailed Description

Definition at line 373 of file StdMeshMaterial.h.


Class Documentation

struct StdMeshMaterialPass::ShaderInstance

Definition at line 432 of file StdMeshMaterial.h.

Collaboration diagram for StdMeshMaterialPass::ShaderInstance:
[legend]
Class Members
StdMeshMaterialShaderParameters Parameters
const StdMeshMaterialShader * Shader

Member Enumeration Documentation

Enumerator
CH_Clockwise 
CH_CounterClockwise 
CH_None 

Definition at line 376 of file StdMeshMaterial.h.

Constructor & Destructor Documentation

StdMeshMaterialPass::StdMeshMaterialPass ( )

Definition at line 1244 of file StdMeshMaterial.cpp.

References AlphaRejectionFunction, AlphaRejectionValue, AlphaToCoverage, Ambient, DF_AlwaysPass, Diffuse, Emissive, FragmentShader, GeometryShader, SB_One, SB_Zero, SceneBlendFactors, StdMeshMaterialPass::ShaderInstance::Shader, Shininess, Specular, and VertexShader.

1244  :
1246 {
1247  Ambient[0] = Ambient[1] = Ambient[2] = 1.0f; Ambient[3] = 1.0f;
1248  Diffuse[0] = Diffuse[1] = Diffuse[2] = 1.0f; Diffuse[3] = 1.0f;
1249  Specular[0] = Specular[1] = Specular[2] = 0.0f; Specular[3] = 0.0f;
1250  Emissive[0] = Emissive[1] = Emissive[2] = 0.0f; Emissive[3] = 0.0f;
1251  Shininess = 0.0f;
1254  AlphaToCoverage = false;
1256 }
ShaderInstance FragmentShader
ShaderInstance GeometryShader
SceneBlendType SceneBlendFactors[2]
const StdMeshMaterialShader * Shader
ShaderInstance VertexShader
CullHardwareType CullHardware
DepthFunctionType AlphaRejectionFunction

Member Function Documentation

bool StdMeshMaterialPass::IsOpaque ( ) const
inline

Definition at line 412 of file StdMeshMaterial.h.

References SB_Zero, and SceneBlendFactors.

void StdMeshMaterialPass::Load ( StdMeshMaterialParserCtx ctx)

Definition at line 1298 of file StdMeshMaterial.cpp.

References StdMeshMaterialParserCtx::AdvanceBoolean(), StdMeshMaterialParserCtx::AdvanceColor(), StdMeshMaterialParserCtx::AdvanceEnum(), StdMeshMaterialParserCtx::AdvanceEnums(), StdMeshMaterialParserCtx::AdvanceFloat(), StdMeshMaterialParserCtx::AdvanceFloatOptional(), StdMeshMaterialParserCtx::AdvanceNonEOF(), StdMeshMaterialParserCtx::AdvanceRequired(), AlphaRejectionFunction, AlphaRejectionValue, AlphaToCoverage, Ambient, CullHardware, DepthCheck, DepthWrite, DF_AlwaysFail, DF_AlwaysPass, Diffuse, Emissive, StdMeshMaterialParserCtx::Error(), StdMeshMaterialParserCtx::ErrorUnexpectedIdentifier(), StdStrBuf::getData(), StdMeshMaterialSubLoader::Load(), SceneBlendFactors, Shininess, SMMS_FRAGMENT, SMMS_GEOMETRY, SMMS_VERTEX, Specular, TextureUnits, TOKEN_BRACE_CLOSE, TOKEN_IDTF, and StdMeshMaterialParserCtx::WarningNotSupported().

1299 {
1300  Token token;
1301  StdCopyStrBuf token_name;
1302  StdMeshMaterialSubLoader texture_unit_loader;
1303  while ((token = ctx.AdvanceNonEOF(token_name)) == TOKEN_IDTF)
1304  {
1305  if (token_name == "texture_unit")
1306  {
1307  texture_unit_loader.Load(ctx, TextureUnits);
1308  }
1309  else if (token_name == "ambient")
1310  {
1311  ctx.AdvanceColor(true, Ambient);
1312  }
1313  else if (token_name == "diffuse")
1314  {
1315  ctx.AdvanceColor(true, Diffuse);
1316  }
1317  else if (token_name == "specular")
1318  {
1319  Specular[0] = ctx.AdvanceFloat();
1320  Specular[1] = ctx.AdvanceFloat();
1321  Specular[2] = ctx.AdvanceFloat();
1322 
1323  // The fourth argument is optional, not the fifth:
1324  float specular3 = ctx.AdvanceFloat();
1325 
1326  float shininess;
1327  if (ctx.AdvanceFloatOptional(shininess))
1328  {
1329  Specular[3] = specular3;
1330  Shininess = shininess;
1331  }
1332  else
1333  {
1334  Shininess = specular3;
1335  }
1336  }
1337  else if (token_name == "emissive")
1338  {
1339  ctx.AdvanceColor(true, Emissive);
1340  }
1341  else if (token_name == "depth_check")
1342  {
1343  DepthCheck = ctx.AdvanceBoolean();
1344  }
1345  else if (token_name == "depth_write")
1346  {
1347  DepthWrite = ctx.AdvanceBoolean();
1348  }
1349  else if (token_name == "cull_hardware")
1350  {
1351  CullHardware = ctx.AdvanceEnum(CullHardwareEnumerators);
1352  }
1353  else if (token_name == "scene_blend")
1354  {
1355  ctx.AdvanceEnums<2, StdMeshMaterialPass::SceneBlendType>(SceneBlendEnumerators, SceneBlendShortcuts, SceneBlendFactors);
1356  }
1357  else if (token_name == "scene_blend_op")
1358  {
1359  StdStrBuf op;
1360  ctx.AdvanceRequired(op, TOKEN_IDTF);
1361  ctx.WarningNotSupported(token_name.getData());
1362  }
1363  else if (token_name == "alpha_rejection")
1364  {
1365  AlphaRejectionFunction = ctx.AdvanceEnum(DepthFunctionEnumerators);
1367  AlphaRejectionValue = ctx.AdvanceFloat() / 255.0f;
1368  }
1369  else if (token_name == "alpha_to_coverage")
1370  {
1372  }
1373  else if (token_name == "colour_write")
1374  {
1375  ctx.AdvanceBoolean();
1376  ctx.WarningNotSupported("colour_write");
1377  }
1378  else if (token_name == "depth_func")
1379  {
1380  StdStrBuf func;
1381  ctx.AdvanceRequired(func, TOKEN_IDTF);
1382  ctx.WarningNotSupported(token_name.getData());
1383  }
1384  else if (token_name == "illumination_stage")
1385  {
1386  ctx.WarningNotSupported(token_name.getData());
1387  }
1388  else if (token_name == "light_clip_planes")
1389  {
1390  ctx.AdvanceBoolean();
1391  ctx.WarningNotSupported(token_name.getData());
1392  }
1393  else if (token_name == "light_scissor")
1394  {
1395  ctx.AdvanceBoolean();
1396  ctx.WarningNotSupported(token_name.getData());
1397  }
1398  else if (token_name == "lighting")
1399  {
1400  ctx.AdvanceBoolean();
1401  ctx.WarningNotSupported(token_name.getData());
1402  }
1403  else if (token_name == "normalise_normals" || token_name == "normalize_normals")
1404  {
1405  ctx.AdvanceBoolean();
1406  ctx.WarningNotSupported(token_name.getData());
1407  }
1408  else if (token_name == "polygon_mode")
1409  {
1410  StdStrBuf mode;
1411  ctx.AdvanceRequired(mode, TOKEN_IDTF);
1412  ctx.WarningNotSupported(token_name.getData());
1413  }
1414  else if (token_name == "shading")
1415  {
1416  StdStrBuf shading;
1417  ctx.AdvanceRequired(shading, TOKEN_IDTF);
1418  ctx.WarningNotSupported(token_name.getData());
1419  }
1420  else if (token_name == "transparent_sorting")
1421  {
1422  ctx.AdvanceBoolean();
1423  ctx.WarningNotSupported(token_name.getData());
1424  }
1425  else if (token_name == "vertex_program_ref")
1426  {
1427  LoadShaderRef(ctx, SMMS_VERTEX);
1428  }
1429  else if (token_name == "fragment_program_ref")
1430  {
1431  LoadShaderRef(ctx, SMMS_FRAGMENT);
1432  }
1433  else if (token_name == "geometry_program_ref")
1434  {
1435  LoadShaderRef(ctx, SMMS_GEOMETRY);
1436  }
1437  else
1438  ctx.ErrorUnexpectedIdentifier(token_name);
1439  }
1440 
1441  if (token != TOKEN_BRACE_CLOSE)
1442  ctx.Error(StdCopyStrBuf("'") + token_name.getData() + "' unexpected");
1443 }
const char * getData() const
Definition: StdBuf.h:450
Token AdvanceRequired(StdStrBuf &name, Token expect)
EnumType AdvanceEnum(const Enumerator< EnumType > *enumerators)
void AdvanceColor(bool with_alpha, float Color[4])
void ErrorUnexpectedIdentifier(const StdStrBuf &identifier)
void Error(const StdStrBuf &message)
SceneBlendType SceneBlendFactors[2]
Token AdvanceNonEOF(StdStrBuf &name)
bool AdvanceFloatOptional(float &value)
void AdvanceEnums(const Enumerator< EnumType > *enumerators, EnumType enums[Num])
void WarningNotSupported(const char *identifier)
CullHardwareType CullHardware
std::vector< StdMeshMaterialTextureUnit > TextureUnits
void Load(StdMeshMaterialParserCtx &ctx, std::vector< SubT > &vec)
DepthFunctionType AlphaRejectionFunction

Here is the call graph for this function:

Member Data Documentation

DepthFunctionType StdMeshMaterialPass::AlphaRejectionFunction

Definition at line 428 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

float StdMeshMaterialPass::AlphaRejectionValue

Definition at line 429 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

bool StdMeshMaterialPass::AlphaToCoverage

Definition at line 430 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

float StdMeshMaterialPass::Ambient[4]

Definition at line 417 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

CullHardwareType StdMeshMaterialPass::CullHardware

Definition at line 426 of file StdMeshMaterial.h.

Referenced by Load().

bool StdMeshMaterialPass::DepthCheck

Definition at line 423 of file StdMeshMaterial.h.

Referenced by Load().

bool StdMeshMaterialPass::DepthWrite

Definition at line 424 of file StdMeshMaterial.h.

Referenced by Load().

float StdMeshMaterialPass::Diffuse[4]

Definition at line 418 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

float StdMeshMaterialPass::Emissive[4]

Definition at line 420 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

ShaderInstance StdMeshMaterialPass::FragmentShader

Definition at line 460 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial(), and StdMeshMaterialPass().

ShaderInstance StdMeshMaterialPass::GeometryShader

Definition at line 462 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial(), and StdMeshMaterialPass().

StdCopyStrBuf StdMeshMaterialPass::Name

Definition at line 414 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial().

std::shared_ptr<ProgramInstance> StdMeshMaterialPass::Program

Definition at line 471 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial().

SceneBlendType StdMeshMaterialPass::SceneBlendFactors[2]

Definition at line 427 of file StdMeshMaterial.h.

Referenced by IsOpaque(), Load(), and StdMeshMaterialPass().

float StdMeshMaterialPass::Shininess

Definition at line 421 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

float StdMeshMaterialPass::Specular[4]

Definition at line 419 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

std::vector<StdMeshMaterialTextureUnit> StdMeshMaterialPass::TextureUnits
ShaderInstance StdMeshMaterialPass::VertexShader

Definition at line 461 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial(), and StdMeshMaterialPass().


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