mirror of https://github.com/CGAL/cgal
Rename isRecent into isOpenGL_4_3
This commit is contained in:
parent
71a8c1c178
commit
bca74e4a8e
|
|
@ -214,7 +214,7 @@ add_to_normal(unsigned char v,
|
||||||
class Vertex_buffer_helper
|
class Vertex_buffer_helper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Vertex_buffer_helper(const Image_accessor& data, bool is_recent);
|
Vertex_buffer_helper(const Image_accessor& data, bool is_ogl_4_3);
|
||||||
|
|
||||||
void fill_buffer_data();
|
void fill_buffer_data();
|
||||||
|
|
||||||
|
|
@ -252,14 +252,14 @@ private:
|
||||||
Indices indices_;
|
Indices indices_;
|
||||||
std::vector<GLfloat> colors_, normals_, vertices_;
|
std::vector<GLfloat> colors_, normals_, vertices_;
|
||||||
std::vector<GLuint> quads_;
|
std::vector<GLuint> quads_;
|
||||||
bool is_recent;
|
bool is_ogl_4_3;
|
||||||
};
|
};
|
||||||
|
|
||||||
int Vertex_buffer_helper::vertex_not_found_ = -1;
|
int Vertex_buffer_helper::vertex_not_found_ = -1;
|
||||||
|
|
||||||
Vertex_buffer_helper::
|
Vertex_buffer_helper::
|
||||||
Vertex_buffer_helper(const Image_accessor& data, bool b)
|
Vertex_buffer_helper(const Image_accessor& data, bool b)
|
||||||
: data_(data), is_recent(b)
|
: data_(data), is_ogl_4_3(b)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -374,7 +374,7 @@ Vertex_buffer_helper::push_quad(int pos1, int pos2, int pos3, int pos4)
|
||||||
quads_.push_back(pos1);
|
quads_.push_back(pos1);
|
||||||
quads_.push_back(pos2);
|
quads_.push_back(pos2);
|
||||||
quads_.push_back(pos3);
|
quads_.push_back(pos3);
|
||||||
if(!is_recent)
|
if(!is_ogl_4_3)
|
||||||
{
|
{
|
||||||
quads_.push_back(pos1);
|
quads_.push_back(pos1);
|
||||||
quads_.push_back(pos3);
|
quads_.push_back(pos3);
|
||||||
|
|
@ -424,7 +424,7 @@ struct Scene_image_item_priv
|
||||||
{
|
{
|
||||||
item = parent;
|
item = parent;
|
||||||
v_box = new std::vector<float>();
|
v_box = new std::vector<float>();
|
||||||
is_recent = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->isRecent();
|
is_ogl_4_3 = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->isOpenGL_4_3();
|
||||||
is_hidden = hidden;
|
is_hidden = hidden;
|
||||||
compile_shaders();
|
compile_shaders();
|
||||||
initializeBuffers();
|
initializeBuffers();
|
||||||
|
|
@ -465,7 +465,7 @@ struct Scene_image_item_priv
|
||||||
mutable QOpenGLVertexArrayObject vao[vaoSize];
|
mutable QOpenGLVertexArrayObject vao[vaoSize];
|
||||||
mutable QOpenGLShaderProgram rendering_program;
|
mutable QOpenGLShaderProgram rendering_program;
|
||||||
bool is_hidden;
|
bool is_hidden;
|
||||||
bool is_recent;
|
bool is_ogl_4_3;
|
||||||
Scene_image_item* item;
|
Scene_image_item* item;
|
||||||
|
|
||||||
//#endif // SCENE_SEGMENTED_IMAGE_GL_BUFFERS_AVAILABLE
|
//#endif // SCENE_SEGMENTED_IMAGE_GL_BUFFERS_AVAILABLE
|
||||||
|
|
@ -498,7 +498,7 @@ void Scene_image_item_priv::compile_shaders()
|
||||||
vao[i].create();
|
vao[i].create();
|
||||||
m_ibo = new QOpenGLBuffer(QOpenGLBuffer::IndexBuffer);
|
m_ibo = new QOpenGLBuffer(QOpenGLBuffer::IndexBuffer);
|
||||||
m_ibo->create();
|
m_ibo->create();
|
||||||
if(!is_recent)
|
if(!is_ogl_4_3)
|
||||||
{
|
{
|
||||||
//Vertex source code
|
//Vertex source code
|
||||||
const char vertex_source[] =
|
const char vertex_source[] =
|
||||||
|
|
@ -755,7 +755,7 @@ Scene_image_item_priv::initializeBuffers()
|
||||||
m_voxel_scale,
|
m_voxel_scale,
|
||||||
m_voxel_scale,
|
m_voxel_scale,
|
||||||
m_voxel_scale);
|
m_voxel_scale);
|
||||||
internal::Vertex_buffer_helper helper (image_data_accessor, is_recent);
|
internal::Vertex_buffer_helper helper (image_data_accessor, is_ogl_4_3);
|
||||||
helper.fill_buffer_data();
|
helper.fill_buffer_data();
|
||||||
rendering_program.bind();
|
rendering_program.bind();
|
||||||
vao[0].bind();
|
vao[0].bind();
|
||||||
|
|
@ -809,7 +809,7 @@ Scene_image_item_priv::draw_gl(Viewer_interface* viewer) const
|
||||||
if(!is_hidden)
|
if(!is_hidden)
|
||||||
{
|
{
|
||||||
vao[0].bind();
|
vao[0].bind();
|
||||||
if(!is_recent)
|
if(!is_ogl_4_3)
|
||||||
viewer->glDrawElements(GL_TRIANGLES, m_ibo->size()/sizeof(GLuint), GL_UNSIGNED_INT, 0);
|
viewer->glDrawElements(GL_TRIANGLES, m_ibo->size()/sizeof(GLuint), GL_UNSIGNED_INT, 0);
|
||||||
else
|
else
|
||||||
viewer->glDrawElements(GL_LINES_ADJACENCY, m_ibo->size()/sizeof(GLuint), GL_UNSIGNED_INT, 0);
|
viewer->glDrawElements(GL_LINES_ADJACENCY, m_ibo->size()/sizeof(GLuint), GL_UNSIGNED_INT, 0);
|
||||||
|
|
|
||||||
|
|
@ -535,7 +535,7 @@ void
|
||||||
Scene_polyhedron_item_priv::initialize_buffers(CGAL::Three::Viewer_interface* viewer) const
|
Scene_polyhedron_item_priv::initialize_buffers(CGAL::Three::Viewer_interface* viewer) const
|
||||||
{
|
{
|
||||||
//vao containing the data for the facets
|
//vao containing the data for the facets
|
||||||
if(!viewer->isRecent() && !no_flat)
|
if(!viewer->isOpenGL_4_3() && !no_flat)
|
||||||
{
|
{
|
||||||
//flat
|
//flat
|
||||||
if(viewer->property("draw_two_sides").toBool())
|
if(viewer->property("draw_two_sides").toBool())
|
||||||
|
|
@ -611,7 +611,7 @@ Scene_polyhedron_item_priv::initialize_buffers(CGAL::Three::Viewer_interface* vi
|
||||||
}
|
}
|
||||||
item->vaos[Gouraud_Facets]->release();
|
item->vaos[Gouraud_Facets]->release();
|
||||||
program->release();
|
program->release();
|
||||||
if(viewer->isRecent())
|
if(viewer->isOpenGL_4_3())
|
||||||
{
|
{
|
||||||
//modern flat
|
//modern flat
|
||||||
program = item->getShaderProgram(Scene_polyhedron_item::PROGRAM_FLAT, viewer);
|
program = item->getShaderProgram(Scene_polyhedron_item::PROGRAM_FLAT, viewer);
|
||||||
|
|
@ -1188,13 +1188,15 @@ QMenu* Scene_polyhedron_item::contextMenu()
|
||||||
actionEraseNextFacet->setObjectName("actionEraseNextFacet");
|
actionEraseNextFacet->setObjectName("actionEraseNextFacet");
|
||||||
connect(actionEraseNextFacet, SIGNAL(toggled(bool)),
|
connect(actionEraseNextFacet, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(set_erase_next_picked_facet(bool)));
|
this, SLOT(set_erase_next_picked_facet(bool)));
|
||||||
|
if(! static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->isOpenGL_4_3())
|
||||||
|
{
|
||||||
QAction* actionDisableFlatShading=
|
QAction* actionDisableFlatShading=
|
||||||
menu->addAction(tr("Disable Flat Shading"));
|
menu->addAction(tr("Disable Flat Shading"));
|
||||||
actionDisableFlatShading->setCheckable(true);
|
actionDisableFlatShading->setCheckable(true);
|
||||||
actionDisableFlatShading->setObjectName("actionDisableFlatShading");
|
actionDisableFlatShading->setObjectName("actionDisableFlatShading");
|
||||||
connect(actionDisableFlatShading, SIGNAL(toggled(bool)),
|
connect(actionDisableFlatShading, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(set_flat_disabled(bool)));
|
this, SLOT(set_flat_disabled(bool)));
|
||||||
|
}
|
||||||
menu->setProperty(prop_name, true);
|
menu->setProperty(prop_name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1245,14 +1247,14 @@ void Scene_polyhedron_item::set_erase_next_picked_facet(bool b)
|
||||||
void Scene_polyhedron_item::draw(CGAL::Three::Viewer_interface* viewer) const {
|
void Scene_polyhedron_item::draw(CGAL::Three::Viewer_interface* viewer) const {
|
||||||
if(!are_buffers_filled)
|
if(!are_buffers_filled)
|
||||||
{
|
{
|
||||||
d->compute_normals_and_vertices(viewer->isRecent(),
|
d->compute_normals_and_vertices(viewer->isOpenGL_4_3(),
|
||||||
false,
|
false,
|
||||||
viewer->property("draw_two_sides").toBool());
|
viewer->property("draw_two_sides").toBool());
|
||||||
d->initialize_buffers(viewer);
|
d->initialize_buffers(viewer);
|
||||||
compute_bbox();
|
compute_bbox();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(viewer->isRecent() &&
|
if(viewer->isOpenGL_4_3() &&
|
||||||
(renderingMode() == Flat || renderingMode() == FlatPlusEdges))
|
(renderingMode() == Flat || renderingMode() == FlatPlusEdges))
|
||||||
{
|
{
|
||||||
vaos[Scene_polyhedron_item_priv::Gouraud_Facets]->bind();
|
vaos[Scene_polyhedron_item_priv::Gouraud_Facets]->bind();
|
||||||
|
|
@ -1272,7 +1274,7 @@ void Scene_polyhedron_item::draw(CGAL::Three::Viewer_interface* viewer) const {
|
||||||
d->program->release();
|
d->program->release();
|
||||||
vaos[Scene_polyhedron_item_priv::Gouraud_Facets]->release();
|
vaos[Scene_polyhedron_item_priv::Gouraud_Facets]->release();
|
||||||
}
|
}
|
||||||
else if(!viewer->isRecent()&&
|
else if(!viewer->isOpenGL_4_3()&&
|
||||||
(renderingMode() == Flat || renderingMode() == FlatPlusEdges))
|
(renderingMode() == Flat || renderingMode() == FlatPlusEdges))
|
||||||
{
|
{
|
||||||
vaos[Scene_polyhedron_item_priv::Facets]->bind();
|
vaos[Scene_polyhedron_item_priv::Facets]->bind();
|
||||||
|
|
@ -1326,7 +1328,7 @@ void Scene_polyhedron_item::drawEdges(CGAL::Three::Viewer_interface* viewer) con
|
||||||
{
|
{
|
||||||
if (!are_buffers_filled)
|
if (!are_buffers_filled)
|
||||||
{
|
{
|
||||||
d->compute_normals_and_vertices(viewer->isRecent(), false,
|
d->compute_normals_and_vertices(viewer->isOpenGL_4_3(), false,
|
||||||
viewer->property("draw_two_sides").toBool());
|
viewer->property("draw_two_sides").toBool());
|
||||||
d->initialize_buffers(viewer);
|
d->initialize_buffers(viewer);
|
||||||
compute_bbox();
|
compute_bbox();
|
||||||
|
|
@ -1375,7 +1377,7 @@ void
|
||||||
Scene_polyhedron_item::drawPoints(CGAL::Three::Viewer_interface* viewer) const {
|
Scene_polyhedron_item::drawPoints(CGAL::Three::Viewer_interface* viewer) const {
|
||||||
if(!are_buffers_filled)
|
if(!are_buffers_filled)
|
||||||
{
|
{
|
||||||
d->compute_normals_and_vertices(viewer->isRecent(), false, viewer->property("draw_two_sides").toBool());
|
d->compute_normals_and_vertices(viewer->isOpenGL_4_3(), false, viewer->property("draw_two_sides").toBool());
|
||||||
d->initialize_buffers(viewer);
|
d->initialize_buffers(viewer);
|
||||||
compute_bbox();
|
compute_bbox();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public:
|
||||||
bool _displayMessage;
|
bool _displayMessage;
|
||||||
QTimer messageTimer;
|
QTimer messageTimer;
|
||||||
QOpenGLFunctions_4_3_Compatibility* _recentFunctions;
|
QOpenGLFunctions_4_3_Compatibility* _recentFunctions;
|
||||||
bool is_recent;
|
bool is_ogl_4_3;
|
||||||
|
|
||||||
//! Holds useful data to draw the axis system
|
//! Holds useful data to draw the axis system
|
||||||
struct AxisData
|
struct AxisData
|
||||||
|
|
@ -246,11 +246,11 @@ void Viewer::initializeGL()
|
||||||
format.setVersion(2,1);
|
format.setVersion(2,1);
|
||||||
new_context->setFormat(format);
|
new_context->setFormat(format);
|
||||||
created = new_context->create();
|
created = new_context->create();
|
||||||
d->is_recent = false;
|
d->is_ogl_4_3 = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
d->is_recent = true;
|
d->is_ogl_4_3 = true;
|
||||||
d->_recentFunctions = new QOpenGLFunctions_4_3_Compatibility();
|
d->_recentFunctions = new QOpenGLFunctions_4_3_Compatibility();
|
||||||
}
|
}
|
||||||
CGAL_warning_msg(created && new_context->isValid(), "The openGL context initialization failed "
|
CGAL_warning_msg(created && new_context->isValid(), "The openGL context initialization failed "
|
||||||
|
|
@ -259,7 +259,7 @@ void Viewer::initializeGL()
|
||||||
context()->makeCurrent();
|
context()->makeCurrent();
|
||||||
QGLViewer::initializeGL();
|
QGLViewer::initializeGL();
|
||||||
initializeOpenGLFunctions();
|
initializeOpenGLFunctions();
|
||||||
if(isRecent())
|
if(isOpenGL_4_3())
|
||||||
{
|
{
|
||||||
d->_recentFunctions->initializeOpenGLFunctions();
|
d->_recentFunctions->initializeOpenGLFunctions();
|
||||||
}
|
}
|
||||||
|
|
@ -1675,6 +1675,9 @@ void Viewer::enableClippingBox(QVector4D box[6])
|
||||||
|
|
||||||
bool Viewer::isRecent() const { return d->is_recent; }
|
bool Viewer::isRecent() const { return d->is_recent; }
|
||||||
|
|
||||||
|
|
||||||
|
bool Viewer::isOpenGL_4_3() const { return d->is_ogl_4_3; }
|
||||||
|
|
||||||
QOpenGLFunctions_4_3_Compatibility* Viewer::recentFunctions() { return d->_recentFunctions; }
|
QOpenGLFunctions_4_3_Compatibility* Viewer::recentFunctions() { return d->_recentFunctions; }
|
||||||
|
|
||||||
#include "Viewer.moc"
|
#include "Viewer.moc"
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ protected:
|
||||||
double prev_radius;
|
double prev_radius;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool isRecent() const;
|
bool isOpenGL_4_3() const;
|
||||||
QOpenGLFunctions_4_3_Compatibility* recentFunctions();
|
QOpenGLFunctions_4_3_Compatibility* recentFunctions();
|
||||||
|
|
||||||
}; // end class Viewer
|
}; // end class Viewer
|
||||||
|
|
|
||||||
|
|
@ -238,11 +238,11 @@ public:
|
||||||
//! Is used to know if the openGL context is 4.3 or 2.1.
|
//! Is used to know if the openGL context is 4.3 or 2.1.
|
||||||
//! @returns `true` if the context is 4.3.
|
//! @returns `true` if the context is 4.3.
|
||||||
//! @returns `false` if the context is 2.1.
|
//! @returns `false` if the context is 2.1.
|
||||||
virtual bool isRecent() const = 0;
|
virtual bool isOpenGL_4_3() const = 0;
|
||||||
//! Gives acces to recent openGL(4.3) features, allowing use of things like
|
//! Gives acces to recent openGL(4.3) features, allowing use of things like
|
||||||
//! Geometry Shaders or Depth Textures.
|
//! Geometry Shaders or Depth Textures.
|
||||||
//! @returns a pointer to an initialized QOpenGLFunctions_4_3_Compatibility if `isRecent()` is `true`
|
//! @returns a pointer to an initialized QOpenGLFunctions_4_3_Compatibility if `isOpenGL_4_3()` is `true`
|
||||||
//! @returns NULL if `isRecent()` is `false`
|
//! @returns NULL if `isOpenGL_4_3()` is `false`
|
||||||
virtual QOpenGLFunctions_4_3_Compatibility* recentFunctions() = 0;
|
virtual QOpenGLFunctions_4_3_Compatibility* recentFunctions() = 0;
|
||||||
}; // end class Viewer_interface
|
}; // end class Viewer_interface
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue