I am trying to render to a texture in the emscripten port and I always get a black screen. It works find if just using the default render target.
Are render targets just not supported through emscripten?
Render targets in emscripten
Re: Render targets in emscripten
Sorry didn't try RTT's back then and it's been a few years since I experimented with emscripten. I just run a quick test and it seems emscripten will need either power of two textures (so like 128, 256, 512 etc) or CLAMP_TO_EDGE has to be set when drawing textures. As a workaround - either use a power of two render target texture or set the following lines before drawing your RTT:
It's probably a good idea to just make this the default for InitMaterial2D in the WebGL driver, but as usual I checked the forum before going to sleep, so not digging deeper anymore today ;-)
Also warning - emscripten was pretty experimental. Also by now some of it is a bit outdated (haven't touched that in 3-4 years). Some stuff will not work yet ,for example particles. If you have other bugs always a good idea to check the console output in the browser (F12 in Firefox).
Code: Select all
SMaterial& matRtt = driver->getMaterial2D();
matRtt.TextureLayer[0].TextureWrapU = ETC_CLAMP_TO_EDGE;
matRtt.TextureLayer[0].TextureWrapV = ETC_CLAMP_TO_EDGE;
driver->enableMaterial2D(true);
Also warning - emscripten was pretty experimental. Also by now some of it is a bit outdated (haven't touched that in 3-4 years). Some stuff will not work yet ,for example particles. If you have other bugs always a good idea to check the console output in the browser (F12 in Firefox).
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Render targets in emscripten
Thanks. That instantly fixed my issue.
Re: Render targets in emscripten
If you update to svn ogl-es [r6674] you can now remove those lines again if you did draw the RTT with drawTexture functions.
I had hoped I could make clamp to edge default for 2D, but turns out that can break stuff, so now WebGL driver doing checks.
Interestingly enough we already convert all other textures to power of two. Which may not really be necessary in all cases I suppose, but I won't touch that for now.
I had hoped I could make clamp to edge default for 2D, but turns out that can break stuff, so now WebGL driver doing checks.
Interestingly enough we already convert all other textures to power of two. Which may not really be necessary in all cases I suppose, but I won't touch that for now.
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm