butler@BRL.MIL ("Lee A. Butler") (03/09/90)
This evening I sat down at the IRIS to start learning to use the graphics library. On page 1-5 of the "Graphics Library Programming Guide" is the program "red.c" which I typed in verbatim: #include <gl/gl.h> main() { prefposition(100, 500, 200, 600); shademodel(FLAT); winopen("red"); color(RED); clear(); sleep(5); } then I compiled with the command line in the manual: % cc red.c -lgl -o red And tried to run the result: % red Segmentation fault (core dumped) % dbx red dbx version 1.31 1/22/90 2:02 Copyright 1987 Silicon Graphics Inc. Copyright 1987 MIPS Computer Systems Inc. Type 'help' for help. Reading symbolic information of `red' . . . Process name from core dump: red Process died at pc 0x400774 of signal : segmentation violation [using memory image in core] (dbx) where > 0 shademodel(0x64, 0x1f4, 0xc8, 0x258, 0x0, 0x400214) [0x400770] 1 main() ["red.c":7, 0x400260] (dbx) q I noticed that if you leave out the call to "shademodel" the program works as advertised. Lee A. Butler SLCBR-VL-V Internet: butler@brl.mil Ballistic Research Laboratory Phone: (301) 278-8740 Aberdeen Proving Grounds, MD 21005-5066
moss@BRL.MIL ("Gary S. Moss", VLD/VMB) (03/09/90)
[Lee Butler writes:] < This evening I sat down at the IRIS to start learning to use the graphics < library. On page 1-5 of the "Graphics Library Programming Guide" is the < program "red.c" which I typed in verbatim: < ... < shademodel(FLAT); < winopen("red"); Lee, This has been brought up before, the documentation is wrong, shade- model() must be called *after* winopen(). I suggested that the GL should protect itself against this by returning failure from shademodel(), with a useful diagnostic, but apparently it tries to reference window structures through an uninitialized pointer. The last word that I heard from SGI was that they are considering providing a debuging version of the GL which does some checking so that they don't have to impact the performance of the graphics routines. You should be able to dig up this discussion a month or so ago in the archives.
glennrp@BRL.MIL (Glenn Randers-Pehrson, WMB) (03/09/90)
Lee, Regarding your problem with the tutorial example "red.c": You should have put shademodel(FLAT) AFTER your call to winopen. ...Glenn R-P
thant@horus.esd.sgi.com (Thant Tessman) (03/09/90)
In article <9003082054.aa06458@VMB.BRL.MIL>, butler@BRL.MIL ("Lee A. Butler") writes: > This evening I sat down at the IRIS to start learning to use the graphics > library. On page 1-5 of the "Graphics Library Programming Guide" is the > program "red.c" which I typed in verbatim: > > #include <gl/gl.h> > > main() > { > prefposition(100, 500, 200, 600); > shademodel(FLAT); > winopen("red"); > color(RED); > clear(); > sleep(5); > } > ... > > I noticed that if you leave out the call to "shademodel" the program works > as advertised. > > Lee A. Butler > SLCBR-VL-V Internet: butler@brl.mil > Ballistic Research Laboratory Phone: (301) 278-8740 > Aberdeen Proving Grounds, MD 21005-5066 There is an error in the program. The 'winopen' needs to happen befor the 'shademodel' command. I think (hope) the manual has been fixed by now. Some commands (like prefposition) are hints, and go before the winopen. All the rest need to happen after the graphics have been initialized. thant
FQH@psuvm.psu.edu (03/10/90)
I found that out yesterday. Also, the program only works in FORTRAN if you likewise leave out the call to SHADEM(). Woody Hunsberger .