diff --git a/Fwk/VizFwk/LibViewing/cvfRenderSequence.cpp b/Fwk/VizFwk/LibViewing/cvfRenderSequence.cpp index b510222bc7..de8cf9582b 100644 --- a/Fwk/VizFwk/LibViewing/cvfRenderSequence.cpp +++ b/Fwk/VizFwk/LibViewing/cvfRenderSequence.cpp @@ -59,8 +59,10 @@ namespace cvf { //------------------------------------------------------------------------------------------------ /// //------------------------------------------------------------------------------------------------ -RenderSequence::RenderSequence() +RenderSequence::RenderSequence() + : m_defaultGlLightPosition(0.5, 5.0, 7.0, 1.0) // Positional Headlight right, up, back from camera { + } @@ -234,6 +236,25 @@ BoundingBox RenderSequence::boundingBox() const } +//-------------------------------------------------------------------------------------------------- +/// Todo: Replace with some renderstate object etc. +//-------------------------------------------------------------------------------------------------- +void RenderSequence::setDefaultFFLightPositional(const Vec3f& position) +{ + m_defaultGlLightPosition = Vec4f(position, 1.0); +} + +//-------------------------------------------------------------------------------------------------- +/// Todo: Replace with some renderstate object etc. +//-------------------------------------------------------------------------------------------------- +void RenderSequence::setDefaultFFLightDirectional(const Vec3f& direction) +{ + // The fourth value= 0.0 makes the light become a directional one, + // with direction from the position towards origo. + + m_defaultGlLightPosition = Vec4f(-direction, 0.0); +} + //-------------------------------------------------------------------------------------------------- /// Get the performance info for the last rendering (last call to render()). //-------------------------------------------------------------------------------------------------- @@ -291,7 +312,7 @@ void RenderSequence::deleteOrReleaseOpenGLResources(OpenGLContext* oglContext) /// in this function, but rather the ones that are likely to have been set by our caller and that /// are likely to affect our rendering. //-------------------------------------------------------------------------------------------------- -void RenderSequence::preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext) +void RenderSequence::preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext) const { CVF_CALLSITE_OPENGL(oglContext); CVF_CHECK_OGL(oglContext); @@ -341,8 +362,8 @@ void RenderSequence::preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext // TODO Work out a proper solution for this // Should probably add some RenderState that encapsulates a light source - const Vec4f lightPosition(0.5f, 5.0f, 7.0f, 1.0f); - glLightfv(GL_LIGHT0, GL_POSITION, lightPosition.ptr()); + + glLightfv(GL_LIGHT0, GL_POSITION, m_defaultGlLightPosition.ptr()); const Vec3f spotDirection(0.0f, 0.0f, -1.0f); glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spotDirection.ptr()); diff --git a/Fwk/VizFwk/LibViewing/cvfRenderSequence.h b/Fwk/VizFwk/LibViewing/cvfRenderSequence.h index 95ca1a5411..56c4cb9ebc 100644 --- a/Fwk/VizFwk/LibViewing/cvfRenderSequence.h +++ b/Fwk/VizFwk/LibViewing/cvfRenderSequence.h @@ -70,17 +70,21 @@ public: BoundingBox boundingBox() const; + void setDefaultFFLightPositional(const Vec3f& position); + void setDefaultFFLightDirectional(const Vec3f& direction); + void render(OpenGLContext* oglContext); const PerformanceInfo& performanceInfo() const; void deleteOrReleaseOpenGLResources(OpenGLContext* oglContext); private: - static void preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext); + void preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext) const; private: Collection m_renderings; // One rendering per render pass PerformanceInfo m_performanceInfo; // Performance summary for this view + Vec4f m_defaultGlLightPosition; // Fixed function default setting for glLightfv(GL_LIGHT0, GL_POSITION, m_defaultGlLightPosition.ptr()); }; }