mirror of https://github.com/CGAL/cgal
Clean-up
- removed the unused functions and dependencies - Replaced QGLBuffer by QOpenGLBuffer
This commit is contained in:
parent
551ad0a36b
commit
ba4ede5f50
|
|
@ -10,16 +10,13 @@
|
|||
#include <QInputDialog>
|
||||
|
||||
#include "Refiner.h"
|
||||
#include "render_edges.h"
|
||||
//#include "render_edges.h"
|
||||
|
||||
#include <CGAL/Timer.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/Subdivision_method_3.h>
|
||||
|
||||
#include <QOpenGLFunctions_3_3_Core>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLShader>
|
||||
|
||||
|
||||
|
|
@ -76,7 +73,7 @@ Scene::~Scene()
|
|||
|
||||
void Scene::compile_shaders()
|
||||
{
|
||||
initializeGLFunctions();
|
||||
initializeOpenGLFunctions();
|
||||
if(! buffers[0].create() || !buffers[1].create() || !buffers[2].create() || !buffers[3].create() || !buffers[4].create() || !buffers[5].create() || !buffers[6].create() || !buffers[7].create())
|
||||
{
|
||||
std::cerr<<"VBO Creation FAILED"<<std::endl;
|
||||
|
|
@ -582,42 +579,6 @@ void Scene::update_bbox()
|
|||
<< " facets)" << std::endl;
|
||||
}
|
||||
|
||||
void Scene::draw()
|
||||
{
|
||||
if(m_view_plane)
|
||||
::glEnable(GL_DEPTH_TEST);
|
||||
else
|
||||
::glDisable(GL_DEPTH_TEST);
|
||||
|
||||
if(m_view_polyhedron)
|
||||
draw_polyhedron();
|
||||
|
||||
if(m_view_points)
|
||||
draw_points();
|
||||
|
||||
if(m_view_segments)
|
||||
draw_segments();
|
||||
|
||||
if (m_view_plane)
|
||||
{
|
||||
switch( m_cut_plane )
|
||||
{
|
||||
case UNSIGNED_EDGES:
|
||||
case UNSIGNED_FACETS:
|
||||
draw_distance_function(m_thermal_ramp, m_thermal_ramp);
|
||||
break;
|
||||
case SIGNED_FACETS:
|
||||
draw_distance_function(m_red_ramp, m_blue_ramp);
|
||||
break;
|
||||
case CUT_SEGMENTS:
|
||||
draw_cut_segment_plane();
|
||||
break;
|
||||
case NONE: // do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::draw(QGLViewer* viewer)
|
||||
{
|
||||
QColor color;
|
||||
|
|
@ -737,167 +698,6 @@ void Scene::draw(QGLViewer* viewer)
|
|||
|
||||
}
|
||||
|
||||
void Scene::draw_polyhedron()
|
||||
{
|
||||
// draw black edges
|
||||
if(m_pPolyhedron != NULL)
|
||||
{
|
||||
::glDisable(GL_LIGHTING);
|
||||
::glColor3ub(0,0,0);
|
||||
::glLineWidth(1.0f);
|
||||
gl_render_edges(*m_pPolyhedron);
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::draw_segments()
|
||||
{
|
||||
if(m_segments.size() != 0)
|
||||
{
|
||||
::glDisable(GL_LIGHTING);
|
||||
::glColor3ub(0,100,0);
|
||||
::glLineWidth(2.0f);
|
||||
::glBegin(GL_LINES);
|
||||
std::list<Segment>::iterator it;
|
||||
for(it = m_segments.begin(); it != m_segments.end(); it++)
|
||||
{
|
||||
const Segment& s = *it;
|
||||
const Point& p = s.source();
|
||||
const Point& q = s.target();
|
||||
::glVertex3d(p.x(),p.y(),p.z());
|
||||
::glVertex3d(q.x(),q.y(),q.z());
|
||||
}
|
||||
::glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::draw_points()
|
||||
{
|
||||
// draw red points
|
||||
if(m_points.size() != 0)
|
||||
{
|
||||
::glDisable(GL_LIGHTING);
|
||||
::glColor3ub(180,0,0);
|
||||
::glPointSize(2.0f);
|
||||
::glBegin(GL_POINTS);
|
||||
std::list<Point>::iterator it;
|
||||
for(it = m_points.begin(); it != m_points.end(); it++)
|
||||
{
|
||||
const Point& p = *it;
|
||||
::glVertex3d(p.x(),p.y(),p.z());
|
||||
}
|
||||
::glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::draw_distance_function(const Color_ramp& ramp_pos,
|
||||
const Color_ramp& ramp_neg) const
|
||||
{
|
||||
::glDisable(GL_LIGHTING);
|
||||
if ( m_fast_distance ) { ::glShadeModel(GL_FLAT); }
|
||||
else { ::glShadeModel(GL_SMOOTH); }
|
||||
|
||||
::glBegin(GL_QUADS);
|
||||
int i,j;
|
||||
const int nb_quads = m_grid_size-1;
|
||||
for(i=0;i<nb_quads;i++)
|
||||
{
|
||||
for(j=0;j<nb_quads;j++)
|
||||
{
|
||||
const Point_distance& pd00 = m_distance_function[i][j];
|
||||
const Point_distance& pd01 = m_distance_function[i][j+1];
|
||||
const Point_distance& pd11 = m_distance_function[i+1][j+1];
|
||||
const Point_distance& pd10 = m_distance_function[i+1][j];
|
||||
const Point& p00 = pd00.first;
|
||||
const Point& p01 = pd01.first;
|
||||
const Point& p11 = pd11.first;
|
||||
const Point& p10 = pd10.first;
|
||||
const FT& d00 = pd00.second;
|
||||
const FT& d01 = pd01.second;
|
||||
const FT& d11 = pd11.second;
|
||||
const FT& d10 = pd10.second;
|
||||
|
||||
// determines grey level
|
||||
unsigned int i00 = 255-(unsigned)(255.0 * (double)std::fabs(d00) / m_max_distance_function);
|
||||
unsigned int i01 = 255-(unsigned)(255.0 * (double)std::fabs(d01) / m_max_distance_function);
|
||||
unsigned int i11 = 255-(unsigned)(255.0 * (double)std::fabs(d11) / m_max_distance_function);
|
||||
unsigned int i10 = 255-(unsigned)(255.0 * (double)std::fabs(d10) / m_max_distance_function);
|
||||
|
||||
// assembles one quad
|
||||
if(d00 > 0.0)
|
||||
::glColor3ub(ramp_pos.r(i00),ramp_pos.g(i00),ramp_pos.b(i00));
|
||||
else
|
||||
::glColor3ub(ramp_neg.r(i00),ramp_neg.g(i00),ramp_neg.b(i00));
|
||||
::glVertex3d(p00.x(),p00.y(),p00.z());
|
||||
|
||||
if(d01 > 0.0)
|
||||
::glColor3ub(ramp_pos.r(i01),ramp_pos.g(i01),ramp_pos.b(i01));
|
||||
else
|
||||
::glColor3ub(ramp_neg.r(i01),ramp_neg.g(i01),ramp_neg.b(i01));
|
||||
::glVertex3d(p01.x(),p01.y(),p01.z());
|
||||
|
||||
if(d11 > 0)
|
||||
::glColor3ub(ramp_pos.r(i11),ramp_pos.g(i11),ramp_pos.b(i11));
|
||||
else
|
||||
::glColor3ub(ramp_neg.r(i11),ramp_neg.g(i11),ramp_neg.b(i11));
|
||||
::glVertex3d(p11.x(),p11.y(),p11.z());
|
||||
|
||||
if(d10 > 0)
|
||||
::glColor3ub(ramp_pos.r(i10),ramp_pos.g(i10),ramp_pos.b(i10));
|
||||
else
|
||||
::glColor3ub(ramp_neg.r(i10),ramp_neg.g(i10),ramp_neg.b(i10));
|
||||
::glVertex3d(p10.x(),p10.y(),p10.z());
|
||||
}
|
||||
}
|
||||
::glEnd();
|
||||
}
|
||||
|
||||
void Scene::draw_cut_segment_plane() const
|
||||
{
|
||||
float diag = .6f * float(bbox_diag());
|
||||
|
||||
::glDisable(GL_LIGHTING);
|
||||
::glLineWidth(1.0f);
|
||||
::glColor3f(.6f, .6f, .6f);
|
||||
|
||||
// draw grid
|
||||
::glPushMatrix();
|
||||
::glMultMatrixd(m_frame->matrix());
|
||||
QGLViewer::drawGrid(diag);
|
||||
::glPopMatrix();
|
||||
|
||||
// draw cut segments
|
||||
::glLineWidth(2.0f);
|
||||
::glColor3f(1.f, 0.f, 0.f);
|
||||
::glBegin(GL_LINES);
|
||||
for ( std::vector<Segment>::const_iterator it = m_cut_segments.begin(),
|
||||
end = m_cut_segments.end() ; it != end ; ++it )
|
||||
{
|
||||
const Point& a = it->source();
|
||||
const Point& b = it->target();
|
||||
|
||||
::glVertex3d(a.x(), a.y(), a.z());
|
||||
::glVertex3d(b.x(), b.y(), b.z());
|
||||
}
|
||||
::glEnd();
|
||||
|
||||
// fill grid with transparent blue
|
||||
::glPushMatrix();
|
||||
::glMultMatrixd(m_frame->matrix());
|
||||
::glColor4f(.6f, .85f, 1.f, .65f);
|
||||
|
||||
::glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||
::glEnable(GL_BLEND);
|
||||
::glBegin(GL_QUADS);
|
||||
::glVertex3d(-diag, -diag, 0.);
|
||||
::glVertex3d(-diag, diag, 0.);
|
||||
::glVertex3d( diag, diag, 0.);
|
||||
::glVertex3d( diag, -diag, 0.);
|
||||
::glEnd();
|
||||
::glDisable(GL_BLEND);
|
||||
|
||||
::glPopMatrix();
|
||||
}
|
||||
|
||||
FT Scene::random_in(const double a,
|
||||
const double b)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,9 +19,8 @@
|
|||
#include <QGLViewer/manipulatedFrame.h>
|
||||
#include <QGLViewer/qglviewer.h>
|
||||
#include <QOpenGLFunctions_3_3_Core>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QGLShaderProgram>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLTexture>
|
||||
|
|
@ -52,7 +51,7 @@ public:
|
|||
GLubyte* getData(){return data; }
|
||||
|
||||
};
|
||||
class Scene : public QObject, protected QGLFunctions
|
||||
class Scene : public QObject, protected QOpenGLFunctions_3_3_Core
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
|
@ -79,7 +78,6 @@ private:
|
|||
|
||||
public:
|
||||
QGLContext* context;
|
||||
void draw();
|
||||
void draw(QGLViewer*);
|
||||
void update_bbox();
|
||||
Bbox bbox() { return m_bbox; }
|
||||
|
|
@ -161,7 +159,7 @@ private:
|
|||
|
||||
Texture *texture;
|
||||
GLint sampler_location;
|
||||
QGLBuffer buffers[10];
|
||||
QOpenGLBuffer buffers[10];
|
||||
QOpenGLVertexArrayObject vao[10];
|
||||
QOpenGLShaderProgram tex_rendering_program;
|
||||
QOpenGLShaderProgram rendering_program;
|
||||
|
|
@ -243,14 +241,6 @@ public:
|
|||
void bench_closest_point_and_primitive(Facet_tree& tree,const double duration);
|
||||
void bench_distance(Facet_tree& tree,const int function,const double duration);
|
||||
|
||||
// drawing
|
||||
void draw_points();
|
||||
void draw_segments();
|
||||
void draw_polyhedron();
|
||||
void draw_distance_function(const Color_ramp& ramp_pos,
|
||||
const Color_ramp& ramp_neg) const;
|
||||
void draw_cut_segment_plane() const;
|
||||
|
||||
// cutting plane activation/deactivation
|
||||
void activate_cutting_plane();
|
||||
void deactivate_cutting_plane();
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
#ifndef _GL_RENDER_EDGES_
|
||||
#define _GL_RENDER_EDGES_
|
||||
|
||||
#include <CGAL/gl.h>
|
||||
|
||||
template <class Polyhedron>
|
||||
void gl_render_edges(Polyhedron& polyhedron)
|
||||
{
|
||||
typedef typename Polyhedron::Traits Kernel;
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
|
||||
::glBegin(GL_LINES);
|
||||
typename Polyhedron::Edge_iterator he;
|
||||
for(he = polyhedron.edges_begin();
|
||||
he != polyhedron.edges_end();
|
||||
he++)
|
||||
{
|
||||
const Point& a = he->vertex()->point();
|
||||
const Point& b = he->opposite()->vertex()->point();
|
||||
::glVertex3d(a.x(),a.y(),a.z());
|
||||
::glVertex3d(b.x(),b.y(),b.z());
|
||||
}
|
||||
::glEnd();
|
||||
}
|
||||
|
||||
#endif // _GL_RENDER_EDGES_
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
void Viewer::compile_shaders()
|
||||
{
|
||||
initializeGLFunctions();
|
||||
initializeOpenGLFunctions();
|
||||
if(! buffers[0].create() || !buffers[1].create() || !buffers[2].create() )
|
||||
{
|
||||
std::cerr<<"VBO Creation FAILED"<<std::endl;
|
||||
|
|
@ -374,55 +374,4 @@ void Viewer::alphaChanged()
|
|||
initialize_buffers();
|
||||
|
||||
}
|
||||
|
||||
void //not used anymore
|
||||
Viewer::gl_draw_surface()
|
||||
{
|
||||
::glColor3f(1.0f, 0.0f, 0.0f);
|
||||
::glDisable(GL_LIGHTING);
|
||||
::glEnable(GL_POINT_SMOOTH);
|
||||
::glPointSize(5);
|
||||
::glBegin(GL_POINTS);
|
||||
for(std::list<Point_3>::iterator it = scene->points.begin();
|
||||
it != scene->points.end();
|
||||
++it){
|
||||
::glVertex3d(it->x(), it->y(), it->z());
|
||||
}
|
||||
::glEnd();
|
||||
::glDisable(GL_POINT_SMOOTH);
|
||||
|
||||
::glEnable(GL_LIGHTING);
|
||||
::glBegin(GL_TRIANGLES);
|
||||
|
||||
::glColor3f(0.2f, 1.0f, 0.2f);
|
||||
|
||||
std::list<Facet> facets;
|
||||
scene->alpha_shape.get_alpha_shape_facets(std::back_inserter(facets), Alpha_shape_3::REGULAR);
|
||||
|
||||
for(std::list<Facet>::iterator fit = facets.begin();
|
||||
fit != facets.end();
|
||||
++fit) {
|
||||
const Cell_handle& ch = fit->first;
|
||||
const int index = fit->second;
|
||||
|
||||
//const Vector_3& n = ch->normal(index); // must be unit vector
|
||||
|
||||
const Point_3& a = ch->vertex((index+1)&3)->point();
|
||||
const Point_3& b = ch->vertex((index+2)&3)->point();
|
||||
const Point_3& c = ch->vertex((index+3)&3)->point();
|
||||
|
||||
Vector_3 v = CGAL::unit_normal(a,b,c);
|
||||
|
||||
|
||||
::glNormal3d(v.x(),v.y(),v.z());
|
||||
::glVertex3d(a.x(),a.y(),a.z());
|
||||
::glVertex3d(b.x(),b.y(),b.z());
|
||||
::glVertex3d(c.x(),c.y(),c.z());
|
||||
}
|
||||
|
||||
|
||||
::glEnd();
|
||||
|
||||
}
|
||||
|
||||
#include "Viewer.moc"
|
||||
|
|
|
|||
|
|
@ -4,14 +4,13 @@
|
|||
#include "typedefs.h"
|
||||
#include <QGLViewer/qglviewer.h>
|
||||
#include <QOpenGLFunctions_3_3_Core>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
|
||||
|
||||
class Viewer : public QGLViewer, protected QGLFunctions {
|
||||
class Viewer : public QGLViewer, protected QOpenGLFunctions_3_3_Core{
|
||||
Q_OBJECT
|
||||
|
||||
CGAL::Timer timer;
|
||||
|
|
@ -27,6 +26,7 @@ public:
|
|||
{
|
||||
buffers[0].destroy();
|
||||
buffers[1].destroy();
|
||||
buffers[2].destroy();
|
||||
vao[0].destroy();
|
||||
vao[1].destroy();
|
||||
}
|
||||
|
|
@ -40,9 +40,6 @@ public:
|
|||
public:
|
||||
void draw();
|
||||
|
||||
void
|
||||
gl_draw_surface();
|
||||
|
||||
private:
|
||||
//Shaders elements
|
||||
|
||||
|
|
@ -61,7 +58,7 @@ private:
|
|||
std::vector<float> pos_poly;
|
||||
std::vector<float> normals;
|
||||
|
||||
QGLBuffer buffers[3];
|
||||
QOpenGLBuffer buffers[3];
|
||||
QOpenGLVertexArrayObject vao[2];
|
||||
QOpenGLShaderProgram rendering_program;
|
||||
QOpenGLShaderProgram rendering_program_points;
|
||||
|
|
|
|||
|
|
@ -626,10 +626,6 @@ void Viewer::compute_elements()
|
|||
//draw points as small spheres
|
||||
for (std::vector<EPIC::Point_3>::const_iterator it=intersections.begin();it!=intersections.end();++it){
|
||||
pos_points.push_back(it->x()); pos_points.push_back(it->y()); pos_points.push_back(it->z());
|
||||
// glPushMatrix();
|
||||
// glTranslatef(it->x(),it->y(),it->z());
|
||||
// gluSphere(qsphere,0.005,10,10);
|
||||
// glPopMatrix();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,13 @@
|
|||
|
||||
#include <QOpenGLFunctions_3_3_Core>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel EPIC;
|
||||
|
||||
class Viewer : public QGLViewer, QOpenGLFunctions_3_3_Core
|
||||
{
|
||||
GLUquadricObj *qsphere;
|
||||
GLuint dl_nb;
|
||||
protected :
|
||||
virtual void draw();
|
||||
|
|
@ -39,7 +38,7 @@ private:
|
|||
std::vector<float> trivial_center;
|
||||
std::vector<float> normals_lines;
|
||||
|
||||
QGLBuffer buffers[9];
|
||||
QOpenGLBuffer buffers[9];
|
||||
QOpenGLVertexArrayObject vao[3];
|
||||
QOpenGLShaderProgram rendering_program;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@
|
|||
#include <CGAL/gl.h>
|
||||
#include <QGLViewer/manipulatedFrame.h>
|
||||
#include <QGLViewer/qglviewer.h>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLFunctions_3_2_Core>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
struct Scene_c3t3_item_priv;
|
||||
|
|
@ -125,7 +125,7 @@ private:
|
|||
|
||||
|
||||
|
||||
mutable QGLBuffer buffers[vboSize];
|
||||
mutable QOpenGLBuffer buffers[vboSize];
|
||||
mutable QOpenGLVertexArrayObject vao[vaoSize];
|
||||
mutable QOpenGLShaderProgram rendering_program;
|
||||
mutable QOpenGLShaderProgram rendering_program_grid;
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@
|
|||
|
||||
#include <QGLViewer/manipulatedFrame.h>
|
||||
#include <QGLViewer/qglviewer.h>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
#define SCENE_IMPLICIT_GRID_SIZE 120
|
||||
|
|
@ -108,7 +107,7 @@ private:
|
|||
GLuint textureId;
|
||||
GLint sampler_location;
|
||||
|
||||
mutable QGLBuffer buffers[vboSize];
|
||||
mutable QOpenGLBuffer buffers[vboSize];
|
||||
mutable QOpenGLVertexArrayObject vao[vaoSize];
|
||||
mutable QOpenGLShaderProgram rendering_program;
|
||||
mutable QOpenGLShaderProgram tex_rendering_program;
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@
|
|||
#include <CGAL_demo/Scene_item.h>
|
||||
#include <iostream>
|
||||
#include <QGLViewer/qglviewer.h>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
struct Polygon_soup;
|
||||
|
|
@ -66,7 +65,7 @@ private:
|
|||
std::vector<float> vertex_nm;
|
||||
|
||||
|
||||
mutable QGLBuffer buffers[vboSize];
|
||||
mutable QOpenGLBuffer buffers[vboSize];
|
||||
mutable QOpenGLVertexArrayObject vao[vaoSize];
|
||||
mutable QOpenGLShaderProgram rendering_program;
|
||||
void initialize_buffers();
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@
|
|||
#include "Polyhedron_type_fwd.h"
|
||||
#include <iostream>
|
||||
#include <QGLViewer/qglviewer.h>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
// This class represents a polyhedron in the OpenGL scene
|
||||
|
|
@ -68,7 +67,7 @@ private:
|
|||
std::vector<float> vertex_nm;
|
||||
|
||||
|
||||
mutable QGLBuffer buffers[vboSize];
|
||||
mutable QOpenGLBuffer buffers[vboSize];
|
||||
mutable QOpenGLVertexArrayObject vao[vaoSize];
|
||||
mutable QOpenGLShaderProgram rendering_program;
|
||||
void initialize_buffers();
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ void Scene_segmented_image_item::compile_shaders()
|
|||
m_vbo[i].create();
|
||||
for(int i=0; i< vaoSize; i++)
|
||||
vao[i].create();
|
||||
m_ibo = new QGLBuffer(QGLBuffer::IndexBuffer);
|
||||
m_ibo = new QOpenGLBuffer(QOpenGLBuffer::IndexBuffer);
|
||||
m_ibo->create();
|
||||
//Vertex source code
|
||||
const char vertex_source[] =
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@
|
|||
#include "Scene_segmented_image_item_config.h"
|
||||
#include <CGAL/gl.h>
|
||||
#include<QGLViewer/qglviewer.h>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
typedef CGAL::Image_3 Image;
|
||||
|
||||
|
|
@ -71,8 +70,8 @@ private:
|
|||
std::vector<float> color;
|
||||
|
||||
|
||||
mutable QGLBuffer m_vbo[vboSize];
|
||||
mutable QGLBuffer *m_ibo;
|
||||
mutable QOpenGLBuffer m_vbo[vboSize];
|
||||
mutable QOpenGLBuffer *m_ibo;
|
||||
mutable QOpenGLVertexArrayObject vao[vaoSize];
|
||||
mutable QOpenGLShaderProgram rendering_program;
|
||||
void draw_bbox();
|
||||
|
|
|
|||
|
|
@ -15,9 +15,8 @@
|
|||
#include <QGLViewer/qglviewer.h>
|
||||
|
||||
#include "Volume_plane_interface.h"
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
|
|
@ -142,13 +141,13 @@ private:
|
|||
const double xscale_, yscale_, zscale_;
|
||||
mutable int currentCube;
|
||||
|
||||
mutable QGLBuffer vVBO;
|
||||
mutable QGLBuffer cbuffer;
|
||||
mutable QGLBuffer rectBuffer;
|
||||
mutable QOpenGLBuffer vVBO;
|
||||
mutable QOpenGLBuffer cbuffer;
|
||||
mutable QOpenGLBuffer rectBuffer;
|
||||
mutable std::vector<float> v_rec;
|
||||
mutable QOpenGLShaderProgram program_bordures;
|
||||
mutable QOpenGLShaderProgram program;
|
||||
mutable std::vector< std::pair<QGLBuffer, unsigned int> > ebos;
|
||||
mutable std::vector< std::pair<QOpenGLBuffer, unsigned int> > ebos;
|
||||
std::vector< float > colors_;
|
||||
|
||||
QString name(x_tag) const { return tr("X Slice for %1").arg(name_); }
|
||||
|
|
@ -259,7 +258,7 @@ Volume_plane<T>::Volume_plane(unsigned int adim, unsigned int bdim, unsigned int
|
|||
|
||||
template<typename T>
|
||||
Volume_plane<T>::~Volume_plane() {
|
||||
for(std::vector< std::pair< QGLBuffer, unsigned int> >::iterator it = ebos.begin();
|
||||
for(std::vector< std::pair< QOpenGLBuffer, unsigned int> >::iterator it = ebos.begin();
|
||||
it != ebos.end(); ++it) {
|
||||
it->first.destroy();
|
||||
}
|
||||
|
|
@ -410,7 +409,7 @@ void Volume_plane<T>::init() {
|
|||
const unsigned int slice = 63399;
|
||||
for(unsigned int i = 0; i < indices.size(); i+=slice)
|
||||
{
|
||||
QGLBuffer ebo = QGLBuffer(QGLBuffer::IndexBuffer);
|
||||
QOpenGLBuffer ebo = QOpenGLBuffer(QOpenGLBuffer::IndexBuffer);
|
||||
unsigned int left_over = (i + slice) > indices.size() ? std::distance(indices.begin() + i, indices.end()) : slice;
|
||||
ebo.create();
|
||||
ebo.bind();
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@
|
|||
#include <QColor>
|
||||
#include <QString>
|
||||
#include<QGLViewer/qglviewer.h>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
class Volume_plane_interface;
|
||||
|
|
@ -65,7 +64,7 @@ private:
|
|||
std::vector<float> b_vertex;
|
||||
std::vector<float> c_vertex;
|
||||
|
||||
mutable QGLBuffer buffers[vboSize];
|
||||
mutable QOpenGLBuffer buffers[vboSize];
|
||||
mutable QOpenGLVertexArrayObject vao[vaoSize];
|
||||
mutable QOpenGLShaderProgram rendering_program;
|
||||
void compute_elements();
|
||||
|
|
|
|||
|
|
@ -1,80 +0,0 @@
|
|||
#ifndef _GL_RENDER_
|
||||
#define _GL_RENDER_
|
||||
|
||||
#include <CGAL/gl.h>
|
||||
#include <CGAL/compute_normal.h>
|
||||
|
||||
template <class Polyhedron>
|
||||
void gl_render_facets(Polyhedron& polyhedron)
|
||||
{
|
||||
typedef typename Polyhedron::Traits Kernel;
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
typedef typename Kernel::Vector_3 Vector;
|
||||
typedef typename Polyhedron::Facet Facet;
|
||||
typedef typename Polyhedron::Facet_iterator Facet_iterator;
|
||||
typedef typename Polyhedron::Halfedge_around_facet_circulator HF_circulator;
|
||||
|
||||
// Get current shading model
|
||||
GLint shading;
|
||||
::glGetIntegerv(GL_SHADE_MODEL, &shading);
|
||||
|
||||
Facet_iterator f;
|
||||
for(f = polyhedron.facets_begin();
|
||||
f != polyhedron.facets_end();
|
||||
f++)
|
||||
{
|
||||
::glBegin(GL_POLYGON);
|
||||
|
||||
// If Flat shading: 1 normal per polygon
|
||||
if (shading == GL_FLAT)
|
||||
{
|
||||
Vector n = compute_facet_normal<Facet,Kernel>(*f);
|
||||
::glNormal3d(n.x(),n.y(),n.z());
|
||||
}
|
||||
|
||||
// revolve around current face to get vertices
|
||||
HF_circulator he = f->facet_begin();
|
||||
HF_circulator end = he;
|
||||
CGAL_For_all(he,end)
|
||||
{
|
||||
// If Gouraud shading: 1 normal per vertex
|
||||
if (shading == GL_SMOOTH)
|
||||
{
|
||||
Vector n = compute_vertex_normal<typename Polyhedron::Vertex,Kernel>(*he->vertex());
|
||||
::glNormal3d(n.x(),n.y(),n.z());
|
||||
}
|
||||
|
||||
const Point& p = he->vertex()->point();
|
||||
::glVertex3d(p.x(),p.y(),p.z());
|
||||
}
|
||||
::glEnd();
|
||||
}
|
||||
} // end gl_render_facets
|
||||
|
||||
template <class Polyhedron>
|
||||
void gl_render_edges(Polyhedron& polyhedron)
|
||||
{
|
||||
typedef typename Polyhedron::Traits Kernel;
|
||||
typedef typename Kernel::Point_3 Point;
|
||||
typedef typename Polyhedron::Edge_iterator Edge_iterator;
|
||||
|
||||
::glBegin(GL_LINES);
|
||||
Edge_iterator he;
|
||||
for(he = polyhedron.edges_begin();
|
||||
he != polyhedron.edges_end();
|
||||
he++)
|
||||
{
|
||||
const Point& a = he->vertex()->point();
|
||||
const Point& b = he->opposite()->vertex()->point();
|
||||
::glVertex3d(a.x(),a.y(),a.z());
|
||||
::glVertex3d(b.x(),b.y(),b.z());
|
||||
}
|
||||
::glEnd();
|
||||
} // end gl_render_edges
|
||||
|
||||
|
||||
#endif // _GL_RENDER_
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -174,7 +174,8 @@ void Scene::compile_shaders()
|
|||
"void main(void)\n"
|
||||
"{\n"
|
||||
" fP = mv_matrix * vertex; \n"
|
||||
" fN = mat3(mv_matrix)* normal; \n"
|
||||
" vec4 TN = transfo*vec4(normal,1.0); \n"
|
||||
" fN = mat3(mv_matrix)* TN.xyz; \n"
|
||||
" gl_Position = mvp_matrix * transfo * vertex; \n"
|
||||
"}"
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,11 +6,9 @@
|
|||
#include <fstream>
|
||||
#include <QObject>
|
||||
#include <QFileDialog>
|
||||
#include <CGAL/glu.h>
|
||||
#include <QOpenGLFunctions_3_3_Core>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
class Scene : public QObject, QOpenGLFunctions_3_3_Core
|
||||
|
|
@ -289,7 +287,7 @@ private:
|
|||
std::vector<float> transfo3_square;
|
||||
std::vector<float> transfo4_square;
|
||||
|
||||
QGLBuffer buffers[24];
|
||||
QOpenGLBuffer buffers[24];
|
||||
QOpenGLVertexArrayObject vao[12];
|
||||
QOpenGLShaderProgram rendering_program;
|
||||
QOpenGLShaderProgram rendering_program_spheres;
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@
|
|||
#include "Scene.h"
|
||||
#include <QGLViewer/qglviewer.h>
|
||||
#include <QOpenGLFunctions_3_3_Core>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
|
||||
|
|
@ -67,7 +66,7 @@ private:
|
|||
std::vector<float> pos_8lines;
|
||||
|
||||
|
||||
QGLBuffer buffers[4];
|
||||
QOpenGLBuffer buffers[4];
|
||||
QOpenGLVertexArrayObject vao[4];
|
||||
QOpenGLShaderProgram rendering_program;
|
||||
void initialize_buffers();
|
||||
|
|
|
|||
|
|
@ -392,4 +392,4 @@ bool Scene_edit_polyhedron_item::keyPressEvent(QKeyEvent* e)
|
|||
return false;
|
||||
}
|
||||
|
||||
#include "Scene_edit_polyhedron_item.moc"
|
||||
//#include "Scene_edit_polyhedron_item.moc"
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ void Viewer::compile_shaders()
|
|||
"void main(void)\n"
|
||||
"{\n"
|
||||
" fP = mv_matrix * vertex; \n"
|
||||
" vec4 TN = mvp_matrix*transfo*vec4(normal,1.0); \n"
|
||||
" vec4 TN = transfo*vec4(normal,1.0); \n"
|
||||
" fN = mat3(mv_matrix)* TN.xyz; \n"
|
||||
" gl_Position = mvp_matrix * transfo* vertex; \n"
|
||||
"}"
|
||||
|
|
@ -1650,28 +1650,7 @@ void Viewer::drawFacet(const Triangle_3& t, const QColor&/*clr*/, std::vector<fl
|
|||
vertices->push_back( p0.x()); vertices->push_back(p0.y()); vertices->push_back(p0.z());
|
||||
vertices->push_back( p1.x()); vertices->push_back(p1.y()); vertices->push_back(p1.z());
|
||||
vertices->push_back( p2.x()); vertices->push_back(p2.y()); vertices->push_back(p2.z());
|
||||
/* // disable lighting
|
||||
::glDisable( GL_LIGHTING );
|
||||
|
||||
// disable depth buffer writing
|
||||
::glDepthMask( GL_FALSE );
|
||||
|
||||
qglColor( m_colorFacet );
|
||||
|
||||
::glBegin(GL_TRIANGLES);
|
||||
Point_3 p0 = t.vertex(0);
|
||||
Point_3 p1 = t.vertex(1);
|
||||
Point_3 p2 = t.vertex(2);
|
||||
::glVertex3f( p0.x(), p0.y(), p0.z() );
|
||||
::glVertex3f( p1.x(), p1.y(), p1.z() );
|
||||
::glVertex3f( p2.x(), p2.y(), p2.z() );
|
||||
::glEnd();
|
||||
|
||||
// resume depth buffer writing
|
||||
::glDepthMask( GL_TRUE );
|
||||
|
||||
// resume lighting
|
||||
::glEnable( GL_LIGHTING );*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,8 @@
|
|||
#include "PreferenceDlg.h"
|
||||
|
||||
#include <QOpenGLFunctions_3_3_Core>
|
||||
#include <QGLFunctions>
|
||||
#include <QOpenGLVertexArrayObject>
|
||||
#include <QGLBuffer>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOpenGLShaderProgram>
|
||||
|
||||
#include <iostream>
|
||||
|
|
@ -390,7 +389,7 @@ private:
|
|||
std::vector<float> *incremental_facet;
|
||||
std::vector<float> *incremental_conflict;
|
||||
|
||||
QGLBuffer buffers[vboSize];
|
||||
QOpenGLBuffer buffers[vboSize];
|
||||
QOpenGLVertexArrayObject vao[vaoSize];
|
||||
QOpenGLShaderProgram rendering_program;
|
||||
QOpenGLShaderProgram rendering_program_spheres;
|
||||
|
|
|
|||
Loading…
Reference in New Issue