func TestTexImage1D(t *testing.T) { gl.TexImage1D(gl.TEXTURE_1D, 0, gl.RGBA, 16, 0, gl.RGBA, gl.INT, &array) if gl.GetError() != gl.NO_ERROR { t.Error("pointer to array failed") } gl.Enable(gl.TEXTURE_1D) gl.TexImage1D(gl.TEXTURE_1D, 1, gl.RGBA, 16, 1, gl.RGBA, gl.INT, &slice[3]) if gl.GetError() != gl.NO_ERROR { t.Error("pointer to element failed") } gl.TexImage1D(gl.TEXTURE_1D, 0, gl.RGBA, 16, 0, gl.RGBA, gl.INT, slice) if gl.GetError() != gl.NO_ERROR { t.Error("slice failed") } gl.TexImage1D(gl.PROXY_TEXTURE_1D, 0, gl.RGBA, 16, 0, gl.RGBA, gl.INT, nil) if gl.GetError() != gl.NO_ERROR { t.Error("nil pointer failed") } }
func TestBufferSubData(t *testing.T) { buf := newBuffer(16 * 4) defer buf.Delete() gl.BufferSubData(gl.ARRAY_BUFFER, 0, 4*4, &array) if gl.GetError() != gl.NO_ERROR { t.Error("pointer to array failed") } gl.BufferSubData(gl.ARRAY_BUFFER, 0, 4*4, slice) if gl.GetError() != gl.NO_ERROR { t.Error("slice failed") } }
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") } }
func TestAttribPointer(t *testing.T) { prg := newProgram() defer prg.Delete() bar := prg.GetAttribLocation("bar") bar.EnableArray() bar.AttribPointer(1, gl.INT, false, 0, &array) if gl.GetError() != gl.NO_ERROR { t.Error("pointer to array failed") } bar.AttribPointer(1, gl.INT, false, 0, slice) if gl.GetError() != gl.NO_ERROR { t.Error("slice failed") } }
func TestCallLists(t *testing.T) { base := gl.GenLists(2) if base == 0 { t.Error("GenLists failed") } gl.NewList(base+0, gl.COMPILE) gl.Color3i(1, 2, 3) gl.Begin(gl.POLYGON) gl.Vertex2f(1.0, 2.0) gl.Vertex2f(3.0, 4.0) gl.Vertex2f(5.0, 6.0) gl.End() gl.EndList() if gl.GetError() != gl.NO_ERROR { t.Error("NewList 1 failed") } gl.NewList(base+1, gl.COMPILE) gl.Begin(gl.POINTS) gl.Vertex2i(3, 4) gl.End() gl.EndList() if gl.GetError() != gl.NO_ERROR { t.Error("NewList 2 failed") } gl.CallList(base) if gl.GetError() != gl.NO_ERROR { t.Error("CallList 1 failed") } gl.ListBase(base) if gl.GetError() != gl.NO_ERROR { t.Error("ListBase failed") } lists := []uint{0, 1} gl.CallLists(2, gl.UNSIGNED_INT, lists) if gl.GetError() != gl.NO_ERROR { t.Error("CallLists 1 2 failed") } }
func TestBufferData(t *testing.T) { buf := newBuffer(16 * 4) defer buf.Delete() gl.BufferData(gl.ARRAY_BUFFER, 16*4, &array, gl.STATIC_READ) if gl.GetError() != gl.NO_ERROR { t.Error("pointer to array failed") } gl.BufferData(gl.ARRAY_BUFFER, 16*4, slice, gl.STATIC_READ) if gl.GetError() != gl.NO_ERROR { t.Error("slice failed") } gl.BufferData(gl.ARRAY_BUFFER, 16*4, nil, gl.STATIC_READ) if gl.GetError() != gl.NO_ERROR { t.Error("nil pointer failed") } }
func TestUniform1fv(t *testing.T) { prg := newProgram() defer prg.Delete() values := []float32{1.0, 1.1, 1.2, 1.3} foo := prg.GetUniformLocation("foo") foo.Uniform1fv(values) if gl.GetError() != gl.NO_ERROR { t.Error("slice failed") } }
func draw() { t := float32(sdl.GetTicks()) / 500.0 time := prg.GetUniformLocation("time") time.Uniform1f(t) gl.Clear(gl.COLOR_BUFFER_BIT) gl.DrawArrays(gl.TRIANGLE_STRIP, 0, 4) if gl.GetError() != gl.NO_ERROR { panic("draw error") } }
func TestTexImage3D(t *testing.T) { gl.TexImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 2, 2, 2, 0, gl.RGBA, gl.INT, &array) if gl.GetError() != gl.NO_ERROR { t.Error("pointer to array failed") } gl.TexImage3D(gl.TEXTURE_3D, 0, gl.RGBA, 2, 2, 2, 0, gl.RGBA, gl.INT, slice) if gl.GetError() != gl.NO_ERROR { t.Error("slice failed") } gl.TexImage3D(gl.PROXY_TEXTURE_3D, 0, gl.RGBA, 2, 2, 2, 0, gl.RGBA, gl.INT, nil) if gl.GetError() != gl.NO_ERROR { t.Error("nil pointer failed") } }
func TestVertexPointer(t *testing.T) { gl.EnableClientState(gl.VERTEX_ARRAY) gl.VertexPointer(3, gl.INT, 0, &array) if gl.GetError() != gl.NO_ERROR { t.Error("pointer to array failed") } gl.VertexPointer(3, gl.INT, 0, slice) if gl.GetError() != gl.NO_ERROR { t.Error("slice failed") } gl.DisableClientState(gl.VERTEX_ARRAY) buf := newBuffer(16 * 4) defer buf.Delete() gl.VertexPointer(3, gl.INT, 0, uintptr(0)) if gl.GetError() != gl.NO_ERROR { t.Error("buffer offset failed") } }
func TestDrawElements(t *testing.T) { gl.EnableClientState(gl.VERTEX_ARRAY) gl.VertexPointer(2, gl.INT, 0, slice) indices := []uint32{0, 1, 2, 3} gl.DrawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_INT, indices) if gl.GetError() != gl.NO_ERROR { t.Error("slice failed") } gl.DisableClientState(gl.VERTEX_ARRAY) }
func TestGetBufferSubData(t *testing.T) { buf := newBuffer(16 * 4) defer buf.Delete() result := make([]int32, 4) gl.GetBufferSubData(gl.ARRAY_BUFFER, 7*4, 4*4, result) if gl.GetError() != gl.NO_ERROR { t.Error("slice failed") } if result[0] != 8 { t.Error("[8, 9, 10, 11] expected, was", result) } }
func TestTexSubImage3D(t *testing.T) { gl.TexSubImage3D(gl.TEXTURE_3D, 0, 1, 1, 1, 1, 1, 1, gl.RGBA, gl.INT, &array) if gl.GetError() != gl.NO_ERROR { t.Error("pointer to failed") } gl.TexSubImage3D(gl.TEXTURE_3D, 0, 1, 1, 1, 1, 1, 1, gl.RGBA, gl.INT, slice) if gl.GetError() != gl.NO_ERROR { t.Error("slice failed") } // gl.TexSubImage3D(gl.PROXY_TEXTURE_3D, // 0, 1, 1, 1, 1, 1, 1, gl.RGBA, gl.INT, // nil) // if gl.GetError() != gl.NO_ERROR { // t.Error("nil pointer failed") // } }
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) } }