HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GlslSyntax.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_GLSL_SYNTAX_H
7 #define MATERIALX_GLSL_SYNTAX_H
8 
9 /// @file
10 /// GLSL syntax class
11 
13 
15 
17 
18 /// Syntax class for GLSL (OpenGL Shading Language)
20 {
21  public:
22  GlslSyntax(TypeSystemPtr typeSystem);
23 
24  static SyntaxPtr create(TypeSystemPtr typeSystem) { return std::make_shared<GlslSyntax>(typeSystem); }
25 
26  const string& getInputQualifier() const override { return INPUT_QUALIFIER; }
27  const string& getOutputQualifier() const override { return OUTPUT_QUALIFIER; }
28  const string& getConstantQualifier() const override { return CONSTANT_QUALIFIER; };
29  const string& getUniformQualifier() const override { return UNIFORM_QUALIFIER; };
30  const string& getSourceFileExtension() const override { return SOURCE_FILE_EXTENSION; };
31 
32  bool typeSupported(const TypeDesc* type) const override;
33 
34  /// Given an input specification attempt to remap this to an enumeration which is accepted by
35  /// the shader generator. The enumeration may be converted to a different type than the input.
36  bool remapEnumeration(const string& value, TypeDesc type, const string& enumNames, std::pair<TypeDesc, ValuePtr>& result) const override;
37 
38  StructTypeSyntaxPtr createStructSyntax(const string& structTypeName, const string& defaultValue,
39  const string& uniformDefaultValue, const string& typeAlias,
40  const string& typeDefinition) const override;
41 
42  static const string INPUT_QUALIFIER;
43  static const string OUTPUT_QUALIFIER;
44  static const string UNIFORM_QUALIFIER;
45  static const string CONSTANT_QUALIFIER;
46  static const string FLAT_QUALIFIER;
47  static const string SOURCE_FILE_EXTENSION;
48 
49  static const StringVec VEC2_MEMBERS;
50  static const StringVec VEC3_MEMBERS;
51  static const StringVec VEC4_MEMBERS;
52 };
53 
54 /// Specialization of TypeSyntax for aggregate types.
56 {
57  public:
59 
60  string getValue(const Value& value, bool uniform) const override;
61 };
62 
64 
65 #endif
string getValue(const Value &value, bool uniform) const override
shared_ptr< StructTypeSyntax > StructTypeSyntaxPtr
Shared pointer to a StructTypeSyntax.
Definition: Syntax.h:34
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
vector< string > StringVec
A vector of strings.
Definition: Library.h:60
virtual bool typeSupported(const TypeDesc *type) const
GLsizei const GLfloat * value
Definition: glcorearb.h:824
shared_ptr< Syntax > SyntaxPtr
Shared pointer to a Syntax.
Definition: Syntax.h:28
static const string INPUT_QUALIFIER
Definition: GlslSyntax.h:42
**But if you need a result
Definition: thread.h:622
shared_ptr< class TypeSystem > TypeSystemPtr
Definition: TypeDesc.h:219
static const StringVec VEC3_MEMBERS
Definition: GlslSyntax.h:50
static const StringVec VEC2_MEMBERS
Definition: GlslSyntax.h:49
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
Syntax class for GLSL (OpenGL Shading Language)
Definition: GlslSyntax.h:19
Specialization of TypeSyntax for aggregate types.
Definition: GlslSyntax.h:55
static const string FLAT_QUALIFIER
Definition: GlslSyntax.h:46
A generic, discriminated value, whose type may be queried dynamically.
Definition: Value.h:45
const string & getOutputQualifier() const override
Definition: GlslSyntax.h:27
const string & getConstantQualifier() const override
Definition: GlslSyntax.h:28
virtual StructTypeSyntaxPtr createStructSyntax(const string &structTypeName, const string &defaultValue, const string &uniformDefaultValue, const string &typeAlias, const string &typeDefinition) const
static SyntaxPtr create(TypeSystemPtr typeSystem)
Definition: GlslSyntax.h:24
virtual bool remapEnumeration(const string &value, TypeDesc type, const string &enumNames, std::pair< TypeDesc, ValuePtr > &result) const
static const string OUTPUT_QUALIFIER
Definition: GlslSyntax.h:43
const string & getInputQualifier() const override
Definition: GlslSyntax.h:26
static const string SOURCE_FILE_EXTENSION
Definition: GlslSyntax.h:47
static const StringVec VEC4_MEMBERS
Definition: GlslSyntax.h:51
static const string UNIFORM_QUALIFIER
Definition: GlslSyntax.h:44
StructTypeSyntax(const Syntax *parent, const string &name, const string &defaultValue, const string &uniformDefaultValue, const string &typeAlias=EMPTY_STRING, const string &typeDefinition=EMPTY_STRING, const StringVec &members=EMPTY_MEMBERS)
const string & getSourceFileExtension() const override
Return the file extension used for source code files in this language.
Definition: GlslSyntax.h:30
static const string CONSTANT_QUALIFIER
Definition: GlslSyntax.h:45
const string & getUniformQualifier() const override
Definition: GlslSyntax.h:29
Specialization of TypeSyntax for struct types.
Definition: Syntax.h:309
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
Definition: Syntax.h:43
#define MX_GENGLSL_API
Definition: Export.h:18