Working with more then 8 ofLights-objects

Hi everybody,

I’m trying to use a bunch of lights (over 20), I found out that the limit is 8. With help from an other post on this forum I was able to change my GL-version to 3,3. The code for this is below:

ofGLWindowSettings settings;
settings.setGLVersion(3, 3);
ofCreateWindow(settings);
return ofRunApp(new ofApp());

The problem now is that my light doesn’t seem to work anymore. The box is white instead of the color I gave as diffuseColor. The code for the light and box is below:

    void ofApp::setup(){

        ofSetVerticalSync(true);
        cam.setAutoDistance(true);
        light.setup();
        light.setSpotlight();
        light.tilt(-180);
        light.setPosition(0, 0, -60);
        light.setDiffuseColor(ofFloatColor::coral);
    }
    
    void ofApp::draw(){
        cam.begin();
        light.enable();

        ofDrawBox(0, 0, 100, 60,60,1);
        light.draw();
        light.disable();
        cam.end();
    }

Do ofLight-objects work differently in GL 3.3 then they do in the original version? Is there a solution for this?

Thanks!

Ehm, I’m not sure of what I’m saying, but maybe you can just try it out. try this

        light.setSpotlight();
        light.tilt(-180);
        light.setPosition(0, 0, -60);
        light.setDiffuseColor(ofFloatColor::coral);
        // this goes after
        light.setup();

with opengl 3+ in OF 0.9.8 you have to use a material for lighting to work. just create an ofMaterial and draw the geometry between begin and end of the material

in examples/3d/ofNodeExamples there is an example with boxes, multiple lights (2) and materials

Thanks everyone for the answers. I tried the ofNodeExamples and adding an ofMaterial. But it’s still not working:

void ofApp::setup(){
    cam.setAutoDistance(true);
    light.setSpotlight();
    light.tilt(-180);
    light.setPosition(0, 0, -60);
    light.setDiffuseColor(ofFloatColor::coral);
    light.setup();
    mat.setDiffuseColor(ofFloatColor::grey);
    }


  void ofApp::draw(){
    cam.begin();
    light.enable();
    mat.begin();
    ofDrawBox(0, 0, 100, 60,60,1);
    mat.end();
    light.draw();
    light.disable();
    cam.end();
    }
If I but the mat.begin() and end() just after and before the camera's its also not working

it seems to be working for me (i’m using OF from github though):

perhaps if you post a couple of screenshots of what you see in GL3 and GL2 it’ll make it more easy to find out what’s going on

could you try to remove light.enable and light.disable in the draw call?

I downloaded the last nightly update (and updated my project with the project generator inside) and the code is still not working. This is what I’m seeing:


It seems that the material is not even registered, when I change the diffuse color to blue nothing happens.
And this is what I see with GL 2.1: