Remove pkg/log from lib/render package
This breaks the last ties from the lib/ folder of publicly open sourceable code from the internals of Doodle in pkg/
This commit is contained in:
parent
8dfae5b8d8
commit
95ef079724
|
@ -2,9 +2,9 @@ package sdl
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
)
|
||||
|
||||
|
@ -26,7 +26,7 @@ func (r *Renderer) Poll() (*events.State, error) {
|
|||
case *sdl.WindowEvent:
|
||||
if DebugWindowEvents {
|
||||
if t.Event == sdl.WINDOWEVENT_RESIZED {
|
||||
log.Debug("[%d ms] tick:%d Window Resized to %dx%d",
|
||||
fmt.Printf("[%d ms] tick:%d Window Resized to %dx%d",
|
||||
t.Timestamp,
|
||||
r.ticks,
|
||||
t.Data1,
|
||||
|
@ -37,7 +37,7 @@ func (r *Renderer) Poll() (*events.State, error) {
|
|||
s.Resized.Push(true)
|
||||
case *sdl.MouseMotionEvent:
|
||||
if DebugMouseEvents {
|
||||
log.Debug("[%d ms] tick:%d MouseMotion type:%d id:%d x:%d y:%d xrel:%d yrel:%d",
|
||||
fmt.Printf("[%d ms] tick:%d MouseMotion type:%d id:%d x:%d y:%d xrel:%d yrel:%d",
|
||||
t.Timestamp, r.ticks, t.Type, t.Which, t.X, t.Y, t.XRel, t.YRel,
|
||||
)
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func (r *Renderer) Poll() (*events.State, error) {
|
|||
s.Button1.Push(t.State == 1)
|
||||
case *sdl.MouseButtonEvent:
|
||||
if DebugClickEvents {
|
||||
log.Debug("[%d ms] tick:%d MouseButton type:%d id:%d x:%d y:%d button:%d state:%d",
|
||||
fmt.Printf("[%d ms] tick:%d MouseButton type:%d id:%d x:%d y:%d button:%d state:%d",
|
||||
t.Timestamp, r.ticks, t.Type, t.Which, t.X, t.Y, t.Button, t.State,
|
||||
)
|
||||
}
|
||||
|
@ -81,13 +81,13 @@ func (r *Renderer) Poll() (*events.State, error) {
|
|||
}
|
||||
case *sdl.MouseWheelEvent:
|
||||
if DebugMouseEvents {
|
||||
log.Debug("[%d ms] tick:%d MouseWheel type:%d id:%d x:%d y:%d",
|
||||
fmt.Printf("[%d ms] tick:%d MouseWheel type:%d id:%d x:%d y:%d",
|
||||
t.Timestamp, r.ticks, t.Type, t.Which, t.X, t.Y,
|
||||
)
|
||||
}
|
||||
case *sdl.KeyboardEvent:
|
||||
if DebugKeyEvents {
|
||||
log.Debug("[%d ms] tick:%d Keyboard type:%d sym:%c modifiers:%d state:%d repeat:%d\n",
|
||||
fmt.Printf("[%d ms] tick:%d Keyboard type:%d sym:%c modifiers:%d state:%d repeat:%d\n",
|
||||
t.Timestamp, r.ticks, t.Type, t.Keysym.Sym, t.Keysym.Mod, t.State, t.Repeat,
|
||||
)
|
||||
}
|
||||
|
|
10
sdl/sdl.go
10
sdl/sdl.go
|
@ -2,11 +2,11 @@
|
|||
package sdl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.kirsle.net/apps/doodle/lib/events"
|
||||
"git.kirsle.net/apps/doodle/lib/render"
|
||||
"git.kirsle.net/apps/doodle/pkg/log"
|
||||
"github.com/veandco/go-sdl2/sdl"
|
||||
"github.com/veandco/go-sdl2/ttf"
|
||||
)
|
||||
|
@ -50,19 +50,16 @@ func (r *Renderer) Teardown() {
|
|||
// Setup the renderer.
|
||||
func (r *Renderer) Setup() error {
|
||||
// Initialize SDL.
|
||||
log.Info("Initializing SDL")
|
||||
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("sdl.Init: %s", err)
|
||||
}
|
||||
|
||||
// Initialize SDL_TTF.
|
||||
log.Info("Initializing SDL_TTF")
|
||||
if err := ttf.Init(); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("ttf.Init: %s", err)
|
||||
}
|
||||
|
||||
// Create our window.
|
||||
log.Info("Creating the Main Window")
|
||||
window, err := sdl.CreateWindow(
|
||||
r.title,
|
||||
sdl.WINDOWPOS_CENTERED,
|
||||
|
@ -77,7 +74,6 @@ func (r *Renderer) Setup() error {
|
|||
r.window = window
|
||||
|
||||
// Blank out the window in white.
|
||||
log.Info("Creating the SDL Renderer")
|
||||
renderer, err := sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
Loading…
Reference in New Issue
Block a user