forked from BradLarson/GPUImage2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextureInput.swift
36 lines (31 loc) · 997 Bytes
/
TextureInput.swift
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
#if os(Linux)
#if GLES
import COpenGLES.gles2
#else
import COpenGL
#endif
#else
#if GLES
import OpenGLES
#else
import OpenGL.GL3
#endif
#endif
public class TextureInput: ImageSource {
public let targets = TargetContainer()
let textureFramebuffer:Framebuffer
public init(texture:GLuint, size:Size, orientation:ImageOrientation = .portrait) {
do {
textureFramebuffer = try Framebuffer(context:sharedImageProcessingContext, orientation:orientation, size:GLSize(size), textureOnly:true, overriddenTexture:texture)
} catch {
fatalError("Could not create framebuffer for custom input texture.")
}
}
public func processTexture() {
updateTargetsWithFramebuffer(textureFramebuffer)
}
public func transmitPreviousImage(to target:ImageConsumer, atIndex:UInt) {
textureFramebuffer.lock()
target.newFramebufferAvailable(textureFramebuffer, fromSourceIndex:atIndex)
}
}