Commit 8d818aec authored by Jan Möbius's avatar Jan Möbius
Browse files

Add multisampling and option to set global multisampling setting to glstate. (...

Add multisampling and option to set global multisampling setting to glstate. ( And use it in materialnode )

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6688 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d5a95160
......@@ -64,7 +64,9 @@ const float GLState::default_shininess(100.0);
GLState::GLState(bool _updateGL)
: updateGL_(_updateGL),
: multisampling_(false),
allow_multisampling_(true),
updateGL_(_updateGL),
blending_(false),
msSinceLastRedraw_ (1)
{
......@@ -105,8 +107,11 @@ void GLState::initialize()
// thickness
set_point_size(1.0f);
set_line_width(1.0f);
// multisampling
set_multisampling(true);
// lighting
set_twosided_lighting(true);
}
......@@ -700,6 +705,35 @@ void GLState::set_twosided_lighting(bool _b)
//-----------------------------------------------------------------------------
void GLState::set_multisampling(bool _b)
{
multisampling_ = _b;
if (updateGL_)
{
makeCurrent();
if ( allow_multisampling_ ) {
if ( _b )
glEnable( GL_MULTISAMPLE );
else
glDisable( GL_MULTISAMPLE );
} else {
multisampling_ = false;
if ( glIsEnabled( GL_MULTISAMPLE ) )
glDisable( GL_MULTISAMPLE );
}
}
}
//-----------------------------------------------------------------------------
Vec3d GLState::eye() const
{
......
......@@ -370,6 +370,20 @@ public:
void set_twosided_lighting(bool _b);
/// get whether transparenet or solid objects should be drawn
bool twosided_lighting() { return twosided_lighting_; }
//--- Multi Sampling --------------------------------------------------------
/// Enable or disable multisampling
void set_multisampling( bool _b );
/// Get current multisampling state
bool multisampling(){ return multisampling_; };
/// Disable multisampling globally
void allow_multisampling( bool _b ) { allow_multisampling_ = _b; };
/// Check if Multisampling is globally disabled
bool multisampling_alloowed(){ return allow_multisampling_; };
//--- picking ---------------------------------------------------------------
......@@ -451,8 +465,12 @@ private: //--------------------------------------------------------------------
// thickness
float point_size_, line_width_;
// lighting
bool twosided_lighting_;
// Multisampling settings
bool multisampling_;
bool allow_multisampling_;
// helper: should GL matrices be updated
bool updateGL_;
......
......@@ -142,14 +142,8 @@ void MaterialNode::enter(GLState& _state, unsigned int _drawmode )
if (applyProperties_ & MultiSampling)
{
multiSampling_backup_ = glIsEnabled(GL_MULTISAMPLE);
if( multiSampling_) {
glEnable(GL_MULTISAMPLE);
} else {
glDisable(GL_MULTISAMPLE);
}
multiSampling_backup_ = _state.multisampling();
_state.set_multisampling( multiSampling_ );
}
if (applyProperties_ & AlphaTest)
......@@ -280,15 +274,7 @@ void MaterialNode::leave(GLState& _state, unsigned int _drawmode )
}
if (applyProperties_ & MultiSampling)
{
if( multiSampling_backup_) {
glEnable(GL_MULTISAMPLE);
} else {
glDisable(GL_MULTISAMPLE);
}
}
_state.set_multisampling( multiSampling_backup_ );
if (applyProperties_ & AlphaTest)
{
......
Markdown is supported
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