예제 #1
0
void Smart_ggiFlush(void)
{
 struct timeval tv_current;

 gettimeofday(&tv_current,NULL);

 if(Smart_ggiFlush_maxusec==0)
 {
  char *ptr=configvariable(&ARACHNEcfg,"GGI_MaxFrameRate",NULL);
  if(ptr)
   Smart_ggiFlush_maxusec=atoi(ptr);
  if(!ptr || Smart_ggiFlush_maxusec<=0 || Smart_ggiFlush_maxusec>100)
    Smart_ggiFlush_maxusec=10;
  Smart_ggiFlush_maxusec=1000000/ Smart_ggiFlush_maxusec;
 }

 if(tv_current.tv_sec!=tv_lastflush.tv_sec ||
   tv_current.tv_usec-tv_lastflush.tv_usec>Smart_ggiFlush_maxusec)
 {
  ggiFlush(ggiVis);
  tv_lastflush.tv_sec=tv_current.tv_sec;
  tv_lastflush.tv_usec=tv_current.tv_usec;
  Forced_ggiFlush_request=0;
 }
 else
  Forced_ggiFlush_request=1;
}
예제 #2
0
static void gl_ggiFlush(GLcontext *ctx)
{
	ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;

	GGIMESADPRINT_CORE("gl_ggiFlush() called\n");
	
	ggiFlush(ggi_ctx->ggi_visual);
}
예제 #3
0
파일: palette.c 프로젝트: Nekrofage/DoomRPi
static void testcase1(const char *desc)
{
	ggi_visual_t vis;
	ggi_color green, back;
	int err;

	printteststart(__FILE__, __PRETTY_FUNCTION__, EXPECTED2PASS, desc);
	if (dontrun) return;

	err = ggiInit();
	printassert(err == GGI_OK, "ggiInit failed with %i\n", err);

	vis = ggiOpen(NULL);
	printassert(vis != NULL, "ggiOpen() failed\n");

	err = ggiSetGraphMode(vis, GGI_AUTO, GGI_AUTO, GGI_AUTO, GGI_AUTO, GT_8BIT);
	if(err < 0) {
		printassert(0, "Palettized mode not available.\n");
		printsuccess();
		ggiClose(vis);
		ggiExit();
		return;
	}

	green.r = 100;
	green.g = 40000;
	green.b = 4000;
	err = ggiSetPalette(vis, GGI_PALETTE_DONTCARE, 1, &green);
	if (err < 0) {
		printfailure("Unable to install colormap with one entry.\n");
		ggiClose(vis);
		ggiExit();
		return;
	}

	printassert(err == (int)ggiMapColor(vis, &green),
		"ggiMapColor inconsistent with retval of ggiSetPalette.\n");

	ggiUnmapPixel(vis, err, &back);
	if(green.r != back.r || green.g != back.g || green.b != back.b) {
		printfailure("Unexpected color from ggiUnmapPixel.\n");
		ggiClose(vis);
		ggiExit();
		return;
	}

	ggiSetGCForeground(vis, err);
	ggiDrawBox(vis, 0, 0, 3000, 3000);
	ggiFlush(vis);

	/* You should see a green square, how to test this? */
	ggUSleep(5000000);
	printsuccess();

	ggiClose(vis);
	ggiExit();
}
예제 #4
0
파일: visual.c 프로젝트: Nekrofage/DoomRPi
static int
GGI_directx_setflags(ggi_visual *vis, ggi_flags flags)
{
	directx_priv *priv = GGIDIRECTX_PRIV(vis);

	if ((LIBGGI_FLAGS(vis) & GGIFLAG_ASYNC) && !(flags & GGIFLAG_ASYNC))
		ggiFlush(vis);
	/* Clear out unknown flags */
	LIBGGI_FLAGS(vis) = flags & GGIFLAG_ASYNC;

	if(LIBGGI_FLAGS(vis) & GGIFLAG_ASYNC) {
		if (priv->timer_id)
			KillTimer(priv->hWnd, priv->timer_id);
		priv->timer_id = 0;
	}
	else
		priv->timer_id = SetTimer(priv->hWnd, 1, 33, NULL);
	return GGI_OK;
}
예제 #5
0
파일: pageflip.c 프로젝트: antrik/libggi
int main(int argc, const char *argv[])
{
	ggi_visual_t vis;
	ggi_mode mode;
	int i, j, cx, cy, c;
	char buf[80];

	/* Set up the random number generator */
	srandom((unsigned)time(NULL));

	/* Initialize LibGGI */
	if (giiInit() < 0) {
		fprintf(stderr, "Cannot initialize LibGII!\n");
		return 1;
	}

	if (ggiInit() < 0) {
		fprintf(stderr, "Cannot initialize LibGGI!\n");
		giiExit();
		return 1;
	}

	vis = ggNewStem(NULL);
	if (!vis) {
		fprintf(stderr, "Cannot open create stem!\n");
		ggiExit();
		giiExit();
		return 1;
	}

	if (giiAttach(vis) < 0) {
		fprintf(stderr, "Cannot attach LibGII!\n");
		ggDelStem(vis);
		ggiExit();
		giiExit();
		return 1;
	}

	if (ggiAttach(vis) < 0) {
		fprintf(stderr, "Cannot attach LibGGI!\n");
		ggDelStem(vis);
		ggiExit();
		giiExit();
		return 1;
	}

	/* Open default visual */
	if (ggiOpen(vis, NULL) < 0) {
		fprintf(stderr, "Cannot open default visual!\n");
		ggDelStem(vis);
		ggiExit();
		giiExit();
		return 1;
	}

	/* Set visual to async mode (drawing not immediate) */
	ggiSetFlags(vis, GGIFLAG_ASYNC);

	/* Set default mode, but with multiple buffering */
	if (argc > 1) {
		ggiParseMode(argv[1], &mode);
	} else {
		ggiParseMode("", &mode);
		if (mode.frames < 2) mode.frames = 2;
	}

	if (ggiSetMode(vis, &mode)) {
		fprintf(stderr, "Cannot set mode!\n");
		ggDelStem(vis);
		ggiExit();
		giiExit();
		return 1;
	}

	ggiGetCharSize(vis, &cx, &cy);

	/* Setup palette */
	if (GT_SCHEME(mode.graphtype) == GT_PALETTE) {
		ggiSetColorfulPalette(vis);
	}

	/* Write something into each frame */
	for (i = 0; i < mode.frames; i++) {

		if (ggiSetWriteFrame(vis, i)) {
			fprintf(stderr, "Cannot set write frame!\n");
			ggDelStem(vis);
			ggiExit();
			giiExit();
			return 1;
		}

		ggiSetGCBackground(vis, ggiMapColor(vis, &white));
		ggiSetGCForeground(vis, ggiMapColor(vis, &white));
		ggiFillscreen(vis);
	}

	/* Clip a small border so that clipping can be verified. */
	ggiSetGCClipping(vis, 5, 5, mode.virt.x - 5, mode.virt.y - 5);

	/* Write something into each frame */
	for (i = 0; i < mode.frames; i++) {

		ggiSetWriteFrame(vis, i);

		ggiSetGCBackground(vis, ggiMapColor(vis, &black));
		ggiSetGCForeground(vis, ggiMapColor(vis, &black));
		ggiFillscreen(vis);

		snprintf(buf, sizeof(buf), "Hello World #%d!", i);

		for (j = 0; j < mode.virt.y; j += cy) {

			ggi_color col;

			int x = random() % mode.virt.x;

			int h = (random() & 0x7fff) + 0x8000;
			int l = (random() & 0x7fff);

			/* Use different colors for different frames */
			col.r = ((i + 1) & 1) ? h : l;
			col.g = ((i + 1) & 2) ? h : l;
			col.b = ((i + 1) & 4) ? h : l;

			ggiSetGCForeground(vis, ggiMapColor(vis, &col));
			ggiPuts(vis, x, j, buf);
		}
		/* Flush commands before proceeding to the next frame */
		ggiFlush(vis);
	}

	/* Cycle through frames */
	i = 0;
	j = 0;
	do {
		if (ggiSetDisplayFrame(vis, i)) {
			ggPanic("Cannot set display frame!\n");
		}

		/* Wait */
		c = GIIK_VOID;
		do {
			struct timeval tv = { 0, 0 };
			int key;

			/* Flush command before waiting for input */
			ggiFlush(vis);

			key = giiEventPoll(vis, emKeyPress, &tv);
			if (key & emKeyPress)
				c = giiGetc(vis);
			ggUSleep(50000);
			animate(vis, &mode, j);
			j++;
		} while (c == GIIK_VOID || GII_KTYP(c) == GII_KT_MOD);

		i = (i + 1) % mode.frames;

	} while (c != 'q' && c != 'Q' && c != 'x' && c != 'X' &&
		 c != GIIUC_Escape);

	ggiClose(vis);

	ggDelStem(vis);
	ggiExit();
	giiExit();
	return 0;
}
예제 #6
0
파일: gr.c 프로젝트: Ringdingcoder/d1x
void gr_update()
{
	ggiFlush(screenvis);
	if (!use_directbuffer)
		ggiPutBox(screenvis, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h, screenbuffer);
}
예제 #7
0
void resolution(ggi_visual_t vis)
{
	int xmax, ymax;
	ggi_mode currmode;

	ggiGetMode(vis, &currmode);
	xmax = currmode.visible.x;
	ymax = currmode.visible.y;

	ggiSetGCForeground(vis, blue);
	ggiDrawBox(vis, 0, 0, xmax, ymax);

	stripevert(vis, 0, 0, xmax - 1, ymax - 1,
		   black, white, 1);
	ggiFlush(vis);
	if (waitabit(vis))
		return;

	stripevert(vis, 0, 0, xmax - 1, ymax - 1,
		   black, white, 2);
	ggiFlush(vis);
	if (waitabit(vis))
		return;

	stripevert(vis, 0, 0, xmax - 1, ymax - 1,
		   black, white, 3);
	ggiFlush(vis);
	if (waitabit(vis))
		return;

	stripevert(vis, 0, 0, xmax - 1, ymax - 1,
		   black, white, 4);
	ggiFlush(vis);
	if (waitabit(vis))
		return;

	stripehor(vis, 0, 0, xmax - 1, ymax - 1, black, white, 1);
	ggiFlush(vis);
	if (waitabit(vis))
		return;

	stripehor(vis, 0, 0, xmax - 1, ymax - 1, black, white, 2);
	ggiFlush(vis);
	if (waitabit(vis))
		return;

	starone(vis, 0, 0, xmax - 1, ymax - 1, black, white);
	ggiFlush(vis);
	if (waitabit(vis))
		return;

	starfive(vis, 0, 0, xmax - 1, ymax - 1, white, black);
	ggiFlush(vis);
	if (waitabit(vis))
		return;

	startwoten(vis, 0, 0, xmax - 1, ymax - 1, white, black);
	ggiFlush(vis);
	if (waitabit(vis))
		return;

	ggiSetGCForeground(vis, black);
	ggiDrawBox(vis, 0, 0, xmax, ymax);

	stripevert(vis, 1 * xmax / 16, 2 * ymax / 8, 3 * xmax / 16 - 1,
		   3 * ymax / 8 - 1, black, red, 4);
	stripevert(vis, 3 * xmax / 16, 2 * ymax / 8, 5 * xmax / 16 - 1,
		   3 * ymax / 8 - 1, black, red, 3);
	stripevert(vis, 5 * xmax / 16, 2 * ymax / 8, 7 * xmax / 16 - 1,
		   3 * ymax / 8 - 1, black, red, 2);
	stripevert(vis, 7 * xmax / 16, 2 * ymax / 8, 9 * xmax / 16 - 1,
		   3 * ymax / 8 - 1, black, red, 1);
	stripevert(vis, 9 * xmax / 16, 2 * ymax / 8, 11 * xmax / 16 - 1,
		   3 * ymax / 8 - 1, black, red, 2);
	stripevert(vis, 11 * xmax / 16, 2 * ymax / 8, 13 * xmax / 16 - 1,
		   3 * ymax / 8 - 1, black, red, 3);
	stripevert(vis, 13 * xmax / 16, 2 * ymax / 8, 15 * xmax / 16 - 1,
		   3 * ymax / 8 - 1, black, red, 4);
	stripevert(vis, 1 * xmax / 16, 3 * ymax / 8, 3 * xmax / 16 - 1,
		   4 * ymax / 8 - 1, black, green, 4);
	stripevert(vis, 3 * xmax / 16, 3 * ymax / 8, 5 * xmax / 16 - 1,
		   4 * ymax / 8 - 1, black, green, 3);
	stripevert(vis, 5 * xmax / 16, 3 * ymax / 8, 7 * xmax / 16 - 1,
		   4 * ymax / 8 - 1, black, green, 2);
	stripevert(vis, 7 * xmax / 16, 3 * ymax / 8, 9 * xmax / 16 - 1,
		   4 * ymax / 8 - 1, black, green, 1);
	stripevert(vis, 9 * xmax / 16, 3 * ymax / 8, 11 * xmax / 16 - 1,
		   4 * ymax / 8 - 1, black, green, 2);
	stripevert(vis, 11 * xmax / 16, 3 * ymax / 8, 13 * xmax / 16 - 1,
		   4 * ymax / 8 - 1, black, green, 3);
	stripevert(vis, 13 * xmax / 16, 3 * ymax / 8, 15 * xmax / 16 - 1,
		   4 * ymax / 8 - 1, black, green, 4);
	stripevert(vis, 1 * xmax / 16, 4 * ymax / 8, 3 * xmax / 16 - 1,
		   5 * ymax / 8 - 1, black, blue, 4);
	stripevert(vis, 3 * xmax / 16, 4 * ymax / 8, 5 * xmax / 16 - 1,
		   5 * ymax / 8 - 1, black, blue, 3);
	stripevert(vis, 5 * xmax / 16, 4 * ymax / 8, 7 * xmax / 16 - 1,
		   5 * ymax / 8 - 1, black, blue, 2);
	stripevert(vis, 7 * xmax / 16, 4 * ymax / 8, 9 * xmax / 16 - 1,
		   5 * ymax / 8 - 1, black, blue, 1);
	stripevert(vis, 9 * xmax / 16, 4 * ymax / 8, 11 * xmax / 16 - 1,
		   5 * ymax / 8 - 1, black, blue, 2);
	stripevert(vis, 11 * xmax / 16, 4 * ymax / 8, 13 * xmax / 16 - 1,
		   5 * ymax / 8 - 1, black, blue, 3);
	stripevert(vis, 13 * xmax / 16, 4 * ymax / 8, 15 * xmax / 16 - 1,
		   5 * ymax / 8 - 1, black, blue, 4);
	stripevert(vis, 1 * xmax / 16, 5 * ymax / 8, 3 * xmax / 16 - 1,
		   6 * ymax / 8 - 1, black, white, 4);
	stripevert(vis, 3 * xmax / 16, 5 * ymax / 8, 5 * xmax / 16 - 1,
		   6 * ymax / 8 - 1, black, white, 3);
	stripevert(vis, 5 * xmax / 16, 5 * ymax / 8, 7 * xmax / 16 - 1,
		   6 * ymax / 8 - 1, black, white, 2);
	stripevert(vis, 7 * xmax / 16, 5 * ymax / 8, 9 * xmax / 16 - 1,
		   6 * ymax / 8 - 1, black, white, 1);
	stripevert(vis, 9 * xmax / 16, 5 * ymax / 8, 11 * xmax / 16 - 1,
		   6 * ymax / 8 - 1, black, white, 2);
	stripevert(vis, 11 * xmax / 16, 5 * ymax / 8, 13 * xmax / 16 - 1,
		   6 * ymax / 8 - 1, black, white, 3);
	stripevert(vis, 13 * xmax / 16, 5 * ymax / 8, 15 * xmax / 16 - 1,
		   6 * ymax / 8 - 1, black, white, 4);
	ggiFlush(vis);
	if (waitabit(vis))
		return;
}
예제 #8
0
int main(int argc, char *argv[])
{
	struct timeval cur_time;
	struct timeval flush_time;

	/* initialize */

	if (handle_args(argc, argv) < 0) {
		return 1;
	}

	/* open visual */

	if (ggiInit() < 0) {
		fprintf(stderr, "teleserver: Error initializing GGI.\n");
		return 1;
	}

	if (tserver_init(&serv, display_num) < 0) {
		ggiExit();
		return 3;
	}

	ggCurTime(&flush_time);

	printf("TeleServer Ready.\n");
	fflush(stdout);


	/* main loop */

	for (quit=0; !quit; ) {
		struct timeval tv;

		int millies;

		busy=0;

		/* check for incoming connections */

		if (tserver_check(&serv)) {
			handle_connection();
			busy++;
		}

		/* check for user input */

		tv.tv_sec = tv.tv_usec = 0;

		if (mode_up && (ggiEventPoll(vis, emAll, &tv) != 0)) {
			handle_event();
			busy++;
		}

		/* check for client commands */

		if (user) {
			check_command(user);
		}

		if (! busy) {
			ggUSleep(TSERVER_SLEEP_TIME * 1000);
		}

		ggCurTime(&cur_time);


		millies = (cur_time.tv_sec  - flush_time.tv_sec)  * 1000 +
		          (cur_time.tv_usec - flush_time.tv_usec) / 1000;

		if (millies >= TSERVER_FLUSH_TIME) {
			if (mode_up) {
				ggiFlush(vis);
			}
			flush_time = cur_time;
		}
	}

	/* shut down */
	tserver_exit(&serv);

	ggiExit();

	return 0;
}
예제 #9
0
static void perf_FLUSH(TeleUser *u)
{
	ggiFlush(vis);
}	/* perf_FLUSH */
예제 #10
0
파일: menu.c 프로젝트: antrik/libggi
int do_menu(struct menu * m , int selected)
{

    /* select a menu item by either a number or with arrow keys */

    int i;

    int evmask;
    gii_event ev;
    struct timeval t= {0,0};
    int oldselection = selected;

    draw_window(&m->w);

    if (m->toptext != NULL) {
        ggiSetGCForeground(m->w.vis,
                           ggiMapColor(m->w.vis,&m->toptextcolor));
        /* FIXME*/
        ggiPuts(m->w.vis, m->w.xorigin+m->toptextx,
                m->w.yorigin+m->toptexty, m->toptext);
    }

    if (m->bottomtext != NULL) {
        ggiSetGCForeground(m->w.vis,
                           ggiMapColor(m->w.vis,&m->bottomtextcolor));
        /* FIXME*/
        ggiPuts(m->w.vis, m->w.xorigin+m->bottomtextx,
                m->w.yorigin+m->bottomtexty, m->bottomtext);
    }

    for (i = 0; i<=m->lastentry; i++) {
        if (i!=selected) {
            ggiSetGCForeground(m->w.vis,
                               ggiMapColor(m->w.vis,&m->entrycolor));
            ggiSetGCBackground(m->w.vis,
                               ggiMapColor(m->w.vis,&m->w.backgroundcolor));
        } else {
            ggiSetGCForeground(m->w.vis,
                               ggiMapColor(m->w.vis,&m->selectedcolor));
            ggiSetGCBackground(m->w.vis,
                               ggiMapColor(m->w.vis,
                                           &m->selectedbackgroundcolor));
        }
        ggiPuts( m->w.vis,
                 m->w.xorigin + m->entry[i].x,
                 m->w.yorigin + m->entry[i].y,
                 m->entry[i].text);
    }
    for (;;) {
        /* if we are in asynchronous mode, we must guarantee */
        /* the user sees he's next.                          */
        ggiFlush(m->w.vis);

        /* get a keypress */
        evmask = emKey;
        giiEventPoll(m->w.vis, evmask, NULL);
        while (giiEventPoll(m->w.vis, evmask,&t)) {
            do {
                giiEventRead(m->w.vis,&ev, evmask);
            } while (!((1<<ev.any.type)&evmask));
            switch(ev.any.type) {
            case evKeyPress:
            case evKeyRepeat:
                switch(ev.key.sym) {
                case '1':
                    selected = 0;
                    break;
                case '2':
                    selected = 1;
                    break;
                case '3':
                    selected = 2;
                    break;
                case '4':
                    selected = 3;
                    break;
                case '5':
                    selected = 4;
                    break;
                case '6':
                    selected = 5;
                    break;
                case '7':
                    selected = 6;
                    break;
                case '8':
                    selected = 7;
                    break;
                case '9':
                    selected = 8;
                    break;
                case GIIK_Up:
                    selected--;
                    break;
                case GIIK_Down:
                    selected++;
                    break;
                case GIIK_Enter:
                    ggiFlush(m->w.vis);
                    /* just to make sure */
                    return (selected);
                    break; /* never get here */
                case GIIUC_Escape:
                    ggiFlush(m->w.vis);
                    /* just to make sure */
                    return (-1);
                default:
                    /*printf("unknown sym=%4x code=%4x\n", ev.key.sym, ev.key.code);*/
                    break;
                }
            default: /*printf("can't handle this event yet.\n");*/
                break;
            }
        }

        ggiSetGCForeground(m->w.vis,
                           ggiMapColor(m->w.vis,&m->entrycolor));
        ggiSetGCBackground(m->w.vis,
                           ggiMapColor(m->w.vis,&m->w.backgroundcolor));
        ggiPuts( m->w.vis,
                 m->w.xorigin+m->entry[oldselection].x,
                 m->w.yorigin+m->entry[oldselection].y,
                 m->entry[oldselection].text);
        if (selected<0) selected = 0;
        if (selected > m->lastentry) selected = m->lastentry;

        ggiSetGCForeground(m->w.vis,
                           ggiMapColor(m->w.vis,&m->selectedcolor));
        ggiSetGCBackground(m->w.vis,
                           ggiMapColor(m->w.vis,
                                       &m->selectedbackgroundcolor));
        ggiPuts( m->w.vis,
                 m->w.xorigin + m->entry[selected].x,
                 m->w.yorigin + m->entry[selected].y,
                 m->entry[selected].text);
        oldselection = selected;
    }
}