Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to_rgba8 support #63

Open
ccie18473 opened this issue Jan 12, 2022 · 2 comments
Open

to_rgba8 support #63

ccie18473 opened this issue Jan 12, 2022 · 2 comments

Comments

@ccie18473
Copy link

I found that "pub fn to_rgba8(&self, ctx: &mut Context) -> GameResult<Vec>" is not implemented in gwg. Do we have any other method to do the same ? If not, what steps do we need to implement it in gwg ?

I'm looking to the source code at:

https://github.com/ggez/ggez/blob/master/src/graphics/image.rs

And I'm thinking that maybe this is too much for me :)

Thanks.

@PSteinhaus
Copy link
Member

Hmm, good question.
We'd probably need to look into miniquads Texture type and how it can be serialized.

From what I can see our only option would be to use gl_internal_id to get the raw OpenGL-handle which we could then probably use to copy the texture GPU-buffer into a CPU-one that we specify, similar to how it works in ggez.

That would require to use some raw OpenGL-calls, accessible through the gl-context that is provided through the miniquad-context which is part of the gwg-context. But, I am not that used to working with OpenGL directly, so I don't spontaneously know what the necessary steps / functions would be exactly and I'm currently sadly a bit busy, so it's not very likely that I'll look into it soon, but I'll try to do so once things get better (which will probably take a couple of weeks sadly). That and working out the asset-cache-thing so that we can finally upgrade to newer miniquad versions...

@ccie18473
Copy link
Author

No issues, I managed to do the same with the image crate. Something like:
image = include_bytes!("../resources/image.png");
rgba = image::load_from_memory(image).unwrap().to_rgba().into_raw();
Thanks !

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

No branches or pull requests

2 participants