From d5e9951c59492e2532471d42d60379a2c2953c5b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 5 Mar 2014 06:35:42 +0100 Subject: [PATCH] (XDK D3D) Simplify set_rotation --- xdk/xdk_d3d.cpp | 30 ++++++------------------------ xdk/xdk_d3d.h | 1 + 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/xdk/xdk_d3d.cpp b/xdk/xdk_d3d.cpp index f97f8252e7..0f1cb3ccf0 100644 --- a/xdk/xdk_d3d.cpp +++ b/xdk/xdk_d3d.cpp @@ -245,35 +245,19 @@ static void xdk_d3d_calculate_rect(void *data, unsigned width, unsigned height, } } -static void xdk_d3d_set_rotation(void *data, unsigned orientation) +static void xdk_d3d_set_rotation(void *data, unsigned rot) { (void)data; xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data; - FLOAT angle = 0; - - switch(orientation) - { - case ORIENTATION_NORMAL: - angle = M_PI * 0 / 180; - break; - case ORIENTATION_FLIPPED_ROTATED: - angle = M_PI * 90 / 180; - break; - case ORIENTATION_FLIPPED: - angle = M_PI * 180 / 180; - break; - case ORIENTATION_VERTICAL: - angle = M_PI * 270 / 180; - break; - } + d3d->dev_rotation = rot; #if defined(HAVE_HLSL) /* TODO: Move to D3DXMATRIX here */ - hlsl_set_proj_matrix(XMMatrixRotationZ(angle)); + hlsl_set_proj_matrix(XMMatrixRotationZ(d3d->dev_rotation * (M_PI / 2.0))); #elif defined(_XBOX1) D3DXMATRIX p_out, p_rotate; D3DXMatrixIdentity(&p_out); - D3DXMatrixRotationZ(&p_rotate, angle); + D3DXMatrixRotationZ(&p_rotate, d3d->dev_rotation * (M_PI / 2.0)); RD3DDevice_SetTransform(d3d->d3d_render_device, D3DTS_WORLD, &p_rotate); RD3DDevice_SetTransform(d3d->d3d_render_device, D3DTS_VIEW, &p_out); @@ -442,7 +426,7 @@ static void *xdk_d3d_init(const video_info_t *video, const input_driver_t **inpu #if defined(_XBOX1) // use an orthogonal matrix for the projection matrix D3DXMATRIX mat; - D3DXMatrixOrthoOffCenterLH(&mat, 0, d3d->win_width , d3d->win_height , 0, 0.0f, 1.0f); + D3DXMatrixOrthoOffCenterLH(&mat, 0, d3d->screen_width , d3d->screen_height , 0, 0.0f, 1.0f); d3d->dev->SetTransform(D3DTS_PROJECTION, &mat); @@ -535,8 +519,6 @@ static void *xdk_d3d_init(const video_info_t *video, const input_driver_t **inpu if (input && input_data) d3d->ctx_driver->input_driver(input, input_data); - xdk_d3d_set_rotation(d3d, g_settings.video.rotation); - #if defined(_XBOX1) font_x = 0; font_y = 0; @@ -640,7 +622,7 @@ static void xdk_d3d_draw_texture(void *data) d3d->dev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); d3d->dev->SetRenderState(D3DRS_ALPHABLENDENABLE, true); texture_image_render(menu_texture, menu_texture->x, menu_texture->y, - d3d->win_width, d3d->win_height, true); + d3d->screen_width, d3d->screen_height, true); d3d->dev->SetRenderState(D3DRS_ALPHABLENDENABLE, false); } #endif diff --git a/xdk/xdk_d3d.h b/xdk/xdk_d3d.h index 46e041b092..bc7d44b132 100644 --- a/xdk/xdk_d3d.h +++ b/xdk/xdk_d3d.h @@ -55,6 +55,7 @@ typedef struct xdk_d3d_video unsigned last_height; unsigned screen_width; unsigned screen_height; + unsigned dev_rotation; unsigned tex_w, tex_h; LPDIRECT3D g_pD3D; LPDIRECT3DDEVICE dev;