completed the gl implementations
This commit is contained in:
parent
34c01f47d4
commit
3d82ce6998
4 changed files with 135 additions and 3 deletions
|
@ -588,14 +588,14 @@ func (cv *Canvas) enableTextureRenderTarget(offscr *offscreenBuffer) {
|
|||
|
||||
gli.GenRenderbuffers(1, &offscr.renderStencilBuf)
|
||||
gli.BindRenderbuffer(gl_RENDERBUFFER, offscr.renderStencilBuf)
|
||||
gli.RenderbufferStorage(gl_RENDERBUFFER, gl_DEPTH_STENCIL, int32(cv.w), int32(cv.h))
|
||||
gli.RenderbufferStorage(gl_RENDERBUFFER, gl_DEPTH24_STENCIL8, int32(cv.w), int32(cv.h))
|
||||
gli.FramebufferRenderbuffer(gl_FRAMEBUFFER, gl_DEPTH_STENCIL_ATTACHMENT, gl_RENDERBUFFER, offscr.renderStencilBuf)
|
||||
|
||||
gli.FramebufferTexture(gl_FRAMEBUFFER, gl_COLOR_ATTACHMENT0, offscr.tex, 0)
|
||||
|
||||
if gli.CheckFramebufferStatus(gl_FRAMEBUFFER) != gl_FRAMEBUFFER_COMPLETE {
|
||||
if err := gli.CheckFramebufferStatus(gl_FRAMEBUFFER); err != gl_FRAMEBUFFER_COMPLETE {
|
||||
// todo this should maybe not panic
|
||||
panic("Failed to set up framebuffer for offscreen texture")
|
||||
panic(fmt.Sprintf("Failed to set up framebuffer for offscreen texture: %x", err))
|
||||
}
|
||||
|
||||
gli.Clear(gl_COLOR_BUFFER_BIT | gl_STENCIL_BUFFER_BIT)
|
||||
|
|
|
@ -52,6 +52,12 @@ func (_ GLImpl) AttachShader(program uint32, shader uint32) {
|
|||
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))
|
||||
}
|
||||
|
@ -61,6 +67,9 @@ func (_ GLImpl) BlendFunc(sfactor uint32, dfactor uint32) {
|
|||
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))
|
||||
}
|
||||
|
@ -95,6 +104,12 @@ func (_ GLImpl) CreateShader(xtype uint32) uint32 {
|
|||
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))
|
||||
}
|
||||
|
@ -113,9 +128,21 @@ func (_ GLImpl) Enable(cap uint32) {
|
|||
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))
|
||||
}
|
||||
|
@ -170,6 +197,9 @@ func (_ GLImpl) LinkProgram(program uint32) {
|
|||
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))
|
||||
}
|
||||
|
@ -199,6 +229,9 @@ func (_ GLImpl) TexSubImage2D(target uint32, level int32, xoffset int32, yoffset
|
|||
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))
|
||||
}
|
||||
|
|
|
@ -52,6 +52,12 @@ func (_ GLImpl) AttachShader(program uint32, shader uint32) {
|
|||
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))
|
||||
}
|
||||
|
@ -61,6 +67,9 @@ func (_ GLImpl) BlendFunc(sfactor uint32, dfactor uint32) {
|
|||
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))
|
||||
}
|
||||
|
@ -95,6 +104,12 @@ func (_ GLImpl) CreateShader(xtype uint32) uint32 {
|
|||
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))
|
||||
}
|
||||
|
@ -113,9 +128,21 @@ func (_ GLImpl) Enable(cap uint32) {
|
|||
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))
|
||||
}
|
||||
|
@ -170,6 +197,9 @@ func (_ GLImpl) LinkProgram(program uint32) {
|
|||
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))
|
||||
}
|
||||
|
@ -199,6 +229,9 @@ func (_ GLImpl) TexSubImage2D(target uint32, level int32, xoffset int32, yoffset
|
|||
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))
|
||||
}
|
||||
|
|
|
@ -59,6 +59,12 @@ func (gli GLImpl) AttachShader(program uint32, shader uint32) {
|
|||
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})
|
||||
}
|
||||
|
@ -73,6 +79,9 @@ func (gli GLImpl) BufferData(target uint32, size int, data unsafe.Pointer, usage
|
|||
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))
|
||||
}
|
||||
|
@ -96,6 +105,26 @@ func (gli GLImpl) CreateShader(xtype uint32) uint32 {
|
|||
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))
|
||||
|
@ -121,6 +150,12 @@ func (gli GLImpl) Enable(cap uint32) {
|
|||
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))
|
||||
|
@ -131,6 +166,26 @@ func (gli GLImpl) GenBuffers(n int32, buffers *uint32) {
|
|||
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))
|
||||
|
@ -178,6 +233,9 @@ func (gli GLImpl) ReadPixels(x int32, y int32, width int32, height int32, format
|
|||
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)
|
||||
}
|
||||
|
@ -215,6 +273,14 @@ func (gli GLImpl) TexSubImage2D(target uint32, level int32, xoffset int32, yoffs
|
|||
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))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue