1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

Update file paths and fix code in d3d9.cpp and idirect3ddevice9.hpp

This commit is contained in:
Eduardo P. Gomez 2024-03-06 04:13:49 -03:00
parent a11825cddc
commit 9393a2b4b3
7 changed files with 70 additions and 12 deletions

View File

@ -3,4 +3,4 @@
#define DEBUG true
//PREPROCESSING ONLY!!!
#define PROJECT_SOURCE_DIR "/workspaces/OpenDX/"
#define PROJECT_SOURCE_DIR "/home/eduardo/git/eduapps/OpenDX/"

View File

@ -5,3 +5,8 @@ inline LONG InterlockedIncrement(LONG volatile *p)
{
return __sync_add_and_fetch(p, 1);
}
inline LONG InterlockedDecrement(LONG volatile *p)
{
return __sync_sub_and_fetch(p, 1);
}

View File

@ -15,7 +15,7 @@
//TODO: add ifdefs when implementing another gpu
#include <drm/i915_drm.h>
IDirect3D9::IDirect3D9 (UINT SDKVersion) {
IDirect3D9::IDirect3D9(UINT SDKVersion) {
#ifdef DEBUG
std::cout << "libd3d9.so: IDirect3D9::IDirect3D9()" << std::endl;
#endif
@ -100,9 +100,16 @@ HRESULT IDirect3D9::CreateDevice(
std::cout << "libd3d9.so: IDirect3D9::CreateDevice()" << std::endl;
#endif
//get hwnd size
RECT rect;
GetClientRect(hFocusWindow, &rect);
//get GtkWindow specs and put them into D3DPRESENT_PARAMETERS
pPresentationParameters->hDeviceWindow = hFocusWindow;
pPresentationParameters->BackBufferWidth = gtk_widget_get_size(hFocusWindow,GTK_ORIENTATION_HORIZONTAL);
pPresentationParameters->BackBufferHeight = gtk_widget_get_size(hFocusWindow,GTK_ORIENTATION_VERTICAL);
//create the device
IDirect3DDevice9 device = IDirect3DDevice9(/*this, pPresentationParameters*/);
*ppReturnedDeviceInterface = &device;
return 0;
}
ULONG IDirect3D9::Release() {
@ -138,3 +145,40 @@ IDirect3D9* Direct3DCreate9(UINT SDKVersion) {
return r;
}
IDirect3DDevice9::IDirect3DDevice9(/*IDirect3D9* d3d, D3DPRESENT_PARAMETERS* pp*/) {
#ifdef DEBUG
std::cout << "libd3d9.so: IDirect3DDevice9::IDirect3DDevice9()" << std::endl;
#endif
refCount = 1;
}
ULONG IDirect3DDevice9::AddRef() {
DXGASSERT(((ULONG_PTR)(&refCount) & 3) == 0);
InterlockedIncrement((LONG *)&refCount);
return refCount;
}
ULONG IDirect3DDevice9::Release() {
InterlockedDecrement((LONG *)&refCount);
return refCount;
}
HRESULT IDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj) {
*ppvObj = this;
IDirect3DDevice9::AddRef();
return 0;
}
HRESULT IDirect3DDevice9::Clear(DWORD Count, const void/*D3DRECT*/ *pRects, DWORD Flags, int/*D3DCOLOR*/ Color, float Z, DWORD Stencil) {
#ifdef DEBUG
std::cout << "libd3d9.so: IDirect3DDevice9::Clear()" << std::endl;
#endif
//intel code
return 0;
}

View File

@ -2,6 +2,8 @@
#include <unknwn.h>
#include <d3d9.h>
// struct IDirect3DDevice9:IUnknown {
// };
/*IDirect3DDevice9::IDirect3DDevice9(IDirect3D9* d3d, D3DPRESENT_PARAMETERS* pp) {
#ifdef DEBUG
std::cout << "libd3d9.so: IDirect3DDevice9::IDirect3DDevice9()" << std::endl;
#endif
}*/

View File

@ -191,12 +191,18 @@ struct D3DPRESENT_PARAMETERS {
};
typedef struct D3DPRESENT_PARAMETERS D3DPRESENT_PARAMETERS, *LPD3DPRESENT_PARAMETERS;
struct IDirect3DDevice9 : public IUnknown {
struct IDirect3DDevice9 {
IDirect3DDevice9();
virtual HRESULT QueryInterface(REFIID riid, void** ppvObj);
virtual ULONG AddRef();
virtual ULONG Release();
HRESULT Clear(DWORD Count, const void/*D3DRECT*/ *pRects, DWORD Flags, int/*D3DCOLOR*/ Color, float Z, DWORD Stencil);
// Define other methods required by IDirect3D9 interface
private:ULONG refCount;
};
typedef struct IDirect3DDevice9 *LPDIRECT3DDEVICE9, *PDIRECT3DDEVICE9;

4
run.sh
View File

@ -1,3 +1,3 @@
# Run dxdiag from build directory
cd build
./tests/sample
cd build/opendx
./bin/sample

View File

@ -2,7 +2,8 @@
* Windows API codes were commented to focus
* on what's important: OpenDX.
*
* Code that doesn't work is also commented.
* Code that doesn't work is also commented and will be gradually
* fixed. This is a work in progress.
*/
#include <opendx.h>
#include <winuser.h>