summaryrefslogtreecommitdiffstats
path: root/src/glw
diff options
context:
space:
mode:
Diffstat (limited to 'src/glw')
-rw-r--r--src/glw/GLwDrawA.c686
-rw-r--r--src/glw/GLwDrawA.h195
-rw-r--r--src/glw/GLwDrawAP.h130
-rw-r--r--src/glw/GLwMDrawA.c41
-rw-r--r--src/glw/GLwMDrawA.h41
-rw-r--r--src/glw/GLwMDrawAP.h41
-rw-r--r--src/glw/Makefile59
-rw-r--r--src/glw/README56
-rw-r--r--src/glw/boilerplate.c451
-rw-r--r--src/glw/depend6
10 files changed, 1706 insertions, 0 deletions
diff --git a/src/glw/GLwDrawA.c b/src/glw/GLwDrawA.c
new file mode 100644
index 00000000000..670ddb18edb
--- /dev/null
+++ b/src/glw/GLwDrawA.c
@@ -0,0 +1,686 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ *
+ * This file has been slightly modified from the original for use with Mesa
+ *
+ * Jeroen van der Zijp
+ *
+ *
+ */
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <GL/glx.h>
+#include <GL/gl.h>
+#ifdef __GLX_MOTIF
+#include <Xm/PrimitiveP.h>
+#include "GLwMDrawAP.h"
+#else
+#include "GLwDrawAP.h"
+#endif
+#include <assert.h>
+#include <stdio.h>
+
+#ifdef __GLX_MOTIF
+#define GLwDrawingAreaWidget GLwMDrawingAreaWidget
+#define GLwDrawingAreaClassRec GLwMDrawingAreaClassRec
+#define glwDrawingAreaClassRec glwMDrawingAreaClassRec
+#define glwDrawingAreaWidgetClass glwMDrawingAreaWidgetClass
+#define GLwDrawingAreaRec GLwMDrawingAreaRec
+#endif
+
+#define ATTRIBLIST_SIZE 30
+
+#define offset(field) XtOffset(GLwDrawingAreaWidget,glwDrawingArea.field)
+
+
+/* forward definitions */
+static void createColormap(GLwDrawingAreaWidget w,int offset,XrmValue *value);
+static void Initialize(GLwDrawingAreaWidget req,GLwDrawingAreaWidget neww,ArgList args,Cardinal *num_args);
+static void Realize(Widget w,Mask *valueMask,XSetWindowAttributes *attributes);
+static void Redraw(GLwDrawingAreaWidget w,XEvent *event,Region region);
+static void Resize(GLwDrawingAreaWidget glw);
+static void Destroy(GLwDrawingAreaWidget glw);
+static void glwInput(GLwDrawingAreaWidget glw,XEvent *event,String *params,Cardinal *numParams);
+
+
+
+static char defaultTranslations[] =
+#ifdef __GLX_MOTIF
+ "<Key>osfHelp:PrimitiveHelp() \n"
+#endif
+ "<KeyDown>: glwInput() \n\
+ <KeyUp>: glwInput() \n\
+ <BtnDown>: glwInput() \n\
+ <BtnUp>: glwInput() \n\
+ <BtnMotion>: glwInput() ";
+
+
+static XtActionsRec actions[] = {
+ {"glwInput",(XtActionProc)glwInput}, /* key or mouse input */
+ };
+
+
+/*
+ * There is a bit of unusual handling of the resources here.
+ * Because Xt insists on allocating the colormap resource when it is
+ * processing the core resources (even if we redeclare the colormap
+ * resource here, we need to do a little trick. When Xt first allocates
+ * the colormap, we allow it to allocate the default one, since we have
+ * not yet determined the appropriate visual (which is determined from
+ * resources parsed after the colormap). We also let it allocate colors
+ * in that default colormap.
+ *
+ * In the initialize proc we calculate the actual visual. Then, we
+ * reobtain the colormap resource using XtGetApplicationResources in
+ * the initialize proc. If requested, we also reallocate colors in
+ * that colormap using the same method.
+ */
+
+static XtResource resources[] = {
+ /* The GLX attributes. Add any new attributes here */
+
+ {GLwNbufferSize, GLwCBufferSize, XtRInt, sizeof (int),
+ offset(bufferSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNlevel, GLwCLevel, XtRInt, sizeof (int),
+ offset(level), XtRImmediate, (XtPointer) 0},
+
+ {GLwNrgba, GLwCRgba, XtRBoolean, sizeof (Boolean),
+ offset(rgba), XtRImmediate, (XtPointer) FALSE},
+
+ {GLwNdoublebuffer, GLwCDoublebuffer, XtRBoolean, sizeof (Boolean),
+ offset(doublebuffer), XtRImmediate, (XtPointer) FALSE},
+
+ {GLwNstereo, GLwCStereo, XtRBoolean, sizeof (Boolean),
+ offset(stereo), XtRImmediate, (XtPointer) FALSE},
+
+ {GLwNauxBuffers, GLwCAuxBuffers, XtRInt, sizeof (int),
+ offset(auxBuffers), XtRImmediate, (XtPointer) 0},
+
+ {GLwNredSize, GLwCColorSize, XtRInt, sizeof (int),
+ offset(redSize), XtRImmediate, (XtPointer) 1},
+
+ {GLwNgreenSize, GLwCColorSize, XtRInt, sizeof (int),
+ offset(greenSize), XtRImmediate, (XtPointer) 1},
+
+ {GLwNblueSize, GLwCColorSize, XtRInt, sizeof (int),
+ offset(blueSize), XtRImmediate, (XtPointer) 1},
+
+ {GLwNalphaSize, GLwCAlphaSize, XtRInt, sizeof (int),
+ offset(alphaSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNdepthSize, GLwCDepthSize, XtRInt, sizeof (int),
+ offset(depthSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNstencilSize, GLwCStencilSize, XtRInt, sizeof (int),
+ offset(stencilSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNaccumRedSize, GLwCAccumColorSize, XtRInt, sizeof (int),
+ offset(accumRedSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNaccumGreenSize, GLwCAccumColorSize, XtRInt, sizeof (int),
+ offset(accumGreenSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNaccumBlueSize, GLwCAccumColorSize, XtRInt, sizeof (int),
+ offset(accumBlueSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNaccumAlphaSize, GLwCAccumAlphaSize, XtRInt, sizeof (int),
+ offset(accumAlphaSize), XtRImmediate, (XtPointer) 0},
+
+ /* the attribute list */
+ {GLwNattribList, GLwCAttribList, XtRPointer, sizeof(int *),
+ offset(attribList), XtRImmediate, (XtPointer) NULL},
+
+ /* the visual info */
+ {GLwNvisualInfo, GLwCVisualInfo, GLwRVisualInfo, sizeof (XVisualInfo *),
+ offset(visualInfo), XtRImmediate, (XtPointer) NULL},
+
+ /* miscellaneous resources */
+ {GLwNinstallColormap, GLwCInstallColormap, XtRBoolean, sizeof (Boolean),
+ offset(installColormap), XtRImmediate, (XtPointer) TRUE},
+
+ {GLwNallocateBackground, GLwCAllocateColors, XtRBoolean, sizeof (Boolean),
+ offset(allocateBackground), XtRImmediate, (XtPointer) FALSE},
+
+ {GLwNallocateOtherColors, GLwCAllocateColors, XtRBoolean, sizeof (Boolean),
+ offset(allocateOtherColors), XtRImmediate, (XtPointer) FALSE},
+
+ {GLwNinstallBackground, GLwCInstallBackground, XtRBoolean, sizeof (Boolean),
+ offset(installBackground), XtRImmediate, (XtPointer) TRUE},
+
+ {GLwNginitCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList),
+ offset(ginitCallback), XtRImmediate, (XtPointer) NULL},
+
+ {GLwNinputCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList),
+ offset(inputCallback), XtRImmediate, (XtPointer) NULL},
+
+ {GLwNresizeCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList),
+ offset(resizeCallback), XtRImmediate, (XtPointer) NULL},
+
+ {GLwNexposeCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList),
+ offset(exposeCallback), XtRImmediate, (XtPointer) NULL},
+
+ /* Changes to Motif primitive resources */
+#ifdef __GLX_MOTIF
+ {XmNtraversalOn, XmCTraversalOn, XmRBoolean, sizeof (Boolean),
+ XtOffset (GLwDrawingAreaWidget, primitive.traversal_on), XmRImmediate,
+ (XtPointer)FALSE},
+
+ /* highlighting is normally disabled, as when Motif tries to disable
+ * highlighting, it tries to reset the color back to the parent's
+ * background (usually Motif blue). Unfortunately, that is in a
+ * different colormap, and doesn't work too well.
+ */
+ {XmNhighlightOnEnter, XmCHighlightOnEnter, XmRBoolean, sizeof (Boolean),
+ XtOffset (GLwDrawingAreaWidget, primitive.highlight_on_enter),
+ XmRImmediate, (XtPointer) FALSE},
+
+ {XmNhighlightThickness, XmCHighlightThickness, XmRHorizontalDimension,
+ sizeof (Dimension),
+ XtOffset (GLwDrawingAreaWidget, primitive.highlight_thickness),
+ XmRImmediate, (XtPointer) 0},
+#endif
+ };
+
+
+/*
+** The following resources are reobtained using XtGetApplicationResources
+** in the initialize proc.
+*/
+
+/* The colormap */
+static XtResource initializeResources[] = {
+ /* reobtain the colormap with the new visual */
+ {XtNcolormap, XtCColormap, XtRColormap, sizeof(Colormap),
+ XtOffset(GLwDrawingAreaWidget, core.colormap),
+ XtRCallProc,(XtPointer) createColormap},
+ };
+
+
+/* reallocate any colors we need in the new colormap */
+
+/* The background is obtained only if the allocateBackground resource is TRUE*/
+static XtResource backgroundResources[] = {
+#ifdef __GLX_MOTIF
+ {XmNbackground, XmCBackground,XmRPixel,
+ sizeof(Pixel),XtOffset(GLwDrawingAreaWidget,core.background_pixel),
+ XmRString,(XtPointer)"lightgrey"},
+ /*XmRCallProc,(XtPointer)_XmBackgroundColorDefault},*/
+
+ {XmNbackgroundPixmap,XmCPixmap,XmRXmBackgroundPixmap,
+ sizeof(Pixmap),XtOffset(GLwDrawingAreaWidget,core.background_pixmap),
+ XmRImmediate,(XtPointer)XmUNSPECIFIED_PIXMAP},
+
+#else
+ {XtNbackground,XtCBackground,XtRPixel,sizeof(Pixel),
+ XtOffset(GLwDrawingAreaWidget,core.background_pixel),
+ XtRString,(XtPointer)"lightgrey"},
+ /*XtRString,(XtPointer)"XtDefaultBackground"},*/
+
+ {XtNbackgroundPixmap, XtCPixmap, XtRPixmap, sizeof(Pixmap),
+ XtOffset(GLwDrawingAreaWidget,core.background_pixmap),
+ XtRImmediate,(XtPointer)XtUnspecifiedPixmap},
+#endif
+ };
+
+
+
+/* The other colors such as the foreground are allocated only if
+ * allocateOtherColors are set. These resources only exist in Motif.
+ */
+#ifdef __GLX_MOTIF
+static XtResource otherColorResources[] = {
+ {XmNforeground,XmCForeground,XmRPixel,
+ sizeof(Pixel),XtOffset(GLwDrawingAreaWidget,primitive.foreground),
+ XmRString,(XtPointer)"lighgrey"},
+ /*XmRCallProc, (XtPointer) _XmForegroundColorDefault},*/
+
+ {XmNhighlightColor,XmCHighlightColor,XmRPixel,sizeof(Pixel),
+ XtOffset(GLwDrawingAreaWidget,primitive.highlight_color),
+ XmRString,(XtPointer)"lightgrey"},
+ /*XmRCallProc,(XtPointer)_XmHighlightColorDefault},*/
+
+ {XmNhighlightPixmap,XmCHighlightPixmap,XmRPrimHighlightPixmap,
+ sizeof(Pixmap),
+ XtOffset(GLwDrawingAreaWidget,primitive.highlight_pixmap),
+ XmRImmediate,(XtPointer)XmUNSPECIFIED_PIXMAP},
+ /*XmRCallProc,(XtPointer)_XmPrimitiveHighlightPixmapDefault},*/
+ };
+#endif
+
+
+#undef offset
+
+
+GLwDrawingAreaClassRec glwDrawingAreaClassRec = {
+ { /* core fields */
+#ifdef __GLX_MOTIF
+ /* superclass */ (WidgetClass) &xmPrimitiveClassRec,
+ /* class_name */ "GLwMDrawingArea",
+#else /* not __GLX_MOTIF */
+ /* superclass */ (WidgetClass) &widgetClassRec,
+ /* class_name */ "GLwDrawingArea",
+#endif /* __GLX_MOTIF */
+ /* widget_size */ sizeof(GLwDrawingAreaRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ (XtInitProc) Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ TRUE,
+ /* destroy */ (XtWidgetProc) Destroy,
+ /* resize */ (XtWidgetProc) Resize,
+ /* expose */ (XtExposeProc) Redraw,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+#ifdef __GLX_MOTIF /* primitive resources */
+ {
+ /* border_highlight */ XmInheritBorderHighlight,
+ /* border_unhighlight */ XmInheritBorderUnhighlight,
+ /* translations */ XtInheritTranslations,
+ /* arm_and_activate */ NULL,
+ /* get_resources */ NULL,
+ /* num get_resources */ 0,
+ /* extension */ NULL,
+ }
+#endif
+ };
+
+WidgetClass glwDrawingAreaWidgetClass=(WidgetClass)&glwDrawingAreaClassRec;
+
+
+
+static void error(Widget w,char* string){
+ char buf[100];
+#ifdef __GLX_MOTIF
+ sprintf(buf,"GLwMDrawingArea: %s\n",string);
+#else
+ sprintf(buf,"GLwDrawingArea: %s\n",string);
+#endif
+ XtAppError(XtWidgetToApplicationContext(w),buf);
+ }
+
+
+static void warning(Widget w,char* string){
+ char buf[100];
+#ifdef __GLX_MOTIF
+ sprintf (buf, "GLwMDraw: %s\n", string);
+#else
+ sprintf (buf, "GLwDraw: %s\n", string);
+#endif
+ XtAppWarning(XtWidgetToApplicationContext(w), buf);
+ }
+
+
+
+/* Initialize the attribList based on the attributes */
+static void createAttribList(GLwDrawingAreaWidget w){
+ int *ptr;
+ w->glwDrawingArea.attribList = (int*)XtMalloc(ATTRIBLIST_SIZE*sizeof(int));
+ if(!w->glwDrawingArea.attribList){
+ error((Widget)w,"Unable to allocate attribute list");
+ }
+ ptr = w->glwDrawingArea.attribList;
+ *ptr++ = GLX_BUFFER_SIZE;
+ *ptr++ = w->glwDrawingArea.bufferSize;
+ *ptr++ = GLX_LEVEL;
+ *ptr++ = w->glwDrawingArea.level;
+ if(w->glwDrawingArea.rgba) *ptr++ = GLX_RGBA;
+ if(w->glwDrawingArea.doublebuffer) *ptr++ = GLX_DOUBLEBUFFER;
+ if(w->glwDrawingArea.stereo) *ptr++ = GLX_STEREO;
+ *ptr++ = GLX_AUX_BUFFERS;
+ *ptr++ = w->glwDrawingArea.auxBuffers;
+ *ptr++ = GLX_RED_SIZE;
+ *ptr++ = w->glwDrawingArea.redSize;
+ *ptr++ = GLX_GREEN_SIZE;
+ *ptr++ = w->glwDrawingArea.greenSize;
+ *ptr++ = GLX_BLUE_SIZE;
+ *ptr++ = w->glwDrawingArea.blueSize;
+ *ptr++ = GLX_ALPHA_SIZE;
+ *ptr++ = w->glwDrawingArea.alphaSize;
+ *ptr++ = GLX_DEPTH_SIZE;
+ *ptr++ = w->glwDrawingArea.depthSize;
+ *ptr++ = GLX_STENCIL_SIZE;
+ *ptr++ = w->glwDrawingArea.stencilSize;
+ *ptr++ = GLX_ACCUM_RED_SIZE;
+ *ptr++ = w->glwDrawingArea.accumRedSize;
+ *ptr++ = GLX_ACCUM_GREEN_SIZE;
+ *ptr++ = w->glwDrawingArea.accumGreenSize;
+ *ptr++ = GLX_ACCUM_BLUE_SIZE;
+ *ptr++ = w->glwDrawingArea.accumBlueSize;
+ *ptr++ = GLX_ACCUM_ALPHA_SIZE;
+ *ptr++ = w->glwDrawingArea.accumAlphaSize;
+ *ptr++ = None;
+ assert((ptr-w->glwDrawingArea.attribList)<ATTRIBLIST_SIZE);
+ }
+
+
+
+/* Initialize the visualInfo based on the attribute list */
+static void createVisualInfo(GLwDrawingAreaWidget w){
+ static XVisualInfo *visualInfo;
+ assert(w->glwDrawingArea.attribList);
+ w->glwDrawingArea.visualInfo=glXChooseVisual(XtDisplay(w),XScreenNumberOfScreen(XtScreen(w)),w->glwDrawingArea.attribList);
+ if(!w->glwDrawingArea.visualInfo) error((Widget)w,"requested visual not supported");
+ }
+
+
+
+/* Initialize the colormap based on the visual info.
+ * This routine maintains a cache of visual-infos to colormaps. If two
+ * widgets share the same visual info, they share the same colormap.
+ * This function is called by the callProc of the colormap resource entry.
+ */
+static void createColormap(GLwDrawingAreaWidget w,int offset,XrmValue *value){
+ static struct cmapCache { Visual *visual; Colormap cmap; } *cmapCache;
+ static int cacheEntries=0;
+ static int cacheMalloced=0;
+ register int i;
+
+ assert(w->glwDrawingArea.visualInfo);
+
+ /* see if we can find it in the cache */
+ for(i=0; i<cacheEntries; i++){
+ if(cmapCache[i].visual==w->glwDrawingArea.visualInfo->visual){
+ value->addr=(XtPointer)(&cmapCache[i].cmap);
+ return;
+ }
+ }
+
+ /* not in the cache, create a new entry */
+ if(cacheEntries >= cacheMalloced){
+ /* need to malloc a new one. Since we are likely to have only a
+ * few colormaps, we allocate one the first time, and double
+ * each subsequent time.
+ */
+ if(cacheMalloced==0){
+ cacheMalloced=1;
+ cmapCache=(struct cmapCache*)XtMalloc(sizeof(struct cmapCache));
+ }
+ else{
+ cacheMalloced<<=1;
+ cmapCache=(struct cmapCache*)XtRealloc((char*)cmapCache,sizeof(struct cmapCache)*cacheMalloced);
+ }
+ }
+
+ cmapCache[cacheEntries].cmap=XCreateColormap(XtDisplay(w),
+ RootWindow(XtDisplay(w),
+ w->glwDrawingArea.visualInfo->screen),
+ w->glwDrawingArea.visualInfo->visual,
+ AllocNone);
+ cmapCache[cacheEntries].visual=w->glwDrawingArea.visualInfo->visual;
+ value->addr=(XtPointer)(&cmapCache[cacheEntries++].cmap);
+ }
+
+
+
+static void Initialize(GLwDrawingAreaWidget req,GLwDrawingAreaWidget neww,ArgList args,Cardinal *num_args){
+
+ /* fix size */
+ if(req->core.width==0) neww->core.width=100;
+ if(req->core.height==0) neww->core.width=100;
+
+ /* create the attribute list if needed */
+ neww->glwDrawingArea.myList=FALSE;
+ if(neww->glwDrawingArea.attribList==NULL){
+ neww->glwDrawingArea.myList=TRUE;
+ createAttribList(neww);
+ }
+
+ /* Gotta have it */
+ assert(neww->glwDrawingArea.attribList);
+
+ /* determine the visual info if needed */
+ neww->glwDrawingArea.myVisual=FALSE;
+ if(neww->glwDrawingArea.visualInfo==NULL){
+ neww->glwDrawingArea.myVisual=TRUE;
+ createVisualInfo(neww);
+ }
+
+ /* Gotta have that too */
+ assert(neww->glwDrawingArea.visualInfo);
+
+ neww->core.depth=neww->glwDrawingArea.visualInfo->depth;
+
+ /* Reobtain the colormap and colors in it using XtGetApplicationResources*/
+ XtGetApplicationResources((Widget)neww,neww,initializeResources,XtNumber(initializeResources),args,*num_args);
+
+ /* obtain the color resources if appropriate */
+ if(req->glwDrawingArea.allocateBackground){
+ XtGetApplicationResources((Widget)neww,neww,backgroundResources,XtNumber(backgroundResources),args,*num_args);
+ }
+
+#ifdef __GLX_MOTIF
+ if(req->glwDrawingArea.allocateOtherColors){
+ XtGetApplicationResources((Widget)neww,neww,otherColorResources,XtNumber(otherColorResources),args,*num_args);
+ }
+#endif
+ }
+
+
+
+static void Realize(Widget w,Mask *valueMask,XSetWindowAttributes *attributes){
+ register GLwDrawingAreaWidget glw=(GLwDrawingAreaWidget)w;
+ GLwDrawingAreaCallbackStruct cb;
+ Widget parentShell;
+ Status status;
+ Window windows[2],*windowsReturn,*windowList;
+ int countReturn,i;
+
+ /* if we haven't requested that the background be both installed and
+ * allocated, don't install it.
+ */
+ if(!(glw->glwDrawingArea.installBackground && glw->glwDrawingArea.allocateBackground)){
+ *valueMask&=~CWBackPixel;
+ }
+
+ XtCreateWindow(w,(unsigned int)InputOutput,glw->glwDrawingArea.visualInfo->visual,*valueMask,attributes);
+
+ /* if appropriate, call XSetWMColormapWindows to install the colormap */
+ if(glw->glwDrawingArea.installColormap){
+
+ /* Get parent shell */
+ for(parentShell=XtParent(w); parentShell&&!XtIsShell(parentShell); parentShell=XtParent(parentShell));
+
+ if(parentShell && XtWindow(parentShell)){
+
+ /* check to see if there is already a property */
+ status=XGetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),&windowsReturn,&countReturn);
+
+ /* if no property, just create one */
+ if(!status){
+ windows[0]=XtWindow(w);
+ windows[1]=XtWindow(parentShell);
+ XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windows,2);
+ }
+
+ /* there was a property, add myself to the beginning */
+ else{
+ windowList=(Window *)XtMalloc((sizeof(Window))*(countReturn+1));
+ windowList[0]=XtWindow(w);
+ for(i=0; i<countReturn; i++) windowList[i+1]=windowsReturn[i];
+ XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windowList,countReturn+1);
+ XtFree((char*)windowList);
+ XtFree((char*)windowsReturn);
+ }
+ }
+ else{
+ warning(w,"Could not set colormap property on parent shell");
+ }
+ }
+
+ /* Invoke callbacks */
+ cb.reason=GLwCR_GINIT;
+ cb.event=NULL;
+ cb.width=glw->core.width;
+ cb.height=glw->core.height;
+ XtCallCallbackList((Widget)glw,glw->glwDrawingArea.ginitCallback,&cb);
+ }
+
+
+
+static void Redraw(GLwDrawingAreaWidget w,XEvent *event,Region region){
+ GLwDrawingAreaCallbackStruct cb;
+ XtCallbackList cblist;
+ if(!XtIsRealized((Widget)w)) return;
+ cb.reason=GLwCR_EXPOSE;
+ cb.event=event;
+ cb.width=w->core.width;
+ cb.height=w->core.height;
+ XtCallCallbackList((Widget)w,w->glwDrawingArea.exposeCallback,&cb);
+ }
+
+
+
+static void Resize(GLwDrawingAreaWidget glw){
+ GLwDrawingAreaCallbackStruct cb;
+ if(!XtIsRealized((Widget)glw)) return;
+ cb.reason=GLwCR_RESIZE;
+ cb.event=NULL;
+ cb.width=glw->core.width;
+ cb.height=glw->core.height;
+ XtCallCallbackList((Widget)glw,glw->glwDrawingArea.resizeCallback,&cb);
+ }
+
+
+
+static void Destroy(GLwDrawingAreaWidget glw){
+ Window *windowsReturn;
+ Widget parentShell;
+ Status status;
+ int countReturn;
+ register int i;
+
+ if(glw->glwDrawingArea.myList && glw->glwDrawingArea.attribList){
+ XtFree((XtPointer)glw->glwDrawingArea.attribList);
+ }
+
+ if(glw->glwDrawingArea.myVisual && glw->glwDrawingArea.visualInfo){
+ XtFree((XtPointer)glw->glwDrawingArea.visualInfo);
+ }
+
+ /* if my colormap was installed, remove it */
+ if(glw->glwDrawingArea.installColormap){
+
+ /* Get parent shell */
+ for(parentShell=XtParent(glw); parentShell&&!XtIsShell(parentShell); parentShell=XtParent(parentShell));
+
+ if(parentShell && XtWindow(parentShell)){
+
+ /* make sure there is a property */
+ status=XGetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),&windowsReturn,&countReturn);
+
+ /* if no property, just return. If there was a property, continue */
+ if(status){
+
+ /* search for a match */
+ for(i=0; i<countReturn; i++){
+ if(windowsReturn[i]==XtWindow(glw)){
+
+ /* we found a match, now copy the rest down */
+ for(i++; i<countReturn; i++){ windowsReturn[i-1]=windowsReturn[i]; }
+
+ XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windowsReturn,countReturn-1);
+ break;
+ }
+ }
+ XtFree((char *)windowsReturn);
+ }
+ }
+ }
+ }
+
+
+
+/* Action routine for keyboard and mouse events */
+static void glwInput(GLwDrawingAreaWidget glw,XEvent *event,String *params,Cardinal *numParams){
+ GLwDrawingAreaCallbackStruct cb;
+ cb.reason=GLwCR_INPUT;
+ cb.event=event;
+ cb.width=glw->core.width;
+ cb.height=glw->core.height;
+ XtCallCallbackList((Widget)glw,glw->glwDrawingArea.inputCallback,&cb);
+ }
+
+
+#ifdef __GLX_MOTIF
+
+/* Create routine */
+Widget GLwCreateMDrawingArea(Widget parent, char *name,ArgList arglist,Cardinal argcount){
+ return XtCreateWidget(name,glwMDrawingAreaWidgetClass, parent, arglist,argcount);
+ }
+
+#endif
+
+
+#ifndef __GLX_MOTIF
+
+/* Make context current */
+void GLwDrawingAreaMakeCurrent(Widget w,GLXContext ctx){
+ glXMakeCurrent(XtDisplay(w),XtWindow(w),ctx);
+ }
+
+
+/* Swap buffers convenience function */
+void GLwDrawingAreaSwapBuffers(Widget w){
+ glXSwapBuffers(XtDisplay(w),XtWindow(w));
+ }
+
+#endif
diff --git a/src/glw/GLwDrawA.h b/src/glw/GLwDrawA.h
new file mode 100644
index 00000000000..a62852c260f
--- /dev/null
+++ b/src/glw/GLwDrawA.h
@@ -0,0 +1,195 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+#ifndef _GLwDrawA_h
+#define _GLwDrawA_h
+
+#include <GL/glx.h>
+#include <GL/gl.h>
+
+/****************************************************************
+ *
+ * GLwDrawingArea widgets
+ *
+ ****************************************************************/
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ attribList AttribList int * NULL
+ visualInfo VisualInfo VisualInfo NULL
+ installColormap InstallColormap Boolean TRUE
+ allocateBackground AllocateColors Boolean FALSE
+ allocateOtherColors AllocateColors Boolean FALSE
+ installBackground InstallBackground Boolean TRUE
+ exposeCallback Callback Pointer NULL
+ ginitCallback Callback Pointer NULL
+ inputCallback Callback Pointer NULL
+ resizeCallback Callback Pointer NULL
+
+*** The following resources all correspond to the GLX configuration
+*** attributes and are used to create the attribList if it is NULL
+ bufferSize BufferSize int 0
+ level Level int 0
+ rgba Rgba Boolean FALSE
+ doublebuffer Doublebuffer Boolean FALSE
+ stereo Stereo Boolean FALSE
+ auxBuffers AuxBuffers int 0
+ redSize ColorSize int 1
+ greenSize ColorSize int 1
+ blueSize ColorSize int 1
+ alphaSize AlphaSize int 0
+ depthSize DepthSize int 0
+ stencilSize StencilSize int 0
+ accumRedSize AccumColorSize int 0
+ accumGreenSize AccumColorSize int 0
+ accumBlueSize AccumColorSize int 0
+ accumAlphaSize AccumAlphaSize int 0
+*/
+
+#define GLwNattribList "attribList"
+#define GLwCAttribList "AttribList"
+#define GLwNvisualInfo "visualInfo"
+#define GLwCVisualInfo "VisualInfo"
+#define GLwRVisualInfo "VisualInfo"
+
+#define GLwNinstallColormap "installColormap"
+#define GLwCInstallColormap "InstallColormap"
+#define GLwNallocateBackground "allocateBackground"
+#define GLwNallocateOtherColors "allocateOtherColors"
+#define GLwCAllocateColors "AllocateColors"
+#define GLwNinstallBackground "installBackground"
+#define GLwCInstallBackground "InstallBackground"
+
+#define GLwCCallback "Callback"
+#define GLwNexposeCallback "exposeCallback"
+#define GLwNginitCallback "ginitCallback"
+#define GLwNresizeCallback "resizeCallback"
+#define GLwNinputCallback "inputCallback"
+
+#define GLwNbufferSize "bufferSize"
+#define GLwCBufferSize "BufferSize"
+#define GLwNlevel "level"
+#define GLwCLevel "Level"
+#define GLwNrgba "rgba"
+#define GLwCRgba "Rgba"
+#define GLwNdoublebuffer "doublebuffer"
+#define GLwCDoublebuffer "Doublebuffer"
+#define GLwNstereo "stereo"
+#define GLwCStereo "Stereo"
+#define GLwNauxBuffers "auxBuffers"
+#define GLwCAuxBuffers "AuxBuffers"
+#define GLwNredSize "redSize"
+#define GLwNgreenSize "greenSize"
+#define GLwNblueSize "blueSize"
+#define GLwCColorSize "ColorSize"
+#define GLwNalphaSize "alphaSize"
+#define GLwCAlphaSize "AlphaSize"
+#define GLwNdepthSize "depthSize"
+#define GLwCDepthSize "DepthSize"
+#define GLwNstencilSize "stencilSize"
+#define GLwCStencilSize "StencilSize"
+#define GLwNaccumRedSize "accumRedSize"
+#define GLwNaccumGreenSize "accumGreenSize"
+#define GLwNaccumBlueSize "accumBlueSize"
+#define GLwCAccumColorSize "AccumColorSize"
+#define GLwNaccumAlphaSize "accumAlphaSize"
+#define GLwCAccumAlphaSize "AccumAlphaSize"
+
+#ifdef __GLX_MOTIF
+
+typedef struct _GLwMDrawingAreaClassRec *GLwMDrawingAreaWidgetClass;
+typedef struct _GLwMDrawingAreaRec *GLwMDrawingAreaWidget;
+
+extern WidgetClass glwMDrawingAreaWidgetClass;
+
+
+#else
+
+typedef struct _GLwDrawingAreaClassRec *GLwDrawingAreaWidgetClass;
+typedef struct _GLwDrawingAreaRec *GLwDrawingAreaWidget;
+
+extern WidgetClass glwDrawingAreaWidgetClass;
+
+
+#endif
+
+
+/* Callback reasons */
+#ifdef __GLX_MOTIF
+#define GLwCR_EXPOSE XmCR_EXPOSE
+#define GLwCR_RESIZE XmCR_RESIZE
+#define GLwCR_INPUT XmCR_INPUT
+#else
+/* The same values as Motif, but don't use Motif constants */
+#define GLwCR_EXPOSE 38
+#define GLwCR_RESIZE 39
+#define GLwCR_INPUT 40
+#endif
+
+#define GLwCR_GINIT 32135 /* Arbitrary number that should neverr clash */
+
+typedef struct
+ {
+ int reason;
+ XEvent *event;
+ Dimension width,height;
+ }
+ GLwDrawingAreaCallbackStruct;
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+/* front ends to glXMakeCurrent and glXSwapBuffers */
+extern void GLwDrawingAreaMakeCurrent(Widget w,GLXContext ctx);
+extern void GLwDrawingAreaSwapBuffers(Widget w);
+
+#ifdef __GLX_MOTIF
+#ifdef _NO_PROTO
+extern Widget GLwCreateMDrawingArea();
+#else
+extern Widget GLwCreateMDrawingArea(Widget parent,char *name,ArgList arglist,Cardinal argcount);
+#endif
+#endif
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif
diff --git a/src/glw/GLwDrawAP.h b/src/glw/GLwDrawAP.h
new file mode 100644
index 00000000000..f1217019541
--- /dev/null
+++ b/src/glw/GLwDrawAP.h
@@ -0,0 +1,130 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+#ifndef _GLwDrawAP_h
+#define _GLwDrawAP_h
+
+
+/* MOTIF */
+#ifdef __GLX_MOTIF
+#include "GLwMDrawA.h"
+#else
+#include "GLwDrawA.h"
+#endif
+
+typedef struct _GLwDrawingAreaClassPart {
+ caddr_t extension;
+ } GLwDrawingAreaClassPart;
+
+
+#ifdef __GLX_MOTIF
+typedef struct _GLwMDrawingAreaClassRec {
+ CoreClassPart core_class;
+ XmPrimitiveClassPart primitive_class;
+ GLwDrawingAreaClassPart glwDrawingArea_class;
+ } GLwMDrawingAreaClassRec;
+
+
+extern GLwMDrawingAreaClassRec glwMDrawingAreaClassRec;
+
+
+/* XT */
+#else
+
+typedef struct _GLwDrawingAreaClassRec {
+ CoreClassPart core_class;
+ GLwDrawingAreaClassPart glwDrawingArea_class;
+ } GLwDrawingAreaClassRec;
+
+extern GLwDrawingAreaClassRec glwDrawingAreaClassRec;
+
+
+#endif
+
+
+
+typedef struct {
+ /* resources */
+ int * attribList;
+ XVisualInfo * visualInfo;
+ Boolean myList; /* TRUE if we malloced the attribList*/
+ Boolean myVisual; /* TRUE if we created the visualInfo*/
+ Boolean installColormap;
+ Boolean allocateBackground;
+ Boolean allocateOtherColors;
+ Boolean installBackground;
+ XtCallbackList ginitCallback;
+ XtCallbackList resizeCallback;
+ XtCallbackList exposeCallback;
+ XtCallbackList inputCallback;
+ /* specific attributes; add as we get new attributes */
+ int bufferSize;
+ int level;
+ Boolean rgba;
+ Boolean doublebuffer;
+ Boolean stereo;
+ int auxBuffers;
+ int redSize;
+ int greenSize;
+ int blueSize;
+ int alphaSize;
+ int depthSize;
+ int stencilSize;
+ int accumRedSize;
+ int accumGreenSize;
+ int accumBlueSize;
+ int accumAlphaSize;
+ } GLwDrawingAreaPart;
+
+#ifdef __GLX_MOTIF
+
+typedef struct _GLwMDrawingAreaRec {
+ CorePart core;
+ XmPrimitivePart primitive;
+ GLwDrawingAreaPart glwDrawingArea;
+ } GLwMDrawingAreaRec;
+
+#else
+
+typedef struct _GLwDrawingAreaRec {
+ CorePart core;
+ GLwDrawingAreaPart glwDrawingArea;
+ } GLwDrawingAreaRec;
+
+#endif
+
+#endif
diff --git a/src/glw/GLwMDrawA.c b/src/glw/GLwMDrawA.c
new file mode 100644
index 00000000000..bdefe92a6d0
--- /dev/null
+++ b/src/glw/GLwMDrawA.c
@@ -0,0 +1,41 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+#ifndef __GLX_MOTIF
+#define __GLX_MOTIF 1
+#endif
+#include "GLwDrawA.c"
diff --git a/src/glw/GLwMDrawA.h b/src/glw/GLwMDrawA.h
new file mode 100644
index 00000000000..2e245890410
--- /dev/null
+++ b/src/glw/GLwMDrawA.h
@@ -0,0 +1,41 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+#ifndef __GLX_MOTIF
+#define __GLX_MOTIF 1
+#endif
+#include "GLwDrawA.h"
diff --git a/src/glw/GLwMDrawAP.h b/src/glw/GLwMDrawAP.h
new file mode 100644
index 00000000000..a0a689bb996
--- /dev/null
+++ b/src/glw/GLwMDrawAP.h
@@ -0,0 +1,41 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+#ifndef __GLX_MOTIF
+#define __GLX_MOTIF 1
+#endif
+#include "GLwDrawAP.h"
diff --git a/src/glw/Makefile b/src/glw/Makefile
new file mode 100644
index 00000000000..af55a1bf38f
--- /dev/null
+++ b/src/glw/Makefile
@@ -0,0 +1,59 @@
+# Makefile for OpenGL widgets
+
+# NOTE: widget code is from SGI. See any of the .c or .h files for the
+# complete copyright. Mesa's GNU copyright DOES NOT apply to this widget
+# code.
+
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIRS = -I../include -I/usr/include/Motif1.2 -I/usr/X11R6/include
+LIBDIR = ../lib
+
+SOURCES = GLwDrawA.c GLwMDrawA.c
+
+
+OBJECTS = $(SOURCES:.c=.o)
+
+
+
+##### RULES #####
+
+.c.o:
+ $(CC) -c $(INCDIRS) $(CFLAGS) $<
+
+
+
+##### TARGETS #####
+
+default:
+ @echo "Specify a target configuration"
+
+clean:
+ -rm *.o *~
+
+# The name of the library file comes from Make-config
+#XXX GLW_LIB = libGLw.a
+
+targets: $(LIBDIR)/$(GLW_LIB)
+
+
+# Make the library
+$(LIBDIR)/$(GLW_LIB): $(OBJECTS)
+ $(MAKELIB) $(GLW_LIB) $(MAJOR) $(MINOR) $(OBJECTS)
+ mv $(GLW_LIB)* $(LIBDIR)
+
+include ../Make-config
+
+include depend
+
+
+
+#
+# Run 'make depend' to update the dependencies if you change what's included
+# by any source file.
+#
+dep: $(SOURCES)
+ makedepend -fdepend -Y -I../include $(SOURCES)
diff --git a/src/glw/README b/src/glw/README
new file mode 100644
index 00000000000..545f8b2a4c6
--- /dev/null
+++ b/src/glw/README
@@ -0,0 +1,56 @@
+
+
+ widgets README file
+
+
+This directory contains the source code for SGI's OpenGL Xt/Motif widgets,
+slightly modified by Jeroen van der Zijp to work better with Mesa.
+
+To compile the widget code (producing lib/libGLw.a) cd to the widgets/
+directory and type 'make <config>' where <config> is the system configuration
+you used to compile Mesa. This hasn't been tested on many systems so
+let us know if you have trouble.
+
+If you want to make a Linux ELF shared lib instead of the non-shared .a
+file see the notes in the Makefile.
+
+
+These files are NOT covered by Mesa's GNU copyright. The real copyright
+is as follows.
+
+
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
diff --git a/src/glw/boilerplate.c b/src/glw/boilerplate.c
new file mode 100644
index 00000000000..c53a3fa7356
--- /dev/null
+++ b/src/glw/boilerplate.c
@@ -0,0 +1,451 @@
+/*
+
+ BOILERPLATE
+
+ To get started with mixed model programming with Motif and OpenGL, this
+ boilerplate `application' might help get you started.
+
+ This program honors two environment variables:
+
+ SETVISUAL <id> Makes the application use the indicated visual,
+ instead of the one chosen by glxChooseVisual.
+
+ SAMEVISUAL Make the application use the same visual for the
+ GUI as for the 3D GL Widget.
+
+ The basic idea is to minimize colormap `flash' on systems with only one
+ hardware colormap, especially when focus shifts between several
+ of the application's windows, e.g. the about box.
+
+ If you have suggestions for improvements, please mail to:
+
+
+ Jeroen van der Zijp <[email protected]>
+
+
+ Feel free to turn this into a useful program!!
+
+*/
+
+
+/*
+
+ This code is hereby placed under GNU GENERAL PUBLIC LICENSE.
+ Copyright (C) 1996 Jeroen van der Zijp <[email protected]>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+
+/* Include the kitchen sink */
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/cursorfont.h>
+#include <X11/keysym.h>
+#include <Xm/Xm.h>
+#include <Xm/MainW.h>
+#include <Xm/RowColumn.h>
+#include <Xm/PushB.h>
+#include <Xm/CascadeB.h>
+#include <Xm/BulletinB.h>
+#include <Xm/DialogS.h>
+#include <Xm/Frame.h>
+#include <Xm/MessageB.h>
+#include <Xm/Form.h>
+#include <Xm/Separator.h>
+#include <Xm/MwmUtil.h>
+
+/* Now some good stuff */
+#include <GLwMDrawA.h>
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include <GL/glx.h>
+
+
+/* Stuff */
+Display *display;
+Visual *gui_visual;
+Colormap gui_colormap;
+Colormap gl_colormap;
+XVisualInfo *gl_visualinfo;
+XtAppContext app_context;
+Widget toplevel;
+Widget mainwindow;
+Widget menubar;
+Widget mainform;
+Widget mainframe;
+Widget glwidget;
+Widget button;
+Widget separator;
+GLXContext glx_context;
+
+#ifndef __cplusplus
+#define c_class class
+#endif
+
+/* Requested attributes; fix as you see fit */
+static int glxConfig[]={
+ GLX_RGBA,
+ GLX_DOUBLEBUFFER,
+ GLX_DEPTH_SIZE, 16,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ None
+ };
+
+
+/* Forwards */
+static void exposeCB(Widget w,XtPointer client_data,GLwDrawingAreaCallbackStruct *cbs);
+static void initCB(Widget w,XtPointer client_data,GLwDrawingAreaCallbackStruct *cbs);
+static void resizeCB(Widget w,XtPointer client_data,GLwDrawingAreaCallbackStruct *cbs);
+static void inputCB(Widget w,XtPointer client_data,GLwDrawingAreaCallbackStruct *cbs);
+static void byeCB(Widget w,XtPointer client_data,XtPointer call_data);
+static void aboutCB(Widget w,XtPointer client_data,XtPointer call_data);
+static char* showvisualclass(int cls);
+
+
+
+/* Sample application */
+int main(int argc, char *argv[]){
+ char *thevisual;
+ XVisualInfo vi;
+ int nvisinfos,visid,n;
+ Arg args[30];
+ Widget pane,cascade,but;
+
+ /*
+ ** Initialize toolkit
+ ** We do *not* use XtAppInitialize as we want to figure visual and
+ ** colormap BEFORE we create the top level shell!!!
+ */
+ XtToolkitInitialize();
+
+ /* Make application context */
+ app_context=XtCreateApplicationContext();
+
+ /* Try open display */
+ display=XtOpenDisplay(app_context,NULL,"boilerPlate","BoilerPlate",NULL,0,&argc,argv);
+
+ /* Report failure */
+ if(!display){
+ fprintf(stderr,"Unable to open the specified display.\n");
+ fprintf(stderr,"Set your `DISPLAY' environment variable properly or\n");
+ fprintf(stderr,"use the `xhost' command to authorize access to the display.\n");
+ exit(1);
+ }
+
+ /* Check for extension; for Mesa, this is always cool */
+ if(!glXQueryExtension(display,NULL,NULL)){
+ fprintf(stderr,"The specified display does not support the OpenGL extension\n");
+ exit(1);
+ }
+
+ /* Init with default visual and colormap */
+ gui_visual=DefaultVisual(display,0);
+ gui_colormap=DefaultColormap(display,0);
+ gl_colormap=DefaultColormap(display,0);
+
+ /* User insists on a specific visual */
+ if((thevisual=getenv("SETVISUAL"))!=NULL){
+ if(sscanf(thevisual,"%x",&visid)==1){
+ vi.visualid=visid;
+ gl_visualinfo=XGetVisualInfo(display,VisualIDMask,&vi,&nvisinfos);
+ }
+ else{
+ fprintf(stderr,"Please set the `SETVISUAL' variable in hexadecimal\n");
+ fprintf(stderr,"Use one of the Visual ID's reported by `xdpyinfo'\n");
+ exit(1);
+ }
+ }
+
+ /* Find visual the regular way */
+ else{
+ gl_visualinfo=glXChooseVisual(display,DefaultScreen(display),glxConfig);
+ }
+
+ /* Make sure we have a visual */
+ if(!gl_visualinfo){
+ fprintf(stderr,"Unable to obtain visual for graphics\n");
+ exit(1);
+ }
+
+ /* Show what visual is being used */
+ fprintf(stderr,"Using the following visual:\n");
+ fprintf(stderr," visualid: %lx\n",gl_visualinfo->visualid);
+ fprintf(stderr," depth: %d\n",gl_visualinfo->depth);
+ fprintf(stderr," screen: %d\n",gl_visualinfo->screen);
+ fprintf(stderr," bits/rgb: %d\n",gl_visualinfo->bits_per_rgb);
+ fprintf(stderr," class: %s\n",showvisualclass(gl_visualinfo->c_class));
+
+ /*
+ ** If not using default visual, we need a colormap for this visual.
+ ** Yes, the GL widget can allocate one itself, but we want to make
+ ** sure the GUI and the 3D have the same one (if hardware does not
+ ** allow more than one simultaneously).
+ ** This prevents nasty flashing when the window with the 3D widget
+ ** looses the focus.
+ */
+ if(gl_visualinfo->visual!=DefaultVisual(display,0)){
+ fprintf(stderr,"Making another colormap\n");
+ gl_colormap=XCreateColormap(display,
+ RootWindow(display,0),
+ gl_visualinfo->visual,
+ AllocNone);
+ if(!gl_colormap){
+ fprintf(stderr,"Unable to create private colormap\n");
+ exit(1);
+ }
+ }
+
+ /*
+ ** Use common visual for GUI and GL?
+ ** Maybe you can invoke some hardware interrogation function and
+ ** see if more than one hardware map is supported. For the purpose
+ ** of this demo, we'll use an environment variable instead.
+ */
+ if(getenv("SAMEVISUAL")!=NULL){
+ gui_visual=gl_visualinfo->visual;
+ gui_colormap=gl_colormap;
+ }
+
+ fprintf(stderr,"GUI uses visual: %lx\n",XVisualIDFromVisual(gui_visual));
+
+ /* Create application shell, finally */
+ n=0;
+ XtSetArg(args[n],XmNvisual,gui_visual); n++; /* Plug in that visual */
+ XtSetArg(args[n],XmNcolormap,gui_colormap); n++; /* And that colormap */
+ toplevel=XtAppCreateShell("boilerPlate","BoilerPlate",
+ applicationShellWidgetClass,display,args,n);
+
+
+ /* Main window */
+ n=0;
+ mainwindow=XmCreateMainWindow(toplevel,"window",args,n);
+ XtManageChild(mainwindow);
+
+ /* Make a menu */
+ n=0;
+ XtSetArg(args[n],XmNmarginWidth,0); n++;
+ XtSetArg(args[n],XmNmarginHeight,0); n++;
+ menubar=XmCreateMenuBar(mainwindow,"menubar",args,2);
+ XtManageChild(menubar);
+
+ n=0;
+ pane=XmCreatePulldownMenu(menubar,"pane",args,n);
+ n=0;
+ but=XmCreatePushButton(pane,"Open",args,n);
+ XtManageChild(but);
+ but=XmCreatePushButton(pane,"Save",args,n);
+ XtManageChild(but);
+ but=XmCreatePushButton(pane,"Save As",args,n);
+ XtManageChild(but);
+ but=XmCreatePushButton(pane,"Quit",args,n);
+ XtAddCallback(but,XmNactivateCallback,byeCB,(XtPointer)NULL);
+ XtManageChild(but);
+ XtSetArg(args[0],XmNsubMenuId,pane);
+ cascade=XmCreateCascadeButton(menubar,"File",args,1);
+ XtManageChild(cascade);
+
+ n=0;
+ pane=XmCreatePulldownMenu(menubar,"pane",args,n);
+ n=0;
+ but=XmCreatePushButton(pane,"About",args,n);
+ XtAddCallback(but,XmNactivateCallback,aboutCB,(XtPointer)NULL);
+ XtManageChild(but);
+ XtSetArg(args[0],XmNsubMenuId,pane);
+ cascade=XmCreateCascadeButton(menubar,"Help",args,1);
+ XtManageChild(cascade);
+ XtVaSetValues(menubar,XmNmenuHelpWidget,cascade,NULL);
+
+ /* Main window form */
+ n=0;
+ XtSetArg(args[n],XmNmarginWidth,5); n++;
+ XtSetArg(args[n],XmNmarginHeight,5); n++;
+ mainform=XmCreateForm(mainwindow,"mainForm",args,n);
+ XtManageChild(mainform);
+
+ /* Some nice button */
+ n=0;
+ XtSetArg(args[n],XmNbottomAttachment,XmATTACH_FORM); n++;
+ XtSetArg(args[n],XmNrightAttachment,XmATTACH_FORM); n++;
+ button=XmCreatePushButton(mainform,"Bye",args,n);
+ XtAddCallback(button,XmNactivateCallback,byeCB,(XtPointer)NULL);
+ XtManageChild(button);
+
+ n=0;
+ XtSetArg(args[n],XmNleftAttachment,XmATTACH_FORM); n++;
+ XtSetArg(args[n],XmNrightAttachment,XmATTACH_FORM); n++;
+ XtSetArg(args[n],XmNbottomAttachment,XmATTACH_WIDGET); n++;
+ XtSetArg(args[n],XmNbottomWidget,button); n++;
+ XtSetArg(args[n],XmNshadowType,XmSHADOW_ETCHED_IN); n++;
+ separator=XmCreateSeparator(mainform,"separator",args,n);
+ XtManageChild(separator);
+
+ /* Main window frame */
+ n = 0;
+ XtSetArg(args[n],XmNleftAttachment,XmATTACH_FORM); n++;
+ XtSetArg(args[n],XmNrightAttachment,XmATTACH_FORM); n++;
+ XtSetArg(args[n],XmNtopAttachment,XmATTACH_FORM); n++;
+ XtSetArg(args[n],XmNbottomAttachment,XmATTACH_WIDGET); n++;
+ XtSetArg(args[n],XmNbottomWidget,separator); n++;
+ XtSetArg(args[n],XmNshadowType,XmSHADOW_IN); n++;
+ mainframe = XmCreateFrame(mainform,"mainFrame",args,n);
+ XtManageChild(mainframe);
+
+ /* GL drawing area */
+ n = 0;
+ XtSetArg(args[n],XmNcolormap,gl_colormap); n++;
+ XtSetArg(args[n],GLwNvisualInfo,gl_visualinfo); n++;
+ XtSetArg(args[n],GLwNinstallColormap,True); n++;
+ XtSetArg(args[n],XmNtraversalOn,True); n++;
+ XtSetArg(args[n],XmNwidth,400); n++;
+ XtSetArg(args[n],XmNheight,300); n++;
+ glwidget = GLwCreateMDrawingArea(mainframe,"glWidget",args,n);
+ XtAddCallback(glwidget,GLwNexposeCallback,(XtCallbackProc)exposeCB,(XtPointer)NULL);
+ XtAddCallback(glwidget,GLwNresizeCallback,(XtCallbackProc)resizeCB,(XtPointer)NULL);
+ XtAddCallback(glwidget,GLwNginitCallback,(XtCallbackProc)initCB,(XtPointer)NULL);
+ XtAddCallback(glwidget,GLwNinputCallback,(XtCallbackProc)inputCB,(XtPointer)NULL);
+ XtManageChild(glwidget);
+
+ /* Set into main window */
+ XmMainWindowSetAreas(mainwindow,menubar,NULL,NULL,NULL,mainform);
+ XtRealizeWidget(toplevel);
+
+ /* Loop until were done */
+ XtAppMainLoop(app_context);
+ return 0;
+ }
+
+
+/* Show visual class */
+static char* showvisualclass(int cls){
+ if(cls==TrueColor) return "TrueColor";
+ if(cls==DirectColor) return "DirectColor";
+ if(cls==PseudoColor) return "PseudoColor";
+ if(cls==StaticColor) return "StaticColor";
+ if(cls==GrayScale) return "GrayScale";
+ if(cls==StaticGray) return "StaticGray";
+ return "Unknown";
+ }
+
+
+static void exposeCB(Widget w,XtPointer client_data,GLwDrawingAreaCallbackStruct *cbs){
+ GLwDrawingAreaMakeCurrent(glwidget,glx_context);
+
+ glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
+ glMatrixMode(GL_PROJECTION);
+
+ glLoadIdentity();
+ glOrtho(-1.0,1.0,-1.0,1.0,0.0,1.0);
+
+ glMatrixMode(GL_MODELVIEW);
+
+ glLoadIdentity();
+
+ glColor3f(1.0,0.0,0.0);
+ glBegin(GL_LINE_STRIP);
+ glVertex3f(-1.0,-1.0,0.0);
+ glVertex3f( 1.0, 1.0,0.0);
+ glEnd();
+ glXSwapBuffers(display,XtWindow(glwidget));
+ }
+
+
+/* Initialize widget */
+static void initCB(Widget w,XtPointer client_data,GLwDrawingAreaCallbackStruct *cbs){
+
+ /* First, create context. We prefer direct rendering */
+ glx_context=glXCreateContext(display,gl_visualinfo,0,TRUE);
+ if(!glx_context){
+ fprintf(stderr,"Unable to create gl context\n");
+ exit(1);
+ }
+
+ /* Make it current */
+ GLwDrawingAreaMakeCurrent(glwidget,glx_context);
+
+ /* Set a viewport */
+ glViewport(0,0,cbs->width,cbs->height);
+
+ /* You might want to do a lot more here ... */
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LEQUAL);
+ glClearColor(1.0,1.0,1.0,1.0);
+ glClearDepth(1.0);
+
+
+ }
+
+
+/* Widget changed size, so adjust txform */
+static void resizeCB(Widget w,XtPointer client_data,GLwDrawingAreaCallbackStruct *cbs){
+ GLwDrawingAreaMakeCurrent(glwidget,glx_context);
+ glViewport(0,0,cbs->width,cbs->height);
+
+ /* blablabla */
+ }
+
+
+/* Boilerplate event handling */
+static void inputCB(Widget w,XtPointer client_data,GLwDrawingAreaCallbackStruct *cbs){
+ switch(cbs->event->type){
+ case ButtonPress:
+ switch(cbs->event->xbutton.button){
+ case Button1: fprintf(stderr,"Pressed 1\n"); break;
+ case Button2: fprintf(stderr,"Pressed 2\n"); break;
+ case Button3: fprintf(stderr,"Pressed 3\n"); break;
+ }
+ break;
+ case ButtonRelease:
+ switch(cbs->event->xbutton.button){
+ case Button1: fprintf(stderr,"Released 1\n"); break;
+ case Button2: fprintf(stderr,"Released 2\n"); break;
+ case Button3: fprintf(stderr,"Released 3\n"); break;
+ }
+ break;
+ case MotionNotify:
+ fprintf(stderr,"Moved mouse to (%d %d)\n",
+ cbs->event->xbutton.x,
+ cbs->event->xbutton.y);
+ break;
+ }
+ }
+
+
+/* Hasta la vista, baby */
+static void byeCB(Widget w,XtPointer client_data,XtPointer call_data){
+ exit(0);
+ }
+
+
+/* Pop informative panel */
+static void aboutCB(Widget w,XtPointer client_data,XtPointer call_data){
+ Arg args[10];
+ XmString str;
+ Widget box;
+ str=XmStringCreateLtoR("Boilerplate Mixed Model Programming Example\n\n (C) 1996 Jeroen van der Zijp \n\n [email protected]",XmSTRING_DEFAULT_CHARSET);
+ XtSetArg(args[0],XmNnoResize,True);
+ XtSetArg(args[1],XmNautoUnmanage,True);
+ XtSetArg(args[2],XmNmessageString,str);
+ XtSetArg(args[3],XmNdefaultPosition,False);
+ box=XmCreateInformationDialog(toplevel,"About Boilerplate",args,4);
+ XtManageChild(box);
+ XtUnmanageChild(XmMessageBoxGetChild(box,XmDIALOG_HELP_BUTTON));
+ XtUnmanageChild(XmMessageBoxGetChild(box,XmDIALOG_CANCEL_BUTTON));
+ XmStringFree(str);
+ }
diff --git a/src/glw/depend b/src/glw/depend
new file mode 100644
index 00000000000..e0c23de53d4
--- /dev/null
+++ b/src/glw/depend
@@ -0,0 +1,6 @@
+# DO NOT DELETE
+
+GLwDrawA.o: ../include/GL/glx.h ../include/GL/gl.h ../include/GL/xmesa.h
+GLwDrawA.o: GLwDrawAP.h GLwDrawA.h
+GLwMDrawA.o: GLwDrawA.c ../include/GL/glx.h ../include/GL/gl.h
+GLwMDrawA.o: ../include/GL/xmesa.h GLwDrawAP.h GLwDrawA.h GLwMDrawAP.h