Thread View: fj.unix
3 messages
3 total messages
Started by kenkona
Tue, 13 Oct 1992 14:42
Help on IRIS/GL programming (multiplexing GL devices)
Author: kenkona
Date: Tue, 13 Oct 1992 14:42
Date: Tue, 13 Oct 1992 14:42
156 lines
4522 bytes
4522 bytes
IRIS $B$N(J GL $B$N%W%m%0%i%`$K4XO"$7$?OC$7$J$N$G$9$,!"$I$J$?$+!"$o$+$k$+$?(J
$B$$$i$C$7$c$$$^$9$G$7$g$&$+!)(J $BBeM}E9$N$R$H$N$[$&$K$bJ9$$$?$N$G$9$,!"7k(J
$B6I!"!V$h$/$o$+$i$J$$!W$H$$$&$3$H$K$J$C$F$7$^$$$^$7$F!&!&!&(J
$B$d$j$?$$$3$H$O(J GL $B$N(J qdevice() $B$GEPO?$7$F$k%G%P%$%9$HIaDL$N%=%1%C%H$N(J
$B4V$G!"%^%k%A%W%l%C%/%9(J --- $B$I$A$i$+$K(J I/O $B%$%Y%s%H$,5/$3$k$^$GBT$D$H$$(J
$B$&$3$H$J$N$G$9$,!"$3$l$,$J$+$J$+$&$^$/F0$+$:$J$d$s$G$$$^$9!#(J
$B$3$l$O2?$+!"$d$j$+$?$H$$$&$N$,$"$k$N$G$7$g$&$+!)(J
$B$H$j$"$($:!"$3$NJU$N$G!";W$$$D$-$r%F%9%H$9$k$N$K:n$C$?%W%m%0%i%`$,$"$k(J
$B$N$G!"$=$l$b$D$1$F$*$-$^$9!#(J
$B%5%s%W%k!'(J
GL $B$N$[$&$O%U%!%$%k%G%9%/%j%W%?$,$"$k$N$+$I$&$+$h$/$o$+$i$J$$$N$G$9$,!"(J
$B%5%s%W%k!&%W%m%0%i%`$G$D$1$?$h$&$K!"$H$j$"$($:!"%U%!%$%k%G%9%/%j%W%?%F!<(J
$B%V%k$r%9%-%c%s$7$F$_$k$H!"$I$&$b!"$=$l$i$7$$$N$,!"#2$D=P$F$/$k$N$G!"$=(J
$B$l$r(J select() $B$7$F$_$k$H!"$3$l<+BN$O$A$c$s$H(J select() $B$G$-$F$$$k$h$&$K(J
$B;W$$$^$9!#$,!"$3$l$K%=%1%C%H$N%U%!%$%k%G%9%/%j%W%?$,2C$o$k$H!"%=%1%C%H(J
$BB&$K$O%G!<%?$,Mh$F$b$9$0$K$O(J select() $B$,JV$C$F$3$J$/$J$C$F$7$^$&!"$H$$(J
$B$&L/$J!J!)!K8=>]$,$*$-$^$9!#(J--- $B$J$<$J$N$G$7$g$&!)(J
---<cut here>---
: To unbundle, sh this file
echo Makefile
cat >Makefile <<'@@@ Fin de Makefile'
# $Id: Makefile,v 1.1.1.1 1992/10/13 04:20:13 ko Exp $
SHELL = /bin/sh
LIBS= -lgl_s -s
CFLAGS = -g
all: glselect
.c:
cc $(CFLAGS) $(INCLUDES) -o $@ $< $(LIBS)
@@@ Fin de Makefile
echo glselect.c
cat >glselect.c <<'@@@ Fin de glselect.c'
/*
* $Id: glselect.c,v 1.2 1992/10/13 04:40:39 ko Exp $
*
* glselect
*
* GL $B$N(J qdevice() $B$N%$%Y%s%H$H%=%1%C%H!J(Jstdin$B!K$KBP$7$F(J select()
* $B$7$h$&$H$9$k%W%m%0%i%`!#(J
*
* $B<B:]$O!"Av$i$;$k$H(J stdin $BB&$K%G!<%?$,Mh$F$b$9$0$K$O(J select() $B$,(J
* $BH4$1$F$3$J$$!J!)!K(J
*
* $B!J(Jstdin $B$O!"(J$ rsh `hostname` `pwd`/glselect $B$N$h$&$K$7$F(J
* $B%=%1%C%H$K3+$$$F$$$k$H2>Dj$7$F$k!K(J
*/
#include <sys/param.h> /* for NOFILE */
#include <sys/types.h>
#include <sys/stat.h>
#include <gl/gl.h>
#include <gl/device.h>
#include <stdio.h>
char *program; /* window title (NULL, if not given) */
int drawproc(); /* redraw procedure */
main(argc,argv)
int argc;
char **argv;
{
short val;
fd_set set0, set;
int nfds;
setbuf(stdin, NULL);
setbuf(stdout, NULL);
setbuf(stderr, NULL);
program = argv[1];
winopen(program);
drawproc(); /* force update */
/* select() $B$N(J fd_set $B$r$D$/$k(J */
FD_ZERO(&set0);
FD_SET(0, &set0); /* look stdin */
nfds = 1;
/* qdevice() $B$N(J fd $B$rC5$9(J -- $B$"$l$P!"(Jset0 $B$K5-O?!#(J */
{ int fd;
struct stat s;
for(fd=3; fd<NOFILE; fd++){
if((fd!=2) && (fstat(fd,&s) == 0)){ /* fstat() $B$N(J 0 => $B@.8y(J */
fprintf(stderr, "stat: fd no.%d is in use...\n", fd);
FD_SET(fd, &set0);
nfds = fd + 1;
}
}
}
/* enter our event loop */
while(1){
int r; /* return value of select() */
set = set0; /* setup fd_set */
if((r=select(nfds, &set, (fd_set *) NULL, (fd_set *) NULL, (struct timeval *)NULL)) < 0){
perror("select");
exit(1);
}
if(FD_ISSET(0, &set)){ /* data on stdin */
char b[128];
if(gets(b) != NULL){
printf("stdin ==> %s\n", b);
}
else{
printf("can't read stdin ??\n");
}
}
if(!(r == 1 && FD_ISSET(0, &set))){ /* data on GL file descriptor */
switch(qread(&val)){
case REDRAW:
fputs("redraw\n", stderr);
drawproc();
break;
default:
; /* ignore */
}
}
}
}
/* procedure get called each time canvas is redrawn. */
drawproc()
{
long x, y;
reshapeviewport();
getsize(&x, &y);
ortho2((Coord) 0, (Coord) x, (Coord) 0, (Coord) y);
color(WHITE);
clear();
color(RED);
move2i((long) 0, (long) 0);
draw2i((long) x, (long) y);
}
@@@ Fin de glselect.c
exit 0
---<end of shar file>--
$B$3$J$+(J $B$1$s$8(J ----- Kokubunji-Shi, Tokyo (kenkona@twics.co.jp,
ko@takuan.chi.snet.or.jp)
PHONE: 0423-20-7171 (office)
ΓΏ
Re: Help on IRIS/GL programming (multiplexing GL devices)
Author: Keisuke CHIBA
Date: Mon, 19 Oct 1992 00:01
Date: Mon, 19 Oct 1992 00:01
28 lines
2008 bytes
2008 bytes
IMAGICA $@$N$A$P$H?=$7$^$9(J.
In article <29982@twics.co.jp> kenkona@twics.co.jp writes:
|$@$d(J$@$j$?$$$3$H$O(J GL $@$N(J qdevice() $@$GEPO?$7$F$k%G%P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22 Oct 1992 17:24
35 lines
1986 bytes
1986 bytes
$B$3$J$+!w%+%$!J(Jon TWICS$B!K$G$9!#(J Message-ID: <CHIBA.92Oct19090116@rnewsx.lab.imagica.co.jp>: > $B$^$5$K(J, $B$=$N$h$&$JL\E*$N$?$a$K:n$i$l$?$H;W$o$l$k(J qgetfd() $B$H$$$&4X?t(J > $B$,$"$j$^$9(J. $B$3$l$O%$%Y%s%H%-%e!<$K7k$S$D$1$i$l$F$$$k%U%!%$%k%G%9%/%j%W(J > $B%?$rJV$7$^$9(J. > |$B$,!"$3$l$K%=%1%C%H$N%U%!%$%k%G%9%/%j%W%?$,2C$o$k$H!"%=%1%C%H(J > |$BB&$K$O%G!<%?$,Mh$F$b$9$0$K$O(J select() $B$,JV$C$F$3$J$/$J$C$F$7$^$&!"$H$$(J > |$B$&L/$J!J!)!K8=>]$,$*$-$^$9!#(J--- $B$J$<$J$N$G$7$g$&!)(J > > $B$3$l$O$o$+$j$^$;$s(J. "man qgetfd" $B$7$F!">u67$,$@$$$?$$$o$+$j$^$7$?!#(J man> Second, to ensure the proper behavior of select, man> call qtest before and after you call select. man> When select indicates data is available man> on the file descriptor, there may not be GL event data to read. man> Similarly, there is a condition where select would block, man> but data is available. The use of qtest before and after man> select guards against this. $BMW$9$k$K!"(Jqtest() $B$7$F>u67$r$H$H$N$($F$d$i$J$$$H!"(Jselect() $B$K$&$^$/1~(J $BEz$G$-$J$$!"$H$$$&$3$H$J$N$G$9$M!#>e$G!V(J select() $B$,JV$C$F$3$J$$!W$H$$$C(J $B$F$$$?$N$b$3$l$G$J$*$j$^$7$?!#(J $B$A$g$C$H!"$3$l$GG:$s$G$$$?$N$GHs>o$K=u$+$j$^$7$?!#(J $B$I$&$b!"$"$j$,$H$&$4$6$$$^$7$?!#(J -- $B$3$J$+(J $B$1$s$8(J ----- Kokubunji-Shi, Tokyo (ko@takuan.chi.snet.or.jp/ kenkona@twics.co.jp) PHONE: 0423-20-7171 (office) οΏ½
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads