Beispiel #1
0
int main(int argc, char *argv[])
{
	const char *backend_opts = "X11";

	if (argc > 1)
		font = GP_FontFaceLoad(argv[1], 0, 20);

	print_instructions();

	win = GP_BackendInit(backend_opts, "Font Align Test");

	if (win == NULL) {
		fprintf(stderr, "Failed to initalize backend '%s'\n",
		        backend_opts);
		return 1;
	}

	black_pixel    = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context);
	red_pixel      = GP_RGBToContextPixel(0xff, 0x00, 0x00, win->context);
	blue_pixel     = GP_RGBToContextPixel(0x00, 0x00, 0xff, win->context);
	green_pixel    = GP_RGBToContextPixel(0x00, 0xff, 0x00, win->context);
	yellow_pixel   = GP_RGBToContextPixel(0xff, 0xff, 0x00, win->context);
	white_pixel   = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context);
	darkgray_pixel = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, win->context);

	redraw_screen();
	GP_BackendFlip(win);
	event_loop();

	return 0;
}
Beispiel #2
0
int main(void)
{
	const char *backend_opts = "X11";

	win = GP_BackendInit(backend_opts, "Random Shape Test", stderr);

	if (win == NULL) {
		fprintf(stderr, "Failed to initalize backend '%s'\n",
		        backend_opts);
		return 1;
	}

	white = GP_ColorToContextPixel(GP_COL_WHITE, win->context);
	black = GP_ColorToContextPixel(GP_COL_BLACK, win->context);

	for (;;) {
		GP_BackendPoll(win);
		event_loop();

		usleep(20000);

		if (pause_flag)
			continue;

		redraw_screen();
		GP_BackendFlip(win);
	}
}
Beispiel #3
0
int main(int argc, char *argv[])
{
	const char *backend_opts = "X11";

	print_instructions();

	if (argc > 1) {
		font_path = argv[1];
		fprintf(stderr, "\nLoading font '%s'\n", argv[1]);
		font = GP_FontFaceLoad(argv[1], 0, font_h);
	}

	win = GP_BackendInit(backend_opts, "Font Test");

	if (win == NULL) {
		fprintf(stderr, "Failed to initalize backend '%s'\n",
		        backend_opts);
		return 1;
	}

	white_pixel     = GP_RGBToContextPixel(0xff, 0xff, 0xff, win->context);
	gray_pixel      = GP_RGBToContextPixel(0xbe, 0xbe, 0xbe, win->context);
	dark_gray_pixel = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, win->context);
	black_pixel     = GP_RGBToContextPixel(0x00, 0x00, 0x00, win->context);
	red_pixel       = GP_RGBToContextPixel(0xff, 0x00, 0x00, win->context);
	blue_pixel      = GP_RGBToContextPixel(0x00, 0x00, 0xff, win->context);

	redraw_screen();
	GP_BackendFlip(win);

	event_loop();

	return 0;
}
Beispiel #4
0
static void init_backend(const char *backend_opts)
{
	backend = GP_BackendInit(backend_opts, "Particles", stderr);

	if (backend == NULL) {
		fprintf(stderr, "Failed to initalize backend '%s'\n", backend_opts);
		exit(1);
	}
}
Beispiel #5
0
int main(int argc, char *argv[])
{
	const char *backend_opts = "X11";
	int opt;

	while ((opt = getopt(argc, argv, "b:h")) != -1) {
		switch (opt) {
		case 'b':
			backend_opts = optarg;
		break;
		case 'h':
			GP_BackendInit(NULL, NULL, stderr);
			return 0;
		break;
		default:
			fprintf(stderr, "Invalid paramter '%c'\n", opt);
			return 1;
		}
	}

	backend = GP_BackendInit(backend_opts, "Input Test", stderr);

	if (backend == NULL) {
		fprintf(stderr, "Failed to initalize backend '%s'\n",
		        backend_opts);
		return 1;
	}

	win = backend->context;

	red   = GP_ColorToContextPixel(GP_COL_RED, win);
	green = GP_ColorToContextPixel(GP_COL_GREEN, win);
	white = GP_ColorToContextPixel(GP_COL_WHITE, win);
	black = GP_ColorToContextPixel(GP_COL_BLACK, win);

	GP_Fill(win, black);
	GP_BackendFlip(backend);

	for (;;) {
		GP_BackendWait(backend);
		event_loop();
	}
}
Beispiel #6
0
int main(int argc, char *argv[])
{
	const char *backend_opts = "X11";

	if (argc == 1) {
		fprintf(stderr, "No file specified\n");
		return 1;
	}

	if (argc > 2)
		font = GP_FontFaceLoad(argv[2], 0, 16);

	if (!read_file_head(argv[1]))
		return 1;

	backend = GP_BackendInit(backend_opts, "File View");

	if (backend == NULL) {
		fprintf(stderr, "Failed to initalize backend '%s'\n",
		        backend_opts);
		return 1;
	}

	win = backend->context;

	white_pixel     = GP_RGBToContextPixel(0xff, 0xff, 0xff, win);
	gray_pixel      = GP_RGBToContextPixel(0xbe, 0xbe, 0xbe, win);
	dark_gray_pixel = GP_RGBToContextPixel(0x7f, 0x7f, 0x7f, win);
	black_pixel     = GP_RGBToContextPixel(0x00, 0x00, 0x00, win);
	red_pixel       = GP_RGBToContextPixel(0xff, 0x00, 0x00, win);
	blue_pixel      = GP_RGBToContextPixel(0x00, 0x00, 0xff, win);

	redraw_screen();
	GP_BackendFlip(backend);

	event_loop();

	return 0;
}
Beispiel #7
0
int main(int argc, char *argv[])
{
	const char *backend_opts = "X11";

	print_instructions();

	GP_SetDebugLevel(10);

	if (argc > 1) {
		font_path = argv[1];
		fprintf(stderr, "\nLoading font '%s'\n", argv[1]);
		font = GP_FontFaceLoad(argv[1], 0, font_h);
	}

	win = GP_BackendInit(backend_opts, "Font Test", stderr);

	if (win == NULL) {
		fprintf(stderr, "Failed to initalize backend '%s'\n",
		        backend_opts);
		return 1;
	}

	white_pixel     = GP_ColorToContextPixel(GP_COL_WHITE, win->context);
	gray_pixel      = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, win->context);
	dark_gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, win->context);
	black_pixel     = GP_ColorToContextPixel(GP_COL_BLACK, win->context);
	red_pixel       = GP_ColorToContextPixel(GP_COL_RED, win->context);
	blue_pixel      = GP_ColorToContextPixel(GP_COL_BLUE, win->context);

	redraw_screen();
	GP_BackendFlip(win);

	event_loop();

	return 0;
}
Beispiel #8
0
int main(int argc, char *argv[])
{
	GP_Backend *backend;
	const char *backend_opts = "X11:350x350";
	int opt;
	GP_PixelType emul_type = GP_PIXEL_UNKNOWN;

	while ((opt = getopt(argc, argv, "b:h:p:")) != -1) {
		switch (opt) {
		case 'b':
			backend_opts = optarg;
		break;
		case 'p':
			emul_type = GP_PixelTypeByName(optarg);

			if (emul_type == GP_PIXEL_UNKNOWN) {
				fprintf(stderr, "Invalid pixel type '%s'\n", optarg);
				return 1;
                        }
		break;
		case 'h':
			GP_BackendInit("help", NULL);
			return 0;
		break;
		default:
			fprintf(stderr, "Invalid paramter '%c'\n", opt);
			return 1;
		}
	}

	/* Turn on debug messages */
	GP_SetDebugLevel(10);

	backend = GP_BackendInit(backend_opts, "Virtual Backend Example");

	if (emul_type != GP_PIXEL_UNKNOWN) {
		GP_Backend *emul;

		/*
		 * Create an emulated backend on the top of real backend.
		 *
		 * The GP_BACKEND_CALL_EXIT says that when calling exit on
		 * emulated backend, the real backend exit will be called as
		 * well.
		 */
		emul = GP_BackendVirtualInit(backend, emul_type, GP_BACKEND_CALL_EXIT);

		if (emul == NULL) {
			fprintf(stderr, "Failed to create Virtual Backend\n");
			GP_BackendExit(backend);
			return 1;
		}

		/* Once created virtual backend behaves exactly like a real one */
		backend = emul;
	}

	redraw(backend);

	for (;;) {
		if (backend->Poll)
			GP_BackendPoll(backend);

		usleep(1000);

		/* Read and parse events */
		GP_Event ev;

		while (GP_BackendGetEvent(backend, &ev)) {

			GP_EventDump(&ev);

			switch (ev.type) {
			case GP_EV_KEY:
				switch (ev.val.key.key) {
				case GP_KEY_ESC:
				case GP_KEY_Q:
					GP_BackendExit(backend);
					return 0;
				break;
				}
			break;
			case GP_EV_SYS:
				switch(ev.code) {
				case GP_EV_SYS_RESIZE:
					GP_BackendResizeAck(backend);
					redraw(backend);
				break;
				}
			break;
			}
		}
	}

	GP_BackendExit(backend);

	return 0;
}
Beispiel #9
0
int main(int argc, char *argv[])
{
	GP_Backend *backend;
	const char *backend_opts = "X11:100x100";
	int opt;

	while ((opt = getopt(argc, argv, "b:h")) != -1) {
		switch (opt) {
		case 'b':
			backend_opts = optarg;
		break;
		case 'h':
			GP_BackendInit(NULL, NULL);
			return 0;
		break;
		default:
			fprintf(stderr, "Invalid paramter '%c'\n", opt);
			return 1;
		}
	}

	backend = GP_BackendInit(backend_opts, "Backend Example");

	if (backend == NULL) {
		fprintf(stderr, "Failed to initialize backend\n");
		return 1;
	}

	redraw(backend);

	/* Handle events */
	for (;;) {
		GP_Event ev;

		GP_BackendWaitEvent(backend, &ev);

		GP_EventDump(&ev);

		switch (ev.type) {
		case GP_EV_KEY:
			switch (ev.val.val) {
			case GP_KEY_ESC:
			case GP_KEY_Q:
				GP_BackendExit(backend);
				return 0;
			break;
			}
		break;
		case GP_EV_SYS:
			switch (ev.code) {
			case GP_EV_SYS_RESIZE:
				GP_BackendResizeAck(backend);
				redraw(backend);
			break;
			case GP_EV_SYS_QUIT:
				GP_BackendExit(backend);
				return 0;
			break;
			}
		break;
		}
	}

	GP_BackendExit(backend);

	return 0;
}