Add golangci-lint and fix errors found
parent
db5a0aa6e8
commit
b3c161eed2
|
@ -1,6 +1,6 @@
|
|||
# BSD 2-Clause License
|
||||
|
||||
Copyright (c) 2021, Sean Hickey (Wisellama)
|
||||
Copyright (c) 2021-2022, Sean Hickey (Wisellama)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
|
|
10
Makefile
10
Makefile
|
@ -3,12 +3,15 @@ all: release
|
|||
dependencies:
|
||||
go mod tidy
|
||||
|
||||
build: dependencies
|
||||
build: linter dependencies
|
||||
go build -x -v
|
||||
|
||||
release: dependencies
|
||||
release: linter dependencies
|
||||
go build -x -v -ldflags "-s -w"
|
||||
|
||||
linter:
|
||||
golangci-lint run
|
||||
|
||||
cross_windows:
|
||||
export CGO_ENABLED=1
|
||||
export CC=x86_64-w64-mingw32-gcc
|
||||
|
@ -22,3 +25,6 @@ cross_windows_x86:
|
|||
export GOOS=windows
|
||||
export GOARCH=386
|
||||
go build -x -v -ldflags "-s -w"
|
||||
|
||||
goimports_everything:
|
||||
find . -name "*.go" -exec goimports -w {} \;
|
||||
|
|
35
main.go
35
main.go
|
@ -17,7 +17,6 @@ import (
|
|||
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
|
||||
|
||||
const gameTitle = "Carpy Breakout"
|
||||
const logFile = "output.log"
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
@ -27,7 +26,10 @@ func main() {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
pprof.StartCPUProfile(f)
|
||||
err = pprof.StartCPUProfile(f)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
|
@ -51,7 +53,10 @@ func runOpenGL() {
|
|||
}
|
||||
defer sdl.Quit()
|
||||
|
||||
sdlSettings()
|
||||
err = sdlSettings()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
gameWindow, err := breakout.NewGameWindow(gameTitle)
|
||||
if err != nil {
|
||||
|
@ -71,7 +76,10 @@ func runOpenGL() {
|
|||
log.Printf("OpenGL Version: %v\n", gl.GoStr(glVersion))
|
||||
|
||||
// Then we can setup the OpenGL specific stuff in the game window
|
||||
gameWindow.GLInitDefault()
|
||||
err = gameWindow.GLInitDefault()
|
||||
if err != nil {
|
||||
log.Printf("error in gameWindow GLInitDefault: %v", err)
|
||||
}
|
||||
|
||||
sunLight := globjects.NewPointLight(mgl32.Vec3{-10, 10, 30})
|
||||
sunLight.GLInit(gameWindow.GLProgram)
|
||||
|
@ -141,6 +149,7 @@ func runOpenGL() {
|
|||
}
|
||||
|
||||
func setupLogging() {
|
||||
// const logFile = "output.log"
|
||||
// file, err := os.OpenFile(logFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
|
@ -158,10 +167,20 @@ func glSettings() {
|
|||
gl.LineWidth(2.0)
|
||||
}
|
||||
|
||||
func sdlSettings() {
|
||||
func sdlSettings() error {
|
||||
var err error
|
||||
|
||||
// Smooth
|
||||
sdl.GLSetAttribute(sdl.GL_MULTISAMPLEBUFFERS, 1)
|
||||
sdl.GLSetAttribute(sdl.GL_MULTISAMPLESAMPLES, 4)
|
||||
err = sdl.GLSetAttribute(sdl.GL_MULTISAMPLEBUFFERS, 1)
|
||||
if err != nil {
|
||||
log.Printf("error setting GL_MULTISAMPLEBUFFERS: %v", err)
|
||||
return err
|
||||
}
|
||||
err = sdl.GLSetAttribute(sdl.GL_MULTISAMPLESAMPLES, 4)
|
||||
if err != nil {
|
||||
log.Printf("error setting GL_MULTISAMPLESAMPLES: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
// Disable the Linux compositor flicker.
|
||||
// https://github.com/mosra/magnum/issues/184#issuecomment-425952900
|
||||
|
@ -171,4 +190,6 @@ func sdlSettings() {
|
|||
|
||||
// Capture the mouse for movement
|
||||
sdl.SetRelativeMouseMode(true)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -90,16 +90,28 @@ func (w *GameWindow) AddObject(object globjects.GLObject) {
|
|||
}
|
||||
|
||||
func (w *GameWindow) Destroy() {
|
||||
w.SDLWindow.Destroy()
|
||||
err := w.SDLWindow.Destroy()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
sdl.GLDeleteContext(*w.GLContext)
|
||||
}
|
||||
|
||||
func (w *GameWindow) ToggleFullscreen() {
|
||||
var err error
|
||||
if w.fullscreen {
|
||||
w.SDLWindow.SetFullscreen(defaultWindowFlags)
|
||||
err = w.SDLWindow.SetFullscreen(defaultWindowFlags)
|
||||
if err != nil {
|
||||
log.Printf("error setting defaultWindowFlags: %v", err)
|
||||
}
|
||||
} else {
|
||||
w.SDLWindow.SetFullscreen(fullscreenWindowFlags)
|
||||
err = w.SDLWindow.SetFullscreen(fullscreenWindowFlags)
|
||||
if err != nil {
|
||||
log.Printf("error setting fullscreenWindowFlags: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
w.fullscreen = !w.fullscreen
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ func (c *Camera) GLDraw() {
|
|||
}
|
||||
|
||||
func (c *Camera) GLInit(glProgram uint32) {
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Camera) Update() {
|
||||
|
@ -61,7 +60,6 @@ func (c *Camera) Update() {
|
|||
}
|
||||
|
||||
func (c *Camera) ToggleWireframe() {
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Camera) GetAABB() *AABB {
|
||||
|
|
Loading…
Reference in New Issue