Example #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))
}
Example #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)
}
Example #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")
}
Example #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),
	)
}
Example #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,
	)
}
Example #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))
}
Example #7
0
func DrawBuffers(bufs []Attachment) {
	gl.DrawBuffers(int32(len(bufs)), (*uint32)(gl.Ptr(bufs)))
}
Example #8
0
func ClearBuffer(buffer TargetBuffer, drawBuffer int, values []float32) {
	gl.ClearBufferfv(uint32(buffer), int32(drawBuffer), (*float32)(gl.Ptr(values)))
}
Example #9
0
File: gl.go Project: 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)))
}
Example #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)))
}
Example #11
0
func (u Uniform) FloatMutliRaw(a interface{}, l int) {
	gl.Uniform4fv(int32(u), int32(l), (*float32)(gl.Ptr(a)))
}
Example #12
0
func (u Uniform) FloatMutli(a []float32) {
	gl.Uniform4fv(int32(u), int32(len(a)), (*float32)(gl.Ptr(a)))
}
Example #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)))
}