Version: v0.15.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type Window

type Window struct {
	Window    *sdl.Window
	WindowID  uint32
	GLContext sdl.GLContext
	Backend   *goglbackend.GoGLBackend

	Event      func(event sdl.Event)
	MouseDown  func(button, x, y int)
	MouseMove  func(x, y int)
	MouseUp    func(button, x, y int)
	MouseWheel func(x, y int)
	KeyDown    func(scancode int, rn rune, name string)
	KeyUp      func(scancode int, rn rune, name string)
	KeyChar    func(rn rune)
	SizeChange func(w, h int)
	// contains filtered or unexported fields

Window represents the opened window with GL context. The Mouse* and Key* functions can be set for callbacks

func CreateWindow

func CreateWindow(w, h int, title string) (*Window, *canvas.Canvas, error)

CreateWindow creates a window using SDL and initializes the OpenGL context

func (*Window) Close

func (wnd *Window) Close()

Close can be used to end a call to MainLoop

func (*Window) Destroy

func (wnd *Window) Destroy()

Destroy destroys the GL context and the window

func (*Window) FPS

func (wnd *Window) FPS() float32

FPS returns the frames per second (averaged over 10 frames)

func (*Window) FinishFrame

func (wnd *Window) FinishFrame()

FinishFrame updates the FPS count and displays the frame

func (*Window) FramebufferSize

func (wnd *Window) FramebufferSize() (int, int)

FramebufferSize returns the current width and height of the framebuffer, which is also the internal size of the canvas

func (*Window) MainLoop

func (wnd *Window) MainLoop(run func())

MainLoop runs a main loop and calls run on every frame

func (*Window) Size

func (wnd *Window) Size() (int, int)

Size returns the current width and height of the window. Note that this size may not be the same as the size of the framebuffer, since some operating systems scale the window. Use the Width/Height/Size function on Canvas to determine the drawing size

func (*Window) StartFrame

func (wnd *Window) StartFrame() error

StartFrame handles events and gets the window ready for rendering

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL