Преглед изворни кода

window api changed / application exec tracer support

leonsal пре 8 година
родитељ
комит
3227dca484
4 измењених фајлова са 248 додато и 170 уклоњено
  1. 2 2
      camera/control/orbit_control.go
  2. 65 19
      util/application/application.go
  3. 149 117
      window/glfw.go
  4. 32 32
      window/window.go

+ 2 - 2
camera/control/orbit_control.go

@@ -130,7 +130,7 @@ func (oc *OrbitControl) Reset() {
 // Pan the camera and target by the specified deltas
 func (oc *OrbitControl) Pan(deltaX, deltaY float32) {
 
-	width, height := oc.win.GetSize()
+	width, height := oc.win.Size()
 	oc.pan(deltaX, deltaY, width, height)
 	oc.updatePan()
 }
@@ -392,7 +392,7 @@ func (oc *OrbitControl) onCursorPos(evname string, ev interface{}) {
 		oc.rotateDelta.SubVectors(&oc.rotateEnd, &oc.rotateStart)
 		oc.rotateStart = oc.rotateEnd
 		// rotating across whole screen goes 360 degrees around
-		width, height := oc.win.GetSize()
+		width, height := oc.win.Size()
 		oc.RotateLeft(2 * math32.Pi * oc.rotateDelta.X / float32(width) * oc.RotateSpeed)
 		// rotating up and down along whole screen attempts to go 360, but limited to 180
 		oc.RotateUp(2 * math32.Pi * oc.rotateDelta.Y / float32(height) * oc.RotateSpeed)

+ 65 - 19
util/application/application.go

@@ -6,6 +6,7 @@ import (
 	"os"
 	"runtime"
 	"runtime/pprof"
+	"runtime/trace"
 	"time"
 
 	"github.com/g3n/engine/audio/al"
@@ -27,6 +28,7 @@ import (
 type Application struct {
 	core.Dispatcher                         // Embedded event dispatcher
 	core.TimerManager                       // Embedded timer manager
+	wmgr              window.IWindowManager // Window manager
 	win               window.IWindow        // Application window
 	gl                *gls.GLS              // OpenGL state
 	log               *logger.Logger        // Default application logger
@@ -48,11 +50,11 @@ type Application struct {
 	frameDelta        time.Duration         // Time delta from previous frame
 	startTime         time.Time             // Time at the start of the render loop
 	fullScreen        *bool                 // Full screen option
-	cpuProfile        *string               // File to write cpu profile to
 	swapInterval      *int                  // Swap interval option
 	targetFPS         *uint                 // Target FPS option
 	noglErrors        *bool                 // No OpenGL check errors options
-
+	cpuProfile        *string               // File to write cpu profile to
+	execTrace         *string               // File to write execution trace data to
 }
 
 // Options defines initial options passed to the application creation function
@@ -105,10 +107,11 @@ func Create(name string, ops Options) (*Application, error) {
 	// Creates flags if requested (override options defaults)
 	if ops.EnableFlags {
 		app.fullScreen = flag.Bool("fullscreen", false, "Stars application with full screen")
-		app.cpuProfile = flag.String("cpuprofile", "", "Activate cpu profiling writing profile to the specified file")
 		app.swapInterval = flag.Int("swapinterval", -1, "Sets the swap buffers interval to this value")
 		app.targetFPS = flag.Uint("targetfps", 60, "Sets the frame rate in frames per second")
 		app.noglErrors = flag.Bool("noglerrors", false, "Do not check OpenGL errors at each call (may increase FPS)")
+		app.cpuProfile = flag.String("cpuprofile", "", "Activate cpu profiling writing profile to the specified file")
+		app.execTrace = flag.String("exectrace", "", "Activate execution tracer writing data to the specified file")
 	}
 	flag.Parse()
 
@@ -121,16 +124,18 @@ func Create(name string, ops Options) (*Application, error) {
 	// Window event handling must run on the main OS thread
 	runtime.LockOSThread()
 
-	// Creates window
-	win, err := window.New("glfw", 800, 600, name, *app.fullScreen)
+	// Get the window manager
+	wmgr, err := window.Manager("glfw")
 	if err != nil {
 		return nil, err
 	}
-	app.win = win
+	app.wmgr = wmgr
+
+	// Get the screen resolution
+	swidth, sheight := app.wmgr.ScreenResolution(nil)
+	var posx, posy int
+	// If not full screen, sets the window size
 	if !*app.fullScreen {
-		// Calculates window size and position
-		swidth, sheight := win.GetScreenResolution(nil)
-		var posx, posy int
 		if ops.Width != 0 {
 			posx = (swidth - ops.Width) / 2
 			if posx < 0 {
@@ -145,10 +150,16 @@ func Create(name string, ops Options) (*Application, error) {
 			}
 			sheight = ops.Height
 		}
-		// Sets the window size and position
-		win.SetSize(swidth, sheight)
-		win.SetPos(posx, posy)
 	}
+
+	// Creates window
+	win, err := app.wmgr.CreateWindow(swidth, sheight, name, *app.fullScreen)
+	if err != nil {
+		return nil, err
+	}
+	win.SetPos(posx, posy)
+	app.win = win
+
 	// Create OpenGL state
 	gl, err := gls.New()
 	if err != nil {
@@ -163,7 +174,7 @@ func Create(name string, ops Options) (*Application, error) {
 	app.gl.Clear(gls.DEPTH_BUFFER_BIT | gls.STENCIL_BUFFER_BIT | gls.COLOR_BUFFER_BIT)
 
 	// Creates perspective camera
-	width, height := app.win.GetSize()
+	width, height := app.win.Size()
 	aspect := float32(width) / float32(height)
 	app.camPersp = camera.NewPerspective(65, aspect, 0.01, 1000)
 
@@ -382,8 +393,8 @@ func (app *Application) Run() error {
 
 	// Set swap interval
 	if *app.swapInterval >= 0 {
-		app.win.SwapInterval(*app.swapInterval)
-		app.log.Debug("Swap interval set to:%v", *app.swapInterval)
+		app.wmgr.SetSwapInterval(*app.swapInterval)
+		app.log.Debug("Swap interval set to: %v", *app.swapInterval)
 	}
 
 	// Start profiling if requested
@@ -392,12 +403,28 @@ func (app *Application) Run() error {
 		if err != nil {
 			return err
 		}
+		defer f.Close()
 		err = pprof.StartCPUProfile(f)
 		if err != nil {
 			return err
 		}
-		app.log.Info("Started writing CPU profile to:%s", *app.cpuProfile)
 		defer pprof.StopCPUProfile()
+		app.log.Info("Started writing CPU profile to: %s", *app.cpuProfile)
+	}
+
+	// Start execution trace if requested
+	if *app.execTrace != "" {
+		f, err := os.Create(*app.execTrace)
+		if err != nil {
+			return err
+		}
+		defer f.Close()
+		err = trace.Start(f)
+		if err != nil {
+			return err
+		}
+		defer trace.Stop()
+		app.log.Info("Started writing execution trace to: %s", *app.execTrace)
 	}
 
 	app.startTime = time.Now()
@@ -431,7 +458,7 @@ func (app *Application) Run() error {
 		}
 
 		// Poll input events and process them
-		app.win.PollEvents()
+		app.wmgr.PollEvents()
 
 		if rendered {
 			app.win.SwapBuffers()
@@ -440,10 +467,29 @@ func (app *Application) Run() error {
 		// Dispatch after render event
 		app.Dispatch(OnAfterRender, nil)
 
-		// Controls the frame rate and updates the FPS for the user
+		// Controls the frame rate
 		app.frameRater.Wait()
 		app.frameCount++
 	}
+
+	// Close default audio device
+	if app.audioDev != nil {
+		err := al.CloseDevice(app.audioDev)
+		if err != nil {
+			app.log.Error("Error closing audio device: %v", err)
+		}
+	}
+
+	// Dispose GL resources
+	if app.scene != nil {
+		app.scene.DisposeChildren(true)
+	}
+	if app.guiroot != nil {
+		app.guiroot.DisposeChildren(true)
+	}
+
+	// Terminates window manager
+	app.wmgr.Terminate()
 	return nil
 }
 
@@ -457,7 +503,7 @@ func (app *Application) Quit() {
 func (app *Application) OnWindowResize() {
 
 	// Get window size and sets the viewport to the same size
-	width, height := app.win.GetSize()
+	width, height := app.win.Size()
 	app.gl.Viewport(0, 0, int32(width), int32(height))
 
 	// Sets perspective camera aspect ratio

+ 149 - 117
window/glfw.go

@@ -11,9 +11,21 @@ import (
 	"github.com/go-gl/glfw/v3.2/glfw"
 )
 
-type GLFW struct {
-	core.Dispatcher
-	win             *glfw.Window
+// glfwManager contains data shared by all windows
+type glfwManager struct {
+	arrowCursor     *glfw.Cursor // Preallocated standard arrow cursor
+	ibeamCursor     *glfw.Cursor // Preallocated standard ibeam cursor
+	crosshairCursor *glfw.Cursor // Preallocated standard cross hair cursor
+	handCursor      *glfw.Cursor // Preallocated standard hand cursor
+	hresizeCursor   *glfw.Cursor // Preallocated standard horizontal resize cursor
+	vresizeCursor   *glfw.Cursor // Preallocated standard vertical resize cursor
+}
+
+// glfwWindow describes one glfw window
+type glfwWindow struct {
+	core.Dispatcher              // Embedded event dispatcher
+	win             *glfw.Window // Pointer to native glfw window
+	mgr             *glfwManager // Pointer to window manager
 	keyEv           KeyEvent
 	charEv          CharEvent
 	mouseEv         MouseEvent
@@ -21,12 +33,6 @@ type GLFW struct {
 	sizeEv          SizeEvent
 	cursorEv        CursorEvent
 	scrollEv        ScrollEvent
-	arrowCursor     *glfw.Cursor
-	ibeamCursor     *glfw.Cursor
-	crosshairCursor *glfw.Cursor
-	handCursor      *glfw.Cursor
-	hresizeCursor   *glfw.Cursor
-	vresizeCursor   *glfw.Cursor
 	fullScreen      bool
 	lastX           int
 	lastY           int
@@ -34,33 +40,70 @@ type GLFW struct {
 	lastHeight      int
 }
 
-// Global GLFW initialization flag
-// is initialized when the first window is created
-var initialized bool = false
+// glfw manager singleton
+var manager *glfwManager
 
-func newGLFW(width, height int, title string, full bool) (*GLFW, error) {
+// Glfw returns the glfw window manager
+func Glfw() (IWindowManager, error) {
 
-	// Initialize GLFW once before the first window is created
-	if !initialized {
-		err := glfw.Init()
-		if err != nil {
-			return nil, err
-		}
-		// Sets window hints
-		glfw.WindowHint(glfw.ContextVersionMajor, 3)
-		glfw.WindowHint(glfw.ContextVersionMinor, 3)
-		glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
-		glfw.WindowHint(glfw.Samples, 8)
-		// Sets OpenGL forward compatible context only for OSX because it is required for OSX.
-		// When this is set glLineWidth(width) only accepts width=1.0 and generates error
-		// for any other values although the spec says it should ignore non supported widths
-		// and generate error only when width <= 0.
-		if runtime.GOOS == "darwin" {
-			glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
-		}
-		initialized = true
+	if manager != nil {
+		return manager, nil
+	}
+
+	// Initialize glfw
+	err := glfw.Init()
+	if err != nil {
+		return nil, err
 	}
 
+	// Sets window hints
+	glfw.WindowHint(glfw.ContextVersionMajor, 3)
+	glfw.WindowHint(glfw.ContextVersionMinor, 3)
+	glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
+	glfw.WindowHint(glfw.Samples, 8)
+	// Sets OpenGL forward compatible context only for OSX because it is required for OSX.
+	// When this is set glLineWidth(width) only accepts width=1.0 and generates error
+	// for any other values although the spec says it should ignore non supported widths
+	// and generate error only when width <= 0.
+	if runtime.GOOS == "darwin" {
+		glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
+	}
+
+	manager = new(glfwManager)
+	return manager, nil
+}
+
+// ScreenResolution returns the screen resolution
+func (m *glfwManager) ScreenResolution(p interface{}) (width, height int) {
+
+	mon := glfw.GetPrimaryMonitor()
+	vmode := mon.GetVideoMode()
+	return vmode.Width, vmode.Height
+}
+
+// PollEvents process events in the event queue
+func (m *glfwManager) PollEvents() {
+
+	glfw.PollEvents()
+}
+
+// SetSwapInterval sets the number of screen updates to wait from the time SwapBuffer()
+// is called before swapping the buffers and returning.
+func (m *glfwManager) SetSwapInterval(interval int) {
+
+	glfw.SwapInterval(interval)
+}
+
+// Terminate destroys any remainding window, cursors and other related objects.
+func (m *glfwManager) Terminate() {
+
+	glfw.Terminate()
+	manager = nil
+}
+
+// CreateWindow creates and returns a new window with the specified width and height in screen coordinates
+func (m *glfwManager) CreateWindow(width, height int, title string, fullscreen bool) (IWindow, error) {
+
 	// Creates window and sets it as the current context.
 	// The window is created always as not full screen because if it is
 	// created as full screen it not possible to revert it to windowed mode.
@@ -72,8 +115,9 @@ func newGLFW(width, height int, title string, full bool) (*GLFW, error) {
 	win.MakeContextCurrent()
 
 	// Create wrapper window with dispacher
-	w := new(GLFW)
+	w := new(glfwWindow)
 	w.win = win
+	w.mgr = m
 	w.Dispatcher.Initialize()
 
 	// Set key callback to dispatch event
@@ -164,92 +208,34 @@ func newGLFW(width, height int, title string, full bool) (*GLFW, error) {
 	})
 
 	// Preallocate standard cursors
-	w.arrowCursor = glfw.CreateStandardCursor(glfw.ArrowCursor)
-	w.ibeamCursor = glfw.CreateStandardCursor(glfw.IBeamCursor)
-	w.crosshairCursor = glfw.CreateStandardCursor(glfw.CrosshairCursor)
-	w.handCursor = glfw.CreateStandardCursor(glfw.HandCursor)
-	w.hresizeCursor = glfw.CreateStandardCursor(glfw.HResizeCursor)
-	w.vresizeCursor = glfw.CreateStandardCursor(glfw.VResizeCursor)
+	w.mgr.arrowCursor = glfw.CreateStandardCursor(glfw.ArrowCursor)
+	w.mgr.ibeamCursor = glfw.CreateStandardCursor(glfw.IBeamCursor)
+	w.mgr.crosshairCursor = glfw.CreateStandardCursor(glfw.CrosshairCursor)
+	w.mgr.handCursor = glfw.CreateStandardCursor(glfw.HandCursor)
+	w.mgr.hresizeCursor = glfw.CreateStandardCursor(glfw.HResizeCursor)
+	w.mgr.vresizeCursor = glfw.CreateStandardCursor(glfw.VResizeCursor)
 
 	// Sets full screen if requested
-	if full {
+	if fullscreen {
 		w.SetFullScreen(true)
 	}
 	return w, nil
 }
 
-// GetScreenResolution returns the resolution of the primary screen in pixels.
-// The parameter is currently ignored
-func (w *GLFW) GetScreenResolution(p interface{}) (width, height int) {
-
-	mon := glfw.GetPrimaryMonitor()
-	vmode := mon.GetVideoMode()
-	return vmode.Width, vmode.Height
-}
-
-func (w *GLFW) SwapInterval(interval int) {
-
-	glfw.SwapInterval(interval)
-}
-
-func (w *GLFW) MakeContextCurrent() {
+// MakeContextCurrent makes the OpenGL context of this window current on the calling thread
+func (w *glfwWindow) MakeContextCurrent() {
 
 	w.win.MakeContextCurrent()
 }
 
-func (w *GLFW) GetSize() (width int, height int) {
-
-	return w.win.GetSize()
-}
-
-func (w *GLFW) SetSize(width int, height int) {
-
-	w.win.SetSize(width, height)
-}
-
-func (w *GLFW) GetPos() (xpos, ypos int) {
-
-	return w.win.GetPos()
-}
-
-func (w *GLFW) SetPos(xpos, ypos int) {
-
-	w.win.SetPos(xpos, ypos)
-}
-
-func (w *GLFW) SetTitle(title string) {
-
-	w.win.SetTitle(title)
-}
-
-func (w *GLFW) SetStandardCursor(cursor StandardCursor) {
-
-	switch cursor {
-	case ArrowCursor:
-		w.win.SetCursor(w.arrowCursor)
-	case IBeamCursor:
-		w.win.SetCursor(w.ibeamCursor)
-	case CrosshairCursor:
-		w.win.SetCursor(w.crosshairCursor)
-	case HandCursor:
-		w.win.SetCursor(w.handCursor)
-	case HResizeCursor:
-		w.win.SetCursor(w.hresizeCursor)
-	case VResizeCursor:
-		w.win.SetCursor(w.vresizeCursor)
-	default:
-		panic("Invalid cursor")
-	}
-}
-
 // FullScreen returns this window full screen state for the primary monitor
-func (w *GLFW) FullScreen() bool {
+func (w *glfwWindow) FullScreen() bool {
 
 	return w.fullScreen
 }
 
 // SetFullScreen sets this window full screen state for the primary monitor
-func (w *GLFW) SetFullScreen(full bool) {
+func (w *glfwWindow) SetFullScreen(full bool) {
 
 	// If already in the desired state, nothing to do
 	if w.fullScreen == full {
@@ -275,35 +261,81 @@ func (w *GLFW) SetFullScreen(full bool) {
 	}
 }
 
-// ShouldClose returns the current state of this window  should close flag
-func (w *GLFW) ShouldClose() bool {
+// Destroy destroys this window and its context
+func (w *glfwWindow) Destroy() {
 
-	return w.win.ShouldClose()
+	w.win.Destroy()
+	w.win = nil
 }
 
-// SetShouldClose sets the state of this windows should close flag
-func (w *GLFW) SetShouldClose(v bool) {
+// SwapBuffers swaps the front and back buffers of this window.
+// If the swap interval is greater than zero,
+// the GPU driver waits the specified number of screen updates before swapping the buffers.
+func (w *glfwWindow) SwapBuffers() {
 
-	w.win.SetShouldClose(v)
+	w.win.SwapBuffers()
 }
 
-func (w *GLFW) SwapBuffers() {
+// Size returns this window size in screen coordinates
+func (w *glfwWindow) Size() (width int, height int) {
 
-	w.win.SwapBuffers()
+	return w.win.GetSize()
 }
 
-func (w *GLFW) Destroy() {
+// SetSize sets the size, in screen coordinates, of the client area of this window
+func (w *glfwWindow) SetSize(width int, height int) {
 
-	w.win.Destroy()
-	w.win = nil
+	w.win.SetSize(width, height)
 }
 
-func (w *GLFW) PollEvents() {
+// Pos returns the position, in screen coordinates, of the upper-left corner of the client area of this window
+func (w *glfwWindow) Pos() (xpos, ypos int) {
 
-	glfw.PollEvents()
+	return w.win.GetPos()
+}
+
+// SetPos sets the position, in screen coordinates, of the upper-left corner of the client area of this window.
+// If the window is a full screen window, this function does nothing.
+func (w *glfwWindow) SetPos(xpos, ypos int) {
+
+	w.win.SetPos(xpos, ypos)
 }
 
-func (w *GLFW) GetTime() float64 {
+// SetTitle sets this window title, encoded as UTF-8
+func (w *glfwWindow) SetTitle(title string) {
+
+	w.win.SetTitle(title)
+}
+
+// ShouldClose returns the current state of this window  should close flag
+func (w *glfwWindow) ShouldClose() bool {
+
+	return w.win.ShouldClose()
+}
+
+// SetShouldClose sets the state of this windows should close flag
+func (w *glfwWindow) SetShouldClose(v bool) {
 
-	return glfw.GetTime()
+	w.win.SetShouldClose(v)
+}
+
+// SetStandardCursor sets this window standard cursor type
+func (w *glfwWindow) SetStandardCursor(cursor StandardCursor) {
+
+	switch cursor {
+	case ArrowCursor:
+		w.win.SetCursor(w.mgr.arrowCursor)
+	case IBeamCursor:
+		w.win.SetCursor(w.mgr.ibeamCursor)
+	case CrosshairCursor:
+		w.win.SetCursor(w.mgr.crosshairCursor)
+	case HandCursor:
+		w.win.SetCursor(w.mgr.handCursor)
+	case HResizeCursor:
+		w.win.SetCursor(w.mgr.hresizeCursor)
+	case VResizeCursor:
+		w.win.SetCursor(w.mgr.vresizeCursor)
+	default:
+		panic("Invalid cursor")
+	}
 }

+ 32 - 32
window/window.go

@@ -2,10 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-/*
- Package window abstracts the OpenGL Window manager
- Currently only "glfw" is supported
-*/
+// Package window abstracts the OpenGL Window manager
+// Currently only "glfw" is supported
 package window
 
 import (
@@ -13,36 +11,37 @@ import (
 	"github.com/go-gl/glfw/v3.2/glfw"
 )
 
-//
-// Interface for all window managers
-//
+// IWindowManager is the interface for all window managers
+type IWindowManager interface {
+	ScreenResolution(interface{}) (width, height int)
+	CreateWindow(width, height int, title string, full bool) (IWindow, error)
+	SetSwapInterval(interval int)
+	PollEvents()
+	Terminate()
+}
+
+// IWindow is the interface for all windows
 type IWindow interface {
 	core.IDispatcher
-	GetScreenResolution(interface{}) (width, height int)
-	SwapInterval(interval int)
 	MakeContextCurrent()
-	GetSize() (width int, height int)
+	Size() (width int, height int)
 	SetSize(width int, height int)
-	GetPos() (xpos, ypos int)
+	Pos() (xpos, ypos int)
 	SetPos(xpos, ypos int)
 	SetTitle(title string)
 	SetStandardCursor(cursor StandardCursor)
-	SwapBuffers()
 	ShouldClose() bool
 	SetShouldClose(bool)
 	FullScreen() bool
 	SetFullScreen(bool)
+	SwapBuffers()
 	Destroy()
-	PollEvents()
-	GetTime() float64
 }
 
 // Key corresponds to a keyboard key.
 type Key int
 
-//
 // Keycodes (from glfw)
-//
 const (
 	KeyUnknown      = Key(glfw.KeyUnknown)
 	KeySpace        = Key(glfw.KeySpace)
@@ -215,9 +214,12 @@ const (
 type Action int
 
 const (
-	Release = Action(glfw.Release) // The key or button was released.
-	Press   = Action(glfw.Press)   // The key or button was pressed.
-	Repeat  = Action(glfw.Repeat)  // The key was held down until it repeated.
+	// Release indicates that key or mouse button was released
+	Release = Action(glfw.Release)
+	// Press indicates that key or mouse button was pressed
+	Press = Action(glfw.Press)
+	// Repeat indicates that key was held down until it repeated
+	Repeat = Action(glfw.Repeat)
 )
 
 // InputMode corresponds to an input mode.
@@ -254,21 +256,21 @@ const (
 	OnFrame      = "win.OnFrame"
 )
 
-// Window position changed event
+// PosEvent describes a windows position changed event
 type PosEvent struct {
 	W    IWindow
 	Xpos int
 	Ypos int
 }
 
-// Window size changed
+// SizeEvent describers a window size changed event
 type SizeEvent struct {
 	W      IWindow
 	Width  int
 	Height int
 }
 
-// Key pressed in window
+// KeyEvent describes a window key event
 type KeyEvent struct {
 	W        IWindow
 	Keycode  Key
@@ -277,14 +279,14 @@ type KeyEvent struct {
 	Mods     ModifierKey
 }
 
-// Char pressed in window
+// CharEvent describes a window char event
 type CharEvent struct {
 	W    IWindow
 	Char rune
 	Mods ModifierKey
 }
 
-// Mouse button event
+// MouseEvent describes a mouse event over the window
 type MouseEvent struct {
 	W      IWindow
 	Xpos   float32
@@ -294,28 +296,26 @@ type MouseEvent struct {
 	Mods   ModifierKey
 }
 
-// Cursor position changed
+// CursorEvent describes a cursor position changed event
 type CursorEvent struct {
 	W    IWindow
 	Xpos float32
 	Ypos float32
 }
 
-// Scroll event
+// ScrollEvent describes a scroll event
 type ScrollEvent struct {
 	W       IWindow
 	Xoffset float32
 	Yoffset float32
 }
 
-// New creates and returns a new window of the specified type, width, height and title.
-// If full is true, the window will be opened in full screen and the width and height
-// parameters will be ignored.
+// Manager returns the window manager for the specified type.
 // Currently only "glfw" type is supported.
-func New(wtype string, width, height int, title string, full bool) (IWindow, error) {
+func Manager(wtype string) (IWindowManager, error) {
 
 	if wtype != "glfw" {
-		panic("Unsupported window type")
+		panic("Unsupported window manager")
 	}
-	return newGLFW(width, height, title, full)
+	return Glfw()
 }