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 {true}
 
bool DepthWrite {true}
 
CullHardwareType CullHardware {CH_Clockwise}
 
SceneBlendType SceneBlendFactors [2]
 
DepthFunctionType AlphaRejectionFunction
 
float AlphaRejectionValue
 
bool AlphaToCoverage
 
ShaderInstance FragmentShader
 
ShaderInstance VertexShader
 
ShaderInstance GeometryShader
 
std::shared_ptr< ProgramInstanceProgram
 

Detailed Description

Definition at line 370 of file StdMeshMaterial.h.


Class Documentation

struct StdMeshMaterialPass::ShaderInstance

Definition at line 429 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 373 of file StdMeshMaterial.h.

Constructor & Destructor Documentation

StdMeshMaterialPass::StdMeshMaterialPass ( )

Definition at line 1224 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.

1225 {
1226  Ambient[0] = Ambient[1] = Ambient[2] = 1.0f; Ambient[3] = 1.0f;
1227  Diffuse[0] = Diffuse[1] = Diffuse[2] = 1.0f; Diffuse[3] = 1.0f;
1228  Specular[0] = Specular[1] = Specular[2] = 0.0f; Specular[3] = 0.0f;
1229  Emissive[0] = Emissive[1] = Emissive[2] = 0.0f; Emissive[3] = 0.0f;
1230  Shininess = 0.0f;
1233  AlphaToCoverage = false;
1235 }
ShaderInstance FragmentShader
ShaderInstance GeometryShader
SceneBlendType SceneBlendFactors[2]
const StdMeshMaterialShader * Shader
ShaderInstance VertexShader
DepthFunctionType AlphaRejectionFunction

Member Function Documentation

bool StdMeshMaterialPass::IsOpaque ( ) const
inline

Definition at line 409 of file StdMeshMaterial.h.

References SB_Zero, and SceneBlendFactors.

void StdMeshMaterialPass::Load ( StdMeshMaterialParserCtx ctx)

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

1278 {
1279  Token token;
1280  StdCopyStrBuf token_name;
1281  StdMeshMaterialSubLoader texture_unit_loader;
1282  while ((token = ctx.AdvanceNonEOF(token_name)) == TOKEN_IDTF)
1283  {
1284  if (token_name == "texture_unit")
1285  {
1286  texture_unit_loader.Load(ctx, TextureUnits);
1287  }
1288  else if (token_name == "ambient")
1289  {
1290  ctx.AdvanceColor(true, Ambient);
1291  }
1292  else if (token_name == "diffuse")
1293  {
1294  ctx.AdvanceColor(true, Diffuse);
1295  }
1296  else if (token_name == "specular")
1297  {
1298  Specular[0] = ctx.AdvanceFloat();
1299  Specular[1] = ctx.AdvanceFloat();
1300  Specular[2] = ctx.AdvanceFloat();
1301 
1302  // The fourth argument is optional, not the fifth:
1303  float specular3 = ctx.AdvanceFloat();
1304 
1305  float shininess;
1306  if (ctx.AdvanceFloatOptional(shininess))
1307  {
1308  Specular[3] = specular3;
1309  Shininess = shininess;
1310  }
1311  else
1312  {
1313  Shininess = specular3;
1314  }
1315  }
1316  else if (token_name == "emissive")
1317  {
1318  ctx.AdvanceColor(true, Emissive);
1319  }
1320  else if (token_name == "depth_check")
1321  {
1322  DepthCheck = ctx.AdvanceBoolean();
1323  }
1324  else if (token_name == "depth_write")
1325  {
1326  DepthWrite = ctx.AdvanceBoolean();
1327  }
1328  else if (token_name == "cull_hardware")
1329  {
1330  CullHardware = ctx.AdvanceEnum(CullHardwareEnumerators);
1331  }
1332  else if (token_name == "scene_blend")
1333  {
1334  ctx.AdvanceEnums<2, StdMeshMaterialPass::SceneBlendType>(SceneBlendEnumerators, SceneBlendShortcuts, SceneBlendFactors);
1335  }
1336  else if (token_name == "scene_blend_op")
1337  {
1338  StdStrBuf op;
1339  ctx.AdvanceRequired(op, TOKEN_IDTF);
1340  ctx.WarningNotSupported(token_name.getData());
1341  }
1342  else if (token_name == "alpha_rejection")
1343  {
1344  AlphaRejectionFunction = ctx.AdvanceEnum(DepthFunctionEnumerators);
1346  AlphaRejectionValue = ctx.AdvanceFloat() / 255.0f;
1347  }
1348  else if (token_name == "alpha_to_coverage")
1349  {
1351  }
1352  else if (token_name == "colour_write")
1353  {
1354  ctx.AdvanceBoolean();
1355  ctx.WarningNotSupported("colour_write");
1356  }
1357  else if (token_name == "depth_func")
1358  {
1359  StdStrBuf func;
1360  ctx.AdvanceRequired(func, TOKEN_IDTF);
1361  ctx.WarningNotSupported(token_name.getData());
1362  }
1363  else if (token_name == "illumination_stage")
1364  {
1365  ctx.WarningNotSupported(token_name.getData());
1366  }
1367  else if (token_name == "light_clip_planes")
1368  {
1369  ctx.AdvanceBoolean();
1370  ctx.WarningNotSupported(token_name.getData());
1371  }
1372  else if (token_name == "light_scissor")
1373  {
1374  ctx.AdvanceBoolean();
1375  ctx.WarningNotSupported(token_name.getData());
1376  }
1377  else if (token_name == "lighting")
1378  {
1379  ctx.AdvanceBoolean();
1380  ctx.WarningNotSupported(token_name.getData());
1381  }
1382  else if (token_name == "normalise_normals" || token_name == "normalize_normals")
1383  {
1384  ctx.AdvanceBoolean();
1385  ctx.WarningNotSupported(token_name.getData());
1386  }
1387  else if (token_name == "polygon_mode")
1388  {
1389  StdStrBuf mode;
1390  ctx.AdvanceRequired(mode, TOKEN_IDTF);
1391  ctx.WarningNotSupported(token_name.getData());
1392  }
1393  else if (token_name == "shading")
1394  {
1395  StdStrBuf shading;
1396  ctx.AdvanceRequired(shading, TOKEN_IDTF);
1397  ctx.WarningNotSupported(token_name.getData());
1398  }
1399  else if (token_name == "transparent_sorting")
1400  {
1401  ctx.AdvanceBoolean();
1402  ctx.WarningNotSupported(token_name.getData());
1403  }
1404  else if (token_name == "vertex_program_ref")
1405  {
1406  LoadShaderRef(ctx, SMMS_VERTEX);
1407  }
1408  else if (token_name == "fragment_program_ref")
1409  {
1410  LoadShaderRef(ctx, SMMS_FRAGMENT);
1411  }
1412  else if (token_name == "geometry_program_ref")
1413  {
1414  LoadShaderRef(ctx, SMMS_GEOMETRY);
1415  }
1416  else
1417  ctx.ErrorUnexpectedIdentifier(token_name);
1418  }
1419 
1420  if (token != TOKEN_BRACE_CLOSE)
1421  ctx.Error(StdCopyStrBuf("'") + token_name.getData() + "' unexpected");
1422 }
const char * getData() const
Definition: StdBuf.h:442
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 425 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

float StdMeshMaterialPass::AlphaRejectionValue

Definition at line 426 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

bool StdMeshMaterialPass::AlphaToCoverage

Definition at line 427 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

float StdMeshMaterialPass::Ambient[4]

Definition at line 414 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

CullHardwareType StdMeshMaterialPass::CullHardware {CH_Clockwise}

Definition at line 423 of file StdMeshMaterial.h.

Referenced by Load().

bool StdMeshMaterialPass::DepthCheck {true}

Definition at line 420 of file StdMeshMaterial.h.

Referenced by Load().

bool StdMeshMaterialPass::DepthWrite {true}

Definition at line 421 of file StdMeshMaterial.h.

Referenced by Load().

float StdMeshMaterialPass::Diffuse[4]

Definition at line 415 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

float StdMeshMaterialPass::Emissive[4]

Definition at line 417 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

ShaderInstance StdMeshMaterialPass::FragmentShader

Definition at line 457 of file StdMeshMaterial.h.

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

ShaderInstance StdMeshMaterialPass::GeometryShader

Definition at line 459 of file StdMeshMaterial.h.

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

StdCopyStrBuf StdMeshMaterialPass::Name

Definition at line 411 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial().

std::shared_ptr<ProgramInstance> StdMeshMaterialPass::Program

Definition at line 468 of file StdMeshMaterial.h.

Referenced by CStdGL::PrepareMaterial().

SceneBlendType StdMeshMaterialPass::SceneBlendFactors[2]

Definition at line 424 of file StdMeshMaterial.h.

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

float StdMeshMaterialPass::Shininess

Definition at line 418 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

float StdMeshMaterialPass::Specular[4]

Definition at line 416 of file StdMeshMaterial.h.

Referenced by Load(), and StdMeshMaterialPass().

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

Definition at line 458 of file StdMeshMaterial.h.

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


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