I'm working on a program that consists of several Fl_Gl_Windows. Each window
has a lot of data, and in order to be able to handle it, I group the data in
several groups and put these in display list entries. My question: how can I
make sure that the right groups are drawn into the right window? How can I set
the right context? It happens every now and then that the contexts get mixed
together.
My program looks something like this (I'm sorry, posting a full compilable
source would be a huge project and would still not make sure that my problem is
reproducable; I'm only hoping for some hints):
int main(/*...*/){
std::vector<MyWin*> MyWinController;
MyWinController.resize(10);
/*
initialise these windows
*/
for(size_t i=0;i<10;i++){
MyWinController[i]->generate(0);
MyWinController[i]->redraw();
}
/*
...
*/
}
class MyWin : public Fl_Gl_Window {
/*
......
*/
GLint DL[100]; //array holding display list indices
};
void MyWin::generate(int startIndex){
/*this is my attempt to make sure I'm working on the
current window; is this the right way?*/
make_current();
int ListPos;
//delete information at the current position
if(glIsList(DL[0]))
glDeleteLists(DL[0],20);
GLuint base;
base = glGenLists(20);
glListBase(base);
ListPos = startIndex+ 0;
DL[ListPos]=base+0;
glNewList(DL[ListPos], GL_COMPILE);
draw_function_A();
glEndList();
ListPos = startIndex+ 1;
DL[ListPos]=base+0;
glNewList(DL[ListPos], GL_COMPILE);
draw_function_B();
glEndList();
/*
...
*/
}
void MyWin::draw_model(int startIndex){
make_current();
if(flag1){
glPushMatrix();
glCallList (DL[startIndex+0]); // blade
glPopMatrix();
}
if(flag2){
glPushMatrix();
glCallList (DL[startIndex+1]); // blade
glPopMatrix();
}
/*
...
*/
}
void MyWin::draw()
{
if (!valid()) {
//...
}
glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslated(xshift, yshift, 0);
glScaled(size, size, size);
glRotated(hAng, 0, 1, 0);
glRotated(vAng, 1, 0, 0);
glRotated(zAng, 0, 0, 1);
glColor3f(1.0, 0.0, 0.0);
draw_model(startIndex);
glPopMatrix();
}
Thanks a lot for any hints!
_______________________________________________
fltk-opengl mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-opengl