[SOLVED]Same Texture Different QGLContext/QGLWidget
I'm currently working for my final Assessment
so here the situation
I build three difference QGLWidget Class which has different function and purpose
Let say I have
GLWidgetLayer, GLWidgetImage, GLWidgetPreview
each QGLWidget class render different object and geometry
when I want to load Texture using bindTexture in GLWidgetLayer object and save TextureID in global variable
how can I use the same texture in object GLWidgetImage / GLWidgetPreview
without call bindTexture again?
so I don't waste texture that already loaded in GLWidgetLayer
I 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 problem
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)
@ 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 firstGLWidget
Thank you very much.