Unable to light up 'ofxGui' & 'font.drawstring'

Hello all,

I’m using ofLight to light up multiple ofSpherePrimitives in a 3D enviorment. In this 3D enviorment I also have some text drawn using .drawstring() and an OfxGui to control certain characteristics/elements. Unfortunately the text and the OfxGui aren’t being lit up. I’m assuming this is because of how ofLight renders certain objects. Are there any other ways I can light up .drawstring() and OfxGui?

Thanks!

Hi,
Something like this will make the text and gui visible, but indeed not lit by ofLight:
(from /examples/gl/singleLightExample)

    ofEnableLighting();
        pointLight.enable();
        ofDrawSphere(0, 0, -200, 100);
    ofDisableLighting();
    
    ofSetColor(255, 255, 255);
    ofDrawBitmapString("Test", 20, 20);

Is this helpful? Or do you actually want the text and gui to interact with the light?

Hi,
Thank you so much for this. This code worked for lighting up the drawstring (didn’t even have to use pointlight.enable();), but unfortunately the OfxGui is still pretty dark. Do you have any other ideas? I don’t need OfxGui to interact with the light, I just need light to be shone on the UI because right now its pretty dark.

So I played a bit with the example I mentioned earlier, and found out that it has to do with ofEnableDepthTest(); Can’t exactly tell why.

    ofEnableLighting();
        pointLight.enable();
        ofDrawSphere(0, 0, -200, 100);
    ofDisableLighting();
    
    ofSetColor(255, 255, 255);
    ofDrawBitmapString("Test", 20, 20);
    ofDisableDepthTest();
    gui.draw();
    ofEnableDepthTest();

Hey, sorry for the late response, but this pointed me in the right direction. What if I found that works is to draw a rectangle around the gui or text and light that rectangle up with ofEnableLighting(); like this:

ofEnableLighting();
ofSetColor(0, 0, 0);
ofNoFill();
ofDrawRectangle(0, 600, 768, 300);
ofDisableLighting();

// and then draw your gui and text

font.drawString("Water - H2O", 585, 640);

gui.draw();