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": {
|
||||
"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
|
||||
|
||||
#define DEBUG false
|
||||
#define DEBUG true
|
||||
|
||||
//PREPROCESSING ONLY!!!
|
||||
#define PROJECT_SOURCE_DIR "/home/eduardo/Documentos/proj/OpenDX/"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define DEBUG false
|
||||
#define DEBUG true
|
||||
|
||||
//PREPROCESSING ONLY!!!
|
||||
#define PROJECT_SOURCE_DIR "@PROJECT_SOURCE_DIR@/"
|
||||
|
@ -12,6 +12,10 @@
|
||||
|
||||
|
||||
IDirect3D9::IDirect3D9 (UINT SDKVersion) {
|
||||
#ifdef DEBUG
|
||||
std::cout << "libd3d9.so: IDirect3D9::IDirect3D9()" << std::endl;
|
||||
#endif
|
||||
|
||||
//Create connection with DRM
|
||||
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
|
||||
<< "Direct3DCreate9 fails and returns NULL.\033[0;0m" << std::endl
|
||||
<< std::endl;
|
||||
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
//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);
|
||||
|
||||
if (ioctlResult != 0) {
|
||||
std::cerr << "\033[1;31m"
|
||||
<< "ODX ERROR: Failed to get device info" << std::endl
|
||||
<< "Direct3DCreate9 fails and returns NULL.\033[0;0m" << std::endl
|
||||
<< std::endl;
|
||||
|
||||
close(fd);
|
||||
perror("ioctl");
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << "\033[1;32m" //GREEN BOLD
|
||||
<< "ODX INFO: Device is " << (gpuType == DRM_CAP_DUMB_BUFFER ? "Software" : "Hardware") << std::endl
|
||||
<< "\033[0;0m" << std::endl;
|
||||
|
||||
#ifdef DEBUG
|
||||
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;
|
||||
this->CreateDevice(
|
||||
D3DADAPTER_DEFAULT,
|
||||
D3DDEVTYPE::D3DDEVTYPE_SW, // TODO
|
||||
deviceType,
|
||||
NULL, // TODO
|
||||
NULL, // TODO
|
||||
NULL, // TODO
|
||||
&device
|
||||
);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <config.hpp>
|
||||
#include <windows.h>
|
||||
#include "d3d9helper.hpp"
|
||||
#include "d3d9types.hpp"
|
||||
|
@ -1,7 +1,9 @@
|
||||
#include "opendx.hpp"
|
||||
#include <windows.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <winuser.h>
|
||||
#include <opendx.h>
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
* @brief Create a Window
|
||||
@ -22,6 +24,10 @@ HWND CreateWindowExA(
|
||||
HINSTANCE instance, //optional (Windows ignores it)
|
||||
LPVOID param //optional
|
||||
) {
|
||||
#ifdef DEBUG
|
||||
std::cout << "libopendx.so: CreateWindowExA()" << std::endl;
|
||||
#endif
|
||||
|
||||
GtkWidget* window = gtk_window_new();
|
||||
|
||||
if (title != nullptr) {
|
||||
|
@ -1,2 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include <config.hpp>
|
@ -35,7 +35,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <windef.h>
|
||||
#include <winnt.h>
|
||||
//#include <gtk/gtk.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define DWORD unsigned long
|
||||
#define HWND GtkWidget*
|
||||
|
Loading…
x
Reference in New Issue
Block a user