View Full Version : How to share texture object with mutil qglwidget
feiz
28th April 2015, 11:29
Hello,
I am developing a application,i need some qglwidgets share a volume 3d texture.I know
QGLWidget::QGLWidget(QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0)
can share texture between two qglwidget(Qglwidget share with shareWidget).Is
tere a way to share texture with multi qglwidget?
Thanks,
pixaeiro
29th April 2015, 14:36
Yes, in OpenGL you can share textures between displays that have the same context.
So, you can create a new gl context, and then create your two widgets with that context:
QGLContext(const QGLFormat & format);
QGLWidget(QGLContext * context, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0)
https://www.opengl.org/discussion_boards/showthread.php/137365-can-two-opengl-context-share-a-texture
yes,I know use QGLContext maybe solve my problem.But I don't understand QGlContext.Is there a example to use QGLContext ?Thanks
Yes, in OpenGL you can share textures between displays that have the same context.
So, you can create a new gl context, and then create your two widgets with that context:
QGLContext(const QGLFormat & format);
QGLWidget(QGLContext * context, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0)
https://www.opengl.org/discussion_boards/showthread.php/137365-can-two-opengl-context-share-a-texture
I have a try like this
cx_ = new QGLContext(QGLFormat::defaultFormat());
cx_->create();
slicerX_ = new slicerCanvas(cx_,this);
cx_ = slicerX_->context();
secWid_ = new secCan(cx_,this,slicerX_);
thrWid_ = new triCan(cx_,this,slicerX_);
but it don't render correct.I saw a question in
http://stackoverflow.com/questions/20955669/how-to-share-opengl-context-or-data?rq=1 ,
any one can give me some advice? thanks
,
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.