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

This commit is contained in:
2018-08-24 21:03:45 +00:00
parent 82e6be90a4
commit 08bbed1b21
2 changed files with 28 additions and 17 deletions

View File

@@ -23,23 +23,12 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) {
setFrameShape(QFrame::NoFrame);
setViewportUpdateMode(FullViewportUpdate);
setCacheMode(CacheNone);
__GLWidget__ * _w;
#if QT_VERSION >= 0x050600
_w = new __GLWidget__();
QSurfaceFormat f = _w->format();
f.setSamples(8);
_w->setFormat(f);
#else
QGLFormat f(QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba | QGL::AlphaChannel | QGL::DirectRendering | QGL::SampleBuffers);
f.setSwapInterval(1);
_w = new __GLWidget__(f);
#endif
setViewport(_w);
setMouseTracking(true);
setFocusPolicy(Qt::WheelFocus);
setScene(new QGraphicsScene());
setInteractive(true);
need_init_ = true;
_w = 0;
need_init_ = is_first_draw = true;
objects_.is_root = true;
painter_ = 0;
backColor_ = Qt::black;
@@ -148,14 +137,17 @@ void QGLView::selectObject(GLObjectBase * o) {
void QGLView::drawBackground(QPainter * painter, const QRectF & rect) {
static bool f = true;
if (setupViewport()) {
QGraphicsView::drawBackground(painter_, rect);
return;
}
painter_ = painter;
painter_->beginNativePainting();
if (f) {
if (is_first_draw) {
resizeGL(viewport()->width(), viewport()->height());
initializeGL();
}
f = false;
is_first_draw = false;
paintGL();
painter_->endNativePainting();
glDisableDepth();
@@ -676,3 +668,20 @@ void QGLView::processKeys() {
foreach (int i, keys_)
emit keyEvent((Qt::Key)i, km);
}
bool QGLView::setupViewport() {
if (_w) return false;
#if QT_VERSION >= 0x050600
_w = new __GLWidget__();
QSurfaceFormat f = _w->format();
f.setSamples(8);
_w->setFormat(f);
#else
QGLFormat f(QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba | QGL::AlphaChannel | QGL::DirectRendering | QGL::SampleBuffers);
f.setSwapInterval(1);
_w = new __GLWidget__(f);
#endif
setViewport(_w);
return true;
}

View File

@@ -239,6 +239,7 @@ private:
void collectGraphicItems(QList<QGraphicsItem * > & list, QGraphicsItem * o);
void reloadThisShaders();
void processKeys();
bool setupViewport();
QPoint lastPos, downPos;
QMutex v_mutex;
@@ -266,10 +267,11 @@ private:
Qt::KeyboardModifier sel_mod;
GLRendererBase::RenderingParameters start_rp;
QHash<int, QVariant> features_;
__GLWidget__ * _w;
double lineWidth_;
double fogDensity_, fogStart_, fogEnd_, fps_, fps_tm, hoverHaloFill_, selectionHaloFill_, m_motionBlurFactor;
int timer, fps_cnt, sh_id_loc;
bool is_init, fogEnabled_, lightEnabled_, grabMouse_, mouse_first, mouseRotate_, mouseSelect_, customMouseMove_;
bool is_first_draw, is_init, fogEnabled_, lightEnabled_, grabMouse_, mouse_first, mouseRotate_, mouseSelect_, customMouseMove_;
bool shaders_supported, changed_, cameraOrbit_, need_init_;
bool hoverHalo_, selectionHalo_, mouseThis_, shaders_bind, selecting_;