mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
ui/app: add GL buffer caches
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -105,6 +105,7 @@ func newContext(w *window) (*context, error) {
|
|||||||
c := &context{
|
c := &context{
|
||||||
driver: w,
|
driver: w,
|
||||||
eglCtx: eglCtx,
|
eglCtx: eglCtx,
|
||||||
|
c: new(gl.Functions),
|
||||||
}
|
}
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func newContext(w *window) (*context, error) {
|
|||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
owner: w,
|
owner: w,
|
||||||
layer: C.CFTypeRef(w.contextLayer()),
|
layer: C.CFTypeRef(w.contextLayer()),
|
||||||
|
c: new(gl.Functions),
|
||||||
}
|
}
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ func newContext(w *window) (*context, error) {
|
|||||||
ctx := C.gio_contextForView(w.contextView())
|
ctx := C.gio_contextForView(w.contextView())
|
||||||
c := &context{
|
c := &context{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
|
c: new(gl.Functions),
|
||||||
}
|
}
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,7 +113,11 @@ __attribute__((constructor)) static void gio_loadGLFunctions() {
|
|||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
type Functions struct{}
|
type Functions struct {
|
||||||
|
// Query caches.
|
||||||
|
uints [100]C.GLuint
|
||||||
|
ints [100]C.GLint
|
||||||
|
}
|
||||||
|
|
||||||
func (f *Functions) ActiveTexture(texture Enum) {
|
func (f *Functions) ActiveTexture(texture Enum) {
|
||||||
C.glActiveTexture(C.GLenum(texture))
|
C.glActiveTexture(C.GLenum(texture))
|
||||||
@@ -317,31 +321,23 @@ func (f *Functions) GetError() Enum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Functions) GetRenderbufferParameteri(target, pname Enum) int {
|
func (f *Functions) GetRenderbufferParameteri(target, pname Enum) int {
|
||||||
// Hope this is enough room.
|
C.glGetRenderbufferParameteriv(C.GLenum(target), C.GLenum(pname), &f.ints[0])
|
||||||
var buf [100]C.GLint
|
return int(f.ints[0])
|
||||||
C.glGetRenderbufferParameteriv(C.GLenum(target), C.GLenum(pname), &buf[0])
|
|
||||||
return int(buf[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Functions) GetFramebufferAttachmentParameteri(target, attachment, pname Enum) int {
|
func (f *Functions) GetFramebufferAttachmentParameteri(target, attachment, pname Enum) int {
|
||||||
// Hope this is enough room.
|
C.glGetFramebufferAttachmentParameteriv(C.GLenum(target), C.GLenum(attachment), C.GLenum(pname), &f.ints[0])
|
||||||
var buf [100]C.GLint
|
return int(f.ints[0])
|
||||||
C.glGetFramebufferAttachmentParameteriv(C.GLenum(target), C.GLenum(attachment), C.GLenum(pname), &buf[0])
|
|
||||||
return int(buf[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Functions) GetInteger(pname Enum) int {
|
func (f *Functions) GetInteger(pname Enum) int {
|
||||||
// Hope this is enough room.
|
C.glGetIntegerv(C.GLenum(pname), &f.ints[0])
|
||||||
var buf [100]C.GLint
|
return int(f.ints[0])
|
||||||
C.glGetIntegerv(C.GLenum(pname), &buf[0])
|
|
||||||
return int(buf[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Functions) GetProgrami(p Program, pname Enum) int {
|
func (f *Functions) GetProgrami(p Program, pname Enum) int {
|
||||||
// Hope this is enough room.
|
C.glGetProgramiv(C.GLuint(p.V), C.GLenum(pname), &f.ints[0])
|
||||||
var buf [100]C.GLint
|
return int(f.ints[0])
|
||||||
C.glGetProgramiv(C.GLuint(p.V), C.GLenum(pname), &buf[0])
|
|
||||||
return int(buf[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Functions) GetProgramInfoLog(p Program) string {
|
func (f *Functions) GetProgramInfoLog(p Program) string {
|
||||||
@@ -357,17 +353,13 @@ func (f *Functions) GetProgramInfoLog(p Program) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Functions) GetQueryObjectuiv(query Query, pname Enum) uint {
|
func (f *Functions) GetQueryObjectuiv(query Query, pname Enum) uint {
|
||||||
// Hope this is enough room.
|
C.gio_glGetQueryObjectuiv(C.GLuint(query.V), C.GLenum(pname), &f.uints[0])
|
||||||
var buf [100]C.GLuint
|
return uint(f.uints[0])
|
||||||
C.gio_glGetQueryObjectuiv(C.GLuint(query.V), C.GLenum(pname), &buf[0])
|
|
||||||
return uint(buf[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Functions) GetShaderi(s Shader, pname Enum) int {
|
func (f *Functions) GetShaderi(s Shader, pname Enum) int {
|
||||||
// Hope this is enough room.
|
C.glGetShaderiv(C.GLuint(s.V), C.GLenum(pname), &f.ints[0])
|
||||||
var buf [100]C.GLint
|
return int(f.ints[0])
|
||||||
C.glGetShaderiv(C.GLuint(s.V), C.GLenum(pname), &buf[0])
|
|
||||||
return int(buf[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Functions) GetShaderInfoLog(s Shader) string {
|
func (f *Functions) GetShaderInfoLog(s Shader) string {
|
||||||
|
|||||||
@@ -86,7 +86,10 @@ var (
|
|||||||
_glViewport = LibGLESv2.NewProc("glViewport")
|
_glViewport = LibGLESv2.NewProc("glViewport")
|
||||||
)
|
)
|
||||||
|
|
||||||
type Functions struct{}
|
type Functions struct {
|
||||||
|
// Query caches.
|
||||||
|
int32s [100]int32
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Functions) ActiveTexture(t Enum) {
|
func (c *Functions) ActiveTexture(t Enum) {
|
||||||
syscall.Syscall(_glActiveTexture.Addr(), 1, uintptr(t), 0, 0)
|
syscall.Syscall(_glActiveTexture.Addr(), 1, uintptr(t), 0, 0)
|
||||||
@@ -252,16 +255,12 @@ func (c *Functions) GetFramebufferAttachmentParameteri(target, attachment, pname
|
|||||||
return int(p)
|
return int(p)
|
||||||
}
|
}
|
||||||
func (c *Functions) GetInteger(pname Enum) int {
|
func (c *Functions) GetInteger(pname Enum) int {
|
||||||
// Hopefully enough room.
|
syscall.Syscall(_glGetIntegerv.Addr(), 2, uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])), 0)
|
||||||
var params [100]int32
|
return int(c.int32s[0])
|
||||||
syscall.Syscall(_glGetIntegerv.Addr(), 2, uintptr(pname), uintptr(unsafe.Pointer(¶ms[0])), 0)
|
|
||||||
return int(params[0])
|
|
||||||
}
|
}
|
||||||
func (c *Functions) GetProgrami(p Program, pname Enum) int {
|
func (c *Functions) GetProgrami(p Program, pname Enum) int {
|
||||||
// Hopefully enough space.
|
syscall.Syscall(_glGetProgramiv.Addr(), 3, uintptr(p.V), uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])))
|
||||||
var params [100]int32
|
return int(c.int32s[0])
|
||||||
syscall.Syscall(_glGetProgramiv.Addr(), 3, uintptr(p.V), uintptr(pname), uintptr(unsafe.Pointer(¶ms[0])))
|
|
||||||
return int(params[0])
|
|
||||||
}
|
}
|
||||||
func (c *Functions) GetProgramInfoLog(p Program) string {
|
func (c *Functions) GetProgramInfoLog(p Program) string {
|
||||||
var n uintptr
|
var n uintptr
|
||||||
@@ -274,17 +273,13 @@ func (c *Functions) GetProgramInfoLog(p Program) string {
|
|||||||
syscall.Syscall6(_glGetProgramInfoLog.Addr(), 4, uintptr(p.V), uintptr(len(buf)), uintptr(unsafe.Pointer(&n)), uintptr(unsafe.Pointer(&buf[0])), 0, 0)
|
syscall.Syscall6(_glGetProgramInfoLog.Addr(), 4, uintptr(p.V), uintptr(len(buf)), uintptr(unsafe.Pointer(&n)), uintptr(unsafe.Pointer(&buf[0])), 0, 0)
|
||||||
return string(buf[:len(buf)-1])
|
return string(buf[:len(buf)-1])
|
||||||
}
|
}
|
||||||
func (f *Functions) GetQueryObjectuiv(query Query, pname Enum) uint {
|
func (c *Functions) GetQueryObjectuiv(query Query, pname Enum) uint {
|
||||||
// Hope this is enough room.
|
syscall.Syscall(_glGetQueryObjectuiv.Addr(), 3, uintptr(query.V), uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])))
|
||||||
var buf [100]int32
|
return uint(c.int32s[0])
|
||||||
syscall.Syscall(_glGetQueryObjectuiv.Addr(), 3, uintptr(query.V), uintptr(pname), uintptr(unsafe.Pointer(&buf[0])))
|
|
||||||
return uint(buf[0])
|
|
||||||
}
|
}
|
||||||
func (c *Functions) GetShaderi(s Shader, pname Enum) int {
|
func (c *Functions) GetShaderi(s Shader, pname Enum) int {
|
||||||
// Hopefully enough room.
|
syscall.Syscall(_glGetShaderiv.Addr(), 3, uintptr(s.V), uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])))
|
||||||
var params [100]int32
|
return int(c.int32s[0])
|
||||||
syscall.Syscall(_glGetShaderiv.Addr(), 3, uintptr(s.V), uintptr(pname), uintptr(unsafe.Pointer(¶ms[0])))
|
|
||||||
return int(params[0])
|
|
||||||
}
|
}
|
||||||
func (c *Functions) GetShaderInfoLog(s Shader) string {
|
func (c *Functions) GetShaderInfoLog(s Shader) string {
|
||||||
var n uintptr
|
var n uintptr
|
||||||
|
|||||||
Reference in New Issue
Block a user