moving window to platform
This commit is contained in:
parent
8c0c4890cb
commit
c045e345d2
@ -1,34 +0,0 @@
|
||||
package graphics
|
||||
|
||||
import "github.com/veandco/go-sdl2/sdl"
|
||||
|
||||
type Window struct {
|
||||
window *sdl.Window
|
||||
renderer *sdl.Renderer
|
||||
}
|
||||
|
||||
func NewWindow(title string, width, height int) (*Window, error) {
|
||||
window, err := sdl.CreateWindow(
|
||||
title,
|
||||
sdl.WINDOWPOS_UNDEFINED,
|
||||
sdl.WINDOWPOS_UNDEFINED,
|
||||
int32(width),
|
||||
int32(height),
|
||||
sdl.WINDOW_SHOWN,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
renderer, err := sdl.CreateRenderer(window, -1, sdl.RENDERER_ACCELERATED)
|
||||
if err != nil {
|
||||
window.Destroy()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Window{window, renderer}, nil
|
||||
}
|
||||
|
||||
func (w *Window) Destroy() {
|
||||
|
||||
}
|
@ -9,6 +9,7 @@ type Window interface {
|
||||
type window struct {
|
||||
sdlWindow *sdl.Window
|
||||
sdlGlContext sdl.GLContext
|
||||
sdlRenderer *sdl.Renderer
|
||||
}
|
||||
|
||||
func newWindow(title string, width, height int) (Window, error) {
|
||||
@ -30,7 +31,13 @@ func newWindow(title string, width, height int) (Window, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &window{sdlWindow, sdlGlContext}, nil
|
||||
sdlRenderer, err := sdl.CreateRenderer(sdlWindow, -1, sdl.RENDERER_ACCELERATED)
|
||||
if err != nil {
|
||||
sdlWindow.Destroy()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &window{sdlWindow, sdlGlContext, sdlRenderer}, nil
|
||||
}
|
||||
|
||||
func (w *window) Destroy() error {
|
||||
|
Loading…
Reference in New Issue
Block a user