mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
Change Game.Draw to have graphics.Texture
This commit is contained in:
parent
b430d385bf
commit
93565f79a9
@ -9,7 +9,7 @@ import (
|
||||
type Game interface {
|
||||
Init(tf graphics.TextureFactory)
|
||||
Update()
|
||||
Draw(g graphics.GraphicsContext, offscreen graphics.TextureID)
|
||||
Draw(g graphics.GraphicsContext, offscreen graphics.Texture)
|
||||
}
|
||||
|
||||
type UI interface {
|
||||
@ -23,7 +23,7 @@ func OpenGLRun(game Game, ui UI) {
|
||||
ch := make(chan bool, 1)
|
||||
device := opengl.NewDevice(
|
||||
ui.ScreenWidth(), ui.ScreenHeight(), ui.ScreenScale(),
|
||||
func(g graphics.GraphicsContext, offscreen graphics.TextureID) {
|
||||
func(g graphics.GraphicsContext, offscreen graphics.Texture) {
|
||||
ticket := <-ch
|
||||
game.Draw(g, offscreen)
|
||||
ch <- ticket
|
||||
|
@ -115,7 +115,7 @@ func (game *DemoGame) Update() {
|
||||
game.x++
|
||||
}
|
||||
|
||||
func (game *DemoGame) Draw(g graphics.GraphicsContext, offscreen graphics.TextureID) {
|
||||
func (game *DemoGame) Draw(g graphics.GraphicsContext, offscreen graphics.Texture) {
|
||||
g.Fill(&color.RGBA{R: 128, G: 128, B: 255, A: 255})
|
||||
|
||||
geometryMatrix := matrix.IdentityGeometry()
|
||||
|
@ -16,11 +16,11 @@ type Device struct {
|
||||
screenScale int
|
||||
graphicsContext *GraphicsContext
|
||||
offscreenTexture graphics.Texture
|
||||
drawFunc func(graphics.GraphicsContext, graphics.TextureID)
|
||||
drawFunc func(graphics.GraphicsContext, graphics.Texture)
|
||||
}
|
||||
|
||||
func NewDevice(screenWidth, screenHeight, screenScale int,
|
||||
drawFunc func(graphics.GraphicsContext, graphics.TextureID)) *Device {
|
||||
drawFunc func(graphics.GraphicsContext, graphics.Texture)) *Device {
|
||||
device := &Device{
|
||||
screenWidth: screenWidth,
|
||||
screenHeight: screenHeight,
|
||||
@ -40,7 +40,7 @@ func (device *Device) Update() {
|
||||
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MAG_FILTER, C.GL_NEAREST)
|
||||
g.SetOffscreen(device.offscreenTexture.ID)
|
||||
g.Clear()
|
||||
device.drawFunc(g, device.offscreenTexture.ID)
|
||||
device.drawFunc(g, device.offscreenTexture)
|
||||
g.flush()
|
||||
|
||||
C.glTexParameteri(C.GL_TEXTURE_2D, C.GL_TEXTURE_MIN_FILTER, C.GL_LINEAR)
|
||||
|
Loading…
Reference in New Issue
Block a user