mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
parent
1aabdd58f1
commit
a03b335c24
@ -29,6 +29,8 @@ import (
|
|||||||
// A command is not immediately executed after created. Instaed, it is queued after created,
|
// A command is not immediately executed after created. Instaed, it is queued after created,
|
||||||
// and executed only when necessary.
|
// and executed only when necessary.
|
||||||
type command interface {
|
type command interface {
|
||||||
|
fmt.Stringer
|
||||||
|
|
||||||
Exec(indexOffsetInBytes int) error
|
Exec(indexOffsetInBytes int) error
|
||||||
NumVertices() int
|
NumVertices() int
|
||||||
NumIndices() int
|
NumIndices() int
|
||||||
@ -147,6 +149,9 @@ func (q *commandQueue) Flush() {
|
|||||||
opengl.GetContext().ResetViewportSize()
|
opengl.GetContext().ResetViewportSize()
|
||||||
es := q.indices
|
es := q.indices
|
||||||
vs := q.vertices
|
vs := q.vertices
|
||||||
|
if recordLog() {
|
||||||
|
fmt.Println("--")
|
||||||
|
}
|
||||||
for len(q.commands) > 0 {
|
for len(q.commands) > 0 {
|
||||||
nv := 0
|
nv := 0
|
||||||
ne := 0
|
ne := 0
|
||||||
@ -177,6 +182,9 @@ func (q *commandQueue) Flush() {
|
|||||||
q.err = err
|
q.err = err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if recordLog() {
|
||||||
|
fmt.Printf("%s\n", c)
|
||||||
|
}
|
||||||
// TODO: indexOffsetInBytes should be reset if the command type is different
|
// TODO: indexOffsetInBytes should be reset if the command type is different
|
||||||
// from the previous one. This fix is needed when another drawing command is
|
// from the previous one. This fix is needed when another drawing command is
|
||||||
// introduced than drawImageCommand.
|
// introduced than drawImageCommand.
|
||||||
@ -221,6 +229,10 @@ func VertexSizeInBytes() int {
|
|||||||
return theArrayBufferLayout.totalBytes()
|
return theArrayBufferLayout.totalBytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *drawImageCommand) String() string {
|
||||||
|
return fmt.Sprintf("draw-image: dst: %p <- src: %p, colorm: %v, mode %d, filter: %d", c.dst, c.src, c.color, c.mode, c.filter)
|
||||||
|
}
|
||||||
|
|
||||||
// Exec executes the drawImageCommand.
|
// Exec executes the drawImageCommand.
|
||||||
func (c *drawImageCommand) Exec(indexOffsetInBytes int) error {
|
func (c *drawImageCommand) Exec(indexOffsetInBytes int) error {
|
||||||
f, err := c.dst.createFramebufferIfNeeded()
|
f, err := c.dst.createFramebufferIfNeeded()
|
||||||
@ -292,6 +304,10 @@ type replacePixelsCommand struct {
|
|||||||
height int
|
height int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *replacePixelsCommand) String() string {
|
||||||
|
return fmt.Sprintf("replace-pixels: dst: %p, x: %d, y: %d, width: %d, height: %d", c.dst, c.x, c.y, c.width, c.height)
|
||||||
|
}
|
||||||
|
|
||||||
// Exec executes the replacePixelsCommand.
|
// Exec executes the replacePixelsCommand.
|
||||||
func (c *replacePixelsCommand) Exec(indexOffsetInBytes int) error {
|
func (c *replacePixelsCommand) Exec(indexOffsetInBytes int) error {
|
||||||
// glFlush is necessary on Android.
|
// glFlush is necessary on Android.
|
||||||
@ -339,6 +355,10 @@ func (c *pixelsCommand) Exec(indexOffsetInBytes int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *pixelsCommand) String() string {
|
||||||
|
return fmt.Sprintf("pixels: img: %p", c.img)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *pixelsCommand) NumVertices() int {
|
func (c *pixelsCommand) NumVertices() int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -362,6 +382,10 @@ type disposeCommand struct {
|
|||||||
target *Image
|
target *Image
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *disposeCommand) String() string {
|
||||||
|
return fmt.Sprintf("dispose: target: %p", c.target)
|
||||||
|
}
|
||||||
|
|
||||||
// Exec executes the disposeCommand.
|
// Exec executes the disposeCommand.
|
||||||
func (c *disposeCommand) Exec(indexOffsetInBytes int) error {
|
func (c *disposeCommand) Exec(indexOffsetInBytes int) error {
|
||||||
if c.target.framebuffer != nil &&
|
if c.target.framebuffer != nil &&
|
||||||
@ -415,6 +439,10 @@ func checkSize(width, height int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *newImageCommand) String() string {
|
||||||
|
return fmt.Sprintf("new-image: result: %p, width: %d, height: %d", c.result, c.width, c.height)
|
||||||
|
}
|
||||||
|
|
||||||
// Exec executes a newImageCommand.
|
// Exec executes a newImageCommand.
|
||||||
func (c *newImageCommand) Exec(indexOffsetInBytes int) error {
|
func (c *newImageCommand) Exec(indexOffsetInBytes int) error {
|
||||||
w := emath.NextPowerOf2Int(c.width)
|
w := emath.NextPowerOf2Int(c.width)
|
||||||
@ -455,6 +483,10 @@ type newScreenFramebufferImageCommand struct {
|
|||||||
height int
|
height int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *newScreenFramebufferImageCommand) String() string {
|
||||||
|
return fmt.Sprintf("new-screen-framebuffer-image: result: %p, width: %d, height: %d", c.result, c.width, c.height)
|
||||||
|
}
|
||||||
|
|
||||||
// Exec executes a newScreenFramebufferImageCommand.
|
// Exec executes a newScreenFramebufferImageCommand.
|
||||||
func (c *newScreenFramebufferImageCommand) Exec(indexOffsetInBytes int) error {
|
func (c *newScreenFramebufferImageCommand) Exec(indexOffsetInBytes int) error {
|
||||||
checkSize(c.width, c.height)
|
checkSize(c.width, c.height)
|
||||||
|
21
internal/graphics/debug_ebitendebug.go
Normal file
21
internal/graphics/debug_ebitendebug.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright 2018 The Ebiten Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build ebitendebug
|
||||||
|
|
||||||
|
package graphics
|
||||||
|
|
||||||
|
func recordLog() bool {
|
||||||
|
return recordLog
|
||||||
|
}
|
21
internal/graphics/debug_notebitendebug.go
Normal file
21
internal/graphics/debug_notebitendebug.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright 2018 The Ebiten Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build !ebitendebug
|
||||||
|
|
||||||
|
package graphics
|
||||||
|
|
||||||
|
func recordLog() bool {
|
||||||
|
return false
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user