Re: Colormaps, etc. (fwd)

Mark Lee (mlee@heartlab.rri.uwo.ca)
Thu, 5 Dec 1996 15:28:22 -0500 (EST)

To subscribers of the xforms list from Mark Lee <mlee@heartlab.rri.uwo.ca> :

On Thu, 5 Dec 1996, Dr. T.C. Zhao wrote:

> To subscribers of the xforms list from "Dr. T.C. Zhao" <zhao@bragg.phys.uwm.edu> :
>
> Message-Id: <9612050505.AA18021@szechuan.UCSD.EDU>
> >> What is this win1_ctx ? If it is a static variable, you might
> >> have a problem. As spl pointed out, when you hide a form,
> >> all the windows (and their associated properties) are destroyed.
> >> You should use fl_get_glcanvas_context to grab the correct
> >> context.
>
> >Doesn't the context get hosed as well?
>
> When you do fl_show_form, everything is re-created.
> This is why you must always use fl_get_glcanvas_context to get the current
> context (as opposed to saving the context at the begining the first time
> the canvas was created). The context as well as window ID come and go.

I tried your suggestion using fl_get_glcanvas_context to define the
correct drawing context, but I still get a bad GLXBadCurrentWindow error
on remote display and on local display the image window is black.

Here is the code fragment:

A proper image form is created using create_form(); when a resize is
required the form is hidden with fl_hide_form(fd_image_form->image_form)
( I tried spl's suggestion using XUnMapWindow and XMapWindow but an
X_ConfigureWindow and X_ChangeWindowAttributes error occurs) and
redisplayed with the following.

fl_set_form_size(fd_image_form->image_form,im.xsize+45,im.ysize+130);
fl_set_object_size(fd_image_form->image_box,im.xsize+45,im.ysize+130);
fl_set_object_size(fd_image_form->gl_canvas1,im.xsize,im.ysize);
fl_set_object_size(fd_image_form->Window_width,im.xsize+15,20);
fl_set_object_size(fd_image_form->Window_centre,im.xsize+15,20);
fl_set_object_position(fd_image_form->Window_width,15,im.ysize+45);
fl_set_object_position(fd_image_form->Window_centre,15,im.ysize+85);

fl_show_form(fd_image_form->image_form,FL_PLACE_GEOMETRY,FL_FULLBORDER," Video Window ");
image_win=fd_image_form->image_form->window;
XSetWindowColormap(dpy,image_win,default_cmap);
win1=fl_get_canvas_id(fd_image_form->gl_canvas1);
XSetWindowColormap(dpy,win1,cmap);

glXMakeCurrent(dpy,win1,(GLXContext)(fl_get_glcanvas_context(fd_image_form->gl_canvas1)));
fl_set_canvas_colormap(fd_image_form->gl_canvas1,cmap);
fl_redraw_form(fd_image_form->image_form);
XFlush(dpy);
fl_winset(win1);

im is a structure with the image size and data, cmap and default_cmap are
color maps that have be set previously. dpy is opened correctly and the
gl visual has been set with:

int attrib[]={
GLX_RED_SIZE,8,
GLX_GREEN_SIZE,8,
GLX_BLUE_SIZE,8,
GLX_DEPTH_SIZE,8,
None
};

screen = DefaultScreen(dpy);

if (!(vis=glXChooseVisual(dpy,screen,attrib)))
fprintf(stderr,"Error: glXChooseVisual() failed.\n"); {
return -1;
}

and an initial glx context was created with:

win1_ctx=glXCreateContext(dpy,vis,0,GL_TRUE);

Any ideas ?

-Thanks
Mark

__
________/\ \ __ Mark Lee "There is thin line between
/\ __ __ \ \/\_\ mlee@irus.rri.uwo.ca Genuis and Insanity and
\ \ \ \ \ \ \/ / / Advanced Imaging Group I'm stuck in a singularity"
\ \ \ \ \ \_\/ / Robarts Research Institute
\/_/\/_/\/___/ London, Ontario Canada

To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html