mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
D3DDEVTYPE detection
This commit is contained in:
parent
555849a1fb
commit
0acfbbebe6
51
.vscode/settings.json
vendored
51
.vscode/settings.json
vendored
@ -5,6 +5,55 @@
|
|||||||
],
|
],
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"phtml": "php",
|
"phtml": "php",
|
||||||
"new": "cpp"
|
"new": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"atomic": "cpp",
|
||||||
|
"bit": "cpp",
|
||||||
|
"*.tcc": "cpp",
|
||||||
|
"cctype": "cpp",
|
||||||
|
"clocale": "cpp",
|
||||||
|
"cmath": "cpp",
|
||||||
|
"compare": "cpp",
|
||||||
|
"concepts": "cpp",
|
||||||
|
"cstdarg": "cpp",
|
||||||
|
"cstddef": "cpp",
|
||||||
|
"cstdint": "cpp",
|
||||||
|
"cstdio": "cpp",
|
||||||
|
"cstdlib": "cpp",
|
||||||
|
"cstring": "cpp",
|
||||||
|
"ctime": "cpp",
|
||||||
|
"cwchar": "cpp",
|
||||||
|
"cwctype": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"exception": "cpp",
|
||||||
|
"algorithm": "cpp",
|
||||||
|
"functional": "cpp",
|
||||||
|
"iterator": "cpp",
|
||||||
|
"memory": "cpp",
|
||||||
|
"memory_resource": "cpp",
|
||||||
|
"numeric": "cpp",
|
||||||
|
"random": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"system_error": "cpp",
|
||||||
|
"tuple": "cpp",
|
||||||
|
"type_traits": "cpp",
|
||||||
|
"utility": "cpp",
|
||||||
|
"fstream": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"iomanip": "cpp",
|
||||||
|
"iosfwd": "cpp",
|
||||||
|
"iostream": "cpp",
|
||||||
|
"istream": "cpp",
|
||||||
|
"limits": "cpp",
|
||||||
|
"numbers": "cpp",
|
||||||
|
"ostream": "cpp",
|
||||||
|
"sstream": "cpp",
|
||||||
|
"stdexcept": "cpp",
|
||||||
|
"streambuf": "cpp",
|
||||||
|
"cinttypes": "cpp",
|
||||||
|
"typeinfo": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define DEBUG false
|
#define DEBUG true
|
||||||
|
|
||||||
//PREPROCESSING ONLY!!!
|
//PREPROCESSING ONLY!!!
|
||||||
#define PROJECT_SOURCE_DIR "/home/eduardo/Documentos/proj/OpenDX/"
|
#define PROJECT_SOURCE_DIR "/home/eduardo/Documentos/proj/OpenDX/"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define DEBUG false
|
#define DEBUG true
|
||||||
|
|
||||||
//PREPROCESSING ONLY!!!
|
//PREPROCESSING ONLY!!!
|
||||||
#define PROJECT_SOURCE_DIR "@PROJECT_SOURCE_DIR@/"
|
#define PROJECT_SOURCE_DIR "@PROJECT_SOURCE_DIR@/"
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
|
|
||||||
|
|
||||||
IDirect3D9::IDirect3D9 (UINT SDKVersion) {
|
IDirect3D9::IDirect3D9 (UINT SDKVersion) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << "libd3d9.so: IDirect3D9::IDirect3D9()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
//Create connection with DRM
|
//Create connection with DRM
|
||||||
int fd = open("/dev/dri/card0", O_RDWR, 0); //DirectX automatically selects the first GPU
|
int fd = open("/dev/dri/card0", O_RDWR, 0); //DirectX automatically selects the first GPU
|
||||||
|
|
||||||
@ -20,36 +24,52 @@ IDirect3D9::IDirect3D9 (UINT SDKVersion) {
|
|||||||
<< "ODX ERROR: Failed to open /dev/dri/card0. Please check if you have the proper permissions to access the device." << std::endl
|
<< "ODX ERROR: Failed to open /dev/dri/card0. Please check if you have the proper permissions to access the device." << std::endl
|
||||||
<< "Direct3DCreate9 fails and returns NULL.\033[0;0m" << std::endl
|
<< "Direct3DCreate9 fails and returns NULL.\033[0;0m" << std::endl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if the device is Hardware or Software (Does DirectX have this check?)
|
//check if the device is Hardware or Software (Does DirectX have this check?)
|
||||||
unsigned int gpuType;
|
drm_get_cap gpuType;
|
||||||
|
|
||||||
int ioctlResult = ioctl(fd, DRM_IOCTL_GET_CAP, &gpuType);
|
int ioctlResult = ioctl(fd, DRM_IOCTL_GET_CAP, &gpuType);
|
||||||
|
|
||||||
if (ioctlResult != 0) {
|
if (ioctlResult != 0) {
|
||||||
std::cerr << "\033[1;31m"
|
std::cerr << "\033[1;31m"
|
||||||
<< "ODX ERROR: Failed to get device info" << std::endl
|
<< "ODX ERROR: Failed to get device info" << std::endl
|
||||||
<< "Direct3DCreate9 fails and returns NULL.\033[0;0m" << std::endl
|
<< "Direct3DCreate9 fails and returns NULL.\033[0;0m" << std::endl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
perror("ioctl");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "\033[1;32m" //GREEN BOLD
|
|
||||||
<< "ODX INFO: Device is " << (gpuType == DRM_CAP_DUMB_BUFFER ? "Software" : "Hardware") << std::endl
|
#ifdef DEBUG
|
||||||
<< "\033[0;0m" << std::endl;
|
std::cout << "\033[1;32m" //GREEN BOLD
|
||||||
|
<< "ODX INFO: Device is " << (gpuType.value == DRM_CAP_DUMB_BUFFER ? "Software" : "Hardware") << std::endl
|
||||||
|
<< "\033[0;0m" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
D3DDEVTYPE deviceType = D3DDEVTYPE::D3DDEVTYPE_NULLREF;
|
||||||
|
|
||||||
|
if (gpuType.value == DRM_CAP_DUMB_BUFFER) {
|
||||||
|
deviceType = D3DDEVTYPE::D3DDEVTYPE_SW;
|
||||||
|
} else {
|
||||||
|
deviceType = D3DDEVTYPE::D3DDEVTYPE_HAL;
|
||||||
|
}
|
||||||
|
|
||||||
IDirect3DDevice9* device;
|
IDirect3DDevice9* device;
|
||||||
this->CreateDevice(
|
this->CreateDevice(
|
||||||
D3DADAPTER_DEFAULT,
|
D3DADAPTER_DEFAULT,
|
||||||
D3DDEVTYPE::D3DDEVTYPE_SW, // TODO
|
deviceType,
|
||||||
NULL, // TODO
|
NULL, // TODO
|
||||||
NULL, // TODO
|
NULL, // TODO
|
||||||
NULL, // TODO
|
NULL, // TODO
|
||||||
&device
|
&device
|
||||||
);
|
);
|
||||||
|
|
||||||
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <config.hpp>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "d3d9helper.hpp"
|
#include "d3d9helper.hpp"
|
||||||
#include "d3d9types.hpp"
|
#include "d3d9types.hpp"
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
#include "opendx.hpp"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
#include <opendx.h>
|
#include <opendx.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Create a Window
|
* @brief Create a Window
|
||||||
@ -22,6 +24,10 @@ HWND CreateWindowExA(
|
|||||||
HINSTANCE instance, //optional (Windows ignores it)
|
HINSTANCE instance, //optional (Windows ignores it)
|
||||||
LPVOID param //optional
|
LPVOID param //optional
|
||||||
) {
|
) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << "libopendx.so: CreateWindowExA()" << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
GtkWidget* window = gtk_window_new();
|
GtkWidget* window = gtk_window_new();
|
||||||
|
|
||||||
if (title != nullptr) {
|
if (title != nullptr) {
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <config.hpp>
|
@ -35,7 +35,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <windef.h>
|
#include <windef.h>
|
||||||
#include <winnt.h>
|
#include <winnt.h>
|
||||||
//#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#define DWORD unsigned long
|
#define DWORD unsigned long
|
||||||
#define HWND GtkWidget*
|
#define HWND GtkWidget*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user