OpenGL 4 support
danomatika opened this issue · 6 comments
ofxGLEditor does not currently support OpenGL version 4 due to the font stash library. We could make font stash optional and add an additional font rendering library, either of which are selectable via a compile time flag.
One option is to use ofTrueTypeFont directly, but this is relatively slow and the reason why fonstash was added, however it would provide a basic backup which should work across GL versions.
As you say, i think ofTrueTypeFont is a little slow for this, but we can test it anyway, meanwhile we can search maybe for some font stash mod compatible with opengl 4?
Maybe try a newer fork?
- https://github.com/akrinke/Font-Stash
- https://github.com/lsmoura/fontstash
- https://github.com/johnfredcee/fontstash (seems to have the newest development)
Basically, just update the files in libs/fontstash
with the source files in one of the forks, rebuild, and try. You can edit the update script and run it to automate this: https://github.com/Akira-Hayasaka/ofxGLEditor/blob/master/scripts/update_fontstash.sh
Thanks a lot for the info, i'll test those and come back with the results.
I looked at this again and the current fontstash the addon uses does work with OpenGL 3+ but there is a render problem.
To try, change the following in ofxEditorFont.cpp
:
#define GLFONTSTASH_IMPLEMENTATION
//#include "glfontstash.h"
#include "gl3corefontstash.h"
The example looks like this when setting OpenGL 3.3 on macOS:
In thinking about this again, there could be a hybrid solution using ofTrueTypeFont and an ofFbo. We can render the text into a transparent fbo only if it's changed and render highlights & the cursor on top. The slow part is drawing lots of font glyphs, so if you only do it as needed, performance should be much better.