mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 18:02:02 +01:00
Remove Canvas.ToTexture
This commit is contained in:
parent
e8c518735b
commit
89c33eac85
@ -98,12 +98,12 @@ func (game *Rects) Draw(g graphics.Canvas) {
|
||||
g.Fill(0, 0, 0)
|
||||
game.offscreenInited = true
|
||||
}
|
||||
g.DrawTexture(g.ToTexture(game.rectTextureId),
|
||||
g.DrawRenderTarget(game.rectTextureId,
|
||||
game.rectGeometryMatrix(),
|
||||
game.rectColorMatrix())
|
||||
|
||||
g.ResetOffscreen()
|
||||
g.DrawTexture(g.ToTexture(game.offscreenId),
|
||||
g.DrawRenderTarget(game.offscreenId,
|
||||
matrix.IdentityGeometry(),
|
||||
matrix.IdentityColor())
|
||||
}
|
||||
|
@ -19,17 +19,23 @@ type TexturePart struct {
|
||||
}
|
||||
|
||||
type Canvas interface {
|
||||
ToTexture(id RenderTargetId) TextureId
|
||||
|
||||
Clear()
|
||||
Fill(r, g, b uint8)
|
||||
DrawTexture(id TextureId,
|
||||
geometryMatrix matrix.Geometry,
|
||||
colorMatrix matrix.Color)
|
||||
DrawRenderTarget(id RenderTargetId,
|
||||
geometryMatrix matrix.Geometry,
|
||||
colorMatrix matrix.Color)
|
||||
DrawTextureParts(id TextureId,
|
||||
parts []TexturePart,
|
||||
geometryMatrix matrix.Geometry,
|
||||
colorMatrix matrix.Color)
|
||||
DrawRenderTargetParts(id RenderTargetId,
|
||||
parts []TexturePart,
|
||||
geometryMatrix matrix.Geometry,
|
||||
colorMatrix matrix.Color)
|
||||
|
||||
ResetOffscreen()
|
||||
SetOffscreen(id RenderTargetId)
|
||||
}
|
||||
|
@ -38,10 +38,6 @@ func newContext(screenWidth, screenHeight, screenScale int) *Context {
|
||||
return context
|
||||
}
|
||||
|
||||
func (context *Context) ToTexture(renderTargetId graphics.RenderTargetId) graphics.TextureId {
|
||||
return context.ids.ToTexture(renderTargetId)
|
||||
}
|
||||
|
||||
func (context *Context) Clear() {
|
||||
context.Fill(0, 0, 0)
|
||||
}
|
||||
@ -57,19 +53,31 @@ func (context *Context) Fill(r, g, b uint8) {
|
||||
}
|
||||
|
||||
func (context *Context) DrawTexture(
|
||||
textureId graphics.TextureId,
|
||||
id graphics.TextureId,
|
||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||
tex := context.ids.TextureAt(textureId)
|
||||
tex := context.ids.TextureAt(id)
|
||||
context.offscreen.DrawTexture(tex, geometryMatrix, colorMatrix)
|
||||
}
|
||||
|
||||
func (context *Context) DrawTextureParts(
|
||||
textureId graphics.TextureId, parts []graphics.TexturePart,
|
||||
func (context *Context) DrawRenderTarget(
|
||||
id graphics.RenderTargetId,
|
||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||
tex := context.ids.TextureAt(textureId)
|
||||
context.DrawTexture(context.ids.ToTexture(id), geometryMatrix, colorMatrix)
|
||||
}
|
||||
|
||||
func (context *Context) DrawTextureParts(
|
||||
id graphics.TextureId, parts []graphics.TexturePart,
|
||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||
tex := context.ids.TextureAt(id)
|
||||
context.offscreen.DrawTextureParts(tex, parts, geometryMatrix, colorMatrix)
|
||||
}
|
||||
|
||||
func (context *Context) DrawRenderTargetParts(
|
||||
id graphics.RenderTargetId, parts []graphics.TexturePart,
|
||||
geometryMatrix matrix.Geometry, colorMatrix matrix.Color) {
|
||||
context.DrawTextureParts(context.ids.ToTexture(id), parts, geometryMatrix, colorMatrix)
|
||||
}
|
||||
|
||||
// Init initializes the context. The initial state is saved for each GL context.
|
||||
func (context *Context) Init() {
|
||||
C.glEnable(C.GL_TEXTURE_2D)
|
||||
|
@ -33,7 +33,7 @@ func (device *Device) Update(draw func(graphics.Canvas)) {
|
||||
scale := float64(device.screenScale)
|
||||
geometryMatrix := matrix.IdentityGeometry()
|
||||
geometryMatrix.Scale(scale, scale)
|
||||
context.DrawTexture(context.ToTexture(context.screenId),
|
||||
context.DrawRenderTarget(context.screenId,
|
||||
geometryMatrix, matrix.IdentityColor())
|
||||
context.flush()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user