static __inline__ void draw_compass() { glPushMatrix(); glColor3f(1.0f,1.0f,1.0f); glTranslatef(float_minimap_size/2, float_minimap_size/2, 0.0f); if(rotate_minimap) glRotatef(-rz - 90, 0.0f,0.0f,1.0f ); else glRotatef(-90, 0.0f,0.0f,1.0f ); glRotatef(180, 1.0f,0.0f,0.0f ); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); #ifdef NEW_TEXTURES bind_texture(compass_tex); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex2f(-float_minimap_size/2, float_minimap_size/2); glTexCoord2f(0.0f, 0.0f); glVertex2f(float_minimap_size/2, float_minimap_size/2); glTexCoord2f(1.0f, 0.0f); glVertex2f(float_minimap_size/2, -float_minimap_size/2); glTexCoord2f(1.0f, 1.0f); glVertex2f(-float_minimap_size/2, -float_minimap_size/2); glEnd(); #else /* NEW_TEXTURES */ bind_texture_id(compass_tex); glBegin(GL_QUADS); glTexCoord2f(0.0f, 0.0f); glVertex2f(-float_minimap_size/2, float_minimap_size/2); glTexCoord2f(0.0f, 1.0f); glVertex2f(float_minimap_size/2, float_minimap_size/2); glTexCoord2f(1.0f, 1.0f); glVertex2f(float_minimap_size/2, -float_minimap_size/2); glTexCoord2f(1.0f, 0.0f); glVertex2f(-float_minimap_size/2, -float_minimap_size/2); glEnd(); #endif /* NEW_TEXTURES */ glDisable(GL_ALPHA_TEST); glDisable( GL_BLEND ); glPopMatrix(); }
void draw_game_map (int map, int mouse_mini) { int screen_x=0; int screen_y=0; int x=-1,y=-1; float x_size=0,y_size=0; GLuint map_small, map_large; actor *me; static int fallback_text = -1; // if we don't have a continent texture (instance may be), fallback to blank paper if (cont_text < 0) { if (fallback_text < 0) #ifdef NEW_TEXTURES { fallback_text = load_texture_cached("./textures/paper1", tt_gui); } #else /* NEW_TEXTURES */ fallback_text = load_texture_cache ("./textures/paper1.bmp", 0); #endif /* NEW_TEXTURES */ cont_text = fallback_text; } if(map){ #ifdef NEW_TEXTURES map_small = cont_text; #else /* NEW_TEXTURES */ map_small=get_texture_id(cont_text); #endif /* NEW_TEXTURES */ if(inspect_map_text == 0) { map_large=map_text; } else { map_large = inspect_map_text; } } else { map_small=map_text; #ifdef NEW_TEXTURES map_large = cont_text; #else /* NEW_TEXTURES */ map_large=get_texture_id(cont_text); #endif /* NEW_TEXTURES */ if(cur_map!=-1){ x_size = ((float)(continent_maps[cur_map].x_end - continent_maps[cur_map].x_start)) / tile_map_size_x; y_size = ((float)(continent_maps[cur_map].y_end - continent_maps[cur_map].y_start)) / tile_map_size_y; } else { x_size=y_size=0; } } glDisable(GL_DEPTH_TEST); glDisable(GL_LIGHTING); glViewport(0, 0 + hud_y, window_width-hud_x, window_height-hud_y); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(300, (GLdouble)0, (GLdouble)0, 200, -250.0, 250.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glDisable(GL_TEXTURE_2D); glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_QUADS); glVertex2i(0, 0); glVertex2i(300, 0); glVertex2i(300, 200); glVertex2i(0, 200); glEnd(); glEnable(GL_TEXTURE_2D); glColor3f(1.0f,1.0f,1.0f); #ifdef NEW_TEXTURES bind_texture(map_large); glBegin(GL_QUADS); glTexCoord2f(1.0f, 1.0f); glVertex3i(50,0,0); glTexCoord2f(1.0f, 0.0f); glVertex3i(50,200,0); glTexCoord2f(0.0f, 0.0f); glVertex3i(250,200,0); glTexCoord2f(0.0f, 1.0f); glVertex3i(250,0,0); glEnd(); #else /* NEW_TEXTURES */ bind_texture_id(map_large); glBegin(GL_QUADS); glTexCoord2f(1.0f,0.0f); glVertex3i(50,0,0); glTexCoord2f(1.0f,1.0f); glVertex3i(50,200,0); glTexCoord2f(0.0f,1.0f); glVertex3i(250,200,0); glTexCoord2f(0.0f,0.0f); glVertex3i(250,0,0); glEnd(); #endif /* NEW_TEXTURES */ if (mouse_mini) glColor4f (1.0f, 1.0f, 1.0f, 1.0f); else glColor4f (0.7f, 0.7f, 0.7f, 0.7f); glEnable(GL_ALPHA_TEST); #ifdef NEW_TEXTURES bind_texture(map_small); glBegin(GL_QUADS); glTexCoord2f(1.0f, 1.0f); glVertex3i(250,150,0); glTexCoord2f(1.0f, 0.0f); glVertex3i(250,200,0); glTexCoord2f(0.0f, 0.0f); glVertex3i(300,200,0); glTexCoord2f(0.0f, 1.0f); glVertex3i(300,150,0); glEnd(); #else /* NEW_TEXTURES */ bind_texture_id(map_small); glBegin(GL_QUADS); glTexCoord2f(1.0f,0.0f); glVertex3i(250,150,0); glTexCoord2f(1.0f,1.0f); glVertex3i(250,200,0); glTexCoord2f(0.0f,1.0f); glVertex3i(300,200,0); glTexCoord2f(0.0f,0.0f); glVertex3i(300,150,0); glEnd(); #endif /* NEW_TEXTURES */ glDisable(GL_ALPHA_TEST); glColor3f(1.0f,1.0f,1.0f); #ifdef NEW_TEXTURES bind_texture(legend_text); glBegin(GL_QUADS); glTexCoord2f(1.0f, 1.0f); glVertex3i(250,50,0); glTexCoord2f(1.0f, 0.0f); glVertex3i(250,150,0); glTexCoord2f(0.0f, 0.0f); glVertex3i(300,150,0); glTexCoord2f(0.0f, 1.0f); glVertex3i(300,50,0); glEnd(); #else /* NEW_TEXTURES */ get_and_set_texture_id(legend_text); glBegin(GL_QUADS); glTexCoord2f(1.0f,0.0f); glVertex3i(250,50,0); glTexCoord2f(1.0f,1.0f); glVertex3i(250,150,0); glTexCoord2f(0.0f,1.0f); glVertex3i(300,150,0); glTexCoord2f(0.0f,0.0f); glVertex3i(300,50,0); glEnd(); #endif /* NEW_TEXTURES */ // this is necessary for the text over map // need to execute this for any map now // because of the coordinate display - Lachesis if(map/*&&(adding_mark||max_mark>0)*/){ glViewport(0, 0 + hud_y, window_width-hud_x, window_height-hud_y); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho((GLdouble)0, (GLdouble)300, (GLdouble)200, (GLdouble)0, -250.0, 250.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); // Draw help for toggling the mini-map { char buf[80]; char keybuf[20]; glEnable(GL_TEXTURE_2D); safe_snprintf(buf, sizeof(buf), "%s %s", win_minimap, get_key_string(K_MINIMAP, keybuf, sizeof(keybuf))); glColor3f (1.0f, 1.0f, 0.0f); draw_string_zoomed(25 - 1.5*strlen(buf), 150 + 43, (const unsigned char *)buf, 1, 0.3); } // draw a temporary mark until the text is entered if (adding_mark) { int x = mark_x; int y = mark_y; screen_x=(51+200*x/(tile_map_size_x*6)); screen_y=201-200*y/(tile_map_size_y*6); glColor3f(1.0f,1.0f,0.0f); glDisable(GL_TEXTURE_2D); glBegin(GL_LINES); glVertex2i(screen_x-9*mapmark_zoom,screen_y-9*mapmark_zoom); glVertex2i(screen_x+6*mapmark_zoom,screen_y+6*mapmark_zoom); glVertex2i(screen_x+6*mapmark_zoom,screen_y-9*mapmark_zoom); glVertex2i(screen_x-9*mapmark_zoom,screen_y+6*mapmark_zoom); glEnd(); glEnable(GL_TEXTURE_2D); glColor3f(1.0f,1.0f,0.0f); draw_string_zoomed (screen_x, screen_y, (unsigned char*)input_text_line.data, 1, mapmark_zoom); } draw_mark_filter(); if(inspect_map_text == 0) { draw_marks(marks, max_mark, tile_map_size_x, tile_map_size_y); draw_coordinates(tile_map_size_x, tile_map_size_y); } else { draw_marks(temp_marks, max_temp_mark, temp_tile_map_size_x, temp_tile_map_size_y); draw_coordinates(temp_tile_map_size_x, temp_tile_map_size_y); } } //if we're following a path, draw the destination on the map if (pf_follow_path && inspect_map_text == 0) { int px = pf_dst_tile->x; int py = pf_dst_tile->y; if (!map) { if (cur_map!=-1) { screen_x = 300 - (50 + 200 * ( (px * x_size / 6) + continent_maps[cur_map].x_start) / 512); screen_y = 200 * ( (py * y_size / 6) + continent_maps[cur_map].y_start) / 512; } else { screen_x = screen_y = 0; } } else { screen_x=51 +200*px/(tile_map_size_x*6); screen_y=201-200*py/(tile_map_size_y*6); } glColor3f(1.0f,0.0f,0.0f); glDisable(GL_TEXTURE_2D); glBegin(GL_LINES); glVertex2i(screen_x-9*mapmark_zoom,screen_y-9*mapmark_zoom); glVertex2i(screen_x+6*mapmark_zoom,screen_y+6*mapmark_zoom); glVertex2i(screen_x+6*mapmark_zoom,screen_y-9*mapmark_zoom); glVertex2i(screen_x-9*mapmark_zoom,screen_y+6*mapmark_zoom); glEnd(); } //ok, now let's draw our possition... if ( (me = get_our_actor ()) != NULL && inspect_map_text == 0) { x = me->x_tile_pos; y = me->y_tile_pos; } else { //We don't exist (usually happens when teleporting) x = -1; y = -1; } if (!map) { if (cur_map != -1) { screen_x = 300 - (50 + 200 * ( (x * x_size / 6) + continent_maps[cur_map].x_start) / 512); screen_y = 200 * ( (y * y_size / 6) + continent_maps[cur_map].y_start) / 512; } else { screen_x = screen_y = 0; } } else { screen_x=51 +200*x/(tile_map_size_x*6); screen_y=201-200*y/(tile_map_size_y*6); } if ( (map || !dungeon) && x != -1 ) { glColor3f (0.0f, 0.0f, 1.0f); glDisable (GL_TEXTURE_2D); glBegin (GL_LINES); glVertex2i(screen_x-9*mapmark_zoom,screen_y-9*mapmark_zoom); glVertex2i(screen_x+6*mapmark_zoom,screen_y+6*mapmark_zoom); glVertex2i(screen_x+6*mapmark_zoom,screen_y-9*mapmark_zoom); glVertex2i(screen_x-9*mapmark_zoom,screen_y+6*mapmark_zoom); glEnd(); } if(!map && show_continent_map_boundaries && cont_text!=fallback_text) { int i; /* Convert mouse coordinates to map coordinates (stolen from pf_get_mouse_position()) */ int min_mouse_x = (window_width-hud_x)/6; int min_mouse_y = 0; int max_mouse_x = min_mouse_x+((window_width-hud_x)/1.5); int max_mouse_y = window_height - hud_y; int screen_map_width = max_mouse_x - min_mouse_x; int screen_map_height = max_mouse_y - min_mouse_y; int m_px = ((mouse_x-min_mouse_x) * 512) / screen_map_width; int m_py = 512 - ((mouse_y * 512) / screen_map_height); int mouse_over = -1; glColor3f (0.267f, 0.267f, 0.267f); glDisable (GL_TEXTURE_2D); glBegin(GL_LINES); /* Draw borders for the maps except the one with the mouse over it */ glColor3f (0.267f, 0.267f, 0.267f); for(i = 0; continent_maps[i].name != NULL; i++) { if(continent_maps[i].cont == continent_maps[cur_map].cont) { if(!mouse_mini && mouse_over == -1 && m_px > continent_maps[i].x_start && m_px < continent_maps[i].x_end && m_py > continent_maps[i].y_start && m_py < continent_maps[i].y_end) { /* Mouse over this map */ mouse_over = i; } else { int x_start = 300-(50+200*continent_maps[i].x_start/512); int x_end = 300-(50+200*continent_maps[i].x_end/512); int y_start = 200*continent_maps[i].y_start / 512; int y_end = 200*continent_maps[i].y_end / 512; glVertex2i(x_start, y_start); glVertex2i(x_start, y_end); glVertex2i(x_start, y_end); glVertex2i(x_end, y_end); glVertex2i(x_end, y_end); glVertex2i(x_end, y_start); glVertex2i(x_end, y_start); glVertex2i(x_start, y_start); } } } /* Draw border for the map with the mouse over it */ if(mouse_over >= 0) { float flash_effect_colour = 0.90f - sin((float)SDL_GetTicks()/100.0f) / 10.0f; int x_start = 300-(50+200*continent_maps[mouse_over].x_start/512); int x_end = 300-(50+200*continent_maps[mouse_over].x_end/512); int y_start = 200*continent_maps[mouse_over].y_start / 512; int y_end = 200*continent_maps[mouse_over].y_end / 512; glColor3f(flash_effect_colour, flash_effect_colour, flash_effect_colour); glVertex2i(x_start, y_start); glVertex2i(x_start, y_end); glVertex2i(x_start, y_end); glVertex2i(x_end, y_end); glVertex2i(x_end, y_end); glVertex2i(x_end, y_start); glVertex2i(x_end, y_start); glVertex2i(x_start, y_start); } glEnd(); } #ifdef DEBUG_MAP_SOUND // If we are in map view (not continent view) draw the sound area boundaries if (map) { print_sound_boundaries(cur_tab_map); } #endif // DEBUG_MAP_SOUND if (map) { glMatrixMode(GL_MODELVIEW); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); } glEnable (GL_TEXTURE_2D); glColor3f (1.0f, 1.0f, 1.0f); glMatrixMode (GL_MODELVIEW); glPopMatrix (); glMatrixMode (GL_PROJECTION); glPopMatrix (); glMatrixMode (GL_MODELVIEW); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE }
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 }
static __inline__ void draw_map(window_info *win,float zoom_multip, float px, float py) { float sx = 0.0f, sy = 0.0f; int i; float x, y; glPushMatrix(); sx = float_minimap_size/2; sy = float_minimap_size/2; glTranslatef(sx, sy, 0.0f); glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); glEnable(GL_STENCIL_TEST); glStencilFunc(GL_ALWAYS, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glDepthMask(GL_FALSE); glColor3f(0.0f,0.0f,0.0f); glBegin(GL_POLYGON); for (i=0; i<=360; i +=10) { x = sin((i)*0.0174532925f)/2*float_minimap_size; y = cos((i)*0.0174532925f)/2*float_minimap_size; glVertex2f(x, y); } glEnd(); glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // re-enable the drawing in the current buffer glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glDepthMask(GL_TRUE); glEnable(GL_TEXTURE_2D); //draw the map #ifdef NEW_TEXTURES bind_texture(minimap_texture); #else /* NEW_TEXTURES */ bind_texture_id(minimap_texture); #endif /* NEW_TEXTURES */ glColor4f(1.0f,1.0f,1.0f,1.0f); rotate_at_player(zoom_multip,px,py); glBegin(GL_QUADS); #ifdef NEW_TEXTURES glTexCoord2f(0.0f, 1.0f); glVertex2f(-float_minimap_size/2, float_minimap_size/2); glTexCoord2f(1.0f, 1.0f); glVertex2f(float_minimap_size/2, float_minimap_size/2); glTexCoord2f(1.0f, 0.0f); glVertex2f(float_minimap_size/2, -float_minimap_size/2); glTexCoord2f(0.0f, 0.0f); glVertex2f(-float_minimap_size/2, -float_minimap_size/2); #else /* NEW_TEXTURES */ glTexCoord2f(0.0f, 0.0f); glVertex2f(-float_minimap_size/2, float_minimap_size/2); glTexCoord2f(1.0f, 0.0f); glVertex2f(float_minimap_size/2, float_minimap_size/2); glTexCoord2f(1.0f, 1.0f); glVertex2f(float_minimap_size/2, -float_minimap_size/2); glTexCoord2f(0.0f, 1.0f); glVertex2f(-float_minimap_size/2, -float_minimap_size/2); #endif /* NEW_TEXTURES */ glEnd(); glDisable(GL_STENCIL_TEST); glPopMatrix(); if (compass_tex) { //draw the compass texture draw_compass(); } }
void draw_enhanced_actor(actor * actor_id) { int i; double x_pos,y_pos,z_pos; float x_rot,y_rot,z_rot; //int texture_id; char *cur_frame; float healtbar_z=0; bind_texture_id(actor_id->texture_id); cur_frame=actor_id->tmp.cur_frame; //now, go and find the current frame i=get_frame_number(actor_id->body_parts->head, cur_frame);; if(i >= 0)healtbar_z=actor_id->body_parts->head->offsetFrames[i].box.max_z; glPushMatrix();//we don't want to affect the rest of the scene x_pos=actor_id->tmp.x_pos; y_pos=actor_id->tmp.y_pos; z_pos=actor_id->tmp.z_pos; if(z_pos==0.0f)//actor is walking, as opposed to flying, get the height underneath z_pos=-2.2f+height_map[actor_id->tmp.y_tile_pos*tile_map_size_x*6+actor_id->tmp.x_tile_pos]*0.2f; glTranslatef(x_pos+0.25f, y_pos+0.25f, z_pos); x_rot=actor_id->tmp.x_rot; y_rot=actor_id->tmp.y_rot; z_rot=actor_id->tmp.z_rot; z_rot+=180;//test z_rot=-z_rot; glRotatef(z_rot, 0.0f, 0.0f, 1.0f); glRotatef(x_rot, 1.0f, 0.0f, 0.0f); glRotatef(y_rot, 0.0f, 1.0f, 0.0f); if(actor_id->body_parts->legs)draw_model(actor_id->body_parts->legs,cur_frame,actor_id->ghost); if(actor_id->body_parts->torso)draw_model(actor_id->body_parts->torso,cur_frame,actor_id->ghost); if(actor_id->body_parts->head)draw_model(actor_id->body_parts->head,cur_frame,actor_id->ghost); if(actor_id->body_parts->weapon) { int glow; draw_model(actor_id->body_parts->weapon,cur_frame,actor_id->ghost); glow=actor_id->body_parts->weapon_glow; if(glow!=GLOW_NONE)draw_model_halo(actor_id->body_parts->weapon,cur_frame,glow_colors[glow].r,glow_colors[glow].g,glow_colors[glow].b); } if(actor_id->body_parts->shield)draw_model(actor_id->body_parts->shield,cur_frame,actor_id->ghost); if(actor_id->body_parts->helmet)draw_model(actor_id->body_parts->helmet,cur_frame,actor_id->ghost); if(actor_id->body_parts->cape)draw_model(actor_id->body_parts->cape,cur_frame,actor_id->ghost); ////// glPopMatrix();//restore the scene //now, draw their damage glPushMatrix(); glTranslatef(x_pos+0.25f, y_pos+0.25f, z_pos); glRotatef(-rz, 0.0f, 0.0f, 1.0f); draw_actor_banner(actor_id, healtbar_z); glPopMatrix();//we don't want to affect the rest of the scene //if(!actor_id->ghost)glEnable(GL_LIGHTING); }