-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPipeline.hx
41 lines (34 loc) · 1.28 KB
/
Pipeline.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package;
import kha.graphics4.ConstantLocation;
import kha.graphics4.PipelineState;
import kha.graphics4.TextureUnit;
class Pipeline {
public var state: PipelineState = new PipelineState();
public var constantLocations: Map<String, ConstantLocation> = new Map();
public var textureUnits: Map<String, TextureUnit> = new Map();
public function new() {
}
public function getConstantLocation(name: String): ConstantLocation {
var location = state.getConstantLocation(name);
constantLocations[name] = location;
return location;
}
public function getTextureUnit(name: String): TextureUnit {
var unit = state.getTextureUnit(name);
textureUnits[name] = unit;
return unit;
}
public function update(): Void {
for (name in constantLocations.keys()) {
var oldLocation: kha.js.graphics4.ConstantLocation = cast constantLocations[name];
var newLocation: kha.js.graphics4.ConstantLocation = cast state.getConstantLocation(name);
oldLocation.type = newLocation.type;
oldLocation.value = newLocation.value;
}
for (name in textureUnits.keys()) {
var oldUnit: kha.js.graphics4.TextureUnit = cast textureUnits[name];
var newUnit: kha.js.graphics4.TextureUnit = cast state.getTextureUnit(name);
oldUnit.value = newUnit.value;
}
}
}