--- gl_start_orig.cxx Sun Feb 29 18:15:24 2004 +++ gl_start.cxx Sun Feb 29 18:15:30 2004 @@ -38,6 +38,8 @@ #include #if HAVE_GL +#include +#include #include #include #include @@ -46,9 +48,16 @@ extern int fl_clip_state_number; // in fl_rect.cxx -static GLContext context; -static int clip_state_number=-1; -static int pw, ph; +static GLContext *contexts=NULL; +static Fl_Window **windows=NULL; +static int *clip_state_numbers=NULL; +static int *pws=NULL; +static int *phs=NULL; +static int numContexts=0; +static int maxContexts=0; + +static int *clip_state_number=NULL; +static int *pw, *ph; #ifdef WIN32 static Fl_Gl_Choice* gl_choice; @@ -58,34 +67,111 @@ static Fl_Gl_Choice* gl_choice; #endif +static GLContext getContext(Fl_Window *currentWindow) +{ + int i; + + Fl_X *thex = Fl_X::i(Fl_Window::current()); + if(thex->private_dc == 0) + return 0; + + for(i=0;i=maxContexts-1) { + const int granularity=8; + + contexts = (GLContext*)realloc(contexts, (granularity+numContexts+1)*sizeof(GLContext)); + windows = (Fl_Window**)realloc(windows, (granularity+numContexts+1)*sizeof(Fl_Window*)); + pws = (int*)realloc(pws, (granularity+numContexts+1)*sizeof(int)); + phs = (int*)realloc(phs, (granularity+numContexts+1)*sizeof(int)); + clip_state_numbers = (int*)realloc(clip_state_numbers, (granularity+numContexts+1)*sizeof(int)); + maxContexts+=granularity; + } + + // see if the window is already in the list (context becomes invalid when window is hidden) + int i; + for(i=0;iw() || ph != Fl_Window::current()->h()) { - pw = Fl_Window::current()->w(); - ph = Fl_Window::current()->h(); + if (*pw != Fl_Window::current()->w() || *ph != Fl_Window::current()->h()) { + //fprintf(stderr, "dopw "); + *pw = Fl_Window::current()->w(); + *ph = Fl_Window::current()->h(); glLoadIdentity(); - glViewport(0, 0, pw, ph); - glOrtho(0, pw, 0, ph, -1, 1); + glViewport(0, 0, *pw, *ph); + glOrtho(0, *pw, 0, *ph, -1, 1); glDrawBuffer(GL_FRONT); } - if (clip_state_number != fl_clip_state_number) { - clip_state_number = fl_clip_state_number; + if (*clip_state_number != fl_clip_state_number) { + *clip_state_number = fl_clip_state_number; + //fprintf(stderr, "docs "); int x, y, w, h; if (fl_clip_box(0, 0, Fl_Window::current()->w(), Fl_Window::current()->h(), x, y, w, h)) { @@ -96,6 +182,7 @@ glDisable(GL_SCISSOR_TEST); } } + //fprintf(stderr, "\n"); } void gl_finish() {