Example #1
0
func onPaint(glctx gl.Context, sz size.Event) {
	glctx.ClearColor(1, 1, 1, 1)
	glctx.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(startTime) * 60 / time.Second)
	game.Update(now)
	eng.Render(scene, now, sz)
}
Example #2
0
func onPaint(glctx gl.Context, sz size.Event) {
	glctx.ClearColor(1, 1, 1, 1) // white background
	glctx.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(startTime) * 60 / time.Second)
	eng.Render(scene, now, sz)
	fps.Draw(sz)
}
Example #3
0
func onPaint(glctx gl.Context, sz size.Event) {
	glctx.ClearColor(1, 1, 1, 1)                                // クリアする色
	glctx.Clear(gl.COLOR_BUFFER_BIT)                            // 塗りつぶし?
	now := clock.Time(time.Since(startTime) * 60 / time.Second) // 60FramePerSecで計算し、現在のフレームを計算する
	game.Update(now)
	eng.Render(scene, now, sz)
}
Example #4
0
func main() {
	app.Main(func(a app.App) {
		var c event.Config
		var eng *WritableEngine
		var root *sprite.Node
		startClock := time.Now()
		for e := range a.Events() {
			switch e := event.Filter(e).(type) {
			case event.Config:
				c = e
			case event.Draw:
				if eng == nil || root == nil {
					eng = NewWritableEngine(
						glsprite.Engine(),
						image.Rect(0, 0, int(c.Width.Px(c.PixelsPerPt)), int(c.Height.Px(c.PixelsPerPt))),
						color.White,
					)
					root = loadScene(eng, loadTextures(eng))
					go listen(eng, ":8080")
				}
				now := clock.Time(time.Since(startClock) * 60 / time.Second)
				gl.ClearColor(1, 1, 1, 1)
				gl.Clear(gl.COLOR_BUFFER_BIT)
				gl.Enable(gl.BLEND)
				gl.BlendEquation(gl.FUNC_ADD)
				gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
				if eng != nil && root != nil {
					eng.Render(root, now, c)
				}
				a.EndDraw()
			}
		}
	})
}
Example #5
0
func onPaint(glctx gl.Context, sz size.Event) {
	glctx.ClearColor(0, 0, 0, 1)
	glctx.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(startTime) * 60 / time.Second)
	eng.Render(scene, now, sz)
	log.Draw(sz)
}
Example #6
0
func (e *Engine) Render(sz size.Event) {
	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(e.startTime) * 60 / time.Second)
	e.arranger.sz = &sz
	e.eng.Render(e.scene, now, sz)
}
Example #7
0
func draw(c event.Config) {
	secondsFromStart := time.Since(startTime) * 60 / time.Second
	now := clock.Time(secondsFromStart)

	currentBottomRight := geom.Point{c.Width, c.Height}
	if bottomRight == nil || currentBottomRight != *bottomRight {
		bottomRight = &currentBottomRight

		log.Printf("Device Sizing: %vx%v PixelsPerPt:%v",
			c.Width,
			c.Height,
			c.PixelsPerPt,
		)
	}

	if fullScene == nil {
		fullScene = setupScene(c.Width, c.Height, secondsFromStart)
	}

	gl.ClearColor(0, 0, 0, 0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	eng.Render(fullScene, now, c)
	debug.DrawFPS(c)
}
Example #8
0
func onPaint(sz size.Event) {
	if scene == nil {
		loadScene(sz)
	}
	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(startTime) * 60 / time.Second)
	eng.Render(scene, now, sz)
}
Example #9
0
func onPaint() {
	if scene == nil {
		loadScene()
	}
	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(startTime) * 60 / time.Second)
	eng.Render(scene, now, cfg)
	debug.DrawFPS(cfg)
}
Example #10
0
func draw(c event.Config) {
	if scene == nil {
		loadScene(c)
	}
	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(startTime) * 60 / time.Second)
	eng.Render(scene, now, c)
	debug.DrawFPS(c)
}
Example #11
0
func onPaint(e size.Event) {
	if scene == nil {
		loadScene()
	}
	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(start) * 60 / time.Second)
	eng.Render(scene, now, e)
	if *dbg {
		debug.DrawFPS(e)
	}
}
Example #12
0
func onPaint(sz size.Event) {
	if scene == nil {
		images = glutil.NewImages()
		fps = debug.NewFPS(images)
		eng = glsprite.Engine(images)
		loadScene()
	}
	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(startTime) * 60 / time.Second)
	eng.Render(scene, now, sz)
	fps.Draw(sz)
}
Example #13
0
func (self *GLPeer) Update() {
	if self.glctx == nil {
		return
	}
	self.glctx.ClearColor(1, 1, 1, 1) // white background
	self.glctx.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(startTime) * 60 / time.Second)

	self.apply()

	self.eng.Render(self.scene, now, sz)
	self.fps.Draw(sz)
}
Example #14
0
func onPaint(glctx gl.Context, sz size.Event, u *uistate.UIState) {
	if u.CurView == uistate.None {
		u.ScanChan = make(chan bool)
		go sync.ScanForSG(u.Ctx, u.ScanChan, u)
		view.LoadDiscoveryView(u)
	}
	glctx.ClearColor(1, 1, 1, 1)
	glctx.Clear(gl.COLOR_BUFFER_BIT)
	now := clock.Time(time.Since(u.StartTime) * 60 / time.Second)
	u.Eng.Render(u.Scene, now, sz)
	if u.Debug {
		fps.Draw(sz)
	}
}
Example #15
0
func onPaint(c config.Event) {
	if !started {
		touchLoc = geom.Point{c.Width / 2, c.Height / 2}
		started = true
	}
	if scene == nil {
		loadScene()
	}
	gl.ClearColor(242/255.0, 240/255.0, 217/255.0, 1) // gophercon bg color
	gl.Clear(gl.COLOR_BUFFER_BIT)

	now := clock.Time(time.Since(startClock) * 60 / time.Second)
	eng.Render(scene, now, c)
	debug.DrawFPS(c)
}
Example #16
0
func draw(c event.Config) {
	if scene == nil {
		loadScene(c)
	}

	now := clock.Time(time.Since(startClock) * 60 / time.Second)
	if now == lastClock {
		return
	}
	lastClock = now

	gl.ClearColor(1, 1, 1, 1)
	gl.Clear(gl.COLOR_BUFFER_BIT)
	eng.Render(scene, now, c)
	//debug.DrawFPS()
}
Example #17
0
func draw(c config.Event) {
	secondsFromStart := time.Since(startTime) * 60 / time.Second
	now := clock.Time(secondsFromStart)

	if screenWidth == nil || *screenWidth != c.WidthPt {
		screenWidth = &c.WidthPt

		log.Printf("Device Sizing: %vx%v PixelsPerPt:%v",
			c.WidthPt,
			c.HeightPt,
			c.PixelsPerPt,
		)
	}

	if fullScene == nil {
		fullScene = setupScene(c.WidthPt, c.HeightPt, secondsFromStart)
	}

	gl.ClearColor(0, 0, 0, 0)
	gl.Clear(gl.COLOR_BUFFER_BIT)

	eng.Render(fullScene, now, c)
	debug.DrawFPS(c)
}
Example #18
0
	"golang.org/x/mobile/exp/sprite/clock"
	"golang.org/x/mobile/exp/sprite/glsprite"
	"golang.org/x/mobile/gl"
)

type State int

const (
	stateStart State = iota
	stateRunning
	stateEnd
)

var (
	startClock = time.Now()
	lastClock  = clock.Time(-1)

	state State = stateStart

	eng   = glsprite.Engine()
	scene *sprite.Node

	player *audio.Player

	texs map[string]sprite.SubTex

	scale float32
	x0    float32
	y0    float32
)