Git Product home page Git Product logo

Comments (12)

hajimehoshi avatar hajimehoshi commented on May 10, 2024 2

Yeah, this additional function call is an intentional change to make the execution cost more explicit.

from ebiten.

hajimehoshi avatar hajimehoshi commented on May 10, 2024 1

I have no idea about the bitmap editor, so I cannot say anything about this.

from ebiten.

hajimehoshi avatar hajimehoshi commented on May 10, 2024 1

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.

hajimehoshi avatar hajimehoshi commented on May 10, 2024

#2902 might be related

from ebiten.

bjorndm avatar bjorndm commented on May 10, 2024

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.

bjorndm avatar bjorndm commented on May 10, 2024

As long as indexed bitmaps are properly supported both ways, this is fine by me

from ebiten.

hajimehoshi avatar hajimehoshi commented on May 10, 2024

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.

eihigh avatar eihigh commented on May 10, 2024

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.

eihigh avatar eihigh commented on May 10, 2024

To avoid or reduce internal allocations.

Will the allocated buf be written from another goroutine?

from ebiten.

hajimehoshi avatar hajimehoshi commented on May 10, 2024

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.

eihigh avatar eihigh commented on May 10, 2024

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.

eihigh avatar eihigh commented on May 10, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.