Exemple #1
0
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
}
Exemple #2
0
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)
	}
}
Exemple #3
0
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)
	}
}
Exemple #4
0
Fichier : gl.go Projet : micia/gl
// 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
}
Exemple #5
0
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)
}
Exemple #6
0
Fichier : gl.go Projet : extrame/gl
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
}
Exemple #7
0
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)
	}
}
Exemple #8
0
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
	}
}
Exemple #9
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)
	}
}
Exemple #10
0
func GetIntegerv(
	pname Enum, params *int32) {
	C.glGetIntegerv(
		C.GLenum(pname),
		(*C.GLint)(params))
}
Exemple #11
0
func GetReadFramebufferBinding() Framebuffer {
	framebuffer := C.GLint(0)
	C.glGetIntegerv(C.GL_READ_FRAMEBUFFER_BINDING, &framebuffer)
	return Framebuffer(framebuffer)
}
Exemple #12
0
func GetDrawFramebufferBinding() Framebuffer {
	framebuffer := C.GLint(0)
	C.glGetIntegerv(C.GL_DRAW_FRAMEBUFFER_BINDING, &framebuffer)
	return Framebuffer(framebuffer)
}
Exemple #13
0
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])
}
Exemple #14
0
func GetIntegerv(index uint, v1 *int) {
	C.glGetIntegerv(C.GLenum(index), (*C.GLint)(Pointer(v1)))
}
Exemple #15
0
func GetInteger(pname Enum) int {
	var v C.GLint
	C.glGetIntegerv(pname.c(), &v)
	return int(v)
}
Exemple #16
0
func GetIntegerv(pname uint, params []int32) []int32 {
	C.glGetIntegerv(C.GLenum(pname), (*C.GLint)(&params[0]))
	return params
}
Exemple #17
0
Fichier : gl.go Projet : james4k/gl
//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)(&params[0]))
}
Exemple #18
0
func GetActiveTexture() TextureUnit {
	texture := C.GLint(0)
	C.glGetIntegerv(C.GL_ACTIVE_TEXTURE, &texture)
	return TextureUnit(texture)
}
Exemple #19
0
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)}
}
Exemple #20
0
Fichier : gl.go Projet : Nvveen/gl
//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)(&params[0]))
}