Exemplo n.º 1
0
func (self *Pause) Draw(t int64) {
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	gl.LoadIdentity()

	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.Disable(gl.LIGHT1)

	gl.Color4ub(0, 0, 0, 240)

	gl.Begin(gl.QUADS)
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.tplane))
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.tplane))
	gl.End()

	str := "paused"
	h, w := pauseFont.Measure(str)

	// x := (viewport.rplane - viewport.lplane - w) / 2
	// y := (viewport.tplane - viewport.bplane - h) / 2
	gl.Translated(-w/2, -h/2, 0)
	pauseFont.Print(str)

	gl.PopMatrix()

}
Exemplo n.º 2
0
func (self *Picker) Draw(t int64) {

	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()

	gl.LoadIdentity()

	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.Disable(gl.LIGHT1)

	gl.Begin(gl.TRIANGLE_FAN)
	gl.Color4ub(0, 0, 0, 128)
	gl.Vertex2f(self.x, self.y)
	for angle := float64(0); angle <= 2*math.Pi; angle += math.Pi / 2 / 10 {
		gl.Vertex2f(self.x-float32(math.Sin(angle))*self.radius, self.y+float32(math.Cos(angle))*self.radius)
	}
	gl.End()

	self.DrawItemHighlight(t, ThePlayer.currentAction)
	self.DrawPlayerItems(t, true)

	gl.PopMatrix()

}
Exemplo n.º 3
0
func (self *Console) Draw(t int64) {
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	gl.LoadIdentity()

	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.Disable(gl.LIGHT1)

	h := float32(consoleFont.height) * PIXEL_SCALE
	margin := float32(3.0) * PIXEL_SCALE
	consoleHeight := 3 * h

	gl.MatrixMode(gl.MODELVIEW)

	gl.LoadIdentity()
	gl.Color4ub(0, 0, 0, 208)

	gl.Begin(gl.QUADS)
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane)+consoleHeight+margin*2) // Bottom Left Of The Texture and Quad
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane)+consoleHeight+margin*2) // Bottom Right Of The Texture and Quad
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))                        // Top Right Of The Texture and Quad
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))                        // Top Left Of The Texture and Quad
	gl.End()

	gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-h, 0)
	consoleFont.Print(fmt.Sprintf("FPS: %5.2f V: %d (%d) CH: %d M: %d", self.fps, self.vertices, self.culledVertices, len(TheWorld.chunks), len(TheWorld.mobs)))
	gl.LoadIdentity()
	gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-2*h, 0)

	consoleFont.Print(fmt.Sprintf("X: %5.2f Y: %4.2f Z: %5.2f H: %5.2f (%s) D: %0.1f (%d)", ThePlayer.position[XAXIS], ThePlayer.position[YAXIS], ThePlayer.position[ZAXIS], ThePlayer.heading, HeadingToCompass(ThePlayer.heading), ThePlayer.distanceTravelled, ThePlayer.distanceFromStart))

	gl.LoadIdentity()
	gl.Translatef(float32(viewport.lplane)+margin, float32(viewport.bplane)+consoleHeight+margin-3*h, 0)

	numgc := uint32(0)
	avggc := float64(0)
	var last3 [3]float64
	if self.mem.NumGC > 3 {
		numgc = self.mem.NumGC
		avggc = float64(self.mem.PauseTotalNs) / float64(self.mem.NumGC) / 1e6
		index := int(numgc) - 1
		if index > 255 {
			index = 255
		}

		last3[0] = float64(self.mem.PauseNs[index]) / 1e6
		last3[1] = float64(self.mem.PauseNs[index-1]) / 1e6
		last3[2] = float64(self.mem.PauseNs[index-2]) / 1e6
	}

	consoleFont.Print(fmt.Sprintf("Mem: %.1f/%.1f   GC: %.1fms [%d: %.1f, %.1f, %.1f] ChGen: %.1fms | Sc: %.1f TOD: %.1f", float64(self.mem.Alloc)/(1024*1024), float64(self.mem.Sys)/(1024*1024), avggc, numgc, last3[0], last3[1], last3[2], float64(self.chunkGenerationTime)/1e6, viewport.scale, timeOfDay))

	gl.PopMatrix()
}
Exemplo n.º 4
0
func drawShip(angle float32) {
	gl.PushMatrix()
	gl.Translatef(x, y, 0.0)
	gl.Rotatef(angle, 0.0, 0.0, 1.0)
	if thrust {
		gl.Color3f(1.0, 0.0, 0.0)
		gl.Begin(gl.LINE_STRIP)
		gl.Vertex2f(-0.75, -0.5)
		gl.Vertex2f(-1.75, 0)
		gl.Vertex2f(-0.75, 0.5)
		gl.End()
	}
	gl.Color3f(1.0, 1.0, 0.0)
	gl.Begin(gl.LINE_LOOP)
	gl.Vertex2f(2.0, 0.0)
	gl.Vertex2f(-1.0, -1.0)
	gl.Vertex2f(-0.5, 0.0)
	gl.Vertex2f(-1.0, 1.0)
	gl.Vertex2f(2.0, 0.0)
	gl.End()
	if shield {
		gl.Color3f(0.1, 0.1, 1.0)
		gl.Begin(gl.LINE_LOOP)
		for rad := 0.0; rad < 12.0; rad += 1.0 {
			gl.Vertex2f(
				float32(2.3*math.Cos(2*float64(rad)/math.Pi)+0.2),
				float32(2.0*math.Sin(2*float64(rad)/math.Pi)))
		}
		gl.End()
	}
	gl.PopMatrix()
}
Exemplo n.º 5
0
func renderTile(x, y float32, tex *gl.Texture) {
	tex.Bind(gl.TEXTURE_2D)
	gl.Begin(gl.QUADS)
	gl.TexCoord2f(0, 0)
	gl.Vertex2f(x, y)
	gl.TexCoord2f(1, 0)
	gl.Vertex2f(x+1, y)
	gl.TexCoord2f(1, 1)
	gl.Vertex2f(x+1, y+1)
	gl.TexCoord2f(0, 1)
	gl.Vertex2f(x, y+1)
	gl.End()
}
Exemplo n.º 6
0
func (self *Picker) DrawItemHighlight(t int64, position Action) {
	gl.PushMatrix()
	gl.LoadIdentity()

	actionItemAngle := -(float64(position) - 1.5) * math.Pi / 4
	gl.Begin(gl.TRIANGLE_FAN)
	gl.Color4ub(64, 64, 64, 228)
	gl.Vertex2f(self.x-self.actionItemRadius*float32(math.Sin(actionItemAngle)), self.y+self.actionItemRadius*float32(math.Cos(actionItemAngle)))
	for angle := float64(0); angle <= 2*math.Pi; angle += math.Pi / 2 / 10 {
		gl.Vertex2f(self.x-self.actionItemRadius*float32(math.Sin(actionItemAngle))-float32(math.Sin(angle))*self.selectionRadius, self.y+self.actionItemRadius*float32(math.Cos(actionItemAngle))+float32(math.Cos(angle))*self.selectionRadius)
	}
	gl.End()
	gl.PopMatrix()
}
Exemplo n.º 7
0
func drawBullets() {
	gl.Begin(gl.POINTS)
	gl.Color3f(1.0, 0.0, 1.0)
	for i := 0; i < MAX_BULLETS; i++ {
		if bullet[i].inuse {
			gl.Vertex2f(bullet[i].x, bullet[i].y)
		}
	}
	gl.End()
}
Exemplo n.º 8
0
func (self *Font) Print(str string) {
	for _, ch := range str {
		self.textures[ch].Bind(gl.TEXTURE_2D)
		h := float32(self.height) * PIXEL_SCALE
		w := float32(self.widths[ch]) * PIXEL_SCALE
		gl.Color4ub(255, 255, 255, 255)
		gl.Begin(gl.QUADS)
		gl.TexCoord2d(0, 0)
		gl.Vertex2f(0, 0) // Bottom Left Of The Texture and Quad
		gl.TexCoord2d(1, 0)
		gl.Vertex2f(w, 0) // Bottom Right Of The Texture and Quad
		gl.TexCoord2d(1, 1)
		gl.Vertex2f(w, h) // Top Right Of The Texture and Quad
		gl.TexCoord2d(0, 1)
		gl.Vertex2f(0, h) // Top Left Of The Texture and Quad
		gl.End()
		gl.Translatef(w, 0, 0)
		self.textures[ch].Unbind(gl.TEXTURE_2D)
	}
}
Exemplo n.º 9
0
func (self *Inventory) Draw(t int64) {
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	gl.LoadIdentity()

	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.Disable(gl.LIGHT1)

	gl.Color4ub(0, 0, 0, 208)

	gl.Begin(gl.QUADS)
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.tplane))
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.tplane))
	gl.End()

	picker.DrawItemHighlight(t, 3)
	picker.DrawItemHighlight(t, 4)
	picker.DrawItemHighlight(t, 5)
	picker.DrawItemHighlight(t, 6)
	picker.DrawItemHighlight(t, 7)
	picker.DrawPlayerItems(t)

	const blocksize = float64(0.3)
	const COLSIZE = 12

	diam := blocksize * 2.4

	offset := diam + float64(4)*PIXEL_SCALE

	for i := range self.inventoryRects {
		x := float64(viewport.lplane) + float64(10)*PIXEL_SCALE + float64(i/COLSIZE)*offset
		y := float64(viewport.tplane) - float64(10)*PIXEL_SCALE - float64(i%COLSIZE)*offset
		self.inventoryRects[i] = Rect{x, y - diam, diam, diam}
		self.DrawItemSlot(t, self.inventoryRects[i])
	}

	slot := 0
	for i := 1; i < len(ThePlayer.inventory); i++ {
		if ThePlayer.inventory[i] > 0 {
			self.inventorySlots[slot] = uint16(i)
			self.DrawItem(t, ThePlayer.inventory[i], uint16(i), self.inventoryRects[slot])
			slot++
		}
	}

	for i := range self.componentSlots {
		x := float64(viewport.lplane) + offset*float64(2+len(self.inventoryRects)/COLSIZE) + float64(i)*offset
		y := float64(viewport.tplane) - (10.0 * PIXEL_SCALE)
		self.componentRects[i] = Rect{x, y - diam, diam, diam}

		self.DrawItemSlot(t, self.componentRects[i])
	}

	for i, cs := range self.componentSlots {
		if cs != 0 {
			self.DrawItem(t, ThePlayer.inventory[cs], cs, self.componentRects[i])
		}
	}

	for i := range self.productSlots {
		x := float64(viewport.lplane) + offset*float64(2+len(self.inventoryRects)/COLSIZE) + offset*float64(i%len(self.componentRects))
		y := float64(viewport.tplane) - (10.0 * PIXEL_SCALE) - offset*float64(2+float64(i/len(self.componentRects)))
		self.productRects[i] = Rect{x, y - diam, diam, diam}

		self.DrawItemSlot(t, self.productRects[i])
	}

	for i, ps := range self.productSlots {
		if ps != nil {
			self.DrawItem(t, ps.product.quantity, ps.product.item, self.productRects[i])
		}
	}

	if self.currentContainer != nil {

		for i := range self.containerRects {
			x := float64(viewport.lplane) + offset*float64(2+len(self.inventoryRects)/COLSIZE) + float64(i)*offset
			y := float64(viewport.tplane) - (10.0 * PIXEL_SCALE) - offset*float64(2+float64(len(self.productRects)/len(self.componentRects))) - offset*float64(2+float64(i/len(self.componentRects)))
			self.containerRects[i] = Rect{x, y - diam, diam, diam}

			self.DrawItemSlot(t, self.containerRects[i])
		}

		for i := uint16(0); i < self.currentContainer.Slots(); i++ {
			item := self.currentContainer.Item(i)
			if item != nil {
				self.DrawItem(t, item.quantity, item.item, self.containerRects[i])
			}
		}

		gl.PushMatrix()
		gl.LoadIdentity()
		gl.Translated(self.containerRects[0].x, self.containerRects[0].y+diam, 0)
		inventoryItemFont.Print(self.currentContainer.Label())
		gl.PopMatrix()

	}

	var mousex, mousey int
	mousestate := sdl.GetMouseState(&mousex, &mousey)
	self.HandleMouse(mousex, mousey, mousestate)

	gl.PopMatrix()
}
Exemplo n.º 10
0
func (s *Sim) Draw() {

	//start := time.Now()

	// Init OpenGL
	gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

	gl.Enable(gl.BLEND)
	gl.Enable(gl.POINT_SMOOTH)
	gl.Enable(gl.LINE_SMOOTH)
	gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)

	gl.Begin(gl.POINTS)

	gl.PointSize(1)
	for x := int(0); x < int(300); x += 1 {
		for y := int(0); y < int(300); y += 1 {
			pot := s.potential(s.units[0], float64(x), float64(y))

			//r := math.Min(pot*2, 1)
			//g := math.Min(pot*2, 2)-1
			gl.Color4f(1-float32(pot), 1-float32(pot), 1-float32(pot), 1)
			gl.Vertex2i(x, y)
		}
	}

	gl.End()

	// Draw Units
	gl.Begin(gl.POINTS)
	for i, unit := range s.units {
		if i == 0 {
			gl.Color4f(1, 0, 0, 1)
			fmt.Println(unit.pos.X)
		} else {
			gl.Color4f(0, 1, 0, 1)
		}

		gl.Vertex2f(float32(unit.pos.X), float32(unit.pos.Y))
	}
	gl.End()

	// Nav mesh
	/*
		for e := s.nav.nodes.Front(); e != nil; e = e.Next() {
			nn := e.Value.(*NavNode)

			gl.Color4f(0, 0, 1, 0.2)

			if s.markedNodes[nn] {
				gl.Color4f(1, 0, 0, 0.2)
			}

			gl.Begin(gl.POLYGON)
			for _, pos := range nn.node.Points {
				if pos == nil {
					continue
				}

				gl.Vertex2f(float32(pos.X), float32(pos.Y))
			}
			gl.End()

			gl.Color4f(0, 0, 1, 1)
			gl.Begin(gl.LINE_LOOP)
			for _, pos := range nn.node.Points {
				if pos == nil {
					continue
				}

				gl.Vertex2f(float32(pos.X), float32(pos.Y))
			}
			gl.End()
		}
	*/
	// Draw Path
	if s.units[0].path != nil {
		gl.Begin(gl.LINE_STRIP)
		gl.Color4f(1, 0, 0, 0.2)
		for e := s.units[0].path.Front(); e != nil; e = e.Next() {
			pos := e.Value.(*geo.Vec)
			gl.Vertex2f(float32(pos.X), float32(pos.Y))
		}
		gl.End()
	}

	// Draw Links
	/*gl.Color4f(1, 0, 0, 1)
	gl.Begin(gl.LINES)
	for i, link := range nn.links {
		pt1 := nn.node.Points[i]
		pt2 := nn.node.Points[(i+1)%nn.node.Len()]
		lineCenter := &geo.Vec{(pt1.X+pt2.X)/2, (pt1.Y+pt2.Y)/2}

		center := link.node.Center()

		gl.Vertex2d(lineCenter.X, lineCenter.Y)
		gl.Vertex2d(center.X, center.Y)
	}
	gl.End()*/

	/*
		fps := 1/(float64(time.Since(start))/float64(time.Second))
		s.ui.fpsLabel2.SetLabel(fmt.Sprintf("%f", fps))
	*/
}
Exemplo n.º 11
0
func (self *Inventory) Draw(t int64) {
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	gl.LoadIdentity()

	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.Disable(gl.LIGHT1)

	gl.Color4ub(0, 0, 0, 240)

	gl.Begin(gl.QUADS)
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.tplane))
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.tplane))
	gl.End()

	picker.DrawItemHighlight(t, 3)
	picker.DrawItemHighlight(t, 4)
	picker.DrawItemHighlight(t, 5)
	picker.DrawItemHighlight(t, 6)
	picker.DrawItemHighlight(t, 7)
	picker.DrawPlayerItems(t)

	const blocksize = float64(0.3)
	const COLSIZE = 12

	diam := blocksize * 2.4

	offset := diam + float64(4)*PIXEL_SCALE

	for i := 0; i < len(self.inventoryRects); i++ {
		x := float64(viewport.lplane) + float64(10)*PIXEL_SCALE + float64(i/COLSIZE)*offset
		y := float64(viewport.tplane) - float64(10)*PIXEL_SCALE - float64(i%COLSIZE)*offset
		self.inventoryRects[i] = Rect{x, y - diam, diam, diam}
		self.DrawItemSlot(t, self.inventoryRects[i])
	}

	slot := 0
	for i := 1; i < len(ThePlayer.inventory); i++ {
		if ThePlayer.inventory[i] > 0 {
			self.inventorySlots[slot] = uint16(i)
			self.DrawItem(t, ThePlayer.inventory[i], uint16(i), self.inventoryRects[slot])
			slot++
		}
	}

	for i := 0; i < len(self.componentSlots); i++ {
		x := float64(viewport.lplane) + offset*float64(2+len(self.inventoryRects)/COLSIZE) + float64(i)*offset
		y := float64(viewport.tplane) - (float64(10) * PIXEL_SCALE)
		self.componentRects[i] = Rect{x, y - diam, diam, diam}

		self.DrawItemSlot(t, self.componentRects[i])
	}

	for i := 0; i < len(self.componentSlots); i++ {
		if self.componentSlots[i] != 0 {
			self.DrawItem(t, ThePlayer.inventory[self.componentSlots[i]], self.componentSlots[i], self.componentRects[i])
		}
	}

	for i := 0; i < len(self.productSlots); i++ {
		x := float64(viewport.lplane) + offset*float64(2+len(self.inventoryRects)/COLSIZE) + offset*float64(i%len(self.componentRects))
		y := float64(viewport.tplane) - (float64(10) * PIXEL_SCALE) - offset*float64(2+float64(i/len(self.componentRects)))
		self.productRects[i] = Rect{x, y - diam, diam, diam}

		self.DrawItemSlot(t, self.productRects[i])
	}

	for i := 0; i < len(self.productSlots); i++ {
		if self.productSlots[i] != nil {
			self.DrawItem(t, self.productSlots[i].product.quantity, self.productSlots[i].product.item, self.productRects[i])
		}
	}

	var mousex, mousey int
	mousestate := sdl.GetMouseState(&mousex, &mousey)
	self.HandleMouse(mousex, mousey, mousestate)

	gl.PopMatrix()
}
Exemplo n.º 12
0
func (self *Inventory) Draw(t int64) {
	gl.MatrixMode(gl.MODELVIEW)
	gl.PushMatrix()
	gl.LoadIdentity()

	gl.Disable(gl.DEPTH_TEST)
	gl.Disable(gl.LIGHTING)
	gl.Disable(gl.LIGHT0)
	gl.Disable(gl.LIGHT1)

	gl.Color4ub(0, 0, 0, 208)

	gl.Begin(gl.QUADS)
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.bplane))
	gl.Vertex2f(float32(viewport.rplane), float32(viewport.tplane))
	gl.Vertex2f(float32(viewport.lplane), float32(viewport.tplane))
	gl.End()

	picker.DrawItemHighlight(t, 3)
	picker.DrawItemHighlight(t, 4)
	picker.DrawItemHighlight(t, 5)
	picker.DrawItemHighlight(t, 6)
	picker.DrawItemHighlight(t, 7)
	picker.DrawPlayerItems(t, false)

	const blocksize = float64(0.3)
	const COLSIZE = 12

	slotsize := blocksize * 2.4
	slotstep := slotsize + float64(4)*PIXEL_SCALE
	slotsInRow := len(self.componentRects)

	xtools := float64(viewport.lplane) + 10.0*PIXEL_SCALE
	ytools := float64(viewport.tplane) - 10.0*PIXEL_SCALE - slotstep

	gl.PushMatrix()
	gl.LoadIdentity()
	gl.Translated(xtools, ytools+4*PIXEL_SCALE, 0)
	inventoryItemFont.Print("Inventory")
	gl.PopMatrix()
	for i := range self.inventoryRects {
		x := xtools + float64(i%slotsInRow)*slotstep
		y := ytools - float64(i/slotsInRow)*slotstep
		self.inventoryRects[i] = Rect{x, y - slotsize, slotsize, slotsize}
		self.DrawItemSlot(t, self.inventoryRects[i])
	}

	for i := range self.inventorySlots {
		if self.inventorySlots[i].item != 0 && self.inventorySlots[i].quantity > 0 {
			self.DrawItemInSlot(t, self.inventorySlots[i].quantity, self.inventorySlots[i].item, self.inventoryRects[i])
		}
	}

	xtools += slotstep * (1.0 + float64(slotsInRow))

	gl.PushMatrix()
	gl.LoadIdentity()
	gl.Translated(xtools, ytools+4*PIXEL_SCALE, 0)

	if self.currentCrafting == nil {
		inventoryItemFont.Print("Handcrafting")
	} else {
		inventoryItemFont.Print(self.currentCrafting.Label())
	}
	gl.PopMatrix()

	for i := range self.componentSlots {
		x := xtools + float64(i)*slotstep
		y := ytools
		self.componentRects[i] = Rect{x, y - slotsize, slotsize, slotsize}

		self.DrawItemSlot(t, self.componentRects[i])
	}

	for i, cs := range self.componentSlots {
		if cs.item != 0 {
			self.DrawItemInSlot(t, cs.quantity, cs.item, self.componentRects[i])
		}
	}

	ytools -= slotstep * 2
	for i := range self.productSlots {
		x := xtools + slotstep*float64(i%slotsInRow)
		y := ytools - slotstep*float64(i/slotsInRow)
		self.productRects[i] = Rect{x, y - slotsize, slotsize, slotsize}

		self.DrawItemSlot(t, self.productRects[i])
	}

	for i, ps := range self.productSlots {
		if ps != nil {
			self.DrawItemInSlot(t, ps.product.quantity, ps.product.item, self.productRects[i])
		}
	}

	ytools -= slotstep * float64(1+len(self.productRects)/slotsInRow)
	if self.currentContainer != nil {

		gl.PushMatrix()
		gl.LoadIdentity()
		gl.Translated(xtools, ytools+4*PIXEL_SCALE, 0)
		inventoryItemFont.Print(self.currentContainer.Label())
		gl.PopMatrix()

		for i := range self.containerRects {
			x := xtools + slotstep*float64(i%slotsInRow)
			y := ytools - slotstep*float64(i/slotsInRow)
			self.containerRects[i] = Rect{x, y - slotsize, slotsize, slotsize}

			self.DrawItemSlot(t, self.containerRects[i])
		}

		for i := 0; i < self.currentContainer.Slots(); i++ {
			if self.currentContainer.Item(i).item != 0 {
				self.DrawItemInSlot(t, self.currentContainer.Item(i).quantity, self.currentContainer.Item(i).item, self.containerRects[i])
			}
		}

	}

	var mousex, mousey int
	mousestate := sdl.GetMouseState(&mousex, &mousey)

	if self.selectedItem != nil {
		x, y := viewport.ScreenCoordsToWorld2D(uint16(mousex), uint16(mousey))
		self.DrawItem(t, self.selectedItem.quantity, self.selectedItem.item, x, y)
	}

	self.HandleMouse(mousex, mousey, mousestate)

	gl.PopMatrix()
}