HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VOP_LanguageContextTypeList.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: VOP_LanguageContextTypeList.h ( VOP Library, C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __VOP_LanguageContextTypeList__
13 #define __VOP_LanguageContextTypeList__
14 
15 #include "VOP_API.h"
16 #include <SYS/SYS_Deprecated.h>
17 #include <UT/UT_StringHolder.h>
18 #include "VOP_Types.h"
19 class UT_StringArray;
20 class OP_Node;
21 
22 /// A class that abstracts shader types and shader context types.
23 /// It encapsulates shader types that make up a given vopnet node,
24 /// and also shader contexts conavailable inside that vopnet.
25 ///
26 /// This class is used to determine variables available in Global VOP
27 /// (as a menu of available context types), constituent shaders in
28 /// Vars Output VOP (as a menu of available shader type), and final form
29 /// of a shader source code n View VEX Code (as a menu of shader types), etc.
30 ///
31 /// A shader type represents a shader kind. It could be a surface,
32 /// a displacement, but also a geometry or a class. It corresponds to VOP_Type.
33 ///
34 /// A context type represents a language support for a given shader type.
35 /// Context determines global variables and functions available to implement
36 /// a given shader type in a given language.
37 /// But not all shader types have corresponding contexts, if they can't be
38 /// implemented in a given language, for example, like geometry shader type.
39 /// Context type is represented by VOP_ContextType.
41 {
42 public:
43  /// @{ Default c-tor de-tor.
46  /// @}
47 
48  /// Constructor for representing a shader type in a given language.
49  /// Some shader types (eg, a material or a class) may represent
50  /// a structured shader that consists of several sub-shader types.
51  /// In such cases the list of sub-shaders can be provided explicitly.
52  ///
53  /// @param language_type Shader's language type.
54  /// It determines the shader context types that are available,
55  /// which in turn determine global variables and functions
56  /// available to the shader. It is needed if (some) shader types
57  /// are implemented thru VOP networks.
58  ///
59  /// @param shader_type The shader type.
60  /// For a single-context node, it represents its shader type.
61  /// For multi-context nodes, it represents the master shader type
62  /// (eg, material or a class).
63  ///
64  /// @param sub_types For a multi-context node, this parameter
65  /// explicitly lists the constituent shader types that make up
66  /// the master shader. Eg, a material may allow surf and disp.
67  ///
69  VOP_LanguageType language_type,
70  VOP_Type shader_type,
71  const VOP_ShaderTypeList *sub_types = NULL);
72 
73  /// Deprecated. Uses old VOP_ContextType rather than VOP_Type shader type.
74  /// Eg, use VOP_CVEX_SHADER instead of VEX_CVEX_CONTEXT.
75  SYS_DEPRECATED_HDK(16.0)
77  VOP_LanguageType language_type,
78  VOP_ContextType context_type);
79 
80 
81  /// Sets the object data to reflect the node's shader types and contexts.
82  void setFromNode( OP_Node *node );
83 
84  /// Obtains the default context.
85  VOP_ContextType getDefaultContextType() const;
86 
87  /// Oringial overarching shader type (eg, class, material, surface).
89  { return myMasterType; }
90 
91  /// Returns the type of the language in which the context types are valid.
93  { return myLanguageType; }
94 
95  /// Returns true if the list represetns a single-context list.
96  bool isSingleContextType() const
97  { return myShaderTypes.entries() == 1; }
98 
99  /// Returns true if the main shader is a class type.
100  bool isClassBasedShader() const;
101 
102  /// Returns a list of shader types that make up the master shader.
103  void getConstituentShaderTypes( VOP_ShaderTypeList &types ) const;
104 
105  /// Returns a list of shader context types which are valid in the list's
106  /// language and for which there is a source code that can be generated.
107  /// Some constituent shader types may not have a corresponding a shader
108  /// context (eg geometry shader type).
109  void getConstituentShaderContexts( VOP_ContextTypeList &ctxs ) const;
110 
111  /// Returns a list of shaders whose parameters can appear on the
112  /// master shader (material) node. Such parameters are tagged
113  /// for shader context so they can be used in renderer's shader string.
114  void getParmTagShaderTypes( VOP_ContextTypeList &contexts ) const;
115 
116  /// Returns a list of shaders contexts (and labels) for which the master
117  /// shader node provides source code. These usually correspond
118  /// to language contexts (surface, displacement), but this can also be just
119  /// a class. However, procedurals (geometry) usually is not in this list.
120  void getSourceCodeShaderTypes( UT_StringArray &labels,
121  VOP_ContextTypeList &contexts ) const;
122 
123 private:
124  /// Convenience helper to obtain a context type.
125  VOP_ContextType asContextType( VOP_Type type ) const
126  { return VOPconvertToContextType(type, myLanguageType);}
127 
128 private:
129  /// The language type in which the context types should be interpreted.
130  VOP_LanguageType myLanguageType;
131 
132  /// The original shader type consisting of shading context types.
133  VOP_Type myMasterType;
134 
135  /// The list of constituent shaders types. Some types (and in most
136  /// cases all types) map to shader contexts valid in the language.
137  /// These are the contexts for which a vopnet can generate source code for
138  /// a well-defined shader function. Other types, eg geometry, don't have
139  /// a corresponding context, but are part of the master shader nonetheless.
140  VOP_ShaderTypeList myShaderTypes;
141 };
142 
143 #endif
144 
VOP_LanguageType getLanguageType() const
Returns the type of the language in which the context types are valid.
int VOP_ContextType
Definition: VOP_Types.h:149
#define VOP_API
Definition: VOP_API.h:10
#define SYS_DEPRECATED_HDK(__V__)
VOP_Type
Definition: VOP_Types.h:24
VOP_Type getMasterShaderType() const
Oringial overarching shader type (eg, class, material, surface).
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
GLsizei GLenum GLenum * types
Definition: glcorearb.h:2541
VOP_API VOP_ContextType VOPconvertToContextType(VOP_Type shader_type, VOP_LanguageType language)
bool isSingleContextType() const
Returns true if the list represetns a single-context list.
VOP_LanguageType
Definition: VOP_Types.h:158