|
@@ -54,12 +54,14 @@ type Application struct {
|
|
|
|
|
|
|
|
// Options defines initial options passed to the application creation function
|
|
// Options defines initial options passed to the application creation function
|
|
|
type Options struct {
|
|
type Options struct {
|
|
|
- Height int // Initial window height (default is screen width)
|
|
|
|
|
- Width int // Initial window width (default is screen height)
|
|
|
|
|
- Fullscreen bool // Window full screen flag (default = false)
|
|
|
|
|
- LogLevel int // Initial log level (default = DEBUG)
|
|
|
|
|
- EnableFlags bool // Enable command line flags (default = false)
|
|
|
|
|
- TargetFPS uint // Desired frames per second rate (default = 60)
|
|
|
|
|
|
|
+ Title string // Initial window title
|
|
|
|
|
+ Height int // Initial window height (default is screen width)
|
|
|
|
|
+ Width int // Initial window width (default is screen height)
|
|
|
|
|
+ Fullscreen bool // Window full screen flag (default = false)
|
|
|
|
|
+ LogPrefix string // Log prefix (default = "")
|
|
|
|
|
+ LogLevel int // Initial log level (default = DEBUG)
|
|
|
|
|
+ EnableFlags bool // Enable command line flags (default = false)
|
|
|
|
|
+ TargetFPS uint // Desired frames per second rate (default = 60)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// OnBeforeRender is the event generated by Application just before rendering the scene/gui
|
|
// OnBeforeRender is the event generated by Application just before rendering the scene/gui
|
|
@@ -71,10 +73,9 @@ const OnAfterRender = "util.application.OnAfterRender"
|
|
|
// appInstance contains the pointer to the single Application instance
|
|
// appInstance contains the pointer to the single Application instance
|
|
|
var appInstance *Application
|
|
var appInstance *Application
|
|
|
|
|
|
|
|
-// Create creates and returns the application object using the specified name for
|
|
|
|
|
-// the window title and log messages
|
|
|
|
|
|
|
+// Create creates and returns the application object using the specified options.
|
|
|
// This function must be called only once.
|
|
// This function must be called only once.
|
|
|
-func Create(name string, ops Options) (*Application, error) {
|
|
|
|
|
|
|
+func Create(ops Options) (*Application, error) {
|
|
|
|
|
|
|
|
if appInstance != nil {
|
|
if appInstance != nil {
|
|
|
return nil, fmt.Errorf("Application already created")
|
|
return nil, fmt.Errorf("Application already created")
|
|
@@ -112,7 +113,7 @@ func Create(name string, ops Options) (*Application, error) {
|
|
|
flag.Parse()
|
|
flag.Parse()
|
|
|
|
|
|
|
|
// Creates application logger
|
|
// Creates application logger
|
|
|
- app.log = logger.New(name, nil)
|
|
|
|
|
|
|
+ app.log = logger.New(ops.LogPrefix, nil)
|
|
|
app.log.AddWriter(logger.NewConsole(false))
|
|
app.log.AddWriter(logger.NewConsole(false))
|
|
|
app.log.SetFormat(logger.FTIME | logger.FMICROS)
|
|
app.log.SetFormat(logger.FTIME | logger.FMICROS)
|
|
|
app.log.SetLevel(ops.LogLevel)
|
|
app.log.SetLevel(ops.LogLevel)
|
|
@@ -149,7 +150,7 @@ func Create(name string, ops Options) (*Application, error) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Creates window
|
|
// Creates window
|
|
|
- win, err := app.wmgr.CreateWindow(swidth, sheight, name, *app.fullScreen)
|
|
|
|
|
|
|
+ win, err := app.wmgr.CreateWindow(swidth, sheight, ops.Title, *app.fullScreen)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|