Comments (12)
Yeah, this additional function call is an intentional change to make the execution cost more explicit.
from ebiten.
I have no idea about the bitmap editor, so I cannot say anything about this.
from ebiten.
What is the role of the buf argument in this case?
To avoid or reduce internal allocations.
What is the case where ReadPixels returns an error, for example?
The graphics driver might fail for some reasons. In most cases there is nothing a user can do.
If we just add a return value, compatibility is certainly preserved, but if the signature is going to change, it would be more straightforward to change the function name.
No, adding a returning value breaks the compatibility. There can be an interface that defines ReadPixels.
from ebiten.
#2902 might be related
from ebiten.
For an indexed bitmap editor for pixel art it is handy that ebiten.Image is an image.Image. If this is removed we will need to add conversion functions in both ways.
from ebiten.
As long as indexed bitmaps are properly supported both ways, this is fine by me
from ebiten.
As ReadPixels
is very special as it flushes the internal command queue, I might want to move this method to somewhere where we can call it in a limited situation (under Update or Draw). Actually, reading pixels was a blocker to implement handling events (#1704 (comment)).
Another possible idea is to make ReadPixels
asynchronous:
type ReadPixelsResult struct {
Bytes []byte
Err error
}
func (*Image) ReadPixels(buf []byte) (<-chan ReadPixelsResult)
from ebiten.
Another possible idea is to make ReadPixels asynchronous:
I have a few questions:
- What is the role of the
buf
argument in this case? - What is the case where ReadPixels returns an error, for example?
- If we just add a return value, compatibility is certainly preserved, but if the signature is going to change, it would be more straightforward to change the function name.
I think the "non-blocking" functions in Go take chan as an argument, not a return value (sorry if I'm wrong).I was wrong, functions like time.After return chan.
from ebiten.
To avoid or reduce internal allocations.
Will the allocated buf
be written from another goroutine?
from ebiten.
Will the allocated buf be written from another goroutine?
Yes and no. We can treat this like append
: if the buf is not enough, ReadPixels can extend the buffer.
from ebiten.
OK, thanks for responding. To be honest I am not sure about the design of the asynchronous API, but my opinion is in favor of this proposal.
from ebiten.
Another example of Go's non-blocking API is a Start/Wait pair like exec.Command, I'm not sure if it's appropriate for Ebitengine, but just FYI.
from ebiten.
Related Issues (20)
- Kage: Compilation panic
- examples/gamepad: PS4 (Dualshock) bluetooth controller inputs not detected on Windows HOT 8
- MacOS Failure in Running 'Hello, World!' Tutorial Example HOT 1
- examples/flappy: Audio not working on Wasm/Firefox HOT 3
- `GOOS=js GOARCH=wasm go test ./...` fails HOT 3
- Kage: Use color argument as the source image color on `DrawRectShader` HOT 4
- input: handle remapped keys on x11 HOT 3
- ebiten: calling `ScreenSizeInFullscreen` panics on browsers HOT 3
- text/v2: Draw performances using DrawImage HOT 13
- ebitenutil: DebugPrint ignoring image origin HOT 5
- SetWindowSize() and Layout() sizes not matching at fractional display scale factors
- png.Encode panics when give *ebiten.Image as the argument HOT 2
- internal/graphicsdriver/metal/*: rename functions to follow Objective-C way
- .github/workflows: Wasm tests often fail with `websocket url timeout reached`
- shaderprecomp: add tests
- internal/graphicsdriver/directx, internal/graphicsdriver/metal: use precompiled shader for bulitin shaders
- shaderprecomp: implement for Android
- ebiten: add a new API to return the logical screen size (= the result of Layout) HOT 5
- Feature request: Ability to set the pixel density of the HTML canvas HOT 1
- Weird behaviour when LayoutF returns small sizes, e.g. 1.33,1.00
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ebiten.