Skip to content

Conversation

@mariovisic
Copy link
Contributor

This pull request changes the Ruby2D::Image class to render using the new texture functions. So a lot of the C code specifically for rendering Images can now be removed. We still have to keep the C R2D_Image struct as it is used by Sprite and Tileset. The Ruby2D::Vertices class can be re-used for Images as it supports rotation and scaling (by defining a width/height that is different from the original image).

Renders look the same as the main branch

Screen Shot 2021-08-07 at 8 16 16 pm

Screen Shot 2021-08-07 at 8 15 31 pm

Image rendering now uses the texture class in ruby that was built out
originally with the `Text` class. I've added a few TODOs that need to be
addressed still.
We don't need this code any more as we're using the texture class to render our
image objects now. There are still some functions inside of `image.c` which
we'll be able to remove once tilesets are also using the new rendering code.
The existing code to render images would take images in other formats like
blue/green/red ordered pixels (BGR) and then convert those to RGB. This patch
moves those changes out to a function so we can re-use it :)

We don't hold onto the 'format' of the image anymore, but we can still read
this from the surface when creating a texture and this seems to work fine :)
This condition would check if we failed to create an image and present a
helpful error message. We don't use the same C code for loading images
anymore and so it may be better to handle this inside of the Texture
class, as Texture will get a blank array instead of useful arguments.
@blacktm blacktm merged commit 9787d22 into ruby2d:main Aug 10, 2021
@mariovisic mariovisic deleted the image_rendering_refactor branch August 11, 2021 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants