Ejemplo n.º 1
0
void drawbox(char **lines)
{
	int x = 28;
	int y = 64;
	int i,numlines = 0;

	//count number of lines
	for(i=0;lines[i+1];i++)
		numlines++;

	//clear screen
	memset(nesscr,0,256*240);

	//draw window
	gui_draw_window(lines[0],x,y,256-60,11 + (numlines * 6));

	//draw text
	for(i=1;lines[i];i++)
		gui_draw_text(GUI_TEXT,x + 2,y + 4 + (i * 6),lines[i]);

	//copy old screen for neat background
	video_copyscreen();

	//update screen
	video_update(nesscr,256+8);

#ifdef PS2
	//double buffered?
	video_update(nesscr,256+8);
#endif
}
Ejemplo n.º 2
0
void draw_display_window(display_item *pDI, int undo, BITMAP *pScreen, RECT *pRect)
{
	WINDOW *pContents = (WINDOW*) pDI->pContents;
	BITMAP *pOldContents = pDI->pOldContents;
	RECT tmp_r;

	// dirty rectangle.
	if (pRect)
	{
		rect_copy(&tmp_r, pRect);

		if (pRect->x == -1)
		{
			rect_copy(pRect, &pContents->window);
		} else {
			rect_combine(pRect, &tmp_r, &pContents->window);
		}
	}

	if (undo)
	{
		// draw it
		blit(pOldContents, pScreen, 0, 0, pContents->window.x, pContents->window.y, pContents->window.w, pContents->window.h);
	} else {
		// save it
		if (pDI->is_saving)
		{
			blit(pScreen, pOldContents, pContents->window.x, pContents->window.y, 0, 0, pContents->window.w, pContents->window.h);
		}

		// draw it
		gui_draw_window(pContents, pScreen);
	}
}
Ejemplo n.º 3
0
Archivo: main.c Proyecto: hglm/libfgen
int main(int argc, char **argv) {
    gui_initialize(&argc, &argv);
    nu_cities = 100;
    srandom(0);
    initialize_cities();
    gui_create_window_layout();
    gui_draw_window();
    gui_run();
}
Ejemplo n.º 4
0
static gboolean area_configure_event_cb(GtkWidget *widget, GdkEventConfigure *event, Window *window) {
    if (!GUI_initialized) {
        return TRUE;
    }
    window->area_width = event->width;
    window->area_height = event->height;
    cairo_surface_destroy(window->surface);
    window->surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, window->area_width, window->area_height);
    gui_draw_window();
    /* We've handled the configure event, no need for further processing. */
    return TRUE;
}
Ejemplo n.º 5
0
Archivo: ex5.c Proyecto: sdeming/alex
int main(int argc, char *argv[])
{
	DATAFILE *datf;
	BITMAP *scrFlip;
	BITMAP *scrMap;
	PALETTE pal;
	WINDOW *winInfo;
	long frames = 0L;
	float start_time, end_time;
	MAP *map, *overlay;
	int x = 0, y = 0;
	int old_x = -1, old_y = -1;
	int dx = 1, dy = 1;
	int view_w, view_h;
	int do_idle = 1;
	char s[128];

	// Default screen resolution to 320x200.
	screen_width = 320;
	screen_height = 200;

	// Read command line args.	Set screen size accordingly.
	if (argc > 2)
	{
		screen_width = atoi(argv[1]);
		screen_height = atoi(argv[2]);
	}
	right_size = 0;
	bottom_size = 0;

	printf("screen: %dX%d\n", screen_width, screen_height);

	// Initialize Allegro.	Great library!
	allegro_init();
	install_timer();
	install_keyboard();

	// Set graphics mode.
	if (set_gfx_mode(GFX_AUTODETECT, screen_width, screen_height, 0, 0) == -1)
	{
		printf("Cannot set video mode to %d, %d.\n", screen_width, screen_height);
		return 1;
	}

	// load comic font from ex4.
	datf = load_datafile_object("ex.dat", "comic12");
	if (datf == NULL)
	{
		allegro_exit();
		printf("Error loading ex.dat\n");
		return 1;
	}

	text_mode(-1);

	// load map
	//printf("loading map\n");
	map = load_map("tile1.wmp", "tile1.spr", pal);
	if (map == NULL)
	{
		allegro_exit();
		printf("Error loading map file.\n");
		return 1;
	}

	// load overlay
	//printf("loading overlay\n");
	overlay = load_map("tile1ovr.wmp", NULL, NULL);
	if (overlay == NULL)
	{
		allegro_exit();
		printf("Error loading overlay file.\n");
		return 1;
	}
	map_settileset(overlay, map->tileset);

	// Allocate buffers for our rendering.
	//printf("allocating buffers\n");
	scrFlip = create_bitmap(SCREEN_W, SCREEN_H);
	clear(scrFlip);
	scrMap = create_bitmap(SCREEN_W + map->t_width*2, SCREEN_H + map->t_height*2);

	// set palette
	//printf("setting palette\n");
	gui_setpalette(pal);

	// Build rgb_table.
	text_mode(makecol8(0, 0, 0));
	textout_centre(screen, font, "Building RGB table.", SCREEN_W>>1, 10, 100);
	create_rgb_table(&rgb_table, pal, rgb_table_callback);
	rgb_map = &rgb_table;

	// Build lighting table.
	text_mode(makecol8(0, 0, 0));
	textout_centre(screen, font, "Building lighting table.", SCREEN_W>>1, 10, 100);
	create_light_table(&light_table, pal, 64, 64, 64, rgb_table_callback);

	// Build translucency table.
	text_mode(makecol8(0, 0, 0));
	textout_centre(screen, font, "Building translucency table.", SCREEN_W>>1, 10, 100);
	create_trans_table(&trans_table, pal, 128, 128, 128, rgb_table_callback);

	color_map = &trans_table;

	// initialize gui
	gui_initialize(&light_table, &trans_table);

	// set map and overlay color tables
	map_settables(map, &trans_table, &light_table);
	map_settables(overlay, &trans_table, &light_table);

	// create info window
	winInfo = gui_create_window(128, 200, WB_THICK, WD_TRANSLUCENT);
	gui_move_window(winInfo, SCREEN_W-winInfo->window.w, 0);

	// set up vars.
	view_w = scrMap->w/map->t_width;
	view_h = scrMap->h/map->t_height;

	// setup time_to_blit interrupt.
	LOCK_VARIABLE(time_to_blit);
	LOCK_FUNCTION(time_to_blit_timer);
	install_int_ex(time_to_blit_timer, BPS_TO_TIMER(30));

	missed_frames = 0;
	// main loop.
	start_time = clock();
	while (1)
	{
		idle_time = 0;
		if (do_idle)
			while (!time_to_blit) idle_proc(); // lock it in at around 30 fps.
		time_to_blit = 0;
		if (idle_time < lowest_idle)
			lowest_idle = idle_time;
		if (idle_time > highest_idle)
			highest_idle = idle_time;

		// render map
		if (map_getx_tile(map, x) != old_x || map_gety_tile(map, y) != old_y)
		{
			render_map(map, scrMap, 0, 0, x, y, view_w, view_h);
			render_map(overlay, scrMap, 0, 0, x, y, view_w, view_h);
			old_x = map_getx_tile(map, x);
			old_y = map_gety_tile(map, y);
		}
		blit(scrMap, scrFlip, map_getx_offset(map, x), map_gety_offset(map, y), 0, 0, SCREEN_W-right_size, SCREEN_H-bottom_size);

		gui_clear_window(winInfo, makecol8(0, 0, 0));
		gui_textout_centre_window(winInfo, "Map Demo", 2, makecol8(255, 0, 0), -1);
		sprintf(s, "X: %d, Y: %d", x, y);
		gui_textout_centre_window(winInfo, s, 14, makecol8(0, 0, 255), -1);
		sprintf(s, "DX: %d, DY: %d", dx, dy);
		gui_textout_centre_window(winInfo, s, 24, makecol8(0, 0, 255), -1);
		sprintf(s, "X Ofs: %d", map_getx_offset(map, x));
		gui_textout_centre_window(winInfo, s, 34, makecol8(0, 0, 255), -1);
		sprintf(s, "Y Ofs: %d", map_gety_offset(map, y));
		gui_textout_centre_window(winInfo, s, 44, makecol8(0, 0, 255), -1);
		sprintf(s, "Idle: %d", idle_time);
		gui_textout_centre_window(winInfo, s, 64, makecol8(0, 255, 255), -1);
		sprintf(s, "Missed: %d", missed_frames);
		gui_textout_centre_window(winInfo, s, 74, makecol8(0, 255, 255), -1);
		gui_draw_window(winInfo, scrFlip);

		// blit it
		//vsync();
		blit(scrFlip, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);

		// check keys
		if (key[KEY_SPACE])
		{
			break;
		}

		if (key[KEY_LSHIFT])
			do_idle = 0;
		else
			do_idle = 1;

		if (key[KEY_CONTROL])
			gui_set_window_styles(winInfo, -1, WD_BLIT);
		else
			gui_set_window_styles(winInfo, -1, WD_TRANSLUCENT);

		if (key[KEY_PGDN])
		{
			dx--;
			if (dx < 1)
				dx = 1;
			dy--;
			if (dy < 1)
				dy = 1;
		}
		if (key[KEY_PGUP])
		{
			dx++;
			dy++;
		}

		if (key[KEY_RIGHT])
		{
			x+=dx;
			if (x > (map->w_width-1) - SCREEN_W)
			{
				x-=dx;
			}
		}

		if (key[KEY_DOWN])
		{
			y+=dy;
			if (y > (map->w_height-1) - SCREEN_H)
			{
				y-=dy;
			}
		}

		if (key[KEY_LEFT])
		{
			x-=dx;
			if (x < 0)
			{
				x = 0;
			}
		}

		if (key[KEY_UP])
		{
			y-=dy;
			if (y < 0)
			{
				y = 0;
			}
		}

		// Increment frame counter.
		frames++;
	}
	end_time = clock();

	// Clean up.
	unload_datafile_object(datf);
	destroy_map(map);
	overlay->tileset=NULL;
	destroy_map(overlay);
	destroy_bitmap(scrFlip);
	destroy_bitmap(scrMap);

	// Close down allegro.
	allegro_exit();

	// Report.
	printf("Tile Map, Copyright 1997 by Scott Deming.\n");
	printf("\nHow'd we do?\n");
	printf("===============================================================================\n");
	printf("  Time:  %3.2f\n", (float) ((end_time-start_time) / 100));
	printf("Frames:  %lu\n", frames);
	printf("   FPS:  %3.2f\n", (float) (float) frames / (float) ((end_time-start_time) / 100));
	printf("Missed:  %d\n", missed_frames);
	printf("  Idle:  %d (lowest was %d, highest %d)\n", idle_time, lowest_idle, highest_idle);
	printf("Screen:  %dX%d\n", screen_width, screen_height);
	printf("-------------------------------------------------------------------------------\n");
	printf("Note:  If \"Idle\" starts to get close to zero then things should be done to\n");
	printf("       speed things up.  When idle proc hits zero, we'll start missing frames\n");
	printf("       (indicated by \"Missed\") and things can start to get a bit jerky.\n");
	printf("       If \"Missed\" is greater than 0, start optimizing.\n");
	printf("       If you turned off the 30 fps timer halt then your lowest idle will be 0.\n");

	return 0;
}
Ejemplo n.º 6
0
int main(int argc, char **argv) {
	gui_initialize(&argc, &argv);
	gui_create_window_layout();
	gui_draw_window();

	if (argc == 2 && strcmp(argv[1], "--help") == 0) {
		printf("texview -- a texture and image file viewer.\n"
			"Usage: texview <filename1> <filename2>\n"
			"<filename2> is optional.\n");
		exit(1);
	}

	option_quiet = 1;
	current_nu_image_sets = 0;

	if (argc >= 2) {
		source_filename[0] = argv[1];
		source_filetype[0] = determine_filename_type(source_filename[0]);
	
		if (!(source_filetype[0] & FILE_TYPE_TEXTURE_BIT) && !(source_filetype[0] & FILE_TYPE_IMAGE_BIT)) {
			printf("Error -- expected image or texture filename as argument.\n");
			exit(1);
		}
		if (!file_exists(source_filename[0])) {
			printf("Error -- source file %s doesn't exist or is unreadable.\n", source_filename[0]);
			exit(1);
		}
		current_nu_image_sets = 1;
	}

	if (argc >= 3) {
		source_filename[1] = argv[2];
		source_filetype[1] = determine_filename_type(source_filename[1]);

		if (!(source_filetype[1] & FILE_TYPE_TEXTURE_BIT) && !(source_filetype[1] & FILE_TYPE_IMAGE_BIT)) {
			printf("Error -- expected image or texture filename as second argument.\n");
			exit(1);
		}

		if (!file_exists(source_filename[1])) {
			printf("Error -- source file %s doesn't exist or is unreadable.\n", source_filename[1]);
			exit(1);
		}	

		current_nu_image_sets = 2;
	}

	for (int j = 0; j < current_nu_image_sets; j++) {
		current_file_type[j] = source_filetype[j];
		if (source_filetype[j] & FILE_TYPE_TEXTURE_BIT) {
			current_nu_mipmaps[j] = load_texture(source_filename[j], source_filetype[j], 32,
				&current_texture[j][0]);
			for (int i = 0 ; i < current_nu_mipmaps[j]; i++)
				convert_texture_to_image(&current_texture[j][i], &current_image[j][i]);
		}
		else {
			load_image(source_filename[j], source_filetype[j], &current_image[j][0]);
			current_nu_mipmaps[j] = 1;
		}
		if (current_nu_mipmaps[j] > 1)
			printf("Found %d mipmap levels.\n", current_nu_mipmaps[j]);
	}

	current_rmse[0] = -1.0;
	if (current_nu_image_sets > 1)
		current_rmse[0] = compare_images(&current_image[0][0], &current_image[1][0]);

	for (int i = 0; i < current_nu_image_sets; i++) {
		if (!current_image[i][0].is_half_float &&
		current_image[i][0].bits_per_component == 8 &&
		current_image[i][0].nu_components > 2)
			convert_image_set(i);
	}
	gui_zoom_fit_to_window();
	for (int i = 0; i < current_nu_image_sets; i++)
		gui_create_base_surface(i);
	gui_draw_and_show_window();
	gui_run();
}
Ejemplo n.º 7
0
void gui_draw_and_show_window() {
    gui_draw_window();
    gui_update_drawing_area(window);
}
Ejemplo n.º 8
0
void gui_main(int argc, char **argv)
{
	extern unsigned long BootPageDirectory;
	paging_map(&BootPageDirectory, (void *)0xC0400000, (void *)0x400000, 1024*1024*8, 0x7);


	lx = x = GUI_WIDTH/2;
	ly = y = GUI_HEIGHT/2;
	x = y = 50;

	task_create(gui_daemon, 0, "moused", 0);
	
	unsigned long frames = 0;
	unsigned long tickstart = kinfo.ticks;
	while (1)
	{
		if (running == 0)
		{
			if (kinfo.gui == 1)
			{
				vga_set_mode(vgadev, GUI_WIDTH, GUI_HEIGHT, GUI_BPP);
				running = 1;
				tickstart = kinfo.ticks;
				frames = 0;
			}
			continue;
		}
		else if (kinfo.gui == 0)
		{
			vga_unset_mode(vgadev);
			running = 0;
			tty_scrolldown();
			continue;
		}
		
		frames++;
		
		// Clear
		vga_clear(vgadev, COLORBG);
		
		// Destop text
		vga_draw_string(vgadev, 0, 0, COLOR4, "EOS (Built %s %s)\n", __DATE__, __TIME__);
		vga_draw_string(vgadev, 0, 8, COLOR4, "Processor: %s", kinfo.cpuname);
		vga_draw_string(vgadev, 0, 16, COLOR4, "Memory: %dMB", kinfo.memory / 1024);
		vga_draw_string(vgadev, 0, 24, COLOR4, "Memory Used: %d", mm_used());

		vga_draw_string(vgadev, 0, 40, COLOR4, "mSPF %d", (kinfo.ticks-tickstart)/frames);
		if (kinfo.ticks - tickstart > 100)
			vga_draw_string(vgadev, 0, 48, COLOR4, "FPS %d", frames / ((kinfo.ticks-tickstart)/100));
		
		// Desktop icons
		//gui_draw_icon(vgadev, 8, 8);
		int winxnow, winynow;
		winxnow = winx;
		winynow = winy;
		gui_draw_window(vgadev, winxnow, winynow, 320, 240);
		gui_draw_icon(vgadev, winxnow+24, winynow+64);
		vga_draw_string(vgadev, winxnow+64, winynow+68, COLOR4, "Devices");
		gui_draw_icon(vgadev, winxnow+24, winynow+96);
		vga_draw_string(vgadev, winxnow+64, winynow+100, COLOR4, "Users");

		gui_draw_widget(vgadev, x, y);
		vga_flip(vgadev);
	}
}