mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Resolve some TODOs
This commit is contained in:
parent
cd4188b0a3
commit
beecf31937
@ -109,7 +109,7 @@ func Queue(channel int, l []int16, r []int16) {
|
||||
ch.r = append(ch.r, r...)
|
||||
}
|
||||
|
||||
func Update() {
|
||||
func Tick() {
|
||||
for _, ch := range channels {
|
||||
ch.nextInsertionPosition += SampleRate / 60
|
||||
}
|
||||
|
13
image.go
13
image.go
@ -21,7 +21,6 @@ import (
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl"
|
||||
"image"
|
||||
"image/color"
|
||||
"math"
|
||||
)
|
||||
|
||||
// Image represents an image.
|
||||
@ -46,15 +45,8 @@ func (i *Image) Clear() (err error) {
|
||||
// Fill fills the image with a solid color.
|
||||
func (i *Image) Fill(clr color.Color) (err error) {
|
||||
i.pixels = nil
|
||||
cr, cg, cb, ca := clr.RGBA()
|
||||
const max = math.MaxUint16
|
||||
r := float64(cr) / max
|
||||
g := float64(cg) / max
|
||||
b := float64(cb) / max
|
||||
a := float64(ca) / max
|
||||
useGLContext(func(c *opengl.Context) {
|
||||
// TODO: Change to pass color.Color
|
||||
err = i.framebuffer.Fill(c, r, g, b, a)
|
||||
err = i.framebuffer.Fill(c, clr)
|
||||
})
|
||||
return
|
||||
}
|
||||
@ -187,7 +179,8 @@ func (i *Image) dispose() {
|
||||
//
|
||||
// This function may be slow (as for implementation, this calls glTexSubImage2D).
|
||||
func (i *Image) ReplacePixels(p []uint8) error {
|
||||
// TODO: Can we set p to pixels?
|
||||
// Don't set i.pixels here because i.pixels is used not every time.
|
||||
|
||||
i.pixels = nil
|
||||
w, h := i.Size()
|
||||
l := 4 * w * h
|
||||
|
@ -33,7 +33,7 @@ type ImageParts interface {
|
||||
Src(i int) (x0, y0, x1, y1 int)
|
||||
}
|
||||
|
||||
// TODO: Remove this in the future.
|
||||
// NOTE: Remove this in the future.
|
||||
type imageParts []ImagePart
|
||||
|
||||
func (p imageParts) Len() int {
|
||||
|
@ -38,7 +38,7 @@ var vertices = make([]int16, 0, 4*8*quadsMaxNum)
|
||||
var shadersInitialized = false
|
||||
|
||||
func drawTexture(c *opengl.Context, texture opengl.Texture, projectionMatrix *[4][4]float64, quads TextureQuads, geo Matrix, color Matrix) error {
|
||||
// TODO: WebGL doesn't seem to have Check gl.MAX_ELEMENTS_VERTICES or gl.MAX_ELEMENTS_INDICES so far.
|
||||
// NOTE: WebGL doesn't seem to have Check gl.MAX_ELEMENTS_VERTICES or gl.MAX_ELEMENTS_INDICES so far.
|
||||
// Let's use them to compare to len(quads) in the future.
|
||||
|
||||
if !shadersInitialized {
|
||||
|
@ -17,6 +17,7 @@ package graphics
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/graphics/internal/opengl"
|
||||
"image/color"
|
||||
"math"
|
||||
)
|
||||
|
||||
type TextureQuads interface {
|
||||
@ -109,10 +110,16 @@ func (f *Framebuffer) projectionMatrix() *[4][4]float64 {
|
||||
return m
|
||||
}
|
||||
|
||||
func (f *Framebuffer) Fill(c *opengl.Context, r, g, b, a float64) error {
|
||||
func (f *Framebuffer) Fill(c *opengl.Context, clr color.Color) error {
|
||||
if err := f.setAsViewport(c); err != nil {
|
||||
return err
|
||||
}
|
||||
cr, cg, cb, ca := clr.RGBA()
|
||||
const max = math.MaxUint16
|
||||
r := float64(cr) / max
|
||||
g := float64(cg) / max
|
||||
b := float64(cb) / max
|
||||
a := float64(ca) / max
|
||||
return c.FillFramebuffer(r, g, b, a)
|
||||
}
|
||||
|
||||
|
@ -65,8 +65,7 @@ type userInterface struct{}
|
||||
|
||||
var currentUI = &userInterface{}
|
||||
|
||||
// TODO: This returns true even when the browser is not active.
|
||||
// The current behavior causes sound noise...
|
||||
// NOTE: This returns true even when the browser is not active.
|
||||
func shown() bool {
|
||||
return !js.Global.Get("document").Get("hidden").Bool()
|
||||
}
|
||||
@ -179,7 +178,7 @@ func Init() {
|
||||
})
|
||||
|
||||
// Touch (emulating mouse events)
|
||||
// TODO: Need to create indimendent touch functions?
|
||||
// TODO: Create indimendent touch functions
|
||||
canvas.Call("addEventListener", "touchstart", func(e js.Object) {
|
||||
e.Call("preventDefault")
|
||||
currentInput.MouseDown(0)
|
||||
@ -208,7 +207,7 @@ func Init() {
|
||||
}
|
||||
|
||||
func setMouseCursorFromEvent(e js.Object) {
|
||||
scale := canvas.Get("dataset").Get("ebitenScale").Int() // TODO: Float?
|
||||
scale := canvas.Get("dataset").Get("ebitenScale").Int()
|
||||
rect := canvas.Call("getBoundingClientRect")
|
||||
x, y := e.Get("clientX").Int(), e.Get("clientY").Int()
|
||||
x -= rect.Get("left").Int()
|
||||
|
5
run.go
5
run.go
@ -103,8 +103,7 @@ func Run(f func(*Image) error, width, height, scale int, title string) error {
|
||||
if err := graphicsContext.postUpdate(); err != nil {
|
||||
return err
|
||||
}
|
||||
// TODO: I'm not sure this is 'Update'. Is 'Tick' better?
|
||||
audio.Update()
|
||||
audio.Tick()
|
||||
ui.SwapBuffers()
|
||||
if err != nil {
|
||||
return err
|
||||
@ -144,5 +143,3 @@ func SetScreenScale(scale int) {
|
||||
}
|
||||
runContext.newScreenScale = scale
|
||||
}
|
||||
|
||||
// TODO: Create SetScreenPosition (for GLFW)
|
||||
|
Loading…
Reference in New Issue
Block a user