void draw_default_lamp_on_texture (void) { screen *lamp_texture_screen; lamp_texture_screen = lamp1_texture_screen; set_system_texture_screen (lamp_texture_screen, TEXTURE_INDEX_AVCKPT_DISPLAY_LHS_MFD); //////////////////////////////////////// // // set up MFD 2D environment // //////////////////////////////////////// set_2d_active_environment (lamp1_env); // // window // set_2d_window (lamp1_env, LAMP1_WINDOW_X_MIN, LAMP1_WINDOW_Y_MIN, LAMP1_WINDOW_X_MAX, LAMP1_WINDOW_Y_MAX); // // viewport // lamp1_viewport_size = LAMP1_VIEWPORT_SMALL_SIZE; lamp1_viewport_x_org = LAMP1_VIEWPORT_TEXTURE_X_ORG; lamp1_viewport_y_org = LAMP1_VIEWPORT_TEXTURE_Y_ORG; lamp1_viewport_x_min = lamp1_viewport_x_org - (lamp1_viewport_size * 0.5); lamp1_viewport_y_min = lamp1_viewport_y_org - (lamp1_viewport_size * 0.5); lamp1_viewport_x_max = lamp1_viewport_x_org + (lamp1_viewport_size * 0.5) - 0.001; lamp1_viewport_y_max = lamp1_viewport_y_org + (lamp1_viewport_size * 0.5) - 0.001; set_2d_viewport (lamp1_env, lamp1_viewport_x_min, lamp1_viewport_y_min, lamp1_viewport_x_max, lamp1_viewport_y_max); set_active_screen (lamp1_texture_screen); if (lock_screen (lamp1_texture_screen)) { draw_default_indicator_lamps_3d (); flush_screen_texture_graphics (lamp1_texture_screen); unlock_screen (lamp1_texture_screen); } set_active_screen (video_screen); }
void draw_apache_upfront_display_on_texture (void) { set_active_screen (texture_screen); if (lock_screen (texture_screen)) { set_block (0, 0, 127, 127, clear_colour); display_messages (0.0, 0.0); flush_screen_texture_graphics (texture_screen); unlock_screen (texture_screen); } set_active_screen (video_screen); }
void draw_apache_altitude_counter(void) { set_active_screen (altitude_counter_screen); if (lock_screen (altitude_counter_screen)) { rgb_colour bg_colour; set_rgb_colour(bg_colour, 20, 20, 25, 255); set_block (0, 0, ALTITUDE_COUNTER_WIDTH - 1, ALTITUDE_COUNTER_HEIGHT - 1, bg_colour); draw_altitude_counter_digits(); flush_screen_texture_graphics(altitude_counter_screen); unlock_screen (altitude_counter_screen); } set_active_screen (video_screen); }
static void load_skin_bitmap (char *filespec, screen *texture, int size) { FILE *fp; BITMAPFILEHEADER bmfh; BITMAPINFOHEADER bmih; char *buffer, *p; int buffer_size, x, y; rgb_colour col; ASSERT (filespec); ASSERT (texture); fp = safe_fopen (filespec, "rb"); // // file header // fread (&bmfh, sizeof (bmfh), 1, fp); if (bmfh.bfType != BITMAP_ID) { safe_fclose (fp); debug_fatal ("%s is not a BMP file!", filespec); } // // info header // fread (&bmih, sizeof (bmih), 1, fp); if (bmih.biCompression != BI_RGB) { safe_fclose (fp); debug_fatal ("%s is not uncompressed RGB!", filespec); } if (bmih.biBitCount != 24) { safe_fclose (fp); debug_fatal ("%s is not 24 bit!", filespec); } if (bmih.biWidth != size) { safe_fclose (fp); debug_fatal ("%s is not %d pixels wide", filespec, size); } if (bmih.biHeight != size) { safe_fclose (fp); debug_fatal ("%s is not %d pixels high", filespec, size); } // // texture // buffer_size = size * size * 3; buffer = safe_malloc (buffer_size); fread (buffer, buffer_size, 1, fp); set_active_screen (texture); if (lock_screen (texture)) { p = buffer; for (y = size - 1; y >= 0; y--) { for (x = 0; x < size; x++) { col.b = *p++; col.g = *p++; col.r = *p++; col.a = 255; set_pixel (x, y, col); } } unlock_screen (texture); } set_active_screen (video_screen); safe_free (buffer); safe_fclose (fp); }
static void draw_area_ui_object (ui_object *obj) { float x, y, x1, y1, x2, y2; int redraw_flag = FALSE, masked, width, height, pitch; font_types font_id; area_ui_object *area; struct SCREEN *old_active_screen, *memory_graphic; unsigned short int *graphic; struct ZOOMABLE_GRAPHIC *zoomable_graphic; unsigned char *data; ui_object *parent; if (get_ui_object_redraw (obj)) { area = (area_ui_object *) obj->data; //debug_log ("AR_DRAW: drawing area %f, %f %f, %f", area->x, area->y, area->x_size, area->y_size); x1 = area->x; y1 = area->y; x2 = x1 + area->x_size; y2 = y1 + area->y_size; old_active_screen = get_active_screen (); if (get_ui_object_active_screen (obj)) { set_active_screen (get_ui_object_active_screen (obj)); } else { set_active_screen (video_screen); } if (lock_screen (active_screen)) { switch (get_ui_object_graphic_type (obj)) { case UI_OBJECT_GRAPHIC: { if (!get_ui_object_clear (obj)) { graphic = get_ui_object_graphic (obj); ui_draw_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); ui_draw_part_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } case UI_OBJECT_MEMORY_GRAPHIC: { memory_graphic = get_ui_object_memory_graphic (obj); if (lock_screen (memory_graphic)) { width = get_screen_width (memory_graphic); height = get_screen_height (memory_graphic); data = get_screen_data (memory_graphic); pitch = get_screen_pitch (memory_graphic); masked = get_ui_object_clear (obj); ui_draw_memory_graphic (obj, x1, y1, x2, y2, width, height, pitch, masked); unlock_screen (memory_graphic); } redraw_flag = TRUE; break; } case UI_OBJECT_ALPHA_GRAPHIC: { if (!get_ui_object_clear (obj)) { graphic = get_ui_object_graphic (obj); ui_draw_alpha_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); ui_draw_part_alpha_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } case UI_OBJECT_ZOOMABLE_PALETTE_GRAPHIC: { if (!get_ui_object_clear (obj)) { zoomable_graphic = get_ui_object_zoomable_palette_graphic (obj); draw_zoomable_graphic (zoomable_graphic, area->cx, area->cy, x1, y1, x2, y2, area->zoom); redraw_flag = TRUE; } break; } case UI_OBJECT_NO_GRAPHIC: default: { if (!get_ui_object_clear (obj)) { ui_draw_area (x1, y1, x2, y2); redraw_flag = TRUE; } } } // text position if (get_ui_object_text (obj)) { font_id = get_ui_font (); set_ui_font (get_ui_object_font (obj)); get_text_position (&x, &y, x1, y1, x2, y2, obj); ui_display_text (get_ui_object_text (obj), x, y); set_ui_font (font_id); redraw_flag = TRUE; } if (redraw_flag) { set_ui_repaint_area (x1 + ui_x_origin, y1 + ui_y_origin, x2 + ui_x_origin + 1, y2 + ui_y_origin + 1); } unlock_screen (active_screen); } set_active_screen (old_active_screen); area->redraw --; call_ui_object_draw_function (obj, NULL); } }
void draw_hind_hud_on_texture (void) { // // set active 3D environment now else 2D clipping will be affected // set_main_3d_full_screen_params (DISPLAY_3D_TINT_CLEAR, DISPLAY_3D_LIGHT_LEVEL_HIGH, DISPLAY_3D_NOISE_LEVEL_NONE); set_3d_active_environment (main_3d_env); //////////////////////////////////////// // // set up HUD 2D environment // //////////////////////////////////////// set_2d_active_environment (hud_env); // // window // set_2d_window (hud_env, HUD_WINDOW_X_MIN, HUD_WINDOW_Y_MIN, HUD_WINDOW_X_MAX, HUD_WINDOW_Y_MAX); if (hud_display_model) { // move HUD coordinate system with head movements to simulate the collimation effect (focus on infinity) float head_offset_x = 0.0, head_offset_y = 0.0, head_offset_z = 0.0; if (get_view_mode() == VIEW_MODE_COCKPIT_PANEL_SPECIAL_HAVOC_HUD) { if (custom_3d_models.arneh_mi24v_cockpit) get_hind_3d_cockpit_hud_view_position(&head_offset_x, &head_offset_y, &head_offset_z); } else { head_offset_x = -getViewpointOffsetX(head_offset_x); head_offset_y = -getViewpointOffsetY(head_offset_y); head_offset_z = -getViewpointOffsetY(head_offset_z); head_offset_x += wide_cockpit_position[WIDEVIEW_HIND_PILOT].c.x; head_offset_y += wide_cockpit_position[WIDEVIEW_HIND_PILOT].c.y; head_offset_z += wide_cockpit_position[WIDEVIEW_HIND_PILOT].c.z; } { // move texture UV coordinates to move and scale the texture unsigned i; for (i=0; i<num_texture_coordinates; i++) { float scale, u = hud_texture_uv_coordinates[i].u, v = hud_texture_uv_coordinates[i].v; // scale hud to keep same absolute size no matter distance to hud u -= 0.5; v -= 0.5; hud_distance = hud_position_z - head_offset_z; scale = hud_position_z / hud_distance; u *= scale; v *= scale; u += 0.5; v += 0.5; // then displace hud to keep it directly in front of pilot's position u -= (scale) * head_offset_x / hud_width; v += (scale) * (head_offset_y - hud_position_y) / hud_height; hud_display_model->surface_texture_points[i].u = u; hud_display_model->surface_texture_points[i].v = v; } } } // // viewport // draw_large_hud = FALSE; hud_viewport_size = HUD_VIEWPORT_SMALL_SIZE; hud_viewport_x_org = HUD_VIEWPORT_TEXTURE_X_ORG; hud_viewport_y_org = HUD_VIEWPORT_TEXTURE_Y_ORG; hud_viewport_x_min = hud_viewport_x_org - (hud_viewport_size * 0.5); hud_viewport_y_min = hud_viewport_y_org - (hud_viewport_size * 0.5); hud_viewport_x_max = hud_viewport_x_org + (hud_viewport_size * 0.5) - 0.001; hud_viewport_y_max = hud_viewport_y_org + (hud_viewport_size * 0.5) - 0.001; set_2d_viewport (hud_env, hud_viewport_x_min, hud_viewport_y_min, hud_viewport_x_max, hud_viewport_y_max); // // get screen co-ords (vitural cockpit texture - scaling only works near screen centre) // hud_screen_x_min = full_screen_x_mid - ((HUD_VIEWPORT_SMALL_SIZE / (640.0 * 2.0)) * full_screen_width); hud_screen_y_min = full_screen_y_mid - ((HUD_VIEWPORT_SMALL_SIZE / (480.0 * 2.0)) * full_screen_height); hud_screen_x_max = full_screen_x_mid + ((HUD_VIEWPORT_SMALL_SIZE / (640.0 * 2.0)) * full_screen_width) - 0.001; hud_screen_y_max = full_screen_y_mid + ((HUD_VIEWPORT_SMALL_SIZE / (480.0 * 2.0)) * full_screen_height) - 0.001; hud_screen_x_scale = 640.0 / full_screen_width; hud_screen_y_scale = 480.0 / full_screen_height; //////////////////////////////////////// // // draw HUD // //////////////////////////////////////// set_active_screen (hud_texture_screen); if (lock_screen (hud_texture_screen)) { rgb_colour clear_hud_colour; if (backup_sight_active) { set_rgb_colour (clear_hud_colour, backup_sight_colour.r, backup_sight_colour.g, backup_sight_colour.b, 0); } else { set_rgb_colour (clear_hud_colour, hud_colour.r, hud_colour.g, hud_colour.b, 0); } set_block (0, 0, HUD_VIEWPORT_SMALL_SIZE - 1, HUD_VIEWPORT_SMALL_SIZE - 1, clear_hud_colour); if (electrical_system_active()) if (backup_sight_active) draw_backup_sight(); else if (!hind_damage.head_up_display) { set_mono_font_colour (hud_colour); draw_layout_grid (); if (hud_mode == HUD_MODE_WEAPON) draw_weapon_mode_hud (TRUE); } // last pixel must be transparent because it's repeated when texture doesn't fill entire polygon draw_line(0, 0, 0, HUD_VIEWPORT_SMALL_SIZE - 1, clear_hud_colour); draw_line(0, 0, HUD_VIEWPORT_SMALL_SIZE - 1, 0, clear_hud_colour); draw_line(0, HUD_VIEWPORT_SMALL_SIZE - 1, HUD_VIEWPORT_SMALL_SIZE - 1, HUD_VIEWPORT_SMALL_SIZE - 1, clear_hud_colour); draw_line(HUD_VIEWPORT_SMALL_SIZE - 1, 0, HUD_VIEWPORT_SMALL_SIZE - 1, HUD_VIEWPORT_SMALL_SIZE - 1, clear_hud_colour); flush_screen_texture_graphics (hud_texture_screen); unlock_screen (hud_texture_screen); } set_active_screen (video_screen); }
static void draw_button_ui_object (ui_object *obj) { float // px1, // py1, x, //y, //vp_x1, //vp_y1, //vp_x2, //vp_y2, x_size, y_size, x_origin, y_origin, x1, y1, x2, y2; //nx1, //ny1, //nx2, //ny2; int redraw_flag = FALSE; // width, // height, // pitch; struct SCREEN *old_active_screen; // *memory_graphic; // unsigned short // *graphic; // unsigned char // *data; // ui_object // *parent; button_ui_object *button; button = obj->button; if (get_ui_object_redraw (obj)) { if (get_ui_object_autosize (obj)) { ui_object_autosize (obj); } //debug_log ("BU_DRAW: drawing button %f, %f %f, %f", button->area.x, button->area.y, button->area.x_size, button->area.y_size); //x1 = get_ui_object_x (obj); //y1 = get_ui_object_y (obj); x_size = get_ui_object_x_size (obj); y_size = get_ui_object_y_size (obj); x_origin = get_ui_object_x_origin (obj); y_origin = get_ui_object_y_origin (obj); ui_set_origin (x_origin, y_origin); //x2 = x1 + x_size;// - 1; //y2 = y1 + y_size;// - 1; x1 = get_ui_object_x (obj); y1 = get_ui_object_y (obj); x1 += x_origin; y1 += y_origin; x2 = x1 + get_ui_object_x_size (obj); y2 = y1 + get_ui_object_y_size (obj); old_active_screen = get_active_screen (); if (get_ui_object_active_screen (obj)) { set_active_screen (get_ui_object_active_screen (obj)); } else { set_active_screen (video_screen); } // debug set_active_screen (video_screen); // debug // if (lock_screen (active_screen)) { // memory_graphic = get_ui_object_memory_graphic (obj); if (!get_ui_object_clear (obj)) { switch (get_ui_object_graphic_type (obj)) { case UI_OBJECT_TEXTURE_GRAPHIC: { texture_graphic *graphic; if ((get_ui_object_state (obj) == UI_OBJECT_STATE_ON) && (get_ui_object_selected_texture_graphic (obj))) { graphic = get_ui_object_selected_texture_graphic (obj); } else if ((get_ui_object_highlighted (obj)) && (get_ui_object_highlighted_texture_graphic (obj))) { graphic = get_ui_object_highlighted_texture_graphic (obj); } else { graphic = get_ui_object_texture_graphic (obj); } if (graphic) { rgb_colour colour; real_colour text_colour; colour = get_ui_object_colour ( obj ); text_colour.red = colour.r; text_colour.green = colour.g; text_colour.blue = colour.b; text_colour.alpha = colour.a; ui_draw_texture_graphic (x1, y1, x2, y2, graphic, text_colour); } else { ui_draw_area (0, 0, x2 - x1, y2 - y1, obj); } break; } /* case UI_OBJECT_GRAPHIC: { if (get_ui_object_state (obj) == UI_OBJECT_STATE_ON) { graphic = get_ui_object_graphic (obj); ui_draw_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); px1 = get_ui_object_x (parent); py1 = get_ui_object_y (parent); x1 -= px1; x2 -= px1; y1 -= py1; y2 -= py1; ui_draw_part_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } case UI_OBJECT_MEMORY_GRAPHIC: { memory_graphic = get_ui_object_memory_graphic (obj); if (lock_screen (memory_graphic)) { width = get_screen_width (memory_graphic); height = get_screen_height (memory_graphic); data = get_screen_data (memory_graphic); pitch = get_screen_pitch (memory_graphic); ui_draw_memory_graphic (obj, x1, y1, x2, y2, width, height, pitch, FALSE); unlock_screen (memory_graphic); } redraw_flag = TRUE; break; } case UI_OBJECT_ALPHA_GRAPHIC: { if (!get_ui_object_clear (obj)) { graphic = get_ui_object_graphic (obj); ui_draw_alpha_graphic (x1, y1, x2, y2, graphic); redraw_flag = TRUE; } else { parent = get_ui_object_parent (obj); if (parent) { graphic = get_ui_object_graphic (parent); ui_draw_part_alpha_graphic (x1, y1, x2, y2, x1, y1, graphic); redraw_flag = TRUE; } } break; } */ case UI_OBJECT_NO_GRAPHIC: default: { int state; state = get_ui_object_state (obj); if ((state == UI_OBJECT_STATE_OFF) && (get_ui_object_highlighted (obj))) { state = UI_OBJECT_STATE_HIGHLIGHTED; } ui_draw_button (x1, y1, x2, y2, state); redraw_flag = TRUE; } } } if (get_ui_object_text (obj)) { const char *text_ptr; int count; float y3; ui_save_current_font (); ui_set_object_font (obj); // count number of lines spanned text_ptr = get_ui_object_text (obj); count = 0; while (text_ptr) { count ++; text_ptr = strchr (text_ptr, '\n'); // if found, step over it and display the next part of string if (text_ptr) { text_ptr ++; } } // now draw text text_ptr = get_ui_object_text (obj); get_text_y_position (&y3, y1, y2, text_ptr, get_ui_object_text_justify (obj), count); while (text_ptr) { get_text_x_position (&x, x1, x2, text_ptr, get_ui_object_text_justify (obj)); ui_display_text (text_ptr, x, y3); y3 += ui_get_font_height (); // check for carriage return text_ptr = strchr (text_ptr, '\n'); // if found, step over it and display the next part of string if (text_ptr) { text_ptr ++; } } ui_restore_current_font (); redraw_flag = TRUE; } if (redraw_flag) { set_ui_repaint_area (x1 - 1, y1 - 1, x2 + 1, y2 + 1); } // unlock_screen (active_screen); } set_active_screen (old_active_screen); button->area.redraw --; call_ui_object_draw_function (obj, NULL); } }
void draw_high_score_table (void) { char buffer [256]; int loop, length; screen *old_active_screen; pilot_score_type *item; old_active_screen = get_active_screen (); set_active_screen ( video_screen ); if ( lock_screen ( active_screen ) ) { // // draw leaderboard // for (loop = 0; loop < NUM_TABLE_ENTRIES; loop ++) { item = &pilot_high_score_table [loop]; if (item->valid) { set_ui_font_type (UI_FONT_ARIAL_14); if (item->side == ENTITY_SIDE_BLUE_FORCE) { set_ui_font_colour (ui_colour_blue); } else { set_ui_font_colour (ui_colour_orange); } length = ui_get_string_length (item->name); sprintf (buffer, "%s : %d", item->name, item->kills); // print text assuming game-exit overlay is 640x480 centred in the screen whatever res. ui_display_text (buffer, get_integer_screen_x_mid () - length, iy_640_480 + 180 + (loop * (ui_get_font_height () + 1))); } } // // update flash timer // flash_timer += (FLASH_RATE * get_delta_time ()); flash_timer = frac (flash_timer); unlock_screen ( active_screen ); } set_active_screen ( old_active_screen ); }
void draw_hind_mfd_on_texture (void) { if (!map_active) return; set_system_texture_screen (mfd_texture_screen, TEXTURE_INDEX_HIND_MAP_DISPLAY); //////////////////////////////////////// // // set up MFD 2D environment // //////////////////////////////////////// set_2d_active_environment (mfd_env); // // window // set_2d_window (mfd_env, MFD_WINDOW_X_MIN, MFD_WINDOW_Y_MIN, MFD_WINDOW_X_MAX, MFD_WINDOW_Y_MAX); // // viewport // if (custom_3d_models.arneh_mi24v_cockpit) { mfd_viewport_size = MFD_VIEWPORT_SIZE; mfd_texture_size = MFD_TEXTURE_SIZE; } else { mfd_viewport_size = MFD_HAVOC_VIEWPORT_SIZE; mfd_texture_size = MFD_HAVOC_TEXTURE_SIZE; } mfd_viewport_texture_x_org = mfd_texture_size / 2; mfd_viewport_texture_y_org = mfd_texture_size / 2; ASSERT (mfd_viewport_size <= mfd_texture_size); mfd_viewport_x_org = mfd_viewport_texture_x_org; mfd_viewport_y_org = mfd_viewport_texture_y_org; mfd_viewport_x_min = mfd_viewport_x_org - (mfd_viewport_size * 0.5); mfd_viewport_y_min = mfd_viewport_y_org - (mfd_viewport_size * 0.5); mfd_viewport_x_max = mfd_viewport_x_org + (mfd_viewport_size * 0.5) - 0.001; mfd_viewport_y_max = mfd_viewport_y_org + (mfd_viewport_size * 0.5) - 0.001; set_2d_viewport (mfd_env, mfd_viewport_x_min, mfd_viewport_y_min, mfd_viewport_x_max, mfd_viewport_y_max); //////////////////////////////////////// // // draw MFD display // //////////////////////////////////////// if (!hind_damage.navigation_computer && !map_up_to_date) { set_active_screen (mfd_texture_screen); if (lock_screen (mfd_texture_screen)) { set_block (0, 0, mfd_viewport_size - 1, mfd_viewport_size - 1, clear_mfd_colour); draw_layout_grid (); draw_map_display (); flush_screen_texture_graphics (mfd_texture_screen); unlock_screen (mfd_texture_screen); } set_active_screen (video_screen); } /* if(command_line_export_mfd) { export_screen=create_screen_for_system_texture (TEXTURE_INDEX_HIND_MAP_DISPLAY); copy_export_mfd(export_screen,NULL); } */ }