// 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)) }
// 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) }
// 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") }
// 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), ) }
// 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, ) }
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)) }
func DrawBuffers(bufs []Attachment) { gl.DrawBuffers(int32(len(bufs)), (*uint32)(gl.Ptr(bufs))) }
func ClearBuffer(buffer TargetBuffer, drawBuffer int, values []float32) { gl.ClearBufferfv(uint32(buffer), int32(drawBuffer), (*float32)(gl.Ptr(values))) }
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))) }
// 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))) }
func (u Uniform) FloatMutliRaw(a interface{}, l int) { gl.Uniform4fv(int32(u), int32(l), (*float32)(gl.Ptr(a))) }
func (u Uniform) FloatMutli(a []float32) { gl.Uniform4fv(int32(u), int32(len(a)), (*float32)(gl.Ptr(a))) }
// 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))) }