Example #1
0
File: gl_test.go Project: shogg/gl
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)
}
Example #2
0
File: gl_test.go Project: shogg/gl
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")
	}
}
Example #3
0
File: main.go Project: shogg/glvox
func initGl() {

	h := float64(height) / float64(width)

	gl.ShadeModel(gl.FLAT)

	gl.Viewport(0, 0, width, height)
	gl.MatrixMode(gl.PROJECTION)
	gl.LoadIdentity()
	gl.Frustum(-1.0, 1.0, -h, h, 5.0, 60.0)

	gl.MatrixMode(gl.MODELVIEW)
	gl.LoadIdentity()
	gl.Translatef(0.0, 0.0, -6.0)

	gl.EnableClientState(gl.VERTEX_ARRAY)
	gl.EnableClientState(gl.TEXTURE_COORD_ARRAY)
	gl.VertexPointer(3, gl.FLOAT, 0, vertices)
	gl.TexCoordPointer(2, gl.FLOAT, 0, texCoords)
}