/* * Render a shield icon - basic shape is: * 1 3 * *************************** * *************************** * ** 2 4 ** * * * * 0 5 * * Defined by 6 points, must be passed in the order show above (i.e. a valid triangle strip) * */ void HudGaugeShield::renderShieldIcon(coord2d coords[6]) { int nx = 0, ny = 0, i; if ( gr_screen.rendering_to_texture != -1 ) { gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); } else { if ( reticle_follow ) { nx = HUD_nose_x; ny = HUD_nose_y; gr_resize_screen_pos(&nx, &ny); gr_set_screen_scale(base_w, base_h); gr_unsize_screen_pos(&nx, &ny); } else { gr_set_screen_scale(base_w, base_h); } } for (i = 0; i < 6; ++i) { coords[i].x += nx; coords[i].y += ny; } //gr_shield_icon(coords); g3_render_shield_icon(coords); gr_reset_screen_scale(); }
/* * Render a shield icon - basic shape is: * 1 3 * *************************** * *************************** * ** 2 4 ** * * * * 0 5 * * Defined by 6 points, must be passed in the order show above (i.e. a valid triangle strip) * */ void HudGaugeShield::renderShieldIcon(coord2d coords[6]) { int nx = 0, ny = 0, i; if ( gr_screen.rendering_to_texture != -1 ) { gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, target_w, target_h, true); // Respect the rendering display offset specified in the table nx = display_offset_x; ny = display_offset_y; // Transfer the offset position into actual texture coordinates gr_unsize_screen_pos(&nx, &ny); } else { if ( reticle_follow ) { nx = HUD_nose_x; ny = HUD_nose_y; gr_resize_screen_pos(&nx, &ny); gr_set_screen_scale(base_w, base_h); gr_unsize_screen_pos(&nx, &ny); } else { gr_set_screen_scale(base_w, base_h); } } for (i = 0; i < 6; ++i) { coords[i].x += nx; coords[i].y += ny; } //gr_shield_icon(coords); g3_render_shield_icon(coords); gr_reset_screen_scale(); }
// change in mouse position since last call void mouse_eval_deltas() { static int old_x = 0; static int old_y = 0; int tmp_x, tmp_y, cx, cy; Mouse_dx = Mouse_dy = Mouse_dz = 0; if (!mouse_inited) return; #ifdef WIN32 if (Mouse_mode == MOUSE_MODE_DI) { mouse_eval_deltas_di(); return; } #endif cx = gr_screen.max_w / 2; cy = gr_screen.max_h / 2; ENTER_CRITICAL_SECTION( mouse_lock ); POINT pnt; getWindowMousePos(&pnt); tmp_x = pnt.x; tmp_y = pnt.y; Mouse_dx = tmp_x - old_x; Mouse_dy = tmp_y - old_y; Mouse_dz = 0; // Speeds up the menu mouse on higher resolutions. The check for a // visible mouse should eliminate any possible gameplay changes. if ( mouse_is_visible() ) { gr_resize_screen_pos( &Mouse_dx, &Mouse_dy ); } if (Keep_mouse_centered && Mouse_hidden) { if (Mouse_dx || Mouse_dy) mouse_force_pos(cx, cy); old_x = cx; old_y = cy; } else { old_x = tmp_x; old_y = tmp_y; } LEAVE_CRITICAL_SECTION( mouse_lock ); //WMC - For On Mouse Moved trigger if(Mouse_dx != 0 || Mouse_dy != 0) { Script_system.RunCondition(CHA_MOUSEMOVED); } }
void gr_opengl_set_clip(int x, int y, int w, int h, int resize_mode) { // check for sanity of parameters if (x < 0) { x = 0; } if (y < 0) { y = 0; } int to_resize = (resize_mode != GR_RESIZE_NONE && (gr_screen.custom_size || (gr_screen.rendering_to_texture != -1))); int max_w = ((to_resize) ? gr_screen.max_w_unscaled : gr_screen.max_w); int max_h = ((to_resize) ? gr_screen.max_h_unscaled : gr_screen.max_h); if ((gr_screen.rendering_to_texture != -1) && to_resize) { gr_unsize_screen_pos(&max_w, &max_h); } if (x >= max_w) { x = max_w - 1; } if (y >= max_h) { y = max_h - 1; } if (x + w > max_w) { w = max_w - x; } if (y + h > max_h) { h = max_h - y; } if (w > max_w) { w = max_w; } if (h > max_h) { h = max_h; } gr_screen.offset_x_unscaled = x; gr_screen.offset_y_unscaled = y; gr_screen.clip_left_unscaled = 0; gr_screen.clip_right_unscaled = w-1; gr_screen.clip_top_unscaled = 0; gr_screen.clip_bottom_unscaled = h-1; gr_screen.clip_width_unscaled = w; gr_screen.clip_height_unscaled = h; if (to_resize) { gr_resize_screen_pos(&x, &y, &w, &h, resize_mode); } else { gr_unsize_screen_pos( &gr_screen.offset_x_unscaled, &gr_screen.offset_y_unscaled ); gr_unsize_screen_pos( &gr_screen.clip_right_unscaled, &gr_screen.clip_bottom_unscaled ); gr_unsize_screen_pos( &gr_screen.clip_width_unscaled, &gr_screen.clip_height_unscaled ); } gr_screen.offset_x = x; gr_screen.offset_y = y; gr_screen.clip_left = 0; gr_screen.clip_right = w-1; gr_screen.clip_top = 0; gr_screen.clip_bottom = h-1; gr_screen.clip_width = w; gr_screen.clip_height = h; gr_screen.clip_aspect = i2fl(w) / i2fl(h); gr_screen.clip_center_x = (gr_screen.clip_left + gr_screen.clip_right) * 0.5f; gr_screen.clip_center_y = (gr_screen.clip_top + gr_screen.clip_bottom) * 0.5f; // just return early if we aren't actually going to need the scissor test if ( (x == 0) && (y == 0) && (w == max_w) && (h == max_h) ) { GL_state.ScissorTest(GL_FALSE); return; } GL_state.ScissorTest(GL_TRUE); if(GL_rendering_to_texture) { glScissor(x, y, w, h); } else { glScissor(x, gr_screen.max_h-y-h, w, h); } }
/** * @param int x * @param int y * @param int w * @param int h * @param int sx * @param int sy * * @return void */ void d3d_stuff_char(D3DVERTEX2D *src_v, int x,int y,int w,int h,int sx,int sy, int bw, int bh, float u_scale, float v_scale, uint color) { float u0, u1, v0, v1; float x1, x2, y1, y2; float fbw = i2fl(bw); float fbh = i2fl(bh); // Rendition if(GlobalD3DVars::D3D_Antialiasing) { u0 = u_scale*(i2fl(sx)-0.5f) / fbw; v0 = v_scale*(i2fl(sy)+0.05f) / fbh; u1 = u_scale*(i2fl(sx+w)-0.5f) / fbw; v1 = v_scale*(i2fl(sy+h)-0.5f) / fbh; } else if (GlobalD3DVars::D3D_rendition_uvs ) { u0 = u_scale*(i2fl(sx)+0.5f) / fbw; v0 = v_scale*(i2fl(sy)+0.5f) / fbh; u1 = u_scale*(i2fl(sx+w)+0.5f) / fbw; v1 = v_scale*(i2fl(sy+h)+0.5f) / fbh; } else { u0 = u_scale*i2fl(sx)/ fbw; v0 = v_scale*i2fl(sy)/ fbh; u1 = u_scale*i2fl(sx+w)/ fbw; v1 = v_scale*i2fl(sy+h)/ fbh; } if(gr_screen.custom_size == -1) { x1 = i2fl(x+gr_screen.offset_x); y1 = i2fl(y+gr_screen.offset_y); x2 = i2fl(x+w+gr_screen.offset_x); y2 = i2fl(y+h+gr_screen.offset_y); } else { int nx = x+gr_screen.offset_x; int ny = y+gr_screen.offset_y; int nw = x+w+gr_screen.offset_x; int nh = y+h+gr_screen.offset_y; gr_resize_screen_pos(&nx, &ny); gr_resize_screen_pos(&nw, &nh); x1 = i2fl(nx); y1 = i2fl(ny); x2 = i2fl(nw); y2 = i2fl(nh); } #if 1 if(gr_screen.custom_size != -1) { u1 -= GlobalD3DVars::texture_adjust_u; v1 -= GlobalD3DVars::texture_adjust_v; } #endif // 0 src_v->sz = 0.99f; src_v->rhw = 1.0f; src_v->color = color; src_v->sx = x1; src_v->sy = y1; src_v->tu = u0; src_v->tv = v0; src_v++; // 1 src_v->sz = 0.99f; src_v->rhw = 1.0f; src_v->color = color; src_v->sx = x2; src_v->sy = y1; src_v->tu = u1; src_v->tv = v0; src_v++; // 2 src_v->sz = 0.99f; src_v->rhw = 1.0f; src_v->color = color; src_v->sx = x2; src_v->sy = y2; src_v->tu = u1; src_v->tv = v1; src_v++; // 0 src_v->sz = 0.99f; src_v->rhw = 1.0f; src_v->color = color; src_v->sx = x1; src_v->sy = y1; src_v->tu = u0; src_v->tv = v0; src_v++; // 2 src_v->sz = 0.99f; src_v->rhw = 1.0f; src_v->color = color; src_v->sx = x2; src_v->sy = y2; src_v->tu = u1; src_v->tv = v1; src_v++; // 3 src_v->sz = 0.99f; src_v->rhw = 1.0f; src_v->color = color; src_v->sx = x1; src_v->sy = y2; src_v->tu = u0; src_v->tv = v1; }
void mouse_eval_deltas_di() { int repeat = 1; HRESULT hr = 0; DIMOUSESTATE mouse_state; Mouse_dx = Mouse_dy = Mouse_dz = 0; if (!Di_mouse_inited) return; repeat = 1; memset(&mouse_state, 0, sizeof(mouse_state)); while (repeat) { repeat = 0; hr = Di_mouse->GetDeviceState(sizeof(mouse_state), &mouse_state); if ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED)) { // DirectInput is telling us that the input stream has // been interrupted. We aren't tracking any state // between polls, so we don't have any special reset // that needs to be done. We just re-acquire and // try again. Sleep(500); // Pause a half second... hr = Di_mouse->Acquire(); if (SUCCEEDED(hr)) repeat = 1; } } if (SUCCEEDED(hr)) { Mouse_dx = (int) mouse_state.lX; Mouse_dy = (int) mouse_state.lY; Mouse_dz = (int) mouse_state.lZ; } else { Mouse_dx = Mouse_dy = Mouse_dz = 0; } // Speeds up the menu mouse on higher resolutions. The check for a // visible mouse should eliminate any possible gameplay changes. if ( mouse_is_visible() ) { gr_resize_screen_pos( &Mouse_dx, &Mouse_dy ); } Mouse_x += Mouse_dx; Mouse_y += Mouse_dy; if (Mouse_x < 0) Mouse_x = 0; if (Mouse_y < 0) Mouse_y = 0; if (Mouse_x >= gr_screen.max_w) Mouse_x = gr_screen.max_w - 1; if (Mouse_y >= gr_screen.max_h) Mouse_y = gr_screen.max_h - 1; // keep the mouse inside our window so we don't switch applications or anything (debug bug people reported?) // JH: Dang! This makes the mouse readings in DirectInput act screwy! // mouse_force_pos(gr_screen.max_w / 2, gr_screen.max_h / 2); }