git-svn-id: svn://db.shs.com.ru/libs@578 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2019-07-19 16:11:11 +00:00
parent 56693c805d
commit 83cf7e041a
4 changed files with 60 additions and 1 deletions

View File

@@ -175,3 +175,46 @@ void GLPrimitiveEllipsoid::init() {
is_init = true;
vbo.rebuffer();
}
void GLPrimitiveAxis::draw(QOpenGLShaderProgram * prog, bool simplest) {
float bs = 1.f;
float as = 0.1f;
float aw = 0.07f;
float cr_x = 0.8f, cg_y = 0.75f, cb_z = 0.8f;
glBegin(GL_LINES);
glColor3f(cr_x, 0, 0);
glVertex3f(-bs, 0, 0);
glVertex3f(bs, 0, 0);
glVertex3f(bs, 0, 0);
glVertex3f(bs-as, aw, 0);
glVertex3f(bs, 0, 0);
glVertex3f(bs-as, -aw, 0);
glVertex3f(bs, 0, 0);
glVertex3f(bs-as, 0, aw);
glVertex3f(bs, 0, 0);
glVertex3f(bs-as, 0, -aw);
glColor3f(0, cg_y, 0);
glVertex3f(0, -bs, 0);
glVertex3f(0, bs, 0);
glVertex3f(0, bs, 0);
glVertex3f(0, bs-as, aw);
glVertex3f(0, bs, 0);
glVertex3f(0, bs-as, -aw);
glVertex3f(0, bs, 0);
glVertex3f(aw, bs-as, 0);
glVertex3f(0, bs, 0);
glVertex3f(-aw, bs-as, 0);
glColor3f(0, 0, cb_z);
glVertex3f(0, 0, -bs);
glVertex3f(0, 0, bs);
glVertex3f(0, 0, bs);
glVertex3f(aw, 0, bs-as);
glVertex3f(0, 0, bs);
glVertex3f(-aw, 0, bs-as);
glVertex3f(0, 0, bs);
glVertex3f(0, aw, bs-as);
glVertex3f(0, 0, bs);
glVertex3f(0, -aw, bs-as);
glEnd();
}

View File

@@ -74,4 +74,12 @@ private:
};
class GLPrimitiveAxis: public GLObjectBase
{
public:
GLPrimitiveAxis() {accept_fog = accept_light = cast_shadow = rec_shadow = select_ = false;}
virtual void draw(QOpenGLShaderProgram * prog, bool simplest = false);
};
#endif // GLPRIMITIVE_CUBE_H

View File

@@ -104,6 +104,11 @@ qreal GLWidget::selectionHaloFillAlpha() const {
}
void GLWidget::addObject(GLObjectBase * o) {
view_->addObject(o);
}
void GLWidget::stop() {
view_->stop();
}
@@ -113,7 +118,7 @@ void GLWidget::start(float freq, GLRendererBase * r) {
if (r == nullptr) r = new RendererSimple(view_);
GLRendererBase * pr = nullptr;
view_->setRenderer(r, &pr);
if (pr != nullptr) delete pr;
if (pr != nullptr && pr != r) delete pr;
view_->start(freq);
}

View File

@@ -6,6 +6,7 @@
class QGLView;
class GLRendererBase;
class GLObjectBase;
class GLWidget : public QWidget
{
@@ -48,6 +49,8 @@ public:
QColor selectionHaloColor() const;
qreal selectionHaloFillAlpha() const;
void addObject(GLObjectBase * o);
public slots:
void stop();
void start(float freq = 60.0, GLRendererBase * r = nullptr);