Documentation
¶
Overview ¶
Mandala is a framework for writing Android native applications in Go using the Goandroid[1] toolchain. You can develop, test and run your application on your desktop and then deploy it to an Android device. It encourages the use of idiomatic Go for writing Android applications: communication happens through channels, no callbacks. The framework is not to be considered as an high-level game engine but as a basic layer onto which game engines can be build or existing ones can be used. In my opinion, this opens interesting scenarios in the developing of native Android applications/games in Go. Goandroid's native_activity[2] example was the initial source of inspiration for this project.
Please consider that Mandala is in a very early stage of development: API will change, test coverage is not so good for now. Last but not least, Go doesn't officially supports native Android development. Regarding this point, I hope that the present work could act as a sort of incentive in the direction of an official Android support by the Go Team.
Have a nice Mandala!
[1] - https://github.com/eliasnaur/goandroid
[2] - https://github.com/eliasnaur/goandroid/tree/master/native-activity
Index ¶
- Constants
- Variables
- func Debugf(format string, v ...interface{})
- func Events() <-chan interface{}
- func Fatalf(format string, v ...interface{})
- func Init(window *glfw.Window)
- func Logf(format string, v ...interface{})
- func ReadResource(filename string, responseCh chan LoadResourceResponse)
- func ResourceManager() chan<- interface{}
- func Stacktrace() string
- type ActionMoveEvent
- type ActionUpDownEvent
- type AudioPlayer
- type ConfigurationChangedEvent
- type CreateEvent
- type DestroyEvent
- type LoadResourceRequest
- type LoadResourceResponse
- type NativeWindowCreatedEvent
- type NativeWindowDestroyedEvent
- type NativeWindowRedrawNeededEvent
- type NativeWindowResizedEvent
- type PauseEvent
- type ResumeEvent
- type StartEvent
- type Window
- type WindowFocusChangedEvent
Constants ¶
const ( // The number of event messages buffered by the event // channel. This is an heuristic value. NumOfBufferedEvents = 10 )
Variables ¶
var ( // If Verbose is true Logf will print on the stdout. Verbose bool // If Debug is true Debugf will print on the stdout. Debug bool )
var ( // The path in which the framework will search for resources. ResourcePath string = "android/res" )
Functions ¶
func Debugf ¶
func Debugf(format string, v ...interface{})
If Debug is true then Debugf will print on stdout.
func Events ¶
func Events() <-chan interface{}
Events() returns a receive-only channel from which client-code receive events. Events are sent in the form of anonymous interfaces. Please refer to events.go for a complete list of the supported events. For a worthwhile reading take a look a this document by NVIDIA:
http://developer.download.nvidia.com/assets/mobile/files/AndroidLifecycleAppNote_v100.pdf
func Init ¶
Init initializes a glfw.Window to be used in a xorg Mandala application. It has to be called after the GLFW initialization boilerplate. See https://github.com/remogatto/mandala-examples/triangle/src/triangle/main.go for an example.
func Logf ¶
func Logf(format string, v ...interface{})
If Verbose is true then Logf will print on stdout.
func ReadResource ¶
func ReadResource(filename string, responseCh chan LoadResourceResponse)
ReadResource reads a resource named filename and send the response to the given responseCh channel.
func ResourceManager ¶
func ResourceManager() chan<- interface{}
ResourceManager() returns a send-only channel to which client-code send request for resources. Please refer to resourcemanager.go for a complete list of supported requests.
func Stacktrace ¶
func Stacktrace() string
Stacktrace returns the stacktrace of the goroutine that calls it.
Types ¶
type ActionMoveEvent ¶
type ActionMoveEvent struct { Activity unsafe.Pointer // Coordinates of the touched point in movement X, Y float32 }
ActionMoveEvent is triggered when the user moves the finger on the device surface.
type ActionUpDownEvent ¶
type ActionUpDownEvent struct { Activity unsafe.Pointer // The finger is down on the surface Down bool // Coordinates of the touched point X, Y float32 }
ActionUpDownEvent is triggered when the user has the finger down/up the device's surface.
type AudioPlayer ¶
type AudioPlayer struct {
// contains filtered or unexported fields
}
func NewAudioPlayer ¶
func NewAudioPlayer() (*AudioPlayer, error)
CreateAudioPlayer instantiates a player for the given filename.
func (*AudioPlayer) Destroy ¶
func (ap *AudioPlayer) Destroy()
func (*AudioPlayer) GetMaxVolumeLevel ¶
func (ap *AudioPlayer) GetMaxVolumeLevel() (int, error)
GetVolumeScale returns the [min,max] values for volume. If the device doesn't support volume controls, it returns an error.
func (*AudioPlayer) Play ¶
func (ap *AudioPlayer) Play(buffer []byte, doneCh chan bool)
Play tells the player to play the named track and send a value to doneCh when done. The channel can be nil, in that case nothing is sent to it.
func (*AudioPlayer) SetVolumeLevel ¶
func (ap *AudioPlayer) SetVolumeLevel(value int) error
SetVolume sets the volume for the player.
type ConfigurationChangedEvent ¶
A ConfigurationChangedEvent is triggered when the application changes its configuration.
type CreateEvent ¶
CreateEvent is the first event triggered by the application.
type DestroyEvent ¶
DestroyEvent is the last event triggered by the application before terminate.
type LoadResourceRequest ¶
type LoadResourceRequest struct { // The path of the resource file, for example // "res/drawable/gopher.png". ResourcePath will be prefixed to // Filename. Filename string // Response is a channel for receiving the response from the // resource manager. Response chan LoadResourceResponse }
The type of request to send to ResourceManager in order to read the resource.
type LoadResourceResponse ¶
type NativeWindowCreatedEvent ¶
A NativeWindowCreatedEvent is triggered when the native window is created. It indicates that the native surface is ready for rendering.
type NativeWindowDestroyedEvent ¶
A NativeWindowDestroyedEvent is triggered when the native window is destroyed and nothing can be rendered on it anymore.
type NativeWindowRedrawNeededEvent ¶
A NativeWindowRedrawNeededEvent is triggered when the native window needs to be redrawn.
type NativeWindowResizedEvent ¶
A NativeWindowResizedEvent is triggered when the native window is resized. It happens, for example, when the device is rotated.
type PauseEvent ¶
A PauseEvent is triggered when the application is paused. It happens, for example, when the back button is pressed and the application goes in background. Please note that the framework will wait for a value from Paused channel before actually pause the application.
type ResumeEvent ¶
A ResumeEvent is triggered when the application goes foreground. This doesn't mean that a native surface is ready for rendering.
type StartEvent ¶
A StartEvent is triggered after a CreateEvent. It initiates the "visible" lifespan of the application.
type Window ¶
type Window interface { // Swap display <-> surface buffers. SwapBuffers() // Bind context to the current rendering thread. MakeContextCurrent() // Get the size of the window as width,height values. GetSize() (int, int) }
Window is an interface that abstracts native EGL surfaces.
type WindowFocusChangedEvent ¶
A WindowFocusChangedEvent is triggered when the native window gain or lost its focus.