Example #1
0
void change_minimap(){
	char minimap_file_name[256];
#ifndef	NEW_TEXTURES
	texture_cache_struct tex;
#endif	/* NEW_TEXTURES */

	if(minimap_win < 0)
		return;
	//save_exploration_map();

#ifdef	NEW_TEXTURES
	//unload all textures
	if(exploration_texture)
		glDeleteTextures(1,&exploration_texture);

	//make filename
	if (check_image_name(map_file_name, sizeof(minimap_file_name), minimap_file_name) == 1)
	{
		minimap_texture = load_texture_cached(minimap_file_name, tt_image);
	}
	else
	{
		minimap_texture = 0;
	}

	compass_tex = load_texture_cached("./textures/compass", tt_gui);
#else	/* NEW_TEXTURES */
	//unload all textures
	if(minimap_texture)
		glDeleteTextures(1,&minimap_texture);
	if(compass_tex)
		glDeleteTextures(1,&compass_tex);
	if(exploration_texture)
		glDeleteTextures(1,&exploration_texture);

	//make filename
	my_strcp(minimap_file_name,map_file_name);
	minimap_file_name[strlen(minimap_file_name)-4] = '\0';
	strcat(minimap_file_name, ".bmp");

	//load textures
	my_strcp(tex.file_name, minimap_file_name);
	if (!el_file_exists(minimap_file_name))
		minimap_texture = 0;
	else
		minimap_texture = load_bmp8_fixed_alpha(&tex,128);
	
	my_strcp(tex.file_name, "./textures/compass.bmp");
	compass_tex = load_bmp8_fixed_alpha_with_transparent_color(&tex,255,0,0,0);
#endif	/* NEW_TEXTURES */

	glGenTextures(1, &exploration_texture);
	bind_texture_id(exploration_texture);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
	//load_exploration_map();

#ifdef OPENGL_TRACE
CHECK_GL_ERRORS();
#endif //OPENGL_TRACE
}
Example #2
0
int switch_to_game_map()
{
#ifdef	NEW_TEXTURES
	char buffer[1024];
#else	/* NEW_TEXTURES */
	int len;
	texture_cache_struct tex;
#endif	/* NEW_TEXTURES */
	short int cur_cont;
	static short int old_cont = -1;
	
	/* check we loaded the mapinfo data */
	if (continent_maps == NULL || continent_maps[0].name == NULL)
	{
		LOG_TO_CONSOLE(c_yellow2,err_nomap_str);
		return 0;
	}
	
#ifdef	NEW_TEXTURES
	if (check_image_name(map_file_name, sizeof(buffer), buffer) == 1)
	{
		map_text = load_texture_cached(buffer, tt_image);
	}
	else
	{
		map_text = 0;
	}
#else	/* NEW_TEXTURES */
	my_strcp(tex.file_name,map_file_name);
	len=strlen(tex.file_name);
	tex.file_name[len-3]='b';
	tex.file_name[len-2]='m';
	tex.file_name[len-1]='p';
	tex.alpha = 128;
	if (!el_file_exists(tex.file_name))
		map_text = 0;
	else
		map_text=load_bmp8_fixed_alpha(&tex, tex.alpha);
#endif	/* NEW_TEXTURES */
	if(!map_text)
	{
		LOG_TO_CONSOLE(c_yellow2,err_nomap_str);
		return 0;
	}
	
	if (cur_map < 0)
	{
		cur_cont = -1;
	}
	else
	{
		cur_cont = continent_maps[cur_map].cont;
	}
	if (cur_cont != old_cont && cur_cont >= 0 && cur_cont < nr_continents)
	{
#ifdef	NEW_TEXTURES
		cont_text = load_texture_cached (cont_map_file_names[cur_cont], tt_image);
#else	/* NEW_TEXTURES */
		cont_text = load_texture_cache (cont_map_file_names[cur_cont], 128);
#endif	/* NEW_TEXTURES */
		old_cont = cur_cont;
	}
#ifdef DEBUG_MAP_SOUND
	cur_tab_map = cur_map;
#endif // DEBUG_MAP_SOUND
	
	if(current_cursor != CURSOR_ARROW)
	{
		change_cursor(CURSOR_ARROW);
	}
	return 1;
}
Example #3
0
void set_new_video_mode(int fs,int mode)
{
	int i;
#ifndef	NEW_TEXTURES
	int alpha;
#endif	/* NEW_TEXTURES */
	
	full_screen=fs;
	video_mode=mode;

	//now, clear all the textures...
#ifdef	NEW_TEXTURES
	unload_texture_cache();
#else	/* NEW_TEXTURES */
	for(i = 0; i < TEXTURE_CACHE_MAX; i++)
	{
		if(texture_cache[i].file_name[0])
		{
			glDeleteTextures(1,(GLuint*)&texture_cache[i].texture_id);
			texture_cache[i].texture_id=0;//force a reload
			CHECK_GL_ERRORS();
		}
	}

#ifndef MAP_EDITOR2
	//do the same for the actors textures...
	for(i=0;i<max_actors;i++)
		{
			if(actors_list[i])
				{
					if(actors_list[i]->remapped_colors || actors_list[i]->is_enhanced_model)//if it is not remapable, then it is already in the cache
						{
							glDeleteTextures(1,&actors_list[i]->texture_id);
							actors_list[i]->texture_id=0;
							CHECK_GL_ERRORS();
						}
				}
		}
#endif
#endif	/* NEW_TEXTURES */

	if (use_vertex_buffers)
	{
		e3d_object * obj;

#ifdef FASTER_MAP_LOAD
		for (i = 0; i < cache_e3d->num_items; i++)
#else
		for (i = 0; i < cache_e3d->max_item; i++)
#endif
		{
			if (!cache_e3d->cached_items[i]) continue;
			obj= cache_e3d->cached_items[i]->cache_item;
			free_e3d_va(obj);
		}
		CHECK_GL_ERRORS();
	}

#ifndef	NEW_TEXTURES
	ec_clear_textures();
#endif	/* NEW_TEXTURES */

	//destroy the current context

	init_video();
#ifndef WINDOWS
	// Re-enable window manager events, since the killing of the video 
	// subsystem turns them off.
	SDL_EventState (SDL_SYSWMEVENT, SDL_ENABLE);
#endif	
	resize_root_window();
	init_lights();
	disable_local_lights();
	reset_material();

	//reload the cursors
	load_cursors();
	build_cursors();
	change_cursor(current_cursor);

	ec_load_textures();

	//now, reload the textures
#ifndef	NEW_TEXTURES
	for(i = 0; i < TEXTURE_CACHE_MAX; i++)
	{
		if (texture_cache[i].file_name[0] && !texture_cache[i].load_err)
		{
			alpha=texture_cache[i].alpha;
			//our texture was freed, we have to reload it
			if(alpha<=0)
				texture_cache[i].texture_id = load_bmp8_color_key (&(texture_cache[i]), alpha);
	            	else
				texture_cache[i].texture_id = load_bmp8_fixed_alpha (&(texture_cache[i]), alpha);
		}
	}
	reload_fonts();

#ifndef MAP_EDITOR2
	//do the same for the actors textures...
	for(i=0;i<max_actors;i++)
		{
			if(actors_list[i])
				{
					if(actors_list[i]->remapped_colors)//if it is not remapable, then it is already in the cache
						{
							//reload the skin
							//actors_list[i]->texture_id=load_bmp8_remapped_skin(actors_list[i]->skin_name,
							//												   150,actors_list[i]->skin,actors_list[i]->hair,actors_list[i]->shirt,
							//												   actors_list[i]->pants,actors_list[i]->boots);
						}
					if(actors_list[i]->is_enhanced_model)
						{
							actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255);
						}
				}
		}
#endif
#endif	/* NEW_TEXTURES */
	
	//it is dependent on the window height...
	init_hud_interface (HUD_INTERFACE_LAST);
	new_minute();

	set_all_intersect_update_needed(main_bbox_tree);
	skybox_init_gl();

	// resize the EL root windows
	resize_all_root_windows (window_width, window_height);
	check_options();
	reload_tab_map = 1;
#ifdef NEW_CURSOR
	if (!sdl_cursors)
	{
		SDL_ShowCursor(0);
		SDL_WM_GrabInput(SDL_GRAB_OFF);
	}
#endif // NEW_CURSOR
}