try to add text support on glfw add font file

This commit is contained in:
lordwelch 2016-04-26 10:23:06 -07:00
parent f0c8b93a22
commit b85f6c86c8
3 changed files with 14 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
Comfortaa-Regular.ttf Executable file

Binary file not shown.

14
glfw.go
View File

@ -5,10 +5,12 @@ import (
"fmt" "fmt"
"image" "image"
"log" "log"
"os"
"github.com/go-gl/gl/v2.1/gl" "github.com/go-gl/gl/v2.1/gl"
"github.com/go-gl/glfw/v3.1/glfw" "github.com/go-gl/glfw/v3.1/glfw"
"github.com/lordwelch/qml" "github.com/lordwelch/qml"
"github.com/go-gl/gltext"
) )
var ( var (
@ -19,8 +21,18 @@ var (
projMonitor *glfw.Monitor projMonitor *glfw.Monitor
tex1 *uint32 //identifier for opengl texture tex1 *uint32 //identifier for opengl texture
texDel Bool //if texture should be deleted texDel Bool //if texture should be deleted
flt *os.File
f *gltext.Font
) )
func loadfont(){
flt,err = os.Open("Comfortaa-Regular.ttf")
if err != nil {
f, err = gltext.LoadTruetype(flt, 30, 32, 255, gltext.LeftToRight)
}
}
func setupScene() { func setupScene() {
gl.ClearColor(0, 0, 0, 0) gl.ClearColor(0, 0, 0, 0)
@ -63,6 +75,7 @@ func drawSlide() {
gl.Vertex3f(-1, -1, 0) gl.Vertex3f(-1, -1, 0)
gl.End() gl.End()
f.Printf(5,10,"test")
} }
@ -142,6 +155,7 @@ func glInit() {
if err := gl.Init(); err != nil { if err := gl.Init(); err != nil {
panic(err) panic(err)
} }
loadfont()
win.SetPos(projMonitor.GetPos()) win.SetPos(projMonitor.GetPos())
setupScene() setupScene()