cdave1 / ftgles

A truetype font rendering library for OpenGL ES on iOS devices (iPad and iPhone)
http://cdave1.github.io/ftgles/
MIT License
142 stars 36 forks source link

Changing FTTextureFont color on gles2 branch #12

Open zeitkunst opened 10 years ago

zeitkunst commented 10 years ago

First off, thanks for writing this! I've been able get it to work on the Raspberry Pi by using the gles2 branch. However, I'm now having difficulty changing the color of the font, and I believe it's due to the change in FTTextureFont.cpp in this commit: https://github.com/cdave1/ftgles/blob/20a245ee569d5c08896b250d832729e0463ddfaa/ftgles/src/FTFont/FTTextureFont.cpp

I'm not an expert on GLES2, so I'm not sure why you're unable to use glGetFloatv to get the current color. Do you have a solution for changing the font color in some other fashion? My only through right now is to add a separate method to set the color.

Thanks!

zeitkunst commented 10 years ago

As a follow-up, I've added a SetColor method to the FTFont class in ftgles to enable setting the color on the Raspberry Pi. I know that this method is not part of FTGL, but it's necessary to enable color changing on the Pi. The changes are in my forked repository (https://github.com/zeitkunst/ftgles/tree/gles2), and I can create a pull request if you would like.

cdave1 commented 10 years ago

This looks like a reasonable solution for now. An alternative is to set a vec4 uniform on the shader, and then change the color within the pixel shader. I've pushed an update to the gles2 branch showing this.

However, the general problem is that the structure of FTGLES was originally designed to work in immediate mode, so it's not very compatible with a shader pipeline. I think the entire project needs to be forked and re-written.

Happy to include your changes, just send a push request when you're ready!