mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#168 Added hacklish control over Fixed Function default light.
This commit is contained in:
parent
20e7e9ec6e
commit
853e92723b
@ -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()).
|
/// 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
|
/// 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.
|
/// are likely to affect our rendering.
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RenderSequence::preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext)
|
void RenderSequence::preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext) const
|
||||||
{
|
{
|
||||||
CVF_CALLSITE_OPENGL(oglContext);
|
CVF_CALLSITE_OPENGL(oglContext);
|
||||||
CVF_CHECK_OGL(oglContext);
|
CVF_CHECK_OGL(oglContext);
|
||||||
@ -341,8 +362,8 @@ void RenderSequence::preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext
|
|||||||
|
|
||||||
// TODO Work out a proper solution for this
|
// TODO Work out a proper solution for this
|
||||||
// Should probably add some RenderState that encapsulates a light source
|
// 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);
|
const Vec3f spotDirection(0.0f, 0.0f, -1.0f);
|
||||||
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spotDirection.ptr());
|
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spotDirection.ptr());
|
||||||
|
@ -70,17 +70,21 @@ public:
|
|||||||
|
|
||||||
BoundingBox boundingBox() const;
|
BoundingBox boundingBox() const;
|
||||||
|
|
||||||
|
void setDefaultFFLightPositional(const Vec3f& position);
|
||||||
|
void setDefaultFFLightDirectional(const Vec3f& direction);
|
||||||
|
|
||||||
void render(OpenGLContext* oglContext);
|
void render(OpenGLContext* oglContext);
|
||||||
const PerformanceInfo& performanceInfo() const;
|
const PerformanceInfo& performanceInfo() const;
|
||||||
|
|
||||||
void deleteOrReleaseOpenGLResources(OpenGLContext* oglContext);
|
void deleteOrReleaseOpenGLResources(OpenGLContext* oglContext);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext);
|
void preRenderApplyExpectedOpenGLState(OpenGLContext* oglContext) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Collection<Rendering> m_renderings; // One rendering per render pass
|
Collection<Rendering> m_renderings; // One rendering per render pass
|
||||||
PerformanceInfo m_performanceInfo; // Performance summary for this view
|
PerformanceInfo m_performanceInfo; // Performance summary for this view
|
||||||
|
Vec4f m_defaultGlLightPosition; // Fixed function default setting for glLightfv(GL_LIGHT0, GL_POSITION, m_defaultGlLightPosition.ptr());
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user