Vuo  2.0.2
VuoShader.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include "VuoColor.h"
13 #include "VuoHeap.h"
14 #include "VuoImage.h"
15 #include "VuoInteger.h"
16 #include "VuoMesh.h"
17 #include "VuoPoint2d.h"
18 #include "VuoPoint3d.h"
19 #include "VuoPoint4d.h"
20 #include "VuoReal.h"
21 #include "VuoText.h"
22 #include "VuoGlContext.h"
23 #include "VuoList_VuoInteger.h"
24 #include "VuoList_VuoImage.h"
25 #include "VuoList_VuoColor.h"
26 #include "VuoList_VuoPoint4d.h"
27 #include "VuoList_VuoText.h"
28 #include "VuoGlPool.h"
29 
30 #ifdef __cplusplus
31 class VuoShaderFile;
32 #else
33 typedef void *VuoShaderFile;
34 #endif
35 
90 typedef struct
91 {
93  unsigned int glVertexShaderName;
94 
96  unsigned int glGeometryShaderName;
97  unsigned int expectedOutputPrimitiveCount;
98  bool mayChangeOutputPrimitiveCount;
99 
101  unsigned int glFragmentShaderName;
102 
103  VuoGlProgram program;
104 
106 } VuoSubshader;
107 
113 typedef struct
114 {
115  VuoText name;
116  VuoText type;
117  union
118  {
119  VuoImage image;
120  VuoBoolean boolean;
121  VuoInteger integer;
122  VuoReal real;
123  VuoPoint2d point2d;
124  VuoPoint3d point3d;
125  VuoPoint4d point4d;
126  VuoColor color;
127  VuoList_VuoBoolean booleans;
128  VuoList_VuoInteger integers;
129  VuoList_VuoReal reals;
130  VuoList_VuoPoint2d point2ds;
131  VuoList_VuoPoint3d point3ds;
132  VuoList_VuoPoint4d point4ds;
133  VuoList_VuoColor colors;
134  float *mat2;
135  float *mat3;
136  float *mat4;
137  } value;
138 
144  unsigned int compiledTextureTarget;
146 
152 typedef struct _VuoShader
153 {
155 
156  VuoSubshader pointProgram;
157  VuoSubshader lineProgram;
158  VuoSubshader triangleProgram;
159 
160  VuoShaderUniform *uniforms;
161  unsigned int uniformsCount;
162 
163  float objectScale;
164 
173 
187 
190 
191  uint64_t activationCount;
193 
194  void *lock;
195 } *VuoShader;
196 
197 
200 VuoShader VuoShader_make(const char *name);
202 void VuoShader_addSource(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const char *vertexShaderSource, const char *geometryShaderSource, const char *fragmentShaderSource);
203 void VuoShader_setExpectedOutputPrimitiveCount(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const unsigned int expectedOutputPrimitiveCount);
204 void VuoShader_setMayChangeOutputPrimitiveCount(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, const bool mayChangeOutputPrimitiveCount);
205 void VuoShader_setTransparent(VuoShader shader, const bool isTransparent);
206 
208 #define VUOSHADER_GLSL_SOURCE(version,source) "#version " #version "\n" #source
209 
211 
219 
223 VuoShader VuoShader_makeUnlitRoundedRectangleTrackShader(VuoColor background, VuoColor active, VuoReal sharpness, VuoReal roundness, VuoReal aspect, VuoBoolean isHorizontal, VuoReal value);
224 VuoShader VuoShader_makeUnlitCheckmarkShader(VuoColor color, VuoColor outline, float thickness);
225 
226 VuoShader VuoShader_makeLitColorShader(VuoColor diffuseColor, VuoColor highlightColor, VuoReal shininess);
227 VuoShader VuoShader_makeLitImageShader(VuoImage image, VuoReal alpha, VuoColor highlightColor, VuoReal shininess);
228 VuoShader VuoShader_makeLitImageDetailsShader(VuoImage image, VuoReal alpha, VuoImage specularImage, VuoImage normalImage);
229 
231 void VuoShader_setLinearGradientShaderValues(VuoShader shader, VuoList_VuoColor colors, VuoPoint2d start, VuoPoint2d end, VuoReal aspect, VuoReal noiseAmount);
232 
234 void VuoShader_setRadialGradientShaderValues(VuoShader shader, VuoList_VuoColor colors, VuoPoint2d center, VuoReal radius, VuoReal width, VuoReal height, VuoReal noiseAmount);
235 
237 void VuoShader_setFrostedGlassShaderValues(VuoShader shader, VuoColor color, VuoReal brightness, VuoPoint2d noisePosition, VuoReal noiseTime, VuoReal noiseAmount, VuoReal noiseScale, VuoReal chromaticAberration, VuoInteger levels, VuoReal roughness, VuoReal spacing, VuoInteger iterations, float aspectRatio);
239 
240 
244 unsigned int VuoShader_getExpectedOutputPrimitiveCount(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode);
246 
247 bool VuoShader_upload(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, void *outIssues) VuoWarnUnusedResult;
248 bool VuoShader_getAttributeLocations(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, int *positionLocation, int *normalLocation, int *textureCoordinateLocation, int *colorLocation) VuoWarnUnusedResult;
249 bool VuoShader_activate(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext, VuoGlProgram *outputProgram) VuoWarnUnusedResult;
250 void VuoShader_deactivate(VuoShader shader, const VuoMesh_ElementAssemblyMethod inputPrimitiveMode, VuoGlContext glContext);
251 void VuoShader_resetContext(VuoGlContext glContext);
252 
253 void VuoShader_setUniform_VuoImage (VuoShader shader, const char *uniformIdentifier, const VuoImage image);
254 void VuoShader_setUniform_VuoBoolean(VuoShader shader, const char *uniformIdentifier, const VuoBoolean boolean);
255 void VuoShader_setUniform_VuoInteger(VuoShader shader, const char *uniformIdentifier, const VuoInteger integer);
256 void VuoShader_setUniform_VuoReal (VuoShader shader, const char *uniformIdentifier, const VuoReal real);
257 void VuoShader_setUniform_VuoPoint2d(VuoShader shader, const char *uniformIdentifier, const VuoPoint2d point2d);
258 void VuoShader_setUniform_VuoPoint3d(VuoShader shader, const char *uniformIdentifier, const VuoPoint3d point3d);
259 void VuoShader_setUniform_VuoPoint4d(VuoShader shader, const char *uniformIdentifier, const VuoPoint4d point4d);
260 void VuoShader_setUniform_VuoColor (VuoShader shader, const char *uniformIdentifier, const VuoColor color);
261 void VuoShader_setUniform_VuoList_VuoBoolean(VuoShader shader, const char *uniformIdentifier, const VuoList_VuoBoolean booleans);
262 void VuoShader_setUniform_VuoList_VuoInteger(VuoShader shader, const char *uniformIdentifier, const VuoList_VuoInteger integers);
263 void VuoShader_setUniform_VuoList_VuoReal (VuoShader shader, const char *uniformIdentifier, const VuoList_VuoReal reals);
264 void VuoShader_setUniform_VuoList_VuoPoint2d(VuoShader shader, const char *uniformIdentifier, const VuoList_VuoPoint2d point2ds);
265 void VuoShader_setUniform_VuoList_VuoPoint3d(VuoShader shader, const char *uniformIdentifier, const VuoList_VuoPoint3d point3ds);
266 void VuoShader_setUniform_VuoList_VuoPoint4d(VuoShader shader, const char *uniformIdentifier, const VuoList_VuoPoint4d point4ds);
267 void VuoShader_setUniform_VuoList_VuoColor (VuoShader shader, const char *uniformIdentifier, const VuoList_VuoColor colors);
268 void VuoShader_setUniform_mat2 (VuoShader shader, const char *uniformIdentifier, float *mat2);
269 void VuoShader_setUniform_mat3 (VuoShader shader, const char *uniformIdentifier, float *mat3);
270 void VuoShader_setUniform_mat4 (VuoShader shader, const char *uniformIdentifier, float *mat4);
271 
275 
276 VuoImage VuoShader_getUniform_VuoImage(VuoShader shader, const char *uniformIdentifier);
278 
279 VuoPoint2d VuoShader_samplerCoordinatesFromVuoCoordinates(VuoPoint2d vuoCoordinates, VuoImage image);
281 VuoPoint2d VuoShader_samplerRectCoordinatesFromNormalizedCoordinates(VuoPoint2d normalizedCoordinates, VuoInteger imageWidth, VuoInteger imageHeight);
282 
283 bool VuoShader_isOpaque(VuoShader shader);
284 bool VuoShader_isPopulated(VuoShader shader);
286 
287 
290 char * VuoShader_getSummary(const VuoShader value);
292 struct json_object * VuoShader_getJson(const VuoShader value);
293 
295 #define VuoShader_REQUIRES_INTERPROCESS_JSON
297 
299 VuoShader VuoShader_makeFromString(const char *str);
301 char * VuoShader_getString(const VuoShader value);
303 void VuoShader_retain(VuoShader value);
305 void VuoShader_release(VuoShader value);
307 
308