git-svn-id: svn://db.shs.com.ru/libs@417 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -23,23 +23,12 @@ QGLView::QGLView(QWidget * parent): QGraphicsView(parent), fbo_selection(3) {
|
|||||||
setFrameShape(QFrame::NoFrame);
|
setFrameShape(QFrame::NoFrame);
|
||||||
setViewportUpdateMode(FullViewportUpdate);
|
setViewportUpdateMode(FullViewportUpdate);
|
||||||
setCacheMode(CacheNone);
|
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);
|
setMouseTracking(true);
|
||||||
setFocusPolicy(Qt::WheelFocus);
|
setFocusPolicy(Qt::WheelFocus);
|
||||||
setScene(new QGraphicsScene());
|
setScene(new QGraphicsScene());
|
||||||
setInteractive(true);
|
setInteractive(true);
|
||||||
need_init_ = true;
|
_w = 0;
|
||||||
|
need_init_ = is_first_draw = true;
|
||||||
objects_.is_root = true;
|
objects_.is_root = true;
|
||||||
painter_ = 0;
|
painter_ = 0;
|
||||||
backColor_ = Qt::black;
|
backColor_ = Qt::black;
|
||||||
@@ -148,14 +137,17 @@ void QGLView::selectObject(GLObjectBase * o) {
|
|||||||
|
|
||||||
|
|
||||||
void QGLView::drawBackground(QPainter * painter, const QRectF & rect) {
|
void QGLView::drawBackground(QPainter * painter, const QRectF & rect) {
|
||||||
static bool f = true;
|
if (setupViewport()) {
|
||||||
|
QGraphicsView::drawBackground(painter_, rect);
|
||||||
|
return;
|
||||||
|
}
|
||||||
painter_ = painter;
|
painter_ = painter;
|
||||||
painter_->beginNativePainting();
|
painter_->beginNativePainting();
|
||||||
if (f) {
|
if (is_first_draw) {
|
||||||
resizeGL(viewport()->width(), viewport()->height());
|
resizeGL(viewport()->width(), viewport()->height());
|
||||||
initializeGL();
|
initializeGL();
|
||||||
}
|
}
|
||||||
f = false;
|
is_first_draw = false;
|
||||||
paintGL();
|
paintGL();
|
||||||
painter_->endNativePainting();
|
painter_->endNativePainting();
|
||||||
glDisableDepth();
|
glDisableDepth();
|
||||||
@@ -676,3 +668,20 @@ void QGLView::processKeys() {
|
|||||||
foreach (int i, keys_)
|
foreach (int i, keys_)
|
||||||
emit keyEvent((Qt::Key)i, km);
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ private:
|
|||||||
void collectGraphicItems(QList<QGraphicsItem * > & list, QGraphicsItem * o);
|
void collectGraphicItems(QList<QGraphicsItem * > & list, QGraphicsItem * o);
|
||||||
void reloadThisShaders();
|
void reloadThisShaders();
|
||||||
void processKeys();
|
void processKeys();
|
||||||
|
bool setupViewport();
|
||||||
|
|
||||||
QPoint lastPos, downPos;
|
QPoint lastPos, downPos;
|
||||||
QMutex v_mutex;
|
QMutex v_mutex;
|
||||||
@@ -266,10 +267,11 @@ private:
|
|||||||
Qt::KeyboardModifier sel_mod;
|
Qt::KeyboardModifier sel_mod;
|
||||||
GLRendererBase::RenderingParameters start_rp;
|
GLRendererBase::RenderingParameters start_rp;
|
||||||
QHash<int, QVariant> features_;
|
QHash<int, QVariant> features_;
|
||||||
|
__GLWidget__ * _w;
|
||||||
double lineWidth_;
|
double lineWidth_;
|
||||||
double fogDensity_, fogStart_, fogEnd_, fps_, fps_tm, hoverHaloFill_, selectionHaloFill_, m_motionBlurFactor;
|
double fogDensity_, fogStart_, fogEnd_, fps_, fps_tm, hoverHaloFill_, selectionHaloFill_, m_motionBlurFactor;
|
||||||
int timer, fps_cnt, sh_id_loc;
|
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 shaders_supported, changed_, cameraOrbit_, need_init_;
|
||||||
bool hoverHalo_, selectionHalo_, mouseThis_, shaders_bind, selecting_;
|
bool hoverHalo_, selectionHalo_, mouseThis_, shaders_bind, selecting_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user