Exemplo n.º 1
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()
}
Exemplo n.º 2
0
func InitFont() {
	LoadTexture(filepath.Join("data", "Font.png"))

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

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

		gl.NewList(oFontBase+uint32(i+32), gl.COMPILE)
		gl.Begin(gl.QUADS)
		gl.TexCoord2d(float64(indexX)*shiftX, float64(indexY)*shiftY)
		gl.Vertex2i(0, 0)
		gl.TexCoord2d(float64(indexX+1)*shiftX, float64(indexY)*shiftY)
		gl.Vertex2i(fontWidth, 0)
		gl.TexCoord2d(float64(indexX+1)*shiftX, float64(indexY+1)*shiftY)
		gl.Vertex2i(fontWidth, fontHeight)
		gl.TexCoord2d(float64(indexX)*shiftX, float64(indexY+1)*shiftY)
		gl.Vertex2i(0, fontHeight)
		gl.End()
		gl.Translated(fontWidth, 0.0, 0.0)
		gl.EndList()
	}

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

	CheckGLError()
}