Greg Ercolano wrote:
> Livia Koch wrote:
>
> I moved the glViewPort() call to the !valid() section, and
> that solved the 'unexpected art' problem.
>
> But I notice if I uncomment your call to generate_model(),
> this causes these errors in my linux console:
>
> XRequest.143: GLXBadContextState 0x1200006
> XRequest.143: GLXBadContextState 0x1200006
>
> So it seems there's something wrong with how the lists are
> being created.
>
> One thing that came to mind just looking at the code is the use
> of std::string in the draw_[xy]_axis() functions.
>
> The way you're using it, you're calling the function with static
> strings,
> and those get converted to std::strings during the call, which go out of
> scope the minute the draw_[xy]_axis() functions return.
>
> That should be fine for non-display list contexts where the string
> is drawn immediately.
>
> But in the context of a display list, that's probably bad, since your
> call to gl_draw() gets delayed until later, when the glCallList() is
> called,
> and by that time your c_str() call will have resolved to a pointer in
> memory
> that long since went out of scope when the glCallList() is actually
> called.
> So that /may/ a problem there.
>
> But that's not /the/ problem; I ripped out all your std::string stuff
> so that static strings were being passed around, and I'm still getting
> the "bad context state" errors from the generate_model() call..
>
Well I did not get any GLXBadContextState messages on my linux console,
but regarding the original problem, I have found that when using display
lists, if the gl_font related display lists are created -before-
creating the x_axis and y_axis display lists then the fonts are
displayed correctly.
So it seems the problem is that the gl_font display lists cannot be
defined as nested display lists. So I found a solution was to change
the generate_model function as follows:
void generate_model(){
gl_font(FL_SYMBOL,14); //ADDED
gl_font(FL_HELVETICA,14); //ADDED
glDeleteLists(DisplayList[0],1); // clear
DisplayList[0] = glGenLists(1);
glNewList(DisplayList[0], GL_COMPILE);
//x-axis
draw_x_axis(20,w()-40,"length","english");
glEndList();
glDeleteLists(DisplayList[1],1); // clear
DisplayList[1] = glGenLists(1);
glNewList(DisplayList[1], GL_COMPILE);
//y-axis
glNewList(DisplayList[1]+1, GL_COMPILE);//REMOVED (this call
seems to
have no purpose)
draw_y_axis(20,h()-40,"r/R","greek");
glEndList();
}
I am not sure yet why the gl_font display lists cannot be defined as
nested lists? I wonder if anyone knows already.
_______________________________________________
fltk-opengl mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-opengl