summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile5
-rw-r--r--README.md2
-rw-r--r--args.go30
-rw-r--r--config.go84
-rw-r--r--main.go20
-rw-r--r--seascape.go15
7 files changed, 50 insertions, 108 deletions
diff --git a/.gitignore b/.gitignore
index a630ed4..c770e3a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
*.swp
go.mod
go.sum
+pixelgl
+pixelgl.so
diff --git a/Makefile b/Makefile
index afde483..b461665 100644
--- a/Makefile
+++ b/Makefile
@@ -2,11 +2,10 @@ all: plugin
ldd ../pixelgl.so
plugin:
- GO111MODULE=off go build -v -x -buildmode=plugin -o ../pixelgl.so
+ go build -v -x -buildmode=plugin -o pixelgl.so
standalone:
- GO111MODULE=off go install -v -x
- pixelgl
+ go build -v -x
check-git-clean:
@git diff-index --quiet HEAD -- || (echo "Git repository is dirty, please commit your changes first"; exit 1)
diff --git a/README.md b/README.md
index 018b9ce..55a6762 100644
--- a/README.md
+++ b/README.md
@@ -3,3 +3,5 @@
Package gui implements a abstraction layer for Go visual elements.
This is a sample plugin. It's a skeleton intended to be used when making a new toolkit plugin.
+
+# github.com/faiface/pixel-examples/community/seascape-shader/
diff --git a/args.go b/args.go
index 88fcf53..f408586 100644
--- a/args.go
+++ b/args.go
@@ -28,3 +28,33 @@ func init() {
ERROR = log.NewFlag("ERROR", true, full, short, "toolkit errors")
}
+
+var argv args
+
+type args struct {
+ Width float64 `arg:"--width" default:"640" help:"window width"`
+ Height float64 `arg:"--height" default:"480" help:"window height"`
+ Filename string `arg:"--filename" help:"what .glsl file to render"`
+ DryRun bool `arg:"--dry-run" help:"show what would be run"`
+ GLdrift float32 `arg:"--drift" default:"0.01" help:"how fast things move around"`
+ // Fetch bool `arg:"--git-fetch" default:"false" help:"run 'git fetch' on all your repos"`
+}
+
+func (args) Version() string {
+ return "go-clone " + VERSION + " Built on " + BUILDTIME
+}
+
+func (a args) Description() string {
+ return `
+git clone go repositories
+
+Examples:
+ go-clone go.wit.com/apps/go-clone # simply try to git clone this
+ go-clone --recursive go.wit.com/apps/go-clone # recursively clone all the dependancies
+ go-clone --auto-work go.wit.com/apps/go-clone # if you are using a go.work file, recreate the go.work file
+ go-clone --go-reset # recreate every go.mod and go.sum file
+ go-clone --git-pull # run 'git pull' in every repo
+ go-clone --build # build every binary package
+ go-clone --install # install every binary package
+`
+}
diff --git a/config.go b/config.go
deleted file mode 100644
index 8aaf309..0000000
--- a/config.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package main
-
-/*
- This simply parses the command line arguments using the default golang
- package called 'flag'. This can be used as a simple template to parse
- command line arguments in other programs.
-
- It puts everything in the 'config' package which I think is a good
- wrapper around the 'flags' package and doesn't need a whole mess of
- global variables
-*/
-
-import (
- "flag"
- "fmt"
- "log"
- "os"
-
- "github.com/gookit/config"
-)
-
-var customUsage = func() {
- fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
- flag.PrintDefaults()
-
- fmt.Println("")
- fmt.Println("EXAMPLES:")
- fmt.Println("")
- fmt.Println(os.Args[0] + " --width 1024 --height 768 --drift .1 --filename seascape.glsl")
- fmt.Println(os.Args[0] + " --width 640 --height 480 --filename planetfall.glsl")
- fmt.Println("")
-}
-
-func parseFlags() {
- var version string
- var race bool
- var filename string
- var width int
- var height int
- var glDrift float64
- var guiJunk string
-
- flag.StringVar(&version, "version", "v0.1", "Set compiled in version string")
-
- flag.StringVar(&filename, "filename", "seascape.glsl", "path to GLSL file")
- flag.StringVar(&guiJunk, "gui", "something", "redo all this code")
- flag.IntVar(&width, "width", 1024, "Width of the OpenGL Window")
- flag.IntVar(&height, "height", 768, "Height of the OpenGL Window")
-
- flag.Float64Var(&glDrift, "drift", 0.01, "Speed of the gradual camera drift")
- flag.BoolVar(&race, "race", race, "Use race detector")
-
- // Set the output if something fails to stdout rather than stderr
- flag.CommandLine.SetOutput(os.Stdout)
-
- flag.Usage = customUsage
- flag.Parse()
-
- if flag.Parsed() {
- log.Println("flag.Parse() worked")
- } else {
- log.Println("flag.Parse() failed")
- }
-
- // keys := []string{"filename", "width", "height", "drift"}
- // keys := []string{"width", "height", "drift"}
-
- // keys := []string{"height"}
- // config.LoadFlags(keys)
-
- config.Set("width", width)
- config.Set("height", height)
- config.Set("glDrift", glDrift)
- config.Set("filename", filename)
-}
-
-func parseConfig() {
- config.WithOptions(config.ParseEnv)
- parseFlags()
-
- // config.LoadOSEnv([]string{"MAIL"})
- // config.LoadOSEnv([]string{"USER"})
- // config.LoadOSEnv([]string{"BUILDDEBUG"})
-}
diff --git a/main.go b/main.go
index 8b67ba3..d92b0b4 100644
--- a/main.go
+++ b/main.go
@@ -10,17 +10,25 @@ package main
import (
"embed"
+ "go.wit.com/dev/alexflint/arg"
"go.wit.com/log"
"go.wit.com/toolkits/tree"
"github.com/faiface/pixel/pixelgl"
- "github.com/gookit/config"
+ // "github.com/gookit/config"
)
+// sent via -ldflags
+var VERSION string
+var BUILDTIME string
+
//go:embed *.glsl
var glFile embed.FS
+var pp *arg.Parser
func init() {
+ pp = arg.MustParse(&argv)
+
log.Log(INFO, "Init()")
me.myTree = tree.New()
@@ -42,12 +50,6 @@ func init() {
go simpleStdin()
- config.Set("width", 640)
- config.Set("height", 480)
- config.Set("glDrift", 0.01)
- // config.Set("filename", "planetfall.glsl")
- config.Set("filename", "seascape.glsl")
-
// I think this doesn't work as a goroutine because
// opengl closes. This plugin probably has to wait
// until there is some sort of protobuf + socket interface
@@ -60,10 +62,6 @@ func init() {
// I assume it's for testing the code in a stand alone way
func main() {
- config.Set("width", 1024)
- config.Set("height", 768)
- config.Set("glDrift", 0.01)
- config.Set("filename", "planetfall.glsl")
// This parses the command line arguments
// parseConfig()
pixelgl.Run(run)
diff --git a/seascape.go b/seascape.go
index 0c830b3..5e93a27 100644
--- a/seascape.go
+++ b/seascape.go
@@ -5,20 +5,17 @@ import (
"github.com/go-gl/mathgl/mgl32"
- "log"
-
"github.com/faiface/pixel"
"github.com/faiface/pixel/pixelgl"
- "github.com/gookit/config"
"golang.org/x/image/colornames"
)
func run() {
// Set up window configs
- log.Println("width = ", config.Int("width"), "height = ", config.String("height"))
cfg := pixelgl.WindowConfig{ // Default: 1024 x 768
- Title: "Golang GLSL",
- Bounds: pixel.R(0, 0, config.Float("width"), config.Float("height")),
+ Title: "Golang GLSL",
+ // Bounds: pixel.R(0, 0, float64(width), float64(height)),
+ Bounds: pixel.R(0, 0, argv.Width, argv.Height),
VSync: true,
}
@@ -35,8 +32,7 @@ func run() {
// I am putting all shader example initializing stuff here for
// easier reference to those learning to use this functionality
- log.Println("Load GSGL file = ", config.String("filename"))
- fragSource, err := LoadFileToString(config.String("filename"))
+ fragSource, err := LoadFileToString(argv.Filename)
if err != nil {
panic(err)
@@ -44,8 +40,7 @@ func run() {
var uMouse mgl32.Vec4
var uTime float32
- log.Println("glDrift = ", config.String("glDrift"))
- var glDrift float32 = float32(config.Float("glDrift"))
+ var glDrift float32 = argv.GLdrift
canvas := win.Canvas()
uResolution := mgl32.Vec2{float32(win.Bounds().W()), float32(win.Bounds().H())}