Omustardo / bytecoder

Encode to Byte Arrays

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bytecoder provides functions for converting various slices into byte slices. Based on the Bytes function from https://github.com/golang/mobile/blob/master/exp/f32/f32.go

I have found this to be of use when working with OpenGL buffers:

// Store basic rectangle vertices in a buffer.
vertices := bytecoder.Float32(binary.LittleEndian,
    0, 0,
    1, 0,
    1, 1,
    0, 1,
)
buf := gl.CreateBuffer()
gl.BindBuffer(gl.ARRAY_BUFFER, buf)
gl.BufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW)

About

Encode to Byte Arrays


Languages

Language:Go 100.0%