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
35d96b714d
commit
fb8f4b1029
|
@ -2,9 +2,9 @@ package sdl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"git.kirsle.net/apps/doodle/lib/events"
|
"git.kirsle.net/apps/doodle/lib/events"
|
||||||
"git.kirsle.net/apps/doodle/pkg/log"
|
|
||||||
"github.com/veandco/go-sdl2/sdl"
|
"github.com/veandco/go-sdl2/sdl"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ func (r *Renderer) Poll() (*events.State, error) {
|
||||||
case *sdl.WindowEvent:
|
case *sdl.WindowEvent:
|
||||||
if DebugWindowEvents {
|
if DebugWindowEvents {
|
||||||
if t.Event == sdl.WINDOWEVENT_RESIZED {
|
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,
|
t.Timestamp,
|
||||||
r.ticks,
|
r.ticks,
|
||||||
t.Data1,
|
t.Data1,
|
||||||
|
@ -37,7 +37,7 @@ func (r *Renderer) Poll() (*events.State, error) {
|
||||||
s.Resized.Push(true)
|
s.Resized.Push(true)
|
||||||
case *sdl.MouseMotionEvent:
|
case *sdl.MouseMotionEvent:
|
||||||
if DebugMouseEvents {
|
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,
|
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)
|
s.Button1.Push(t.State == 1)
|
||||||
case *sdl.MouseButtonEvent:
|
case *sdl.MouseButtonEvent:
|
||||||
if DebugClickEvents {
|
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,
|
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:
|
case *sdl.MouseWheelEvent:
|
||||||
if DebugMouseEvents {
|
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,
|
t.Timestamp, r.ticks, t.Type, t.Which, t.X, t.Y,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
case *sdl.KeyboardEvent:
|
case *sdl.KeyboardEvent:
|
||||||
if DebugKeyEvents {
|
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,
|
t.Timestamp, r.ticks, t.Type, t.Keysym.Sym, t.Keysym.Mod, t.State, t.Repeat,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
package sdl
|
package sdl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.kirsle.net/apps/doodle/lib/events"
|
"git.kirsle.net/apps/doodle/lib/events"
|
||||||
"git.kirsle.net/apps/doodle/lib/render"
|
"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/sdl"
|
||||||
"github.com/veandco/go-sdl2/ttf"
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
)
|
)
|
||||||
|
@ -50,19 +50,16 @@ func (r *Renderer) Teardown() {
|
||||||
// Setup the renderer.
|
// Setup the renderer.
|
||||||
func (r *Renderer) Setup() error {
|
func (r *Renderer) Setup() error {
|
||||||
// Initialize SDL.
|
// Initialize SDL.
|
||||||
log.Info("Initializing SDL")
|
|
||||||
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
|
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
|
||||||
return err
|
return fmt.Errorf("sdl.Init: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize SDL_TTF.
|
// Initialize SDL_TTF.
|
||||||
log.Info("Initializing SDL_TTF")
|
|
||||||
if err := ttf.Init(); err != nil {
|
if err := ttf.Init(); err != nil {
|
||||||
return err
|
return fmt.Errorf("ttf.Init: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create our window.
|
// Create our window.
|
||||||
log.Info("Creating the Main Window")
|
|
||||||
window, err := sdl.CreateWindow(
|
window, err := sdl.CreateWindow(
|
||||||
r.title,
|
r.title,
|
||||||
sdl.WINDOWPOS_CENTERED,
|
sdl.WINDOWPOS_CENTERED,
|
||||||
|
@ -77,7 +74,6 @@ func (r *Renderer) Setup() error {
|
||||||
r.window = window
|
r.window = window
|
||||||
|
|
||||||
// Blank out the window in white.
|
// Blank out the window in white.
|
||||||
log.Info("Creating the SDL Renderer")
|
|
||||||
renderer, err := sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
|
renderer, err := sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user