mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Rename ID -> Id
This commit is contained in:
parent
3a383b3078
commit
a0f17a4971
@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type Input struct {
|
||||
textTextureID graphics.TextureID
|
||||
textTextureId graphics.TextureId
|
||||
inputState ebiten.InputState
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ func (game *Input) InitTextures(tf graphics.TextureFactory) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if game.textTextureID, err = tf.NewTextureFromImage(img); err != nil {
|
||||
if game.textTextureId, err = tf.NewTextureFromImage(img); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@ -74,6 +74,6 @@ func (game *Input) drawText(g graphics.Context, text string, x, y int) {
|
||||
geometryMatrix := matrix.IdentityGeometry()
|
||||
geometryMatrix.Translate(float64(x), float64(y))
|
||||
colorMatrix := matrix.IdentityColor()
|
||||
g.DrawTextureParts(game.textTextureID, parts,
|
||||
g.DrawTextureParts(game.textTextureId, parts,
|
||||
geometryMatrix, colorMatrix)
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ const (
|
||||
)
|
||||
|
||||
type Monochrome struct {
|
||||
ebitenTextureID graphics.TextureID
|
||||
ebitenTextureId graphics.TextureId
|
||||
ch chan bool
|
||||
colorMatrix matrix.Color
|
||||
geometryMatrix matrix.Geometry
|
||||
@ -40,7 +40,7 @@ func (game *Monochrome) InitTextures(tf graphics.TextureFactory) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if game.ebitenTextureID, err = tf.NewTextureFromImage(img); err != nil {
|
||||
if game.ebitenTextureId, err = tf.NewTextureFromImage(img); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
@ -102,6 +102,6 @@ func (game *Monochrome) Update(context ebiten.GameContext) {
|
||||
func (game *Monochrome) Draw(g graphics.Context) {
|
||||
g.Fill(128, 128, 255)
|
||||
|
||||
g.DrawTexture(game.ebitenTextureID,
|
||||
g.DrawTexture(game.ebitenTextureId,
|
||||
game.geometryMatrix, game.colorMatrix)
|
||||
}
|
||||
|
@ -11,9 +11,9 @@ import (
|
||||
)
|
||||
|
||||
type Rects struct {
|
||||
rectTextureID graphics.RenderTargetID
|
||||
rectTextureId graphics.RenderTargetId
|
||||
rectTextureInited bool
|
||||
offscreenID graphics.RenderTargetID
|
||||
offscreenId graphics.RenderTargetId
|
||||
offscreenInited bool
|
||||
rectBounds *graphics.Rect
|
||||
rectColor *color.RGBA
|
||||
@ -37,11 +37,11 @@ func New() *Rects {
|
||||
|
||||
func (game *Rects) InitTextures(tf graphics.TextureFactory) {
|
||||
var err error
|
||||
game.rectTextureID, err = tf.NewRenderTarget(rectTextureWidth, rectTextureHeight)
|
||||
game.rectTextureId, err = tf.NewRenderTarget(rectTextureWidth, rectTextureHeight)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
game.offscreenID, err = tf.NewRenderTarget(offscreenWidth, offscreenHeight)
|
||||
game.offscreenId, err = tf.NewRenderTarget(offscreenWidth, offscreenHeight)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -88,22 +88,22 @@ func (game *Rects) rectColorMatrix() matrix.Color {
|
||||
|
||||
func (game *Rects) Draw(g graphics.Context) {
|
||||
if !game.rectTextureInited {
|
||||
g.SetOffscreen(game.rectTextureID)
|
||||
g.SetOffscreen(game.rectTextureId)
|
||||
g.Fill(255, 255, 255)
|
||||
game.rectTextureInited = true
|
||||
}
|
||||
|
||||
g.SetOffscreen(game.offscreenID)
|
||||
g.SetOffscreen(game.offscreenId)
|
||||
if !game.offscreenInited {
|
||||
g.Fill(0, 0, 0)
|
||||
game.offscreenInited = true
|
||||
}
|
||||
g.DrawTexture(g.ToTexture(game.rectTextureID),
|
||||
g.DrawTexture(g.ToTexture(game.rectTextureId),
|
||||
game.rectGeometryMatrix(),
|
||||
game.rectColorMatrix())
|
||||
|
||||
g.ResetOffscreen()
|
||||
g.DrawTexture(g.ToTexture(game.offscreenID),
|
||||
g.DrawTexture(g.ToTexture(game.offscreenId),
|
||||
matrix.IdentityGeometry(),
|
||||
matrix.IdentityColor())
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ const (
|
||||
)
|
||||
|
||||
type Rotating struct {
|
||||
ebitenTextureID graphics.TextureID
|
||||
ebitenTextureId graphics.TextureId
|
||||
x int
|
||||
geometryMatrix matrix.Geometry
|
||||
}
|
||||
@ -36,7 +36,7 @@ func (game *Rotating) InitTextures(tf graphics.TextureFactory) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if game.ebitenTextureID, err = tf.NewTextureFromImage(img); err != nil {
|
||||
if game.ebitenTextureId, err = tf.NewTextureFromImage(img); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@ -56,7 +56,7 @@ func (game *Rotating) Update(context ebiten.GameContext) {
|
||||
|
||||
func (game *Rotating) Draw(g graphics.Context) {
|
||||
g.Fill(128, 128, 255)
|
||||
g.DrawTexture(game.ebitenTextureID,
|
||||
g.DrawTexture(game.ebitenTextureId,
|
||||
game.geometryMatrix,
|
||||
matrix.IdentityColor())
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func (sprite *Sprite) Update() {
|
||||
}
|
||||
|
||||
type Sprites struct {
|
||||
ebitenTextureID graphics.TextureID
|
||||
ebitenTextureId graphics.TextureId
|
||||
sprites []*Sprite
|
||||
}
|
||||
|
||||
@ -86,7 +86,7 @@ func (game *Sprites) InitTextures(tf graphics.TextureFactory) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if game.ebitenTextureID, err = tf.NewTextureFromImage(img); err != nil {
|
||||
if game.ebitenTextureId, err = tf.NewTextureFromImage(img); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@ -125,7 +125,7 @@ func (game *Sprites) Draw(g graphics.Context) {
|
||||
locations = append(locations, location)
|
||||
}
|
||||
geometryMatrix := matrix.IdentityGeometry()
|
||||
g.DrawTextureParts(game.ebitenTextureID, locations,
|
||||
g.DrawTextureParts(game.ebitenTextureId, locations,
|
||||
geometryMatrix, matrix.IdentityColor())
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
type TestPattern struct {
|
||||
textureId graphics.TextureID
|
||||
textureId graphics.TextureId
|
||||
textureWidth int
|
||||
textureHeight int
|
||||
geos []matrix.Geometry
|
||||
|
@ -19,28 +19,28 @@ type TexturePart struct {
|
||||
}
|
||||
|
||||
type Context interface {
|
||||
ToTexture(id RenderTargetID) TextureID
|
||||
ToTexture(id RenderTargetId) TextureId
|
||||
|
||||
Clear()
|
||||
Fill(r, g, b uint8)
|
||||
DrawTexture(id TextureID,
|
||||
DrawTexture(id TextureId,
|
||||
geometryMatrix matrix.Geometry,
|
||||
colorMatrix matrix.Color)
|
||||
DrawTextureParts(id TextureID,
|
||||
DrawTextureParts(id TextureId,
|
||||
parts []TexturePart,
|
||||
geometryMatrix matrix.Geometry,
|
||||
colorMatrix matrix.Color)
|
||||
ResetOffscreen()
|
||||
SetOffscreen(id RenderTargetID)
|
||||
SetOffscreen(id RenderTargetId)
|
||||
}
|
||||
|
||||
type TextureFactory interface {
|
||||
NewRenderTarget(width, height int) (RenderTargetID, error)
|
||||
NewTextureFromImage(img image.Image) (TextureID, error)
|
||||
NewRenderTarget(width, height int) (RenderTargetId, error)
|
||||
NewTextureFromImage(img image.Image) (TextureId, error)
|
||||
}
|
||||
|
||||
type TextureID int
|
||||
type TextureId int
|
||||
|
||||
// A render target is essentially same as a texture, but it is assumed that the
|
||||
// all alpha of a render target is maximum.
|
||||
type RenderTargetID int
|
||||
type RenderTargetId int
|
||||
|
@ -15,13 +15,13 @@ import (
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
screenId graphics.RenderTargetID
|
||||
screenId graphics.RenderTargetId
|
||||
screenWidth int
|
||||
screenHeight int
|
||||
screenScale int
|
||||
textures map[graphics.TextureID]*Texture
|
||||
renderTargets map[graphics.RenderTargetID]*RenderTarget
|
||||
renderTargetToTexture map[graphics.RenderTargetID]graphics.TextureID
|
||||
textures map[graphics.TextureId]*Texture
|
||||
renderTargets map[graphics.RenderTargetId]*RenderTarget
|
||||
renderTargetToTexture map[graphics.RenderTargetId]graphics.TextureId
|
||||
currentOffscreen *RenderTarget
|
||||
mainFramebufferTexture *RenderTarget
|
||||
}
|
||||
@ -31,9 +31,9 @@ func newContext(screenWidth, screenHeight, screenScale int) *Context {
|
||||
screenWidth: screenWidth,
|
||||
screenHeight: screenHeight,
|
||||
screenScale: screenScale,
|
||||
textures: map[graphics.TextureID]*Texture{},
|
||||
renderTargets: map[graphics.RenderTargetID]*RenderTarget{},
|
||||
renderTargetToTexture: map[graphics.RenderTargetID]graphics.TextureID{},
|
||||
textures: map[graphics.TextureId]*Texture{},
|
||||
renderTargets: map[graphics.RenderTargetId]*RenderTarget{},
|
||||
renderTargetToTexture: map[graphics.RenderTargetId]graphics.TextureId{},
|
||||
}
|
||||
return context
|
||||
}
|
||||
@ -59,8 +59,8 @@ func (context *Context) Init() {
|
||||
}
|
||||
}
|
||||
|
||||
func (context *Context) ToTexture(renderTargetID graphics.RenderTargetID) graphics.TextureID {
|
||||
return context.renderTargetToTexture[renderTargetID]
|
||||
func (context *Context) ToTexture(renderTargetId graphics.RenderTargetId) graphics.TextureId {
|
||||
return context.renderTargetToTexture[renderTargetId]
|
||||
}
|
||||
|
||||
func (context *Context) Clear() {
|
||||
@ -78,25 +78,25 @@ func (context *Context) Fill(r, g, b uint8) {
|
||||
}
|
||||
|
||||
func (context *Context) DrawTexture(
|
||||
textureID graphics.TextureID,
|
||||
textureId graphics.TextureId,
|
||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||
texture, ok := context.textures[textureID]
|
||||
texture, ok := context.textures[textureId]
|
||||
if !ok {
|
||||
panic("invalid texture ID")
|
||||
}
|
||||
source := graphics.Rect{0, 0, texture.width, texture.height}
|
||||
locations := []graphics.TexturePart{{0, 0, source}}
|
||||
context.DrawTextureParts(textureID, locations,
|
||||
context.DrawTextureParts(textureId, locations,
|
||||
geometryMatrix, colorMatrix)
|
||||
}
|
||||
|
||||
func (context *Context) DrawTextureParts(
|
||||
textureID graphics.TextureID, parts []graphics.TexturePart,
|
||||
textureId graphics.TextureId, parts []graphics.TexturePart,
|
||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||
|
||||
texture, ok := context.textures[textureID]
|
||||
texture, ok := context.textures[textureId]
|
||||
if !ok {
|
||||
panic("invalid texture ID")
|
||||
panic("invalid texture Id")
|
||||
}
|
||||
|
||||
shaderProgram := context.setShaderProgram(geometryMatrix, colorMatrix)
|
||||
@ -151,8 +151,8 @@ func (context *Context) ResetOffscreen() {
|
||||
context.SetOffscreen(context.screenId)
|
||||
}
|
||||
|
||||
func (context *Context) SetOffscreen(renderTargetID graphics.RenderTargetID) {
|
||||
renderTarget := context.renderTargets[renderTargetID]
|
||||
func (context *Context) SetOffscreen(renderTargetId graphics.RenderTargetId) {
|
||||
renderTarget := context.renderTargets[renderTargetId]
|
||||
context.setOffscreen(renderTarget)
|
||||
}
|
||||
|
||||
@ -267,13 +267,13 @@ func (context *Context) setShaderProgram(
|
||||
}
|
||||
|
||||
func (context *Context) NewRenderTarget(width, height int) (
|
||||
graphics.RenderTargetID, error) {
|
||||
graphics.RenderTargetId, error) {
|
||||
renderTarget, err := newRenderTarget(width, height)
|
||||
if err != nil {
|
||||
return 0, nil
|
||||
}
|
||||
renderTargetId := graphics.RenderTargetID(<-newId)
|
||||
textureId := graphics.TextureID(<-newId)
|
||||
renderTargetId := graphics.RenderTargetId(<-newId)
|
||||
textureId := graphics.TextureId(<-newId)
|
||||
context.renderTargets[renderTargetId] = renderTarget
|
||||
context.textures[textureId] = renderTarget.texture
|
||||
context.renderTargetToTexture[renderTargetId] = textureId
|
||||
@ -286,12 +286,12 @@ func (context *Context) NewRenderTarget(width, height int) (
|
||||
}
|
||||
|
||||
func (context *Context) NewTextureFromImage(img image.Image) (
|
||||
graphics.TextureID, error) {
|
||||
graphics.TextureId, error) {
|
||||
texture, err := newTextureFromImage(img)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
textureId := graphics.TextureID(<-newId)
|
||||
textureId := graphics.TextureId(<-newId)
|
||||
context.textures[textureId] = texture
|
||||
return textureId, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user