ebiten: Brush up shader APIs

Created on 1 Sep 2020  ·  10Comments  ·  Source: hajimehoshi/ebiten

Now there are APIs to use shaders

  • DrawImage
  • DrawRectShader
  • DrawTrianglesShader

And there are some builtin functions for shaders

  • imageSrcTextureSize / imageDstTextureSize
  • imageSrcTextureSourceRegion
  • image[N]TextureAt
  • image[N]TextureBoundsAt

I'm not satisfied with this yet. I think the API can be more minimal and simple. For example, I think it is fine to merge DrawTriangles and DrawTrianglesShader, like what DrawImage does. For builtin functions, they can be more consistent and concise.

Most helpful comment

I'll rename

  • imageSrcTextureSourceRegion -> imageSrcTextureRegion
  • image[N]TextureAt -> imageSrc[N]At
  • image[N]TextureBoundsAt -> imageSrc[N]BoundsAt

CC @tomlister @nanoslayer

All 10 comments

I'll rename

  • imageSrcTextureSourceRegion -> imageSrcTextureRegion
  • image[N]TextureAt -> imageSrc[N]At
  • image[N]TextureBoundsAt -> imageSrc[N]BoundsAt

CC @tomlister @nanoslayer

Seems like a good fit 👍

imageSrc[N]BoundsAt sounds a little odd but I didn't come up with a better name. imageSrc[N]AtWithBoundaryCheck seems verbose.

  • imageSrc[N]AtFast and imageSrc[N]At?
  • imageSrc[N]AtUnsafe and imageSrc[N]At?
  • imageSrc[N]At and imageSrc[N]AtSafe?

My current plan:

  • imageSrc[N]BoundsAt -> imageSrc[N]At
  • imageSrc[N]At -> imageSrc[N]UnsafeAt

Now there are APIs to use shaders

  • DrawImage
  • DrawRectShader
  • DrawTriangles

And there are some builtin functions for shaders

  • imageSrcTextureSize / imageDstTextureSize // returns the size in pixels
  • imageSrcTextureRegion // returns the region in texels
  • image[N]UnsafeAt
  • image[N]At

I'll rename imageSrcTextureRegion to imageSrcRegionOnTexture

Good stuff 👍

On Sat, 19 Sep 2020, 8:30 pm Hajime Hoshi, notifications@github.com wrote:

Now there are APIs to use shaders

  • DrawImage
  • DrawRectShader
  • DrawTriangles

And there are some builtin functions for shaders

  • imageSrcTextureSize / imageDstTextureSize
  • imageSrcTextureRegion
  • image[N]UnsafeAt
  • image[N]At


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/hajimehoshi/ebiten/issues/1325#issuecomment-695196386,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABSK64Z5E5FGI3DZJBBIEYDSGSB2VANCNFSM4QRNJJVQ
.

||Number of source images|How source images are specified|Note|
|-|-|-|-|
|DrawImage [1]|1|An argument|The most common function|
|DrawRectShader [2]|0 to 4|An option|Newly introduced|
|DrawTriangles|0 to 4|An argument and an option [3]|The lowest-level function|

[1] DrawImage now can take a shader, but is this needed?
[2] DrawRect seems more consistent?
[3] This might be changed in the future #1352

I'll change the API like this for consistency:

||Number of source images|How source images are specified|Shader|
|-|-|-|-|
|DrawImage|1|An argument|No|
|DrawRectShader|0 to 4|An option|Yes|
|DrawTriangles|1|An argument|No|
|DrawTrianglesShader|0 to 4|An option|Yes|

Sorry for going back and forth.

OK let's go with them and see how things go!

Was this page helpful?
0 / 5 - 0 ratings