removed openglinterface implementations
This commit is contained in:
parent
f8aa4d62ce
commit
2717a0bdd9
4 changed files with 0 additions and 1042 deletions
|
@ -1,263 +0,0 @@
|
|||
package glimplandroid
|
||||
|
||||
// #include <stdlib.h>
|
||||
// #include <GLES2/gl2.h>
|
||||
// #cgo android LDFLAGS: -lGLESv2
|
||||
import "C"
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
|
||||
"github.com/tfriedel6/canvas"
|
||||
)
|
||||
|
||||
type GLImpl struct{}
|
||||
|
||||
var _ canvas.GL = GLImpl{}
|
||||
|
||||
func (GLImpl) Ptr(data interface{}) unsafe.Pointer {
|
||||
if data == nil {
|
||||
return unsafe.Pointer(nil)
|
||||
}
|
||||
var addr unsafe.Pointer
|
||||
v := reflect.ValueOf(data)
|
||||
switch v.Type().Kind() {
|
||||
case reflect.Ptr:
|
||||
e := v.Elem()
|
||||
switch e.Kind() {
|
||||
case
|
||||
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
|
||||
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
|
||||
reflect.Float32, reflect.Float64:
|
||||
addr = unsafe.Pointer(e.UnsafeAddr())
|
||||
default:
|
||||
panic(fmt.Errorf("unsupported pointer to type %s; must be a slice or pointer to a singular scalar value or the first element of an array or slice", e.Kind()))
|
||||
}
|
||||
case reflect.Uintptr:
|
||||
addr = unsafe.Pointer(v.Pointer())
|
||||
case reflect.Slice:
|
||||
addr = unsafe.Pointer(v.Index(0).UnsafeAddr())
|
||||
default:
|
||||
panic(fmt.Errorf("unsupported type %s; must be a slice or pointer to a singular scalar value or the first element of an array or slice", v.Type()))
|
||||
}
|
||||
return addr
|
||||
}
|
||||
func (GLImpl) ActiveTexture(texture uint32) {
|
||||
C.glActiveTexture(C.uint(texture))
|
||||
}
|
||||
func (GLImpl) AttachShader(program uint32, shader uint32) {
|
||||
C.glAttachShader(C.uint(program), C.uint(shader))
|
||||
}
|
||||
func (GLImpl) BindBuffer(target uint32, buffer uint32) {
|
||||
C.glBindBuffer(C.uint(target), C.uint(buffer))
|
||||
}
|
||||
func (GLImpl) BindFramebuffer(target uint32, framebuffer uint32) {
|
||||
C.glBindFramebuffer(C.uint(target), C.uint(framebuffer))
|
||||
}
|
||||
func (GLImpl) BindRenderbuffer(target uint32, renderbuffer uint32) {
|
||||
C.glBindRenderbuffer(C.uint(target), C.uint(renderbuffer))
|
||||
}
|
||||
func (GLImpl) BindTexture(target uint32, texture uint32) {
|
||||
C.glBindTexture(C.uint(target), C.uint(texture))
|
||||
}
|
||||
func (GLImpl) BlendFunc(sfactor uint32, dfactor uint32) {
|
||||
C.glBlendFunc(C.uint(sfactor), C.uint(dfactor))
|
||||
}
|
||||
func (GLImpl) BufferData(target uint32, size int, data unsafe.Pointer, usage uint32) {
|
||||
C.glBufferData(C.uint(target), C.long(size), data, C.uint(usage))
|
||||
}
|
||||
func (GLImpl) CheckFramebufferStatus(target uint32) uint32 {
|
||||
return uint32(C.glCheckFramebufferStatus(C.uint(target)))
|
||||
}
|
||||
func (GLImpl) Clear(mask uint32) {
|
||||
C.glClear(C.uint(mask))
|
||||
}
|
||||
func (GLImpl) ClearColor(red float32, green float32, blue float32, alpha float32) {
|
||||
C.glClearColor(C.float(red), C.float(green), C.float(blue), C.float(alpha))
|
||||
}
|
||||
func (GLImpl) ColorMask(red bool, green bool, blue bool, alpha bool) {
|
||||
var r, g, b, a C.uchar
|
||||
if red {
|
||||
r = 1
|
||||
}
|
||||
if green {
|
||||
g = 1
|
||||
}
|
||||
if blue {
|
||||
b = 1
|
||||
}
|
||||
if alpha {
|
||||
a = 1
|
||||
}
|
||||
C.glColorMask(r, g, b, a)
|
||||
}
|
||||
func (GLImpl) CompileShader(shader uint32) {
|
||||
C.glCompileShader(C.uint(shader))
|
||||
}
|
||||
func (GLImpl) CreateProgram() uint32 {
|
||||
return uint32(C.glCreateProgram())
|
||||
}
|
||||
func (GLImpl) CreateShader(xtype uint32) uint32 {
|
||||
return uint32(C.glCreateShader(C.uint(xtype)))
|
||||
}
|
||||
func (GLImpl) DeleteShader(shader uint32) {
|
||||
C.glDeleteShader(C.uint(shader))
|
||||
}
|
||||
func (GLImpl) DeleteFramebuffers(n int32, framebuffers *uint32) {
|
||||
C.glDeleteFramebuffers(C.int(n), (*C.uint)(framebuffers))
|
||||
}
|
||||
func (GLImpl) DeleteRenderbuffers(n int32, renderbuffers *uint32) {
|
||||
C.glDeleteRenderbuffers(C.int(n), (*C.uint)(renderbuffers))
|
||||
}
|
||||
func (GLImpl) DeleteTextures(n int32, textures *uint32) {
|
||||
C.glDeleteTextures(C.int(n), (*C.uint)(textures))
|
||||
}
|
||||
func (GLImpl) Disable(cap uint32) {
|
||||
C.glDisable(C.uint(cap))
|
||||
}
|
||||
func (GLImpl) DisableVertexAttribArray(index uint32) {
|
||||
C.glDisableVertexAttribArray(C.uint(index))
|
||||
}
|
||||
func (GLImpl) DrawArrays(mode uint32, first int32, count int32) {
|
||||
C.glDrawArrays(C.uint(mode), C.int(first), C.int(count))
|
||||
}
|
||||
func (GLImpl) Enable(cap uint32) {
|
||||
C.glEnable(C.uint(cap))
|
||||
}
|
||||
func (GLImpl) EnableVertexAttribArray(index uint32) {
|
||||
C.glEnableVertexAttribArray(C.uint(index))
|
||||
}
|
||||
func (GLImpl) FramebufferRenderbuffer(target uint32, attachment uint32, renderbuffertarget uint32, renderbuffer uint32) {
|
||||
C.glFramebufferRenderbuffer(C.uint(target), C.uint(attachment), C.uint(renderbuffertarget), C.uint(renderbuffer))
|
||||
}
|
||||
func (GLImpl) FramebufferTexture(target uint32, attachment uint32, texture uint32, level int32) {
|
||||
C.glFramebufferTexture2D(C.uint(target), C.uint(attachment), C.GL_TEXTURE_2D, C.uint(texture), C.int(level))
|
||||
}
|
||||
func (GLImpl) GenBuffers(n int32, buffers *uint32) {
|
||||
C.glGenBuffers(C.int(n), (*C.uint)(buffers))
|
||||
}
|
||||
func (GLImpl) GenFramebuffers(n int32, framebuffers *uint32) {
|
||||
C.glGenFramebuffers(C.int(n), (*C.uint)(framebuffers))
|
||||
}
|
||||
func (GLImpl) GenRenderbuffers(n int32, renderbuffers *uint32) {
|
||||
C.glGenRenderbuffers(C.int(n), (*C.uint)(renderbuffers))
|
||||
}
|
||||
func (GLImpl) GenTextures(n int32, textures *uint32) {
|
||||
C.glGenTextures(C.int(n), (*C.uint)(textures))
|
||||
}
|
||||
func (GLImpl) GenerateMipmap(target uint32) {
|
||||
C.glGenerateMipmap(C.uint(target))
|
||||
}
|
||||
func (GLImpl) GetAttribLocation(program uint32, name string) int32 {
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
return int32(C.glGetAttribLocation(C.uint(program), cname))
|
||||
}
|
||||
func (GLImpl) GetError() uint32 {
|
||||
return uint32(C.glGetError())
|
||||
}
|
||||
func (GLImpl) GetProgramInfoLog(program uint32) string {
|
||||
var length C.int
|
||||
C.glGetProgramiv(C.uint(program), C.GL_INFO_LOG_LENGTH, &length)
|
||||
if length == 0 {
|
||||
return ""
|
||||
}
|
||||
clog := C.CBytes(make([]byte, int(length)+1))
|
||||
defer C.free(clog)
|
||||
C.glGetProgramInfoLog(C.uint(program), C.int(length), nil, (*C.char)(clog))
|
||||
return string(C.GoBytes(clog, length))
|
||||
}
|
||||
func (GLImpl) GetProgramiv(program uint32, pname uint32, params *int32) {
|
||||
C.glGetProgramiv(C.uint(program), C.uint(pname), (*C.int)(params))
|
||||
}
|
||||
func (GLImpl) GetShaderInfoLog(program uint32) string {
|
||||
var length C.int
|
||||
C.glGetShaderiv(C.uint(program), C.GL_INFO_LOG_LENGTH, &length)
|
||||
if length == 0 {
|
||||
return ""
|
||||
}
|
||||
clog := C.CBytes(make([]byte, int(length)+1))
|
||||
defer C.free(clog)
|
||||
C.glGetShaderInfoLog(C.uint(program), C.int(length), nil, (*C.char)(clog))
|
||||
return string(C.GoBytes(clog, length))
|
||||
}
|
||||
func (GLImpl) GetShaderiv(shader uint32, pname uint32, params *int32) {
|
||||
C.glGetShaderiv(C.uint(shader), C.uint(pname), (*C.int)(params))
|
||||
|
||||
}
|
||||
func (GLImpl) GetUniformLocation(program uint32, name string) int32 {
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
return int32(C.glGetUniformLocation(C.uint(program), cname))
|
||||
}
|
||||
func (GLImpl) LinkProgram(program uint32) {
|
||||
C.glLinkProgram(C.uint(program))
|
||||
}
|
||||
func (GLImpl) ReadPixels(x int32, y int32, width int32, height int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
C.glReadPixels(C.int(x), C.int(y), C.int(width), C.int(height), C.uint(format), C.uint(xtype), pixels)
|
||||
}
|
||||
func (GLImpl) RenderbufferStorage(target uint32, internalformat uint32, width int32, height int32) {
|
||||
C.glRenderbufferStorage(C.uint(target), C.uint(internalformat), C.int(width), C.int(height))
|
||||
}
|
||||
func (GLImpl) Scissor(x int32, y int32, width int32, height int32) {
|
||||
C.glScissor(C.int(x), C.int(y), C.int(width), C.int(height))
|
||||
}
|
||||
func (GLImpl) ShaderSource(shader uint32, source string) {
|
||||
csource := C.CString(source)
|
||||
defer C.free(unsafe.Pointer(csource))
|
||||
C.glShaderSource(C.uint(shader), 1, &csource, nil)
|
||||
}
|
||||
func (GLImpl) StencilFunc(xfunc uint32, ref int32, mask uint32) {
|
||||
C.glStencilFunc(C.uint(xfunc), C.int(ref), C.uint(mask))
|
||||
}
|
||||
func (GLImpl) StencilMask(mask uint32) {
|
||||
C.glStencilMask(C.uint(mask))
|
||||
}
|
||||
func (GLImpl) StencilOp(fail uint32, zfail uint32, zpass uint32) {
|
||||
C.glStencilOp(C.uint(fail), C.uint(zfail), C.uint(zpass))
|
||||
}
|
||||
func (GLImpl) TexImage2D(target uint32, level int32, internalformat int32, width int32, height int32, border int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
C.glTexImage2D(C.uint(target), C.int(level), C.int(internalformat), C.int(width), C.int(height), C.int(border), C.uint(format), C.uint(xtype), pixels)
|
||||
}
|
||||
func (GLImpl) TexParameteri(target uint32, pname uint32, param int32) {
|
||||
C.glTexParameteri(C.uint(target), C.uint(pname), C.int(param))
|
||||
}
|
||||
func (GLImpl) TexSubImage2D(target uint32, level int32, xoffset int32, yoffset int32, width int32, height int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
C.glTexSubImage2D(C.uint(target), C.int(level), C.int(xoffset), C.int(yoffset), C.int(width), C.int(height), C.uint(format), C.uint(xtype), pixels)
|
||||
}
|
||||
func (GLImpl) Uniform1f(location int32, v0 float32) {
|
||||
C.glUniform1f(C.int(location), C.float(v0))
|
||||
}
|
||||
func (GLImpl) Uniform1fv(location int32, count int32, v *float32) {
|
||||
C.glUniform1fv(C.int(location), C.int(count), (*C.float)(v))
|
||||
}
|
||||
func (GLImpl) Uniform1i(location int32, v0 int32) {
|
||||
C.glUniform1i(C.int(location), C.int(v0))
|
||||
}
|
||||
func (GLImpl) Uniform2f(location int32, v0 float32, v1 float32) {
|
||||
C.glUniform2f(C.int(location), C.float(v0), C.float(v1))
|
||||
}
|
||||
func (GLImpl) Uniform4f(location int32, v0 float32, v1 float32, v2 float32, v3 float32) {
|
||||
C.glUniform4f(C.int(location), C.float(v0), C.float(v1), C.float(v2), C.float(v3))
|
||||
}
|
||||
func (GLImpl) UniformMatrix3fv(location int32, count int32, transpose bool, value *float32) {
|
||||
var t C.uchar
|
||||
if transpose {
|
||||
t = 1
|
||||
}
|
||||
C.glUniformMatrix3fv(C.int(location), C.int(count), t, (*C.float)(value))
|
||||
}
|
||||
func (GLImpl) UseProgram(program uint32) {
|
||||
C.glUseProgram(C.uint(program))
|
||||
}
|
||||
func (GLImpl) VertexAttribPointer(index uint32, size int32, xtype uint32, normalized bool, stride int32, offset uint32) {
|
||||
var n C.uchar
|
||||
if normalized {
|
||||
n = 1
|
||||
}
|
||||
C.glVertexAttribPointer(C.uint(index), C.int(size), C.uint(xtype), n, C.int(stride), unsafe.Pointer(uintptr(offset)))
|
||||
}
|
||||
func (GLImpl) Viewport(x int32, y int32, width int32, height int32) {
|
||||
C.glViewport(C.int(x), C.int(y), C.int(width), C.int(height))
|
||||
}
|
|
@ -1,207 +0,0 @@
|
|||
package glimplgogl
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"github.com/go-gl/gl/v3.2-core/gl"
|
||||
"github.com/tfriedel6/canvas"
|
||||
)
|
||||
|
||||
type GLImpl struct{}
|
||||
|
||||
var _ canvas.GL = GLImpl{}
|
||||
|
||||
func (GLImpl) Ptr(data interface{}) unsafe.Pointer {
|
||||
return gl.Ptr(data)
|
||||
}
|
||||
func (GLImpl) ActiveTexture(texture uint32) {
|
||||
gl.ActiveTexture(texture)
|
||||
}
|
||||
func (GLImpl) AttachShader(program uint32, shader uint32) {
|
||||
gl.AttachShader(program, shader)
|
||||
}
|
||||
func (GLImpl) BindBuffer(target uint32, buffer uint32) {
|
||||
gl.BindBuffer(target, buffer)
|
||||
}
|
||||
func (GLImpl) BindFramebuffer(target uint32, framebuffer uint32) {
|
||||
gl.BindFramebuffer(target, framebuffer)
|
||||
}
|
||||
func (GLImpl) BindRenderbuffer(target uint32, renderbuffer uint32) {
|
||||
gl.BindRenderbuffer(target, renderbuffer)
|
||||
}
|
||||
func (GLImpl) BindTexture(target uint32, texture uint32) {
|
||||
gl.BindTexture(target, texture)
|
||||
}
|
||||
func (GLImpl) BlendFunc(sfactor uint32, dfactor uint32) {
|
||||
gl.BlendFunc(sfactor, dfactor)
|
||||
}
|
||||
func (GLImpl) BufferData(target uint32, size int, data unsafe.Pointer, usage uint32) {
|
||||
gl.BufferData(target, size, data, usage)
|
||||
}
|
||||
func (GLImpl) CheckFramebufferStatus(target uint32) uint32 {
|
||||
return gl.CheckFramebufferStatus(target)
|
||||
}
|
||||
func (GLImpl) Clear(mask uint32) {
|
||||
gl.Clear(mask)
|
||||
}
|
||||
func (GLImpl) ClearColor(red float32, green float32, blue float32, alpha float32) {
|
||||
gl.ClearColor(red, green, blue, alpha)
|
||||
}
|
||||
func (GLImpl) ColorMask(red bool, green bool, blue bool, alpha bool) {
|
||||
gl.ColorMask(red, green, blue, alpha)
|
||||
}
|
||||
func (GLImpl) CompileShader(shader uint32) {
|
||||
gl.CompileShader(shader)
|
||||
}
|
||||
func (GLImpl) CreateProgram() uint32 {
|
||||
return gl.CreateProgram()
|
||||
}
|
||||
func (GLImpl) CreateShader(xtype uint32) uint32 {
|
||||
return gl.CreateShader(xtype)
|
||||
}
|
||||
func (GLImpl) DeleteShader(shader uint32) {
|
||||
gl.DeleteShader(shader)
|
||||
}
|
||||
func (GLImpl) DeleteFramebuffers(n int32, framebuffers *uint32) {
|
||||
gl.DeleteFramebuffers(n, framebuffers)
|
||||
}
|
||||
func (GLImpl) DeleteRenderbuffers(n int32, renderbuffers *uint32) {
|
||||
gl.DeleteRenderbuffers(n, renderbuffers)
|
||||
}
|
||||
func (GLImpl) DeleteTextures(n int32, textures *uint32) {
|
||||
gl.DeleteTextures(n, textures)
|
||||
}
|
||||
func (GLImpl) Disable(cap uint32) {
|
||||
gl.Disable(cap)
|
||||
}
|
||||
func (GLImpl) DisableVertexAttribArray(index uint32) {
|
||||
gl.DisableVertexAttribArray(index)
|
||||
}
|
||||
func (GLImpl) DrawArrays(mode uint32, first int32, count int32) {
|
||||
gl.DrawArrays(mode, first, count)
|
||||
}
|
||||
func (GLImpl) Enable(cap uint32) {
|
||||
gl.Enable(cap)
|
||||
}
|
||||
func (GLImpl) EnableVertexAttribArray(index uint32) {
|
||||
gl.EnableVertexAttribArray(index)
|
||||
}
|
||||
func (GLImpl) FramebufferRenderbuffer(target uint32, attachment uint32, renderbuffertarget uint32, renderbuffer uint32) {
|
||||
gl.FramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer)
|
||||
}
|
||||
func (GLImpl) FramebufferTexture(target uint32, attachment uint32, texture uint32, level int32) {
|
||||
gl.FramebufferTexture(target, attachment, texture, level)
|
||||
}
|
||||
func (GLImpl) GenBuffers(n int32, buffers *uint32) {
|
||||
gl.GenBuffers(n, buffers)
|
||||
}
|
||||
func (GLImpl) GenFramebuffers(n int32, framebuffers *uint32) {
|
||||
gl.GenFramebuffers(n, framebuffers)
|
||||
}
|
||||
func (GLImpl) GenRenderbuffers(n int32, renderbuffers *uint32) {
|
||||
gl.GenRenderbuffers(n, renderbuffers)
|
||||
}
|
||||
func (GLImpl) GenTextures(n int32, textures *uint32) {
|
||||
gl.GenTextures(n, textures)
|
||||
}
|
||||
func (GLImpl) GenerateMipmap(target uint32) {
|
||||
gl.GenerateMipmap(target)
|
||||
}
|
||||
func (GLImpl) GetAttribLocation(program uint32, name string) int32 {
|
||||
return gl.GetAttribLocation(program, gl.Str(name+"\x00"))
|
||||
}
|
||||
func (GLImpl) GetError() uint32 {
|
||||
return gl.GetError()
|
||||
}
|
||||
func (GLImpl) GetProgramInfoLog(program uint32) string {
|
||||
var length int32
|
||||
gl.GetProgramiv(program, gl.INFO_LOG_LENGTH, &length)
|
||||
if length == 0 {
|
||||
return ""
|
||||
}
|
||||
log := strings.Repeat("\x00", int(length+1))
|
||||
gl.GetProgramInfoLog(program, length, nil, gl.Str(log))
|
||||
return log
|
||||
}
|
||||
func (GLImpl) GetProgramiv(program uint32, pname uint32, params *int32) {
|
||||
gl.GetProgramiv(program, pname, params)
|
||||
}
|
||||
func (GLImpl) GetShaderInfoLog(program uint32) string {
|
||||
var length int32
|
||||
gl.GetShaderiv(program, gl.INFO_LOG_LENGTH, &length)
|
||||
if length == 0 {
|
||||
return ""
|
||||
}
|
||||
log := strings.Repeat("\x00", int(length+1))
|
||||
gl.GetShaderInfoLog(program, length, nil, gl.Str(log))
|
||||
return log
|
||||
}
|
||||
func (GLImpl) GetShaderiv(shader uint32, pname uint32, params *int32) {
|
||||
gl.GetShaderiv(shader, pname, params)
|
||||
}
|
||||
func (GLImpl) GetUniformLocation(program uint32, name string) int32 {
|
||||
return gl.GetUniformLocation(program, gl.Str(name+"\x00"))
|
||||
}
|
||||
func (GLImpl) LinkProgram(program uint32) {
|
||||
gl.LinkProgram(program)
|
||||
}
|
||||
func (GLImpl) RenderbufferStorage(target uint32, internalformat uint32, width int32, height int32) {
|
||||
gl.RenderbufferStorage(target, internalformat, width, height)
|
||||
}
|
||||
func (GLImpl) ReadPixels(x int32, y int32, width int32, height int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
gl.ReadPixels(x, y, width, height, format, xtype, pixels)
|
||||
}
|
||||
func (GLImpl) Scissor(x int32, y int32, width int32, height int32) {
|
||||
gl.Scissor(x, y, width, height)
|
||||
}
|
||||
func (GLImpl) ShaderSource(shader uint32, source string) {
|
||||
csource, freeFunc := gl.Strs(source + "\x00")
|
||||
gl.ShaderSource(shader, 1, csource, nil)
|
||||
freeFunc()
|
||||
}
|
||||
func (GLImpl) StencilFunc(xfunc uint32, ref int32, mask uint32) {
|
||||
gl.StencilFunc(xfunc, ref, mask)
|
||||
}
|
||||
func (GLImpl) StencilMask(mask uint32) {
|
||||
gl.StencilMask(mask)
|
||||
}
|
||||
func (GLImpl) StencilOp(fail uint32, zfail uint32, zpass uint32) {
|
||||
gl.StencilOp(fail, zfail, zpass)
|
||||
}
|
||||
func (GLImpl) TexImage2D(target uint32, level int32, internalformat int32, width int32, height int32, border int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
gl.TexImage2D(target, level, internalformat, width, height, border, format, xtype, pixels)
|
||||
}
|
||||
func (GLImpl) TexParameteri(target uint32, pname uint32, param int32) {
|
||||
gl.TexParameteri(target, pname, param)
|
||||
}
|
||||
func (GLImpl) TexSubImage2D(target uint32, level int32, xoffset int32, yoffset int32, width int32, height int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
gl.TexSubImage2D(target, level, xoffset, yoffset, width, height, format, xtype, pixels)
|
||||
}
|
||||
func (GLImpl) Uniform1f(location int32, v0 float32) {
|
||||
gl.Uniform1f(location, v0)
|
||||
}
|
||||
func (GLImpl) Uniform1fv(location int32, count int32, v *float32) {
|
||||
gl.Uniform1fv(location, count, v)
|
||||
}
|
||||
func (GLImpl) Uniform1i(location int32, v0 int32) {
|
||||
gl.Uniform1i(location, v0)
|
||||
}
|
||||
func (GLImpl) Uniform2f(location int32, v0 float32, v1 float32) {
|
||||
gl.Uniform2f(location, v0, v1)
|
||||
}
|
||||
func (GLImpl) Uniform4f(location int32, v0 float32, v1 float32, v2 float32, v3 float32) {
|
||||
gl.Uniform4f(location, v0, v1, v2, v3)
|
||||
}
|
||||
func (GLImpl) UniformMatrix3fv(location int32, count int32, transpose bool, value *float32) {
|
||||
gl.UniformMatrix3fv(location, count, transpose, value)
|
||||
}
|
||||
func (GLImpl) UseProgram(program uint32) {
|
||||
gl.UseProgram(program)
|
||||
}
|
||||
func (GLImpl) VertexAttribPointer(index uint32, size int32, xtype uint32, normalized bool, stride int32, offset uint32) {
|
||||
gl.VertexAttribPointer(index, size, xtype, normalized, stride, gl.PtrOffset(int(offset)))
|
||||
}
|
||||
func (GLImpl) Viewport(x int32, y int32, width int32, height int32) {
|
||||
gl.Viewport(x, y, width, height)
|
||||
}
|
|
@ -1,263 +0,0 @@
|
|||
package glimplios
|
||||
|
||||
// #include <stdlib.h>
|
||||
// #include <OpenGLES/ES2/gl.h>
|
||||
// #cgo ios LDFLAGS: -framework OpenGLES
|
||||
import "C"
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
|
||||
"github.com/tfriedel6/canvas"
|
||||
)
|
||||
|
||||
type GLImpl struct{}
|
||||
|
||||
var _ canvas.GL = GLImpl{}
|
||||
|
||||
func (GLImpl) Ptr(data interface{}) unsafe.Pointer {
|
||||
if data == nil {
|
||||
return unsafe.Pointer(nil)
|
||||
}
|
||||
var addr unsafe.Pointer
|
||||
v := reflect.ValueOf(data)
|
||||
switch v.Type().Kind() {
|
||||
case reflect.Ptr:
|
||||
e := v.Elem()
|
||||
switch e.Kind() {
|
||||
case
|
||||
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
|
||||
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
|
||||
reflect.Float32, reflect.Float64:
|
||||
addr = unsafe.Pointer(e.UnsafeAddr())
|
||||
default:
|
||||
panic(fmt.Errorf("unsupported pointer to type %s; must be a slice or pointer to a singular scalar value or the first element of an array or slice", e.Kind()))
|
||||
}
|
||||
case reflect.Uintptr:
|
||||
addr = unsafe.Pointer(v.Pointer())
|
||||
case reflect.Slice:
|
||||
addr = unsafe.Pointer(v.Index(0).UnsafeAddr())
|
||||
default:
|
||||
panic(fmt.Errorf("unsupported type %s; must be a slice or pointer to a singular scalar value or the first element of an array or slice", v.Type()))
|
||||
}
|
||||
return addr
|
||||
}
|
||||
func (GLImpl) ActiveTexture(texture uint32) {
|
||||
C.glActiveTexture(C.GLenum(texture))
|
||||
}
|
||||
func (GLImpl) AttachShader(program uint32, shader uint32) {
|
||||
C.glAttachShader(C.GLuint(program), C.GLuint(shader))
|
||||
}
|
||||
func (GLImpl) BindBuffer(target uint32, buffer uint32) {
|
||||
C.glBindBuffer(C.GLenum(target), C.GLuint(buffer))
|
||||
}
|
||||
func (GLImpl) BindFramebuffer(target uint32, framebuffer uint32) {
|
||||
C.glBindFramebuffer(C.GLenum(target), C.GLuint(framebuffer))
|
||||
}
|
||||
func (GLImpl) BindRenderbuffer(target uint32, renderbuffer uint32) {
|
||||
C.glBindRenderbuffer(C.GLenum(target), C.GLuint(renderbuffer))
|
||||
}
|
||||
func (GLImpl) BindTexture(target uint32, texture uint32) {
|
||||
C.glBindTexture(C.GLenum(target), C.GLuint(texture))
|
||||
}
|
||||
func (GLImpl) BlendFunc(sfactor uint32, dfactor uint32) {
|
||||
C.glBlendFunc(C.GLenum(sfactor), C.GLenum(dfactor))
|
||||
}
|
||||
func (GLImpl) BufferData(target uint32, size int, data unsafe.Pointer, usage uint32) {
|
||||
C.glBufferData(C.GLenum(target), C.GLsizeiptr(size), data, C.GLenum(usage))
|
||||
}
|
||||
func (GLImpl) CheckFramebufferStatus(target uint32) uint32 {
|
||||
return uint32(C.glCheckFramebufferStatus(C.GLenum(target)))
|
||||
}
|
||||
func (GLImpl) Clear(mask uint32) {
|
||||
C.glClear(C.GLbitfield(mask))
|
||||
}
|
||||
func (GLImpl) ClearColor(red float32, green float32, blue float32, alpha float32) {
|
||||
C.glClearColor(C.GLfloat(red), C.GLfloat(green), C.GLfloat(blue), C.GLfloat(alpha))
|
||||
}
|
||||
func (GLImpl) ColorMask(red bool, green bool, blue bool, alpha bool) {
|
||||
var r, g, b, a C.GLboolean
|
||||
if red {
|
||||
r = 1
|
||||
}
|
||||
if green {
|
||||
g = 1
|
||||
}
|
||||
if blue {
|
||||
b = 1
|
||||
}
|
||||
if alpha {
|
||||
a = 1
|
||||
}
|
||||
C.glColorMask(r, g, b, a)
|
||||
}
|
||||
func (GLImpl) CompileShader(shader uint32) {
|
||||
C.glCompileShader(C.GLuint(shader))
|
||||
}
|
||||
func (GLImpl) CreateProgram() uint32 {
|
||||
return uint32(C.glCreateProgram())
|
||||
}
|
||||
func (GLImpl) CreateShader(xtype uint32) uint32 {
|
||||
return uint32(C.glCreateShader(C.GLenum(xtype)))
|
||||
}
|
||||
func (GLImpl) DeleteShader(shader uint32) {
|
||||
C.glDeleteShader(C.GLuint(shader))
|
||||
}
|
||||
func (GLImpl) DeleteFramebuffers(n int32, framebuffers *uint32) {
|
||||
C.glDeleteFramebuffers(C.GLsizei(n), (*C.GLuint)(framebuffers))
|
||||
}
|
||||
func (GLImpl) DeleteRenderbuffers(n int32, renderbuffers *uint32) {
|
||||
C.glDeleteRenderbuffers(C.GLsizei(n), (*C.GLuint)(renderbuffers))
|
||||
}
|
||||
func (GLImpl) DeleteTextures(n int32, textures *uint32) {
|
||||
C.glDeleteTextures(C.GLsizei(n), (*C.GLuint)(textures))
|
||||
}
|
||||
func (GLImpl) Disable(cap uint32) {
|
||||
C.glDisable(C.GLenum(cap))
|
||||
}
|
||||
func (GLImpl) DisableVertexAttribArray(index uint32) {
|
||||
C.glDisableVertexAttribArray(C.GLuint(index))
|
||||
}
|
||||
func (GLImpl) DrawArrays(mode uint32, first int32, count int32) {
|
||||
C.glDrawArrays(C.GLenum(mode), C.GLint(first), C.GLsizei(count))
|
||||
}
|
||||
func (GLImpl) Enable(cap uint32) {
|
||||
C.glEnable(C.GLenum(cap))
|
||||
}
|
||||
func (GLImpl) EnableVertexAttribArray(index uint32) {
|
||||
C.glEnableVertexAttribArray(C.GLuint(index))
|
||||
}
|
||||
func (GLImpl) FramebufferRenderbuffer(target uint32, attachment uint32, renderbuffertarget uint32, renderbuffer uint32) {
|
||||
C.glFramebufferRenderbuffer(C.GLenum(target), C.GLenum(attachment), C.GLenum(renderbuffertarget), C.GLuint(renderbuffer))
|
||||
}
|
||||
func (GLImpl) FramebufferTexture(target uint32, attachment uint32, texture uint32, level int32) {
|
||||
C.glFramebufferTexture2D(C.GLenum(target), C.GLenum(attachment), C.GL_TEXTURE_2D, C.GLuint(texture), C.GLint(level))
|
||||
}
|
||||
func (GLImpl) GenBuffers(n int32, buffers *uint32) {
|
||||
C.glGenBuffers(C.GLsizei(n), (*C.GLuint)(buffers))
|
||||
}
|
||||
func (GLImpl) GenFramebuffers(n int32, framebuffers *uint32) {
|
||||
C.glGenFramebuffers(C.GLsizei(n), (*C.GLuint)(framebuffers))
|
||||
}
|
||||
func (GLImpl) GenRenderbuffers(n int32, renderbuffers *uint32) {
|
||||
C.glGenRenderbuffers(C.GLsizei(n), (*C.GLuint)(renderbuffers))
|
||||
}
|
||||
func (GLImpl) GenTextures(n int32, textures *uint32) {
|
||||
C.glGenTextures(C.GLsizei(n), (*C.GLuint)(textures))
|
||||
}
|
||||
func (GLImpl) GenerateMipmap(target uint32) {
|
||||
C.glGenerateMipmap(C.GLenum(target))
|
||||
}
|
||||
func (GLImpl) GetAttribLocation(program uint32, name string) int32 {
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
return int32(C.glGetAttribLocation(C.GLuint(program), (*C.GLchar)(cname)))
|
||||
}
|
||||
func (GLImpl) GetError() uint32 {
|
||||
return uint32(C.glGetError())
|
||||
}
|
||||
func (GLImpl) GetProgramInfoLog(program uint32) string {
|
||||
var length C.GLint
|
||||
C.glGetProgramiv(C.GLuint(program), C.GL_INFO_LOG_LENGTH, &length)
|
||||
if length == 0 {
|
||||
return ""
|
||||
}
|
||||
clog := C.CBytes(make([]byte, int(length)+1))
|
||||
defer C.free(clog)
|
||||
C.glGetProgramInfoLog(C.GLuint(program), C.GLsizei(length), nil, (*C.GLchar)(clog))
|
||||
return string(C.GoBytes(clog, C.int(length)))
|
||||
}
|
||||
func (GLImpl) GetProgramiv(program uint32, pname uint32, params *int32) {
|
||||
C.glGetProgramiv(C.GLuint(program), C.GLenum(pname), (*C.GLint)(params))
|
||||
}
|
||||
func (GLImpl) GetShaderInfoLog(program uint32) string {
|
||||
var length C.GLint
|
||||
C.glGetShaderiv(C.GLuint(program), C.GL_INFO_LOG_LENGTH, &length)
|
||||
if length == 0 {
|
||||
return ""
|
||||
}
|
||||
clog := C.CBytes(make([]byte, int(length)+1))
|
||||
defer C.free(clog)
|
||||
C.glGetShaderInfoLog(C.GLuint(program), C.GLsizei(length), nil, (*C.GLchar)(clog))
|
||||
return string(C.GoBytes(clog, C.int(length)))
|
||||
}
|
||||
func (GLImpl) GetShaderiv(shader uint32, pname uint32, params *int32) {
|
||||
C.glGetShaderiv(C.GLuint(shader), C.GLenum(pname), (*C.GLint)(params))
|
||||
|
||||
}
|
||||
func (GLImpl) GetUniformLocation(program uint32, name string) int32 {
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
return int32(C.glGetUniformLocation(C.GLuint(program), (*C.GLchar)(cname)))
|
||||
}
|
||||
func (GLImpl) LinkProgram(program uint32) {
|
||||
C.glLinkProgram(C.GLuint(program))
|
||||
}
|
||||
func (GLImpl) ReadPixels(x int32, y int32, width int32, height int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
C.glReadPixels(C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height), C.GLenum(format), C.GLenum(xtype), pixels)
|
||||
}
|
||||
func (GLImpl) RenderbufferStorage(target uint32, internalformat uint32, width int32, height int32) {
|
||||
C.glRenderbufferStorage(C.GLenum(target), C.GLenum(internalformat), C.GLint(width), C.GLint(height))
|
||||
}
|
||||
func (GLImpl) Scissor(x int32, y int32, width int32, height int32) {
|
||||
C.glScissor(C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height))
|
||||
}
|
||||
func (GLImpl) ShaderSource(shader uint32, source string) {
|
||||
csource := (*C.GLchar)(C.CString(source))
|
||||
defer C.free(unsafe.Pointer(csource))
|
||||
C.glShaderSource(C.GLuint(shader), 1, &csource, nil)
|
||||
}
|
||||
func (GLImpl) StencilFunc(xfunc uint32, ref int32, mask uint32) {
|
||||
C.glStencilFunc(C.GLenum(xfunc), C.GLint(ref), C.GLuint(mask))
|
||||
}
|
||||
func (GLImpl) StencilMask(mask uint32) {
|
||||
C.glStencilMask(C.GLuint(mask))
|
||||
}
|
||||
func (GLImpl) StencilOp(fail uint32, zfail uint32, zpass uint32) {
|
||||
C.glStencilOp(C.GLenum(fail), C.GLenum(zfail), C.GLenum(zpass))
|
||||
}
|
||||
func (GLImpl) TexImage2D(target uint32, level int32, internalformat int32, width int32, height int32, border int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
C.glTexImage2D(C.GLenum(target), C.GLint(level), C.GLint(internalformat), C.GLsizei(width), C.GLsizei(height), C.GLint(border), C.GLenum(format), C.GLenum(xtype), pixels)
|
||||
}
|
||||
func (GLImpl) TexParameteri(target uint32, pname uint32, param int32) {
|
||||
C.glTexParameteri(C.GLenum(target), C.GLenum(pname), C.GLint(param))
|
||||
}
|
||||
func (GLImpl) TexSubImage2D(target uint32, level int32, xoffset int32, yoffset int32, width int32, height int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
C.glTexSubImage2D(C.GLenum(target), C.GLint(level), C.GLint(xoffset), C.GLint(yoffset), C.GLsizei(width), C.GLsizei(height), C.GLenum(format), C.GLenum(xtype), pixels)
|
||||
}
|
||||
func (GLImpl) Uniform1f(location int32, v0 float32) {
|
||||
C.glUniform1f(C.GLint(location), C.GLfloat(v0))
|
||||
}
|
||||
func (GLImpl) Uniform1fv(location int32, count int32, v *float32) {
|
||||
C.glUniform1fv(C.GLint(location), C.GLsizei(count), (*C.GLfloat)(v))
|
||||
}
|
||||
func (GLImpl) Uniform1i(location int32, v0 int32) {
|
||||
C.glUniform1i(C.GLint(location), C.GLint(v0))
|
||||
}
|
||||
func (GLImpl) Uniform2f(location int32, v0 float32, v1 float32) {
|
||||
C.glUniform2f(C.GLint(location), C.GLfloat(v0), C.GLfloat(v1))
|
||||
}
|
||||
func (GLImpl) Uniform4f(location int32, v0 float32, v1 float32, v2 float32, v3 float32) {
|
||||
C.glUniform4f(C.GLint(location), C.GLfloat(v0), C.GLfloat(v1), C.GLfloat(v2), C.GLfloat(v3))
|
||||
}
|
||||
func (GLImpl) UniformMatrix3fv(location int32, count int32, transpose bool, value *float32) {
|
||||
var t C.GLboolean
|
||||
if transpose {
|
||||
t = 1
|
||||
}
|
||||
C.glUniformMatrix3fv(C.GLint(location), C.GLsizei(count), t, (*C.GLfloat)(value))
|
||||
}
|
||||
func (GLImpl) UseProgram(program uint32) {
|
||||
C.glUseProgram(C.GLuint(program))
|
||||
}
|
||||
func (GLImpl) VertexAttribPointer(index uint32, size int32, xtype uint32, normalized bool, stride int32, offset uint32) {
|
||||
var n C.GLboolean
|
||||
if normalized {
|
||||
n = 1
|
||||
}
|
||||
C.glVertexAttribPointer(C.GLuint(index), C.GLint(size), C.GLenum(xtype), n, C.GLsizei(stride), unsafe.Pointer(uintptr(offset)))
|
||||
}
|
||||
func (GLImpl) Viewport(x int32, y int32, width int32, height int32) {
|
||||
C.glViewport(C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height))
|
||||
}
|
|
@ -1,309 +0,0 @@
|
|||
package glimplxmobile
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"unsafe"
|
||||
|
||||
"github.com/tfriedel6/canvas"
|
||||
"golang.org/x/mobile/gl"
|
||||
)
|
||||
|
||||
type GLImpl struct {
|
||||
gl gl.Context
|
||||
programs map[uint32]gl.Program
|
||||
}
|
||||
|
||||
var _ canvas.GL = GLImpl{}
|
||||
|
||||
func New(ctx gl.Context) *GLImpl {
|
||||
return &GLImpl{
|
||||
gl: ctx,
|
||||
programs: make(map[uint32]gl.Program),
|
||||
}
|
||||
}
|
||||
|
||||
func (gli GLImpl) Ptr(data interface{}) unsafe.Pointer {
|
||||
if data == nil {
|
||||
return unsafe.Pointer(nil)
|
||||
}
|
||||
var addr unsafe.Pointer
|
||||
v := reflect.ValueOf(data)
|
||||
switch v.Type().Kind() {
|
||||
case reflect.Ptr:
|
||||
e := v.Elem()
|
||||
switch e.Kind() {
|
||||
case
|
||||
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
|
||||
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
|
||||
reflect.Float32, reflect.Float64:
|
||||
addr = unsafe.Pointer(e.UnsafeAddr())
|
||||
default:
|
||||
panic(fmt.Errorf("unsupported pointer to type %s; must be a slice or pointer to a singular scalar value or the first element of an array or slice", e.Kind()))
|
||||
}
|
||||
case reflect.Uintptr:
|
||||
addr = unsafe.Pointer(v.Pointer())
|
||||
case reflect.Slice:
|
||||
addr = unsafe.Pointer(v.Index(0).UnsafeAddr())
|
||||
default:
|
||||
panic(fmt.Errorf("unsupported type %s; must be a slice or pointer to a singular scalar value or the first element of an array or slice", v.Type()))
|
||||
}
|
||||
return addr
|
||||
}
|
||||
func (gli GLImpl) ActiveTexture(texture uint32) {
|
||||
gli.gl.ActiveTexture(gl.Enum(texture))
|
||||
}
|
||||
func (gli GLImpl) AttachShader(program uint32, shader uint32) {
|
||||
gli.gl.AttachShader(gli.programs[program], gl.Shader{Value: shader})
|
||||
}
|
||||
func (gli GLImpl) BindBuffer(target uint32, buffer uint32) {
|
||||
gli.gl.BindBuffer(gl.Enum(target), gl.Buffer{Value: buffer})
|
||||
}
|
||||
func (gli GLImpl) BindFramebuffer(target uint32, framebuffer uint32) {
|
||||
gli.gl.BindFramebuffer(gl.Enum(target), gl.Framebuffer{Value: framebuffer})
|
||||
}
|
||||
func (gli GLImpl) BindRenderbuffer(target uint32, renderbuffer uint32) {
|
||||
gli.gl.BindRenderbuffer(gl.Enum(target), gl.Renderbuffer{Value: renderbuffer})
|
||||
}
|
||||
func (gli GLImpl) BindTexture(target uint32, texture uint32) {
|
||||
gli.gl.BindTexture(gl.Enum(target), gl.Texture{Value: texture})
|
||||
}
|
||||
func (gli GLImpl) BlendFunc(sfactor uint32, dfactor uint32) {
|
||||
gli.gl.BlendFunc(gl.Enum(sfactor), gl.Enum(dfactor))
|
||||
}
|
||||
func (gli GLImpl) BufferData(target uint32, size int, data unsafe.Pointer, usage uint32) {
|
||||
var buf []byte
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = size
|
||||
sh.Len = size
|
||||
sh.Data = uintptr(data)
|
||||
gli.gl.BufferData(gl.Enum(target), buf, gl.Enum(usage))
|
||||
}
|
||||
func (gli GLImpl) CheckFramebufferStatus(target uint32) uint32 {
|
||||
return uint32(gli.gl.CheckFramebufferStatus(gl.Enum(target)))
|
||||
}
|
||||
func (gli GLImpl) Clear(mask uint32) {
|
||||
gli.gl.Clear(gl.Enum(mask))
|
||||
}
|
||||
func (gli GLImpl) ClearColor(red float32, green float32, blue float32, alpha float32) {
|
||||
gli.gl.ClearColor(red, green, blue, alpha)
|
||||
}
|
||||
func (gli GLImpl) ColorMask(red bool, green bool, blue bool, alpha bool) {
|
||||
gli.gl.ColorMask(red, green, blue, alpha)
|
||||
}
|
||||
func (gli GLImpl) CompileShader(shader uint32) {
|
||||
gli.gl.CompileShader(gl.Shader{Value: shader})
|
||||
}
|
||||
func (gli GLImpl) CreateProgram() uint32 {
|
||||
program := gli.gl.CreateProgram()
|
||||
gli.programs[program.Value] = program
|
||||
return program.Value
|
||||
}
|
||||
func (gli GLImpl) CreateShader(xtype uint32) uint32 {
|
||||
return gli.gl.CreateShader(gl.Enum(xtype)).Value
|
||||
}
|
||||
func (gli GLImpl) DeleteShader(shader uint32) {
|
||||
gli.gl.DeleteShader(gl.Shader{Value: shader})
|
||||
}
|
||||
func (gli GLImpl) DeleteFramebuffers(n int32, framebuffers *uint32) {
|
||||
var buf []uint32
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = int(n)
|
||||
sh.Len = int(n)
|
||||
sh.Data = uintptr(unsafe.Pointer(framebuffers))
|
||||
for i := 0; i < int(n); i++ {
|
||||
gli.gl.DeleteFramebuffer(gl.Framebuffer{Value: buf[i]})
|
||||
}
|
||||
}
|
||||
func (gli GLImpl) DeleteRenderbuffers(n int32, renderbuffers *uint32) {
|
||||
var buf []uint32
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = int(n)
|
||||
sh.Len = int(n)
|
||||
sh.Data = uintptr(unsafe.Pointer(renderbuffers))
|
||||
for i := 0; i < int(n); i++ {
|
||||
gli.gl.DeleteRenderbuffer(gl.Renderbuffer{Value: buf[i]})
|
||||
}
|
||||
}
|
||||
func (gli GLImpl) DeleteTextures(n int32, textures *uint32) {
|
||||
var buf []uint32
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = int(n)
|
||||
sh.Len = int(n)
|
||||
sh.Data = uintptr(unsafe.Pointer(textures))
|
||||
for i := 0; i < int(n); i++ {
|
||||
gli.gl.DeleteTexture(gl.Texture{Value: buf[i]})
|
||||
}
|
||||
}
|
||||
func (gli GLImpl) Disable(cap uint32) {
|
||||
gli.gl.Disable(gl.Enum(cap))
|
||||
}
|
||||
func (gli GLImpl) DisableVertexAttribArray(index uint32) {
|
||||
gli.gl.DisableVertexAttribArray(gl.Attrib{Value: uint(index)})
|
||||
}
|
||||
func (gli GLImpl) DrawArrays(mode uint32, first int32, count int32) {
|
||||
gli.gl.DrawArrays(gl.Enum(mode), int(first), int(count))
|
||||
}
|
||||
func (gli GLImpl) Enable(cap uint32) {
|
||||
gli.gl.Enable(gl.Enum(cap))
|
||||
}
|
||||
func (gli GLImpl) EnableVertexAttribArray(index uint32) {
|
||||
gli.gl.EnableVertexAttribArray(gl.Attrib{Value: uint(index)})
|
||||
}
|
||||
func (gli GLImpl) FramebufferRenderbuffer(target uint32, attachment uint32, renderbuffertarget uint32, renderbuffer uint32) {
|
||||
gli.gl.FramebufferRenderbuffer(gl.Enum(target), gl.Enum(attachment), gl.Enum(renderbuffertarget), gl.Renderbuffer{Value: renderbuffer})
|
||||
}
|
||||
func (gli GLImpl) FramebufferTexture(target uint32, attachment uint32, texture uint32, level int32) {
|
||||
gli.gl.FramebufferTexture2D(gl.Enum(target), gl.Enum(attachment), gl.TEXTURE_2D, gl.Texture{Value: texture}, int(level))
|
||||
}
|
||||
func (gli GLImpl) GenBuffers(n int32, buffers *uint32) {
|
||||
var buf []uint32
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = int(n)
|
||||
sh.Len = int(n)
|
||||
sh.Data = uintptr(unsafe.Pointer(buffers))
|
||||
for i := 0; i < int(n); i++ {
|
||||
buf[i] = gli.gl.CreateBuffer().Value
|
||||
}
|
||||
}
|
||||
func (gli GLImpl) GenFramebuffers(n int32, framebuffers *uint32) {
|
||||
var buf []uint32
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = int(n)
|
||||
sh.Len = int(n)
|
||||
sh.Data = uintptr(unsafe.Pointer(framebuffers))
|
||||
for i := 0; i < int(n); i++ {
|
||||
buf[i] = gli.gl.CreateFramebuffer().Value
|
||||
}
|
||||
}
|
||||
func (gli GLImpl) GenRenderbuffers(n int32, renderbuffers *uint32) {
|
||||
var buf []uint32
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = int(n)
|
||||
sh.Len = int(n)
|
||||
sh.Data = uintptr(unsafe.Pointer(renderbuffers))
|
||||
for i := 0; i < int(n); i++ {
|
||||
buf[i] = gli.gl.CreateRenderbuffer().Value
|
||||
}
|
||||
}
|
||||
func (gli GLImpl) GenTextures(n int32, textures *uint32) {
|
||||
var buf []uint32
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = int(n)
|
||||
sh.Len = int(n)
|
||||
sh.Data = uintptr(unsafe.Pointer(textures))
|
||||
for i := 0; i < int(n); i++ {
|
||||
buf[i] = gli.gl.CreateTexture().Value
|
||||
}
|
||||
}
|
||||
func (gli GLImpl) GenerateMipmap(target uint32) {
|
||||
gli.gl.GenerateMipmap(gl.Enum(target))
|
||||
}
|
||||
func (gli GLImpl) GetAttribLocation(program uint32, name string) int32 {
|
||||
return int32(gli.gl.GetAttribLocation(gli.programs[program], name).Value)
|
||||
}
|
||||
func (gli GLImpl) GetError() uint32 {
|
||||
return uint32(gli.gl.GetError())
|
||||
}
|
||||
func (gli GLImpl) GetProgramInfoLog(program uint32) string {
|
||||
return gli.gl.GetProgramInfoLog(gli.programs[program])
|
||||
}
|
||||
func (gli GLImpl) GetProgramiv(program uint32, pname uint32, params *int32) {
|
||||
i := gli.gl.GetProgrami(gli.programs[program], gl.Enum(pname))
|
||||
*params = int32(i)
|
||||
}
|
||||
func (gli GLImpl) GetShaderInfoLog(program uint32) string {
|
||||
return gli.gl.GetShaderInfoLog(gl.Shader{Value: program})
|
||||
}
|
||||
func (gli GLImpl) GetShaderiv(shader uint32, pname uint32, params *int32) {
|
||||
i := gli.gl.GetShaderi(gl.Shader{Value: shader}, gl.Enum(pname))
|
||||
*params = int32(i)
|
||||
}
|
||||
func (gli GLImpl) GetUniformLocation(program uint32, name string) int32 {
|
||||
return gli.gl.GetUniformLocation(gli.programs[program], name).Value
|
||||
}
|
||||
func (gli GLImpl) LinkProgram(program uint32) {
|
||||
gli.gl.LinkProgram(gli.programs[program])
|
||||
}
|
||||
func (gli GLImpl) ReadPixels(x int32, y int32, width int32, height int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
var buf []byte
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = int(width * height * 4)
|
||||
sh.Len = int(width * height * 4)
|
||||
sh.Data = uintptr(pixels)
|
||||
gli.gl.ReadPixels(buf, int(x), int(y), int(width), int(height), gl.Enum(format), gl.Enum(xtype))
|
||||
}
|
||||
func (gli GLImpl) RenderbufferStorage(target uint32, internalformat uint32, width int32, height int32) {
|
||||
gli.gl.RenderbufferStorage(gl.Enum(target), gl.Enum(internalformat), int(width), int(height))
|
||||
}
|
||||
func (gli GLImpl) Scissor(x int32, y int32, width int32, height int32) {
|
||||
gli.gl.Scissor(x, y, width, height)
|
||||
}
|
||||
func (gli GLImpl) ShaderSource(shader uint32, source string) {
|
||||
gli.gl.ShaderSource(gl.Shader{Value: shader}, source)
|
||||
}
|
||||
func (gli GLImpl) StencilFunc(xfunc uint32, ref int32, mask uint32) {
|
||||
gli.gl.StencilFunc(gl.Enum(xfunc), int(ref), mask)
|
||||
}
|
||||
func (gli GLImpl) StencilMask(mask uint32) {
|
||||
gli.gl.StencilMask(mask)
|
||||
}
|
||||
func (gli GLImpl) StencilOp(fail uint32, zfail uint32, zpass uint32) {
|
||||
gli.gl.StencilOp(gl.Enum(fail), gl.Enum(zfail), gl.Enum(zpass))
|
||||
}
|
||||
func (gli GLImpl) TexImage2D(target uint32, level int32, internalformat int32, width int32, height int32, border int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
var buf []byte
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = int(width * height * 4)
|
||||
sh.Len = int(width * height * 4)
|
||||
sh.Data = uintptr(pixels)
|
||||
gli.gl.TexImage2D(gl.Enum(target), int(level), int(internalformat), int(width), int(height), gl.Enum(format), gl.Enum(xtype), buf)
|
||||
}
|
||||
func (gli GLImpl) TexParameteri(target uint32, pname uint32, param int32) {
|
||||
gli.gl.TexParameteri(gl.Enum(target), gl.Enum(pname), int(param))
|
||||
}
|
||||
func (gli GLImpl) TexSubImage2D(target uint32, level int32, xoffset int32, yoffset int32, width int32, height int32, format uint32, xtype uint32, pixels unsafe.Pointer) {
|
||||
var buf []byte
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = int(width * height * 4)
|
||||
sh.Len = int(width * height * 4)
|
||||
sh.Data = uintptr(pixels)
|
||||
gli.gl.TexSubImage2D(gl.Enum(target), int(level), int(xoffset), int(yoffset), int(width), int(height), gl.Enum(format), gl.Enum(xtype), buf)
|
||||
}
|
||||
func (gli GLImpl) Uniform1f(location int32, v0 float32) {
|
||||
gli.gl.Uniform1f(gl.Uniform{Value: location}, v0)
|
||||
}
|
||||
func (gli GLImpl) Uniform1fv(location int32, count int32, v *float32) {
|
||||
var buf []float32
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = int(count)
|
||||
sh.Len = int(count)
|
||||
sh.Data = uintptr(unsafe.Pointer(v))
|
||||
gli.gl.Uniform1fv(gl.Uniform{Value: location}, buf)
|
||||
}
|
||||
func (gli GLImpl) Uniform1i(location int32, v0 int32) {
|
||||
gli.gl.Uniform1i(gl.Uniform{Value: location}, int(v0))
|
||||
}
|
||||
func (gli GLImpl) Uniform2f(location int32, v0 float32, v1 float32) {
|
||||
gli.gl.Uniform2f(gl.Uniform{Value: location}, v0, v1)
|
||||
}
|
||||
func (gli GLImpl) Uniform4f(location int32, v0 float32, v1 float32, v2 float32, v3 float32) {
|
||||
gli.gl.Uniform4f(gl.Uniform{Value: location}, v0, v1, v2, v3)
|
||||
}
|
||||
func (gli GLImpl) UniformMatrix3fv(location int32, count int32, transpose bool, value *float32) {
|
||||
var buf []float32
|
||||
sh := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
sh.Cap = 9
|
||||
sh.Len = 9
|
||||
sh.Data = uintptr(unsafe.Pointer(value))
|
||||
gli.gl.UniformMatrix3fv(gl.Uniform{Value: location}, buf)
|
||||
}
|
||||
func (gli GLImpl) UseProgram(program uint32) {
|
||||
gli.gl.UseProgram(gli.programs[program])
|
||||
}
|
||||
func (gli GLImpl) VertexAttribPointer(index uint32, size int32, xtype uint32, normalized bool, stride int32, offset uint32) {
|
||||
gli.gl.VertexAttribPointer(gl.Attrib{Value: uint(index)}, int(size), gl.Enum(xtype), normalized, int(stride), int(offset))
|
||||
}
|
||||
func (gli GLImpl) Viewport(x int32, y int32, width int32, height int32) {
|
||||
gli.gl.Viewport(int(x), int(y), int(width), int(height))
|
||||
}
|
Loading…
Reference in a new issue