Quantcast
Viewing all articles
Browse latest Browse all 40524

Problem with lighting and 3d shapes in openframeworks 9

I just migrated over to OF 9 and noticed something is not working as before with the lighting in one of my apps. I've isolated the problem into a small test program which you can see below:

void ofApp::setup(){
    mPointLight.setPosition(100,100, 500);

    mPointLight.setSpecularColor( ofFloatColor(1.f, 1.f, 1.f) );
    mPointLight.setDiffuseColor(  ofFloatColor(1.f, 1.f, 1.f) );
    mPointLight.setSpotConcentration(5.0);

    mPointLight.setPointLight();

    glEnable(GL_DEPTH_TEST);
    ofEnableLighting();
    mPointLight.enable();
}

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

}

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

    ofBackground(ofColor::gray);
    ofEnableLighting();
    mPointLight.enable();
    ofSetColor(ofRandom(255));
    ofDrawSphere(ofGetWidth()/2, ofGetHeight()/2, -50, 105);


    mPointLight.disable();
    ofDisableLighting();

}

With OF 8.4 this draws a sphere with some lighting that randomly changes colour each frame(which is what I want), but on OF 9 the spheres colour stays the same?

Can anyone advice on what i'm doing wrong?

Thanks.


Viewing all articles
Browse latest Browse all 40524

Trending Articles