Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
OOShaderUniform.h
Go to the documentation of this file.
1/*
2
3OOShaderUniform.h
4
5Manages a uniform variable for OOShaderMaterial.
6
7
8Copyright (C) 2007-2013 Jens Ayton
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files (the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26SOFTWARE.
27
28*/
29
30#import "OOShaderMaterial.h"
31
32#if OO_SHADERS
33
34
35#import "OOMaths.h"
36
37@class OOColor;
38
39
40@interface OOShaderUniform: NSObject
41{
42@private
43 NSString *name;
44 GLint location;
45 uint8_t isBinding: 1,
46 // flags that apply only to bindings:
47 isActiveBinding: 1,
48 convertClamp: 1,
49 convertNormalize: 1,
50 convertToMatrix: 1,
51 bindToSuper: 1;
52 uint8_t type;
53 union
54 {
55 GLint constInt;
56 GLfloat constFloat;
57 GLfloat constVector[4];
58 OOMatrix constMatrix;
59 struct
60 {
61 OOWeakReference *object;
62 SEL selector;
63 IMP method;
64 } binding;
65 } value;
66}
67
68- (id)initWithName:(NSString *)uniformName shaderProgram:(OOShaderProgram *)shaderProgram intValue:(GLint)constValue;
69- (id)initWithName:(NSString *)uniformName shaderProgram:(OOShaderProgram *)shaderProgram floatValue:(GLfloat)constValue;
70- (id)initWithName:(NSString *)uniformName shaderProgram:(OOShaderProgram *)shaderProgram vectorValue:(GLfloat[4])constValue;
71- (id)initWithName:(NSString *)uniformName shaderProgram:(OOShaderProgram *)shaderProgram colorValue:(OOColor *)constValue; // Converted to vector
72- (id)initWithName:(NSString *)uniformName shaderProgram:(OOShaderProgram *)shaderProgram quaternionValue:(Quaternion)constValue asMatrix:(BOOL)asMatrix; // Converted to vector (in xyzw order, not wxyz!) or rotation matrix.
73- (id)initWithName:(NSString *)uniformName shaderProgram:(OOShaderProgram *)shaderProgram matrixValue:(OOMatrix)constValue;
74
75/* "Convert" has different meanings for different types.
76 For float and int types, it clamps to the range [0, 1].
77 For vector types, it normalizes.
78 For quaternions, it converts to rotation matrix (instead of vec4).
79*/
80- (id)initWithName:(NSString *)uniformName
81 shaderProgram:(OOShaderProgram *)shaderProgram
82 boundToObject:(id<OOWeakReferenceSupport>)target
83 property:(SEL)selector
84 convertOptions:(OOUniformConvertOptions)options;
85
86- (void)apply;
87
88- (void)setBindingTarget:(id<OOWeakReferenceSupport>)target;
89
90@end
91
92#endif // OO_SHADERS