func drawRoom(room *Room) {
	h := float64(room.Box.GetAsBox().Height)
	w := float64(room.Box.GetAsBox().Width)
	x1 := float64(0 - w*0.5)
	y1 := float64(0 - h*0.5)
	x2 := float64(0 + w*0.5)
	y2 := float64(0 - h*0.5)
	x3 := float64(0 + w*0.5)
	y3 := float64(0 + h*0.5)
	x4 := float64(0 - w*0.5)
	y4 := float64(0 + h*0.5)

	gl.Begin(gl.POLYGON)
	gl.Color4f(
		room.Color.X(),
		room.Color.Y(),
		room.Color.Z(),
		room.Color.W(),
	)
	gl.Vertex2d(x1, y1)
	gl.Vertex2d(x2, y2)
	gl.Vertex2d(x3, y3)
	gl.Vertex2d(x4, y4)
	gl.End()
	gl.Begin(gl.LINE_LOOP)
	gl.Color4f(.3, .3, 1, .9)
	gl.LineWidth(1.0)
	gl.Vertex2d(x1, y1)
	gl.Vertex2d(x2, y2)
	gl.Vertex2d(x3, y3)
	gl.Vertex2d(x4, y4)
	gl.End()
}
示例#2
0
文件: main.go 项目: joonazan/go-opas
func piirrä(aika float64) {

	gl.Begin(gl.LINES)

	gl.Color3d(1, 1, 1)
	gl.Vertex2d(0, 0)
	gl.Color3d(0, 0, 0)
	gl.Vertex2d(0.5, 0)

	gl.Color3d(1, 0, 0)
	gl.Vertex2d(0, 0)
	gl.Vertex2d(0, 0.5)

	gl.End()
}
示例#3
0
// drawCircle draws a circle for the specified radius, rotation angle, and the specified number of sides
func drawCircle(radius float64, sides int) {
	gl.Begin(gl.LINE_LOOP)
	for a := 0.0; a < 2*math.Pi; a += (2 * math.Pi / float64(sides)) {
		gl.Vertex2d(math.Sin(a)*radius, math.Cos(a)*radius)
	}
	gl.Vertex3f(0, 0, 0)
	gl.End()
}
示例#4
0
// drawCircle draws a circle for the specified radius, rotation angle, and the specified number of sides
func drawCircle(radius float64, sides int) {
	gl.Begin(gl.TRIANGLE_FAN)
	for a := 0.0; a < 2*math.Pi; a += (2 * math.Pi / float64(70)) {
		gl.Vertex2d(math.Sin(a)*radius, math.Cos(a)*radius)
	}
	gl.Vertex3f(0, 0, 0)
	gl.End()

}
示例#5
0
文件: main.go 项目: rexposadas/gx
func (this *Pointer) Render() {
	switch {
	case this.VirtualCategory == POINTING && len(this.State.Axes) >= 2:
		// Prevent pointer from being drawn when the OS mouse pointer is visible.
		{
			// HACK
			var windowSize [2]int
			if globalWindow != nil {
				windowSize[0], windowSize[1] = globalWindow.GetSize()
			}

			// HACK: OS X specific.
			const border = 3
			if this.State.Axes[1] < 0 || this.State.Axes[0] < border || this.State.Axes[0] >= float64(windowSize[0])-border || this.State.Axes[1] >= float64(windowSize[1])-border {
				break
			}
		}

		gl.PushMatrix()
		defer gl.PopMatrix()
		gl.Translated(float64(NearInt64(this.State.Axes[0]))+0.5, float64(NearInt64(this.State.Axes[1]))+0.5, 0)

		const size float64 = 12 * 40 / 40
		gl.Color3d(1, 1, 1)
		gl.Begin(gl.TRIANGLE_FAN)
		gl.Vertex2d(0, 0)
		gl.Vertex2d(0, size)
		gl.Vertex2d(size*0.85*math.Sin(math.Pi/8), size*0.85*math.Cos(math.Pi/8))
		gl.Vertex2d(size/math.Sqrt2, size/math.Sqrt2)
		gl.End()

		gl.Begin(gl.LINE_LOOP)
		gl.Color3d(0, 0, 0)
		gl.Vertex2d(0, 0)
		gl.Vertex2d(0, size)
		gl.Color3d(0.75, 0.75, 0.75)
		gl.Vertex2d(size*0.85*math.Sin(math.Pi/8), size*0.85*math.Cos(math.Pi/8))
		gl.Color3d(0, 0, 0)
		gl.Vertex2d(size/math.Sqrt2, size/math.Sqrt2)
		gl.End()
	}
}
示例#6
0
func InitFont() {
	LoadTexture(filepath.FromSlash("/Users/Dmitri/Dropbox/Work/2015/Bitmap Fonts/Helvetica Neue.png"))

	oFontBase = gl.GenLists(32 + 96)
	for i := 0; i < 96; i++ {
		const shiftY = float64(1.0 / 6)

		indexX, indexY := i%16, i/16

		charWidth := shiftXs[indexY][indexX+1] - shiftXs[indexY][indexX]

		gl.NewList(oFontBase+uint32(i+32), gl.COMPILE)
		gl.Begin(gl.QUADS)
		gl.TexCoord2d(shiftXs[indexY][indexX], float64(indexY)*shiftY)
		gl.Vertex2d(0, 0)
		gl.TexCoord2d(shiftXs[indexY][indexX+1], float64(indexY)*shiftY)
		gl.Vertex2d(fontWidth*charWidth/float64(1.0/16), 0)
		gl.TexCoord2d(shiftXs[indexY][indexX+1], float64(indexY+1)*shiftY)
		gl.Vertex2d(fontWidth*charWidth/float64(1.0/16), fontHeight)
		gl.TexCoord2d(shiftXs[indexY][indexX], float64(indexY+1)*shiftY)
		gl.Vertex2d(0, fontHeight)
		gl.End()
		gl.Translated(fontWidth*charWidth/float64(1.0/16), 0.0, 0.0)
		gl.EndList()
	}

	oFontBackground = gl.GenLists(1)
	gl.NewList(oFontBackground, gl.COMPILE)
	gl.Begin(gl.QUADS)
	gl.Vertex2d(0, 0)
	gl.Vertex2d(0, fontHeight)
	gl.Vertex2d(fontWidth, fontHeight)
	gl.Vertex2d(fontWidth, 0)
	gl.End()
	gl.Translated(fontWidth, 0.0, 0.0)
	gl.EndList()

	CheckGLError()
}
示例#7
0
文件: main.go 项目: joonazan/go-opas
func piirrä(aika float64) {

	const pisteitä = 200

	gl.Begin(gl.LINE_STRIP)

	gl.Color3d(
		nollastaYhteen(aika*10),
		nollastaYhteen(aika*7),
		nollastaYhteen(aika*3),
	)

	for i := 0.0; i < pisteitä; i++ {

		x := i / (pisteitä - 1)

		gl.Vertex2d(x*2-1, 0.8*math.Sin(x*8+aika))
	}

	gl.End()
}
示例#8
0
文件: main.go 项目: rexposadas/gx
func drawInnerSlicedBox(pos, size mgl64.Vec2, borderColor, backgroundColor mgl64.Vec3) {
	if size[0] == 0 || size[1] == 0 {
		return
	}

	const OuterDistance = 2.5
	gl.Begin(gl.POLYGON)
	gl.Color3dv((*float64)(&borderColor[0]))
	gl.Vertex2d(float64(pos[0]+OuterDistance), float64(pos[1]))
	gl.Vertex2d(float64(pos[0]), float64(pos[1]+OuterDistance))
	gl.Vertex2d(float64(pos[0]), float64(pos[1]-OuterDistance+size[1]))
	gl.Vertex2d(float64(pos[0]+OuterDistance), float64(pos[1]+size[1]))
	gl.Vertex2d(float64(pos[0]-OuterDistance+size[0]), float64(pos[1]+size[1]))
	gl.Vertex2d(float64(pos[0]+size[0]), float64(pos[1]-OuterDistance+size[1]))
	gl.Vertex2d(float64(pos[0]+size[0]), float64(pos[1]+OuterDistance))
	gl.Vertex2d(float64(pos[0]-OuterDistance+size[0]), float64(pos[1]))
	gl.End()

	const InnerDistance = OuterDistance + (math.Sqrt2 - 1)
	gl.Begin(gl.POLYGON)
	gl.Color3dv((*float64)(&backgroundColor[0]))
	gl.Vertex2d(float64(pos[0]+InnerDistance), float64(pos[1]+1))
	gl.Vertex2d(float64(pos[0]+1), float64(pos[1]+InnerDistance))
	gl.Vertex2d(float64(pos[0]+1), float64(pos[1]-InnerDistance+size[1]))
	gl.Vertex2d(float64(pos[0]+InnerDistance), float64(pos[1]-1+size[1]))
	gl.Vertex2d(float64(pos[0]-InnerDistance+size[0]), float64(pos[1]-1+size[1]))
	gl.Vertex2d(float64(pos[0]-1+size[0]), float64(pos[1]-InnerDistance+size[1]))
	gl.Vertex2d(float64(pos[0]-1+size[0]), float64(pos[1]+InnerDistance))
	gl.Vertex2d(float64(pos[0]-InnerDistance+size[0]), float64(pos[1]+1))
	gl.End()
}
示例#9
0
文件: main.go 项目: rexposadas/gx
func drawInnerRoundedBox(pos, size mgl64.Vec2, borderColor, backgroundColor mgl64.Vec3) {
	if size[0] == 0 || size[1] == 0 {
		return
	}

	const totalSlices = 4 * 16
	const borderWidth = 1
	const radius = 2.5 + borderWidth
	var x = float64(totalSlices)

	gl.Color3dv((*float64)(&backgroundColor[0]))
	gl.Begin(gl.TRIANGLE_STRIP)
	for i := 0; i <= totalSlices/4; i++ {
		gl.Vertex2d(pos[0]+size[0]-radius+math.Sin(Tau*float64(i)/x)*(radius-borderWidth), pos[1]+radius-math.Cos(Tau*float64(i)/x)*(radius-borderWidth))
		gl.Vertex2d(pos[0]+radius+math.Sin(Tau*float64(totalSlices-i)/x)*(radius-borderWidth), pos[1]+radius-math.Cos(Tau*float64(totalSlices-i)/x)*(radius-borderWidth))
	}
	for i := totalSlices / 4; i <= totalSlices/2; i++ {
		gl.Vertex2d(pos[0]+size[0]-radius+math.Sin(Tau*float64(i)/x)*(radius-borderWidth), pos[1]+size[1]-radius-math.Cos(Tau*float64(i)/x)*(radius-borderWidth))
		gl.Vertex2d(pos[0]+radius+math.Sin(Tau*float64(totalSlices-i)/x)*(radius-borderWidth), pos[1]+size[1]-radius-math.Cos(Tau*float64(totalSlices-i)/x)*(radius-borderWidth))
	}
	gl.End()

	gl.Color3dv((*float64)(&borderColor[0]))
	gl.Begin(gl.TRIANGLE_STRIP)
	gl.Vertex2d(pos[0]+radius, pos[1])
	gl.Vertex2d(pos[0]+radius, pos[1]+borderWidth)
	for i := 0; i <= totalSlices/4; i++ {
		gl.Vertex2d(pos[0]+size[0]-radius+math.Sin(Tau*float64(i)/x)*radius, pos[1]+radius-math.Cos(Tau*float64(i)/x)*radius)
		gl.Vertex2d(pos[0]+size[0]-radius+math.Sin(Tau*float64(i)/x)*(radius-borderWidth), pos[1]+radius-math.Cos(Tau*float64(i)/x)*(radius-borderWidth))
	}
	for i := totalSlices / 4; i <= totalSlices/2; i++ {
		gl.Vertex2d(pos[0]+size[0]-radius+math.Sin(Tau*float64(i)/x)*radius, pos[1]+size[1]-radius-math.Cos(Tau*float64(i)/x)*radius)
		gl.Vertex2d(pos[0]+size[0]-radius+math.Sin(Tau*float64(i)/x)*(radius-borderWidth), pos[1]+size[1]-radius-math.Cos(Tau*float64(i)/x)*(radius-borderWidth))
	}
	for i := totalSlices / 2; i <= totalSlices*3/4; i++ {
		gl.Vertex2d(pos[0]+radius+math.Sin(Tau*float64(i)/x)*radius, pos[1]+size[1]-radius-math.Cos(Tau*float64(i)/x)*radius)
		gl.Vertex2d(pos[0]+radius+math.Sin(Tau*float64(i)/x)*(radius-borderWidth), pos[1]+size[1]-radius-math.Cos(Tau*float64(i)/x)*(radius-borderWidth))
	}
	for i := totalSlices * 3 / 4; i <= totalSlices; i++ {
		gl.Vertex2d(pos[0]+radius+math.Sin(Tau*float64(i)/x)*radius, pos[1]+radius-math.Cos(Tau*float64(i)/x)*radius)
		gl.Vertex2d(pos[0]+radius+math.Sin(Tau*float64(i)/x)*(radius-borderWidth), pos[1]+radius-math.Cos(Tau*float64(i)/x)*(radius-borderWidth))
	}
	gl.End()
}
示例#10
0
func piirräPiste(v vec2.Vector) {
	gl.Vertex2d(v.X, v.Y)
}