Loading different size images in emscripten

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
n00bc0de
Posts: 138
Joined: Tue Oct 04, 2022 1:21 am

Loading different size images in emscripten

Post by n00bc0de »

I have been trying to find a way to load images with sizes that are not powers of 2. I tried to have a texture target that is the next higher power of 2 and draw the image to that but the alpha on the image gets applied to a black background on the texture, even if I set the clear color to 0.

Is there a good way to get this to work?
CuteAlien
Admin
Posts: 10042
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Loading different size images in emscripten

Post by CuteAlien »

Sorry, need a bit more details to understand what exactly you are trying. Are you trying to pad the image so it keeps the original size but has some invisible alpha part? (I do something like that here: https://github.com/mzeilfelder/irr-play ... adding.cpp)
There's 2 parts you have to be careful about. First when drawing make sure it uses the alpha, for example when you use draw2DImage it has parameter for that. The other thing is make sure your image format actually has an alpha channel. Like the example I linked doesn't - so it will be black. But when I pass irr::video::ECF_A8R8G8B8 to createImage then the background will be transparent.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
n00bc0de
Posts: 138
Joined: Tue Oct 04, 2022 1:21 am

Re: Loading different size images in emscripten

Post by n00bc0de »

It looks like you did this with the IImage rather than using a texture target. I should have looked at the IImage documentation more.

Thanks. I think this is exactly what I needed.
Post Reply