Exemplo n.º 1
0
func (w *MultitouchTestBoxWidget) Render() {
	colors := [...]mgl64.Vec3{
		{0 / 255.0, 140 / 255.0, 0 / 255.0},
		{0 / 255.0, 98 / 255.0, 140 / 255.0},
		{194 / 255.0, 74 / 255.0, 0 / 255.0},
		{89 / 255.0, 0 / 255.0, 140 / 255.0},
		{191 / 255.0, 150 / 255.0, 0 / 255.0},
		{140 / 255.0, 0 / 255.0, 0 / 255.0},
	}

	backgroundColor := colors[w.color]

	//borderColor := backgroundColor

	switch 1 {
	case 0:
		DrawBorderlessBox(w.pos, mgl64.Vec2{200, 200}, backgroundColor)
	case 1:
		gl.PushMatrix()
		gl.Translated(w.pos[0], w.pos[1], 0)
		gl.Color3dv(&backgroundColor[0])

		gl.EnableClientState(gl.VERTEX_ARRAY)
		gl.BindBuffer(gl.ARRAY_BUFFER, w.buffer)
		gl.VertexPointer(2, gl.FLOAT, 0, nil)

		gl.DrawArrays(gl.TRIANGLE_FAN, 0, 4)

		gl.PopMatrix()
	}
}
Exemplo n.º 2
0
func (r *Renderer) Render() {
	gl.EnableClientState(gl.VERTEX_ARRAY)

	rVbo := r.Vbos[0]
	gl.BindBuffer(gl.ARRAY_BUFFER, rVbo.Id)

	for _, c := range r.Layer.Flatten() {
		renderable := c.GetRenderable()
		transform := c.GetTransform()

		if renderable == nil || transform == nil || !c.Visible() {
			continue
		}

		if rVbo != renderable.VboPosition.Vbo {
			rVbo = renderable.VboPosition.Vbo
			gl.BindBuffer(gl.ARRAY_BUFFER, rVbo.Id)
		}

		gl.VertexPointer(ValsInVertex, gl.FLOAT, 0, nil)

		if transform.NeedsUpdate {
			transform.Update()
		}

		gl.LoadMatrixf(&(transform.Matrix[0]))
		gl.DrawArrays(gl.QUADS, int32(renderable.VboPosition.Index/ValsInVertex),
			int32(renderable.Length/ValsInVertex))
	}

	gl.DisableClientState(gl.VERTEX_ARRAY)
}
Exemplo n.º 3
0
func (r *Renderer) Render() {
	gl.EnableClientState(gl.VERTEX_ARRAY)

	for _, g := range r.GameObjects {
		gl.BindBuffer(gl.ARRAY_BUFFER, g.VboPosition.Vbo.Id)
		gl.VertexPointer(2, gl.FLOAT, 0, nil)
		gl.DrawArrays(gl.QUADS, 0, int32(4))
	}

	gl.DisableClientState(gl.VERTEX_ARRAY)
}
Exemplo n.º 4
0
Arquivo: gc.go Projeto: stanim/draw2d
func (p *Painter) Flush() {
	if len(p.vertices) != 0 {
		gl.EnableClientState(gl.COLOR_ARRAY)
		gl.EnableClientState(gl.VERTEX_ARRAY)
		gl.ColorPointer(4, gl.UNSIGNED_BYTE, 0, gl.Ptr(p.colors))
		gl.VertexPointer(2, gl.INT, 0, gl.Ptr(p.vertices))

		// draw lines
		gl.DrawArrays(gl.LINES, 0, int32(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]
	}
}
Exemplo n.º 5
0
func List(width, height int, list *draw.List) {
	gl.Enable(gl.BLEND)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	gl.Enable(gl.SCISSOR_TEST)
	defer gl.Disable(gl.SCISSOR_TEST)

	gl.EnableClientState(gl.VERTEX_ARRAY)
	defer gl.DisableClientState(gl.VERTEX_ARRAY)

	gl.EnableClientState(gl.COLOR_ARRAY)
	defer gl.DisableClientState(gl.COLOR_ARRAY)

	gl.EnableClientState(gl.TEXTURE_COORD_ARRAY)
	defer gl.DisableClientState(gl.TEXTURE_COORD_ARRAY)

	gl.VertexPointer(2, gl.FLOAT, vertexStride, unsafe.Pointer(&(list.Vertices[0].P)))
	gl.TexCoordPointer(2, gl.FLOAT, vertexStride, unsafe.Pointer(&(list.Vertices[0].UV)))
	gl.ColorPointer(4, gl.UNSIGNED_BYTE, vertexStride, unsafe.Pointer(&(list.Vertices[0].Color)))

	offset := 0
	for _, cmd := range list.Commands {
		if cmd.Count == 0 {
			continue
		}
		if cmd.Texture == 0 {
			gl.Disable(gl.TEXTURE_2D)
		} else {
			gl.Enable(gl.TEXTURE_2D)
			gl.BindTexture(gl.TEXTURE_2D, uint32(cmd.Texture))
		}

		x, y, w, h := cmd.Clip.AsInt32()
		gl.Scissor(x, int32(height)-y-h, w, h)
		gl.DrawElements(gl.TRIANGLES, int32(cmd.Count), indexType, gl.Ptr(list.Indicies[offset:]))
		offset += int(cmd.Count)
	}
}