From fe4b07d8b117033dc88315b64ed596648fe7411c Mon Sep 17 00:00:00 2001 From: freakdave Date: Mon, 23 Jul 2012 16:05:16 +0200 Subject: [PATCH] (Xbox 1) Modified RetroLaunch to use RetroArch's D3D device (!NOT TESTED!) --- xbox1/RetroLaunch/Surface.cpp | 21 +++++++++++---------- xbox1/RetroLaunch/Video.cpp | 9 ++++++++- xbox1/RetroLaunch/Video.h | 6 ++++-- xdk/frontend/main.c | 9 +++++++-- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/xbox1/RetroLaunch/Surface.cpp b/xbox1/RetroLaunch/Surface.cpp index e0ac7b8e98..f8718ef968 100644 --- a/xbox1/RetroLaunch/Surface.cpp +++ b/xbox1/RetroLaunch/Surface.cpp @@ -17,6 +17,7 @@ #include "Surface.h" #include "Debug.h" +#include "../xdk_d3d8.h" CSurface::CSurface() { @@ -68,7 +69,7 @@ bool CSurface::Create(const string &szFilename) } // 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, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &m_pVertexBuffer); @@ -104,7 +105,7 @@ bool CSurface::Create(dword width, dword height) m_imageInfo.Format = D3DFMT_A8R8G8B8; // 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, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, &m_pVertexBuffer); @@ -163,17 +164,17 @@ bool CSurface::Render(int x, int y, dword w, dword h) float fY = static_cast(y); // create the new vertices - CustomVertex newVerts[] = + /*CustomVertex*/DrawVerticeFormats newVerts[] = { // x, y, z, color, u ,v - {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 + 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, 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 + 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} }; // load the existing vertices - CustomVertex *pCurVerts; + /*CustomVertex*/DrawVerticeFormats *pCurVerts; 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; } // copy the new verts over the old verts - memcpy(pCurVerts, newVerts, 4 * sizeof(CustomVertex)); + memcpy(pCurVerts, newVerts, 4 * sizeof(DrawVerticeFormats)); m_pVertexBuffer->Unlock(); @@ -199,7 +200,7 @@ bool CSurface::Render(int x, int y, dword w, dword h) // draw the quad 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->DrawPrimitive(D3DPT_QUADLIST, 0, 1); return true; diff --git a/xbox1/RetroLaunch/Video.cpp b/xbox1/RetroLaunch/Video.cpp index 28d5ba67fc..35f3c403bc 100644 --- a/xbox1/RetroLaunch/Video.cpp +++ b/xbox1/RetroLaunch/Video.cpp @@ -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) { + /* // Create the Direct3D object (leave it DX8 or should we try DX9 for WIN32 ?) m_pD3D = Direct3DCreate8(D3D_SDK_VERSION); @@ -85,7 +92,7 @@ bool CVideo::Create(HWND hDeviceWindow, bool bWindowed) // disable z-buffer (see autodepthstencil) m_pD3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE ); - +*/ return true; } diff --git a/xbox1/RetroLaunch/Video.h b/xbox1/RetroLaunch/Video.h index 451ef8067e..fc9c80e155 100644 --- a/xbox1/RetroLaunch/Video.h +++ b/xbox1/RetroLaunch/Video.h @@ -18,8 +18,9 @@ #include "Global.h" #undef D3DFVF_CUSTOMVERTEX -#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1) +//#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1) +/* typedef struct CustomVertex { float x, y, z; @@ -27,7 +28,7 @@ typedef struct CustomVertex float u, v; //float rhw; }CustomVertex; - +*/ class CVideo { @@ -36,6 +37,7 @@ public: ~CVideo(void); bool Create(HWND hDeviceWindow, bool bWindowed); //Device creation + bool SetDevice(IDirect3DDevice8 *D3D_Device); void BeginRender(); void EndRender(); diff --git a/xdk/frontend/main.c b/xdk/frontend/main.c index a3379a964f..ef0cfc2d95 100644 --- a/xdk/frontend/main.c +++ b/xdk/frontend/main.c @@ -192,10 +192,15 @@ static void menu_init(void) g_IOSupport.Mount("F:", "Harddisk0\\Partition6"); 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 - if (!g_video.Create(NULL, false)) - return; + //if (!g_video.Create(NULL, false)) + //return; + + if(!g_video.SetDevice(d3d->d3d_render_device)) + return; // Parse ini file for settings g_iniFile.CheckForIniEntry();