[comp.windows.x] problem with colormaps.

lteyssie@POLYSLO.CALPOLY.EDU (Luke Teyssier) (11/16/89)

I am running X11R3 on a sun3/60 usin awm.

I have been fighting with a colormap problem for about a week. This is a program
which will draw an octahedron using backface removal and lighting 
techniques.  The shape rotates in the x, y, and z axes when you move the
scrollbars, and lights the object according to the location of the point light
source, the ambient light intensity, and the reflectivity of the object.
	My problem is this: when I try to set an entry in the colormap to an
rgb value and then set that to the foreground color for drawing my object,
I seem to get the default color no matter what rgb value I set.  In 
wireframe.c I actually set the colormap cell for all sides of the object to 
full red, I still get what seems to be the old colors for those colormap cells.
Is it that my colormap is not getting installed into the window?
So, my question is: why won't my rgb value get stored in the colormap, and
what do I need to do to make it work properly?

The interesting files progress as follows:
	Jump.c 		- handles the scrollbar callback. 
	wireframe.c - draws the object.
	math.c		- does some of the math needed to draw the object.
	openPane.c 	- opens a data structure called pane which stores some 
				information about the window. also sets up the colormap for use.

the error probably occurs in wireframe.c or openPane.c

A shar file of the application follows. Thanks for your help. If you cannot 
duplicate my problem, pleas let me know, as that will be useful. 

Luke Teyssier - lteyssie@polyslo.calpoly.edu

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	assign5
# This archive created: Wed Nov 15 22:44:12 1989
export PATH; PATH=/bin:$PATH
if test ! -d 'assign5'
then
	mkdir 'assign5'
fi
cd 'assign5'
if test -f 'save_restore'
then
	echo shar: will not over-write existing file "'save_restore'"
else
sed 's/^+//' << \SHAR_EOF > 'save_restore'
+
+`developarea`
+`boxWidgetClass`
+`toplevel`
+XtNwidth	`833`
+XtNheight	`539`
+XtNresizable	`False`
+WidgetType	`box`
+IncludeFile	`Box`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNborderWidth	`2`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+XtNy	`4`
+XtNx	`4`
+EndOfWidget
+
+`drawingcore`
+`widgetClass`
+`developarea`
+XtNcursor	`34`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`False`
+XtNhorizDistance	`4`
+XtNvertDistance	`4`
+XtNborderWidth	`1`
+XtNwidth	`506`
+XtNheight	`502`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+XtNy	`4`
+XtNx	`4`
+WidgetType	`core`
+IncludeFile	`Core`
+EndOfWidget
+
+`form24`
+`formWidgetClass`
+`developarea`
+XtNwidth	`311`
+XtNheight	`395`
+WidgetType	`form`
+IncludeFile	`Form`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`False`
+XtNhorizDistance	`549`
+XtNvertDistance	`15`
+XtNborderWidth	`1`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+XtNy	`4`
+XtNx	`516`
+EndOfWidget
+
+`quitcommand`
+`commandWidgetClass`
+`developarea`
+XtNlabel	`Quit`
+XtNsensitive	`True`
+WidgetType	`command`
+IncludeFile	`Command`
+XtNjustify	`XtJustifyCenter`
+XtNfont	`9x15`
+XtNresize	`False`
+XtNforeground	`XtDefaultForeground`
+XtNy	`402`
+XtNx	`514`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`True`
+XtNhorizDistance	`680`
+XtNvertDistance	`420`
+XtNborderWidth	`1`
+XtNwidth	`80`
+XtNheight	`40`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+EndOfWidget
+
+`label25`
+`labelWidgetClass`
+`form24`
+XtNjustify	`XtJustifyCenter`
+XtNfont	`9x15`
+XtNlabel	` x       y       z   distance `
+XtNresize	`True`
+XtNforeground	`XtDefaultForeground`
+XtNy	`11`
+XtNx	`17`
+WidgetType	`label`
+IncludeFile	`Label`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`True`
+XtNhorizDistance	`17`
+XtNvertDistance	`11`
+XtNborderWidth	`1`
+XtNwidth	`278`
+XtNheight	`17`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+EndOfWidget
+
+`scrollbar26`
+`scrollbarWidgetClass`
+`form24`
+XtNorientation	`XtorientVertical`
+XtNthickness	`20`
+XtNlength	`200`
+XtNwidth	`20`
+XtNheight	`311`
+XtNforeground	`XtDefaultForeground`
+WidgetType	`scrollbar`
+IncludeFile	`Scroll`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`True`
+XtNhorizDistance	`26`
+XtNvertDistance	`41`
+XtNborderWidth	`1`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+XtNy	`41`
+XtNx	`26`
+EndOfWidget
+
+`scrollbar27`
+`scrollbarWidgetClass`
+`form24`
+XtNorientation	`XtorientVertical`
+XtNthickness	`20`
+XtNlength	`200`
+XtNwidth	`20`
+XtNheight	`311`
+XtNforeground	`XtDefaultForeground`
+WidgetType	`scrollbar`
+IncludeFile	`Scroll`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`True`
+XtNhorizDistance	`99`
+XtNvertDistance	`39`
+XtNborderWidth	`1`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+XtNy	`39`
+XtNx	`99`
+EndOfWidget
+
+`scrollbar28`
+`scrollbarWidgetClass`
+`form24`
+XtNorientation	`XtorientVertical`
+XtNthickness	`20`
+XtNlength	`200`
+XtNwidth	`20`
+XtNheight	`311`
+XtNforeground	`XtDefaultForeground`
+WidgetType	`scrollbar`
+IncludeFile	`Scroll`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`True`
+XtNhorizDistance	`171`
+XtNvertDistance	`41`
+XtNborderWidth	`1`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+XtNy	`41`
+XtNx	`171`
+EndOfWidget
+
+`scrollbar29`
+`scrollbarWidgetClass`
+`form24`
+XtNorientation	`XtorientVertical`
+XtNthickness	`20`
+XtNlength	`200`
+XtNwidth	`20`
+XtNheight	`311`
+XtNforeground	`XtDefaultForeground`
+WidgetType	`scrollbar`
+IncludeFile	`Scroll`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`True`
+XtNhorizDistance	`251`
+XtNvertDistance	`39`
+XtNborderWidth	`1`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+XtNy	`39`
+XtNx	`251`
+EndOfWidget
+
+`text30`
+`asciiStringWidgetClass`
+`form24`
+XtNeditType	`XttextEdit`
+XtNlength	`10`
+XtNstring	`0.00`
+XtNwidth	`53`
+WidgetType	`text`
+IncludeFile	`AsciiText`
+XtNfont	`9x15`
+XtNlabel	`label`
+XtNresize	`False`
+XtNforeground	`XtDefaultForeground`
+XtNy	`361`
+XtNx	`10`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`True`
+XtNhorizDistance	`10`
+XtNvertDistance	`361`
+XtNborderWidth	`1`
+XtNheight	`23`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+EndOfWidget
+
+`text31`
+`asciiStringWidgetClass`
+`form24`
+XtNeditType	`XttextEdit`
+XtNlength	`10`
+XtNstring	`0.00`
+XtNwidth	`53`
+WidgetType	`text`
+IncludeFile	`AsciiText`
+XtNfont	`9x15`
+XtNlabel	`label`
+XtNresize	`False`
+XtNforeground	`XtDefaultForeground`
+XtNy	`361`
+XtNx	`91`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`True`
+XtNhorizDistance	`91`
+XtNvertDistance	`361`
+XtNborderWidth	`1`
+XtNheight	`23`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+EndOfWidget
+
+`text32`
+`asciiStringWidgetClass`
+`form24`
+XtNeditType	`XttextEdit`
+XtNlength	`10`
+XtNstring	`0.00`
+XtNwidth	`53`
+WidgetType	`text`
+IncludeFile	`AsciiText`
+XtNfont	`9x15`
+XtNlabel	`label`
+XtNresize	`False`
+XtNforeground	`XtDefaultForeground`
+XtNy	`360`
+XtNx	`164`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`True`
+XtNhorizDistance	`164`
+XtNvertDistance	`360`
+XtNborderWidth	`1`
+XtNheight	`23`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+EndOfWidget
+
+`text33`
+`asciiStringWidgetClass`
+`form24`
+XtNeditType	`XttextEdit`
+XtNlength	`10`
+XtNstring	`0.00`
+XtNwidth	`53`
+WidgetType	`text`
+IncludeFile	`AsciiText`
+XtNfont	`9x15`
+XtNlabel	`label`
+XtNresize	`False`
+XtNforeground	`XtDefaultForeground`
+XtNy	`358`
+XtNx	`234`
+XtNright	`XtChainLeft`
+XtNleft	`XtChainLeft`
+XtNbottom	`XtChainTop`
+XtNtop	`XtChainTop`
+XtNresizable	`True`
+XtNhorizDistance	`234`
+XtNvertDistance	`358`
+XtNborderWidth	`1`
+XtNheight	`23`
+XtNmappedWhenManaged	`True`
+XtNbackground	`XtDefaultBackground`
+EndOfWidget
SHAR_EOF
fi # end of overwriting check
if test -f 'readme'
then
	echo shar: will not over-write existing file "'readme'"
else
sed 's/^+//' << \SHAR_EOF > 'readme'
+
+The bug is probably in wireframe.c or openPane.c
+Even though I set the color to pure red, I still get shades of green and 
+yellow.
+This is a standard shar file format, and the makefile should work properly
+for a sun 3/60 running X11R3.
+
+luke - lteyssie@polyslo.calpoly.edu
+
SHAR_EOF
fi # end of overwriting check
if test ! -d 'include'
then
	mkdir 'include'
fi
cd 'include'
if test -f 'assign5lists.h'
then
	echo shar: will not over-write existing file "'assign5lists.h'"
else
sed 's/^+//' << \SHAR_EOF > 'assign5lists.h'
+#ifndef XXXScrollList
+#define XXXScrollList
+static XtCallbackRec ScrollList[] = {
+  {  (XtCallbackProc)Scroll, NULL  },
+  {  NULL, NULL  }
+};
+#endif
+
+#ifndef XXXJumpList
+#define XXXJumpList
+static XtCallbackRec JumpList[] = {
+  {  (XtCallbackProc)Jump, NULL  },
+  {  NULL, NULL  }
+};
+#endif
+
+#ifndef XXXXcleanupList
+#define XXXXcleanupList
+static XtCallbackRec XcleanupList[] = {
+  {  (XtCallbackProc)Xcleanup, NULL  },
+  {  NULL, NULL  }
+};
+#endif
SHAR_EOF
fi # end of overwriting check
if test -f 'assign5.h'
then
	echo shar: will not over-write existing file "'assign5.h'"
else
sed 's/^+//' << \SHAR_EOF > 'assign5.h'
+#include <stdio.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/cursorfont.h>
+#include <X11/Core.h>
+#include <X11/Form.h>
+#include <X11/Label.h>
+#include <X11/Scroll.h>
+#include <X11/Command.h>
+#include <X11/Box.h>
+#include <X11/AsciiText.h>
+
+extern Winit();
+extern Xcleanup();
+extern Scroll();
+extern Jump();
+
+Widget toplevel;
+Widget developarea;
+Cursor Cursor4drawingcore;
+Widget drawingcore;
+Widget xyzdform;
+Widget xyzdlabel;
+Widget xscrollbar;
+Widget yscrollbar;
+Widget zscrollbar;
+Widget dscrollbar;
+Widget xtext;
+Widget ytext;
+Widget ztext;
+Widget dtext;
+Widget quitcommand;
SHAR_EOF
fi # end of overwriting check
if test -f 'assign5args.h'
then
	echo shar: will not over-write existing file "'assign5args.h'"
else
sed 's/^+//' << \SHAR_EOF > 'assign5args.h'
+static Arg arglistdeveloparea[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNy, (XtArgVal) 4  },
+  {  XtNheight, (XtArgVal) 558   },
+  {  XtNwidth, (XtArgVal) 833   },
+  {  XtNborderWidth, (XtArgVal) 2  },
+  {  XtNresizable, (XtArgVal) False  }
+};
+
+static Arg arglistdrawingcore[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNhorizDistance, (XtArgVal) 4  },
+  {  XtNvertDistance, (XtArgVal) 4  },
+  {  XtNheight, (XtArgVal) 502   },
+  {  XtNwidth, (XtArgVal) 506   },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNresizable, (XtArgVal) True }
+};
+
+static Arg arglistxyzdform[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNy, (XtArgVal) 4  },
+  {  XtNheight, (XtArgVal) 395   },
+  {  XtNwidth, (XtArgVal) 311   },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNresizable, (XtArgVal) False  }
+};
+
+static Arg arglistxyzdlabel[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNforeground, (XtArgVal) 1  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNresize, (XtArgVal) True  },
+  {  XtNhorizDistance, (XtArgVal) 17  },
+  {  XtNvertDistance, (XtArgVal) 11  },
+  {  XtNheight, (XtArgVal) 17   },
+  {  XtNwidth, (XtArgVal) 278   },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNlabel, (XtArgVal) " x       y       z   distance "  },
+  {  XtNjustify, (XtArgVal) XtJustifyCenter  },
+  {  XtNresizable, (XtArgVal) True  }
+};
+
+static Arg arglistxscrollbar[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNforeground, (XtArgVal) 1  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNhorizDistance, (XtArgVal) 26  },
+  {  XtNvertDistance, (XtArgVal) 41  },
+  {  XtNheight, (XtArgVal) 311   },
+  {  XtNwidth, (XtArgVal) 20   },
+  {  XtNlength, (XtArgVal) 200   },
+  {  XtNthickness, (XtArgVal) 20   },
+  {  XtNorientation, (XtArgVal) XtorientVertical  },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNscrollProc, (XtArgVal) ScrollList  },
+  {  XtNjumpProc, (XtArgVal) JumpList  },
+  {  XtNresizable, (XtArgVal) True  }
+};
+
+static Arg arglistyscrollbar[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNforeground, (XtArgVal) 1  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNhorizDistance, (XtArgVal) 99  },
+  {  XtNvertDistance, (XtArgVal) 39  },
+  {  XtNheight, (XtArgVal) 311   },
+  {  XtNwidth, (XtArgVal) 20   },
+  {  XtNlength, (XtArgVal) 200   },
+  {  XtNthickness, (XtArgVal) 20   },
+  {  XtNorientation, (XtArgVal) XtorientVertical  },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNscrollProc, (XtArgVal) ScrollList  },
+  {  XtNjumpProc, (XtArgVal) JumpList  },
+  {  XtNresizable, (XtArgVal) True  }
+};
+
+static Arg arglistzscrollbar[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNforeground, (XtArgVal) 1  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNhorizDistance, (XtArgVal) 171  },
+  {  XtNvertDistance, (XtArgVal) 41  },
+  {  XtNheight, (XtArgVal) 311   },
+  {  XtNwidth, (XtArgVal) 20   },
+  {  XtNlength, (XtArgVal) 200   },
+  {  XtNthickness, (XtArgVal) 20   },
+  {  XtNorientation, (XtArgVal) XtorientVertical  },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNscrollProc, (XtArgVal) ScrollList  },
+  {  XtNjumpProc, (XtArgVal) JumpList  },
+  {  XtNresizable, (XtArgVal) True  }
+};
+
+static Arg arglistdscrollbar[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNforeground, (XtArgVal) 1  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNhorizDistance, (XtArgVal) 251  },
+  {  XtNvertDistance, (XtArgVal) 39  },
+  {  XtNheight, (XtArgVal) 311   },
+  {  XtNwidth, (XtArgVal) 20   },
+  {  XtNlength, (XtArgVal) 200   },
+  {  XtNthickness, (XtArgVal) 20   },
+  {  XtNorientation, (XtArgVal) XtorientVertical  },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNscrollProc, (XtArgVal) ScrollList  },
+  {  XtNjumpProc, (XtArgVal) JumpList  },
+  {  XtNresizable, (XtArgVal) True  }
+};
+
+static Arg arglistxtext[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNforeground, (XtArgVal) 1  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNhorizDistance, (XtArgVal) 10  },
+  {  XtNvertDistance, (XtArgVal) 361  },
+  {  XtNheight, (XtArgVal) 23   },
+  {  XtNwidth, (XtArgVal) 53   },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNstring, (XtArgVal) "0.00"  },
+  {  XtNlength, (XtArgVal) 10  },
+  {  XtNeditType, (XtArgVal) XttextEdit  },
+  {  XtNresizable, (XtArgVal) True  }
+};
+
+static Arg arglistytext[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNforeground, (XtArgVal) 1  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNhorizDistance, (XtArgVal) 91  },
+  {  XtNvertDistance, (XtArgVal) 361  },
+  {  XtNheight, (XtArgVal) 23   },
+  {  XtNwidth, (XtArgVal) 53   },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNstring, (XtArgVal) "0.00"  },
+  {  XtNlength, (XtArgVal) 10  },
+  {  XtNeditType, (XtArgVal) XttextEdit  },
+  {  XtNresizable, (XtArgVal) True  }
+};
+
+static Arg arglistztext[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNforeground, (XtArgVal) 1  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNhorizDistance, (XtArgVal) 164  },
+  {  XtNvertDistance, (XtArgVal) 360  },
+  {  XtNheight, (XtArgVal) 23   },
+  {  XtNwidth, (XtArgVal) 53   },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNstring, (XtArgVal) "0.00"  },
+  {  XtNlength, (XtArgVal) 10  },
+  {  XtNeditType, (XtArgVal) XttextEdit  },
+  {  XtNresizable, (XtArgVal) True  }
+};
+
+static Arg arglistdtext[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNforeground, (XtArgVal) 1  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNhorizDistance, (XtArgVal) 234  },
+  {  XtNvertDistance, (XtArgVal) 358  },
+  {  XtNheight, (XtArgVal) 23   },
+  {  XtNwidth, (XtArgVal) 53   },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNstring, (XtArgVal) "0.00"  },
+  {  XtNlength, (XtArgVal) 10  },
+  {  XtNeditType, (XtArgVal) XttextEdit  },
+  {  XtNresizable, (XtArgVal) True  }
+};
+
+static Arg arglistquitcommand[] = {
+  {  NULL, (XtArgVal) NULL  },
+  {  XtNforeground, (XtArgVal) 1  },
+  {  XtNbackground, (XtArgVal) 0  },
+  {  XtNmappedWhenManaged, (XtArgVal) True  },
+  {  XtNresize, (XtArgVal) False  },
+  {  XtNsensitive, (XtArgVal) True  },
+  {  XtNhorizDistance, (XtArgVal) 680  },
+  {  XtNvertDistance, (XtArgVal) 420  },
+  {  XtNheight, (XtArgVal) 40   },
+  {  XtNwidth, (XtArgVal) 80   },
+  {  XtNborderWidth, (XtArgVal) 1  },
+  {  XtNlabel, (XtArgVal) "Quit"  },
+  {  XtNjustify, (XtArgVal) XtJustifyCenter  },
+  {  XtNcallback, (XtArgVal) XcleanupList },
+  /* Constraint resources */
+  {  XtNresizable, (XtArgVal) True  }
+};
SHAR_EOF
fi # end of overwriting check
cd ..
if test -f 'makefile'
then
	echo shar: will not over-write existing file "'makefile'"
else
sed 's/^+//' << \SHAR_EOF > 'makefile'
+TASK		= assign5
+CFLAGS 		= -g -I/usr/local/include -I./include 
+LCFLAGS		= -I/usr/local/include -I./include 
+OCFLAGS 	= -f68881 -I/usr/local/include -I./include 
+LDFLAGS		= -g -L/usr/local/lib -L. -lXaw -lXmu -lXt -lX11 -lm 
+LLDFLAGS	= -L/usr/local/lib -L. -lXaw -lXmu -lXt -lX11 -lm 
+CC = cc
+LINT = lint -ciux
+
+UserWrittenObjects = Wsetup.o Jump.o Scroll.o openPane.o wireframe.o math.o
+
+$(TASK) : $(UserWrittenObjects) $(TASK).o
+#	$(LINT) $(TASK).o $(UserWrittenObjects) $(LDFLAGS) -o $(TASK)
+	$(CC) $(TASK).o $(UserWrittenObjects) $(LDFLAGS) -o $(TASK)
+	clear
+	$(TASK) &
+
+I = include/
+
+$(TASK).o : $(TASK).c $(I)$(TASK).h $(I)$(TASK)args.h $(I)$(TASK)lists.h
+#	$(LINT) $(LCFLAGS) -c $(TASK).c
+	$(CC) $(CFLAGS) -c $(TASK).c
+
+wireframe.o : wireframe.c wireframe.h types.h
+#	$(LINT) $(LCFLAGS) -c wireframe.c
+	$(CC) $(CFLAGS) -c wireframe.c
+
+math.o : math.c math.h types.h
+#	$(LINT) $(LCFLAGS) -c math.c
+	$(CC) $(CFLAGS) -c math.c
+
+.c.o :
+#	$(LINT) $(LCFLAGS) -c $*.c
+	$(CC) $(CFLAGS) -c $*.c
SHAR_EOF
fi # end of overwriting check
if test -f 'Jump.c'
then
	echo shar: will not over-write existing file "'Jump.c'"
else
sed 's/^+//' << \SHAR_EOF > 'Jump.c'
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/cursorfont.h>
+#include <X11/AsciiText.h>
+#include <X11/Text.h>
+#include <X11/Scroll.h>
+#include "Pane.h"
+
+#define xfactor 360 
+#define yfactor 360 
+#define zfactor 360 
+#define dfactor 10
+
+extern Widget xtext;
+extern Widget ytext;
+extern Widget ztext;
+extern Widget dtext;
+extern Widget xscrollbar;
+extern Widget yscrollbar;
+extern Widget zscrollbar;
+extern Widget dscrollbar;
+extern Widget drawingcore;
+
+replaceText(w,s)
+    Widget w;
+    char *s;
+{
+    XtTextBlock text;
+    int insertPos, endPos;
+
+    text.firstPos=0;
+    text.length=strlen(s);
+    text.ptr=s;
+    text.format=FMT8BIT;
+
+    insertPos=0;
+    endPos=20;
+    XtTextReplace(w,insertPos,endPos,&text);
+    /* XtTextDisplay(w); */
+}
+
+void Jump(scrollbar,client_data,percent)
+  Widget scrollbar;
+  caddr_t client_data;
+  caddr_t percent;
+{
+    char s[80];
+	static Boolean setup=False;
+	static Pane pane;
+	static float distance;
+	static int xtheta,ytheta,ztheta;
+
+	if (setup==False){  /* do only once */
+		openPane(drawingcore,&pane);
+		XClearWindow(pane.display, pane.drawwin);
+		setup=True;
+	}
+	if (scrollbar == xscrollbar){
+		xtheta=-((*(float*)percent)*xfactor+0.5);
+		sprintf(s,"%d",-xtheta);
+   		replaceText(xtext,s);
+	}
+	if (scrollbar == yscrollbar){
+		ytheta=((*(float*)percent)*yfactor+0.5);
+		sprintf(s,"%d",ytheta);
+   		replaceText(ytext,s);
+	}
+	if (scrollbar == zscrollbar){
+		/*z=log(1.0000001-(*(float*)percent))*zfactor*-1+0.0000001;*/
+		ztheta=-((*(float*)percent)*zfactor+0.5);
+		sprintf(s,"%d",-ztheta);
+   		replaceText(ztext,s);
+	}
+	if (scrollbar == dscrollbar){
+		distance=(*(float*)percent)*dfactor;
+		sprintf(s,"%f.2",distance);
+   		replaceText(dtext,s);
+	}
+	demoTriangles(&pane,xtheta,ytheta,ztheta,distance);
+}
SHAR_EOF
fi # end of overwriting check
if test -f 'Scroll.c'
then
	echo shar: will not over-write existing file "'Scroll.c'"
else
sed 's/^+//' << \SHAR_EOF > 'Scroll.c'
+/* %W	%G */
+#include <stdio.h>
+#include <X11/Intrinsic.h>
+
+void Scroll(scrollbar,client_data,position)
+  Widget scrollbar;
+  caddr_t client_data;
+  int position;
+{
+ printf("Scroll called at %d\n", position);
+}
SHAR_EOF
fi # end of overwriting check
if test -f 'Wcleanup.c'
then
	echo shar: will not over-write existing file "'Wcleanup.c'"
else
sed 's/^+//' << \SHAR_EOF > 'Wcleanup.c'
+Xcleanup()
+{
+  printf("Xcleanup called\n");
+  exit(0); 
+}
SHAR_EOF
fi # end of overwriting check
if test -f 'Winit.c'
then
	echo shar: will not over-write existing file "'Winit.c'"
else
sed 's/^+//' << \SHAR_EOF > 'Winit.c'
+Winit()
+{
+  printf("Winit called\n");
+}
SHAR_EOF
fi # end of overwriting check
if test -f 'Wsetup.c'
then
	echo shar: will not over-write existing file "'Wsetup.c'"
else
sed 's/^+//' << \SHAR_EOF > 'Wsetup.c'
+#include <X11/Intrinsic.h>
+#include "assign5.h"
+
+XtCallbackProc BDownInDevelop()
+{
+    printf("button pressed in developarea\n");
+}
+
+void Wsetup()
+{
+    /* Default action when in window but not in a widget */
+    XtAddEventHandler(developarea,ButtonPressMask, FALSE, BDownInDevelop, NULL);
+
+  Cursor4drawingcore = XCreateFontCursor(XtDisplay(toplevel),34);
+  XDefineCursor(XtDisplay(toplevel),XtWindow(drawingcore),Cursor4drawingcore);
+
+}
+
+Winit()
+{
+  printf("Winit called\n");
+}
+Xcleanup()
+{
+  printf("Xcleanup called\n");
+  exit(0); 
+}
SHAR_EOF
fi # end of overwriting check
if test -f 'openPane.c'
then
	echo shar: will not over-write existing file "'openPane.c'"
else
sed 's/^+//' << \SHAR_EOF > 'openPane.c'
+/**********************************************************************/
+/*	           openPane.c                                               */
+/**********************************************************************/
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Intrinsic.h>
+#include <X11/Core.h>
+#include <X11/StringDefs.h>
+#include "Pane.h"
+
+#define COLORS     256
+
+/*************************************************************************/
+/*  sets up the colormap                                                 */
+/*************************************************************************/
+color_setup(pane)
+	Pane *pane;
+{
+	Colormap               defcmap, cmap;
+	Visual                *visual;
+	XColor                 color[COLORS], defcolor[COLORS];
+	unsigned long          pixel[COLORS];
+	unsigned long         *planemasks;
+	int i;
+
+	defcmap = DefaultColormap(pane->display, DefaultScreen(pane->display));
+    cmap = XCreateColormap(pane->display, pane->drawwin, pane->xwa.visual, 
+			AllocNone);
+    XAllocColorCells(pane->display, cmap, False, &planemasks, 0, pixel, COLORS);
+    for (i = 0; i < COLORS; i++) {
+      defcolor[i].pixel = pixel[i];
+      color[i].pixel = pixel[i];
+    }
+    XQueryColors(pane->display, defcmap, color, COLORS);
+    XQueryColors(pane->display, defcmap, defcolor, COLORS);
+    XStoreColors(pane->display, cmap, color, COLORS);
+    XSetWindowColormap(pane->display, pane->drawwin, cmap);
+	pane->cmap=cmap;
+}
+/**********************************************************************/
+/*	   openPane() - opens a window in the X environment.           */
+/**********************************************************************/
+openPane(w,pane)
+	Pane	*pane;
+	Widget	w;
+{
+	unsigned long	eventmask;
+	int				screen;
+	unsigned long	foregdcolor, backgdcolor;
+	unsigned long	whitepix, blackpix;
+	unsigned long	gcvmask=0;
+	XGCValues		gcvals;
+	XWindowAttributes xwa;
+
+	pane->display = XtDisplay(w);
+	pane->drawwin = XtWindow(w);
+
+	XGetWindowAttributes(pane->display,pane->drawwin,&xwa);
+	pane->width=xwa.width;
+	pane->height=xwa.height;
+	pane->xwa=xwa;
+	screen		= DefaultScreen(pane->display);
+	whitepix	= WhitePixel(pane->display, screen);
+	blackpix	= BlackPixel(pane->display, screen);
+
+	gcvals.foreground = blackpix;
+	gcvals.background = whitepix;
+	gcvmask	= GCForeground|GCBackground;
+	pane->gc	= XCreateGC(pane->display, pane->drawwin, gcvmask, &gcvals);
+
+	color_setup(pane);
+}
SHAR_EOF
fi # end of overwriting check
if test -f 'Pane.h'
then
	echo shar: will not over-write existing file "'Pane.h'"
else
sed 's/^+//' << \SHAR_EOF > 'Pane.h'
+/**********************************************************************/
+/*             pane.h                                               */
+/**********************************************************************/
+
+typedef struct{
+    Display		*display;
+	Window		drawwin;
+    GC			gc;
+	char 		*title;
+    int			width, height;
+	XWindowAttributes xwa;
+	Colormap	cmap;
+} Pane;
SHAR_EOF
fi # end of overwriting check
if test -f 'wireframe.c'
then
	echo shar: will not over-write existing file "'wireframe.c'"
else
sed 's/^+//' << \SHAR_EOF > 'wireframe.c'
+/* 
+	triangle algorithm demonstration
+
+	Written by, copyright c. 1989 Luke Teyssier 
+	for Csc 455
+	Oct 20, 1989
+
+*/
+#include <stdio.h>
+#include <math.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Intrinsic.h>
+#include <X11/Core.h>
+#include <X11/StringDefs.h>
+#include "Pane.h"
+#include "wireframe.h"
+
+/* triangle program */
+
+setfgcolor(pane,cosangle,Ia,Ip,Kd,colornum)
+	light 	Ia,Ip,Kd;
+	real	cosangle;
+	Pane 	*pane;
+	int		colornum;
+{
+	light	Itotal;
+	XColor	color;
+
+    Itotal.red   = Ia.red   * Kd.red   + Ip.red   * cosangle * Kd.red;
+    Itotal.green = Ia.green * Kd.green + Ip.green * cosangle * Kd.green;
+    Itotal.blue  = Ia.blue  * Kd.blue  + Ip.blue  * cosangle * Kd.blue;
+
+    if (Itotal.red   > 256) Itotal.red   = 256;
+    if (Itotal.green > 256) Itotal.green = 256;
+    if (Itotal.blue  > 256) Itotal.blue  = 256;
+
+    color.red   = (unsigned short) (256* 256 -1);
+/*  
+    color.red   = (unsigned short) (Itotal.red   * 256 -1);
+	color.green = (unsigned short) (Itotal.green * 256 -1);
+    color.blue  = (unsigned short) (Itotal.blue  * 256 -1);
+*/
+    color.green = (unsigned short) (0);
+    color.blue  = (unsigned short) (0);
+    color.flags = DoRed|DoGreen|DoBlue;
+	color.pixel = (unsigned long)colornum;
+    XStoreColor(pane->display,pane->cmap,&color);
+	printf("(%.3u,%.3u,%.3u)\t",color.red/256,color.green/256,color.blue/256);
+    XSetForeground(pane->display,pane->gc,colornum);
+}
+
+drawTriangle(pane,t,vertex,i)
+	Pane		*pane;
+	Triangle	t;
+	Point		*vertex;
+	int			i;
+{
+	int		x1,y1,x2,y2,x3,y3;
+	int		xscale,yscale, xoffset, yoffset;
+	real	xp1,yp1,xp2,yp2,xp3,yp3;
+	real	xu1,xu2,xu3,yu1,yu2,yu3,zu1,zu2,zu3;
+	Point	pa, pb, pc;
+	XPoint	points[3];
+	real	cosangle;
+	static 	Point Lp={0,0.707107,0.707107};	/* location of light source */
+	static	light Ia={100,100,100}, Ip={255,255,255}, Kd={0.6,0.1,0.5};	
+
+	xscale=xoffset=(pane->width)/2;
+	yscale=yoffset=(pane->height)/2;
+
+	pa=vertex[t.a];
+	pb=vertex[t.b];
+	pc=vertex[t.c];
+	xu1=pa.x; yu1=pa.y; zu1=pa.z;
+	xu2=pb.x; yu2=pb.y; zu2=pb.z;
+	xu3=pc.x; yu3=pc.y; zu3=pc.z;
+	
+	xp1=(xu1*persp_d)/(zu1+persp_d);
+	yp1=(yu1*persp_d)/(zu1+persp_d);
+	xp2=(xu2*persp_d)/(zu2+persp_d);
+	yp2=(yu2*persp_d)/(zu2+persp_d);
+	xp3=(xu3*persp_d)/(zu3+persp_d);
+	yp3=(yu3*persp_d)/(zu3+persp_d);
+
+	points[0].x=(int)(xp1*xscale)+xoffset;
+	points[1].x=(int)(xp2*xscale)+xoffset;
+	points[2].x=(int)(xp3*xscale)+xoffset;
+
+	points[0].y=yoffset-(int)(yp1*yscale);
+	points[1].y=yoffset-(int)(yp2*yscale);
+	points[2].y=yoffset-(int)(yp3*yscale);
+
+    cosangle = -(Lp.x*t.pa + Lp.y*t.pb + Lp.z*t.pc);
+	printf("cosangle %5.5f\t",cosangle);
+    if (cosangle < 0) cosangle = 0; 
+
+	setfgcolor(pane,cosangle,Ia,Ip,Kd,i+50);
+
+	XFillPolygon(pane->display, pane->drawwin, pane->gc,points,3,
+			Convex,CoordModeOrigin);
+}
+
+demoTriangles(pane,xtheta,ytheta,ztheta,distance)
+	Pane *pane;
+	int xtheta,ytheta,ztheta;
+	float distance;
+{
+	int i;
+
+		dupv(vs,vd,vertex_count);
+		rotate_list(vd,tr,vertex_count,xtheta,ytheta,ztheta);
+		for (i=0; i<vertex_count; i++)
+			vd[i].z=vd[i].z+distance;
+		XClearWindow(pane->display, pane->drawwin);	
+		for (i=0; i<triangle_count; i++){
+			if (tr[i].visible)
+				drawTriangle(pane,tr[i],vd,i);
+		}
+		printf("\n\n");
+		XFlush(pane->display);
+}
SHAR_EOF
fi # end of overwriting check
if test -f '.exrc'
then
	echo shar: will not over-write existing file "'.exrc'"
else
sed 's/^+//' << \SHAR_EOF > '.exrc'
+set notimeout
+set beautify
SHAR_EOF
fi # end of overwriting check
if test -f 'math.c'
then
	echo shar: will not over-write existing file "'math.c'"
else
sed 's/^+//' << \SHAR_EOF > 'math.c'
+#include <stdio.h>
+#include <math.h>
+#include "math.h"
+
+real det(m)
+	matrix m;
+{
+/* (x1*(y2*z3-z2*y3)) -
+   (y1*(x2*z3-z2*x3)) +
+   (z1*(x2*y3-y2*x3))	
+*/
+	return ((m[0][0]*(m[1][1]*m[2][2]-m[2][1]*m[1][2])) -
+	       (m[1][0]*(m[0][1]*m[2][2]-m[2][1]*m[0][2])) +
+	       (m[2][0]*(m[0][1]*m[1][2]-m[1][1]*m[0][2])) );
+}
+
+setup(A,B,C)
+	matrix A,B,C;
+{
+	A[0][0]=A[0][1]=A[0][2]=1.0;
+	B[1][0]=B[1][1]=B[1][2]=1.0;
+	C[2][0]=C[2][1]=C[2][2]=1.0;
+}
+
+/* duplicate vertex list v1 into v2 */
+dupv(v1,v2,count)
+	Point *v1,*v2;
+	int count;
+{
+	int i;
+
+	for(i=0;i<count;i++)
+		v2[i]=v1[i];
+}
+
+/* t is a triangle, v is a pointer to the vertex list */
+/* call once for each triangle */
+copy(t,v,a,b,c,d)
+	Triangle t;
+	Point *v;
+	matrix a,b,c,d;
+{
+	int i;
+	Point p[3];
+
+	p[0]=v[t.a];
+	p[1]=v[t.b];
+	p[2]=v[t.c];
+	for(i=0;i<3;i++){
+		b[0][i]=c[0][i]=d[0][i]=p[i].x;	
+		a[1][i]=c[1][i]=d[1][i]=p[i].y;	
+		a[2][i]=b[2][i]=d[2][i]=p[i].z;	
+	}
+}
+rotatex(v,vcount,theta)
+	Point *v;
+	int theta;
+	int vcount;
+{
+	int i;
+	real c,s,x,y,z;
+
+	c=cos((double)((PI*theta)/180.0)); 
+	s=sin((double)((PI*theta)/180.0)); 
+	for(i=0;i<vcount;i++){
+		y=v[i].y; z=v[i].z;
+		v[i].y=y*c-z*s;
+		v[i].z=y*s+z*c;
+	}
+}
+rotatey(v,vcount,theta)
+	Point *v;
+	int theta;
+	int vcount;
+{
+	int i;
+	real c,s,x,y,z;
+
+	c=cos((double)((PI*theta)/180.0)); 
+	s=sin((double)((PI*theta)/180.0)); 
+	for(i=0;i<vcount;i++){
+		x=v[i].x; z=v[i].z;
+		v[i].x=x*c-z*s;
+		v[i].z=x*s+z*c;
+	}
+}
+rotatez(v,vcount,theta)
+	Point *v;
+	int theta;
+	int vcount;
+{
+	int i;
+	real c,s,x,y,z;
+
+	c=cos((double)((PI*theta)/180.0)); 
+	s=sin((double)((PI*theta)/180.0)); 
+	for(i=0;i<vcount;i++){
+		x=v[i].x; y=v[i].y;
+		v[i].x=x*c-y*s;
+		v[i].y=x*s+y*c;
+	}
+}
+
+vis(tr,vertex,a,b,c,d)
+	matrix a,b,c,d;
+	Triangle *tr;
+	Point *vertex;
+{
+	int i;
+	real pa,pb,pc,pd,m;
+
+	for (i=0;i<triangle_count;i++){
+		copy(tr[i],vertex,a,b,c,d);
+		pa=det(a); pb=det(b); pc=det(c); pd=det(d);
+		m = sqrt(pa*pa+pb*pb+pc*pc);
+		tr[i].pa=pa/m;
+		tr[i].pb=pb/m;
+		tr[i].pc=pc/m;
+		tr[i].pd=pd/m;
+		tr[i].visible=(-(persp_d*pc)-pd)>0;
+	}
+}
+rotate_list(vd,tr,vcount,xtheta,ytheta,ztheta)
+	Point *vd;
+	int vcount,xtheta,ytheta,ztheta;
+	Triangle *tr;
+{
+	matrix a,b,c,d;
+
+	setup(a,b,c);
+	rotatex(vd,vcount,xtheta);
+	rotatey(vd,vcount,ytheta);
+	rotatez(vd,vcount,ztheta);
+	vis(tr,vd,a,b,c,d);
+}
+/*
+main()
+{
+	matrix a,b,c,d;
+	int i,xtheta=180,ytheta=180,ztheta=180;
+
+	setup(a,b,c);
+	vis(tr,vs,a,b,c,d);
+	rotate_list(vs,vd,vcount,xtheta,ytheta,ztheta);
+	vis(tr,vd,a,b,c,d);
+}
+*/
SHAR_EOF
fi # end of overwriting check
if test -f 'wireframe.h'
then
	echo shar: will not over-write existing file "'wireframe.h'"
else
sed 's/^+//' << \SHAR_EOF > 'wireframe.h'
+/* wireframe.h */
+#include "types.h"
+
+extern rotate_list();
+
+Triangle tr[]={ 
+	{1,3,4,0,0,0,0},
+	{2,4,3,0,0,0,0},
+	{1,5,3,0,0,0,0},
+	{2,3,5,0,0,0,0},
+	{1,4,0,0,0,0,0},
+	{0,4,2,0,0,0,0},
+	{2,5,0,0,0,0,0},
+    {1,0,5,0,0,0,0}
+ };
+
+int zlist[]={0,0,0,0,0,-1,1};
+Point vs[]={ 
+	{ 0,  1,  0},
+	{ 1,  0,  0},
+	{-1,  0,  0},
+	{ 0, -1,  0},
+	{ 0,  0, -1},
+	{ 0,  0,  1} };
+
+Point vd[]={ 
+	{ 0,  1,  0},
+	{ 1,  0,  0},
+	{-1,  0,  0},
+	{ 0, -1,  0},
+	{ 0,  0, -1},
+	{ 0,  0,  1} };
SHAR_EOF
fi # end of overwriting check
if test -f 'instructions'
then
	echo shar: will not over-write existing file "'instructions'"
else
sed 's/^+//' << \SHAR_EOF > 'instructions'
+    Instructions for viewing perspective program written by 
+        Luke Teyssier
+        Csc 455
+        1 November 1989
+
+the file in your mailbox was created with shar. To unpackage the file and 
+run the program:
+	1. Login to a sun
+	2. Start X windows by typing 'x'
+	3. In a text window type mail
+	4. save the shar file in a temporary file called temp
+	5. edit the file, type 'vi temp'
+	6. Remove everything above the #! /bin/sh line.
+	7. Save the resulting text.
+	8. Execute the file with /bin/sh (not csh) to create the directory 
+		Rotations:  type 'source temp'
+	9. 'cd Rotations'
+	10. 'make'
+	11. use the scroll bars to effect the rotations.
+
+Luke Teyssier (lteyssie)  1 November 1989
SHAR_EOF
fi # end of overwriting check
if test -f 'math.h'
then
	echo shar: will not over-write existing file "'math.h'"
else
sed 's/^+//' << \SHAR_EOF > 'math.h'
+#include "types.h"
+typedef real matrix[3][3];
+extern Triangle tr[];
+extern Point vs[];
+#define PI	3.1415926535897932384
SHAR_EOF
fi # end of overwriting check
if test -f '.c'
then
	echo shar: will not over-write existing file "'.c'"
else
sed 's/^+//' << \SHAR_EOF > '.c'
SHAR_EOF
fi # end of overwriting check
if test -f 'types.h'
then
	echo shar: will not over-write existing file "'types.h'"
else
sed 's/^+//' << \SHAR_EOF > 'types.h'
+#define persp_d 4.0
+#define real double 
+#define vertex_count 6
+#define triangle_count 8 /* should be 8 */
+#define Boolean int
+
+typedef struct {
+	real x,y,z;
+} Point;
+
+typedef struct {
+	int a,b,c;
+	real pa,pb,pc,pd;
+	Boolean visible;
+} Triangle;
+
+typedef struct {
+	float red,green,blue;
+} light;
SHAR_EOF
fi # end of overwriting check
if test -f 'math.bak'
then
	echo shar: will not over-write existing file "'math.bak'"
else
sed 's/^+//' << \SHAR_EOF > 'math.bak'
+#include <stdio.h>
+#include <math.h>
+#include "math.h"
+
+typedef float matrix[3][3];
+matrix m={
+	{0,1,2},
+	{3,4,5},
+	{6,7,8} };
+
+float det(m)
+	matrix m;
+{
+/* (x1*(y2*z3-z2*y3)) -
+   (y1*(x2*z3-z2*x3)) +
+   (z1*(x2*y3-y2*x3))	
+*/
+	return ((m[0][0]*(m[1][1]*m[2][2]-m[2][1]*m[1][2])) -
+	       (m[1][0]*(m[0][1]*m[2][2]-m[2][1]*m[0][2])) +
+	       (m[2][0]*(m[0][1]*m[1][2]-m[1][1]*m[0][2])) );
+}
+
+setup(A,B,C)
+	matrix A,B,C;
+{
+	A[0][0]=A[0][1]=A[0][2]=1;
+	B[1][0]=B[1][1]=B[1][2]=1;
+	C[2][0]=C[2][1]=C[2][2]=1;
+}
+dupv(v1,v2,count)
+	Point *v1,*v2;
+	int count;
+/* duplicate vertex list v1 into v2 */
+{
+	int i;
+
+	for(i=0;i<count;i++)
+		v2[i]=v1[i];
+}
+copy(t,v,a,b,c,d)
+	Triangle t;
+	Point *v;
+	matrix a,b,c,d;
+/* t is a triangle, v is a pointer to the vertex list */
+/* call once for each triangle */
+{
+	int i;
+	Point p[3];
+
+	p[0]=v[t.a];
+	p[1]=v[t.b];
+	p[2]=v[t.c];
+	for(i=0;i<3;i++){
+		b[0][i]=c[0][i]=d[0][i]=p[i].x;	
+		a[1][i]=c[1][i]=d[1][i]=p[i].y;	
+		a[2][i]=b[2][i]=d[2][i]=p[i].z;	
+	}
+}
+rotatez(v,theta)
+	Point *v;
+	int theta;
+{
+	int i;
+	float c,s,x,y,z;
+
+	c=cos((double)((pi*theta)/180)); 
+	s=sin((double)((pi*theta)/180)); 
+	for(i=0;i<vcount;i++){
+		x=v[i].x; y=v[i].y; z=v[i].z;
+		v[i].x=x*c-y*s;
+		v[i].y=x*s+y*c;
+		v[i].z=z;
+	}
+}
+
+vis(tr,vertex,a,b,c,d)
+	matrix a,b,c,d;
+	Triangle *tr;
+	Point *vertex;
+{
+	int i;
+	real pc,pd;
+
+	for (i=0;i<tcount;i++){
+		copy(tr[i],vertex,a,b,c,d);
+		tr[i].pa=det(a);
+		tr[i].pb=det(b);
+		tr[i].pc=pc=det(c);
+		tr[i].pd=pd=det(d);
+		tr[i].visible=((persp_d*pc+pd)>0);
+		printf("t%d ",i);
+		if (tr[i].visible==1) printf("visible");
+		printf("\n");
+	}
+}
+rotate_list(vs,vd,vcount,xtheta,ytheta,ztheta)
+	Point *vs,vd;
+	int vcount,xtheta,ytheta,ztheta;
+{
+	dupv(vs,vd,vcount);
+	rotatez(vd,ztheta,vcount);
+	/*rotatey(vd,ytheta,vcount);
+	rotatex(vd,xtheta,vcount);
+	demoTriangle(pane);
+	*/
+}
+main()
+{
+	matrix a,b,c,d;
+	int i,xtheta=180,ytheta=180,ztheta=180;
+
+	setup(a,b,c);
+	vis(tr,vs,a,b,c,d);
+	rotate_list(vs,vd,vcount,xtheta,ytheta,ztheta);
+/*	vis(tr,vs,a,b,c,d);
+	rotatez(vs,ztheta,vcount);
+	vis(tr,vs,a,b,c,d);
+*/
+	vis(tr,vd,a,b,c,d);
+}
SHAR_EOF
fi # end of overwriting check
if test -f 'assign5.c'
then
	echo shar: will not over-write existing file "'assign5.c'"
else
sed 's/^+//' << \SHAR_EOF > 'assign5.c'
+/***********************************************************
+
+     APPLICATION:  assign4
+
+     Comments to user
+
+***********************************************************/
+
+#include "assign5.h"
+#include "assign5lists.h"
+#include "assign5args.h"
+
+main(argc, argv)
+  unsigned int argc;
+  char **argv;
+{
+  Arg args[1];
+  int scr;
+
+  toplevel = XtInitialize(argv[0], "TopLevel", 0, 0, &argc, argv);
+  scr = DefaultScreen(XtDisplay(toplevel));
+
+    XtSetArg(arglistxyzdlabel[0], XtNfont, XLoadQueryFont(XtDisplay(toplevel), "9x15"));
+    XtSetArg(arglistxtext[0], XtNfont, XLoadQueryFont(XtDisplay(toplevel), "9x15"));
+    XtSetArg(arglistytext[0], XtNfont, XLoadQueryFont(XtDisplay(toplevel), "9x15"));
+    XtSetArg(arglistztext[0], XtNfont, XLoadQueryFont(XtDisplay(toplevel), "9x15"));
+    XtSetArg(arglistdtext[0], XtNfont, XLoadQueryFont(XtDisplay(toplevel), "9x15"));
+    XtSetArg(arglistquitcommand[0], XtNfont, XLoadQueryFont(XtDisplay(toplevel), "9x15"));
+
+  developarea = XtCreateManagedWidget(
+                                    "developarea",
+                                    boxWidgetClass,
+                                    toplevel,
+                                    arglistdeveloparea,
+                                    XtNumber(arglistdeveloparea));
+  drawingcore = XtCreateManagedWidget(
+                                    "drawingcore",
+                                    widgetClass,
+                                    developarea,
+                                    arglistdrawingcore,
+                                    XtNumber(arglistdrawingcore));
+  xyzdform = XtCreateManagedWidget(
+                                    "xyzdform",
+                                    formWidgetClass,
+                                    developarea,
+                                    arglistxyzdform,
+                                    XtNumber(arglistxyzdform));
+  xyzdlabel = XtCreateManagedWidget(
+                                    "xyzdlabel",
+                                    labelWidgetClass,
+                                    xyzdform,
+                                    arglistxyzdlabel,
+                                    XtNumber(arglistxyzdlabel));
+  xscrollbar = XtCreateManagedWidget(
+                                    "xscrollbar",
+                                    scrollbarWidgetClass,
+                                    xyzdform,
+                                    arglistxscrollbar,
+                                    XtNumber(arglistxscrollbar));
+  yscrollbar = XtCreateManagedWidget(
+                                    "yscrollbar",
+                                    scrollbarWidgetClass,
+                                    xyzdform,
+                                    arglistyscrollbar,
+                                    XtNumber(arglistyscrollbar));
+  zscrollbar = XtCreateManagedWidget(
+                                    "zscrollbar",
+                                    scrollbarWidgetClass,
+                                    xyzdform,
+                                    arglistzscrollbar,
+                                    XtNumber(arglistzscrollbar));
+  dscrollbar = XtCreateManagedWidget(
+                                    "dscrollbar",
+                                    scrollbarWidgetClass,
+                                    xyzdform,
+                                    arglistdscrollbar,
+                                    XtNumber(arglistdscrollbar));
+  xtext = XtCreateManagedWidget(
+                                    "xtext",
+                                    asciiStringWidgetClass,
+                                    xyzdform,
+                                    arglistxtext,
+                                    XtNumber(arglistxtext));
+  ytext = XtCreateManagedWidget(
+                                    "ytext",
+                                    asciiStringWidgetClass,
+                                    xyzdform,
+                                    arglistytext,
+                                    XtNumber(arglistytext));
+  ztext = XtCreateManagedWidget(
+                                    "ztext",
+                                    asciiStringWidgetClass,
+                                    xyzdform,
+                                    arglistztext,
+                                    XtNumber(arglistztext));
+  dtext = XtCreateManagedWidget(
+                                    "dtext",
+                                    asciiStringWidgetClass,
+                                    xyzdform,
+                                    arglistdtext,
+                                    XtNumber(arglistdtext));
+  quitcommand = XtCreateManagedWidget(
+                                    "quitcommand",
+                                    commandWidgetClass,
+                                    developarea,
+                                    arglistquitcommand,
+                                    XtNumber(arglistquitcommand));
+  Winit();
+  XtRealizeWidget(toplevel);
+  Wsetup();
+  XtMainLoop();
+}
SHAR_EOF
fi # end of overwriting check
if test -f 'wireframe.bak'
then
	echo shar: will not over-write existing file "'wireframe.bak'"
else
sed 's/^+//' << \SHAR_EOF > 'wireframe.bak'
+/* 
+	triangle algorithm demonstration
+
+	Written by, copyright c. 1989 Luke Teyssier 
+	for Csc 455
+	Oct 20, 1989
+
+*/
+#include <stdio.h>
+#include <math.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Intrinsic.h>
+#include <X11/Core.h>
+#include <X11/StringDefs.h>
+#include "Pane.h"
+#include "wireframe.h"
+
+/* triangle program */
+
+DrawLine(pane,xu1,yu1,zu1,xu2,yu2,zu2)
+	Pane *pane;
+	real xu1,yu1,zu1,xu2,yu2,zu2;
+{
+	int x1,y1,x2,y2;
+	int xscale,yscale, xoffset, yoffset;
+	real xp1,yp1,xp2,yp2;
+
+	xscale=xoffset=(pane->width)/2;
+	yscale=yoffset=(pane->height)/2;
+	
+	xp1=(xu1*persp_d)/(zu1+persp_d);
+	yp1=(yu1*persp_d)/(zu1+persp_d);
+	xp2=(xu2*persp_d)/(zu2+persp_d);
+	yp2=(yu2*persp_d)/(zu2+persp_d);
+
+	x1=(int)(xp1*xscale)+xoffset;
+	x2=(int)(xp2*xscale)+xoffset;
+	y1=yoffset-(int)(yp1*yscale);
+	y2=yoffset-(int)(yp2*yscale);
+	/*printf("line from (%d,%d) to (%d,%d)\n",x1,y1,x2,y2);*/
+	XDrawLine(pane->display, pane->drawwin, pane->gc,x1,y1,x2,y2);
+}
+
+drawTriangle(pane,t,vertex)
+	Pane *pane;
+	Triangle t;
+	Point *vertex;
+{
+	Point pa, pb, pc;
+
+	pa=vertex[t.a];
+	pb=vertex[t.b];
+	pc=vertex[t.c];
+	DrawLine(pane,pa.x, pa.y, pa.z, pb.x, pb.y, pb.z); 
+	DrawLine(pane,pb.x, pb.y, pb.z, pc.x, pc.y, pc.z); 
+	DrawLine(pane,pc.x, pc.y, pc.z, pa.x, pa.y, pa.z); 
+}
+
+demoTriangles(pane,xtheta,ytheta,ztheta,distance)
+	Pane *pane;
+	int xtheta,ytheta,ztheta;
+	float distance;
+{
+	int i;
+
+		dupv(vs,vd,vertex_count);
+		rotate_list(vd,tr,vertex_count,xtheta,ytheta,ztheta);
+		for (i=0; i<vertex_count; i++)
+			vd[i].z=vd[i].z+distance;
+		XClearWindow(pane->display, pane->drawwin);	
+		for (i=0; i<triangle_count; i++){
+			if (tr[i].visible)
+				drawTriangle(pane,tr[i],vd);
+		}
+		XFlush(pane->display);
+}
SHAR_EOF
fi # end of overwriting check
if test -f 'color.h'
then
	echo shar: will not over-write existing file "'color.h'"
else
sed 's/^+//' << \SHAR_EOF > 'color.h'
+
+#define COLORS     256
+
+light Ia={100,100,100}, Ip={255,255,255}, Kd={0.6,0.1,0.5};
SHAR_EOF
fi # end of overwriting check
cd ..
#	End of shell archive
exit 0

mouse@LARRY.MCRCIM.MCGILL.EDU (der Mouse) (11/18/89)

> I am running X11R3 on a sun3/60 usin awm.

> I have been fighting with a colormap problem for about a week. This
> is a program which [uses color, but isn't seeing colors on the
> screen].

Your problem is that you're being a good client.

Now that I have your attention....

You are doing the correct thing and calling XSetWindowColormap.
However, awm is not being a good window manager; it's ignoring the
window colormaps [%].  If you had done the wrong thing and called
XInstallColormap directly, it would have worked for you (in that you
would have seen your colors on the screen - I hesitate to imply that
doing this would make it completely working, because it would be
non-colormap-compliant in the ICCCM sense).

[%] I feel sure of this because I tried it here and it did this.

You have only a few choices.  Here are the ones that come to mind.

1) Switch to a colormap-compliant window manager.
2) Call XInstallColormap yourself and accept that this is not correct
   and will not work right when you eventually do use a compliant
   window manager (or someone else runs your program under one).
3) Allocate the colors out of the default colormap.
4) Put up with getting the wrong colors.

I assume we can ignore option 4.  Option 1 is the best solution, but
presumably you use awm because either there's no choice or you like it,
and in either case switching is undesirable.  Option 3 is reasonable if
you don't need very many colors, but from your description of the
program you need lots.  Option 2 is acceptable, particularly if you put
it under the control of something user-configurable (command-line
option, resource database flag, something like that) and make the
default be the compliant behavior (what you have now).

I've chosen a mix of 1 and 2.  I made my window manager handle window
colormaps properly, but I've also added an option to the program I had
which turned up this problem to make it install the map itself, for
others' use.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu