finally runs
This commit is contained in:
parent
9d39c2dbcb
commit
3ad06351ae
|
@ -10,17 +10,7 @@ import "log"
|
||||||
import "os"
|
import "os"
|
||||||
import "flag"
|
import "flag"
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
import "github.com/gookit/config"
|
||||||
var (
|
|
||||||
version string
|
|
||||||
race bool
|
|
||||||
debug = os.Getenv("BUILDDEBUG") != ""
|
|
||||||
filename string
|
|
||||||
width int
|
|
||||||
height int
|
|
||||||
timeout = "120s"
|
|
||||||
uDrift float32
|
|
||||||
)
|
|
||||||
|
|
||||||
var customUsage = func() {
|
var customUsage = func() {
|
||||||
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
|
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
|
||||||
|
@ -35,12 +25,22 @@ var customUsage = func() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseFlags() {
|
func parseFlags() {
|
||||||
|
var version string
|
||||||
|
var race bool
|
||||||
|
// var debug = os.Getenv("BUILDDEBUG") != ""
|
||||||
|
var filename string
|
||||||
|
var width int
|
||||||
|
var height int
|
||||||
|
// var timeout = "120s"
|
||||||
|
var glDrift float64
|
||||||
|
|
||||||
flag.StringVar (&version, "version", "v0.1", "Set compiled in version string")
|
flag.StringVar (&version, "version", "v0.1", "Set compiled in version string")
|
||||||
|
|
||||||
flag.StringVar (&filename, "filename", "shaders/seascape.glsl", "path to GLSL file")
|
flag.StringVar (&filename, "filename", "shaders/seascape.glsl", "path to GLSL file")
|
||||||
flag.IntVar (&width, "width", 1024, "Width of the OpenGL Window")
|
flag.IntVar (&width, "width", 1024, "Width of the OpenGL Window")
|
||||||
flag.IntVar (&height, "height", 768, "Height of the OpenGL Window")
|
flag.IntVar (&height, "height", 768, "Height of the OpenGL Window")
|
||||||
var tmp float64
|
|
||||||
flag.Float64Var (&tmp, "drift", 0.01, "Speed of the gradual camera drift")
|
flag.Float64Var (&glDrift, "drift", 0.01, "Speed of the gradual camera drift")
|
||||||
flag.BoolVar (&race, "race", race, "Use race detector")
|
flag.BoolVar (&race, "race", race, "Use race detector")
|
||||||
|
|
||||||
// Set the output if something fails to stdout rather than stderr
|
// Set the output if something fails to stdout rather than stderr
|
||||||
|
@ -51,13 +51,28 @@ func parseFlags() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if flag.Parsed() {
|
if flag.Parsed() {
|
||||||
log.Println("Parsed() worked. width=",width)
|
log.Println("Parsed() worked")
|
||||||
} else {
|
} else {
|
||||||
log.Println("Parsed() failed. width=",width)
|
log.Println("Parsed() failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
uDrift = float32(tmp)
|
// keys := []string{"filename", "width", "height", "drift"}
|
||||||
log.Println("width=",width)
|
// keys := []string{"width", "height", "drift"}
|
||||||
log.Println("height=",height)
|
|
||||||
log.Println("uDrift=",uDrift)
|
// keys := []string{"height"}
|
||||||
|
// config.LoadFlags(keys)
|
||||||
|
|
||||||
|
config.Set("width", width)
|
||||||
|
config.Set("height", height)
|
||||||
|
config.Set("filename", filename)
|
||||||
|
|
||||||
|
// uDrift = float32(tmp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseConfig() {
|
||||||
|
config.WithOptions(config.ParseEnv)
|
||||||
|
parseFlags()
|
||||||
|
|
||||||
|
// config.LoadOSEnv([]string{"MAIL"})
|
||||||
|
// config.LoadOSEnv([]string{"USER"})
|
||||||
}
|
}
|
|
@ -10,11 +10,14 @@ import (
|
||||||
"golang.org/x/image/colornames"
|
"golang.org/x/image/colornames"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
import "github.com/gookit/config"
|
||||||
|
|
||||||
func run() {
|
func run() {
|
||||||
// Set up window configs
|
// Set up window configs
|
||||||
cfg := pixelgl.WindowConfig{ // Default: 1024 x 768
|
cfg := pixelgl.WindowConfig{ // Default: 1024 x 768
|
||||||
Title: "Golang GLSL",
|
Title: "Golang GLSL",
|
||||||
Bounds: pixel.R(0, 0, float64(width), float64(height)),
|
Bounds: pixel.R(0, 0, config.Float("width"), config.Float("height")),
|
||||||
VSync: true,
|
VSync: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +34,7 @@ func run() {
|
||||||
// I am putting all shader example initializing stuff here for
|
// I am putting all shader example initializing stuff here for
|
||||||
// easier reference to those learning to use this functionality
|
// easier reference to those learning to use this functionality
|
||||||
|
|
||||||
fragSource, err := LoadFileToString(filename)
|
fragSource, err := LoadFileToString(config.String("filename"))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -39,6 +42,7 @@ func run() {
|
||||||
|
|
||||||
var uMouse mgl32.Vec4
|
var uMouse mgl32.Vec4
|
||||||
var uTime float32
|
var uTime float32
|
||||||
|
var uDrift float32 = float32(config.Float("uDrift"))
|
||||||
|
|
||||||
canvas := win.Canvas()
|
canvas := win.Canvas()
|
||||||
uResolution := mgl32.Vec2{float32(win.Bounds().W()), float32(win.Bounds().H())}
|
uResolution := mgl32.Vec2{float32(win.Bounds().W()), float32(win.Bounds().H())}
|
||||||
|
@ -73,7 +77,19 @@ func run() {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// This parses the command line arguments
|
// This parses the command line arguments
|
||||||
parseFlags()
|
parseConfig()
|
||||||
|
|
||||||
|
name := config.String("name")
|
||||||
|
fmt.Println("name = ", name)
|
||||||
|
|
||||||
|
fmt.Println("name2 = ", config.String("name2"))
|
||||||
|
fmt.Println("width = ", config.Int("width"))
|
||||||
|
fmt.Println("height = ", config.String("height"))
|
||||||
|
fmt.Println("drift = ", config.Int("drift"))
|
||||||
|
fmt.Println("filename = ", config.String("filename"))
|
||||||
|
fmt.Println("MAIL=", config.String("MAIL"))
|
||||||
|
fmt.Println("mail=", config.String("mail"))
|
||||||
|
fmt.Println("USER=", config.String("USER"))
|
||||||
|
|
||||||
pixelgl.Run(run)
|
pixelgl.Run(run)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue