Documentation ¶
Index ¶
- Constants
- type Application
- func (app *Application) Camera() camera.ICamera
- func (app *Application) CameraOrtho() *camera.Orthographic
- func (app *Application) CameraPersp() *camera.Perspective
- func (app *Application) FrameCount() uint64
- func (app *Application) FrameDelta() time.Duration
- func (app *Application) FrameDeltaSeconds() float32
- func (app *Application) FrameRater() *FrameRater
- func (app *Application) Gl() *gls.GLS
- func (app *Application) Gui() *gui.Root
- func (app *Application) KeyState() *KeyState
- func (app *Application) Log() *logger.Logger
- func (app *Application) OnWindowResize()
- func (app *Application) OpenDefaultAudioDevice() error
- func (app *Application) Orbit() *control.OrbitControl
- func (app *Application) Panel3D() gui.IPanel
- func (app *Application) Quit()
- func (app *Application) Renderer() *renderer.Renderer
- func (app *Application) Run() error
- func (app *Application) RunSeconds() float32
- func (app *Application) RunTime() time.Duration
- func (app *Application) Scene() *core.Node
- func (app *Application) SetCPUProfile(fname string)
- func (app *Application) SetCamera(cam camera.ICamera)
- func (app *Application) SetGui(root *gui.Root)
- func (app *Application) SetOnWindowResize(f func(evname string, ev interface{}))
- func (app *Application) SetOrbit(oc *control.OrbitControl)
- func (app *Application) SetPanel3D(panel3D gui.IPanel)
- func (app *Application) SetScene(scene *core.Node)
- func (app *Application) Window() window.IWindow
- type FrameRater
- type KeyState
- type Options
Constants ¶
const OnAfterRender = "util.application.OnAfterRender"
OnAfterRender is the event generated by Application just after rendering the scene/gui
const OnBeforeRender = "util.application.OnBeforeRender"
OnBeforeRender is the event generated by Application just before rendering the scene/gui
const OnQuit = "util.application.OnQuit"
OnQuit is the event generated by Application when the user tries to close the window or the Quit() method is called.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct { core.Dispatcher // Embedded event dispatcher core.TimerManager // Embedded timer manager // contains filtered or unexported fields }
Application is a standard application object which can be used as a base for G3N applications. It creates a Window, OpenGL state, default cameras, default scene and Gui and has a method to run the render loop.
func Create ¶
func Create(ops Options) (*Application, error)
Create creates and returns the application object using the specified options. This function must be called only once.
func Get ¶
func Get() *Application
Get returns the application single instance or nil if the application was not created yet
func (*Application) Camera ¶
func (app *Application) Camera() camera.ICamera
Camera returns the current application camera
func (*Application) CameraOrtho ¶
func (app *Application) CameraOrtho() *camera.Orthographic
CameraOrtho returns the application orthographic camera
func (*Application) CameraPersp ¶
func (app *Application) CameraPersp() *camera.Perspective
CameraPersp returns the application perspective camera
func (*Application) FrameCount ¶
func (app *Application) FrameCount() uint64
FrameCount returns the total number of frames since the call to Run()
func (*Application) FrameDelta ¶
func (app *Application) FrameDelta() time.Duration
FrameDelta returns the duration of the previous frame
func (*Application) FrameDeltaSeconds ¶
func (app *Application) FrameDeltaSeconds() float32
FrameDeltaSeconds returns the duration of the previous frame in float32 seconds
func (*Application) FrameRater ¶
func (app *Application) FrameRater() *FrameRater
FrameRater returns the FrameRater object
func (*Application) Gui ¶
func (app *Application) Gui() *gui.Root
Gui returns the current application Gui root panel
func (*Application) KeyState ¶
func (app *Application) KeyState() *KeyState
KeyState returns the application KeyState
func (*Application) Log ¶
func (app *Application) Log() *logger.Logger
Log returns the application logger
func (*Application) OnWindowResize ¶
func (app *Application) OnWindowResize()
OnWindowResize is default handler for window resize events.
func (*Application) OpenDefaultAudioDevice ¶
func (app *Application) OpenDefaultAudioDevice() error
OpenDefaultAudioDevice opens the default audio device setting it to the current context
func (*Application) Orbit ¶
func (app *Application) Orbit() *control.OrbitControl
Orbit returns the current camera orbit control
func (*Application) Panel3D ¶
func (app *Application) Panel3D() gui.IPanel
Panel3D returns the current gui panel where the 3D scene is shown.
func (*Application) Quit ¶
func (app *Application) Quit()
Quit requests to terminate the application Application will dispatch OnQuit events to registered subscriber which can cancel the process by calling CancelDispatch().
func (*Application) Renderer ¶
func (app *Application) Renderer() *renderer.Renderer
Renderer returns the application renderer
func (*Application) RunSeconds ¶
func (app *Application) RunSeconds() float32
RunSeconds returns the elapsed time in seconds since the call to Run()
func (*Application) RunTime ¶
func (app *Application) RunTime() time.Duration
RunTime returns the duration since the call to Run()
func (*Application) Scene ¶
func (app *Application) Scene() *core.Node
Scene returns the current application 3D scene
func (*Application) SetCPUProfile ¶
func (app *Application) SetCPUProfile(fname string)
SetCPUProfile must be called before Run() and sets the file name for cpu profiling. If set the cpu profiling starts before running the render loop and continues till the end of the application.
func (*Application) SetCamera ¶
func (app *Application) SetCamera(cam camera.ICamera)
SetCamera sets the current application camera
func (*Application) SetGui ¶
func (app *Application) SetGui(root *gui.Root)
SetGui sets the root panel of the gui to be rendered
func (*Application) SetOnWindowResize ¶
func (app *Application) SetOnWindowResize(f func(evname string, ev interface{}))
SetOnWindowResize replaces the default window resize handler with the specified one
func (*Application) SetOrbit ¶
func (app *Application) SetOrbit(oc *control.OrbitControl)
SetOrbit sets the camera orbit control
func (*Application) SetPanel3D ¶
func (app *Application) SetPanel3D(panel3D gui.IPanel)
SetPanel3D sets the gui panel inside which the 3D scene is shown.
func (*Application) SetScene ¶
func (app *Application) SetScene(scene *core.Node)
SetScene sets the 3D scene to be rendered
func (*Application) Window ¶
func (app *Application) Window() window.IWindow
Window returns the application window
type FrameRater ¶
type FrameRater struct {
// contains filtered or unexported fields
}
FrameRater implements a frame rate controller
func NewFrameRater ¶
func NewFrameRater(targetFPS uint) *FrameRater
NewFrameRater returns a frame rate controller object for the specified number of target frames per second
func (*FrameRater) FPS ¶
FPS calculates and returns the current measured FPS and the maximum potential FPS after the specified time interval has elapsed. It returns an indication if the results are valid
func (*FrameRater) Start ¶
func (f *FrameRater) Start()
Start should be called at the start of the frame
func (*FrameRater) Wait ¶
func (f *FrameRater) Wait()
Wait should be called at the end of the frame If necessary it will sleep to achieve the desired frame rate
type KeyState ¶
type KeyState struct {
// contains filtered or unexported fields
}
KeyState keeps track of the state of all keys.
func NewKeyState ¶
NewKeyState returns a new KeyState object.
type Options ¶
type Options struct { 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) }
Options defines initial options passed to the application creation function