github.com/rajveermalviya/gamen@v0.1.2-0.20220930195403-9be15877c1aa/display/display_web.go (about)

     1  //go:build js
     2  
     3  package display
     4  
     5  import (
     6  	"syscall/js"
     7  
     8  	"github.com/rajveermalviya/gamen/internal/web"
     9  )
    10  
    11  // NewDisplay initializes the event loop and returns
    12  // a handle to manage it.
    13  //
    14  // Must only be called from main goroutine.
    15  func NewDisplay() (Display, error) {
    16  	return web.NewDisplay()
    17  }
    18  
    19  // NewWindow creates a new window for the provided
    20  // display event loop.
    21  //
    22  // To receive events you must set individual callbacks
    23  // via Set[event]Callback methods.
    24  //
    25  // Must only be called from main goroutine.
    26  func NewWindow(d Display) (Window, error) {
    27  	return web.NewWindow(d.(*web.Display))
    28  }
    29  
    30  type WebWindow interface {
    31  	WebCanvas() js.Value
    32  }