示例#1
0
//for timer debug, #define TIMER
void generic_render_eff_stream(generic_anim *ga)
{
	if(ga->current_frame == ga->previous_frame)
		return;
	ubyte bpp = 32;
	if(ga->use_hud_color)
		bpp = 8;
	#ifdef TIMER
		int start_time = timer_get_fixed_seconds();
	#endif

	#ifdef TIMER
		mprintf(("=========================\n"));
		mprintf(("frame: %d\n", ga->current_frame));
	#endif
		char frame_name[MAX_FILENAME_LEN];
		snprintf(frame_name, MAX_FILENAME_LEN, "%s_%.4d", ga->filename, ga->current_frame);
		if(bm_reload(ga->eff.next_frame, frame_name) == ga->eff.next_frame)
		{
			bitmap* next_frame_bmp = bm_lock(ga->eff.next_frame, bpp, (bpp==8)?BMP_AABITMAP:BMP_TEX_NONCOMP, true);
			if(next_frame_bmp->data)
				gr_update_texture(ga->bitmap_id, bpp, (ubyte*)next_frame_bmp->data, ga->width, ga->height);
			bm_unlock(ga->eff.next_frame);
			bm_unload(ga->eff.next_frame, 0, true);
			if (ga->current_frame == ga->num_frames-1)
			{
				snprintf(frame_name, MAX_FILENAME_LEN, "%s_0001", ga->filename);
				bm_reload(ga->eff.next_frame, frame_name);
			}
		}
	#ifdef TIMER
		mprintf(("end: %d\n", timer_get_fixed_seconds() - start_time));
		mprintf(("=========================\n"));
	#endif
}
示例#2
0
/*
 * @brief apng specific animation rendering
 *
 * @param [in] ga  pointer to generic_anim struct
 */
void generic_render_png_stream(generic_anim* ga)
{
	if(ga->current_frame == ga->previous_frame) {
		return;
	}

	try {
		if ((ga->direction & GENERIC_ANIM_DIRECTION_BACKWARDS) && (ga->previous_frame != -1)) {
			// mainhall door anims start backwards to ensure they stay shut
			// in that case (i.e. previous_frame is -1) we actually want to call
			// next_frame, in order to retrieve the 1st frame of the animation
			ga->png.anim->prev_frame();
		}
		else {
			ga->png.anim->next_frame();
		}
	}
	catch (const apng::ApngException& e) {
		nprintf(("apng", "Unable to get next/prev apng frame: %s\n", e.what()));
		return;
	}

	bm_lock(ga->bitmap_id, ga->png.anim->bpp, BMP_TEX_NONCOMP, true);  // lock in 32 bpp for png
	ubyte bpp = ga->png.anim->bpp;
	if (ga->use_hud_color) {
		bpp = 8;
	}
	gr_update_texture(ga->bitmap_id, bpp, ga->buffer, ga->width, ga->height);  // this will convert to 8 bpp if required
	bm_unlock(ga->bitmap_id);
}
示例#3
0
void UI_WINDOW::set_mask_bmap(int bmap, const char *name)
{
	// int i;

	// init_tooltips();
	Assert(bmap >= 0);	

	if (bmap != mask_bmap_id) {
		if (mask_bmap_id >= 0){
			bm_unlock(mask_bmap_id);
		}

		mask_w = -1;
		mask_h = -1;

		mask_bmap_id = bmap;
		mask_bmap_ptr = bm_lock(mask_bmap_id, 8, BMP_AABITMAP);
		mask_data = (ubyte *) mask_bmap_ptr->data;		
		bm_get_info( bmap, &mask_w, &mask_h );
		tt_group = -1;
		/*
		for (i=0; i<Num_tooltip_groups; i++){
			if (!stricmp(Tooltip_groups[i].mask, name)){
				tt_group = i;
			}
		}
		*/
	} else {
		nprintf(("UI", "Warning: tried to switch bitmap mask to the same bitmap\n"));
	}
}
示例#4
0
void training_menu_close()
{
	if (training_menu_inited) {
		// done with the bitmap, so unlock it
		bm_unlock(trainingMenuMask);

		// unload the bitmaps
		bm_unload(trainingMenuBitmap);
		bm_unload(trainingMenuMask);

		training_menu_inited = 0;
		snazzy_menu_close();
	}
}
// maybe try and reload player squad logo bitmaps
void multi_data_maybe_reload()
{
	int idx;

	// go through all connected and try to reload their images if necessary
	for(idx=0; idx<MAX_PLAYERS; idx++){
		if(MULTI_CONNECTED(Net_players[idx]) && strlen(Net_players[idx].m_player->m_squad_filename) && (Net_players[idx].m_player->insignia_texture == -1)){
			Net_players[idx].m_player->insignia_texture = bm_load_duplicate(Net_players[idx].m_player->m_squad_filename);

			// if the bitmap loaded properly, lock it as a transparent texture
			if(Net_players[idx].m_player->insignia_texture != -1){
				bm_lock(Net_players[idx].m_player->insignia_texture, 16, BMP_TEX_XPARENT);
				bm_unlock(Net_players[idx].m_player->insignia_texture);
			}
		}
	}	
}
示例#6
0
void UI_WINDOW::release_bitmaps()
{
	if (mask_bmap_ptr) {
		// done with the mask bitmap, so unlock it
		bm_unlock(mask_bmap_id);

		// unload the bitmaps
		if (mask_bmap_id >= 0) {
			bm_release(mask_bmap_id);
			mask_bmap_id = -1;
		}

		mask_data = NULL;
		mask_bmap_ptr = NULL;
	}

	if (foreground_bmap_id >= 0) {
		bm_release(foreground_bmap_id);
		foreground_bmap_id = -1;
	}
}
// will attempt to load an insignia bitmap and set it as active for the player
void player_set_squad_bitmap(player *p, char *fname, bool ismulti)
{
	// sanity check
	if(p == NULL){
		return;
	}

	char *squad_pic_p;
	if (ismulti) {
		squad_pic_p = p->m_squad_filename;
	} else {
		squad_pic_p = p->s_squad_filename;
	}

	// if he has another bitmap already - unload it
	if (p->insignia_texture > 0) {
		bm_release(p->insignia_texture);
	}

	p->insignia_texture = -1;

	// try and set the new one
	if (fname != squad_pic_p) {
		strncpy(squad_pic_p, fname, MAX_FILENAME_LEN);
	}

	if (squad_pic_p[0] != '\0') {
		p->insignia_texture = bm_load_duplicate(fname);

		// lock is as a transparent texture
		if (p->insignia_texture != -1) {
			bm_lock(p->insignia_texture, 16, BMP_TEX_XPARENT);
			bm_unlock(p->insignia_texture);
		}
	}
}