[comp.sys.sgi] Twilight Background Program

howardl@landis.csd.sgi.com (Howard Look) (06/07/90)

Here's yet another little background program. It looks like the
sky at sunset. It will only run properly on 24 or more bit plane systems.

Compile it with:
cc night.c -lgl_s -lm -o night

Enjoy.

----------------------------------------------------------
Howard Look                          "What's your point ?"
Customer Support Division
Silicon Graphics
howardl@sgi.com
----------------------------------------------------------

(------- cut here --------)
#include "gl.h"
#include "device.h"

/*
A way cool background that looks like the twilight sky.
Start it up in user.ps

Howard Look
howardl@sgi.com
*/

main()
{
	int gid;
	
	imakebackground() ;

	gid = winopen("") ;
	RGBmode();
	gconfig();
	shademodel(GOURAUD);
	
	ortho2(0.0, 1.0, 0.0, 1.0) ;

	qenter(REDRAW,gid);

	while (1)
	{
		short val ;
		long dev = qread(&val) ;
		if (dev == REDRAW) draw_background() ;
	}
}

#define Y1 0.0
#define Y2 .2

draw_background()
{
    int i,j;
	static int orange[] = {255,72,0};
	static int blueish[] = {0,110,189};
	static int black[] = {0,0,0};
	static int red[] = {255,0,0};
	float v1[2],v2[2],v3[2],v4[2];

	v1[0] = v4[0] = 0.0;
	v2[0] = v3[0] = 1.0;

	v1[1] = v2[1] = 0.0;
	v3[1] = v4[1] = Y1;
	bgnpolygon();
		c3i(red);
		v2f(v1);
		v2f(v2);
		c3i(orange);
		v2f(v3);
		v2f(v4);
	endpolygon();

	v1[1] = v2[1] = Y2;
	bgnpolygon();
		c3i(orange);
		v2f(v4);
		v2f(v3);
		c3i(blueish);
		v2f(v2);
		v2f(v1);
	endpolygon();

	v3[1] = v4[1] = 1.0;
	bgnpolygon();
		c3i(blueish);
		v2f(v1);
		v2f(v2);
		c3i(black);
		v2f(v3);
		v2f(v4);
	endpolygon();

	cpack(0xFFFFFF);

    for (j=0; j<10; j++)
    {
        bgnpoint();
        for (i=0; i<256; i++)
        {
			float x[2];
			x[0] = ((float)rand())/32767.0;
			x[1] = ((float)rand())/32767.0;
			v2f(x);
        }
        endpoint();
    }

    for (j =0; j<200; j++)
    {
		float x[2],r;
		x[0] = ((float)rand())/32767.0;
		x[1] = ((float)rand())/32767.0;
		r = ((float)rand())/32767.0/500.0;
		circf(x[0],x[1],r);
    }
}

smfedor@moe.lerc.nasa.gov (Gregory Fedor) (06/07/90)

Just a naive question, is this a background program for NeWS and if so how do
you invoke it?

IF it's not, is there any way to put an image file up as the background in
NeWS?

--
Hailing frequencies closed...

Gregory Fedor                 (216) 433-8468
Sverdrup Technology           smfedor@lerc01.lerc.nasa.gov
NASA Lewis Research Center    Cleveland, Ohio 44135
-------------------------------------------------------------------------------

miq@sgi.com (06/08/90)

In article <1990Jun7.162505.3526@eagle.lerc.nasa.gov> smfedor@lerc01.lerc.nasa.gov (Gregory Fedor) writes:
>Just a naive question, is this a background program for NeWS and if so how do
>you invoke it?
>
>IF it's not, is there any way to put an image file up as the background in
>NeWS?
>
>--
>Hailing frequencies closed...
>
>Gregory Fedor                 (216) 433-8468
>Sverdrup Technology           smfedor@lerc01.lerc.nasa.gov
>NASA Lewis Research Center    Cleveland, Ohio 44135
>-------------------------------------------------------------------------------

You can run the program by first compiling it with the proper libraries
(cc program.c -o twilight -lgl_s -lm) should be sufficient and then running
the executable.  If you get tired of it, simply choose a different background
from the Windows toolchest.

For an easy way to put images up in the backgroud follow this recipe:

First you need some images in SGI format that are viewable with the ipaste 
command.

Now you need to have the 4Dgifts directory installed on you machine.  If you
don't have this, get it off the DEV tape.  This is done by loading the instal-
lation tools off EOE1 tape and going into manual mode (choice 2 from the menu)
then switching to the DEV tape and going into select mode (type select at the
Manual> prompt).  Now unselect everything by saying "no *" then select only
the 4Dgifts stuff "yes dev.sw.giftssrc".  Quit and reboot.

Get the source for ipaste from the /usr/people/4Dgifts/iristools/imgtools 
directory and copy it somewhere else.  Edit this file and find the section that
has the winopen calls in it.  Before all occurances of winopen(), insert a call
to imakebackgroud().  Save this and compile it as bacpaste or something.

Run bacpaste <imagefile> to get a new background.  You will have to experiment
with izoom to get the image to be 1280x1024 if you want it to fill the entire
canvass, or adding that code is left as an exercise to the reader.


--
"Mister! Hey mister! You lights are popped up, but they aren't on!"
	"Huh?  Oh gee thanks...<sigh>"
				An ignorant good samaritan and me in my Bugeye
Miq Millman -- miq@sgi.com or {decwrl,pyramid,ucbvax}!sgi!miq  415 335 1041