Akira-Hayasaka / ofxGLEditor

Script editor for oF Live Coding
GNU General Public License v2.0
100 stars 16 forks source link

OpenGL 4 support #26

Open danomatika opened 2 years ago

danomatika commented 2 years ago

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.

danomatika commented 2 years ago

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.

d3cod3 commented 1 year ago

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?

danomatika commented 1 year ago

Maybe try a newer fork?

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

d3cod3 commented 1 year ago

Thanks a lot for the info, i'll test those and come back with the results.

danomatika commented 9 months ago

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: Screenshot 2023-11-12 at 12 37 16 AM

danomatika commented 9 months ago

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.