-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscenebuffer.sj
31 lines (27 loc) · 1.39 KB
/
scenebuffer.sj
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
scenebuffer(
size : size()
framebuffer := framebuffer()
texture := texture()
renderbuffer := renderbuffer()
) {
framebuffer = glGenFramebuffer(size)
texture = glGenTexture(size)
renderbuffer = glGenRenderbuffer(size)
glPushFramebuffer(framebuffer)
glBindTexture(glTexture.GL_TEXTURE_2D, texture)
glTexParameteri(glTexture.GL_TEXTURE_2D, glTextureAttribute.GL_TEXTURE_WRAP_S, glTextureValue.GL_CLAMP_TO_EDGE)
glTexParameteri(glTexture.GL_TEXTURE_2D, glTextureAttribute.GL_TEXTURE_WRAP_T, glTextureValue.GL_CLAMP_TO_EDGE)
glTexParameteri(glTexture.GL_TEXTURE_2D, glTextureAttribute.GL_TEXTURE_MIN_FILTER, glTextureValue.GL_LINEAR)
glTexParameteri(glTexture.GL_TEXTURE_2D, glTextureAttribute.GL_TEXTURE_MAG_FILTER, glTextureValue.GL_LINEAR)
glTexImage2D(glTexture.GL_TEXTURE_2D, 0, glTextureFormat.GL_RGBA, size, glTextureType.GL_UNSIGNED_BYTE)
glFramebufferTexture2D(glFramebufferAttachment.GL_COLOR_ATTACHMENT0, glFramebufferTexture.GL_TEXTURE_2D, texture, 0)
glBindRenderbuffer(renderbuffer)
glRenderbufferStorage(glRenderbufferFormat.GL_DEPTH_COMPONENT16, size)
glFramebufferRenderbuffer(glFramebufferAttachment.GL_DEPTH_ATTACHMENT, renderbuffer)
status : glCheckFramebufferStatus()
if status != glFramebufferStatus.GL_FRAMEBUFFER_COMPLETE {
halt("Framebuffer failed")
}
glPopFramebuffer(framebuffer)
this
}