Ofxgui : text missing

HI,

I have a problem. I can’t see the text of my buttons, labels, etc…
It occurs in the parameterGroupExample and my own projects.
I’m working on osx, and recent working release of OF
Any idea ?

Cheers
Sebastien Albert

yeah, i’m getting the same problem in master with that example, will take a look

it’s fixed now

Wow, so quick ! thx.

Hi,
I’m having this text missing issue on a clean built project. Also it displaces the slider bars when I move it around. I’m working on latest version of Yosemite and OF release 8.4. The example works fine. Is there something weird I’m doing in my code?

#include "testApp.h"

//--------------------------------------------------------------
void testApp::setup(){

ofEnableDepthTest();
ofEnableLighting();
ofSetSmoothLighting(true);
ofBackground(255);
pointLight.setDiffuseColor( ofFloatColor(.85, .85, .55) );
pointLight.setSpecularColor( ofFloatColor(1.f, 1.f, 1.f) );

  
c.set(1,0,0, 1);
plane.set(ofGetWidth(), ofGetHeight());
plane.setResolution(20,20);

mesh.setupIndicesAuto();
mesh = plane.getMesh();
mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);

screenSize = false;

meshPos.set(0,0,0);
meshRotate.set(0,0,0);
lightPos.set(0,0,0);
meshScale.set(1.0,1.0);


string guiPath = "mesh.xml";

gui.setup("audio", guiPath, 20, 20);
gui.add(posX.setup("posX", 0, 0, ofGetWidth()));
gui.add(posY.setup("posY", 0, 0, ofGetHeight()));
gui.add(posZ.setup("posZ", 0, -500, 500));

gui.add(scaleX.setup("scaleX", 1, 0.0, 1.0));
gui.add(scaleX.setup("scaleY", 1, 0.0, 1.0));

//gui.add(audioMirror.setup("audioMirror", true));
gui.setTextColor(ofColor::crimson);
gui.loadFromFile(guiPath);

}

//--------------------------------------------------------------
void testApp::update(){

ofVec3f planeDims = plane.getResolution();
float planeAngleX = ofGetElapsedTimef() * 1.0;
float planeAngleInc = 3.f/(float)planeDims.x;
ofVec3f vert;
for(int i = 0; i < mesh.getNumIndices(); i++ ) {
    planeAngleX += planeAngleInc;
    int ii = mesh.getIndex( i );
    vert = mesh.getVertex( ii );
    float meshScale = 100; //put fft here
    vert.z = ofNoise(planeAngleX) * meshScale;
    mesh.setVertex( ii, vert );
}

 pointLight.setPosition((ofGetWidth()*.5)+ cos(ofGetElapsedTimef()*.005)*(ofGetWidth()*.3),  ofGetHeight() * .45, 200);


//Change Color Here

c.set(.65, 1., 1., 1.);

//Move Mesh here

meshPos.set(posX,posY,posZ);
meshRotate.set(0,0,0);
meshScale.set(scaleX,scaleY);

}

//--------------------------------------------------------------
void testApp::draw(){

pointLight.enable();
//ofSetColor(pointLight.getDiffuseColor());
//pointLight.draw();



ofSetColor(c);
ofPushMatrix();

ofTranslate(meshPos);
//float rotation = sin(ofGetElapsedTimef() * 0.25);
float rotateX = meshRotate.x;
float rotateY = meshRotate.y;
float rotateZ = meshRotate.z;

ofRotateX(rotateX);
ofRotateY(rotateY);
ofRotateZ(rotateZ);
ofScale(meshScale.x, meshScale.y);
mesh.draw();
ofSetColor(ofFloatColor::white);
mesh.drawWireframe();
ofPopMatrix();



ofPushStyle();
ofPushMatrix();
gui.draw();
ofPopMatrix();
ofPopStyle();

}

//--------------------------------------------------------------
void testApp::keyPressed(int key){

if ( key == ' ' ) {
    
    screenSize = !screenSize;
    ofSetFullscreen(screenSize);
}

}

Hi there!

You are doing this:

ofPushStyle();
ofPushMatrix();
gui.draw();
ofPopMatrix();
ofPopStyle();

Instead, do ofEnableDepthTest() before you draw your 3D scene, and ofDisableDepthTest() before you draw your GUI.

2 Likes

Hi.
I’m building an app based on the multiWindowOneAppExample to put the gui in another window.
I noticed the same problem when I set the GL version to 4.1. It seems that gui text is missing when another version than 2.1 is used, problem occurs with 3.2 too.
Then I tried to reset GL version to 2.1 back before creating the gui window like :

ofGLFWWindowSettings settings;
settings.setGLVersion(4, 1);
shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);
settings.setGLVersion(2, 1);
shared_ptr<ofAppBaseWindow> guiWindow = ofCreateWindow(settings);

but it doesn’t work, actually it’s worse, everything becomes glitchy.

Arturo, as you already fixed this kind of issue you should probably know what to do ?

Thanks.

this is probably because you are creating the objects in a window context and drawing it in the other. you should be creating things in the window callbacks of the window that it’s going to draw it (in it’s setup call usually). the easiest is to use 2 applications, one per window as it’s demoed in the example.

also you can’t mix opengl versions in 1 application.

there’s a way to share contexts between windows but even with that anything that is not memory (like shaders, fbo, vao…) won’t be shared. to share the context you can do:

ofGLFWWindowSettings settings;
settings.setGLVersion(4, 1);
shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);

settings.shareContextWith = mainWindow;
shared_ptr<ofAppBaseWindow> guiWindow = ofCreateWindow(settings);
1 Like

Sorry I didn’t post the entire code to keep it simple but yes I’m aware of creating the gui stuff in window callbacks. So my main is :

ofGLFWWindowSettings gl_settings;
gl_settings.setGLVersion( 4, 1 );
gl_settings.width = 1024;
gl_settings.height = 768;

shared_ptr<ofAppBaseWindow> main_window = ofCreateWindow( gl_settings );

gl_settings.width = 800;
gl_settings.height = 600;

shared_ptr<ofAppBaseWindow> gui_window = ofCreateWindow( gl_settings );

shared_ptr<ofApp> main_app( new ofApp );
main_app->setupGUI();
ofAddListener( gui_window->events().update, main_app.get(), &ofApp::updateGUI );
ofAddListener( gui_window->events().draw, main_app.get(), &ofApp::drawGUI );

ofRunApp( main_window, main_app );
ofRunMainLoop();

I just tried to set glVersion to 4.1 in the basic guiExemple, without having multiple windows like so :

//	ofSetupOpenGL(1024,768, OF_WINDOW);// <-------- setup the GL context
    ofGLFWWindowSettings gl_settings;
    gl_settings.setGLVersion( 4, 1 );
    gl_settings.width = 1024;
    gl_settings.height = 768;

ofCreateWindow( gl_settings );

// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp( new ofApp());

and again the text disappears, so I think there is really something wrong with ofxGUI and gl version 3+.
I thought maybe a context would be created for each window, but yes I was wrong.

i was actually meaning not to do that and instead use 2 separate applications as is demoed in events/multiWindowExample but since you are calling setupGui right after seting app the gui window it should be ok, in any case it’s preferable to do it the other way since it’s much clear the separation between windows.

i’m trying the gui example with the programmable renderer (i can only test up to 3.2 but it should be the same) and it’s working for me fine. what platform are you in?

I’m on osx 10.10.5, macbook pro 13" mid-2012, new to openFrameworks but sure that my laptop supports 4.1. As you will see 3.2 give me the same thing. nothing in the console : (

Do you have any possible clue ? I can dig it if you don’t get the same result.

thank you I’ll go with your 2 applications solution if it’s better when the problem will be resolved

I was using the release version. I didn’t find out the cause but I can get the text with the github master repo. That’s why we didn’t get the same output, assuming you tested the gui example from your dev repo. So this will be fixed within the next release.
Thank you : )

I had a similar problem with text missing in one of the ofxGui in one of the windows.
This hint about settings.shareContextWith = mainWindow; in ofMain.cpp solved my problem.

#include "ofMain.h"
#include "ofApp.h"
#include "ofAppGLFWWindow.h"

//========================================================================
int main( ){

    
    ofGLFWWindowSettings settings;
    
    settings.setSize(1200, 600);
    settings.setPosition(ofVec2f(500,0));
    settings.resizable = true;
    shared_ptr<ofAppBaseWindow> mainWindow = ofCreateWindow(settings);
    
    settings.shareContextWith = mainWindow;
    
    settings.setSize(450, 800);
    settings.setPosition(ofVec2f(0,0));
    settings.resizable = false;
    shared_ptr<ofAppBaseWindow> oscWindow = ofCreateWindow(settings);
    
    shared_ptr<ofApp> mainApp(new ofApp);
    mainApp->setupOSC();
    ofAddListener(oscWindow->events().draw,mainApp.get(),&ofApp::drawOSC);
    
    ofRunApp(mainWindow, mainApp);
    ofRunMainLoop();

}

1 Like