Change Game.Draw to have graphics.Texture

This commit is contained in:
Hajime Hoshi 2013-06-21 01:56:24 +09:00
parent b430d385bf
commit 93565f79a9
3 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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()

View File

@ -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)