mirror of https://github.com/vitalif/openscad
create GLView as parent of OffscreenView and QGLView. combine setRenderer()
parent
4f578513a0
commit
5389107aa6
|
@ -180,6 +180,7 @@ HEADERS += src/version_check.h \
|
|||
src/CGAL_renderer.h \
|
||||
src/OGL_helper.h \
|
||||
src/QGLView.h \
|
||||
src/GLView.h \
|
||||
src/MainWindow.h \
|
||||
src/Preferences.h \
|
||||
src/OpenCSGWarningDialog.h \
|
||||
|
@ -285,6 +286,7 @@ SOURCES += src/version_check.cc \
|
|||
src/OpenCSGWarningDialog.cc \
|
||||
src/editor.cc \
|
||||
src/qglview.cc \
|
||||
src/GLView.cc \
|
||||
\
|
||||
src/builtin.cc \
|
||||
src/export.cc \
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
class CsgInfo
|
||||
{
|
||||
public:
|
||||
CsgInfo() { qglview = NULL; }
|
||||
OffscreenView *qglview;
|
||||
CsgInfo() { glview = NULL; }
|
||||
OffscreenView *glview;
|
||||
};
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ public:
|
|||
root_chain = NULL;
|
||||
highlights_chain = NULL;
|
||||
background_chain = NULL;
|
||||
qglview = NULL;
|
||||
glview = NULL;
|
||||
}
|
||||
shared_ptr<CSGTerm> root_norm_term; // Normalized CSG products
|
||||
class CSGChain *root_chain;
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#include "GLView.h"
|
||||
|
||||
void GLView::setRenderer(class Renderer* r)
|
||||
{
|
||||
this->renderer = r;
|
||||
}
|
||||
|
||||
/*
|
||||
void initializeGL(); //
|
||||
void resizeGL(int w, int h); //
|
||||
|
||||
void setGimbalCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d &rot, double distance); //
|
||||
void setupGimbalPerspective(); //
|
||||
void setupGimbalOrtho(double distance, bool offset=false); //
|
||||
|
||||
void setCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d ¢er); //
|
||||
void setupPerspective(); //
|
||||
void setupOrtho(bool offset=false); //
|
||||
|
||||
void paintGL(); //
|
||||
bool save(const char *filename); //
|
||||
//bool save(std::ostream &output); // not implemented in qgl?
|
||||
std::string getRendererInfo(); //
|
||||
|
||||
GLint shaderinfo[11]; //
|
||||
|
||||
private:
|
||||
Renderer *renderer;//
|
||||
double w_h_ratio;//
|
||||
|
||||
bool orthomode;//
|
||||
bool showaxes;//
|
||||
bool showfaces;//
|
||||
bool showedges;//
|
||||
|
||||
Eigen::Vector3d object_rot;//
|
||||
Eigen::Vector3d camera_eye;//
|
||||
Eigen::Vector3d camera_center;//
|
||||
};
|
||||
|
||||
*/
|
|
@ -0,0 +1,54 @@
|
|||
#ifndef GLVIEW_H_
|
||||
#define GLVIEW_H_
|
||||
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Geometry>
|
||||
#include <string>
|
||||
#ifndef _MSC_VER
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include "system-gl.h"
|
||||
#include <iostream>
|
||||
#include "renderer.h"
|
||||
|
||||
class GLView
|
||||
{
|
||||
public:
|
||||
void setRenderer(Renderer* r);
|
||||
Renderer *renderer = 0;
|
||||
/*
|
||||
void initializeGL(); //
|
||||
void resizeGL(int w, int h); //
|
||||
|
||||
void setGimbalCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d &rot, double distance); //
|
||||
void setupGimbalPerspective(); //
|
||||
void setupGimbalOrtho(double distance, bool offset=false); //
|
||||
|
||||
void setCamera(const Eigen::Vector3d &pos, const Eigen::Vector3d ¢er); //
|
||||
void setupPerspective(); //
|
||||
void setupOrtho(bool offset=false); //
|
||||
|
||||
void paintGL(); //
|
||||
bool save(const char *filename); //
|
||||
//bool save(std::ostream &output); // not implemented in qgl?
|
||||
std::string getRendererInfo(); //
|
||||
|
||||
GLint shaderinfo[11]; //
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/* double w_h_ratio;//
|
||||
|
||||
bool orthomode;//
|
||||
bool showaxes;//
|
||||
bool showfaces;//
|
||||
bool showedges;//
|
||||
|
||||
Eigen::Vector3d object_rot;//
|
||||
Eigen::Vector3d camera_eye;//
|
||||
Eigen::Vector3d camera_center;//
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,7 +1,6 @@
|
|||
#include <GL/glew.h>
|
||||
#include "OffscreenView.h"
|
||||
#include "system-gl.h"
|
||||
#include "renderer.h"
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -27,11 +26,6 @@ OffscreenView::~OffscreenView()
|
|||
teardown_offscreen_context(this->ctx);
|
||||
}
|
||||
|
||||
void OffscreenView::setRenderer(Renderer* r)
|
||||
{
|
||||
this->renderer = r;
|
||||
}
|
||||
|
||||
void OffscreenView::initializeGL()
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
|
|
@ -10,13 +10,13 @@
|
|||
#endif
|
||||
#include "system-gl.h"
|
||||
#include <iostream>
|
||||
#include "GLView.h"
|
||||
|
||||
class OffscreenView
|
||||
class OffscreenView : public GLView
|
||||
{
|
||||
public:
|
||||
OffscreenView(size_t width, size_t height); // not
|
||||
~OffscreenView(); // not
|
||||
void setRenderer(class Renderer* r); //
|
||||
|
||||
void initializeGL(); //
|
||||
void resizeGL(int w, int h); //
|
||||
|
@ -40,9 +40,7 @@ public:
|
|||
size_t width; // not
|
||||
size_t height; // not
|
||||
private:
|
||||
Renderer *renderer;//
|
||||
double w_h_ratio;//
|
||||
|
||||
bool orthomode;//
|
||||
bool showaxes;//
|
||||
bool showfaces;//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef GLVIEW_H_
|
||||
#define GLVIEW_H_
|
||||
#ifndef QGLVIEW_H_
|
||||
#define QGLVIEW_H_
|
||||
|
||||
#include "system-gl.h"
|
||||
#include <QGLWidget>
|
||||
|
@ -7,8 +7,10 @@
|
|||
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Geometry>
|
||||
#include "GLView.h"
|
||||
#include "renderer.h"
|
||||
|
||||
class QGLView : public QGLWidget
|
||||
class QGLView : public QGLWidget, public GLView
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool showFaces READ showFaces WRITE setShowFaces);
|
||||
|
@ -20,7 +22,6 @@ class QGLView : public QGLWidget
|
|||
public:
|
||||
QGLView(QWidget *parent = NULL);
|
||||
QGLView(const QGLFormat & format, QWidget *parent = NULL);
|
||||
void setRenderer(class Renderer* r);
|
||||
#ifdef ENABLE_OPENCSG
|
||||
bool hasOpenCSGSupport() { return this->opencsg_support; }
|
||||
#endif
|
||||
|
@ -55,7 +56,6 @@ public:
|
|||
|
||||
private:
|
||||
void init();
|
||||
Renderer *renderer;
|
||||
|
||||
std::string rendererInfo;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, std::ostream &output)
|
|||
{
|
||||
CsgInfo csgInfo;
|
||||
try {
|
||||
csgInfo.qglview = new OffscreenView(512,512);
|
||||
csgInfo.glview = new OffscreenView(512,512);
|
||||
} catch (int error) {
|
||||
fprintf(stderr,"Can't create OpenGL OffscreenView. Code: %i.\n", error);
|
||||
return;
|
||||
|
@ -40,10 +40,10 @@ void export_png_with_cgal(CGAL_Nef_polyhedron *root_N, std::ostream &output)
|
|||
//std::cerr << center << "\n";
|
||||
//std::cerr << radius << "\n";
|
||||
|
||||
csgInfo.qglview->setCamera(camerapos, center);
|
||||
csgInfo.qglview->setRenderer(&cgalRenderer);
|
||||
csgInfo.qglview->paintGL();
|
||||
csgInfo.qglview->save(output);
|
||||
csgInfo.glview->setCamera(camerapos, center);
|
||||
csgInfo.glview->setRenderer(&cgalRenderer);
|
||||
csgInfo.glview->paintGL();
|
||||
csgInfo.glview->save(output);
|
||||
}
|
||||
|
||||
void export_png_with_opencsg(CGAL_Nef_polyhedron *root_N, std::ostream &output)
|
||||
|
|
|
@ -1498,6 +1498,7 @@ void MainWindow::viewModeOpenCSG()
|
|||
viewModeActionsUncheck();
|
||||
viewActionOpenCSG->setChecked(true);
|
||||
this->qglview->setRenderer(this->opencsgRenderer ? (Renderer *)this->opencsgRenderer : (Renderer *)this->thrownTogetherRenderer);
|
||||
this->qglview->updateGL();
|
||||
} else {
|
||||
viewModeThrownTogether();
|
||||
}
|
||||
|
@ -1522,6 +1523,7 @@ void MainWindow::viewModeCGALGrid()
|
|||
viewActionCGALGrid->setChecked(true);
|
||||
this->qglview->setShowFaces(false);
|
||||
this->qglview->setRenderer(this->cgalRenderer);
|
||||
this->qglview->updateGL();
|
||||
}
|
||||
|
||||
#endif /* ENABLE_CGAL */
|
||||
|
@ -1531,6 +1533,7 @@ void MainWindow::viewModeThrownTogether()
|
|||
viewModeActionsUncheck();
|
||||
viewActionThrownTogether->setChecked(true);
|
||||
this->qglview->setRenderer(this->thrownTogetherRenderer);
|
||||
this->qglview->updateGL();
|
||||
}
|
||||
|
||||
void MainWindow::viewModeShowEdges()
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
#define FAR_FAR_AWAY 100000.0
|
||||
|
||||
QGLView::QGLView(QWidget *parent) : QGLWidget(parent), renderer(NULL)
|
||||
QGLView::QGLView(QWidget *parent) : QGLWidget(parent)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -113,12 +113,6 @@ void QGLView::init()
|
|||
#endif
|
||||
}
|
||||
|
||||
void QGLView::setRenderer(Renderer *r)
|
||||
{
|
||||
this->renderer = r;
|
||||
if (r) updateGL(); // Let the last image stay, e.g. to avoid animation flickering
|
||||
}
|
||||
|
||||
void QGLView::initializeGL()
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
|
Loading…
Reference in New Issue