craftyjs / Crafty

JavaScript Game Engine
http://craftyjs.com
MIT License
3.42k stars 557 forks source link

Display Text via WebGL #975

Open mucaho opened 8 years ago

mucaho commented 8 years ago

Text is still missing in order to have all display components run on any display backend (see comment). Possible implementations:

Actually approach#1 could be used to create a texture dynamically for all the required letters and fonts at loading time. Then approach#2 can be used to draw individual letters from this dynamically created texture during runtime.

starwed commented 8 years ago

I've thought about this in the past, and I think the best approach would be to create a new "ImageText" component that uses a spritemap, as per approach #2.

That would be useful even outside of WebGL, since games often want custom bitmap fonts.

The idea of automatically rendering a specified style of font using canvas to a bitmap font would complement this approach well.

matthijsgroen commented 8 years ago

Since you guys seem experienced with webGL (and I'm not). I see a lot of examples online of demo's that manipulate images (brightness, hue, saturation, blur) using webgl shaders. How hard is it to add these kind of things to crafty?

This way I could recolor/saturate sprites dynamically with the minimal amount of real assets needed.

MeineZ commented 3 years ago

@matthijsgroen Did you manage to get this to work? I'd like to apply a hue-rotation filter to my images, but I'm not able to find a solution at this moment.

Or perhaps this has been added to the API already? I can't seem to find it in the docs in that case.