mirror of https://github.com/CGAL/cgal
Polyhedron demo: do not use the OpenGL API directly
This commit is contained in:
parent
f5b5aead66
commit
3466eb83f0
|
|
@ -47,7 +47,33 @@ CGAL_QT_EXPORT void traverse_resources(const QString& name,
|
||||||
/**
|
/**
|
||||||
* Call this in the end of an OpenGL implementation to check if it returns errors.
|
* Call this in the end of an OpenGL implementation to check if it returns errors.
|
||||||
*/
|
*/
|
||||||
CGAL_QT_EXPORT void opengl_check_errors(unsigned int line);
|
template <typename QtOpenGLFunctions>
|
||||||
|
void opengl_check_errors(QtOpenGLFunctions* gl,
|
||||||
|
unsigned int line) {
|
||||||
|
GLenum error = gl->glGetError();
|
||||||
|
while (error != GL_NO_ERROR)
|
||||||
|
{
|
||||||
|
if(error == GL_INVALID_ENUM)
|
||||||
|
std::cerr << "An unacceptable value is specified for an enumerated argument." << "@" << line << std::endl;
|
||||||
|
if(error == GL_INVALID_VALUE)
|
||||||
|
std::cerr << "A numeric argument is out of range." << "@" << line << std::endl;
|
||||||
|
if(error == GL_INVALID_OPERATION)
|
||||||
|
std::cerr << "The specified operation is not allowed in the current state." << "@" << line << std::endl;
|
||||||
|
if(error == GL_INVALID_FRAMEBUFFER_OPERATION)
|
||||||
|
std::cerr << "The framebuffer object is not complete." << "@" << line << std::endl;
|
||||||
|
if(error == GL_OUT_OF_MEMORY)
|
||||||
|
std::cerr << "There is not enough memory left to execute the command." << "@" << line << std::endl;
|
||||||
|
#ifdef GL_STACK_UNDERFLOW
|
||||||
|
if(error == GL_STACK_UNDERFLOW)
|
||||||
|
std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to underflow." << "@" << line << std::endl;
|
||||||
|
#endif
|
||||||
|
#ifdef GL_STACK_OVERFLOW
|
||||||
|
if(error == GL_STACK_OVERFLOW)
|
||||||
|
std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to overflow." << "@" << line << std::endl;
|
||||||
|
#endif
|
||||||
|
error = gl->glGetError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Qt
|
} // namespace Qt
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
|
||||||
|
|
@ -59,32 +59,5 @@ void traverse_resources(const QString& name, const QString& dirname, int indent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGAL_INLINE_FUNCTION
|
|
||||||
void opengl_check_errors(unsigned int line)
|
|
||||||
{
|
|
||||||
GLenum error = ::glGetError();
|
|
||||||
while (error != GL_NO_ERROR)
|
|
||||||
{
|
|
||||||
if(error == GL_INVALID_ENUM)
|
|
||||||
std::cerr << "An unacceptable value is specified for an enumerated argument." << "@" << line << std::endl;
|
|
||||||
if(error == GL_INVALID_VALUE)
|
|
||||||
std::cerr << "A numeric argument is out of range." << "@" << line << std::endl;
|
|
||||||
if(error == GL_INVALID_OPERATION)
|
|
||||||
std::cerr << "The specified operation is not allowed in the current state." << "@" << line << std::endl;
|
|
||||||
if(error == GL_INVALID_FRAMEBUFFER_OPERATION)
|
|
||||||
std::cerr << "The framebuffer object is not complete." << "@" << line << std::endl;
|
|
||||||
if(error == GL_OUT_OF_MEMORY)
|
|
||||||
std::cerr << "There is not enough memory left to execute the command." << "@" << line << std::endl;
|
|
||||||
#ifdef GL_STACK_UNDERFLOW
|
|
||||||
if(error == GL_STACK_UNDERFLOW)
|
|
||||||
std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to underflow." << "@" << line << std::endl;
|
|
||||||
#endif
|
|
||||||
#ifdef GL_STACK_OVERFLOW
|
|
||||||
if(error == GL_STACK_OVERFLOW)
|
|
||||||
std::cerr << "An attempt has been made to perform an operation that would cause an internal stack to overflow." << "@" << line << std::endl;
|
|
||||||
#endif
|
|
||||||
error = ::glGetError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // namesapce Qt
|
} // namesapce Qt
|
||||||
} // namespace CGAL
|
} // namespace CGAL
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,10 @@ endif()
|
||||||
if(POLICY CMP0071)
|
if(POLICY CMP0071)
|
||||||
cmake_policy(SET CMP0071 NEW)
|
cmake_policy(SET CMP0071 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
if(POLICY CMP0072)
|
||||||
|
# About the use of OpenGL
|
||||||
|
cmake_policy(SET CMP0072 NEW)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Find includes in corresponding build directories
|
# Find includes in corresponding build directories
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
@ -139,7 +143,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||||
add_library(gl_splat SHARED
|
add_library(gl_splat SHARED
|
||||||
GlSplat/GlSplat.cpp GlSplat/Shader.cpp ${gl_splat_rc})
|
GlSplat/GlSplat.cpp GlSplat/Shader.cpp ${gl_splat_rc})
|
||||||
target_link_libraries(gl_splat PUBLIC ${QGLVIEWER_LIBRARIES} Qt5::OpenGL Qt5::Gui)
|
target_link_libraries(gl_splat PUBLIC ${QGLVIEWER_LIBRARIES} Qt5::OpenGL Qt5::Gui)
|
||||||
target_link_libraries(gl_splat PRIVATE ${OPENGL_gl_LIBRARY} ${QGLVIEWER_LIBRARIES})
|
target_link_libraries(gl_splat PRIVATE ${OPENGL_LIBRARIES} ${QGLVIEWER_LIBRARIES})
|
||||||
|
|
||||||
find_path(CGAL_THREE_HEADERS_PATH
|
find_path(CGAL_THREE_HEADERS_PATH
|
||||||
NAME CGAL/Three/Scene_item.h
|
NAME CGAL/Three/Scene_item.h
|
||||||
|
|
@ -185,8 +189,6 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||||
target_link_libraries(demo_framework
|
target_link_libraries(demo_framework
|
||||||
PUBLIC Qt5::OpenGL Qt5::Widgets Qt5::Gui Qt5::Script
|
PUBLIC Qt5::OpenGL Qt5::Widgets Qt5::Gui Qt5::Script
|
||||||
${QGLVIEWER_LIBRARIES}
|
${QGLVIEWER_LIBRARIES}
|
||||||
${OPENGL_gl_LIBRARY}
|
|
||||||
${OPENGL_glu_LIBRARY}
|
|
||||||
gl_splat
|
gl_splat
|
||||||
)
|
)
|
||||||
if(CGAL_HEADER_ONLY)
|
if(CGAL_HEADER_ONLY)
|
||||||
|
|
@ -202,8 +204,6 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||||
demo_framework
|
demo_framework
|
||||||
${CGAL_LIBRARIES}
|
${CGAL_LIBRARIES}
|
||||||
${QGLVIEWER_LIBRARIES}
|
${QGLVIEWER_LIBRARIES}
|
||||||
${OPENGL_gl_LIBRARY}
|
|
||||||
${OPENGL_glu_LIBRARY}
|
|
||||||
gl_splat
|
gl_splat
|
||||||
Qt5::OpenGL Qt5::Gui Qt5::Script Qt5::Widgets)
|
Qt5::OpenGL Qt5::Gui Qt5::Script Qt5::Widgets)
|
||||||
add_library(scene_color_ramp SHARED Color_ramp.cpp)
|
add_library(scene_color_ramp SHARED Color_ramp.cpp)
|
||||||
|
|
@ -344,8 +344,8 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
||||||
# Link with CGAL
|
# Link with CGAL
|
||||||
target_link_libraries( Polyhedron_3 PUBLIC ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
|
target_link_libraries( Polyhedron_3 PUBLIC ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
|
||||||
|
|
||||||
# Link with libQGLViewer, OpenGL
|
# Link with libQGLViewer
|
||||||
target_link_libraries( Polyhedron_3 PUBLIC ${QGLVIEWER_LIBRARIES} ${OPENGL_gl_LIBRARY})
|
target_link_libraries( Polyhedron_3 PUBLIC ${QGLVIEWER_LIBRARIES})
|
||||||
|
|
||||||
add_to_cached_list( CGAL_EXECUTABLE_TARGETS Polyhedron_3 )
|
add_to_cached_list( CGAL_EXECUTABLE_TARGETS Polyhedron_3 )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -373,7 +373,7 @@ public Q_SLOTS:
|
||||||
|
|
||||||
void addVP(Volume_plane_thread* thread) {
|
void addVP(Volume_plane_thread* thread) {
|
||||||
Volume_plane_interface* plane = thread->getItem();
|
Volume_plane_interface* plane = thread->getItem();
|
||||||
plane->init();
|
plane->init(static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first()));
|
||||||
// add the interface for this Volume_plane
|
// add the interface for this Volume_plane
|
||||||
int id = scene->addItem(plane);
|
int id = scene->addItem(plane);
|
||||||
scene->changeGroup(plane, group);
|
scene->changeGroup(plane, group);
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@ using namespace CGAL::Three;
|
||||||
|
|
||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
inline
|
inline
|
||||||
void printGlError(unsigned int line) {
|
void printGlError(CGAL::Three::Viewer_interface* viewer, unsigned int line) {
|
||||||
CGAL::Qt::opengl_check_errors(line);
|
CGAL::Qt::opengl_check_errors(viewer, line);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
inline
|
inline
|
||||||
void printGlError(unsigned int) {
|
void printGlError(CGAL::Three::Viewer_interface*, unsigned int) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -121,7 +121,7 @@ public:
|
||||||
|
|
||||||
// uses a public init function to enable construction in
|
// uses a public init function to enable construction in
|
||||||
// threads without gl-context
|
// threads without gl-context
|
||||||
void init();
|
void init(Viewer_interface* viewer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool is_grabbing;
|
bool is_grabbing;
|
||||||
|
|
@ -438,11 +438,11 @@ void Volume_plane<T>::draw(Viewer_interface *viewer) const {
|
||||||
program_bordures.setUniformValue("f_matrix", f);
|
program_bordures.setUniformValue("f_matrix", f);
|
||||||
program_bordures.release();
|
program_bordures.release();
|
||||||
GLint renderMode;
|
GLint renderMode;
|
||||||
glGetIntegerv(GL_RENDER_MODE, &renderMode);
|
viewer->glGetIntegerv(GL_RENDER_MODE, &renderMode);
|
||||||
printGlError(__LINE__);
|
printGlError(viewer, __LINE__);
|
||||||
|
|
||||||
|
|
||||||
glLineWidth(4.0f);
|
viewer->glLineWidth(4.0f);
|
||||||
v_rec.resize(0);
|
v_rec.resize(0);
|
||||||
drawRectangle(*this);
|
drawRectangle(*this);
|
||||||
|
|
||||||
|
|
@ -453,10 +453,10 @@ void Volume_plane<T>::draw(Viewer_interface *viewer) const {
|
||||||
program_bordures.setAttributeBuffer("vertex",GL_FLOAT,0,3);
|
program_bordures.setAttributeBuffer("vertex",GL_FLOAT,0,3);
|
||||||
program_bordures.enableAttributeArray("vertex");
|
program_bordures.enableAttributeArray("vertex");
|
||||||
program_bordures.setUniformValue("color",this->color());
|
program_bordures.setUniformValue("color",this->color());
|
||||||
glDrawArrays(GL_LINE_LOOP, 0, static_cast<GLsizei>(v_rec.size()/3));
|
viewer->glDrawArrays(GL_LINE_LOOP, 0, static_cast<GLsizei>(v_rec.size()/3));
|
||||||
rectBuffer.release();
|
rectBuffer.release();
|
||||||
program_bordures.release();
|
program_bordures.release();
|
||||||
glLineWidth(1.0f);
|
viewer->glLineWidth(1.0f);
|
||||||
|
|
||||||
program.bind();
|
program.bind();
|
||||||
int mvpLoc = program.uniformLocation("mvp_matrix");
|
int mvpLoc = program.uniformLocation("mvp_matrix");
|
||||||
|
|
@ -477,20 +477,20 @@ void Volume_plane<T>::draw(Viewer_interface *viewer) const {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
printGlError(__LINE__);
|
printGlError(viewer, __LINE__);
|
||||||
|
|
||||||
for(unsigned int i = 0; i < ebos.size(); ++i)
|
for(unsigned int i = 0; i < ebos.size(); ++i)
|
||||||
{
|
{
|
||||||
ebos[i].first.bind();
|
ebos[i].first.bind();
|
||||||
glDrawElements(GL_TRIANGLES, ebos[i].second, GL_UNSIGNED_INT, 0);
|
viewer->glDrawElements(GL_TRIANGLES, ebos[i].second, GL_UNSIGNED_INT, 0);
|
||||||
ebos[i].first.release();
|
ebos[i].first.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuffer.release();
|
cbuffer.release();
|
||||||
printGlError(__LINE__);
|
printGlError(viewer, __LINE__);
|
||||||
program.release();
|
program.release();
|
||||||
|
|
||||||
printGlError(__LINE__);
|
printGlError(viewer, __LINE__);
|
||||||
|
|
||||||
if(!are_buffers_filled)
|
if(!are_buffers_filled)
|
||||||
initializeBuffers(viewer);
|
initializeBuffers(viewer);
|
||||||
|
|
@ -512,7 +512,7 @@ void Volume_plane<T>::draw(Viewer_interface *viewer) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Volume_plane<T>::init() {
|
void Volume_plane<T>::init(Viewer_interface* viewer) {
|
||||||
is_grabbing = false;
|
is_grabbing = false;
|
||||||
initShaders();
|
initShaders();
|
||||||
|
|
||||||
|
|
@ -530,14 +530,14 @@ void Volume_plane<T>::init() {
|
||||||
assert(vertices.size() == (3 * adim_ * bdim_));
|
assert(vertices.size() == (3 * adim_ * bdim_));
|
||||||
|
|
||||||
int maxi, maxv;
|
int maxi, maxv;
|
||||||
glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &maxi);
|
viewer->glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &maxi);
|
||||||
glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &maxv);
|
viewer->glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &maxv);
|
||||||
assert((vertices.size( ) / 3) < (unsigned int)maxi);
|
assert((vertices.size( ) / 3) < (unsigned int)maxi);
|
||||||
vVBO.create();
|
vVBO.create();
|
||||||
vVBO.bind();
|
vVBO.bind();
|
||||||
vVBO.allocate(vertices.data(),static_cast<int>(sizeof(float) * vertices.size()));
|
vVBO.allocate(vertices.data(),static_cast<int>(sizeof(float) * vertices.size()));
|
||||||
vVBO.release();
|
vVBO.release();
|
||||||
printGlError(__LINE__);
|
printGlError(viewer, __LINE__);
|
||||||
|
|
||||||
// for each patch
|
// for each patch
|
||||||
std::vector<unsigned int> indices;
|
std::vector<unsigned int> indices;
|
||||||
|
|
@ -589,7 +589,7 @@ void Volume_plane<T>::init() {
|
||||||
cbuffer.allocate(colors_.data(),static_cast<int>(colors_.size()*sizeof(float)));
|
cbuffer.allocate(colors_.data(),static_cast<int>(colors_.size()*sizeof(float)));
|
||||||
cbuffer.release();
|
cbuffer.release();
|
||||||
|
|
||||||
printGlError(__LINE__);
|
printGlError(viewer, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
#include <QGLViewer/qglviewer.h>
|
#include <QGLViewer/qglviewer.h>
|
||||||
#include <CGAL/Three/Scene_item.h>
|
#include <CGAL/Three/Scene_item.h>
|
||||||
|
#include <CGAL/Three/Viewer_interface.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QGLViewer/manipulatedFrame.h>
|
#include <QGLViewer/manipulatedFrame.h>
|
||||||
using namespace CGAL::Three;
|
using namespace CGAL::Three;
|
||||||
|
|
@ -22,7 +23,7 @@ public:
|
||||||
delete mFrame_;
|
delete mFrame_;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void init() = 0;
|
virtual void init(CGAL::Three::Viewer_interface*) = 0;
|
||||||
|
|
||||||
virtual void setData(unsigned int adim, unsigned int bdim, unsigned int cdim, float xscale, float yscale, float zscale, std::vector<float> &colors) =0;
|
virtual void setData(unsigned int adim, unsigned int bdim, unsigned int cdim, float xscale, float yscale, float zscale, std::vector<float> &colors) =0;
|
||||||
virtual unsigned int aDim() const = 0;
|
virtual unsigned int aDim() const = 0;
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ void Volume_plane_intersection::draw(Viewer_interface* viewer) const {
|
||||||
d->initializeBuffers(viewer);
|
d->initializeBuffers(viewer);
|
||||||
}
|
}
|
||||||
attribBuffers(viewer, PROGRAM_NO_SELECTION);
|
attribBuffers(viewer, PROGRAM_NO_SELECTION);
|
||||||
glDepthRange(0.0,0.9999);
|
viewer->glDepthRange(0.0,0.9999);
|
||||||
if(d->b && d->c) {
|
if(d->b && d->c) {
|
||||||
|
|
||||||
vaos[Volume_plane_intersection_priv::AArray]->bind();
|
vaos[Volume_plane_intersection_priv::AArray]->bind();
|
||||||
|
|
@ -186,7 +186,7 @@ void Volume_plane_intersection::draw(Viewer_interface* viewer) const {
|
||||||
vaos[Volume_plane_intersection_priv::CArray]->release();
|
vaos[Volume_plane_intersection_priv::CArray]->release();
|
||||||
}
|
}
|
||||||
viewer->glLineWidth(1.0f);
|
viewer->glLineWidth(1.0f);
|
||||||
glDepthRange(0.00001,1.0);
|
viewer->glDepthRange(0.00001,1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Volume_plane_intersection::Volume_plane_intersection(float x, float y, float z)
|
Volume_plane_intersection::Volume_plane_intersection(float x, float y, float z)
|
||||||
|
|
|
||||||
|
|
@ -1279,8 +1279,8 @@ void Scene_edit_box_item_priv::picking(int& type, int& id, Viewer_interface *vie
|
||||||
int deviceHeight = viewer->camera()->screenHeight();
|
int deviceHeight = viewer->camera()->screenHeight();
|
||||||
QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(deviceWidth, deviceHeight,QOpenGLFramebufferObject::Depth);
|
QOpenGLFramebufferObject* fbo = new QOpenGLFramebufferObject(deviceWidth, deviceHeight,QOpenGLFramebufferObject::Depth);
|
||||||
fbo->bind();
|
fbo->bind();
|
||||||
glEnable(GL_DEPTH_TEST);
|
viewer->glEnable(GL_DEPTH_TEST);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
QColor bgColor(viewer->backgroundColor());
|
QColor bgColor(viewer->backgroundColor());
|
||||||
//draws the image in the fbo
|
//draws the image in the fbo
|
||||||
viewer->setBackgroundColor(::Qt::white);
|
viewer->setBackgroundColor(::Qt::white);
|
||||||
|
|
@ -1290,7 +1290,7 @@ void Scene_edit_box_item_priv::picking(int& type, int& id, Viewer_interface *vie
|
||||||
const static int dataLength = rowLength * deviceHeight;
|
const static int dataLength = rowLength * deviceHeight;
|
||||||
GLubyte* buffer = new GLubyte[dataLength];
|
GLubyte* buffer = new GLubyte[dataLength];
|
||||||
// Qt uses upper corner for its origin while GL uses the lower corner.
|
// Qt uses upper corner for its origin while GL uses the lower corner.
|
||||||
glReadPixels(picked_pixel.x(), deviceHeight-1-picked_pixel.y(), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
viewer->glReadPixels(picked_pixel.x(), deviceHeight-1-picked_pixel.y(), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||||
//decode ID and pick (don't forget the case nothing is picked
|
//decode ID and pick (don't forget the case nothing is picked
|
||||||
if(!(buffer[0]==buffer[1] && buffer[1]==buffer[2]))
|
if(!(buffer[0]==buffer[1] && buffer[1]==buffer[2]))
|
||||||
{
|
{
|
||||||
|
|
@ -1392,8 +1392,8 @@ void Scene_edit_box_item::drawHl(Viewer_interface* viewer)const
|
||||||
{
|
{
|
||||||
viewer->glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &offset_factor);
|
viewer->glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &offset_factor);
|
||||||
viewer->glGetFloatv(GL_POLYGON_OFFSET_UNITS, &offset_units);
|
viewer->glGetFloatv(GL_POLYGON_OFFSET_UNITS, &offset_units);
|
||||||
glEnable(GL_BLEND);
|
viewer->glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
viewer->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
vaos[Scene_edit_box_item_priv::S_Faces]->bind();
|
vaos[Scene_edit_box_item_priv::S_Faces]->bind();
|
||||||
d->program = &d->transparent_face_program;
|
d->program = &d->transparent_face_program;
|
||||||
d->program->bind();
|
d->program->bind();
|
||||||
|
|
@ -1409,8 +1409,8 @@ void Scene_edit_box_item::drawHl(Viewer_interface* viewer)const
|
||||||
viewer->glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(d->hl_vertex.size()/3));
|
viewer->glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(d->hl_vertex.size()/3));
|
||||||
vaos[Scene_edit_box_item_priv::S_Faces]->release();
|
vaos[Scene_edit_box_item_priv::S_Faces]->release();
|
||||||
d->program->release();
|
d->program->release();
|
||||||
glPolygonOffset(offset_factor, offset_units);
|
viewer->glPolygonOffset(offset_factor, offset_units);
|
||||||
glDisable(GL_BLEND);
|
viewer->glDisable(GL_BLEND);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1445,8 +1445,8 @@ void Scene_edit_box_item::drawTransparent(CGAL::Three::Viewer_interface*viewer)c
|
||||||
// Specular
|
// Specular
|
||||||
QVector4D specular(0.0f, 0.0f, 0.0f, 1.0f);
|
QVector4D specular(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
viewer->glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
viewer->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
vaos[Scene_edit_box_item_priv::Faces]->bind();
|
vaos[Scene_edit_box_item_priv::Faces]->bind();
|
||||||
d->program = &d->transparent_face_program;
|
d->program = &d->transparent_face_program;
|
||||||
d->program->bind();
|
d->program->bind();
|
||||||
|
|
@ -1462,5 +1462,5 @@ void Scene_edit_box_item::drawTransparent(CGAL::Three::Viewer_interface*viewer)c
|
||||||
viewer->glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(d->vertex_faces.size()/3));
|
viewer->glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(d->vertex_faces.size()/3));
|
||||||
vaos[Scene_edit_box_item_priv::Faces]->release();
|
vaos[Scene_edit_box_item_priv::Faces]->release();
|
||||||
d->program->release();
|
d->program->release();
|
||||||
glDisable(GL_BLEND);
|
viewer->glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -363,8 +363,8 @@ void Scene_alpha_shape_item::draw(CGAL::Three::Viewer_interface* viewer) const
|
||||||
vaos[0]->bind();
|
vaos[0]->bind();
|
||||||
|
|
||||||
program->setAttributeValue("colors", this->color());
|
program->setAttributeValue("colors", this->color());
|
||||||
glDrawElements(GL_TRIANGLES, static_cast<GLuint>(indices.size()),
|
viewer->glDrawElements(GL_TRIANGLES, static_cast<GLuint>(indices.size()),
|
||||||
GL_UNSIGNED_INT, indices.data());
|
GL_UNSIGNED_INT, indices.data());
|
||||||
program->release();
|
program->release();
|
||||||
vaos[0]->release();
|
vaos[0]->release();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ void Scene_polyhedron_shortest_path_item::drawPoints(CGAL::Three::Viewer_interfa
|
||||||
{
|
{
|
||||||
d->initialize_buffers(viewer);
|
d->initialize_buffers(viewer);
|
||||||
}
|
}
|
||||||
glPointSize(4.0f);
|
viewer->glPointSize(4.0f);
|
||||||
d->program = getShaderProgram(PROGRAM_NO_SELECTION);
|
d->program = getShaderProgram(PROGRAM_NO_SELECTION);
|
||||||
attribBuffers(viewer, PROGRAM_NO_SELECTION);
|
attribBuffers(viewer, PROGRAM_NO_SELECTION);
|
||||||
vaos[Scene_polyhedron_shortest_path_item_priv::Selected_Edges]->bind();
|
vaos[Scene_polyhedron_shortest_path_item_priv::Selected_Edges]->bind();
|
||||||
|
|
@ -195,7 +195,7 @@ void Scene_polyhedron_shortest_path_item::drawPoints(CGAL::Three::Viewer_interfa
|
||||||
viewer->glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(d->vertices.size() / 3));
|
viewer->glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(d->vertices.size() / 3));
|
||||||
d->program->release();
|
d->program->release();
|
||||||
vaos[Scene_polyhedron_shortest_path_item_priv::Selected_Edges]->release();
|
vaos[Scene_polyhedron_shortest_path_item_priv::Selected_Edges]->release();
|
||||||
glPointSize(1.0f);
|
viewer->glPointSize(1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene_polyhedron_shortest_path_item* Scene_polyhedron_shortest_path_item::clone() const
|
Scene_polyhedron_shortest_path_item* Scene_polyhedron_shortest_path_item::clone() const
|
||||||
|
|
|
||||||
|
|
@ -1456,8 +1456,8 @@ void Scene_edit_polyhedron_item::drawTransparent(Viewer_interface *viewer) const
|
||||||
viewer->camera()->getModelViewProjectionMatrix(d_mat);
|
viewer->camera()->getModelViewProjectionMatrix(d_mat);
|
||||||
for (int i=0; i<16; ++i)
|
for (int i=0; i<16; ++i)
|
||||||
mvp_mat.data()[i] = GLfloat(d_mat[i]);
|
mvp_mat.data()[i] = GLfloat(d_mat[i]);
|
||||||
glEnable(GL_BLEND);
|
viewer->glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
viewer->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
vaos[Scene_edit_polyhedron_item_priv::Frame_plane]->bind();
|
vaos[Scene_edit_polyhedron_item_priv::Frame_plane]->bind();
|
||||||
d->program = &d->transparent_plane_program;
|
d->program = &d->transparent_plane_program;
|
||||||
d->program->bind();
|
d->program->bind();
|
||||||
|
|
@ -1468,7 +1468,7 @@ void Scene_edit_polyhedron_item::drawTransparent(Viewer_interface *viewer) const
|
||||||
viewer->glDrawElements(GL_TRIANGLES, (GLsizei) d->plane_idx.size(), GL_UNSIGNED_INT, d->plane_idx.data());
|
viewer->glDrawElements(GL_TRIANGLES, (GLsizei) d->plane_idx.size(), GL_UNSIGNED_INT, d->plane_idx.data());
|
||||||
d->program->release();
|
d->program->release();
|
||||||
vaos[Scene_edit_polyhedron_item_priv::Frame_plane]->release();
|
vaos[Scene_edit_polyhedron_item_priv::Frame_plane]->release();
|
||||||
glDisable(GL_BLEND);
|
viewer->glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1572,7 +1572,7 @@ void Scene_edit_polyhedron_item_priv::draw_ROI_and_control_vertices(CGAL::Three:
|
||||||
}
|
}
|
||||||
void Scene_edit_polyhedron_item::draw_ROI_and_control_vertices(CGAL::Three::Viewer_interface* viewer) const {
|
void Scene_edit_polyhedron_item::draw_ROI_and_control_vertices(CGAL::Three::Viewer_interface* viewer) const {
|
||||||
|
|
||||||
CGAL::GL::Point_size point_size; point_size.set_point_size(5);
|
CGAL::GL::Point_size point_size(viewer); point_size.set_point_size(5);
|
||||||
|
|
||||||
//Draw the points
|
//Draw the points
|
||||||
if(d->ui_widget->ShowROICheckBox->isChecked()) {
|
if(d->ui_widget->ShowROICheckBox->isChecked()) {
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,7 @@ Scene::duplicate(Item_id index)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::initializeGL()
|
void Scene::initializeGL(CGAL::Three::Viewer_interface* viewer)
|
||||||
{
|
{
|
||||||
ms_splatting->init();
|
ms_splatting->init();
|
||||||
|
|
||||||
|
|
@ -325,10 +325,10 @@ void Scene::initializeGL()
|
||||||
GLfloat position[] = { 0.0f, 0.0f, 1.0f, 1.0f };
|
GLfloat position[] = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||||
|
|
||||||
// Assign created components to GL_LIGHT0
|
// Assign created components to GL_LIGHT0
|
||||||
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
|
viewer->glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
|
viewer->glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
|
||||||
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
|
viewer->glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
|
||||||
glLightfv(GL_LIGHT0, GL_POSITION, position);
|
viewer->glLightfv(GL_LIGHT0, GL_POSITION, position);
|
||||||
|
|
||||||
gl_init = true;
|
gl_init = true;
|
||||||
}
|
}
|
||||||
|
|
@ -380,11 +380,11 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
||||||
{
|
{
|
||||||
QMap<float, int> picked_item_IDs;
|
QMap<float, int> picked_item_IDs;
|
||||||
if(with_names)
|
if(with_names)
|
||||||
glEnable(GL_DEPTH_TEST);
|
viewer->glEnable(GL_DEPTH_TEST);
|
||||||
if(!ms_splatting->viewer_is_set)
|
if(!ms_splatting->viewer_is_set)
|
||||||
ms_splatting->setViewer(viewer);
|
ms_splatting->setViewer(viewer);
|
||||||
if(!gl_init)
|
if(!gl_init)
|
||||||
initializeGL();
|
initializeGL(viewer);
|
||||||
// Flat/Gouraud OpenGL drawing
|
// Flat/Gouraud OpenGL drawing
|
||||||
for(int index = 0; index < m_entries.size(); ++index)
|
for(int index = 0; index < m_entries.size(); ++index)
|
||||||
{
|
{
|
||||||
|
|
@ -404,8 +404,8 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
||||||
if(item.renderingMode() == Flat || item.renderingMode() == FlatPlusEdges || item.renderingMode() == Gouraud)
|
if(item.renderingMode() == Flat || item.renderingMode() == FlatPlusEdges || item.renderingMode() == Gouraud)
|
||||||
{
|
{
|
||||||
if(with_names) {
|
if(with_names) {
|
||||||
glClearDepth(1.0);
|
viewer->glClearDepth(1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
viewer->glEnable(GL_LIGHTING);
|
viewer->glEnable(GL_LIGHTING);
|
||||||
viewer->glPointSize(2.f);
|
viewer->glPointSize(2.f);
|
||||||
|
|
@ -423,7 +423,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
||||||
|
|
||||||
// read depth buffer at pick location;
|
// read depth buffer at pick location;
|
||||||
float depth = 1.0;
|
float depth = 1.0;
|
||||||
glReadPixels(picked_pixel.x(),viewer->camera()->screenHeight()-1-picked_pixel.y(),1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
|
viewer->glReadPixels(picked_pixel.x(),viewer->camera()->screenHeight()-1-picked_pixel.y(),1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
|
||||||
if (depth != 1.0)
|
if (depth != 1.0)
|
||||||
{
|
{
|
||||||
//add object to list of picked objects;
|
//add object to list of picked objects;
|
||||||
|
|
@ -433,7 +433,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glDepthFunc(GL_LEQUAL);
|
viewer->glDepthFunc(GL_LEQUAL);
|
||||||
// Wireframe OpenGL drawing
|
// Wireframe OpenGL drawing
|
||||||
for(int index = 0; index < m_entries.size(); ++index)
|
for(int index = 0; index < m_entries.size(); ++index)
|
||||||
{
|
{
|
||||||
|
|
@ -453,8 +453,8 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
||||||
if((item.renderingMode() == Wireframe || item.renderingMode() == PointsPlusNormals )
|
if((item.renderingMode() == Wireframe || item.renderingMode() == PointsPlusNormals )
|
||||||
&& with_names)
|
&& with_names)
|
||||||
{
|
{
|
||||||
glClearDepth(1.0);
|
viewer->glClearDepth(1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
if((!with_names && item.renderingMode() == FlatPlusEdges )
|
if((!with_names && item.renderingMode() == FlatPlusEdges )
|
||||||
|| item.renderingMode() == Wireframe)
|
|| item.renderingMode() == Wireframe)
|
||||||
|
|
@ -495,7 +495,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
||||||
|
|
||||||
// read depth buffer at pick location;
|
// read depth buffer at pick location;
|
||||||
float depth = 1.0;
|
float depth = 1.0;
|
||||||
glReadPixels(picked_pixel.x(),viewer->camera()->screenHeight()-1-picked_pixel.y(),1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
|
viewer->glReadPixels(picked_pixel.x(),viewer->camera()->screenHeight()-1-picked_pixel.y(),1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
|
||||||
if (depth != 1.0)
|
if (depth != 1.0)
|
||||||
{
|
{
|
||||||
//add object to list of picked objects;
|
//add object to list of picked objects;
|
||||||
|
|
@ -512,8 +512,8 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
||||||
if(item.visible())
|
if(item.visible())
|
||||||
{
|
{
|
||||||
if(item.renderingMode() == Points && with_names) {
|
if(item.renderingMode() == Points && with_names) {
|
||||||
glClearDepth(1.0);
|
viewer->glClearDepth(1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
if(item.renderingMode() == Points ||
|
if(item.renderingMode() == Points ||
|
||||||
(!with_names && item.renderingMode() == PointsPlusNormals) ||
|
(!with_names && item.renderingMode() == PointsPlusNormals) ||
|
||||||
|
|
@ -531,7 +531,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
||||||
if(item.renderingMode() == Points && with_names) {
|
if(item.renderingMode() == Points && with_names) {
|
||||||
// read depth buffer at pick location;
|
// read depth buffer at pick location;
|
||||||
float depth = 1.0;
|
float depth = 1.0;
|
||||||
glReadPixels(picked_pixel.x(),viewer->camera()->screenHeight()-1-picked_pixel.y(),1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
|
viewer->glReadPixels(picked_pixel.x(),viewer->camera()->screenHeight()-1-picked_pixel.y(),1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
|
||||||
if (depth != 1.0)
|
if (depth != 1.0)
|
||||||
{
|
{
|
||||||
//add object to list of picked objects;
|
//add object to list of picked objects;
|
||||||
|
|
@ -541,7 +541,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
||||||
|
|
||||||
if(!with_names)
|
if(!with_names)
|
||||||
{
|
{
|
||||||
glDepthFunc(GL_LESS);
|
viewer->glDepthFunc(GL_LESS);
|
||||||
// Splatting
|
// Splatting
|
||||||
if(!with_names && ms_splatting->isSupported())
|
if(!with_names && ms_splatting->isSupported())
|
||||||
{
|
{
|
||||||
|
|
@ -594,8 +594,8 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
||||||
if(item.visible())
|
if(item.visible())
|
||||||
{
|
{
|
||||||
if(with_names) {
|
if(with_names) {
|
||||||
glClearDepth(1.0);
|
viewer->glClearDepth(1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
viewer->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
viewer->glEnable(GL_LIGHTING);
|
viewer->glEnable(GL_LIGHTING);
|
||||||
viewer->glPointSize(2.f);
|
viewer->glPointSize(2.f);
|
||||||
|
|
@ -612,7 +612,7 @@ Scene::draw_aux(bool with_names, CGAL::Three::Viewer_interface* viewer)
|
||||||
|
|
||||||
// read depth buffer at pick location;
|
// read depth buffer at pick location;
|
||||||
float depth = 1.0;
|
float depth = 1.0;
|
||||||
glReadPixels(picked_pixel.x(),viewer->camera()->screenHeight()-1-picked_pixel.y(),1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
|
viewer->glReadPixels(picked_pixel.x(),viewer->camera()->screenHeight()-1-picked_pixel.y(),1,1,GL_DEPTH_COMPONENT, GL_FLOAT, &depth);
|
||||||
if (depth != 1.0)
|
if (depth != 1.0)
|
||||||
{
|
{
|
||||||
//add object to list of picked objects;
|
//add object to list of picked objects;
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public:
|
||||||
QList<int> selectionIndices() const Q_DECL_OVERRIDE;
|
QList<int> selectionIndices() const Q_DECL_OVERRIDE;
|
||||||
int selectionAindex() const Q_DECL_OVERRIDE;
|
int selectionAindex() const Q_DECL_OVERRIDE;
|
||||||
int selectionBindex() const Q_DECL_OVERRIDE;
|
int selectionBindex() const Q_DECL_OVERRIDE;
|
||||||
void initializeGL() Q_DECL_OVERRIDE;
|
void initializeGL(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
||||||
void setPickedPixel(const QPoint &p) Q_DECL_OVERRIDE {picked_pixel = p;}
|
void setPickedPixel(const QPoint &p) Q_DECL_OVERRIDE {picked_pixel = p;}
|
||||||
void draw(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
void draw(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
||||||
void drawWithNames(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
void drawWithNames(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
||||||
|
|
|
||||||
|
|
@ -957,7 +957,7 @@ void Scene_c3t3_item::drawEdges(CGAL::Three::Viewer_interface* viewer) const {
|
||||||
if(renderingMode() == FlatPlusEdges)
|
if(renderingMode() == FlatPlusEdges)
|
||||||
{
|
{
|
||||||
GLint renderMode;
|
GLint renderMode;
|
||||||
glGetIntegerv(GL_RENDER_MODE, &renderMode);
|
viewer->glGetIntegerv(GL_RENDER_MODE, &renderMode);
|
||||||
if(renderMode == GL_SELECT) return;
|
if(renderMode == GL_SELECT) return;
|
||||||
}
|
}
|
||||||
Scene_c3t3_item* ncthis = const_cast<Scene_c3t3_item*>(this);
|
Scene_c3t3_item* ncthis = const_cast<Scene_c3t3_item*>(this);
|
||||||
|
|
|
||||||
|
|
@ -1267,8 +1267,8 @@ void Scene_polyhedron_item::draw(CGAL::Three::Viewer_interface* viewer) const {
|
||||||
d->program->setUniformValue("is_selected", true);
|
d->program->setUniformValue("is_selected", true);
|
||||||
else
|
else
|
||||||
d->program->setUniformValue("is_selected", false);
|
d->program->setUniformValue("is_selected", false);
|
||||||
glDrawElements(GL_TRIANGLES, static_cast<GLuint>(d->idx_faces.size()),
|
viewer->glDrawElements(GL_TRIANGLES, static_cast<GLuint>(d->idx_faces.size()),
|
||||||
GL_UNSIGNED_INT, d->idx_faces.data());
|
GL_UNSIGNED_INT, d->idx_faces.data());
|
||||||
d->program->release();
|
d->program->release();
|
||||||
vaos[Scene_polyhedron_item_priv::Gouraud_Facets]->release();
|
vaos[Scene_polyhedron_item_priv::Gouraud_Facets]->release();
|
||||||
}
|
}
|
||||||
|
|
@ -1314,8 +1314,8 @@ void Scene_polyhedron_item::draw(CGAL::Three::Viewer_interface* viewer) const {
|
||||||
else
|
else
|
||||||
d->program->setUniformValue("is_selected", false);
|
d->program->setUniformValue("is_selected", false);
|
||||||
|
|
||||||
glDrawElements(GL_TRIANGLES, static_cast<GLuint>(d->idx_faces.size()),
|
viewer->glDrawElements(GL_TRIANGLES, static_cast<GLuint>(d->idx_faces.size()),
|
||||||
GL_UNSIGNED_INT, d->idx_faces.data());
|
GL_UNSIGNED_INT, d->idx_faces.data());
|
||||||
d->program->release();
|
d->program->release();
|
||||||
vaos[Scene_polyhedron_item_priv::Gouraud_Facets]->release();
|
vaos[Scene_polyhedron_item_priv::Gouraud_Facets]->release();
|
||||||
}
|
}
|
||||||
|
|
@ -1345,8 +1345,8 @@ void Scene_polyhedron_item::drawEdges(CGAL::Three::Viewer_interface* viewer) con
|
||||||
d->program->setUniformValue("is_selected", true);
|
d->program->setUniformValue("is_selected", true);
|
||||||
else
|
else
|
||||||
d->program->setUniformValue("is_selected", false);
|
d->program->setUniformValue("is_selected", false);
|
||||||
glDrawElements(GL_LINES, static_cast<GLuint>(d->idx_lines.size()),
|
viewer->glDrawElements(GL_LINES, static_cast<GLuint>(d->idx_lines.size()),
|
||||||
GL_UNSIGNED_INT, d->idx_lines.data());
|
GL_UNSIGNED_INT, d->idx_lines.data());
|
||||||
d->program->release();
|
d->program->release();
|
||||||
vaos[Scene_polyhedron_item_priv::Edges]->release();
|
vaos[Scene_polyhedron_item_priv::Edges]->release();
|
||||||
}
|
}
|
||||||
|
|
@ -1365,8 +1365,8 @@ void Scene_polyhedron_item::drawEdges(CGAL::Three::Viewer_interface* viewer) con
|
||||||
else
|
else
|
||||||
d->program->setAttributeValue("colors",QColor(0,0,0));
|
d->program->setAttributeValue("colors",QColor(0,0,0));
|
||||||
}
|
}
|
||||||
glDrawElements(GL_LINES, static_cast<GLuint>(d->idx_feature_lines.size()),
|
viewer->glDrawElements(GL_LINES, static_cast<GLuint>(d->idx_feature_lines.size()),
|
||||||
GL_UNSIGNED_INT, d->idx_feature_lines.data());
|
GL_UNSIGNED_INT, d->idx_feature_lines.data());
|
||||||
d->program->release();
|
d->program->release();
|
||||||
vaos[Scene_polyhedron_item_priv::Feature_edges]->release();
|
vaos[Scene_polyhedron_item_priv::Feature_edges]->release();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -640,7 +640,7 @@ void Scene_polyhedron_selection_item::draw(CGAL::Three::Viewer_interface* viewer
|
||||||
|
|
||||||
viewer->glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &offset_factor);
|
viewer->glGetFloatv(GL_POLYGON_OFFSET_FACTOR, &offset_factor);
|
||||||
viewer->glGetFloatv(GL_POLYGON_OFFSET_UNITS, &offset_units);
|
viewer->glGetFloatv(GL_POLYGON_OFFSET_UNITS, &offset_units);
|
||||||
glPolygonOffset(0.5f, 0.9f);
|
viewer->glPolygonOffset(0.5f, 0.9f);
|
||||||
vaos[Scene_polyhedron_selection_item_priv::HLFacets]->bind();
|
vaos[Scene_polyhedron_selection_item_priv::HLFacets]->bind();
|
||||||
d->program = getShaderProgram(PROGRAM_WITH_LIGHT);
|
d->program = getShaderProgram(PROGRAM_WITH_LIGHT);
|
||||||
attribBuffers(viewer,PROGRAM_WITH_LIGHT);
|
attribBuffers(viewer,PROGRAM_WITH_LIGHT);
|
||||||
|
|
@ -693,13 +693,13 @@ void Scene_polyhedron_selection_item::draw(CGAL::Three::Viewer_interface* viewer
|
||||||
d->program->release();
|
d->program->release();
|
||||||
vaos[Scene_polyhedron_selection_item_priv::Facets]->release();
|
vaos[Scene_polyhedron_selection_item_priv::Facets]->release();
|
||||||
|
|
||||||
glEnable(GL_POLYGON_OFFSET_LINE);
|
viewer->glEnable(GL_POLYGON_OFFSET_LINE);
|
||||||
viewer->glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
|
viewer->glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
|
||||||
glPolygonOffset(0.0f, 1.5f);
|
viewer->glPolygonOffset(0.0f, 1.5f);
|
||||||
drawEdges(viewer);
|
drawEdges(viewer);
|
||||||
glDisable(GL_POLYGON_OFFSET_LINE);
|
viewer->glDisable(GL_POLYGON_OFFSET_LINE);
|
||||||
viewer->glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
|
viewer->glPolygonMode(GL_FRONT_AND_BACK,GL_POINT);
|
||||||
glPolygonOffset(offset_factor, offset_units);
|
viewer->glPolygonOffset(offset_factor, offset_units);
|
||||||
drawPoints(viewer);
|
drawPoints(viewer);
|
||||||
viewer->glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
|
viewer->glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -654,7 +654,7 @@ void Scene_surface_mesh_item_priv::initializeBuffers(CGAL::Three::Viewer_interfa
|
||||||
|
|
||||||
void Scene_surface_mesh_item::draw(CGAL::Three::Viewer_interface *viewer) const
|
void Scene_surface_mesh_item::draw(CGAL::Three::Viewer_interface *viewer) const
|
||||||
{
|
{
|
||||||
glShadeModel(GL_SMOOTH);
|
viewer->glShadeModel(GL_SMOOTH);
|
||||||
if(!are_buffers_filled)
|
if(!are_buffers_filled)
|
||||||
{
|
{
|
||||||
d->compute_elements();
|
d->compute_elements();
|
||||||
|
|
@ -673,8 +673,8 @@ void Scene_surface_mesh_item::draw(CGAL::Three::Viewer_interface *viewer) const
|
||||||
d->program->setAttributeValue("is_selected", false);
|
d->program->setAttributeValue("is_selected", false);
|
||||||
if(!d->has_vcolors)
|
if(!d->has_vcolors)
|
||||||
d->program->setAttributeValue("colors", this->color());
|
d->program->setAttributeValue("colors", this->color());
|
||||||
glDrawElements(GL_TRIANGLES, static_cast<GLuint>(d->idx_data_.size()),
|
viewer->glDrawElements(GL_TRIANGLES, static_cast<GLuint>(d->idx_data_.size()),
|
||||||
GL_UNSIGNED_INT, d->idx_data_.data());
|
GL_UNSIGNED_INT, d->idx_data_.data());
|
||||||
vaos[Scene_surface_mesh_item_priv::Smooth_facets]->release();
|
vaos[Scene_surface_mesh_item_priv::Smooth_facets]->release();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -686,7 +686,7 @@ void Scene_surface_mesh_item::draw(CGAL::Three::Viewer_interface *viewer) const
|
||||||
d->program->setAttributeValue("is_selected", false);
|
d->program->setAttributeValue("is_selected", false);
|
||||||
if(!d->has_fcolors)
|
if(!d->has_fcolors)
|
||||||
d->program->setAttributeValue("colors", this->color());
|
d->program->setAttributeValue("colors", this->color());
|
||||||
glDrawArrays(GL_TRIANGLES,0,static_cast<GLsizei>(d->nb_flat/3));
|
viewer->glDrawArrays(GL_TRIANGLES,0,static_cast<GLsizei>(d->nb_flat/3));
|
||||||
vaos[Scene_surface_mesh_item_priv::Flat_facets]->release();
|
vaos[Scene_surface_mesh_item_priv::Flat_facets]->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -709,15 +709,15 @@ void Scene_surface_mesh_item::drawEdges(CGAL::Three::Viewer_interface *viewer) c
|
||||||
d->program->setUniformValue("is_selected", true);
|
d->program->setUniformValue("is_selected", true);
|
||||||
else
|
else
|
||||||
d->program->setUniformValue("is_selected", false);
|
d->program->setUniformValue("is_selected", false);
|
||||||
glDrawElements(GL_LINES, static_cast<GLuint>(d->idx_edge_data_.size()),
|
viewer->glDrawElements(GL_LINES, static_cast<GLuint>(d->idx_edge_data_.size()),
|
||||||
GL_UNSIGNED_INT, d->idx_edge_data_.data());
|
GL_UNSIGNED_INT, d->idx_edge_data_.data());
|
||||||
|
|
||||||
if(d->has_feature_edges)
|
if(d->has_feature_edges)
|
||||||
{
|
{
|
||||||
d->program->setAttributeValue("colors", Qt::red);
|
d->program->setAttributeValue("colors", Qt::red);
|
||||||
d->program->setUniformValue("is_selected", false);
|
d->program->setUniformValue("is_selected", false);
|
||||||
glDrawElements(GL_LINES, static_cast<GLuint>(d->idx_feature_edge_data_.size()),
|
viewer->glDrawElements(GL_LINES, static_cast<GLuint>(d->idx_feature_edge_data_.size()),
|
||||||
GL_UNSIGNED_INT, d->idx_feature_edge_data_.data());
|
GL_UNSIGNED_INT, d->idx_feature_edge_data_.data());
|
||||||
}
|
}
|
||||||
vaos[Scene_surface_mesh_item_priv::Edges]->release();
|
vaos[Scene_surface_mesh_item_priv::Edges]->release();
|
||||||
d->program->release();
|
d->program->release();
|
||||||
|
|
@ -739,8 +739,8 @@ void Scene_surface_mesh_item::drawPoints(CGAL::Three::Viewer_interface *viewer)
|
||||||
d->program->setAttributeValue("is_selected", true);
|
d->program->setAttributeValue("is_selected", true);
|
||||||
else
|
else
|
||||||
d->program->setAttributeValue("is_selected", false);
|
d->program->setAttributeValue("is_selected", false);
|
||||||
glDrawElements(GL_POINTS, static_cast<GLuint>(d->idx_edge_data_.size()),
|
viewer->glDrawElements(GL_POINTS, static_cast<GLuint>(d->idx_edge_data_.size()),
|
||||||
GL_UNSIGNED_INT, d->idx_edge_data_.data());
|
GL_UNSIGNED_INT, d->idx_edge_data_.data());
|
||||||
vaos[Scene_surface_mesh_item_priv::Edges]->release();
|
vaos[Scene_surface_mesh_item_priv::Edges]->release();
|
||||||
d->program->release();
|
d->program->release();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ void Scene_textured_polyhedron_item_priv::initializeBuffers(CGAL::Three::Viewer_
|
||||||
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
viewer->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
nb_facets = positions_facets.size();
|
nb_facets = positions_facets.size();
|
||||||
positions_facets.resize(0);
|
positions_facets.resize(0);
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ void Scene_textured_surface_mesh_item_priv::initializeBuffers(CGAL::Three::Viewe
|
||||||
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
viewer->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
viewer->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
item->are_buffers_filled = true;
|
item->are_buffers_filled = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#define CGAL_OPENGL_TOOLS_H
|
#define CGAL_OPENGL_TOOLS_H
|
||||||
|
|
||||||
# include <CGAL/gl.h>
|
# include <CGAL/gl.h>
|
||||||
|
#include <CGAL/Three/Viewer_interface.h>
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
namespace GL {
|
namespace GL {
|
||||||
|
|
@ -46,15 +47,16 @@ public:
|
||||||
|
|
||||||
class Point_size {
|
class Point_size {
|
||||||
GLfloat ps;
|
GLfloat ps;
|
||||||
|
CGAL::Three::Viewer_interface* viewer;
|
||||||
public:
|
public:
|
||||||
Point_size() {
|
Point_size(CGAL::Three::Viewer_interface* viewer) : viewer(viewer) {
|
||||||
::glGetFloatv(GL_POINT_SIZE, &ps);
|
viewer->glGetFloatv(GL_POINT_SIZE, &ps);
|
||||||
}
|
}
|
||||||
~Point_size() {
|
~Point_size() {
|
||||||
set_point_size(ps);
|
set_point_size(ps);
|
||||||
}
|
}
|
||||||
void set_point_size(GLfloat v) {
|
void set_point_size(GLfloat v) {
|
||||||
::glPointSize(v);
|
viewer->glPointSize(v);
|
||||||
}
|
}
|
||||||
}; // end class Point_size
|
}; // end class Point_size
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public:
|
||||||
/*! Is called by Viewer::initializeGL(). Allows all the initialization
|
/*! Is called by Viewer::initializeGL(). Allows all the initialization
|
||||||
* of OpenGL code that needs a context.
|
* of OpenGL code that needs a context.
|
||||||
*/
|
*/
|
||||||
virtual void initializeGL() = 0;
|
virtual void initializeGL(CGAL::Three::Viewer_interface*) = 0;
|
||||||
|
|
||||||
//! \brief Draws the items.
|
//! \brief Draws the items.
|
||||||
//! It is called by Viewer::draw().
|
//! It is called by Viewer::draw().
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue