mirror of https://github.com/CGAL/cgal
workaround for multiple linking under windows.
This commit is contained in:
parent
ab3ad395fc
commit
c3fab3df15
|
|
@ -1217,6 +1217,7 @@ protected:
|
||||||
//C o n t e x t
|
//C o n t e x t
|
||||||
bool is_ogl_4_3;
|
bool is_ogl_4_3;
|
||||||
bool is_sharing;
|
bool is_sharing;
|
||||||
|
bool is_linked;
|
||||||
QOpenGLContext* shared_context;
|
QOpenGLContext* shared_context;
|
||||||
public:
|
public:
|
||||||
//! Is used to know if the openGL context is 4.3 or ES 2.0.
|
//! Is used to know if the openGL context is 4.3 or ES 2.0.
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,7 @@ void CGAL::QGLViewer::defaultConstructor() {
|
||||||
_offset = CGAL::qglviewer::Vec(0,0,0);
|
_offset = CGAL::qglviewer::Vec(0,0,0);
|
||||||
stored_fbo = NULL;
|
stored_fbo = NULL;
|
||||||
is_sharing = false;
|
is_sharing = false;
|
||||||
|
is_linked = false;
|
||||||
shared_context = nullptr;
|
shared_context = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -275,7 +276,7 @@ void CGAL::QGLViewer::initializeGL() {
|
||||||
{
|
{
|
||||||
vbos[i].create();
|
vbos[i].create();
|
||||||
}
|
}
|
||||||
//program without light
|
if(!is_linked)
|
||||||
{
|
{
|
||||||
//Vertex source code
|
//Vertex source code
|
||||||
const char v_s[] =
|
const char v_s[] =
|
||||||
|
|
@ -361,9 +362,6 @@ void CGAL::QGLViewer::initializeGL() {
|
||||||
{
|
{
|
||||||
qDebug() << rendering_program.log();
|
qDebug() << rendering_program.log();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//program with light
|
|
||||||
{
|
|
||||||
//Vertex source code
|
//Vertex source code
|
||||||
const char vertex_source[] =
|
const char vertex_source[] =
|
||||||
{
|
{
|
||||||
|
|
@ -476,8 +474,6 @@ void CGAL::QGLViewer::initializeGL() {
|
||||||
//It is said in the doc that a QOpenGLShader is
|
//It is said in the doc that a QOpenGLShader is
|
||||||
// only destroyed with the QOpenGLShaderProgram
|
// only destroyed with the QOpenGLShaderProgram
|
||||||
//it has been linked with.
|
//it has been linked with.
|
||||||
QOpenGLShader vertex_shader(QOpenGLShader::Vertex);
|
|
||||||
QOpenGLShader fragment_shader(QOpenGLShader::Fragment);
|
|
||||||
if(is_ogl_4_3)
|
if(is_ogl_4_3)
|
||||||
{
|
{
|
||||||
if(!vertex_shader.compileSourceCode(vertex_source))
|
if(!vertex_shader.compileSourceCode(vertex_source))
|
||||||
|
|
@ -516,7 +512,7 @@ void CGAL::QGLViewer::initializeGL() {
|
||||||
qDebug() << rendering_program_light.log();
|
qDebug() << rendering_program_light.log();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
is_linked = true;
|
||||||
// Give time to glInit to finish and then call setFullScreen().
|
// Give time to glInit to finish and then call setFullScreen().
|
||||||
if (isFullScreen())
|
if (isFullScreen())
|
||||||
QTimer::singleShot(100, this, SLOT(delayedFullScreen()));
|
QTimer::singleShot(100, this, SLOT(delayedFullScreen()));
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,6 @@ public:
|
||||||
//! Decides if the distance between APoint and BPoint must be drawn;
|
//! Decides if the distance between APoint and BPoint must be drawn;
|
||||||
bool distance_is_displayed;
|
bool distance_is_displayed;
|
||||||
bool i_is_pressed;
|
bool i_is_pressed;
|
||||||
bool initialized;
|
|
||||||
bool z_is_pressed;
|
bool z_is_pressed;
|
||||||
QImage static_image;
|
QImage static_image;
|
||||||
//!Draws the distance between two selected points.
|
//!Draws the distance between two selected points.
|
||||||
|
|
@ -249,7 +248,6 @@ void Viewer::doBindings()
|
||||||
d->spec_power = viewer_settings.value("spec_power", 51.8).toFloat();
|
d->spec_power = viewer_settings.value("spec_power", 51.8).toFloat();
|
||||||
d->scene = 0;
|
d->scene = 0;
|
||||||
d->projection_is_ortho = false;
|
d->projection_is_ortho = false;
|
||||||
d->initialized = false;
|
|
||||||
d->twosides = false;
|
d->twosides = false;
|
||||||
this->setProperty("draw_two_sides", false);
|
this->setProperty("draw_two_sides", false);
|
||||||
d->macro_mode = false;
|
d->macro_mode = false;
|
||||||
|
|
@ -460,91 +458,91 @@ void Viewer::init()
|
||||||
d->buffer.create();
|
d->buffer.create();
|
||||||
|
|
||||||
//setting the program used for the distance
|
//setting the program used for the distance
|
||||||
{
|
if(!is_linked)
|
||||||
//Vertex source code
|
{
|
||||||
const char vertex_source_dist[] =
|
//Vertex source code
|
||||||
{
|
const char vertex_source_dist[] =
|
||||||
"#version 150 \n"
|
{
|
||||||
"in vec4 vertex;\n"
|
"#version 150 \n"
|
||||||
"uniform mat4 mvp_matrix;\n"
|
"in vec4 vertex;\n"
|
||||||
"uniform float point_size;\n"
|
"uniform mat4 mvp_matrix;\n"
|
||||||
"void main(void)\n"
|
"uniform float point_size;\n"
|
||||||
"{\n"
|
"void main(void)\n"
|
||||||
" gl_PointSize = point_size; \n"
|
"{\n"
|
||||||
" gl_Position = mvp_matrix * vertex; \n"
|
" gl_PointSize = point_size; \n"
|
||||||
"} \n"
|
" gl_Position = mvp_matrix * vertex; \n"
|
||||||
"\n"
|
"} \n"
|
||||||
};
|
"\n"
|
||||||
const char vertex_source_comp_dist[] =
|
};
|
||||||
{
|
const char vertex_source_comp_dist[] =
|
||||||
"attribute highp vec4 vertex;\n"
|
{
|
||||||
"uniform highp mat4 mvp_matrix;\n"
|
"attribute highp vec4 vertex;\n"
|
||||||
"uniform highp float point_size;\n"
|
"uniform highp mat4 mvp_matrix;\n"
|
||||||
"void main(void)\n"
|
"uniform highp float point_size;\n"
|
||||||
"{\n"
|
"void main(void)\n"
|
||||||
" gl_PointSize = point_size; \n"
|
"{\n"
|
||||||
" gl_Position = mvp_matrix * vertex; \n"
|
" gl_PointSize = point_size; \n"
|
||||||
"} \n"
|
" gl_Position = mvp_matrix * vertex; \n"
|
||||||
"\n"
|
"} \n"
|
||||||
};
|
"\n"
|
||||||
//Fragment source code
|
};
|
||||||
const char fragment_source_dist[] =
|
//Fragment source code
|
||||||
{
|
const char fragment_source_dist[] =
|
||||||
"#version 150 \n"
|
{
|
||||||
"out vec4 out_color; \n"
|
"#version 150 \n"
|
||||||
"void main(void) { \n"
|
"out vec4 out_color; \n"
|
||||||
"out_color = vec4(0.0,0.0,0.0,1.0); \n"
|
"void main(void) { \n"
|
||||||
"} \n"
|
"out_color = vec4(0.0,0.0,0.0,1.0); \n"
|
||||||
"\n"
|
"} \n"
|
||||||
};
|
"\n"
|
||||||
const char fragment_source_comp_dist[] =
|
};
|
||||||
{
|
const char fragment_source_comp_dist[] =
|
||||||
"void main(void) { \n"
|
{
|
||||||
"gl_FragColor = vec4(0.0,0.0,0.0,1.0); \n"
|
"void main(void) { \n"
|
||||||
"} \n"
|
"gl_FragColor = vec4(0.0,0.0,0.0,1.0); \n"
|
||||||
"\n"
|
"} \n"
|
||||||
};
|
"\n"
|
||||||
QOpenGLShader vertex_shader(QOpenGLShader::Vertex);
|
};
|
||||||
QOpenGLShader fragment_shader(QOpenGLShader::Fragment);
|
QOpenGLShader vertex_shader(QOpenGLShader::Vertex);
|
||||||
if(isOpenGL_4_3())
|
QOpenGLShader fragment_shader(QOpenGLShader::Fragment);
|
||||||
{
|
if(isOpenGL_4_3())
|
||||||
if(!vertex_shader.compileSourceCode(vertex_source_dist))
|
{
|
||||||
{
|
if(!vertex_shader.compileSourceCode(vertex_source_dist))
|
||||||
std::cerr<<"Compiling vertex source FAILED"<<std::endl;
|
{
|
||||||
}
|
std::cerr<<"Compiling vertex source FAILED"<<std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
if(!fragment_shader.compileSourceCode(fragment_source_dist))
|
if(!fragment_shader.compileSourceCode(fragment_source_dist))
|
||||||
{
|
{
|
||||||
std::cerr<<"Compiling fragmentsource FAILED"<<std::endl;
|
std::cerr<<"Compiling fragmentsource FAILED"<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!vertex_shader.compileSourceCode(vertex_source_comp_dist))
|
if(!vertex_shader.compileSourceCode(vertex_source_comp_dist))
|
||||||
{
|
{
|
||||||
std::cerr<<"Compiling vertex source FAILED"<<std::endl;
|
std::cerr<<"Compiling vertex source FAILED"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!fragment_shader.compileSourceCode(fragment_source_comp_dist))
|
if(!fragment_shader.compileSourceCode(fragment_source_comp_dist))
|
||||||
{
|
{
|
||||||
std::cerr<<"Compiling fragmentsource FAILED"<<std::endl;
|
std::cerr<<"Compiling fragmentsource FAILED"<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!d->rendering_program_dist.addShader(&vertex_shader))
|
if(!d->rendering_program_dist.addShader(&vertex_shader))
|
||||||
{
|
{
|
||||||
std::cerr<<"adding vertex shader FAILED"<<std::endl;
|
std::cerr<<"adding vertex shader FAILED"<<std::endl;
|
||||||
}
|
}
|
||||||
if(!d->rendering_program_dist.addShader(&fragment_shader))
|
if(!d->rendering_program_dist.addShader(&fragment_shader))
|
||||||
{
|
{
|
||||||
std::cerr<<"adding fragment shader FAILED"<<std::endl;
|
std::cerr<<"adding fragment shader FAILED"<<std::endl;
|
||||||
}
|
}
|
||||||
if(!d->rendering_program_dist.link())
|
if(!d->rendering_program_dist.link())
|
||||||
{
|
{
|
||||||
qDebug() << d->rendering_program_dist.log();
|
qDebug() << d->rendering_program_dist.log();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d->painter = new QPainter();
|
d->painter = new QPainter();
|
||||||
d->initialized = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
|
@ -1332,8 +1330,6 @@ QPainter* Viewer::getPainter(){return d->painter;}
|
||||||
|
|
||||||
void Viewer::paintEvent(QPaintEvent *)
|
void Viewer::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
if(!d->initialized)
|
|
||||||
initializeGL();
|
|
||||||
paintGL();
|
paintGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue