Ejemplo n.º 1
0
func TexImage2D(target TextureTarget, level int, internalformat InternalFormat, width, height int, format TextureFormat, datatype DataType, pixels []uint8) {
	if pixels != nil {
		C.glTexImage2D(C.GLenum(target), C.GLint(level), C.GLint(internalformat), C.GLsizei(width), C.GLsizei(height), 0, C.GLenum(format), C.GLenum(datatype), unsafe.Pointer(&pixels[0]))
	} else {
		C.glTexImage2D(C.GLenum(target), C.GLint(level), C.GLint(internalformat), C.GLsizei(width), C.GLsizei(height), 0, C.GLenum(format), C.GLenum(datatype), unsafe.Pointer(nil))
	}
}
Ejemplo n.º 2
0
func TexImage2D(target Enum, level int, width, height int, format Enum, ty Enum, data []byte) {
	p := unsafe.Pointer(nil)
	if len(data) > 0 {
		p = unsafe.Pointer(&data[0])
	}
	C.glTexImage2D(target.c(), C.GLint(level), C.GLint(format), C.GLsizei(width), C.GLsizei(height), 0, format.c(), ty.c(), p)
}
Ejemplo n.º 3
0
// TexImage2D writes a 2D texture image.
//
// http://www.khronos.org/opengles/sdk/docs/man3/html/glTexImage2D.xhtml
func TexImage2D(target Enum, level int, width, height int, format Enum, ty Enum, data []byte) {
	// TODO(crawshaw): GLES3 offset for PIXEL_UNPACK_BUFFER and PIXEL_PACK_BUFFER.
	p := unsafe.Pointer(nil)
	if len(data) > 0 {
		p = unsafe.Pointer(&data[0])
	}
	C.glTexImage2D(target.c(), C.GLint(level), C.GLint(format), C.GLsizei(width), C.GLsizei(height), 0, format.c(), ty.c(), p)
}
Ejemplo n.º 4
0
func TexImage2D(target Enum, level int, width, height int, format Enum, ty Enum, data []byte) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.TexImage2D(%v, %v, %v, %v, %v, %v, len(%d)) %v", target, level, width, height, format, ty, len(data), errstr)
	}()
	p := unsafe.Pointer(nil)
	if len(data) > 0 {
		p = unsafe.Pointer(&data[0])
	}
	C.glTexImage2D(target.c(), C.GLint(level), C.GLint(format), C.GLsizei(width), C.GLsizei(height), 0, format.c(), ty.c(), p)
}
Ejemplo n.º 5
0
// TexImage2D specifies a two-dimensional texture image.
func TexImage2D(targ TextureTarget, lvl int, ifmt TextureFormat, w, h, border int, fmt TextureFormat, data interface{}) {
	tipe, _, ptr := rawData(data)
	C.glTexImage2D(C.GLenum(targ),
		C.GLint(lvl),
		C.GLint(ifmt),
		C.GLsizei(w),
		C.GLsizei(h),
		C.GLint(border),
		C.GLenum(fmt),
		C.GLenum(tipe),
		ptr)
}
Ejemplo n.º 6
0
func TexImage2D(
	target Enum, level int32, internalformat int32,
	width Sizei, height Sizei, border int32, format Enum,
	type_ Enum, pixels Void) {
	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(type_),
		unsafe.Pointer(pixels))
}
Ejemplo n.º 7
0
Archivo: gla.go Proyecto: spate/gla
// TexImage2DFromImage loads texture data from an image.Image into the currently
// bound GL texture using the glTexImage2D call. If you wish to load only part of
// an image, pass a subimage as the argument.
//
// Precondition: no buffer object bound to PIXEL_UNPACK_BUFFER
//
// Additional state modified: UNPACK_ALIGNMENT, UNPACK_ROW_LENGTH
func TexImage2DFromImage(target GLenum, level int, internalformat int, border int, img image.Image) {
	bounds := img.Bounds()
	if bounds.Empty() {
		return
	}

	info := getImageInfo(img)

	C.glPixelStorei(C.GLenum(gl.UNPACK_ALIGNMENT), C.GLint(1))
	C.glPixelStorei(C.GLenum(gl.UNPACK_ROW_LENGTH), C.GLint(info.RowLength))
	C.glTexImage2D(C.GLenum(target), C.GLint(level), C.GLint(internalformat),
		C.GLsizei(bounds.Dx()), C.GLsizei(bounds.Dy()), C.GLint(border),
		C.GLenum(info.Format), C.GLenum(info.Type),
		info.Data)
}
Ejemplo n.º 8
0
Archivo: gl.go Proyecto: extrame/gl
// NewTexture2D creates a new texture object from the given image using glTexImage2D. It uses RGBA as a color format and sets GL_TEXTURE_{MIN,MAG}_FILTER to GL_NEAREST
func NewTexture2D(img image.Image, border int) Texture {
	var t C.GLuint

	C.glGenTextures(1, &t)
	tt := Texture(t)
	tt.Bind(TEXTURE_2D)
	data := make([]uint16, img.Bounds().Dx()*img.Bounds().Dy()*4)
	r := img.Bounds()
	for x := r.Min.X; x < r.Max.X; x++ {
		for y := r.Min.Y; y < r.Max.Y; y++ {
			R, G, B, A := img.At(x, y).RGBA()
			i := (y*r.Dx() + x) * 4
			data[i] = uint16(R)
			data[i+1] = uint16(G)
			data[i+2] = uint16(B)
			data[i+3] = uint16(A)
		}
	}
	C.glTexImage2D(TEXTURE_2D, 0, RGBA, C.GLsizei(img.Bounds().Dx()), C.GLsizei(img.Bounds().Dy()), C.GLint(border), RGBA, UNSIGNED_SHORT, unsafe.Pointer(&data[0]))
	C.glTexParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, NEAREST)
	C.glTexParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, NEAREST)
	tt.Unbind(TEXTURE_2D)
	return tt
}
Ejemplo n.º 9
0
func TexImage2D(target Enum, level int, width, height int, format Enum, ty Enum, p unsafe.Pointer) {
	C.glTexImage2D(target.c(), C.GLint(level), C.GLint(format), C.GLsizei(width), C.GLsizei(height), 0, format.c(), ty.c(), p)
}
Ejemplo n.º 10
0
Archivo: texture.go Proyecto: Nvveen/gl
//void glTexImage2D (GLenum target, int level, int internalformat, int width, int height, int border, GLenum format, GLenum type, const GLvoid *pixels)
func TexImage2D(target GLenum, level int, internalformat int, width int, height int, border int, format, typ GLenum, pixels interface{}) {
	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(typ), ptr(pixels))
}
Ejemplo n.º 11
0
func TexImageLuminance(target TextureTarget, level int, img *image.Gray) {
	a := adjustUnpackAlignment(img.Stride)
	C.glTexImage2D(C.GLenum(target), C.GLint(level), C.GL_LUMINANCE, C.GLsizei(img.Rect.Dx()), C.GLsizei(img.Rect.Dy()), 0, C.GL_LUMINANCE, C.GL_UNSIGNED_BYTE, unsafe.Pointer(&img.Pix[0]))
	restoreAlignment(a)
}
Ejemplo n.º 12
0
func TexImage2D(target uint, level, internalformat, width, height,
	border int, format, type_ uint, pixels Void) {
	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(type_), unsafe.Pointer(pixels))
}
Ejemplo n.º 13
0
//void glTexImage2D (GLenum target, int level, int internalformat, int width, int height, int border, GLenum format, GLenum type, const GLvoid *pixels)
func TexImage2D(target GLenum, level int, internalformat int, width int, height int, border int, format GLenum, pixels interface{}) {
	t, p := GetGLenumType(pixels)
	C.glTexImage2D(C.GLenum(target), C.GLint(level), C.GLenum(internalformat), C.GLsizei(width), C.GLsizei(height), C.GLint(border), C.GLenum(format), C.GLenum(t), p)
}