[SOLVED]Same Texture Different QGLContext/QGLWidget
-
hi
I'm currently working for my final Assessmentso here the situation
I build three difference QGLWidget Class which has different function and purpose
Let say I have
GLWidgetLayer, GLWidgetImage, GLWidgetPrevieweach QGLWidget class render different object and geometry
when I want to load Texture using bindTexture in GLWidgetLayer object and save TextureID in global variablehow can I use the same texture in object GLWidgetImage / GLWidgetPreview
without call bindTexture again?
so I don't waste texture that already loaded in GLWidgetLayerI have read about share context between QGLContext using chooseContext and QGLWidget Contructor
but I don't understand, how to use it, and can it solve my problemThanks,
Sapidol2002 -
MAybe what you are trying to do is something like this.
The QGLWidget constructor:
@QGLWidget ( QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 )@It includes a call to a sharing context widget. The only thing you need to do is to make your GL instance with a constructor similar to this one, like:
@GLClass::GLClass(QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0)
: QGLWidget(parent, shareGLWidget)
{}@
Finally:
@ secondGLWidget= new SideWidget(this); //some QGLWidget instance...
firstGLWidget = new GLClass(this, secondGLWidget); //QGLWidget that shares context w/ anotherQGLWidget@ -
yes it's work!
now I can loadTexture from secondGLWidget
and then use it in firstGLWidgetThank you very much.