mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Change the signiture of GraphicsContext.DrawTexture
This commit is contained in:
parent
81a7d4c4fd
commit
92ac4b97ea
11
ebiten.go
11
ebiten.go
@ -6,6 +6,11 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type TapInfo struct {
|
||||
X int
|
||||
Y int
|
||||
}
|
||||
|
||||
type Game interface {
|
||||
ScreenWidth() int
|
||||
ScreenHeight() int
|
||||
@ -20,7 +25,7 @@ type UI interface {
|
||||
|
||||
func OpenGLRun(game Game, ui UI, screenScale int) {
|
||||
ch := make(chan bool, 1)
|
||||
device := opengl.NewDevice(
|
||||
graphicsDevice := opengl.NewDevice(
|
||||
game.ScreenWidth(), game.ScreenHeight(), screenScale,
|
||||
func(g graphics.GraphicsContext, offscreen graphics.Texture) {
|
||||
ticket := <-ch
|
||||
@ -39,7 +44,7 @@ func OpenGLRun(game Game, ui UI, screenScale int) {
|
||||
}
|
||||
}()
|
||||
|
||||
game.Init(device.TextureFactory())
|
||||
game.Init(graphicsDevice.TextureFactory())
|
||||
ch <- true
|
||||
ui.Run(device)
|
||||
ui.Run(graphicsDevice)
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ func (game *Rects) Draw(g graphics.GraphicsContext, offscreen graphics.Texture)
|
||||
)
|
||||
|
||||
g.SetOffscreen(offscreen.ID)
|
||||
g.DrawTexture(game.rectsTexture,
|
||||
g.DrawTexture(game.rectsTexture.ID,
|
||||
matrix.IdentityGeometry(),
|
||||
matrix.IdentityColor())
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ func (game *Rotating) Draw(g graphics.GraphicsContext, offscreen graphics.Textur
|
||||
centerY := float64(game.ScreenHeight()) / 2
|
||||
geometryMatrix.Translate(centerX-tx/2, centerY-ty/2)
|
||||
|
||||
g.DrawTexture(game.ebitenTexture,
|
||||
g.DrawTexture(game.ebitenTexture.ID,
|
||||
geometryMatrix,
|
||||
matrix.IdentityColor())
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ func (game *Sprites) Init(tf graphics.TextureFactory) {
|
||||
panic(err)
|
||||
}
|
||||
game.sprites = []*Sprite{}
|
||||
for i := 0; i < 1000; i++ {
|
||||
for i := 0; i < 100; i++ {
|
||||
sprite := newSprite(
|
||||
game.ScreenWidth(),
|
||||
game.ScreenHeight(),
|
||||
|
@ -6,10 +6,12 @@ package main
|
||||
// #include <GLUT/glut.h>
|
||||
//
|
||||
// void display(void);
|
||||
// void mouse(int button, int state, int x, int y);
|
||||
// void idle(void);
|
||||
//
|
||||
// static void setGlutFuncs(void) {
|
||||
// glutDisplayFunc(display);
|
||||
// glutMouseFunc(mouse);
|
||||
// glutIdleFunc(idle);
|
||||
// }
|
||||
//
|
||||
@ -37,6 +39,11 @@ func display() {
|
||||
C.glutSwapBuffers()
|
||||
}
|
||||
|
||||
//export mouse
|
||||
func mouse(button, state, x, y C.int) {
|
||||
|
||||
}
|
||||
|
||||
//export idle
|
||||
func idle() {
|
||||
C.glutPostRedisplay()
|
||||
|
@ -28,14 +28,14 @@ type GraphicsContext interface {
|
||||
Clear()
|
||||
Fill(color color.Color)
|
||||
DrawRect(rect Rect, clr color.Color)
|
||||
DrawTexture(texture Texture,
|
||||
DrawTexture(textureID TextureID,
|
||||
geometryMatrix matrix.Geometry,
|
||||
colorMatrix matrix.Color)
|
||||
DrawTextureParts(textureId TextureID,
|
||||
DrawTextureParts(textureID TextureID,
|
||||
locations []TexturePart,
|
||||
geometryMatrix matrix.Geometry,
|
||||
colorMatrix matrix.Color)
|
||||
SetOffscreen(textureId TextureID)
|
||||
SetOffscreen(textureID TextureID)
|
||||
}
|
||||
|
||||
type TextureFactory interface {
|
||||
|
@ -55,7 +55,7 @@ func (device *Device) Update() {
|
||||
{0, scale, 0},
|
||||
},
|
||||
}
|
||||
g.DrawTexture(device.offscreenTexture,
|
||||
g.DrawTexture(device.offscreenTexture.ID,
|
||||
geometryMatrix, matrix.IdentityColor())
|
||||
g.flush()
|
||||
}
|
||||
|
@ -113,11 +113,13 @@ func (context *GraphicsContext) DrawRect(rect graphics.Rect, clr color.Color) {
|
||||
}
|
||||
|
||||
func (context *GraphicsContext) DrawTexture(
|
||||
texture graphics.Texture,
|
||||
textureID graphics.TextureID,
|
||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||
source := graphics.Rect{0, 0, texture.Width, texture.Height}
|
||||
texture := context.textures[textureID]
|
||||
|
||||
source := graphics.Rect{0, 0, texture.width, texture.height}
|
||||
locations := []graphics.TexturePart{{0, 0, source}}
|
||||
context.DrawTextureParts(texture.ID, locations,
|
||||
context.DrawTextureParts(textureID, locations,
|
||||
geometryMatrix, colorMatrix)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user