mirror of https://github.com/CGAL/cgal
Improve drawing.
This commit is contained in:
parent
a21da00c9d
commit
3f206e9b60
|
|
@ -737,24 +737,13 @@ void Viewer::init()
|
||||||
|
|
||||||
::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
|
::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
|
||||||
|
|
||||||
if (flatShading)
|
|
||||||
{
|
|
||||||
::glShadeModel(GL_FLAT);
|
::glShadeModel(GL_FLAT);
|
||||||
::glDisable(GL_BLEND);
|
::glDisable(GL_BLEND);
|
||||||
::glDisable(GL_LINE_SMOOTH);
|
::glDisable(GL_LINE_SMOOTH);
|
||||||
::glDisable(GL_POLYGON_SMOOTH_HINT);
|
::glDisable(GL_POLYGON_SMOOTH_HINT);
|
||||||
::glBlendFunc(GL_ONE, GL_ZERO);
|
::glBlendFunc(GL_ONE, GL_ZERO);
|
||||||
::glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
|
::glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
::glShadeModel(GL_FLAT);
|
|
||||||
::glDisable(GL_BLEND);
|
|
||||||
::glDisable(GL_LINE_SMOOTH);
|
|
||||||
::glDisable(GL_POLYGON_SMOOTH_HINT);
|
|
||||||
::glBlendFunc(GL_ONE, GL_ZERO);
|
|
||||||
::glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
|
|
||||||
}
|
|
||||||
initializeOpenGLFunctions();
|
initializeOpenGLFunctions();
|
||||||
compile_shaders();
|
compile_shaders();
|
||||||
}
|
}
|
||||||
|
|
@ -775,24 +764,6 @@ void Viewer::keyPressEvent(QKeyEvent *e)
|
||||||
else if ((e->key()==Qt::Key_F) && (modifiers==Qt::NoButton))
|
else if ((e->key()==Qt::Key_F) && (modifiers==Qt::NoButton))
|
||||||
{
|
{
|
||||||
flatShading = !flatShading;
|
flatShading = !flatShading;
|
||||||
if (flatShading)
|
|
||||||
{
|
|
||||||
::glShadeModel(GL_FLAT);
|
|
||||||
::glDisable(GL_BLEND);
|
|
||||||
::glDisable(GL_LINE_SMOOTH);
|
|
||||||
::glDisable(GL_POLYGON_SMOOTH_HINT);
|
|
||||||
::glBlendFunc(GL_ONE, GL_ZERO);
|
|
||||||
::glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
::glShadeModel(GL_FLAT);
|
|
||||||
::glDisable(GL_BLEND);
|
|
||||||
::glDisable(GL_LINE_SMOOTH);
|
|
||||||
::glDisable(GL_POLYGON_SMOOTH_HINT);
|
|
||||||
::glBlendFunc(GL_ONE, GL_ZERO);
|
|
||||||
::glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
|
|
||||||
}
|
|
||||||
updateGL();
|
updateGL();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_E) && (modifiers==Qt::NoButton))
|
else if ((e->key()==Qt::Key_E) && (modifiers==Qt::NoButton))
|
||||||
|
|
|
||||||
|
|
@ -726,9 +726,9 @@ protected:
|
||||||
{
|
{
|
||||||
vao[0].bind();
|
vao[0].bind();
|
||||||
attrib_buffers(this);
|
attrib_buffers(this);
|
||||||
color.setRgbF(0.7f, 0.2f, 0.7f);
|
color.setRgbF(0.1f, 0.7f, 0.1f);
|
||||||
rendering_program.bind();
|
rendering_program.bind();
|
||||||
rendering_program.setAttributeValue(colorLocation2,color);
|
rendering_program.setUniformValue(colorLocation2,color);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
|
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
|
||||||
rendering_program.release();
|
rendering_program.release();
|
||||||
vao[0].release();
|
vao[0].release();
|
||||||
|
|
@ -737,9 +737,9 @@ protected:
|
||||||
{
|
{
|
||||||
vao[1].bind();
|
vao[1].bind();
|
||||||
attrib_buffers(this);
|
attrib_buffers(this);
|
||||||
color.setRgbF(0.7f, 0.2f, 0.7f);
|
color.setRgbF(0.1f, 0.7f, 0.1f);
|
||||||
rendering_program.bind();
|
rendering_program.bind();
|
||||||
rendering_program.setAttributeValue(colorLocation2,color);
|
rendering_program.setUniformValue(colorLocation2,color);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
|
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(pos_facets.size()/3));
|
||||||
rendering_program.release();
|
rendering_program.release();
|
||||||
vao[1].release();
|
vao[1].release();
|
||||||
|
|
@ -796,23 +796,12 @@ protected:
|
||||||
|
|
||||||
::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
|
::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
|
||||||
|
|
||||||
if (flatShading)
|
|
||||||
{
|
|
||||||
::glShadeModel(GL_FLAT);
|
::glShadeModel(GL_FLAT);
|
||||||
::glDisable(GL_BLEND);
|
::glDisable(GL_BLEND);
|
||||||
::glDisable(GL_LINE_SMOOTH);
|
::glDisable(GL_LINE_SMOOTH);
|
||||||
::glDisable(GL_POLYGON_SMOOTH_HINT);
|
::glDisable(GL_POLYGON_SMOOTH_HINT);
|
||||||
::glBlendFunc(GL_ONE, GL_ZERO);
|
::glBlendFunc(GL_ONE, GL_ZERO);
|
||||||
::glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
|
::glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
::glShadeModel(GL_SMOOTH);
|
|
||||||
::glEnable(GL_BLEND);
|
|
||||||
::glEnable(GL_LINE_SMOOTH);
|
|
||||||
::glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
|
||||||
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
}
|
|
||||||
|
|
||||||
initializeOpenGLFunctions();
|
initializeOpenGLFunctions();
|
||||||
compile_shaders();
|
compile_shaders();
|
||||||
|
|
@ -832,7 +821,6 @@ protected:
|
||||||
{
|
{
|
||||||
const Qt::KeyboardModifiers modifiers = e->modifiers();
|
const Qt::KeyboardModifiers modifiers = e->modifiers();
|
||||||
|
|
||||||
bool handled = false;
|
|
||||||
if ((e->key()==Qt::Key_W) && (modifiers==Qt::NoButton))
|
if ((e->key()==Qt::Key_W) && (modifiers==Qt::NoButton))
|
||||||
{
|
{
|
||||||
wireframe = !wireframe;
|
wireframe = !wireframe;
|
||||||
|
|
@ -840,46 +828,24 @@ protected:
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||||
else
|
else
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
handled = true;
|
|
||||||
updateGL();
|
updateGL();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_F) && (modifiers==Qt::NoButton))
|
else if ((e->key()==Qt::Key_F) && (modifiers==Qt::NoButton))
|
||||||
{
|
{
|
||||||
flatShading = !flatShading;
|
flatShading = !flatShading;
|
||||||
if (flatShading)
|
|
||||||
{
|
|
||||||
::glShadeModel(GL_FLAT);
|
|
||||||
::glDisable(GL_BLEND);
|
|
||||||
::glDisable(GL_LINE_SMOOTH);
|
|
||||||
::glDisable(GL_POLYGON_SMOOTH_HINT);
|
|
||||||
::glBlendFunc(GL_ONE, GL_ZERO);
|
|
||||||
::glHint(GL_LINE_SMOOTH_HINT, GL_FASTEST);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
::glShadeModel(GL_SMOOTH);
|
|
||||||
::glEnable(GL_BLEND);
|
|
||||||
::glEnable(GL_LINE_SMOOTH);
|
|
||||||
::glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
|
||||||
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
}
|
|
||||||
handled = true;
|
|
||||||
updateGL();
|
updateGL();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_E) && (modifiers==Qt::NoButton))
|
else if ((e->key()==Qt::Key_E) && (modifiers==Qt::NoButton))
|
||||||
{
|
{
|
||||||
edges = !edges;
|
edges = !edges;
|
||||||
handled = true;
|
|
||||||
updateGL();
|
updateGL();
|
||||||
}
|
}
|
||||||
else if ((e->key()==Qt::Key_V) && (modifiers==Qt::NoButton))
|
else if ((e->key()==Qt::Key_V) && (modifiers==Qt::NoButton))
|
||||||
{
|
{
|
||||||
vertices = !vertices;
|
vertices = !vertices;
|
||||||
handled = true;
|
|
||||||
updateGL();
|
updateGL();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!handled)
|
|
||||||
QGLViewer::keyPressEvent(e);
|
QGLViewer::keyPressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue