This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to turn on a light through an actionPerformed with opengl Java  RSS feed

 
Michelle Ruth
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing a java program with opengl and I'm trying to get it where the user would select something like lighting on in a JMenu and then it would turn the lighting on in the house/barn... I have a method called LightOn that I put gl.glEnable(gl.GL_LIGHT0); but it just doesn't seem to turn on when I call it from the action performed... Is there something I'm missing from my code that I'm supposed to use instead since I have tried it with a boolean.. So the boolean starts off as false and when the JMenuItem is clicked the actionPerformed will turn the boolean to true and call the method LightOn. In the display method I have what the light is supposed to be

Snippet of code in display method for lighting:



 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have two separate variables both named light.
 
Steve Beckle
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the word "boolean" on line 6 of your second code block. You're redefining "light" rather than referencing the value you defined earlier. Also, just a friendly suggestion, if the intent is to not leave the light on indefinitely once it's been turned on, modify your logic so that if your action command is not "light on", set light=false.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!