-
Notifications
You must be signed in to change notification settings - Fork 52
/
framebuffer.go
94 lines (77 loc) · 3.64 KB
/
framebuffer.go
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright 2012 The go-gl Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gl
// #include "gl.h"
import "C"
// Framebuffer Objects
// TODO: implement GLsync stuff
type Framebuffer Object
// void glBindFramebuffer(GLenum target, GLuint framebuffer);
//
// Binds fb to target FRAMEBUFFER. To bind to a specific target, see BindTarget.
func (fb Framebuffer) Bind() {
C.glBindFramebuffer(C.GLenum(FRAMEBUFFER), C.GLuint(fb))
}
// Binds fb to the specified target.
//
// See issue at github for why this function exists:
// http://github.com/go-gl/gl/issues/113
func (fb Framebuffer) BindTarget(target GLenum) {
C.glBindFramebuffer(C.GLenum(target), C.GLuint(fb))
}
// Unbinds target FRAMEBUFFER. To unbind a a specific target, see UnbindTarget.
func (fb Framebuffer) Unbind() {
C.glBindFramebuffer(C.GLenum(FRAMEBUFFER), 0)
}
// Unbinds the specified target.
//
// See issue at github for why this function exists:
// http://github.com/go-gl/gl/issues/113
func (fb Framebuffer) UnbindTarget(target GLenum) {
C.glBindFramebuffer(C.GLenum(target), 0)
}
// void glBlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
func BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1 int, mask GLbitfield, filter GLenum) {
C.glBlitFramebuffer(C.GLint(srcX0), C.GLint(srcY0), C.GLint(srcX1), C.GLint(srcY1), C.GLint(dstX0), C.GLint(dstY0), C.GLint(dstX1), C.GLint(dstY1), C.GLbitfield(mask), C.GLenum(filter))
}
// GLenum glCheckFramebufferStatus(GLenum target);
func CheckFramebufferStatus(target GLenum) GLenum {
return (GLenum)(C.glCheckFramebufferStatus(C.GLenum(target)))
}
// void glDeleteFramebuffers(GLsizei n, GLuint* framebuffers);
func (fb Framebuffer) Delete() {
C.glDeleteFramebuffers(1, (*C.GLuint)(&fb))
}
func DeleteFramebuffers(bufs []Framebuffer) {
if len(bufs) > 0 {
C.glDeleteFramebuffers(C.GLsizei(len(bufs)), (*C.GLuint)(&bufs[0]))
}
}
// void glFramebufferTexture1D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
func FramebufferTexture1D(target, attachment, textarget GLenum, texture Texture, level int) {
C.glFramebufferTexture1D(C.GLenum(target), C.GLenum(attachment), C.GLenum(textarget), C.GLuint(texture), C.GLint(level))
}
// void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
func FramebufferTexture2D(target, attachment, textarget GLenum, texture Texture, level int) {
C.glFramebufferTexture2D(C.GLenum(target), C.GLenum(attachment), C.GLenum(textarget), C.GLuint(texture), C.GLint(level))
}
// void glFramebufferTexture3D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer);
func FramebufferTexture3D(target, attachment, textarget GLenum, texture Texture, level int, layer int) {
C.glFramebufferTexture3D(C.GLenum(target), C.GLenum(attachment), C.GLenum(textarget), C.GLuint(texture), C.GLint(level), C.GLint(layer))
}
// void glFramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
func FramebufferTextureLayer(target, attachment GLenum, texture Texture, level, layer int) {
C.glFramebufferTextureLayer(C.GLenum(target), C.GLenum(attachment), C.GLuint(texture), C.GLint(level), C.GLint(layer))
}
// void glGenFramebuffers(GLsizei n, GLuint* ids);
func GenFramebuffer() Framebuffer {
var b C.GLuint
C.glGenFramebuffers(1, &b)
return Framebuffer(b)
}
func GenFramebuffers(bufs []Framebuffer) {
if len(bufs) > 0 {
C.glGenFramebuffers(C.GLsizei(len(bufs)), (*C.GLuint)(&bufs[0]))
}
}