Example #1
0
static void perf_GETPIXELFMT(TeleUser *u, TeleEvent *ev)
{
	TeleCmdPixelFmtData *d = (TeleCmdPixelFmtData *) ev->data;
	T_Long reply_sequence;
	int err;
	
	const ggi_pixelformat * format;
	format = ggiGetPixelFormat(vis);

	reply_sequence = ev->sequence;
	tserver_new_event(u, ev, TELE_CMD_GETPIXELFMT,
			  sizeof(TeleCmdPixelFmtData), 0);
	ev->sequence = reply_sequence;

	/* send result back to client */

	d = (TeleCmdPixelFmtData *)ev->data;

	d->depth          = (T_Long) format->depth;
	d->size           = (T_Long) format->size;
	
	d->red_mask       = (T_Long) format->red_mask;
	d->green_mask     = (T_Long) format->green_mask;
	d->blue_mask      = (T_Long) format->blue_mask;
	d->alpha_mask     = (T_Long) format->alpha_mask;
	d->clut_mask      = (T_Long) format->clut_mask;
	d->fg_mask        = (T_Long) format->fg_mask;
	d->bg_mask        = (T_Long) format->bg_mask;
	d->texture_mask   = (T_Long) format->texture_mask;
	d->flags          = (T_Long) format->flags;
	d->stdformat      = (T_Long) format->stdformat;

	err = tserver_write(u, ev);

	if (err == TELE_ERROR_SHUTDOWN) {
		/* Client has gone away */

		close_connection(1);
		return;
	}
}
Example #2
0
/* Set the default mode and do all the work. We might want to split 
 * that later ...
 */
static int setup_mode(void)
{
	int i;
	ggi_color col;
	const ggi_directbuffer *buf;
	ggi_mode gmode;

	if ((visual=ggNewStem(NULL)) == NULL) {
		fprintf(stderr,
			"unable to create stem, exiting.\n");
		return -1;
	}

	if (ggiAttach(visual) < 0) {
		fprintf(stderr,
			"unable to attach ggi api, exiting.\n");
		return -1;
	}

	if (ggiOpen(visual, NULL) < 0) {
		fprintf(stderr,
			"unable to open default visual, exiting.\n");
		return -1;
	}

	ggiCheckSimpleMode(visual, GGI_AUTO, GGI_AUTO, GGI_AUTO, GT_AUTO,
			   &gmode);
	if (ggiSetMode(visual, &gmode) == 0) {
		printf("Graph mode %dx%d (%dx%d virt)\n",
		       gmode.visible.x, gmode.visible.y,
		       gmode.virt.x, gmode.virt.y);
	} else {
		fprintf(stderr, "Unable to set any mode at all!\n");
		ggiClose(visual);
		return -1;
	}

	col.r = 0xFFFF;
	col.g = 0xFFFF;
	col.b = 0xFFFF;
	printf("white = 0x%"PRIx32"\n", ggiMapColor(visual, &col));

	col.r = 0x0000;
	col.g = 0x0000;
	col.b = 0x0000;
	printf("black = 0x%"PRIx32"\n", ggiMapColor(visual, &col));

	printf("Pixelformat for Get/Put buffers:\n");
	print_pixfmt(ggiGetPixelFormat(visual));

	for (i = 0; ; i++) {
		int acquired = 0;

		buf = ggiDBGetBuffer(visual, i);
		if (buf == NULL) break;

		printf("DirectBuffer (frame #%d):\n", buf->frame);
		if (ggiResourceMustAcquire(buf->resource)) {
			switch (db_doacquire(buf)) {
			case 2:
				printf("Acquired DirectBuffer read/write\n");
				acquired = 1;
				break;
			case 1:
				printf("Acquired DirectBuffer for writing\n");
				acquired = 1;
				break;
			case 0:
				printf("Acquired DirectBuffer for read-only\n");
				acquired = 1;
				break;
			default:
				printf("DirectBuffer can not be Acquired!\n");
				break;
			}
		} else {
			printf("Does not need to be acquired\n");
		}

		printf("Mapped at read:%p, write:%p (paged %u)\n",
		       buf->read, buf->write, buf->page_size);
		switch (buf->layout) {
			case blPixelLinearBuffer: 
				printf("Layout: Linear Pixel Buffer\n");
				printf("Stride=%d\n", buf->buffer.plb.stride);
				printf("Pixelformat:\n");
				print_pixfmt(buf->buffer.plb.pixelformat);
				break;
			default: 
				printf("Layout: Unknown\n");
				break;	/* Skip it. Don't know it. */
		}
		if (acquired) ggiResourceRelease(buf->resource);
	}

	return 0;
}