-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathquery.go
96 lines (75 loc) · 2.58 KB
/
query.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
95
96
// 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"
type Query Object
func GenQuery() (q Query) {
C.glGenQueries(1, (*C.GLuint)(&q))
return
}
func GenQueries(queries []Query) {
if len(queries) > 0 {
C.glGenQueries(C.GLsizei(len(queries)), (*C.GLuint)(&queries[0]))
}
}
func (query Query) Begin(target GLenum) {
C.glBeginQuery(C.GLenum(target), C.GLuint(query))
}
func (query Query) BeginIndexed(target GLenum, index uint) {
C.glBeginQueryIndexed(C.GLenum(target), C.GLuint(index), C.GLuint(query))
}
func (query Query) Delete() {
C.glDeleteQueries(1, (*C.GLuint)(&query))
}
func (query Query) GetObjecti(pname GLenum) (param int32) {
C.glGetQueryObjectiv(C.GLuint(query), C.GLenum(pname), (*C.GLint)(¶m))
return
}
func (query Query) GetObjectui(pname GLenum) (param uint32) {
C.glGetQueryObjectuiv(C.GLuint(query), C.GLenum(pname), (*C.GLuint)(¶m))
return
}
func (query Query) GetObjecti64(pname GLenum) (param int64) {
C.glGetQueryObjecti64v(C.GLuint(query), C.GLenum(pname), (*C.GLint64)(¶m))
return
}
func (query Query) GetObjectui64(pname GLenum) (param uint64) {
C.glGetQueryObjectui64v(C.GLuint(query), C.GLenum(pname), (*C.GLuint64)(¶m))
return
}
func (query Query) Counter(target GLenum) {
C.glQueryCounter(C.GLuint(query), C.GLenum(target))
}
// Returns whether the passed samples counter is immediately available. If a delay
// would not occur waiting for the query result, true is returned, which also indicates
// that the results of all previous queries are available as well.
func (query Query) ResultAvailable() bool {
return query.GetObjectui(QUERY_RESULT_AVAILABLE) == TRUE
}
func (query Query) BeginConditionalRender(mode GLenum) {
C.glBeginConditionalRender(C.GLuint(query), C.GLenum(mode))
}
func DeleteQueries(queries []Query) {
if len(queries) > 0 {
C.glDeleteQueries(C.GLsizei(len(queries)), (*C.GLuint)(&queries[0]))
}
}
func EndQuery(target GLenum) {
C.glEndQuery(C.GLenum(target))
}
func GetQuery(target GLenum, pname GLenum) (param int32) {
C.glGetQueryiv(C.GLenum(target), C.GLenum(pname), (*C.GLint)(¶m))
return
}
func GetQueryIndexed(target GLenum, index uint, pname GLenum) (param int32) {
C.glGetQueryIndexediv(C.GLenum(target), C.GLuint(index), C.GLenum(pname), (*C.GLint)(¶m))
return
}
func (query Query) EndQueryIndexed(target GLenum, index uint) {
C.glEndQueryIndexed(C.GLenum(target), C.GLuint(index))
}
func (query Query) EndConditionalRender() {
C.glEndConditionalRender()
}