engine: github.com/g3n/engine/util/application Index | Files

package application

import "github.com/g3n/engine/util/application"

Index

Package Files

application.go framerater.go keystate.go

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.

type Application Uses

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 Uses

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 Uses

func Get() *Application

Get returns the application single instance or nil if the application was not created yet

func (*Application) Camera Uses

func (app *Application) Camera() camera.ICamera

Camera returns the current application camera

func (*Application) CameraOrtho Uses

func (app *Application) CameraOrtho() *camera.Orthographic

CameraOrtho returns the application orthographic camera

func (*Application) CameraPersp Uses

func (app *Application) CameraPersp() *camera.Perspective

CameraPersp returns the application perspective camera

func (*Application) FrameCount Uses

func (app *Application) FrameCount() uint64

FrameCount returns the total number of frames since the call to Run()

func (*Application) FrameDelta Uses

func (app *Application) FrameDelta() time.Duration

FrameDelta returns the duration of the previous frame

func (*Application) FrameDeltaSeconds Uses

func (app *Application) FrameDeltaSeconds() float32

FrameDeltaSeconds returns the duration of the previous frame in float32 seconds

func (*Application) FrameRater Uses

func (app *Application) FrameRater() *FrameRater

FrameRater returns the FrameRater object

func (*Application) Gl Uses

func (app *Application) Gl() *gls.GLS

Gl returns the OpenGL state

func (*Application) Gui Uses

func (app *Application) Gui() *gui.Root

Gui returns the current application Gui root panel

func (*Application) KeyState Uses

func (app *Application) KeyState() *KeyState

KeyState returns the application KeyState

func (*Application) Log Uses

func (app *Application) Log() *logger.Logger

Log returns the application logger

func (*Application) OnWindowResize Uses

func (app *Application) OnWindowResize()

OnWindowResize is default handler for window resize events.

func (*Application) OpenDefaultAudioDevice Uses

func (app *Application) OpenDefaultAudioDevice() error

OpenDefaultAudioDevice opens the default audio device setting it to the current context

func (*Application) Orbit Uses

func (app *Application) Orbit() *control.OrbitControl

Orbit returns the current camera orbit control

func (*Application) Panel3D Uses

func (app *Application) Panel3D() gui.IPanel

Panel3D returns the current gui panel where the 3D scene is shown.

func (*Application) Quit Uses

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 Uses

func (app *Application) Renderer() *renderer.Renderer

Renderer returns the application renderer

func (*Application) Run Uses

func (app *Application) Run() error

Run runs the application render loop

func (*Application) RunSeconds Uses

func (app *Application) RunSeconds() float32

RunSeconds returns the elapsed time in seconds since the call to Run()

func (*Application) RunTime Uses

func (app *Application) RunTime() time.Duration

RunTime returns the duration since the call to Run()

func (*Application) Scene Uses

func (app *Application) Scene() *core.Node

Scene returns the current application 3D scene

func (*Application) SetCPUProfile Uses

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 Uses

func (app *Application) SetCamera(cam camera.ICamera)

SetCamera sets the current application camera

func (*Application) SetGui Uses

func (app *Application) SetGui(root *gui.Root)

SetGui sets the root panel of the gui to be rendered

func (*Application) SetOnWindowResize Uses

func (app *Application) SetOnWindowResize(f func(evname string, ev interface{}))

SetOnWindowResize replaces the default window resize handler with the specified one

func (*Application) SetOrbit Uses

func (app *Application) SetOrbit(oc *control.OrbitControl)

SetOrbit sets the camera orbit control

func (*Application) SetPanel3D Uses

func (app *Application) SetPanel3D(panel3D gui.IPanel)

SetPanel3D sets the gui panel inside which the 3D scene is shown.

func (*Application) SetScene Uses

func (app *Application) SetScene(scene *core.Node)

SetScene sets the 3D scene to be rendered

func (*Application) Window Uses

func (app *Application) Window() window.IWindow

Window returns the application window

type FrameRater Uses

type FrameRater struct {
    // contains filtered or unexported fields
}

FrameRater implements a frame rate controller

func NewFrameRater Uses

func NewFrameRater(targetFPS uint) *FrameRater

NewFrameRater returns a frame rate controller object for the specified number of target frames per second

func (*FrameRater) FPS Uses

func (f *FrameRater) FPS(t time.Duration) (float64, float64, bool)

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 Uses

func (f *FrameRater) Start()

Start should be called at the start of the frame

func (*FrameRater) Wait Uses

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 Uses

type KeyState struct {
    // contains filtered or unexported fields
}

KeyState keeps track of the state of all keys.

func NewKeyState Uses

func NewKeyState(win window.IWindow) *KeyState

NewKeyState returns a new KeyState object.

func (*KeyState) Dispose Uses

func (ks *KeyState) Dispose()

Dispose unsubscribes from the window events.

func (*KeyState) Pressed Uses

func (ks *KeyState) Pressed(k window.Key) bool

Pressed returns whether the specified key is currently pressed.

type Options Uses

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

Package application imports 18 packages (graph) and is imported by 2 packages. Updated 2019-02-26. Refresh now. Tools for package owners.