func GetShaderBinaryFormats() (formats []ShaderBinaryFormat) { numFormats := C.GLint(0) C.glGetIntegerv(C.GL_NUM_SHADER_BINARY_FORMATS, &numFormats) if numFormats > 0 { formats = make([]ShaderBinaryFormat, numFormats) C.glGetIntegerv(C.GL_SHADER_BINARY_FORMATS, (*C.GLint)(&formats[0])) } return }
func ReadAlpha(image *image.Alpha) { alignment := C.GLint(0) C.glGetIntegerv(C.GL_PACK_ALIGNMENT, &alignment) align := C.GLint(1) for align < alignment && image.Stride%(int(align)*2) == 0 { align *= 2 } // need smaller alignment if align < alignment { C.glPixelStorei(C.GL_PACK_ALIGNMENT, align) } C.glReadPixels(C.GLint(image.Rect.Min.X), C.GLint(image.Rect.Min.Y), C.GLsizei(image.Rect.Dx()), C.GLsizei(image.Rect.Dy()), C.GL_ALPHA, C.GL_UNSIGNED_BYTE, unsafe.Pointer(&image.Pix[0])) // restore alignment if align < alignment { C.glPixelStorei(C.GL_PACK_ALIGNMENT, alignment) } }
func GetIntegerv(pname Enum, data []int32) { buf := make([]C.GLint, len(data)) C.glGetIntegerv(pname.c(), &buf[0]) for i, v := range buf { data[i] = int32(v) } }
// Convenience function for glGetIntegerv func GetInteger4(pname GLenum) (v0, v1, v2, v3 int) { var values [4]C.GLint C.glGetIntegerv(C.GLenum(pname), &values[0]) v0 = int(values[0]) v1 = int(values[1]) v2 = int(values[2]) v3 = int(values[3]) return }
func GetInteger(pname Enum) (r0 int) { defer func() { errstr := errDrain() log.Printf("gl.GetInteger(%v) %v%v", pname, r0, errstr) }() var v C.GLint C.glGetIntegerv(pname.c(), &v) return int(v) }
func GetIntegerv(targ int, size int) (data []int) { data = make([]int, 4) var p []C.GLint = make([]C.GLint, size) C.glGetIntegerv(C.GLenum(targ), &p[0]) for i := 0; i < size; i++ { data[i] = int(p[i]) } return }
func GetIntegerv(pname Enum, data []int32) { defer func() { errstr := errDrain() log.Printf("gl.GetIntegerv(%v, %v) %v", pname, data, errstr) }() buf := make([]C.GLint, len(data)) C.glGetIntegerv(pname.c(), &buf[0]) for i, v := range buf { data[i] = int32(v) } }
func adjustUnpackAlignment(stride int) C.GLint { alignment := C.GLint(0) C.glGetIntegerv(C.GL_UNPACK_ALIGNMENT, &alignment) align := C.GLint(1) for align < alignment && stride%(int(align)*2) == 0 { align *= 2 } // need smaller alignment if align < alignment { C.glPixelStorei(C.GL_UNPACK_ALIGNMENT, align) // return old alignment return alignment } else { return 0 } }
func ReadRGBA(image *image.NRGBA) { alignment := C.GLint(0) C.glGetIntegerv(C.GL_PACK_ALIGNMENT, &alignment) align := image.Stride % int(alignment) // align: 4 or 0 // need smaller alignment if align > 0 { C.glPixelStorei(C.GL_PACK_ALIGNMENT, C.GLint(align)) } C.glReadPixels(C.GLint(image.Rect.Min.X), C.GLint(image.Rect.Min.Y), C.GLsizei(image.Rect.Dx()), C.GLsizei(image.Rect.Dy()), C.GL_RGBA, C.GL_UNSIGNED_BYTE, unsafe.Pointer(&image.Pix[0])) // restore alignment if align > 0 { C.glPixelStorei(C.GL_PACK_ALIGNMENT, alignment) } }
func GetIntegerv( pname Enum, params *int32) { C.glGetIntegerv( C.GLenum(pname), (*C.GLint)(params)) }
func GetReadFramebufferBinding() Framebuffer { framebuffer := C.GLint(0) C.glGetIntegerv(C.GL_READ_FRAMEBUFFER_BINDING, &framebuffer) return Framebuffer(framebuffer) }
func GetDrawFramebufferBinding() Framebuffer { framebuffer := C.GLint(0) C.glGetIntegerv(C.GL_DRAW_FRAMEBUFFER_BINDING, &framebuffer) return Framebuffer(framebuffer) }
func GetViewport() (int, int, int, int) { data := [4]C.GLint{0, 0, 0, 0} C.glGetIntegerv(C.GL_VIEWPORT, &data[0]) return int(data[0]), int(data[1]), int(data[2]), int(data[3]) }
func GetIntegerv(index uint, v1 *int) { C.glGetIntegerv(C.GLenum(index), (*C.GLint)(Pointer(v1))) }
func GetInteger(pname Enum) int { var v C.GLint C.glGetIntegerv(pname.c(), &v) return int(v) }
func GetIntegerv(pname uint, params []int32) []int32 { C.glGetIntegerv(C.GLenum(pname), (*C.GLint)(¶ms[0])) return params }
//void glGetIntegerv (GLenum pname, int *params) func GetIntegerv(pname GLenum, params []int32) { if len(params) == 0 { panic("Invalid params length") } C.glGetIntegerv(C.GLenum(pname), (*C.GLint)(¶ms[0])) }
func GetActiveTexture() TextureUnit { texture := C.GLint(0) C.glGetIntegerv(C.GL_ACTIVE_TEXTURE, &texture) return TextureUnit(texture) }
func GetBoundFramebuffer() Framebuffer { println("GetBoundFramebuffer: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)") var b C.GLint C.glGetIntegerv(FRAMEBUFFER_BINDING, &b) return Framebuffer{Value: uint32(b)} }
//void glGetIntegerv (GLenum pname, int *params) func GetIntegerv(pname GLenum, params []int32) { if len(params) == 0 { panic(ErrorInputSize) } C.glGetIntegerv(C.GLenum(pname), (*C.GLint)(¶ms[0])) }