My program draw a polygon on a pixmap,then copy it to the screen area.It works well on sun workstation(solaris 8.0),but it stops and reports error infomation on ALPHA workstation(alpha unix 4.0f) when it goes to function glXMakeCurrent() as this:
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 3 (X_GetWindowAttributes)
Resource id in failed request: 0x5c00018
Serial number of failed request: 124
Current serial number in output stream: 125
If you are good at this ,give me some advices please.Here is my code:
-------------------------------------------------------------------
simple.cxx:
#include <stdio.h>
#include <Xm/Form.h>
#include <Xm/Frame.h>
#include <X11/keysym.h>
#if defined(DEC) && defined(__vms)
#include "GLwMDrawA.h"
#else
#include <X11/GLw/GLwMDrawA.h>
#endif
#include <GL/gl.h>
#include <GL/glu.h>

/* Callbacks */
static void input(Widget w, XtPointer client_data, GLwDrawingAreaCallbackStruct *call_data);
static void draw_scene();
static void draw_polys();
void CreateGC(Display *dpy);
static XtAppContext app_context;
static GLXContext glx_context;
static String fallback_resources[] = {
"*frame*shadowType: SHADOW_IN",
"*glwidget*width: 300",
"*glwidget*height: 300",
"*glwidget*rgba: TRUE",
"*glwidget*allocateBackground: TRUE",
NULL
};
static Pixmap pix=NULL;
static GLXPixmap glpix=NULL;
Widget glw;
GC gc;
XVisualInfo *vi;

static void
draw_scene_callback(Widget w, XtPointer client_data, XtPointer call_data)
{
printf("now draw_scene_callback!\n");
GLfloat val;
glDrawBuffer( GL_FRONT );
draw_scene();
XCopyArea(XtDisplay(w),pix,XtWindow(glw),gc,0,0,30 0,300,0,0);
}

static void do_resize(Widget w, XtPointer client_data,GLwDrawingAreaCallbackStruct *call_data)
{
printf("now do_resize!\n");
glViewport(0, 0, (GLint)call_data->width-1, (GLint)call_data->height-1);

}
static void init_window(Widget w, XtPointer client_data, XtPointer call_data)
{
printf("now init_window!\n");
Arg args[1];
XtSetArg(args[0], GLwNvisualInfo, &vi);
XtGetValues(w, args, 1);

glx_context = glXCreateContext(XtDisplay(w), vi, 0, GL_FALSE);
pix=XCreatePixmap(XtDisplay(w),RootWindow(XtDispla y(w), vi->screen),
300,300,vi->depth);

glpix=glXCreateGLXPixmap(XtDisplay(w),vi,pix);
printf("now makecurrent+++++++++++\n");
int aa= glXMakeCurrent(XtDisplay(w),glpix,glx_context);//!!!stoped here
printf("makec return %d\n",aa);
}

main(int argc, char *argv[])
{
Arg args[20];
int n;
Widget toplevel, form, frame;


toplevel = XtAppInitialize(&app_context, "4DgiftsGLw",
(XrmOptionDescList)NULL , 0,
&argc,
(String*)argv,
fallback_resources,
(ArgList)NULL, 0);

n = 0;
form = XmCreateForm(toplevel, "form", args, n);
XtManageChild(form);

CreateGC(XtDisplay(form));
n = 0;
XtSetArg(args[n], XtNx, 10); n++;
XtSetArg(args[n], XtNy, 10); n++;
XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg(args[n], XmNleftOffset, 10); n++;
XtSetArg(args[n], XmNtopOffset, 10); n++;
XtSetArg(args[n], XmNbottomOffset, 10); n++;
XtSetArg(args[n], XmNrightOffset, 10); n++;
frame = XmCreateFrame (form, "frame", args, n);
XtManageChild (frame);

n = 0;
XtSetArg(args[n],GLwNdoublebuffer, True);n++;
glw = GLwCreateMDrawingArea(frame, "glwidget", args, n);
XtManageChild (glw);
XtAddCallback(glw, GLwNginitCallback, (XtCallbackProc)init_window, 0);
XtAddCallback(glw, GLwNexposeCallback, (XtCallbackProc)draw_scene_callback, 0);
XtAddCallback(glw, GLwNresizeCallback, (XtCallbackProc)do_resize, 0);

XtRealizeWidget(toplevel);
XtAppMainLoop(app_context);
}


static void draw_scene(void)
{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluPerspective(40.0, 1.0, 30.0, 1000.0);
glTranslatef(0.0, 0.0, -40.0);
glRotatef(-58.0, 0,1,0);
draw_polys();
glFlush();
}

float polygon1[3][3] = { {-10.0, -10.0, 0.0,},
{ 10.0, -10.0, 0.0,},
{-10.0, 10.0, 0.0,}
};
static void draw_polys() {
glBegin(GL_POLYGON);
glColor3f(0.0, 0.0, 0.0);
glVertex3fv(&polygon1[0][0]);
glColor3f(0.7, 0.7, 0.7);
glVertex3fv(&polygon1[1][0]);
glColor3f(1.0, 1.0, 1.0);
glVertex3fv(&polygon1[2][0]);
glEnd();
}
void CreateGC(Display *dpy)
{
XGCValues gcvalues;
gcvalues.foreground = 0;
gcvalues.background = 1;
gc = XCreateGC(dpy,DefaultRootWindow(dpy) ,
GCBackground | GCForeground, &gcvalues);
}
================================================== ==========
CC simple.cxx -o simple -lXm -lXt -lX11 -lGL -lGLw -lGLU
================================================== ==========
Thanks.