コード例 #1
0
ファイル: graphics.go プロジェクト: rolfrm/boxworld
func DrawAABB(aabb Drawable, t float32, program gl.Program) {
	box := aabb.GetBox3D()
	nverts, normals := GetVerts()
	if box.Animator != nil {
		box.Animator(&box, t)
	}
	drawPos := box.Pos
	drawColor := box.Color
	drawSize := box.Size

	program.GetUniformLocation("SizeVec").Uniform3f(drawSize.X, drawSize.Y, drawSize.Z)
	program.GetUniformLocation("PosVec").Uniform3f(drawPos.X, drawPos.Y, drawPos.Z)
	gl.Color3f(drawColor.X, drawColor.Y, drawColor.Z)
	gl.EnableClientState(gl.VERTEX_ARRAY)
	gl.VertexPointer(3, 0, nverts)
	gl.EnableClientState(gl.NORMAL_ARRAY)
	gl.NormalPointer(0, normals)

	gl.DrawArrays(gl.QUADS, 0, 24)
	gl.DisableClientState(gl.NORMAL_ARRAY)
	gl.DisableClientState(gl.VERTEX_ARRAY)
	for it := aabb.GetChildren(); it != nil; it = it.Next() {
		DrawAABB(it.Value.(Drawable), t, program)
	}
}
コード例 #2
0
ファイル: gc.go プロジェクト: xushiwei/draw2d
func (p *GLPainter) Flush() {
	if len(p.vertices) != 0 {
		gl.EnableClientState(gl.COLOR_ARRAY)
		gl.EnableClientState(gl.VERTEX_ARRAY)
		gl.ColorPointer(4, 0, p.colors)
		gl.VertexPointer(2, 0, p.vertices)

		// draw lines
		gl.DrawArrays(gl.LINES, 0, len(p.vertices)/2)
		gl.DisableClientState(gl.VERTEX_ARRAY)
		gl.DisableClientState(gl.COLOR_ARRAY)
		p.vertices = p.vertices[0:0]
		p.colors = p.colors[0:0]
	}
}
コード例 #3
0
ファイル: ogl_graphics.go プロジェクト: chsc/g3
func (gd *openGLGraphicsDevice) SetVertices(buffer VertexBuffer) {
	glbuffer := buffer.(*openGLVertexBuffer)
	gl.EnableClientState(gl.VERTEX_ARRAY) // TODO: DisableClientState
	gl.VertexPointer(3, 3*4, &glbuffer.vertices3[0].X)
}
コード例 #4
0
ファイル: ogl_graphics.go プロジェクト: chsc/g3
func (gd *openGLGraphicsDevice) SetNormals(buffer VertexBuffer) {
	glbuffer := buffer.(*openGLVertexBuffer)
	gl.EnableClientState(gl.NORMAL_ARRAY) // TODO: DisableClientState
	gl.NormalPointer(3*4, &glbuffer.vertices3[0].X)
}
コード例 #5
0
ファイル: ogl_graphics.go プロジェクト: chsc/g3
func (gd *openGLGraphicsDevice) SetTexCoords(buffer VertexBuffer, index uint) {
	glbuffer := buffer.(*openGLVertexBuffer)
	gl.EnableClientState(gl.TEXTURE_COORD_ARRAY) // TODO: DisableClientState
	gl.TexCoordPointer(2, 3*4, &glbuffer.vertices2[0].X)
}