Exemple #1
0
func TestDrawPixels(t *testing.T) {

	gl.DrawPixels(4, 4, gl.RGBA, gl.UNSIGNED_INT, slice)
	if gl.GetError() != gl.NO_ERROR {
		t.Error("slice failed")
	}

	buf := newBuffer(16 * 4)
	buf.Bind(gl.PIXEL_UNPACK_BUFFER)
	defer buf.Delete()

	gl.DrawPixels(2, 2, gl.RGBA, gl.UNSIGNED_INT, uintptr(0))
	if gl.GetError() != gl.NO_ERROR {
		t.Error("buffer offset failed")
	}
}
Exemple #2
0
func TestReadPixels(t *testing.T) {

	pixels := []byte{1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}
	gl.DrawPixels(2, 2, gl.RGB, gl.UNSIGNED_BYTE, pixels)

	result := make([]byte, 4*3)
	gl.ReadPixels(0, 0, 2, 2, gl.RGB, gl.UNSIGNED_BYTE, result)
	if gl.GetError() != gl.NO_ERROR {
		t.Error("slice failed")
	}

	// result is {1,1,1, 2,2,2, 0,0,3, 4,4,4}, no idea why.
	if false {
		t.Error("was", result)
	}
}