Commit ab8b0fcc authored by Mike Kremer's avatar Mike Kremer
Browse files

We now get the correct GL_MAX_LIGHTS value.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8973 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 494060b9
......@@ -61,10 +61,10 @@
namespace ACG {
namespace SceneGraph {
static LightSourceHandle lightSourceHandle;
//== IMPLEMENTATION ==========================================================
static LightSourceHandle* lightSourceHandle = 0;
//default Constructor
LightSource::LightSource()
{
......@@ -200,16 +200,18 @@ LightNode::LightNode( BaseNode* _parent,
: BaseNode(_parent, _name),
lightId_(0) {
lightId_ = lightSourceHandle.getLight(this);
//std::cerr << "Getting light id: " << lightId_ << std::endl;
//std::cerr << "GL_MAX_LIGHTS: " << GL_MAX_LIGHTS << std::endl;
if(lightSourceHandle == 0) {
lightSourceHandle = new LightSourceHandle();
}
lightId_ = lightSourceHandle->getLight(this);
}
//----------------------------------------------------------------------------
LightNode::~LightNode() {
lightSourceHandle.removeLight(this);
lightSourceHandle->removeLight(this);
}
//----------------------------------------------------------------------------
......
......@@ -57,6 +57,7 @@
#include "ACG/Scenegraph/BaseNode.hh"
#include <OpenFlipper/common/GlobalDefines.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include "ACG/GL/gl.hh"
#include <string>
#include <vector>
......@@ -258,13 +259,15 @@ private:
* Assign a unique OpenGL light source identifier to each of the
* light source nodes in the scene. These relations are
* stored in a map. If there is no free light source left,
* return GL_FALSE as light source enumerator.
* return GL_INVALID_ENUM as light source enumerant.
*/
class DLLEXPORT LightSourceHandle {
public:
LightSourceHandle() {
for(int i = 0; i < GL_MAX_LIGHTS; ++i) {
// Get max number of lights
GLint maxLights;
glGetIntegerv(GL_MAX_LIGHTS, &maxLights);
for(int i = 0; i < maxLights; ++i) {
lights_.insert(std::pair<GLenum, LightNode*>(GL_LIGHT0 + i, 0));
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment