2013-12-31 22:19:51 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2014-01-01 00:50:59 +00:00
|
|
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
|
|
* Copyright (C) 2011-2014 - Daniel De Matteis
|
|
|
|
* Copyright (C) 2012-2014 - OV2
|
2013-12-31 22:19:51 +00:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2014-09-14 04:45:47 +00:00
|
|
|
#include "../d3d/d3d.hpp"
|
2014-03-08 04:18:05 +00:00
|
|
|
#include "win32_common.h"
|
2014-03-08 03:13:20 +00:00
|
|
|
|
|
|
|
#include "../gfx_common.h"
|
2013-12-31 22:19:51 +00:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#ifndef _XBOX
|
|
|
|
#pragma comment( lib, "d3d9" )
|
|
|
|
#pragma comment( lib, "d3dx9" )
|
|
|
|
#pragma comment( lib, "cgd3d9" )
|
|
|
|
#pragma comment( lib, "dxguid" )
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2014-03-08 03:13:20 +00:00
|
|
|
#if defined(_XBOX1)
|
|
|
|
#define XBOX_PRESENTATIONINTERVAL D3DRS_PRESENTATIONINTERVAL
|
|
|
|
#define PresentationInterval FullScreen_PresentationInterval
|
|
|
|
#elif defined(_XBOX360)
|
|
|
|
#define XBOX_PRESENTATIONINTERVAL D3DRS_PRESENTINTERVAL
|
|
|
|
#endif
|
|
|
|
|
2014-10-02 19:45:09 +00:00
|
|
|
#ifdef _XBOX
|
|
|
|
static bool widescreen_mode = false;
|
|
|
|
#endif
|
|
|
|
|
2014-03-07 18:34:17 +00:00
|
|
|
static d3d_video_t *curD3D = NULL;
|
2014-01-18 19:49:57 +00:00
|
|
|
static bool d3d_quit = false;
|
|
|
|
static void *dinput;
|
|
|
|
|
2014-06-17 18:42:38 +00:00
|
|
|
extern bool d3d_restore(d3d_video_t *data);
|
2014-01-18 19:49:57 +00:00
|
|
|
|
2014-03-09 16:15:10 +00:00
|
|
|
static void d3d_resize(void *data, unsigned new_width, unsigned new_height)
|
2014-01-18 19:49:57 +00:00
|
|
|
{
|
2014-03-09 16:15:10 +00:00
|
|
|
(void)data;
|
2014-03-07 18:34:17 +00:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)curD3D;
|
|
|
|
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
2014-03-05 04:25:27 +00:00
|
|
|
if (!d3dr)
|
2014-01-18 19:49:57 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
RARCH_LOG("[D3D]: Resize %ux%u.\n", new_width, new_height);
|
|
|
|
|
|
|
|
if (new_width != d3d->video_info.width || new_height != d3d->video_info.height)
|
|
|
|
{
|
|
|
|
d3d->video_info.width = d3d->screen_width = new_width;
|
|
|
|
d3d->video_info.height = d3d->screen_height = new_height;
|
|
|
|
d3d_restore(d3d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_WINDOW
|
|
|
|
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message,
|
|
|
|
WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
2014-09-04 02:10:15 +00:00
|
|
|
LPCREATESTRUCT p_cs;
|
|
|
|
p_cs = (LPCREATESTRUCT)lParam;
|
|
|
|
curD3D = (d3d_video_t*)p_cs->lpCreateParams;
|
|
|
|
break;
|
2014-01-18 19:49:57 +00:00
|
|
|
|
|
|
|
case WM_CHAR:
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
case WM_KEYUP:
|
|
|
|
case WM_SYSKEYUP:
|
|
|
|
case WM_SYSKEYDOWN:
|
2014-09-04 02:10:15 +00:00
|
|
|
return win32_handle_keyboard_event(hWnd, message, wParam, lParam);
|
2014-01-18 19:49:57 +00:00
|
|
|
|
|
|
|
case WM_DESTROY:
|
2014-09-04 02:10:15 +00:00
|
|
|
d3d_quit = true;
|
|
|
|
return 0;
|
2014-01-18 19:49:57 +00:00
|
|
|
case WM_SIZE:
|
2014-09-04 02:10:15 +00:00
|
|
|
unsigned new_width, new_height;
|
|
|
|
new_width = LOWORD(lParam);
|
|
|
|
new_height = HIWORD(lParam);
|
2014-01-18 19:49:57 +00:00
|
|
|
|
2014-09-04 02:10:15 +00:00
|
|
|
if (new_width && new_height)
|
|
|
|
d3d_resize(driver.video_data, new_width, new_height);
|
|
|
|
return 0;
|
2014-01-18 19:49:57 +00:00
|
|
|
}
|
|
|
|
if (dinput_handle_message(dinput, message, wParam, lParam))
|
|
|
|
return 0;
|
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-09 16:11:06 +00:00
|
|
|
static void gfx_ctx_d3d_swap_buffers(void *data)
|
2014-01-09 18:05:31 +00:00
|
|
|
{
|
2014-03-09 17:54:02 +00:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
2014-03-07 18:34:17 +00:00
|
|
|
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
2014-03-07 20:14:56 +00:00
|
|
|
|
2014-09-12 15:36:22 +00:00
|
|
|
d3d_swap(d3d, d3dr);
|
2014-01-18 17:43:07 +00:00
|
|
|
}
|
|
|
|
|
2014-03-09 16:11:06 +00:00
|
|
|
static void gfx_ctx_d3d_update_title(void *data)
|
2014-01-18 17:43:07 +00:00
|
|
|
{
|
2014-03-09 17:54:02 +00:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
2014-05-30 04:31:53 +00:00
|
|
|
char buf[128], buffer_fps[128];
|
2014-01-09 18:05:31 +00:00
|
|
|
bool fps_draw = g_settings.fps_show;
|
2014-03-07 20:14:56 +00:00
|
|
|
|
2014-05-30 04:31:53 +00:00
|
|
|
if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buffer_fps : NULL, sizeof(buffer_fps)))
|
2014-01-09 18:05:31 +00:00
|
|
|
{
|
2014-03-07 20:14:56 +00:00
|
|
|
#ifndef _XBOX
|
2014-05-30 04:31:53 +00:00
|
|
|
SetWindowText(d3d->hWnd, buf);
|
2014-03-07 20:14:56 +00:00
|
|
|
#endif
|
2014-01-09 18:05:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fps_draw)
|
2014-03-07 20:14:56 +00:00
|
|
|
{
|
|
|
|
#ifdef _XBOX
|
|
|
|
char mem[128];
|
|
|
|
MEMORYSTATUS stat;
|
|
|
|
GlobalMemoryStatus(&stat);
|
|
|
|
snprintf(mem, sizeof(mem), "|| MEM: %.2f/%.2fMB", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f));
|
|
|
|
strlcat(buffer_fps, mem, sizeof(buffer_fps));
|
|
|
|
#endif
|
2014-01-09 18:05:31 +00:00
|
|
|
msg_queue_push(g_extern.msg_queue, buffer_fps, 1, 1);
|
2014-03-07 20:14:56 +00:00
|
|
|
}
|
2014-01-09 18:05:31 +00:00
|
|
|
|
2014-05-30 04:31:53 +00:00
|
|
|
#ifndef _XBOX
|
2014-01-09 18:05:31 +00:00
|
|
|
g_extern.frame_count++;
|
2014-05-30 04:31:53 +00:00
|
|
|
#endif
|
2014-01-09 18:05:31 +00:00
|
|
|
}
|
|
|
|
|
2014-03-09 16:11:06 +00:00
|
|
|
static void gfx_ctx_d3d_show_mouse(void *data, bool state)
|
2014-01-09 20:27:53 +00:00
|
|
|
{
|
2014-03-09 16:11:06 +00:00
|
|
|
(void)data;
|
2014-01-09 20:27:53 +00:00
|
|
|
#ifdef HAVE_WINDOW
|
|
|
|
if (state)
|
|
|
|
while (ShowCursor(TRUE) < 0);
|
|
|
|
else
|
|
|
|
while (ShowCursor(FALSE) >= 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void d3d_make_d3dpp(void *data, const video_info_t *info, D3DPRESENT_PARAMETERS *d3dpp)
|
|
|
|
{
|
2014-03-07 18:34:17 +00:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
2014-01-09 20:27:53 +00:00
|
|
|
memset(d3dpp, 0, sizeof(*d3dpp));
|
|
|
|
|
2014-03-07 21:26:47 +00:00
|
|
|
#ifdef _XBOX
|
|
|
|
d3dpp->Windowed = false;
|
|
|
|
#else
|
2014-01-09 20:27:53 +00:00
|
|
|
d3dpp->Windowed = g_settings.video.windowed_fullscreen || !info->fullscreen;
|
2014-03-07 21:26:47 +00:00
|
|
|
#endif
|
2014-01-09 20:27:53 +00:00
|
|
|
|
|
|
|
if (info->vsync)
|
|
|
|
{
|
|
|
|
switch (g_settings.video.swap_interval)
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case 1: d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_ONE; break;
|
|
|
|
case 2: d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_TWO; break;
|
|
|
|
case 3: d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_THREE; break;
|
|
|
|
case 4: d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_FOUR; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2014-09-04 02:10:15 +00:00
|
|
|
{
|
2014-01-09 20:27:53 +00:00
|
|
|
d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
2014-09-04 02:10:15 +00:00
|
|
|
}
|
2014-01-09 20:27:53 +00:00
|
|
|
|
|
|
|
d3dpp->SwapEffect = D3DSWAPEFFECT_DISCARD;
|
|
|
|
d3dpp->BackBufferCount = 2;
|
2014-03-07 21:26:47 +00:00
|
|
|
#ifdef _XBOX
|
|
|
|
d3dpp->BackBufferFormat =
|
|
|
|
#ifdef _XBOX360
|
|
|
|
g_extern.console.screen.gamma_correction ? (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) :
|
|
|
|
#endif
|
|
|
|
info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5;
|
|
|
|
#else
|
2014-03-08 03:13:20 +00:00
|
|
|
d3dpp->hDeviceWindow = d3d->hWnd;
|
2014-01-09 20:27:53 +00:00
|
|
|
d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN;
|
2014-03-07 21:26:47 +00:00
|
|
|
#endif
|
2014-01-09 20:27:53 +00:00
|
|
|
|
|
|
|
if (!d3dpp->Windowed)
|
|
|
|
{
|
2014-03-07 21:26:47 +00:00
|
|
|
#ifdef _XBOX
|
|
|
|
unsigned width, height;
|
|
|
|
width = 0;
|
|
|
|
height = 0;
|
|
|
|
|
|
|
|
if (d3d->ctx_driver && d3d->ctx_driver->get_video_size)
|
2014-03-09 17:51:35 +00:00
|
|
|
d3d->ctx_driver->get_video_size(d3d, &width, &height);
|
2014-03-07 21:26:47 +00:00
|
|
|
|
|
|
|
d3dpp->BackBufferWidth = d3d->screen_width = width;
|
|
|
|
d3dpp->BackBufferHeight = d3d->screen_height = height;
|
|
|
|
#else
|
2014-01-09 20:27:53 +00:00
|
|
|
d3dpp->BackBufferWidth = d3d->screen_width;
|
|
|
|
d3dpp->BackBufferHeight = d3d->screen_height;
|
2014-03-07 21:26:47 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _XBOX
|
|
|
|
d3dpp->MultiSampleType = D3DMULTISAMPLE_NONE;
|
|
|
|
d3dpp->EnableAutoDepthStencil = FALSE;
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
|
|
|
|
// Get the "video mode"
|
|
|
|
DWORD video_mode = XGetVideoFlags();
|
|
|
|
|
|
|
|
// Check if we are able to use progressive mode
|
|
|
|
if (video_mode & XC_VIDEO_FLAGS_HDTV_480p)
|
|
|
|
d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
|
|
|
|
else
|
|
|
|
d3dpp->Flags = D3DPRESENTFLAG_INTERLACED;
|
|
|
|
|
|
|
|
// Only valid in PAL mode, not valid for HDTV modes!
|
|
|
|
if (XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I)
|
|
|
|
{
|
|
|
|
if (video_mode & XC_VIDEO_FLAGS_PAL_60Hz)
|
|
|
|
d3dpp->FullScreen_RefreshRateInHz = 60;
|
|
|
|
else
|
|
|
|
d3dpp->FullScreen_RefreshRateInHz = 50;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (XGetAVPack() == XC_AV_PACK_HDTV)
|
|
|
|
{
|
|
|
|
if (video_mode & XC_VIDEO_FLAGS_HDTV_480p)
|
|
|
|
d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
|
|
|
|
else if (video_mode & XC_VIDEO_FLAGS_HDTV_720p)
|
|
|
|
d3dpp->Flags = D3DPRESENTFLAG_PROGRESSIVE;
|
|
|
|
else if (video_mode & XC_VIDEO_FLAGS_HDTV_1080i)
|
|
|
|
d3dpp->Flags = D3DPRESENTFLAG_INTERLACED;
|
2014-01-09 20:27:53 +00:00
|
|
|
}
|
2014-03-07 21:26:47 +00:00
|
|
|
|
2014-10-02 19:45:09 +00:00
|
|
|
if (widescreen_mode)
|
2014-03-07 21:26:47 +00:00
|
|
|
d3dpp->Flags |= D3DPRESENTFLAG_WIDESCREEN;
|
|
|
|
#elif defined(_XBOX360)
|
2014-10-02 19:45:09 +00:00
|
|
|
if (!widescreen_mode)
|
2014-03-07 21:26:47 +00:00
|
|
|
d3dpp->Flags |= D3DPRESENTFLAG_NO_LETTERBOX;
|
|
|
|
|
|
|
|
if (g_extern.console.screen.gamma_correction)
|
|
|
|
d3dpp->FrontBufferFormat = (D3DFORMAT)MAKESRGBFMT(D3DFMT_LE_X8R8G8B8);
|
|
|
|
else
|
|
|
|
d3dpp->FrontBufferFormat = D3DFMT_LE_X8R8G8B8;
|
|
|
|
d3dpp->MultiSampleQuality = 0;
|
|
|
|
#endif
|
|
|
|
#endif
|
2014-01-09 20:27:53 +00:00
|
|
|
}
|
|
|
|
|
2014-03-09 16:11:06 +00:00
|
|
|
static void gfx_ctx_d3d_check_window(void *data, bool *quit,
|
2014-01-18 17:43:07 +00:00
|
|
|
bool *resize, unsigned *width, unsigned *height, unsigned frame_count)
|
2014-01-09 20:27:53 +00:00
|
|
|
{
|
2014-03-09 16:11:06 +00:00
|
|
|
(void)data;
|
2014-03-09 17:54:02 +00:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
2014-01-18 17:43:07 +00:00
|
|
|
*quit = false;
|
|
|
|
*resize = false;
|
2014-01-18 20:07:34 +00:00
|
|
|
|
|
|
|
if (d3d_quit)
|
|
|
|
*quit = true;
|
2014-03-07 20:14:56 +00:00
|
|
|
if (d3d->should_resize)
|
|
|
|
*resize = true;
|
2014-06-07 21:45:52 +00:00
|
|
|
#ifndef _XBOX
|
2014-01-09 20:27:53 +00:00
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
2014-01-15 13:14:37 +00:00
|
|
|
#endif
|
2014-01-18 17:43:07 +00:00
|
|
|
}
|
|
|
|
|
2014-06-07 21:45:52 +00:00
|
|
|
#ifdef _XBOX
|
|
|
|
static HANDLE GetFocus(void)
|
|
|
|
{
|
|
|
|
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
|
|
|
return d3d->hWnd;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-09 16:11:06 +00:00
|
|
|
static bool gfx_ctx_d3d_has_focus(void *data)
|
2014-01-18 17:43:07 +00:00
|
|
|
{
|
2014-03-09 17:54:02 +00:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
2014-01-18 17:43:07 +00:00
|
|
|
return GetFocus() == d3d->hWnd;
|
|
|
|
}
|
|
|
|
|
2014-03-09 16:11:06 +00:00
|
|
|
static bool gfx_ctx_d3d_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor)
|
2014-01-18 17:43:07 +00:00
|
|
|
{
|
2014-03-09 16:11:06 +00:00
|
|
|
(void)data;
|
2014-01-18 17:43:07 +00:00
|
|
|
(void)major;
|
|
|
|
(void)minor;
|
|
|
|
(void)api;
|
|
|
|
#if defined(_XBOX1)
|
|
|
|
return api == GFX_CTX_DIRECT3D8_API;
|
2014-03-07 20:14:56 +00:00
|
|
|
#else /* As long as we don't have a D3D11 implementation, we default to this */
|
2014-01-18 17:43:07 +00:00
|
|
|
return api == GFX_CTX_DIRECT3D9_API;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-03-09 16:11:06 +00:00
|
|
|
static bool gfx_ctx_d3d_init(void *data)
|
2014-01-18 17:43:07 +00:00
|
|
|
{
|
2014-03-09 16:11:06 +00:00
|
|
|
(void)data;
|
2014-09-02 15:44:04 +00:00
|
|
|
d3d_quit = false;
|
2014-01-09 21:25:50 +00:00
|
|
|
return true;
|
2014-01-15 16:24:24 +00:00
|
|
|
}
|
2014-01-18 17:43:07 +00:00
|
|
|
|
2014-03-09 16:11:06 +00:00
|
|
|
static void gfx_ctx_d3d_destroy(void *data)
|
2014-03-08 04:21:36 +00:00
|
|
|
{
|
2014-03-09 16:11:06 +00:00
|
|
|
(void)data;
|
2014-03-08 04:21:36 +00:00
|
|
|
}
|
|
|
|
|
2014-03-09 16:11:06 +00:00
|
|
|
static void gfx_ctx_d3d_input_driver(void *data, const input_driver_t **input, void **input_data)
|
2014-01-18 19:49:57 +00:00
|
|
|
{
|
2014-03-09 16:11:06 +00:00
|
|
|
(void)data;
|
2014-03-07 20:14:56 +00:00
|
|
|
#ifdef _XBOX
|
|
|
|
void *xinput = input_xinput.init();
|
|
|
|
*input = xinput ? (const input_driver_t*)&input_xinput : NULL;
|
|
|
|
*input_data = xinput;
|
|
|
|
#else
|
2014-01-18 19:49:57 +00:00
|
|
|
dinput = input_dinput.init();
|
|
|
|
*input = dinput ? &input_dinput : NULL;
|
|
|
|
*input_data = dinput;
|
2014-03-07 20:14:56 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-03-09 16:11:06 +00:00
|
|
|
static void gfx_ctx_d3d_get_video_size(void *data, unsigned *width, unsigned *height)
|
2014-03-07 20:14:56 +00:00
|
|
|
{
|
2014-10-02 19:57:01 +00:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)driver.video_data;
|
2014-03-07 20:22:59 +00:00
|
|
|
#ifdef _XBOX
|
2014-03-07 20:14:56 +00:00
|
|
|
(void)width;
|
|
|
|
(void)height;
|
|
|
|
#if defined(_XBOX360)
|
|
|
|
XVIDEO_MODE video_mode;
|
|
|
|
XGetVideoMode(&video_mode);
|
|
|
|
|
|
|
|
*width = video_mode.dwDisplayWidth;
|
|
|
|
*height = video_mode.dwDisplayHeight;
|
|
|
|
|
2014-10-02 19:57:01 +00:00
|
|
|
driver.resolution_hd_enable = false;
|
|
|
|
|
2014-03-07 20:14:56 +00:00
|
|
|
if(video_mode.fIsHiDef)
|
|
|
|
{
|
|
|
|
*width = 1280;
|
|
|
|
*height = 720;
|
2014-10-02 19:57:01 +00:00
|
|
|
driver.resolution_hd_enable = true;
|
2014-03-07 20:14:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-09-04 02:10:15 +00:00
|
|
|
*width = 640;
|
|
|
|
*height = 480;
|
2014-03-07 20:14:56 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 19:45:09 +00:00
|
|
|
widescreen_mode = video_mode.fIsWideScreen;
|
2014-03-07 20:14:56 +00:00
|
|
|
#elif defined(_XBOX1)
|
|
|
|
DWORD video_mode = XGetVideoFlags();
|
|
|
|
|
|
|
|
*width = 640;
|
|
|
|
*height = 480;
|
|
|
|
|
|
|
|
// Only valid in PAL mode, not valid for HDTV modes!
|
|
|
|
if(XGetVideoStandard() == XC_VIDEO_STANDARD_PAL_I)
|
|
|
|
{
|
2014-10-02 19:45:09 +00:00
|
|
|
widescreen_mode = false;
|
|
|
|
|
|
|
|
/* Check for 16:9 mode (PAL REGION) */
|
2014-03-07 20:14:56 +00:00
|
|
|
if(video_mode & XC_VIDEO_FLAGS_WIDESCREEN)
|
|
|
|
{
|
2014-10-02 19:45:09 +00:00
|
|
|
*width = 720;
|
2014-09-04 02:10:15 +00:00
|
|
|
//60 Hz, 720x480i
|
2014-03-07 20:14:56 +00:00
|
|
|
if(video_mode & XC_VIDEO_FLAGS_PAL_60Hz)
|
|
|
|
*height = 480;
|
2014-09-04 02:10:15 +00:00
|
|
|
else //50 Hz, 720x576i
|
2014-03-07 20:14:56 +00:00
|
|
|
*height = 576;
|
2014-10-02 19:45:09 +00:00
|
|
|
widescreen_mode = true;
|
2014-09-04 02:10:15 +00:00
|
|
|
}
|
2014-03-07 20:14:56 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-02 19:45:09 +00:00
|
|
|
widescreen_mode = false;
|
|
|
|
|
|
|
|
/* Check for 16:9 mode (NTSC REGIONS) */
|
2014-03-07 20:14:56 +00:00
|
|
|
if(video_mode & XC_VIDEO_FLAGS_WIDESCREEN)
|
|
|
|
{
|
|
|
|
*width = 720;
|
|
|
|
*height = 480;
|
2014-10-02 19:45:09 +00:00
|
|
|
widescreen_mode = true;
|
2014-09-04 02:10:15 +00:00
|
|
|
}
|
2014-03-07 20:14:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(XGetAVPack() == XC_AV_PACK_HDTV)
|
|
|
|
{
|
|
|
|
if(video_mode & XC_VIDEO_FLAGS_HDTV_480p)
|
|
|
|
{
|
2014-09-04 02:10:15 +00:00
|
|
|
*width = 640;
|
2014-03-07 20:14:56 +00:00
|
|
|
*height = 480;
|
2014-10-02 19:45:09 +00:00
|
|
|
widescreen_mode = false;
|
2014-10-02 19:57:01 +00:00
|
|
|
driver.resolution_hd_enable = true;
|
2014-03-07 20:14:56 +00:00
|
|
|
}
|
2014-09-04 02:10:15 +00:00
|
|
|
else if(video_mode & XC_VIDEO_FLAGS_HDTV_720p)
|
2014-03-07 20:14:56 +00:00
|
|
|
{
|
2014-09-04 02:10:15 +00:00
|
|
|
*width = 1280;
|
2014-03-07 20:14:56 +00:00
|
|
|
*height = 720;
|
2014-10-02 19:45:09 +00:00
|
|
|
widescreen_mode = true;
|
2014-10-02 19:57:01 +00:00
|
|
|
driver.resolution_hd_enable = true;
|
2014-03-07 20:14:56 +00:00
|
|
|
}
|
2014-09-04 02:10:15 +00:00
|
|
|
else if(video_mode & XC_VIDEO_FLAGS_HDTV_1080i)
|
2014-03-07 20:14:56 +00:00
|
|
|
{
|
2014-09-04 02:10:15 +00:00
|
|
|
*width = 1920;
|
2014-03-07 20:14:56 +00:00
|
|
|
*height = 1080;
|
2014-10-02 19:45:09 +00:00
|
|
|
widescreen_mode = true;
|
2014-10-02 19:57:01 +00:00
|
|
|
driver.resolution_hd_enable = true;
|
2014-03-07 20:14:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-03-09 16:11:06 +00:00
|
|
|
static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval)
|
2014-03-07 20:14:56 +00:00
|
|
|
{
|
2014-03-09 17:54:02 +00:00
|
|
|
d3d_video_t *d3d = (d3d_video_t*)data;
|
2014-06-08 02:29:25 +00:00
|
|
|
#ifdef _XBOX
|
2014-03-07 20:14:56 +00:00
|
|
|
LPDIRECT3DDEVICE d3dr = d3d->dev;
|
|
|
|
|
|
|
|
if (interval)
|
|
|
|
d3dr->SetRenderState(XBOX_PRESENTATIONINTERVAL, D3DPRESENT_INTERVAL_ONE);
|
|
|
|
else
|
|
|
|
d3dr->SetRenderState(XBOX_PRESENTATIONINTERVAL, D3DPRESENT_INTERVAL_IMMEDIATE);
|
2014-06-08 02:29:25 +00:00
|
|
|
#else
|
|
|
|
d3d_restore(d3d);
|
2014-03-07 20:14:56 +00:00
|
|
|
#endif
|
2014-01-18 19:49:57 +00:00
|
|
|
}
|
|
|
|
|
2014-09-14 04:45:47 +00:00
|
|
|
const gfx_ctx_driver_t gfx_ctx_d3d = {
|
2014-01-18 19:49:57 +00:00
|
|
|
gfx_ctx_d3d_init,
|
2014-03-08 04:21:36 +00:00
|
|
|
gfx_ctx_d3d_destroy,
|
2014-01-18 19:49:57 +00:00
|
|
|
gfx_ctx_d3d_bind_api,
|
2014-03-07 20:14:56 +00:00
|
|
|
gfx_ctx_d3d_swap_interval,
|
2014-03-08 04:21:36 +00:00
|
|
|
NULL,
|
2014-03-07 20:14:56 +00:00
|
|
|
gfx_ctx_d3d_get_video_size,
|
2014-09-04 02:10:15 +00:00
|
|
|
NULL,
|
2014-01-18 19:49:57 +00:00
|
|
|
gfx_ctx_d3d_update_title,
|
|
|
|
gfx_ctx_d3d_check_window,
|
2014-01-18 20:13:08 +00:00
|
|
|
d3d_resize,
|
2014-01-18 19:49:57 +00:00
|
|
|
gfx_ctx_d3d_has_focus,
|
|
|
|
gfx_ctx_d3d_swap_buffers,
|
|
|
|
gfx_ctx_d3d_input_driver,
|
|
|
|
NULL,
|
2014-09-16 00:16:36 +00:00
|
|
|
#ifdef HAVE_EGL
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
#endif
|
2014-01-18 19:49:57 +00:00
|
|
|
gfx_ctx_d3d_show_mouse,
|
2014-03-07 20:22:59 +00:00
|
|
|
"d3d",
|
2014-01-18 17:43:07 +00:00
|
|
|
};
|