Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lighting abstractions: Initialization bug #2

Open
jamshark70 opened this issue Jan 16, 2021 · 1 comment
Open

Lighting abstractions: Initialization bug #2

jamshark70 opened this issue Jan 16, 2021 · 1 comment

Comments

@jamshark70
Copy link

In pointlight, spotlight, and the other similar light sources, I get an error about accessing a nil item when creating an instance.

It looks like M.setup() is called at least once before the window is created. At that time, the setup function won't create the ofLight object -- but then its logic is of the form:

  • If the window exists:
    • Then create the window and set some properties.
  • Always set the abstraction's user facing parameters -- and these functions set properties of the ofLight object (which may not exist if the window didn't exist -- here's the error).

I can think of two solutions:

  • Move the parameter-setting functions into the if block, not outside.
  • Or, guarantee that the setup function will not fire until the window is ready.

In my revisions, I did the first. If the second is better, that would be ok too.

@60-hz
Copy link
Owner

60-hz commented Jan 16, 2021

Thanks, that's true. I also removed the light:disable() causing an error when the object was removed.
Anyway, lights are a bit confusing and sometimes unstable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants