Ejemplo n.º 1
0
// Data uploads the passed data to the gpu to be placed in this buffer.
// The usage specifies how the program plans to use this buffer.
func (b Buffer) Data(data []byte, usage BufferUsage) {
	var ptr unsafe.Pointer
	if len(data) != 0 {
		ptr = gl.Ptr(data)
	}
	gl.BufferData(uint32(currentBufferTarget), len(data), ptr, uint32(usage))
}
Ejemplo n.º 2
0
// Image3D uploads a 3D texture to the GPU.
func (t Texture) Image3D(level, width, height, depth int, format TextureFormat, ty Type, pix []byte) {
	if t != currentTexture {
		panic("texture not bound")
	}
	var ptr unsafe.Pointer
	if len(pix) != 0 {
		ptr = gl.Ptr(pix)
	}
	gl.TexImage3D(uint32(currentTextureTarget), int32(level), int32(format), int32(width), int32(height), int32(depth), int32(0), uint32(format), uint32(ty), ptr)
}
Ejemplo n.º 3
0
// InfoLog returns the log from compiling the shader.
func (s Shader) InfoLog() string {
	l := s.Parameter(InfoLogLength)

	var ptr unsafe.Pointer
	var buf []byte
	if l > 0 {
		buf = make([]byte, l)
		ptr = gl.Ptr(buf)
	}

	gl.GetShaderInfoLog(uint32(s), int32(l), nil, (*uint8)(ptr))
	return strings.TrimRight(string(buf), "\x00")
}
Ejemplo n.º 4
0
// SubImage2D updates a region of a 2D texture.
func (t Texture) SubImage2D(level int, x, y, width, height int, format TextureFormat, ty Type, pix []byte) {
	if t != currentTexture {
		panic("texture not bound")
	}
	gl.TexSubImage2D(
		uint32(currentTextureTarget),
		int32(level),
		int32(x),
		int32(y),
		int32(width),
		int32(height),
		uint32(format),
		uint32(ty),
		gl.Ptr(pix),
	)
}
Ejemplo n.º 5
0
// Image2DEx uploads a 2D texture to the GPU.
func (t Texture) Image2DEx(level, width, height int, internalFormat, format TextureFormat, ty Type, pix []byte) {
	if t != currentTexture {
		panic("texture not bound")
	}
	var ptr unsafe.Pointer
	if pix != nil {
		ptr = gl.Ptr(pix)
	}
	gl.TexImage2D(
		uint32(currentTextureTarget),
		int32(level),
		int32(internalFormat),
		int32(width),
		int32(height),
		0,
		uint32(format),
		uint32(ty),
		ptr,
	)
}
Ejemplo n.º 6
0
func (t Texture) Get(level int, format TextureFormat, ty Type, pixels []byte) {
	if t != currentTexture {
		panic("texture not bound")
	}
	gl.GetTexImage(uint32(currentTextureTarget), int32(level), uint32(format), uint32(ty), gl.Ptr(pixels))
}
Ejemplo n.º 7
0
func DrawBuffers(bufs []Attachment) {
	gl.DrawBuffers(int32(len(bufs)), (*uint32)(gl.Ptr(bufs)))
}
Ejemplo n.º 8
0
func ClearBuffer(buffer TargetBuffer, drawBuffer int, values []float32) {
	gl.ClearBufferfv(uint32(buffer), int32(drawBuffer), (*float32)(gl.Ptr(values)))
}
Ejemplo n.º 9
0
Archivo: gl.go Proyecto: num5/steven
func MultiDrawElements(ty DrawType, count []int32, dty Type, offset []uintptr) {
	gl.MultiDrawElements(uint32(ty), (*int32)(gl.Ptr(count)), uint32(dty), (*uintptr)(gl.Ptr(offset)), int32(len(count)))
}
Ejemplo n.º 10
0
// Matrix4 sets the value of the uniform to the passed matrix.
func (u Uniform) Matrix4Multi(matrix []mgl32.Mat4) {
	gl.UniformMatrix4fv(int32(u), int32(len(matrix)), false, (*float32)(gl.Ptr(matrix)))
}
Ejemplo n.º 11
0
func (u Uniform) FloatMutliRaw(a interface{}, l int) {
	gl.Uniform4fv(int32(u), int32(l), (*float32)(gl.Ptr(a)))
}
Ejemplo n.º 12
0
func (u Uniform) FloatMutli(a []float32) {
	gl.Uniform4fv(int32(u), int32(len(a)), (*float32)(gl.Ptr(a)))
}
Ejemplo n.º 13
0
// IntV sets the value of the uniform to the passed integer array.
func (u Uniform) IntV(v ...int) {
	gl.Uniform1iv(int32(u), int32(len(v)), (*int32)(gl.Ptr(v)))
}