Destroying Spotlight object affects other ofLight objects

Open
#5,738 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Reproduce the issue using the ofApp.h and ofApp.cpp example, focusing on setSpotlight(), enable(), and spotlight.reset(). Trace ofLight's spotlight cleanup and verify that destroying the spotlight leaves directionalLight functional; done when the supplied directional-light draw continues to work after spotlight destruction.

Written by the indexing model from the issue text.

Description

Hi, I use openGL 2.1 and I learned that up to 8 instance of ofLight object can be used at once in this version.

So I tried to use and destroy ofLight instance and it seemed to be working well this way.

But today I found out that if I create and destroy ofLight instance which is set to spotlight, it caused other ofLight instances to not work properly.

Here's a simplified test code.

in ofApp.h,

   unique_ptr<ofLight> directionalLight, spotlight;

in ofApp.cpp,

//--------------------------------------------------------------
void ofApp::setup(){
    
    //directionalLight
    directionalLight = make_unique<ofLight>();
    directionalLight->setDirectional();
    directionalLight->setOrientation(ofVec3f(0,120,0));
    
    //spotlight
    spotlight = make_unique<ofLight>();
    
    //the following 3 lines below caused directionalLight to not work properly
    //commenting out one of these makes it work again.
    spotlight->setSpotlight();
    spotlight->enable();
    spotlight.reset();

    ofEnableDepthTest();
}

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

}

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

    ofGetGLRenderer()->enableLighting();
    directionalLight->enable();
    
    ofDrawSphere(ofGetWidth()/2, ofGetHeight()/2, ofGetHeight()/4);
    
    directionalLight->disable();
    ofGetGLRenderer()->disableLighting();
}

As it is stated in the code, destroying spotlight with .reset() causes directionalLight to not work properly even though one should not affect the other.

I tested this with pointLight, spotlight and directionalLight and destroying the spotlight only caused this issue.
So I'm pretty certain that this is a bug and I would appreciate if anyone can confirm this issue.

My testing was done with OF 0.9.8 on Mac OS X 10.11.6.

Thanks!

Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openframeworks/openFrameworks

All issues in openframeworks/openFrameworks

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.