示例#1
0
func CreateVOB() {
    Verticies := [...]gl.Float{-0.8f, -0.8f, 0.0f, 1.0f,
                               0.0f,  0.8f, 0.0f, 1.0f,
                               0.8f, -0.8f, 0.0f, 1.0f}

    Colours := [...]gl.Float{1.0f, 0.0f, 0.0f, 1.0f,
                         0.0f, 1.0f, 0.0f, 1.0f,
                         0.0f, 0.0f, 1.0f, 1.0f}

    BufferSize = unsafe.Sizeof(Verticies)
    VertexSize = unsafe.Sizeof(Verticies[0])
    RgbOffset  = unsafe.Sizeof(Verticies[0].XYZW)

    gl.GenVertexArrays(1, &VaoId)
    gl.BindVertexArray(VaoId)

    gl.GenBuffers(1, &VboId)
    gl.BindBuffer(gl.ARRAY_BUFFER, VboId)
    gl.BufferData(gl.ARRAY_BUFFER, unsafe.Sizeof(Verticies), Verticies, gl.STATIC_DRAW)
    gl.VertexAttribPointer(1, 4, gl.Float, gl.FALSE, 0, 0)
    gl.EnableVertexAttribArray(1)

    if err := gl.GetError(); err != gl.NO_ERROR {
    	fmt.Println(err, "ERROR: Could not create a VBO")
    }
}
示例#2
0
func LastErrors(filterBy ...gl.Enum) []gl.Enum {
	var errs []gl.Enum = nil
	var err gl.Enum
	for {
		if err = gl.GetError(); err == 0 {
			break
		} else if (len(filterBy) == 0) || (gltypes.InSliceAt(filterBy, err) >= 0) {
			if errs == nil {
				errs = []gl.Enum{err}
			} else {
				errs = append(errs, err)
			}
		}
	}
	return errs
}