A pretty background for anybody running 3.1D or later

Gavin Bell gavin at krypton.SGI.COM
Thu Apr 27 09:06:55 AEST 1989


I thought I'd post this, since it is short and kind of pretty.
It is a gouraud shaded background for SGI 4D-series machines with at
least 24 bitplanes and at least release 3.1D of the OS.  It uses the
imakebackground() GL call, which was fixed around 3.1D (this might
work with 3.1C-- I can't remember exactly when the fix was made).

Cut at the dotted line, and run the result through /bin/sh-- it will
create and run a binary called 'shadedbg'.

Anybody else have interesting, small, backgrounds they want to share?

--gavin   (gavin at sgi.com)
-----------------------------cut here-----------------------------------
cat > shadedbg.c << EOF
/*
 *	A program to gouraud shade the background
 */

#include "gl.h"
#include "device.h"

main()
{
	imakebackground() ;

	winopen("") ;
	ortho2(0.0, 1.0, 0.0, 1.0) ;
	RGBmode() ;
	shademodel(GOURAUD) ;
	gconfig() ;
	draw_background() ;
	while (1)
	{
		short val ;
		long dev = qread(&val) ;
		if (dev == REDRAW) draw_background() ;
	}
}

float colors[] = {
	0.0, 0.0, 0.0, 0.75, 0.0, 0.75
} ;
float vertices[] = {
	0.0, 0.0, 1.0, 1.0, 0.0
} ;

draw_background()
{
	int i ;
	bgnpolygon() ;
	for (i = 0 ; i < 4 ; i++)
	{
		c3f(colors + i) ;
		v2f(vertices + i) ;
	}
	endpolygon() ;
}
EOF
#Strip, optimize, and use shared libraries to
# create an executable only 12K big.
cc -s -O -o shadedbg shadedbg.c -lgl_s -lm -lc_s
./shadedbg



More information about the Comp.sys.sgi mailing list