(Xbox 1) Modified RetroLaunch to use RetroArch's D3D device (!NOT TESTED!)

This commit is contained in:
freakdave 2012-07-23 16:05:16 +02:00
parent 7395c805e6
commit fe4b07d8b1
4 changed files with 30 additions and 15 deletions

View File

@ -17,6 +17,7 @@
#include "Surface.h" #include "Surface.h"
#include "Debug.h" #include "Debug.h"
#include "../xdk_d3d8.h"
CSurface::CSurface() CSurface::CSurface()
{ {
@ -68,7 +69,7 @@ bool CSurface::Create(const string &szFilename)
} }
// create a vertex buffer for the quad that will display the texture // create a vertex buffer for the quad that will display the texture
g_hResult = g_video.m_pD3DDevice->CreateVertexBuffer(4 * sizeof(CustomVertex), g_hResult = g_video.m_pD3DDevice->CreateVertexBuffer(4 * sizeof(DrawVerticeFormats),
D3DUSAGE_WRITEONLY, D3DUSAGE_WRITEONLY,
D3DFVF_CUSTOMVERTEX, D3DFVF_CUSTOMVERTEX,
D3DPOOL_MANAGED, &m_pVertexBuffer); D3DPOOL_MANAGED, &m_pVertexBuffer);
@ -104,7 +105,7 @@ bool CSurface::Create(dword width, dword height)
m_imageInfo.Format = D3DFMT_A8R8G8B8; m_imageInfo.Format = D3DFMT_A8R8G8B8;
// create a vertex buffer for the quad that will display the texture // create a vertex buffer for the quad that will display the texture
g_hResult = g_video.m_pD3DDevice->CreateVertexBuffer(4 * sizeof(CustomVertex), g_hResult = g_video.m_pD3DDevice->CreateVertexBuffer(4 * sizeof(DrawVerticeFormats),
D3DUSAGE_WRITEONLY, D3DUSAGE_WRITEONLY,
D3DFVF_CUSTOMVERTEX, D3DFVF_CUSTOMVERTEX,
D3DPOOL_MANAGED, &m_pVertexBuffer); D3DPOOL_MANAGED, &m_pVertexBuffer);
@ -163,17 +164,17 @@ bool CSurface::Render(int x, int y, dword w, dword h)
float fY = static_cast<float>(y); float fY = static_cast<float>(y);
// create the new vertices // create the new vertices
CustomVertex newVerts[] = /*CustomVertex*/DrawVerticeFormats newVerts[] =
{ {
// x, y, z, color, u ,v // x, y, z, color, u ,v
{fX, fY, 0.0f, D3DCOLOR_ARGB(m_byOpacity, m_byR, m_byG, m_byB), 0, 0}, {fX, fY, 0.0f, /*D3DCOLOR_ARGB(m_byOpacity, m_byR, m_byG, m_byB),*/ 0, 0},
{fX + w, fY, 0.0f, D3DCOLOR_ARGB(m_byOpacity, m_byR, m_byG, m_byB), 1, 0}, {fX + w, fY, 0.0f, /*D3DCOLOR_ARGB(m_byOpacity, m_byR, m_byG, m_byB),*/ 1, 0},
{fX + w, fY + h, 0.0f, D3DCOLOR_ARGB(m_byOpacity, m_byR, m_byG, m_byB), 1, 1}, {fX + w, fY + h, 0.0f, /*D3DCOLOR_ARGB(m_byOpacity, m_byR, m_byG, m_byB),*/ 1, 1},
{fX, fY + h, 0.0f, D3DCOLOR_ARGB(m_byOpacity, m_byR, m_byG, m_byB), 0, 1} {fX, fY + h, 0.0f, /*D3DCOLOR_ARGB(m_byOpacity, m_byR, m_byG, m_byB),*/ 0, 1}
}; };
// load the existing vertices // load the existing vertices
CustomVertex *pCurVerts; /*CustomVertex*/DrawVerticeFormats *pCurVerts;
g_hResult = m_pVertexBuffer->Lock(0, 0, (byte **)&pCurVerts, 0); g_hResult = m_pVertexBuffer->Lock(0, 0, (byte **)&pCurVerts, 0);
@ -183,7 +184,7 @@ bool CSurface::Render(int x, int y, dword w, dword h)
return false; return false;
} }
// copy the new verts over the old verts // copy the new verts over the old verts
memcpy(pCurVerts, newVerts, 4 * sizeof(CustomVertex)); memcpy(pCurVerts, newVerts, 4 * sizeof(DrawVerticeFormats));
m_pVertexBuffer->Unlock(); m_pVertexBuffer->Unlock();
@ -199,7 +200,7 @@ bool CSurface::Render(int x, int y, dword w, dword h)
// draw the quad // draw the quad
g_video.m_pD3DDevice->SetTexture(0, m_pTexture); g_video.m_pD3DDevice->SetTexture(0, m_pTexture);
g_video.m_pD3DDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(CustomVertex)); g_video.m_pD3DDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(DrawVerticeFormats));
g_video.m_pD3DDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX); g_video.m_pD3DDevice->SetVertexShader(D3DFVF_CUSTOMVERTEX);
g_video.m_pD3DDevice->DrawPrimitive(D3DPT_QUADLIST, 0, 1); g_video.m_pD3DDevice->DrawPrimitive(D3DPT_QUADLIST, 0, 1);
return true; return true;

View File

@ -29,8 +29,15 @@ CVideo::~CVideo(void)
{ {
} }
bool CVideo::SetDevice(IDirect3DDevice8 *D3D_Device)
{
m_pD3DDevice = D3D_Device;
return true;
}
bool CVideo::Create(HWND hDeviceWindow, bool bWindowed) bool CVideo::Create(HWND hDeviceWindow, bool bWindowed)
{ {
/*
// Create the Direct3D object (leave it DX8 or should we try DX9 for WIN32 ?) // Create the Direct3D object (leave it DX8 or should we try DX9 for WIN32 ?)
m_pD3D = Direct3DCreate8(D3D_SDK_VERSION); m_pD3D = Direct3DCreate8(D3D_SDK_VERSION);
@ -85,7 +92,7 @@ bool CVideo::Create(HWND hDeviceWindow, bool bWindowed)
// disable z-buffer (see autodepthstencil) // disable z-buffer (see autodepthstencil)
m_pD3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE ); m_pD3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE );
*/
return true; return true;
} }

View File

@ -18,8 +18,9 @@
#include "Global.h" #include "Global.h"
#undef D3DFVF_CUSTOMVERTEX #undef D3DFVF_CUSTOMVERTEX
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1) //#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1)
/*
typedef struct CustomVertex typedef struct CustomVertex
{ {
float x, y, z; float x, y, z;
@ -27,7 +28,7 @@ typedef struct CustomVertex
float u, v; float u, v;
//float rhw; //float rhw;
}CustomVertex; }CustomVertex;
*/
class CVideo class CVideo
{ {
@ -36,6 +37,7 @@ public:
~CVideo(void); ~CVideo(void);
bool Create(HWND hDeviceWindow, bool bWindowed); //Device creation bool Create(HWND hDeviceWindow, bool bWindowed); //Device creation
bool SetDevice(IDirect3DDevice8 *D3D_Device);
void BeginRender(); void BeginRender();
void EndRender(); void EndRender();

View File

@ -192,9 +192,14 @@ static void menu_init(void)
g_IOSupport.Mount("F:", "Harddisk0\\Partition6"); g_IOSupport.Mount("F:", "Harddisk0\\Partition6");
g_IOSupport.Mount("G:", "Harddisk0\\Partition7"); g_IOSupport.Mount("G:", "Harddisk0\\Partition7");
// Get RetroArch's native d3d device
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
// Initialize Direct3D // Initialize Direct3D
if (!g_video.Create(NULL, false)) //if (!g_video.Create(NULL, false))
//return;
if(!g_video.SetDevice(d3d->d3d_render_device))
return; return;
// Parse ini file for settings // Parse ini file for settings