Commit 0b9ea0c4 authored by Jan Möbius's avatar Jan Möbius
Browse files

Multisampling for material node

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5845 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 8917d0dd
......@@ -66,7 +66,7 @@ namespace QtWidgets {
QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
SceneGraph::MaterialNode * _node )
SceneGraph::MaterialNode * _node )
: QDialog( _parent ),
node_(_node)
{
......@@ -90,6 +90,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
blendParam1_ = bak_blendParam1_ = node_->blending_param1();
blendParam2_ = bak_blendParam2_ = node_->blending_param2();
colorMaterial_ = bak_colorMaterial_ = node_->colorMaterial();
multiSampling_ = bak_multiSampling_ = node_->multiSampling();
baseColorActive_ = bak_baseColorActive_ = node_->applyProperties() & SceneGraph::MaterialNode::BaseColor;
materialActive_ = bak_materialActive_ = node_->applyProperties() & SceneGraph::MaterialNode::Material;
......@@ -101,6 +102,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
blendingActive_ = bak_blendingActive_ = node_->applyProperties() & SceneGraph::MaterialNode::Blending;
backfaceCullingActive_ = bak_backfaceCullingActive_ = node_->applyProperties() & SceneGraph::MaterialNode::BackFaceCulling;
colorMaterialActive_ = bak_colorMaterialActive_ = node_->applyProperties() & SceneGraph::MaterialNode::ColorMaterial;
multiSamplingActive_ = bak_multiSamplingActive_ = node_->applyProperties() & SceneGraph::MaterialNode::MultiSampling;
setButtonColor( ui_.baseColorButton, color_ );
setButtonColor( ui_.ambientColorButton, ambient_ );
......@@ -116,6 +118,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
ui_.alphaTest->setChecked( alphaTest_ );
ui_.alpha->setValue((int) alphaValue_ * 100.0f );
ui_.colorMaterial->setChecked( colorMaterial_ );
ui_.multiSampling->setChecked( multiSampling_ );
ui_.blending->setChecked( blending_ );
for (int i=0; i < ui_.blendParam1->count(); i++)
......@@ -138,6 +141,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
ui_.blendingActive->setChecked( blendingActive_ );
ui_.backfaceCullingActive->setChecked( backfaceCullingActive_ );
ui_.colorMaterialActive->setChecked( colorMaterialActive_ );
ui_.multiSamplingActive->setChecked( multiSamplingActive_ );
connect( ui_.baseColorButton, SIGNAL( clicked() ), this, SLOT( enableProperty() ) );
connect( ui_.ambientColorButton, SIGNAL( clicked() ), this, SLOT( enableProperty() ) );
......@@ -152,6 +156,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
connect( ui_.alphaTest, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.blending, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.colorMaterial, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.multiSampling, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.baseColorButton, SIGNAL( clicked() ),
this, SLOT( changeBaseColor() ) );
......@@ -180,6 +185,8 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
this, SLOT( changeAlphaValue(int) ) );
connect( ui_.colorMaterial, SIGNAL( toggled(bool) ),
this, SLOT( changeColorMaterial(bool) ) );
connect( ui_.multiSampling, SIGNAL( toggled(bool) ),
this, SLOT( changeMultiSampling(bool) ) );
connect( ui_.blending, SIGNAL( toggled(bool) ),
this, SLOT( changeBlending(bool) ) );
connect( ui_.blendParam1, SIGNAL( currentIndexChanged(const QString&) ),
......@@ -208,6 +215,8 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
this, SLOT( changeActive(bool) ) );
connect( ui_.colorMaterialActive, SIGNAL( toggled(bool) ),
this, SLOT( changeActive(bool) ) );
connect( ui_.multiSamplingActive, SIGNAL( toggled(bool) ),
this, SLOT( changeActive(bool) ) );
connect( ui_.alphaTest, SIGNAL( toggled(bool) ),
ui_.alpha, SLOT( setEnabled(bool) ) );
......@@ -231,6 +240,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
ui_.blendingActive->setChecked(blendingActive_);
ui_.backfaceCullingActive->setChecked(backfaceCullingActive_);
ui_.colorMaterialActive->setChecked(colorMaterialActive_);
ui_.multiSamplingActive->setChecked(multiSamplingActive_);
connect( ui_.okButton, SIGNAL( clicked() ),
this, SLOT( accept() ) );
......@@ -308,6 +318,7 @@ void QtMaterialDialog::applyChanges()
if (blendingActive_) properties = properties | SceneGraph::MaterialNode::Blending;
if (backfaceCullingActive_) properties = properties | SceneGraph::MaterialNode::BackFaceCulling;
if (colorMaterialActive_) properties = properties | SceneGraph::MaterialNode::ColorMaterial;
if (multiSamplingActive_) properties = properties | SceneGraph::MaterialNode::MultiSampling;
node_->applyProperties(properties);
......@@ -341,6 +352,11 @@ void QtMaterialDialog::applyChanges()
else
node_->disable_color_material();
if ( multiSampling_ )
node_->enable_multisampling();
else
node_->disable_multisampling();
// this is not optimal !
if(round_points_ || line_smooth_ )
node_->enable_alpha_test(0.5);
......@@ -374,6 +390,7 @@ void QtMaterialDialog::undoChanges()
if (bak_blendingActive_) properties = properties | SceneGraph::MaterialNode::Blending;
if (bak_backfaceCullingActive_) properties = properties | SceneGraph::MaterialNode::BackFaceCulling;
if (bak_colorMaterialActive_) properties = properties | SceneGraph::MaterialNode::ColorMaterial;
if (bak_multiSampling_) properties = properties | SceneGraph::MaterialNode::MultiSampling;
node_->applyProperties(properties);
......@@ -407,6 +424,11 @@ void QtMaterialDialog::undoChanges()
else
node_->disable_color_material();
if ( bak_multiSampling_ )
node_->enable_multisampling();
else
node_->disable_multisampling();
setButtonColor( ui_.diffuseColorButton, diffuse_ );
setButtonColor( ui_.ambientColorButton, ambient_ );
setButtonColor( ui_.specularColorButton, specular_ );
......@@ -568,6 +590,15 @@ QtMaterialDialog::changeColorMaterial(bool _b)
//-----------------------------------------------------------------------------
void
QtMaterialDialog::changeMultiSampling(bool _b)
{
multiSampling_ = (bool)_b;
applyChanges();
}
//-----------------------------------------------------------------------------
void
QtMaterialDialog::changeAlphaValue(int _new)
{
......@@ -652,6 +683,7 @@ QtMaterialDialog::changeActive(bool /*toggle*/)
blendingActive_ = ui_.blendingActive->isChecked();
backfaceCullingActive_ = ui_.backfaceCullingActive->isChecked();
colorMaterialActive_ = ui_.colorMaterialActive->isChecked();
multiSamplingActive_ = ui_.multiSamplingActive->isChecked();
applyChanges();
}
......@@ -674,6 +706,7 @@ QtMaterialDialog::enableProperty(int /*i*/)
else if (sender() == ui_.alphaTest) ui_.alphaTestActive->setChecked( true );
else if (sender() == ui_.blending) ui_.blendingActive->setChecked( true );
else if (sender() == ui_.colorMaterial) ui_.colorMaterialActive->setChecked( true );
else if (sender() == ui_.multiSampling) ui_.multiSamplingActive->setChecked( true );
}
//-----------------------------------------------------------------------------
......@@ -695,6 +728,7 @@ QtMaterialDialog::enableProperty()
else if (sender() == ui_.alphaTest) ui_.alphaTestActive->setChecked( true );
else if (sender() == ui_.blending) ui_.blendingActive->setChecked( true );
else if (sender() == ui_.colorMaterial) ui_.colorMaterialActive->setChecked( true );
else if (sender() == ui_.multiSampling) ui_.multiSamplingActive->setChecked( true );
}
......
......@@ -82,7 +82,7 @@ class ACGDLLEXPORT QtMaterialDialog : public QDialog
public:
QtMaterialDialog( QWidget * _parent,
SceneGraph::MaterialNode * _node );
SceneGraph::MaterialNode * _node );
~QtMaterialDialog() {}
......@@ -98,7 +98,7 @@ private:
Vec4f convertColor( QColor _color);
void setButtonColor( QPushButton * _button,
const Vec4f & _color );
const Vec4f & _color );
private slots:
......@@ -118,6 +118,7 @@ private slots:
void changeBlendingParam1(const QString& _name);
void changeBlendingParam2(const QString& _name);
void changeColorMaterial(bool _b);
void changeMultiSampling(bool _b);
void changeActive(bool toggle);
......@@ -153,6 +154,7 @@ private:
GLenum blendParam1_, bak_blendParam1_;
GLenum blendParam2_, bak_blendParam2_;
bool colorMaterial_, bak_colorMaterial_;
bool multiSampling_, bak_multiSampling_;
bool baseColorActive_, bak_baseColorActive_;
bool materialActive_, bak_materialActive_;
......@@ -164,6 +166,7 @@ private:
bool blendingActive_, bak_blendingActive_;
bool backfaceCullingActive_, bak_backfaceCullingActive_;
bool colorMaterialActive_, bak_colorMaterialActive_;
bool multiSamplingActive_, bak_multiSamplingActive_;
SceneGraph::MaterialNode * node_;
......
......@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>616</width>
<height>632</height>
<width>621</width>
<height>663</height>
</rect>
</property>
<property name="sizePolicy" >
......@@ -416,7 +416,7 @@ back is visible should be rendered.</string>
</item>
</layout>
</item>
<item row="3" column="0" >
<item row="4" column="0" >
<widget class="QCheckBox" name="blending" >
<property name="layoutDirection" >
<enum>Qt::LeftToRight</enum>
......@@ -426,7 +426,7 @@ back is visible should be rendered.</string>
</property>
</widget>
</item>
<item row="4" column="1" >
<item row="5" column="1" >
<widget class="QComboBox" name="blendParam1" >
<property name="currentIndex" >
<number>1</number>
......@@ -503,7 +503,7 @@ back is visible should be rendered.</string>
</item>
</widget>
</item>
<item row="5" column="1" >
<item row="6" column="1" >
<widget class="QComboBox" name="blendParam2" >
<item>
<property name="text" >
......@@ -584,6 +584,13 @@ back is visible should be rendered.</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QCheckBox" name="multiSampling" >
<property name="text" >
<string>Multi Sampling</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......@@ -678,6 +685,13 @@ back is visible should be rendered.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="multiSamplingActive" >
<property name="text" >
<string>Multi Sampling</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -75,7 +75,8 @@ MaterialNode::MaterialNode( BaseNode* _parent,
blend_param1_(GL_ONE),
blend_param2_(GL_ZERO),
color_material_(true),
backface_culling_(false)
backface_culling_(false),
multiSampling_(true)
{}
......@@ -120,9 +121,10 @@ void MaterialNode::enter(GLState& _state, unsigned int _drawmode )
round_points_backup_ = glIsEnabled(GL_POINT_SMOOTH) &&
glIsEnabled(GL_ALPHA_TEST);
if( round_points_)
if( round_points_) {
glHint(GL_POINT_SMOOTH_HINT,GL_NICEST);
glEnable(GL_POINT_SMOOTH);
else
} else
glDisable(GL_POINT_SMOOTH);
}
......@@ -132,12 +134,23 @@ void MaterialNode::enter(GLState& _state, unsigned int _drawmode )
glIsEnabled(GL_ALPHA_TEST);
if( lines_smooth_) {
glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
glEnable(GL_LINE_SMOOTH);
} else
glDisable(GL_LINE_SMOOTH);
}
if (applyProperties_ & MultiSampling)
{
multiSampling_backup_ = glIsEnabled(GL_MULTISAMPLE);
if( multiSampling_) {
glEnable(GL_MULTISAMPLE);
} else {
glDisable(GL_MULTISAMPLE);
}
}
if (applyProperties_ & AlphaTest)
{
......@@ -266,6 +279,17 @@ void MaterialNode::leave(GLState& _state, unsigned int _drawmode )
glDisable(GL_LINE_SMOOTH);
}
if (applyProperties_ & MultiSampling)
{
if( multiSampling_backup_) {
glEnable(GL_MULTISAMPLE);
} else {
glDisable(GL_MULTISAMPLE);
}
}
if (applyProperties_ & AlphaTest)
{
if (alpha_test_backup_)
......
......@@ -94,7 +94,9 @@ public:
/// backface culling
BackFaceCulling=256,
/// Color Material ( Only when a drawmode using shading and lighting is enabled )
ColorMaterial=512
ColorMaterial=512,
/// MultiSampling
MultiSampling=1024
};
......@@ -132,7 +134,7 @@ public:
/** @} */
//===========================================================================
/** @name Color settings ( Applied to all objects below this node )
/** @name Color and material settings ( Applied to all objects below this node )
* @{ */
//===========================================================================
......@@ -174,6 +176,11 @@ public:
/// get colorMaterial state
bool colorMaterial() { return color_material_; }
/// set shininess
void set_shininess(float _s) { shininess_ = _s; }
/// get shininess
float shininess() const { return shininess_; }
/** @} */
//===========================================================================
......@@ -220,12 +227,35 @@ public:
/** @} */
//===========================================================================
/** @name Other Rendering options
* @{ */
//===========================================================================
/// Enable Multisampling
void enable_multisampling() {
multiSampling_ = true;
}
/// enable alpha test (draw pixels if alpha >= _clip)
void disable_multisampling() {
multiSampling_ = false;
}
/// Get state of multisampling
bool multiSampling() {
return multiSampling_;
}
/// Set state of multisampling
void set_multisampling( bool _state ) {
multiSampling_ = _state;
}
/** @} */
/// set shininess
void set_shininess(float _s) { shininess_ = _s; }
/// get shininess
float shininess() const { return shininess_; }
......@@ -251,6 +281,8 @@ public:
/// disable backface culling (not active by default, see applyProperties)
void disable_backface_culling() { backface_culling_ = false; }
/// get properties that will be applied (OR'ed ApplyProperties)
unsigned int applyProperties() const { return applyProperties_; }
......@@ -273,18 +305,20 @@ private:
float point_size_, point_size_backup_;
float line_width_, line_width_backup_;
bool round_points_, round_points_backup_;
bool lines_smooth_, lines_smooth_backup_;
bool round_points_, round_points_backup_;
bool lines_smooth_, lines_smooth_backup_;
bool alpha_test_, alpha_test_backup_;
float alpha_clip_, alpha_clip_backup_;
bool alpha_test_, alpha_test_backup_;
float alpha_clip_, alpha_clip_backup_;
bool blending_, blending_backup_;
GLenum blend_param1_, blend_param1_backup_;
GLenum blend_param2_, blend_param2_backup_;
bool blending_, blending_backup_;
GLenum blend_param1_, blend_param1_backup_;
GLenum blend_param2_, blend_param2_backup_;
bool color_material_, color_material_backup_;
bool backface_culling_,backface_culling_backup_;
bool color_material_,color_material_backup_;
bool backface_culling_, backface_culling_backup_;
bool multiSampling_, multiSampling_backup_;
};
......
......@@ -1072,7 +1072,6 @@ draw_faces(FaceMode _mode)
}
}
glBindTexture( GL_TEXTURE_2D, (*textureMap_)[texture] );
// Remember active texture to skip extra switches
......
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