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);
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user