├── .devcontainer └── devcontainer.json ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ └── cmake.yml ├── .gitignore ├── .vscode ├── c_cpp_properties.json ├── launch.json ├── settings.json └── tasks.json ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── build.sh ├── build └── .no-delete ├── img ├── logo.png ├── print.png └── social.png ├── include ├── config.hpp ├── config.hpp.in ├── preprocessor │ └── GetFileContent.hpp └── types │ └── Translation.hpp ├── libs ├── Ole32 │ └── Ole32.cpp ├── d3d9 │ ├── d3d9.cpp │ ├── d3d9.hpp │ ├── d3d9_types.hpp │ ├── d3d9helper.hpp │ ├── d3d9macros.hpp │ ├── d3d9types.hpp │ ├── d3dadapter.cpp │ ├── d3dobject.cpp │ ├── d3dobject.hpp │ ├── i915 │ │ ├── idirect3ddevice9.cpp │ │ └── idirect3ddevice9.hpp │ ├── idirect3d9.cpp │ ├── idirect3d9.hpp │ └── idirect3ddevice9.hpp ├── dsetup │ ├── README.md │ ├── dsetup.cpp │ ├── dsetup.hpp │ └── fun │ │ ├── DirectXSetupGetVersion.cpp │ │ └── DirectXSetupGetVersion.hpp └── opendx │ ├── README.md │ ├── gtk │ ├── gdkd3dcontext.cpp │ └── gdkd3dcontext.hpp │ ├── opendx.cpp │ ├── opendx.hpp │ └── opendx_config.hpp ├── pack.sh ├── prod_include ├── README.md ├── basetsd.h ├── d3d9.h ├── objbase.h ├── opendx.h ├── unknwn.h ├── winbase.h ├── windef.h ├── windows.h ├── winerror.h ├── winnt.h └── winuser.h ├── run.sh ├── setpath.sh ├── tests ├── CMakeLists.txt └── basic_window.cpp └── tools └── dxdiag ├── README.md ├── layout ├── MainWindow.hpp └── MainWindow.ui ├── locale ├── de_DE.hpp ├── en_US.hpp ├── es_ES.hpp ├── it_IT.hpp ├── pt_BR.hpp └── tr_TR.hpp ├── main.cpp └── src ├── SystemTab.hpp └── utils ├── .DXUtils.hpp.kate-swp └── DXUtils.hpp /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ubuntu", 3 | "image": "docker.io/library/ubuntu", 4 | "customizations": { 5 | "vscode": { 6 | "extensions": [ 7 | "ms-vscode.cpptools-extension-pack" 8 | ] 9 | } 10 | }, 11 | "features": { 12 | "ghcr.io/devcontainers/features/desktop-lite:1": {} 13 | }, 14 | "onCreateCommand": "apt update && apt install sudo git", 15 | "postCreateCommand": "sudo ./build.sh" 16 | } 17 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: EduApps-CDG 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report crashes, rendering issues etc. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Please describe your issue as accurately as possible. If you run into a problem with a binary release, make sure to test with latest `master` as well. 11 | 12 | **Important:** When reporting an issue with a specific game or application, such as crashes or rendering issues, please include log files and, if possible, a D3D11/D3D9 Apitrace (see https://github.com/apitrace/apitrace) so that the issue can be reproduced. 13 | In order to create a trace for **D3D11/D3D10**: Run `wine apitrace.exe trace -a dxgi YOURGAME.exe`. 14 | In order to create a trace for **D3D9**: Follow https://github.com/Joshua-Ashton/d9vk/wiki/Making-a-Trace. 15 | Preferably record the trace on Windows, or wined3d if possible. 16 | 17 | **Reports with no log files will be ignored.** 18 | 19 | ### Software information 20 | Name of the game, settings used etc. 21 | 22 | ### System information 23 | - GPU: 24 | - Driver: 25 | - Wine version: 26 | - DXVK version: 27 | 28 | ### Apitrace file(s) 29 | - Put a link here 30 | 31 | ### Log files 32 | - d3d9.log: 33 | - d3d11.log: 34 | - dxgi.log: 35 | -------------------------------------------------------------------------------- /.github/workflows/cmake.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | env: 10 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 11 | BUILD_TYPE: Release 12 | 13 | jobs: 14 | build: 15 | # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. 16 | # You can convert this to a matrix build if you need cross-platform coverage. 17 | # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 18 | runs-on: ubuntu-latest 19 | 20 | steps: 21 | - uses: actions/checkout@v3 22 | 23 | - name: Auto-build and Resolve dependencies 24 | run: ./build.sh 25 | 26 | - name: Packing into a tar and a deb 27 | run: ./pack.sh #&& cat /home/runner/work/OpenDX/OpenDX/build/_CPack_Packages/Linux/DEB/PreinstallOutput.log 28 | 29 | - name: Test 30 | working-directory: ${{github.workspace}}/build 31 | # Execute tests defined by the CMake configuration. 32 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail 33 | run: ctest -C ${{env.BUILD_TYPE}} 34 | 35 | - name: Upload Artifact 36 | uses: actions/upload-artifact@v4 37 | with: 38 | path: | 39 | opendx.deb 40 | opendx.tar 41 | retention-days: 5 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | include/config.hpp 2 | CMakeLists.txt.user 3 | CMakeCache.txt 4 | CMakeFiles 5 | CMakeScripts 6 | Testing 7 | Makefile 8 | cmake_install.cmake 9 | install_manifest.txt 10 | compile_commands.json 11 | CTestTestfile.cmake 12 | _deps 13 | build 14 | .kdev4 15 | OpenDX.kdev4 16 | opendx.tar 17 | opendx.deb 18 | !build/.no-delete 19 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "${workspaceFolder}/include", 8 | "${workspaceFolder}/prod_include", 9 | "/usr/include/c++/12", 10 | "/usr/include/x86_64-linux-gnu/c++/12", 11 | "/usr/include/c++/12/backward", 12 | "/usr/lib/gcc/x86_64-linux-gnu/12/include", 13 | "/usr/local/include", 14 | "/usr/include/x86_64-linux-gnu", 15 | "/usr/include", 16 | "/usr/include/pango-1.0", 17 | "/usr/include/gtk-4.0", 18 | "/usr/include/glib-2.0", 19 | "/usr/include/pango-1.0", 20 | "/usr/lib/x86_64-linux-gnu/glib-2.0/include", 21 | "/usr/include/harfbuzz", 22 | "/usr/include/freetype2", 23 | "/usr/include/libpng16", 24 | "/usr/include/libmount", 25 | "/usr/include/blkid", 26 | "/usr/include/fribidi", 27 | "/usr/include/cairo", 28 | "/usr/include/pixman-1", 29 | "/usr/include/gdk-pixbuf-2.0", 30 | "/usr/include/graphene-1.0", 31 | "/usr/lib/x86_64-linux-gnu/graphene-1.0/include" 32 | ], 33 | "compilerArgs": [ 34 | "-I${workspaceFolder}/include/d3d12.so", 35 | "-I${workspaceFolder}/include/dxgi.so", 36 | "-I${workspaceFolder}/include/wrl" 37 | ], 38 | "defines": [], 39 | "compilerPath": "/usr/bin/gcc", 40 | "cppStandard": "gnu++23", 41 | "intelliSenseMode": "linux-gcc-x64", 42 | "cStandard": "gnu23", 43 | "compileCommands": "${workspaceFolder}/build/compile_commands.json" 44 | } 45 | ], 46 | "version": 4 47 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | //cmake then make in build folder 4 | { 5 | "name": "dxdiag", 6 | "type": "cppdbg", 7 | "request": "launch", 8 | "program": "${workspaceFolder}/build/dxdiag", 9 | "args": [], 10 | "stopAtEntry": false, 11 | "cwd": "${workspaceFolder}/build", 12 | "environment": [], 13 | "externalConsole": false, 14 | "MIMode": "gdb", 15 | "miDebuggerPath": "/usr/bin/gdb" 16 | }, 17 | 18 | //sample (also in build folder) 19 | { 20 | "name": "sample", 21 | "type": "cppdbg", 22 | "request": "launch", 23 | "program": "${workspaceFolder}/build/tests/sample", 24 | "args": [], 25 | "stopAtEntry": false, 26 | "cwd": "${workspaceFolder}/build", 27 | "environment": [], 28 | "externalConsole": false, 29 | "MIMode": "gdb", 30 | "miDebuggerPath": "/usr/bin/gdb" 31 | } 32 | ], 33 | "version": "2.0.0" 34 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "mesonbuild.configureOnOpen": true, 3 | "C_Cpp.codeAnalysis.clangTidy.checks.disabled": [ 4 | "clang-diagnostic-pragma-once-outside-header" 5 | ], 6 | "files.associations": { 7 | "*.toml": "ini", 8 | "new": "cpp", 9 | "array": "cpp", 10 | "atomic": "cpp", 11 | "bit": "cpp", 12 | "*.tcc": "cpp", 13 | "cctype": "cpp", 14 | "clocale": "cpp", 15 | "cmath": "cpp", 16 | "compare": "cpp", 17 | "concepts": "cpp", 18 | "cstdarg": "cpp", 19 | "cstddef": "cpp", 20 | "cstdint": "cpp", 21 | "cstdio": "cpp", 22 | "cstdlib": "cpp", 23 | "cstring": "cpp", 24 | "ctime": "cpp", 25 | "cwchar": "cpp", 26 | "cwctype": "cpp", 27 | "deque": "cpp", 28 | "string": "cpp", 29 | "unordered_map": "cpp", 30 | "vector": "cpp", 31 | "exception": "cpp", 32 | "algorithm": "cpp", 33 | "functional": "cpp", 34 | "iterator": "cpp", 35 | "memory": "cpp", 36 | "memory_resource": "cpp", 37 | "numeric": "cpp", 38 | "random": "cpp", 39 | "string_view": "cpp", 40 | "system_error": "cpp", 41 | "tuple": "cpp", 42 | "type_traits": "cpp", 43 | "utility": "cpp", 44 | "fstream": "cpp", 45 | "initializer_list": "cpp", 46 | "iomanip": "cpp", 47 | "iosfwd": "cpp", 48 | "iostream": "cpp", 49 | "istream": "cpp", 50 | "limits": "cpp", 51 | "numbers": "cpp", 52 | "ostream": "cpp", 53 | "sstream": "cpp", 54 | "stdexcept": "cpp", 55 | "streambuf": "cpp", 56 | "cinttypes": "cpp", 57 | "typeinfo": "cpp", 58 | "*.ui": "cpp", 59 | "bitset": "cpp", 60 | "regex": "cpp", 61 | "charconv": "cpp", 62 | "map": "cpp", 63 | "set": "cpp", 64 | "expected": "cpp", 65 | "optional": "cpp", 66 | "format": "cpp", 67 | "span": "cpp", 68 | "variant": "cpp", 69 | "*.in": "cpp" 70 | }, 71 | "C_Cpp.codeAnalysis.clangTidy.useBuildPath": true 72 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "type": "cppbuild", 5 | "label": "C/C++: g++ build active file", 6 | "command": "/usr/bin/g++", 7 | "args": [ 8 | "-fdiagnostics-color=always", 9 | "-g", 10 | "${file}", 11 | "-o", 12 | "${fileDirname}/${fileBasenameNoExtension}" 13 | ], 14 | "options": { 15 | "cwd": "${fileDirname}" 16 | }, 17 | "problemMatcher": [ 18 | "$gcc" 19 | ], 20 | "group": { 21 | "kind": "build", 22 | "isDefault": true 23 | }, 24 | "detail": "Task generated by Debugger." 25 | }, 26 | { 27 | "type": "cppbuild", 28 | "label": "C/C++: gcc build active file", 29 | "command": "/usr/bin/gcc", 30 | "args": [ 31 | "-fdiagnostics-color=always", 32 | "-g", 33 | "${file}", 34 | "-o", 35 | "${fileDirname}/${fileBasenameNoExtension}", 36 | "-I${workspaceFolder}/include/d3d12.so", 37 | "-I${workspaceFolder}/include/dxgi.so", 38 | "-I${workspaceFolder}/include/wrl" 39 | ], 40 | "options": { 41 | "cwd": "${fileDirname}" 42 | }, 43 | "problemMatcher": [ 44 | "$gcc" 45 | ], 46 | "group": "build", 47 | "detail": "Task generated by Debugger." 48 | } 49 | ], 50 | "version": "2.0.0" 51 | } -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 2 | # SPDX-License-Identifier: Apache-2.0 3 | 4 | # - Try to find 5 | # Once done this will define 6 | # _FOUND - System has 7 | # _INCLUDE_DIRS - The include directories 8 | # _LIBRARIES - The libraries needed to use 9 | # _DEFINITIONS - Compiler switches required for using 10 | 11 | set(PROJECT_SOURCE_DIR "${CMAKE_SOURCE_DIR}") 12 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/opendx/bin") 13 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/opendx/lib") 14 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 15 | 16 | #Package 17 | set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/opendx) 18 | set(CPACK_GENERATOR "DEB") 19 | set(CPACK_PACKAGE_NAME "opendx") 20 | set(CPACK_PACKAGE_VERSION "1.0.0") 21 | set(CPACK_PACKAGE_DESCRIPTION "Open Source reimplementation of DirectX for Linux") 22 | set(CPACK_PACKAGE_CONTACT "Eduardo P. Gomez ") 23 | set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgtk-4-1, libdrm2") 24 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") 25 | 26 | 27 | #base include 28 | include_directories(./include) 29 | configure_file(include/config.hpp.in ../include/config.hpp) 30 | 31 | #production include (for use with .so files) 32 | include_directories(./prod_include) 33 | 34 | #Defaults 35 | set(CMAKE_C_STANDARD 23) 36 | set(CMAKE_CXX_STANDARD 23) 37 | cmake_minimum_required(VERSION 3.22) 38 | project(OpenDX) 39 | 40 | #Packaging 41 | include(CPack) 42 | install(DIRECTORY ${CMAKE_BINARY_DIR}/opendx/bin DESTINATION /usr/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) 43 | install(DIRECTORY ${CMAKE_BINARY_DIR}/opendx/lib DESTINATION /usr/ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ WORLD_READ) 44 | 45 | find_package(PkgConfig) 46 | pkg_check_modules(PC_ QUIET ) 47 | set(_DEFINITIONS ${PC__CFLAGS_OTHER}) 48 | 49 | find_path(_INCLUDE_DIR 50 | HINTS ${PC__INCLUDEDIR} ${PC__INCLUDE_DIRS} 51 | PATH_SUFFIXES ) 52 | 53 | find_library(_LIBRARY NAMES 54 | HINTS ${PC__LIBDIR} ${PC__LIBRARY_DIRS} ) 55 | pkg_check_modules(GTK4 REQUIRED gtk4) 56 | pkg_check_modules(LIBDRM REQUIRED libdrm) 57 | 58 | set(_LIBRARIES ${_LIBRARY} ) 59 | set(_INCLUDE_DIRS ${_INCLUDE_DIR} ) 60 | 61 | include(FindPackageHandleStandardArgs) 62 | # handle the QUIETLY and REQUIRED arguments and set _FOUND to TRUE 63 | # if all listed variables are TRUE 64 | find_package_handle_standard_args( DEFAULT_MSG 65 | _LIBRARY _INCLUDE_DIR) 66 | mark_as_advanced(_INCLUDE_DIR _LIBRARY ) 67 | 68 | find_package(PkgConfig REQUIRED) 69 | 70 | #dependency 71 | include_directories(${GTK4_INCLUDE_DIRS}) 72 | link_directories(${GTK4_LIBRARY_DIRS}) 73 | include_directories(${LIBDRM_INCLUDE_DIRS}) 74 | link_directories(${LIBDRM_LIBRARY_DIRS}) 75 | 76 | #libopendx.so: 77 | set(OPENDX_CPP libs/opendx/opendx.cpp) 78 | #file(GLOB_RECURSE OPENDX_CPP libs/opendx/fun/*.cpp) 79 | add_library(opendx SHARED ${OPENDX_CPP}) 80 | target_link_libraries(opendx ${GTK4_LIBRARIES}) 81 | target_link_libraries(opendx ${LIBDRM_LIBRARIES}) 82 | 83 | #libdsetup.so: 84 | set(DSETUP_CPP libs/dsetup/dsetup.cpp) 85 | file(GLOB_RECURSE DSETUP_CPP libs/dsetup/fun/*.cpp) 86 | 87 | add_library(dsetup SHARED ${DSETUP_CPP}) 88 | 89 | #libd3d9.so: 90 | file(GLOB_RECURSE D3D9_SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "libs/d3d9/*.cpp") 91 | add_library(d3d9 SHARED ${D3D9_SOURCES}) 92 | target_link_libraries(d3d9 ${LIBDRM_LIBRARIES}) 93 | 94 | #dxdiag: 95 | add_executable(dxdiag tools/dxdiag/main.cpp) 96 | target_link_libraries(dxdiag ${GTK4_LIBRARIES}) 97 | target_link_libraries(dxdiag dsetup) 98 | target_link_libraries(dxdiag d3d9) 99 | 100 | include(tests/CMakeLists.txt) 101 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | This guide shows how to prepare your environment to contribute for OpenDX's DirectX reimplementation. 3 | 4 | ## Dependencies 5 | `./build.sh` detect and try to install the dependencies for you, but if you want to do it manually, here is the list of dependencies: 6 | 7 | | Dependency | Version | 8 | |:-|-:| 9 | |[`gcc`](https://packages.ubuntu.com/lunar/gcc)|`12.2.0`| 10 | |[`cmake`](https://packages.ubuntu.com/lunar/cmake)|`3.25.1`| 11 | |[`make`](https://packages.ubuntu.com/lunar/make)|`4.3`| 12 | |[`libgtk-4-dev`](https://packages.ubuntu.com/lunar/libgtk-4-dev)|`4.10.1`| 13 | |[`libdrm-dev`](https://packages.ubuntu.com/lunar/libdrm-dev)|`4.10.1`| 14 | 15 | ## Building and running 16 | These are the same universal steps for cmake: 17 | 18 | **Build:** 19 | ```sh 20 | ./build.sh 21 | ``` 22 | 23 | **Run:** 24 | ```sh 25 | #setups the terminal for better running. 26 | PATH=$PATH:./build/opendx/bin 27 | 28 | #commands available to run: 29 | dxdiag 30 | sample 31 | ``` 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Eduardo Procopio Gomez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

3 | OpenDX 4 |
5 | | Bring DirectX to Linux! 6 |

7 | The Open Source DirectX alternative for Linux. 8 | 9 | **Compile:** `./build.sh && ./run.sh` 10 | 11 | [![Build Status](https://github.com/EduApps-CDG/OpenDX/actions/workflows/cmake.yml/badge.svg)](https://github.com/EduApps-CDG/OpenDX/actions/workflows/cmake.yml) 12 |
13 | 14 | OpenDX is a fully-featured implementation of DirectX for the Linux operating system, without the need for compatibility layers or emulators. This allows Linux developers to build DirectX games and applications with improved performance thanks to Linux's built-in Direct Rendering Manager (DRM). 15 | 16 |
17 | 18 | ![OpenDX dxdiag](./img/print.png) 19 |
20 | 21 | ## Improved Performance 22 | We believe that Linux should have a native implementation of DirectX, which will provide improved performance and compatibility compared to compatibility layers such as Wine. 23 | Although the project is still in development and we have a long way to go, we are committed to bringing you the best possible experience when playing DirectX games on Linux. 24 | 25 | Here's a list of what OpenDX does better than Windows: 26 | * dxdiag: Even on 11th gen Intel CPUs, dxdiag takes some time to open on Windows. On OpenDX, it opens instantly. Also, in the System tab, OpenDX shows the correct date and time, while Windows shows the date and time when dxdiag was opened (*lol*). 27 | 28 | ## [Join the OpenDX Community](https://github.com/EduApps-CDG/OpenDX/discussions) 29 | If you are interested in contributing to OpenDX or just want to stay up-to-date on the project, please join the community and share your toughts. 30 | 31 | ## Give us a Star and Contribute 32 | If you like OpenDX, please give us a star on GitHub. This will help us to attract more users and contributors. 33 | 34 | Active contributors will also appear here: 35 | 36 | 37 | 38 | 39 | 40 | Join us on our journey to bring DirectX to Linux! 41 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file will install the required packages and build the project 3 | 4 | # Check if package is installed 5 | function check_package { 6 | if ! dpkg -s $1 > /dev/null 2>&1; then 7 | echo "Package $1 is not installed. Installing..." 8 | sudo apt install $1 9 | fi 10 | } 11 | 12 | # Check if package is installed (Ubuntu) 13 | check_package "gcc" 14 | check_package "cmake" 15 | check_package "make" 16 | check_package "libdrm-dev" 17 | check_package "libgtk-4-dev" 18 | 19 | # Build the project 20 | cd build 21 | cmake .. 22 | make 23 | 24 | echo "Build complete, run ./run.sh to run the program" 25 | -------------------------------------------------------------------------------- /build/.no-delete: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EduApps-CDG/OpenDX/6a8b51491f3b0d5973837bc274ef7f57e5ea3552/build/.no-delete -------------------------------------------------------------------------------- /img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EduApps-CDG/OpenDX/6a8b51491f3b0d5973837bc274ef7f57e5ea3552/img/logo.png -------------------------------------------------------------------------------- /img/print.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EduApps-CDG/OpenDX/6a8b51491f3b0d5973837bc274ef7f57e5ea3552/img/print.png -------------------------------------------------------------------------------- /img/social.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EduApps-CDG/OpenDX/6a8b51491f3b0d5973837bc274ef7f57e5ea3552/img/social.png -------------------------------------------------------------------------------- /include/config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #define export __attribute__((visibility("default"))) 5 | 6 | #define DEBUG true 7 | #ifdef DEBUG 8 | #define DLOG(x) std::cout << x << std::endl; 9 | #else 10 | #define DLOG(x) //x 11 | #endif 12 | 13 | //PREPROCESSING ONLY!!! 14 | #define PROJECT_SOURCE_DIR "/home/eduardo/Documentos/proj/OpenDX/" 15 | #define CONFIG_FILE "opendx.conf" 16 | -------------------------------------------------------------------------------- /include/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #define export __attribute__((visibility("default"))) 5 | 6 | #define DEBUG true 7 | #ifdef DEBUG 8 | #define DLOG(x) std::cout << x << std::endl; 9 | #else 10 | #define DLOG(x) //x 11 | #endif 12 | 13 | //PREPROCESSING ONLY!!! 14 | #define PROJECT_SOURCE_DIR "@PROJECT_SOURCE_DIR@/" 15 | #define CONFIG_FILE "opendx.conf" -------------------------------------------------------------------------------- /include/preprocessor/GetFileContent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | /** 8 | * Caution: by using that function, 9 | * it means that every time it's called 10 | * the file content will be included in the code 11 | */ 12 | #define GetFileContent(file_path) #file_path 13 | -------------------------------------------------------------------------------- /include/types/Translation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef struct { 4 | //Common texts 5 | char* yes; 6 | char* no; 7 | char* not_available; 8 | char* enabled; 9 | 10 | //Tab names 11 | char* tab_system; 12 | char* tab_display; 13 | char* tab_sound; 14 | char* tab_input; 15 | 16 | //Buttons 17 | char* btn_help; 18 | char* btn_next; 19 | char* btn_save; 20 | char* btn_exit; 21 | 22 | //Tab System 23 | char* system_description; //This tool reports [...] 24 | char* system_info_label; //Section System Info 25 | char* system_info_currentDate; 26 | char* system_info_pcName; 27 | char* system_info_os; 28 | char* system_info_language; 29 | char* system_info_manufacturer; 30 | char* system_info_model; 31 | char* system_info_bios; 32 | char* system_info_processor; 33 | char* system_info_memory; 34 | char* system_info_pageFile; 35 | char* system_info_directxVersion; 36 | char* system_info_opendxVersion; //exclusive :) 37 | 38 | //Tab Display X 39 | char* display_device_label; // section Device 40 | char* display_device_manufacturer; 41 | char* display_device_chipType; 42 | char* display_device_dacType; 43 | char* display_device_type; 44 | char* display_device_mem; 45 | char* display_device_videoMem; 46 | char* display_device_sharedMem; 47 | char* display_device_currDisplayMode; 48 | char* display_device_monitor; 49 | char* display_driver_label; //section Drivers 50 | char* display_driver_mainDriver; 51 | char* display_driver_version; 52 | char* display_driver_date; 53 | char* display_driver_whqlLogo; 54 | char* display_driver_d3dDdi; 55 | char* display_driver_featureLevels; 56 | char* display_driver_model; 57 | char* display_features_label; //section DirecX Features 58 | char* display_features_ddAccel; 59 | char* display_features_d3dAccel; 60 | char* display_features_agpAccel; 61 | char* display_notes_label; //section Notes 62 | 63 | //Tab Sound 64 | char* sound_device_label; //section Device 65 | char* sound_device_name; 66 | char* sound_device_hardwareId; 67 | char* sound_device_manufacturerId; 68 | char* sound_device_productId; 69 | char* sound_device_type; 70 | char* sound_device_default; 71 | char* sound_driver_label; //section Drivers 72 | char* sound_driver_name; 73 | char* sound_driver_version; 74 | char* sound_driver_date; 75 | char* sound_driver_whqlLogo; 76 | char* sound_driver_otherFiles; 77 | char* sound_driver_provider; 78 | char* sound_notes_label; //section Notes 79 | } Translation_t; 80 | -------------------------------------------------------------------------------- /libs/Ole32/Ole32.cpp: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/d3d9/d3d9.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "d3d9types.hpp" 4 | #include "d3d9helper.hpp" 5 | #include "d3d9.hpp" 6 | #include "d3dobject.hpp" 7 | #include 8 | #include 9 | 10 | export IDirect3D9Ex::IDirect3D9Ex(UINT SDKVersion):IDirect3D9(SDKVersion) { 11 | } 12 | 13 | export IDirect3D9* Direct3DCreate9(UINT SDKVersion) { 14 | HINSTANCE instance = NULL; 15 | constexpr const UINT supported_sdk = 0x0900; 16 | 17 | if (SDKVersion != supported_sdk) { 18 | std::cout << "\033[1;31m" //RED BOLD 19 | << std::endl 20 | << "D3D ERROR: This application compiled against improper D3D headers." << std::endl 21 | << "The application is compiled with SDK version (" << SDKVersion << ") but the currently installed" << std::endl 22 | << "runtime supports versions from (" << supported_sdk << ")." << std::endl 23 | << "Please recompile with an up-to-date SDK.\033[0;0m" << std::endl 24 | << std::endl; 25 | return NULL; 26 | } 27 | 28 | IDirect3D9* r = new IDirect3D9(SDKVersion); 29 | 30 | if (r == NULL) 31 | std::cout << "\033[0;31m" 32 | << "Creating D3D enumeration object failed; out of memory. Direct3DCreate fails and returns NULL.\033[0;0m" << std::endl; 33 | 34 | return r; 35 | } 36 | 37 | // IDirect3DDevice9::IDirect3DDevice9(/*IDirect3D9* d3d, D3DPRESENT_PARAMETERS* pp*/) { 38 | // #ifdef DEBUG 39 | // std::cout << "libd3d9.so: IDirect3DDevice9::IDirect3DDevice9()" << std::endl; 40 | // #endif 41 | 42 | // refCount = 1; 43 | // } 44 | 45 | // ULONG IDirect3DDevice9::AddRef() { 46 | // DXGASSERT(((ULONG_PTR)(&refCount) & 3) == 0); 47 | 48 | // InterlockedIncrement((LONG *)&refCount); 49 | // return refCount; 50 | // } 51 | 52 | // ULONG IDirect3DDevice9::Release() { 53 | // InterlockedDecrement((LONG *)&refCount); 54 | // return refCount; 55 | // } 56 | 57 | // HRESULT IDirect3DDevice9::QueryInterface(REFIID riid, void** ppvObj) { 58 | // *ppvObj = this; 59 | 60 | // IDirect3DDevice9::AddRef(); 61 | // return 0; 62 | // } 63 | 64 | // HRESULT IDirect3DDevice9::Clear(DWORD Count, const void/*D3DRECT*/ *pRects, DWORD Flags, int/*D3DCOLOR*/ Color, float Z, DWORD Stencil) { 65 | // #ifdef DEBUG 66 | // std::cout << "libd3d9.so: IDirect3DDevice9::Clear()" << std::endl; 67 | // #endif 68 | 69 | // //intel code 70 | 71 | // return 0; 72 | // } -------------------------------------------------------------------------------- /libs/d3d9/d3d9.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "d3d9helper.hpp" 5 | #include "d3d9types.hpp" 6 | #include "idirect3ddevice9.hpp" 7 | 8 | #define D3DCREATE_PUREDEVICE 0x00000010L 9 | #define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L 10 | #define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L 11 | #define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L 12 | 13 | typedef struct IDirect3D9 *LPDIRECT3D9, *PDIRECT3D9; 14 | IDirect3D9* Direct3DCreate9(UINT SDKVersion); -------------------------------------------------------------------------------- /libs/d3d9/d3d9_types.hpp: -------------------------------------------------------------------------------- 1 | typedef enum { 2 | REF_EXTERNAL = 0, 3 | REF_INTRINSIC = 1, 4 | REF_INTERNAL = 2 5 | 6 | } REF_TYPE; 7 | /** 8 | * Defines the various types of surface formats. 9 | */ 10 | typedef enum _D3DFORMAT { 11 | D3DFMT_UNKNOWN = 0, 12 | 13 | D3DFMT_R8G8B8 = 20, 14 | D3DFMT_A8R8G8B8 = 21, 15 | D3DFMT_X8R8G8B8 = 22, 16 | D3DFMT_R5G6B5 = 23, 17 | D3DFMT_X1R5G5B5 = 24, 18 | D3DFMT_A1R5G5B5 = 25, 19 | D3DFMT_A4R4G4B4 = 26, 20 | D3DFMT_R3G3B2 = 27, 21 | D3DFMT_A8 = 28, 22 | D3DFMT_A8R3G3B2 = 29, 23 | D3DFMT_X4R4G4B4 = 30, 24 | D3DFMT_A2B10G10R10 = 31, 25 | D3DFMT_A8B8G8R8 = 32, 26 | D3DFMT_X8B8G8R8 = 33, 27 | D3DFMT_G16R16 = 34, 28 | D3DFMT_A2R10G10B10 = 35, 29 | D3DFMT_A16B16G16R16 = 36, 30 | 31 | D3DFMT_A8P8 = 40, 32 | D3DFMT_P8 = 41, 33 | 34 | D3DFMT_L8 = 50, 35 | D3DFMT_A8L8 = 51, 36 | D3DFMT_A4L4 = 52, 37 | 38 | D3DFMT_V8U8 = 60, 39 | D3DFMT_L6V5U5 = 61, 40 | D3DFMT_X8L8V8U8 = 62, 41 | D3DFMT_Q8W8V8U8 = 63, 42 | D3DFMT_V16U16 = 64, 43 | D3DFMT_A2W10V10U10 = 67, 44 | 45 | D3DFMT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'), 46 | D3DFMT_R8G8_B8G8 = MAKEFOURCC('R', 'G', 'B', 'G'), 47 | D3DFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'), 48 | D3DFMT_G8R8_G8B8 = MAKEFOURCC('G', 'R', 'G', 'B'), 49 | D3DFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'), 50 | D3DFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'), 51 | D3DFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'), 52 | D3DFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'), 53 | D3DFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'), 54 | 55 | D3DFMT_D16_LOCKABLE = 70, 56 | D3DFMT_D32 = 71, 57 | D3DFMT_D15S1 = 73, 58 | D3DFMT_D24S8 = 75, 59 | D3DFMT_D24X8 = 77, 60 | D3DFMT_D24X4S4 = 79, 61 | D3DFMT_D16 = 80, 62 | 63 | D3DFMT_D32F_LOCKABLE = 82, 64 | D3DFMT_D24FS8 = 83, 65 | 66 | #if !defined(D3D_DISABLE_9EX) 67 | D3DFMT_D32_LOCKABLE = 84, 68 | D3DFMT_S8_LOCKABLE = 85, 69 | #endif // !D3D_DISABLE_9EX 70 | 71 | D3DFMT_L16 = 81, 72 | 73 | D3DFMT_VERTEXDATA =100, 74 | D3DFMT_INDEX16 =101, 75 | D3DFMT_INDEX32 =102, 76 | 77 | D3DFMT_Q16W16V16U16 =110, 78 | 79 | D3DFMT_MULTI2_ARGB8 = MAKEFOURCC('M','E','T','1'), 80 | 81 | D3DFMT_R16F = 111, 82 | D3DFMT_G16R16F = 112, 83 | D3DFMT_A16B16G16R16F = 113, 84 | 85 | D3DFMT_R32F = 114, 86 | D3DFMT_G32R32F = 115, 87 | D3DFMT_A32B32G32R32F = 116, 88 | 89 | D3DFMT_CxV8U8 = 117, 90 | 91 | #if !defined(D3D_DISABLE_9EX) 92 | D3DFMT_A1 = 118, 93 | D3DFMT_A2B10G10R10_XR_BIAS = 119, 94 | D3DFMT_BINARYBUFFER = 199, 95 | #endif // !D3D_DISABLE_9EX 96 | 97 | D3DFMT_FORCE_DWORD =0x7fffffff 98 | } D3DFORMAT; 99 | 100 | /** 101 | * Defines the levels of full-scene multisampling that the device can apply. 102 | */ 103 | typedef enum D3DMULTISAMPLE_TYPE { 104 | D3DMULTISAMPLE_NONE = 0, 105 | D3DMULTISAMPLE_NONMASKABLE = 1, 106 | D3DMULTISAMPLE_2_SAMPLES = 2, 107 | D3DMULTISAMPLE_3_SAMPLES = 3, 108 | D3DMULTISAMPLE_4_SAMPLES = 4, 109 | D3DMULTISAMPLE_5_SAMPLES = 5, 110 | D3DMULTISAMPLE_6_SAMPLES = 6, 111 | D3DMULTISAMPLE_7_SAMPLES = 7, 112 | D3DMULTISAMPLE_8_SAMPLES = 8, 113 | D3DMULTISAMPLE_9_SAMPLES = 9, 114 | D3DMULTISAMPLE_10_SAMPLES = 10, 115 | D3DMULTISAMPLE_11_SAMPLES = 11, 116 | D3DMULTISAMPLE_12_SAMPLES = 12, 117 | D3DMULTISAMPLE_13_SAMPLES = 13, 118 | D3DMULTISAMPLE_14_SAMPLES = 14, 119 | D3DMULTISAMPLE_15_SAMPLES = 15, 120 | D3DMULTISAMPLE_16_SAMPLES = 16, 121 | D3DMULTISAMPLE_FORCE_DWORD = 0xffffffff 122 | } D3DMULTISAMPLE_TYPE, *LPD3DMULTISAMPLE_TYPE; 123 | 124 | /** 125 | * Defines swap effects 126 | */ 127 | typedef enum D3DSWAPEFFECT { 128 | D3DSWAPEFFECT_DISCARD = 1, 129 | D3DSWAPEFFECT_FLIP = 2, 130 | D3DSWAPEFFECT_COPY = 3, 131 | D3DSWAPEFFECT_OVERLAY = 4, 132 | D3DSWAPEFFECT_FLIPEX = 5, 133 | D3DSWAPEFFECT_FORCE_DWORD = 0xFFFFFFFF 134 | } D3DSWAPEFFECT, *LPD3DSWAPEFFECT; 135 | 136 | /** 137 | * Describes the presentation parameters. 138 | */ 139 | struct D3DPRESENT_PARAMETERS { 140 | UINT BackBufferWidth; 141 | UINT BackBufferHeight; 142 | D3DFORMAT BackBufferFormat; 143 | UINT BackBufferCount; 144 | D3DMULTISAMPLE_TYPE MultiSampleType; 145 | DWORD MultiSampleQuality; 146 | D3DSWAPEFFECT SwapEffect; 147 | HWND hDeviceWindow; 148 | BOOL Windowed; 149 | BOOL EnableAutoDepthStencil; 150 | D3DFORMAT AutoDepthStencilFormat; 151 | DWORD Flags; 152 | UINT FullScreen_RefreshRateInHz; 153 | UINT PresentationInterval; 154 | }; 155 | typedef struct D3DPRESENT_PARAMETERS D3DPRESENT_PARAMETERS, *LPD3DPRESENT_PARAMETERS; -------------------------------------------------------------------------------- /libs/d3d9/d3d9helper.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "idirect3ddevice9.hpp" 4 | #include "idirect3d9.hpp" 5 | 6 | /** 7 | * IDirect3D9 8 | */ 9 | typedef IDirect3D9 *LPDIRECT3D9, *PDIRECT3D9; 10 | typedef IDirect3DDevice9 *LPDIRECT3DDEVICE9, *PDIRECT3DDEVICE9; 11 | -------------------------------------------------------------------------------- /libs/d3d9/d3d9macros.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //not sure if this goes here. 4 | /*#define API_ENTER_NO_LOCK() \ 5 | do { \ 6 | InterlockedIncrement(&g_nInsideAPI); \ 7 | } while (false)*/ 8 | 9 | // #ifdef _DEBUG 10 | // #define DXGASSERT(exp) do { \ 11 | // if (!(exp)) { \ 12 | // fprintf(stderr, "Assertion failed: %s, file %s, line %d\n", #exp, __FILE__, __LINE__); \ 13 | // abort(); \ 14 | // } \ 15 | // } while (0) 16 | // #else 17 | // #define DXGASSERT(exp) ((void)0) 18 | // #endif 19 | 20 | // #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ 21 | // ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ 22 | // ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) -------------------------------------------------------------------------------- /libs/d3d9/d3d9types.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #define D3DADAPTER_DEFAULT 0 5 | 6 | #ifdef _DEBUG 7 | #define DXGASSERT(exp) do { \ 8 | if (!(exp)) { \ 9 | fprintf(stderr, "Assertion failed: %s, file %s, line %d\n", #exp, __FILE__, __LINE__); \ 10 | abort(); \ 11 | } \ 12 | } while (0) 13 | #else 14 | #define DXGASSERT(exp) ((void)0) 15 | #endif 16 | 17 | #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ 18 | ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ 19 | ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) 20 | 21 | typedef enum { 22 | REF_EXTERNAL = 0, 23 | REF_INTRINSIC = 1, 24 | REF_INTERNAL = 2 25 | 26 | } REF_TYPE; 27 | /** 28 | * Defines the various types of surface formats. 29 | */ 30 | typedef enum _D3DFORMAT { 31 | D3DFMT_UNKNOWN = 0, 32 | 33 | D3DFMT_R8G8B8 = 20, 34 | D3DFMT_A8R8G8B8 = 21, 35 | D3DFMT_X8R8G8B8 = 22, 36 | D3DFMT_R5G6B5 = 23, 37 | D3DFMT_X1R5G5B5 = 24, 38 | D3DFMT_A1R5G5B5 = 25, 39 | D3DFMT_A4R4G4B4 = 26, 40 | D3DFMT_R3G3B2 = 27, 41 | D3DFMT_A8 = 28, 42 | D3DFMT_A8R3G3B2 = 29, 43 | D3DFMT_X4R4G4B4 = 30, 44 | D3DFMT_A2B10G10R10 = 31, 45 | D3DFMT_A8B8G8R8 = 32, 46 | D3DFMT_X8B8G8R8 = 33, 47 | D3DFMT_G16R16 = 34, 48 | D3DFMT_A2R10G10B10 = 35, 49 | D3DFMT_A16B16G16R16 = 36, 50 | 51 | D3DFMT_A8P8 = 40, 52 | D3DFMT_P8 = 41, 53 | 54 | D3DFMT_L8 = 50, 55 | D3DFMT_A8L8 = 51, 56 | D3DFMT_A4L4 = 52, 57 | 58 | D3DFMT_V8U8 = 60, 59 | D3DFMT_L6V5U5 = 61, 60 | D3DFMT_X8L8V8U8 = 62, 61 | D3DFMT_Q8W8V8U8 = 63, 62 | D3DFMT_V16U16 = 64, 63 | D3DFMT_A2W10V10U10 = 67, 64 | 65 | D3DFMT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'), 66 | D3DFMT_R8G8_B8G8 = MAKEFOURCC('R', 'G', 'B', 'G'), 67 | D3DFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'), 68 | D3DFMT_G8R8_G8B8 = MAKEFOURCC('G', 'R', 'G', 'B'), 69 | D3DFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'), 70 | D3DFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'), 71 | D3DFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'), 72 | D3DFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'), 73 | D3DFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'), 74 | 75 | D3DFMT_D16_LOCKABLE = 70, 76 | D3DFMT_D32 = 71, 77 | D3DFMT_D15S1 = 73, 78 | D3DFMT_D24S8 = 75, 79 | D3DFMT_D24X8 = 77, 80 | D3DFMT_D24X4S4 = 79, 81 | D3DFMT_D16 = 80, 82 | 83 | D3DFMT_D32F_LOCKABLE = 82, 84 | D3DFMT_D24FS8 = 83, 85 | 86 | #if !defined(D3D_DISABLE_9EX) 87 | D3DFMT_D32_LOCKABLE = 84, 88 | D3DFMT_S8_LOCKABLE = 85, 89 | #endif // !D3D_DISABLE_9EX 90 | 91 | D3DFMT_L16 = 81, 92 | 93 | D3DFMT_VERTEXDATA =100, 94 | D3DFMT_INDEX16 =101, 95 | D3DFMT_INDEX32 =102, 96 | 97 | D3DFMT_Q16W16V16U16 =110, 98 | 99 | D3DFMT_MULTI2_ARGB8 = MAKEFOURCC('M','E','T','1'), 100 | 101 | D3DFMT_R16F = 111, 102 | D3DFMT_G16R16F = 112, 103 | D3DFMT_A16B16G16R16F = 113, 104 | 105 | D3DFMT_R32F = 114, 106 | D3DFMT_G32R32F = 115, 107 | D3DFMT_A32B32G32R32F = 116, 108 | 109 | D3DFMT_CxV8U8 = 117, 110 | 111 | #if !defined(D3D_DISABLE_9EX) 112 | D3DFMT_A1 = 118, 113 | D3DFMT_A2B10G10R10_XR_BIAS = 119, 114 | D3DFMT_BINARYBUFFER = 199, 115 | #endif // !D3D_DISABLE_9EX 116 | 117 | D3DFMT_FORCE_DWORD =0x7fffffff 118 | } D3DFORMAT; 119 | 120 | /** 121 | * Defines the levels of full-scene multisampling that the device can apply. 122 | */ 123 | typedef enum D3DMULTISAMPLE_TYPE { 124 | D3DMULTISAMPLE_NONE = 0, 125 | D3DMULTISAMPLE_NONMASKABLE = 1, 126 | D3DMULTISAMPLE_2_SAMPLES = 2, 127 | D3DMULTISAMPLE_3_SAMPLES = 3, 128 | D3DMULTISAMPLE_4_SAMPLES = 4, 129 | D3DMULTISAMPLE_5_SAMPLES = 5, 130 | D3DMULTISAMPLE_6_SAMPLES = 6, 131 | D3DMULTISAMPLE_7_SAMPLES = 7, 132 | D3DMULTISAMPLE_8_SAMPLES = 8, 133 | D3DMULTISAMPLE_9_SAMPLES = 9, 134 | D3DMULTISAMPLE_10_SAMPLES = 10, 135 | D3DMULTISAMPLE_11_SAMPLES = 11, 136 | D3DMULTISAMPLE_12_SAMPLES = 12, 137 | D3DMULTISAMPLE_13_SAMPLES = 13, 138 | D3DMULTISAMPLE_14_SAMPLES = 14, 139 | D3DMULTISAMPLE_15_SAMPLES = 15, 140 | D3DMULTISAMPLE_16_SAMPLES = 16, 141 | D3DMULTISAMPLE_FORCE_DWORD = 0xffffffff 142 | } D3DMULTISAMPLE_TYPE, *LPD3DMULTISAMPLE_TYPE; 143 | 144 | /** 145 | * Defines swap effects 146 | */ 147 | typedef enum D3DSWAPEFFECT { 148 | D3DSWAPEFFECT_DISCARD = 1, 149 | D3DSWAPEFFECT_FLIP = 2, 150 | D3DSWAPEFFECT_COPY = 3, 151 | D3DSWAPEFFECT_OVERLAY = 4, 152 | D3DSWAPEFFECT_FLIPEX = 5, 153 | D3DSWAPEFFECT_FORCE_DWORD = 0xFFFFFFFF 154 | } D3DSWAPEFFECT, *LPD3DSWAPEFFECT; 155 | 156 | /** 157 | * Describes the presentation parameters. 158 | */ 159 | struct D3DPRESENT_PARAMETERS { 160 | UINT BackBufferWidth; 161 | UINT BackBufferHeight; 162 | D3DFORMAT BackBufferFormat; 163 | UINT BackBufferCount; 164 | D3DMULTISAMPLE_TYPE MultiSampleType; 165 | DWORD MultiSampleQuality; 166 | D3DSWAPEFFECT SwapEffect; 167 | HWND hDeviceWindow; 168 | BOOL Windowed; 169 | BOOL EnableAutoDepthStencil; 170 | D3DFORMAT AutoDepthStencilFormat; 171 | DWORD Flags; 172 | UINT FullScreen_RefreshRateInHz; 173 | UINT PresentationInterval; 174 | }; 175 | typedef struct D3DPRESENT_PARAMETERS D3DPRESENT_PARAMETERS, *LPD3DPRESENT_PARAMETERS; -------------------------------------------------------------------------------- /libs/d3d9/d3dadapter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "idirect3d9.hpp" 3 | 4 | // typedef struct IDirect3D9ExVtbl 5 | // { 6 | // /* IUnknown */ 7 | // HRESULT (*QueryInterface)(IDirect3D9Ex *This, REFIID riid, void **ppvObject); 8 | // ULONG (*AddRef)(IDirect3D9Ex *This); 9 | // ULONG (*Release)(IDirect3D9Ex *This); 10 | // /* IDirect3D9 */ 11 | // HRESULT (*RegisterSoftwareDevice)(IDirect3D9Ex *This, void *pInitializeFunction); 12 | // UINT (*GetAdapterCount)(IDirect3D9Ex *This); 13 | // HRESULT (*GetAdapterIdentifier)(IDirect3D9Ex *This, UINT Adapter, DWORD Flags, D3DADAPTER_IDENTIFIER9 *pIdentifier); 14 | // UINT (*GetAdapterModeCount)(IDirect3D9Ex *This, UINT Adapter, D3DFORMAT Format); 15 | // HRESULT (*EnumAdapterModes)(IDirect3D9Ex *This, UINT Adapter, D3DFORMAT Format, UINT Mode, D3DDISPLAYMODE *pMode); 16 | // HRESULT (*GetAdapterDisplayMode)(IDirect3D9Ex *This, UINT Adapter, D3DDISPLAYMODE *pMode); 17 | // HRESULT (*CheckDeviceType)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DevType, D3DFORMAT AdapterFormat, D3DFORMAT BackBufferFormat, BOOL bWindowed); 18 | // HRESULT (*CheckDeviceFormat)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat); 19 | // HRESULT (*CheckDeviceMultiSampleType)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SurfaceFormat, BOOL Windowed, D3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels); 20 | // HRESULT (*CheckDepthStencilMatch)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, D3DFORMAT RenderTargetFormat, D3DFORMAT DepthStencilFormat); 21 | // HRESULT (*CheckDeviceFormatConversion)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat); 22 | // HRESULT (*GetDeviceCaps)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9 *pCaps); 23 | // HMONITOR (*GetAdapterMonitor)(IDirect3D9Ex *This, UINT Adapter); 24 | // HRESULT (*CreateDevice)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, IDirect3DDevice9 **ppReturnedDeviceInterface); 25 | // /* IDirect3D9Ex */ 26 | // UINT (*GetAdapterModeCountEx)(IDirect3D9Ex *This, UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter); 27 | // HRESULT (*EnumAdapterModesEx)(IDirect3D9Ex *This, UINT Adapter, const D3DDISPLAYMODEFILTER *pFilter, UINT Mode, D3DDISPLAYMODEEX *pMode); 28 | // HRESULT (*GetAdapterDisplayModeEx)(IDirect3D9Ex *This, UINT Adapter, D3DDISPLAYMODEEX *pMode, D3DDISPLAYROTATION *pRotation); 29 | // HRESULT (*CreateDeviceEx)(IDirect3D9Ex *This, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, D3DDISPLAYMODEEX *pFullscreenDisplayMode, IDirect3DDevice9Ex **ppReturnedDeviceInterface); 30 | // HRESULT (*GetAdapterLUID)(IDirect3D9Ex *This, UINT Adapter, LUID *pLUID); 31 | // } IDirect3D9ExVtbl; 32 | 33 | // /** 34 | // * Thanks to Gallium Nine for the implementation of this function. 35 | // */ 36 | // static IDirect3D9ExVtbl d3dadapter9_vtable = { 37 | // (void *)d3dadapter9_QueryInterface, 38 | // (void *)d3dadapter9_AddRef, 39 | // (void *)d3dadapter9_Release, 40 | // (void *)d3dadapter9_RegisterSoftwareDevice, 41 | // (void *)d3dadapter9_GetAdapterCount, 42 | // (void *)d3dadapter9_GetAdapterIdentifier, 43 | // (void *)d3dadapter9_GetAdapterModeCount, 44 | // (void *)d3dadapter9_EnumAdapterModes, 45 | // (void *)d3dadapter9_GetAdapterDisplayMode, 46 | // (void *)d3dadapter9_CheckDeviceType, 47 | // (void *)d3dadapter9_CheckDeviceFormat, 48 | // (void *)d3dadapter9_CheckDeviceMultiSampleType, 49 | // (void *)d3dadapter9_CheckDepthStencilMatch, 50 | // (void *)d3dadapter9_CheckDeviceFormatConversion, 51 | // (void *)d3dadapter9_GetDeviceCaps, 52 | // (void *)d3dadapter9_GetAdapterMonitor, 53 | // (void *)d3dadapter9_CreateDevice, 54 | // (void *)d3dadapter9_GetAdapterModeCountEx, 55 | // (void *)d3dadapter9_EnumAdapterModesEx, 56 | // (void *)d3dadapter9_GetAdapterDisplayModeEx, 57 | // (void *)d3dadapter9_CreateDeviceEx, 58 | // (void *)d3dadapter9_GetAdapterLUID 59 | // }; -------------------------------------------------------------------------------- /libs/d3d9/d3dobject.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "idirect3ddevice9.hpp" 3 | 4 | export class D3DObject { 5 | public: 6 | D3DObject(IDirect3DDevice9* device) : m_device(device) {} 7 | virtual ~D3DObject() {} 8 | 9 | virtual void render() = 0; 10 | 11 | protected: 12 | IDirect3DDevice9* m_device; 13 | }; -------------------------------------------------------------------------------- /libs/d3d9/d3dobject.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "idirect3ddevice9.hpp" 3 | 4 | class D3DObject { 5 | public:D3DObject(IDirect3DDevice9* device); 6 | protected:IDirect3DDevice9* m_device; 7 | }; -------------------------------------------------------------------------------- /libs/d3d9/i915/idirect3ddevice9.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../idirect3d9.hpp" 3 | #include "idirect3ddevice9.hpp" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | export IDirect3DDevice9 IDirect3D9_i915::createDevice( 13 | IDirect3D9* d3d9, UINT Adapter, D3DDEVTYPE DeviceType, 14 | HWND hFocusWindow, DWORD BehaviorFlags, 15 | D3DPRESENT_PARAMETERS *pPresentationParameters 16 | ) { 17 | //create IDirect3DDevice9 device; and assign functions to it 18 | IDirect3DDevice9 device = {}; 19 | device.QueryInterface = (long (*)(REFIID riid, void **ppvObject)) createQueryInterface(&device); 20 | //create a framebuffer to hFocusWindow 21 | uint32_t fbid; 22 | drmModeAddFB( 23 | Adapter, 24 | pPresentationParameters->BackBufferWidth, 25 | pPresentationParameters->BackBufferHeight, 26 | 24, 27 | 32, 28 | pPresentationParameters->BackBufferWidth * 4, 29 | pPresentationParameters->BackBufferFormat, 30 | &fbid 31 | ); 32 | drmModeFB* fb = drmModeGetFB(Adapter, fbid); 33 | 34 | //test-only: draw a square 35 | int width = pPresentationParameters->BackBufferWidth - 50; 36 | int height = pPresentationParameters->BackBufferHeight - 50; 37 | 38 | // Draw a red square around the screen 39 | uint32_t* framebuffer = static_cast(mmap(0, fb->pitch * fb->height, PROT_READ | PROT_WRITE, MAP_SHARED, Adapter, fb->handle)); 40 | for (int i = 0; i < width; i++) { 41 | for (int j = 0; j < height; j++) { 42 | if (i < 50 || i > width - 50 || j < 50 || j > height - 50) { 43 | framebuffer[i * fb->pitch / 4 + j] = 0x00FF0000; 44 | } 45 | } 46 | } 47 | munmap(framebuffer, fb->pitch * fb->height); 48 | 49 | // Update CRTC 50 | drmModeSetCrtc( 51 | Adapter, 52 | 0, // CRTC ID 53 | fbid, 54 | 0, // x 55 | 0, // y 56 | NULL, // connectors 57 | 0, // count 58 | 0 59 | ); 60 | 61 | //display the framebuffer in hFocusWindow as GtkWidget 62 | 63 | 64 | return device; 65 | } 66 | 67 | 68 | void* IDirect3D9_i915::createQueryInterface(IDirect3DDevice9* device) { 69 | std::shared_ptr> fun = std::make_shared>([device](REFIID riid, void ** ppvObj) -> HRESULT { 70 | if (!ppvObj) return E_POINTER; 71 | return E_NOINTERFACE; 72 | }); 73 | 74 | return (void*) fun->target(); 75 | } -------------------------------------------------------------------------------- /libs/d3d9/i915/idirect3ddevice9.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../idirect3d9.hpp" 3 | #include 4 | #include 5 | 6 | class IDirect3D9_i915 : public IUnknown { 7 | public:static IDirect3DDevice9 createDevice(IDirect3D9* d3d9, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters); 8 | public:static void* createQueryInterface(IDirect3DDevice9* device); 9 | }; -------------------------------------------------------------------------------- /libs/d3d9/idirect3d9.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "d3d9types.hpp" 4 | #include "idirect3d9.hpp" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "i915/idirect3ddevice9.hpp" 14 | 15 | export IDirect3D9::IDirect3D9(UINT SDKVersion) { 16 | #ifdef DEBUG 17 | std::cout << "libd3d9.so: IDirect3D9::IDirect3D9()" << std::endl; 18 | #endif 19 | 20 | //Create connection with DRM 21 | char* card = OpenDX_Config.preferred_card.value ?: OpenDX::getPreferredGraphics(); 22 | 23 | DLOG(" Using card: " << card); 24 | 25 | int fd = open(card, O_RDWR, 0); 26 | 27 | if (fd < 0) { 28 | std::cerr << "\033[1;31m" //RED BOLD 29 | << "ODX ERROR: Failed to open /dev/dri/card0. Please check if you have the proper permissions to access the device." << std::endl 30 | << "IDirect3D9 fails and returns NULL.\033[0;0m" << std::endl 31 | << std::endl; 32 | 33 | close(fd); 34 | return; 35 | } 36 | 37 | //check if the device is Hardware or Software (Does DirectX have this check?) 38 | drm_get_cap gpuType; 39 | int ioctlResult = ioctl(fd, DRM_IOCTL_GET_CAP, &gpuType); 40 | 41 | if (ioctlResult != 0) { 42 | std::cerr << "\033[1;31m" 43 | << "ODX ERROR: Failed to get device info" << std::endl 44 | << "IDirect3DC9 fails and returns NULL.\033[0;0m" << std::endl 45 | << std::endl; 46 | 47 | close(fd); 48 | perror("ioctl"); 49 | return; 50 | } 51 | 52 | 53 | #ifdef DEBUG 54 | //get device vendor id: 55 | drmVersion* version = drmGetVersion(fd); 56 | std::cout << "\033[1;32m" //GREEN BOLD 57 | << "ODX INFO: Device \"" << version->name << " (" << version->desc << ' ' << version->version_minor << '.' << version->version_patchlevel << ')' << "\" is " << (gpuType.value == DRM_CAP_DUMB_BUFFER ? "Software" : "Hardware") << std::endl 58 | << "\033[0;0m" << std::endl; 59 | #endif 60 | 61 | D3DDEVTYPE deviceType = D3DDEVTYPE::D3DDEVTYPE_NULLREF; 62 | 63 | if (gpuType.value == DRM_CAP_DUMB_BUFFER) { 64 | deviceType = D3DDEVTYPE::D3DDEVTYPE_SW; 65 | } else { 66 | deviceType = D3DDEVTYPE::D3DDEVTYPE_HAL; 67 | } 68 | 69 | IDirect3DDevice9* device; 70 | this->CreateDevice( 71 | fd, // D3DADAPTER_DEFAULT 72 | deviceType, 73 | NULL, // TODO 74 | NULL, // TODO 75 | NULL, // TODO 76 | &device 77 | ); 78 | 79 | close(fd); 80 | 81 | // this->base = new IDirect3D9_Base(FALSE); 82 | } 83 | 84 | export HRESULT IDirect3D9::CreateDevice( 85 | UINT Adapter, 86 | D3DDEVTYPE DeviceType, 87 | HWND hFocusWindow, 88 | DWORD BehaviorFlags, 89 | D3DPRESENT_PARAMETERS *pPresentationParameters, 90 | IDirect3DDevice9 **ppReturnedDeviceInterface 91 | ) { 92 | //is the device i915 (Intel)? 93 | drmVersion* version = drmGetVersion(Adapter); 94 | if (version == nullptr) { 95 | std::cerr << "\033[1;31m" //RED BOLD 96 | << "ODX ERROR: Failed to get device info" << std::endl 97 | << "IDirect3DC9::CreateDevice fails and returns NULL.\033[0;0m" << std::endl 98 | << std::endl; 99 | return E_FAIL; 100 | } 101 | 102 | if (strcmp(version->name, "i915") == 0) { 103 | //load the libd3d915_i915.so 104 | dlopen("libd3d915_i915.so", RTLD_NOW); 105 | *ppReturnedDeviceInterface = new IDirect3DDevice9(IDirect3D9_i915::createDevice( 106 | this, 107 | Adapter, 108 | DeviceType, 109 | hFocusWindow, 110 | BehaviorFlags, 111 | pPresentationParameters 112 | )); 113 | } 114 | } 115 | 116 | export HRESULT IDirect3D9::QueryInterface(REFIID riid, void ** ppvObj) { 117 | if (!ppvObj) return E_POINTER; 118 | 119 | return 0; 120 | } 121 | 122 | export ULONG IDirect3D9::AddRef() { 123 | DXGASSERT(((ULONG_PTR)(&m_cRef) & 3) == 0); 124 | 125 | InterlockedIncrement((LONG *)&m_cRef); 126 | return m_cRef; 127 | } 128 | 129 | export ULONG IDirect3D9::Release() { 130 | return 0; 131 | } -------------------------------------------------------------------------------- /libs/d3d9/idirect3d9.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "idirect3ddevice9.hpp" 4 | #include "d3d9types.hpp" 5 | 6 | struct IDirect3D9 : public IUnknown { 7 | IDirect3D9(UINT SDKVersion); 8 | 9 | HRESULT QueryInterface(REFIID riid, void** ppvObj); 10 | ULONG AddRef(); 11 | ULONG Release(); 12 | 13 | HRESULT CreateDevice( 14 | UINT Adapter, 15 | D3DDEVTYPE DeviceType, 16 | HWND hFocusWindow, 17 | DWORD BehaviorFlags, 18 | D3DPRESENT_PARAMETERS *pPresentationParameters, 19 | IDirect3DDevice9 **ppReturnedDeviceInterface 20 | ); 21 | 22 | private: 23 | DWORD m_cRef; 24 | // Define other methods required by IDirect3D9 interface 25 | }; 26 | 27 | //redeclare IDirect3D9 as IDirect3D9Ex 28 | struct IDirect3D9Ex : public IDirect3D9 { 29 | IDirect3D9Ex(UINT SDKVersion); 30 | }; -------------------------------------------------------------------------------- /libs/d3d9/idirect3ddevice9.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | /** 4 | * Defines device types 5 | */ 6 | typedef enum D3DDEVTYPE { 7 | D3DDEVTYPE_HAL = 1, 8 | D3DDEVTYPE_NULLREF = 4, 9 | D3DDEVTYPE_REF = 2, 10 | D3DDEVTYPE_SW = 3, 11 | D3DDEVTYPE_FORCE_DWORD = 0xffffffff 12 | } D3DDEVTYPE, *LPD3DDEVTYPE; 13 | 14 | 15 | struct IDirect3DDevice9:IUnknown { 16 | 17 | }; -------------------------------------------------------------------------------- /libs/dsetup/README.md: -------------------------------------------------------------------------------- 1 | # libdsetup.so 2 | Legacy code for DirectX Setup. This is a DLL that is loaded by the DirectX 9. -------------------------------------------------------------------------------- /libs/dsetup/dsetup.cpp: -------------------------------------------------------------------------------- 1 | #include "dsetup.hpp" -------------------------------------------------------------------------------- /libs/dsetup/dsetup.hpp: -------------------------------------------------------------------------------- 1 | #pragma onnce 2 | #include "fun/DirectXSetupGetVersion.hpp" -------------------------------------------------------------------------------- /libs/dsetup/fun/DirectXSetupGetVersion.cpp: -------------------------------------------------------------------------------- 1 | #include "DirectXSetupGetVersion.hpp" 2 | 3 | /** 4 | * @brief Get DirectX version 5 | * 6 | * @todo Implement this function 7 | * * @see https://github.com/EduApps-CDG/OpenDX/wiki/dsetup.dll-or-libdsetup.so#int-directxsetupgetversiondword-dword 8 | * 9 | * @param ver 10 | * @param rev 11 | * @return int 1 (always?) 12 | */ 13 | int DirectXSetupGetVersion(DWORD* ver, DWORD* rev) { 14 | *ver = 0; 15 | *rev = 0; 16 | return 1; 17 | } -------------------------------------------------------------------------------- /libs/dsetup/fun/DirectXSetupGetVersion.hpp: -------------------------------------------------------------------------------- 1 | #pragma onnce 2 | #include 3 | 4 | /** 5 | * @brief Get DirectX version 6 | * 7 | * @todo Implement this function 8 | * * @see https://github.com/EduApps-CDG/OpenDX/wiki/dsetup.dll-or-libdsetup.so#int-directxsetupgetversiondword-dword 9 | * 10 | * @param ver 11 | * @param rev 12 | * @return int 1 (always?) 13 | */ 14 | int DirectXSetupGetVersion(DWORD* ver, DWORD* rev); -------------------------------------------------------------------------------- /libs/opendx/README.md: -------------------------------------------------------------------------------- 1 | # libopendx.so 2 | Here goes everything that's not part of DirectX library. 3 | Some examples are: 4 | * DLL files that DirectX depends on will be turned into `libopendx.so` 5 | such as kernel32.dll. 6 | * Essential external functions and definitions needed to mantain software 7 | compatibility such as functions contained in ``. But the headers 8 | will be found in [`/prod_include`](../../prod_include). 9 | 10 | All of these examples will be built in a single library and that's what 11 | `libopendx.so` does. 12 | 13 | The main file is [`./opendx.cpp`](./opendx.cpp) 14 | -------------------------------------------------------------------------------- /libs/opendx/gtk/gdkd3dcontext.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Thanks to https://github.com/GNOME/gtk/blob/main/gdk/gdkvulkancontext.c 3 | * 4 | * @brief A D3D context for GDK 5 | */ 6 | #include "gdkd3dcontext.hpp" 7 | 8 | static void gdk_d3d_context_init(GdkD3DContext* self) { 9 | } 10 | 11 | static gboolean gdk_d3d_context_real_init( 12 | GInitable* initable, 13 | GCancellable* cancellable, 14 | GError** error 15 | ) { 16 | GdkD3DContext* context = GDK_D3D_CONTEXT(initable); 17 | // GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context); 18 | GdkDisplay* display = gdk_draw_context_get_display(GDK_DRAW_CONTEXT(context)); 19 | GdkSurface* surface = gdk_draw_context_get_surface(GDK_DRAW_CONTEXT(context)); 20 | return TRUE; 21 | } 22 | 23 | static void gdk_d3d_context_initable_init(GInitableIface* iface) { 24 | iface->init = gdk_d3d_context_real_init; 25 | } -------------------------------------------------------------------------------- /libs/opendx/gtk/gdkd3dcontext.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | G_BEGIN_DECLS 5 | #define GDK_TYPE_D3D_CONTEXT (gdk_d3d_context_get_type()) 6 | #define GDK_D3D_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GDK_TYPE_D3D_CONTEXT, GdkD3DContext)) 7 | #define GDK_IS_D3D_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GDK_TYPE_D3D_CONTEXT)) 8 | 9 | struct GdkD3DContext { 10 | GdkDrawContext* parent; 11 | }; 12 | 13 | GDK_AVAILABLE_IN_ALL GType gdk_d3d_context_get_type(void) G_GNUC_CONST; 14 | 15 | G_DEFINE_AUTOPTR_CLEANUP_FUNC(GdkD3DContext, g_object_unref) 16 | 17 | G_END_DECLS -------------------------------------------------------------------------------- /libs/opendx/opendx.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "opendx.hpp" 3 | #include "opendx_config.hpp" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | using namespace std; 16 | 17 | /** 18 | * @brief Create a Window 19 | * 20 | * @return HWND 21 | */ 22 | export HWND CreateWindowExA( 23 | DWORD extStyle, 24 | LPCSTR className, //optional 25 | LPCSTR title, //optional 26 | DWORD style, 27 | int x, //ignored. It's the user responsability to set the window position. (GTK4) 28 | int y, //ignored. It's the user responsability to set the window position. (GTK4) 29 | int width, 30 | int height, 31 | HWND parent, //optional 32 | HMENU menu, //optional 33 | HINSTANCE instance, //optional (Windows ignores it) 34 | LPVOID param //optional 35 | ) { 36 | #ifdef DEBUG 37 | std::cout << "libopendx.so: CreateWindowExA()" << std::endl; 38 | #endif 39 | 40 | GtkWidget* window = gtk_window_new(); 41 | 42 | if (title != nullptr) { 43 | gtk_window_set_title(GTK_WINDOW(window), title); 44 | } 45 | 46 | gtk_window_set_default_size(GTK_WINDOW(window), width, height); 47 | 48 | //style: 49 | // TODO: Complete the list 50 | if (!(style & WS_CAPTION)) { 51 | gtk_window_set_title(GTK_WINDOW(window), ""); 52 | } 53 | if (!(style & WS_SYSMENU)) { 54 | gtk_window_set_deletable(GTK_WINDOW(window), false); 55 | } 56 | if (style & WS_VISIBLE) { 57 | gtk_widget_show(GTK_WIDGET(window)); 58 | } 59 | 60 | // TODO: find a no-signal way 61 | // g_signal_connect(window, "destroy", G_CALLBACK(on_window_destroy), NULL); 62 | 63 | return window; 64 | } 65 | 66 | /** 67 | * @brief Aka ZeroMemory (Thanks Wine project) 68 | * 69 | * @param dest 70 | * @param size 71 | */ 72 | export VOID WINAPI RtlZeroMemory(LPVOID dest, SIZE_T size) { 73 | memset(dest, 0, size); 74 | } 75 | 76 | export BOOL ShowWindow(HWND window, int nCmdShow) { 77 | BOOL r = gtk_widget_get_visible(GTK_WIDGET(window)); 78 | gtk_widget_show(GTK_WIDGET(window)); 79 | return r; 80 | } 81 | 82 | export BOOL DestroyWindow(HWND window) { 83 | gtk_window_destroy(GTK_WINDOW(window)); 84 | return true; 85 | } 86 | 87 | export BOOL GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax) { 88 | BOOL r = g_main_context_pending(NULL); 89 | 90 | 91 | //i know this is wrong, but i need to get the sample working 92 | if (r) { 93 | g_main_context_iteration(NULL, true); 94 | } else { 95 | lpMsg->message = WM_QUIT; 96 | } 97 | 98 | return r; 99 | } 100 | 101 | export BOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg) { 102 | BOOL r = g_list_model_get_n_items(gtk_window_get_toplevels ()) > 0; 103 | 104 | if (r) { 105 | g_main_context_iteration(NULL, true); 106 | } else { 107 | lpMsg->message = WM_QUIT; 108 | } 109 | 110 | return r; 111 | } 112 | 113 | /* 114 | * OpenDX utility class 115 | */ 116 | export OpenDX::OpenDX(int argc, char* argv[], int (*WinMain)(HINSTANCE, HINSTANCE, LPSTR, int)) { 117 | this->loadConfig(); 118 | 119 | //Converts argc and argv to WinMain params 120 | char* cmdline = (char*) malloc(sizeof(char)); 121 | cmdline[0] = '\0'; 122 | 123 | for (int i = 0; i < argc; i++) { 124 | cmdline = (char*) realloc(cmdline, strlen(cmdline) + strlen(argv[i]) + 2); 125 | strcat(cmdline, argv[i]); 126 | if (i < argc - 1) { 127 | strcat(cmdline, " "); 128 | } 129 | } 130 | 131 | gtk_init(); 132 | if (WinMain != nullptr) { 133 | winMain_r = (*WinMain)(nullptr,nullptr,cmdline,0); 134 | } 135 | } 136 | 137 | export OpenDX::OpenDX(int (*WinMain)(HINSTANCE, HINSTANCE, LPSTR, int)) { 138 | this->loadConfig(); 139 | 140 | gtk_init(); 141 | 142 | if (WinMain != nullptr) { 143 | winMain_r = (*WinMain)(nullptr,nullptr,"",0); 144 | } 145 | } 146 | 147 | export int OpenDX::getReturnCode() { 148 | return winMain_r; 149 | } 150 | 151 | /** 152 | * search for the preferred graphics and return the it's name 153 | */ 154 | export char* OpenDX::getPreferredGraphics() { 155 | DLOG("libopendx.so: OpenDX::getPreferredGraphics()"); 156 | 157 | drmDevicePtr devices; 158 | int numDevices = drmGetDevices(&devices, 32); 159 | DLOG(" Found " << numDevices << " devices"); 160 | 161 | char* preferred = nullptr; 162 | 163 | for (int i = 0; i < numDevices; i++) { 164 | char* node = devices[i].nodes[0]; 165 | DLOG(" Checking device " << node); 166 | 167 | int fd = open(node, O_RDWR); 168 | drmModeRes* res = drmModeGetResources(fd); 169 | 170 | if (res == nullptr) { 171 | DLOG(" Failed to get resources from " << node << ". Not a DRM device."); 172 | continue; 173 | } else { 174 | preferred = node; 175 | break; 176 | } 177 | } 178 | 179 | return preferred; 180 | } 181 | 182 | /** 183 | * Load the configuration file from user's .config/opendx/opendx.conf 184 | */ 185 | export void OpenDX::loadConfig() { 186 | DLOG("libopendx.so: loadConfig()"); 187 | OpenDX_Config = {}; 188 | OpenDX_Config.preferred_card = { 189 | name: "preferred_card", 190 | value: OpenDX::getPreferredGraphics() 191 | }; 192 | OpenDX_Config.experimental_force_master = { 193 | name: "experimental_force_master", 194 | value: "false" 195 | }; 196 | 197 | //read ~/.config/opendx/opendx.conf 198 | char* home = getenv("HOME") ?: (char*) "~"; 199 | char* config = "/.config/opendx/opendx.conf"; 200 | std::string path = std::string(home) + std::string(config); 201 | 202 | ifstream file = ifstream(path); 203 | if (!file.is_open()) { 204 | DLOG(" Failed to open " << path << ". Using default values."); 205 | return; 206 | } 207 | 208 | std::string line; 209 | while (std::getline(file, line)) { 210 | //ini standard (with comments) 211 | if (line[0] == ';' || line[0] == '#' || line[0] == '\n') { 212 | continue; 213 | } 214 | 215 | //parse the line 216 | size_t pos = line.find("="); 217 | if (pos == std::string::npos) { //Warning (do not continue) 218 | std::cout << "\033[1;33m" //YELLOW BOLD 219 | << "ODX WARNING: Invalid configuration line in " << path << ":" << 220 | line << ". Ignoring subsequent lines.\033[0;0m" << std::endl; 221 | break; 222 | } 223 | 224 | std::string key = line.substr(0, pos); 225 | std::string value = line.substr(pos + 1); 226 | 227 | //is value "default" or a comment or empty? 228 | if (value == "default" || value == "" || value[0] == ';' || value[0] == '#') { 229 | continue; 230 | } 231 | 232 | //load the configuration 233 | char* val = (char*) value.c_str(); 234 | if (key == "preferred_card") { 235 | val = loadConfig_preferred_card(val); 236 | OpenDX_Config.preferred_card = { 237 | name:key.c_str(), 238 | value:val 239 | }; 240 | } 241 | 242 | DLOG(" Config: " << key << " = " << val); 243 | } 244 | 245 | file.close(); 246 | } 247 | 248 | char* loadConfig_preferred_card(char* value) { 249 | DLOG("libopendx.so: loadConfig_preferred_card()"); 250 | 251 | int fd = open(value, O_RDWR, 0); 252 | if (fd < 0) { 253 | DLOG(" Failed to open " << value << "."); 254 | return OpenDX::getPreferredGraphics(); 255 | } 256 | 257 | drmModeRes* res = drmModeGetResources(fd); 258 | if (res == nullptr) { 259 | DLOG(" Failed to get resources from " << value << ". Not a DRM device."); 260 | return OpenDX::getPreferredGraphics(); 261 | } 262 | 263 | return value; 264 | } 265 | 266 | char* loadConfig_experimental_force_master(char* value) { 267 | DLOG("libopendx.so: loadConfig_experimental_force_master()"); 268 | 269 | if (strcmp(value, "true") == 0 || strcmp(value, "1") == 0) { 270 | //check if we are in a tty 271 | if (isatty(fileno(stdout))) { 272 | DLOG(" Experimental: enforcing master framebuffer"); 273 | return "true"; 274 | } else { 275 | std::cout << "\033[1;33m" //YELLOW BOLD 276 | << "ODX WARNING: Experimental feature 'experimental_force_master' enabled. Please try to run this program under a tty.\033[0;0m" << std::endl; 277 | throw std::runtime_error("Experimental feature 'experimental_force_master' enabled without a tty."); 278 | } 279 | } 280 | 281 | return "false"; 282 | } -------------------------------------------------------------------------------- /libs/opendx/opendx.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "opendx_config.hpp" 6 | 7 | class OpenDX { 8 | public: 9 | OpenDX(int argc, char* argv[],int (*WinMain)(HINSTANCE, HINSTANCE, LPSTR, int) = nullptr); 10 | OpenDX(int (*WinMain)(HINSTANCE, HINSTANCE, LPSTR, int) = nullptr); 11 | int getReturnCode(); 12 | static char* getPreferredGraphics(); 13 | 14 | private: 15 | int winMain_r = 0; 16 | void loadConfig(); 17 | }; 18 | 19 | char* loadConfig_preferred_card(char* value); -------------------------------------------------------------------------------- /libs/opendx/opendx_config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define CONFIG_OPTION(name, val) \ 4 | name: new OpenDX_ConfigOption{#name, val} 5 | 6 | struct OpenDX_ConfigOption { 7 | const char* name; 8 | char* value; 9 | }; 10 | 11 | /// @brief OpenDX configuration options from the opendx.conf file 12 | struct OpenDX_Config { 13 | /// @brief the preferred graphics card set by configuration 14 | OpenDX_ConfigOption preferred_card; 15 | /// @brief Experimental: ensure that our fb is the "master" framebuffer (the fb that owns the display) 16 | OpenDX_ConfigOption experimental_force_master; 17 | } OpenDX_Config; -------------------------------------------------------------------------------- /pack.sh: -------------------------------------------------------------------------------- 1 | tar -cvf opendx.tar -C build opendx 2 | cd build 3 | cpack 4 | cd .. 5 | mv build/opendx*.deb ./opendx.deb 6 | -------------------------------------------------------------------------------- /prod_include/README.md: -------------------------------------------------------------------------------- 1 | # prod_include 2 | This folder contains headers that you can use as reference to 3 | port your software for Linux. 4 | -------------------------------------------------------------------------------- /prod_include/basetsd.h: -------------------------------------------------------------------------------- 1 | #define SIZE_T unsigned long -------------------------------------------------------------------------------- /prod_include/d3d9.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Production "d3d9.h" file. 3 | * 4 | * TODO: Auto-generate this file from internal headers. 5 | */ 6 | #ifndef _D3D9_H 7 | #define _D3D9_H 8 | #include 9 | #include 10 | #include 11 | 12 | UINT D3D_SDK_VERSION = 0x0900; 13 | #define D3DCREATE_PUREDEVICE 0x00000010L 14 | #define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L 15 | #define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L 16 | #define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L 17 | 18 | 19 | #define D3DADAPTER_DEFAULT 0 20 | 21 | //not sure if this goes here. 22 | /*#define API_ENTER_NO_LOCK() \ 23 | do { \ 24 | InterlockedIncrement(&g_nInsideAPI); \ 25 | } while (false)*/ 26 | 27 | #ifdef _DEBUG 28 | #define DXGASSERT(exp) do { \ 29 | if (!(exp)) { \ 30 | fprintf(stderr, "Assertion failed: %s, file %s, line %d\n", #exp, __FILE__, __LINE__); \ 31 | abort(); \ 32 | } \ 33 | } while (0) 34 | #else 35 | #define DXGASSERT(exp) ((void)0) 36 | #endif 37 | 38 | #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ 39 | ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \ 40 | ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 )) 41 | 42 | 43 | typedef enum { 44 | REF_EXTERNAL = 0, 45 | REF_INTRINSIC = 1, 46 | REF_INTERNAL = 2 47 | 48 | } REF_TYPE; 49 | /** 50 | * Defines the various types of surface formats. 51 | */ 52 | typedef enum _D3DFORMAT { 53 | D3DFMT_UNKNOWN = 0, 54 | 55 | D3DFMT_R8G8B8 = 20, 56 | D3DFMT_A8R8G8B8 = 21, 57 | D3DFMT_X8R8G8B8 = 22, 58 | D3DFMT_R5G6B5 = 23, 59 | D3DFMT_X1R5G5B5 = 24, 60 | D3DFMT_A1R5G5B5 = 25, 61 | D3DFMT_A4R4G4B4 = 26, 62 | D3DFMT_R3G3B2 = 27, 63 | D3DFMT_A8 = 28, 64 | D3DFMT_A8R3G3B2 = 29, 65 | D3DFMT_X4R4G4B4 = 30, 66 | D3DFMT_A2B10G10R10 = 31, 67 | D3DFMT_A8B8G8R8 = 32, 68 | D3DFMT_X8B8G8R8 = 33, 69 | D3DFMT_G16R16 = 34, 70 | D3DFMT_A2R10G10B10 = 35, 71 | D3DFMT_A16B16G16R16 = 36, 72 | 73 | D3DFMT_A8P8 = 40, 74 | D3DFMT_P8 = 41, 75 | 76 | D3DFMT_L8 = 50, 77 | D3DFMT_A8L8 = 51, 78 | D3DFMT_A4L4 = 52, 79 | 80 | D3DFMT_V8U8 = 60, 81 | D3DFMT_L6V5U5 = 61, 82 | D3DFMT_X8L8V8U8 = 62, 83 | D3DFMT_Q8W8V8U8 = 63, 84 | D3DFMT_V16U16 = 64, 85 | D3DFMT_A2W10V10U10 = 67, 86 | 87 | D3DFMT_UYVY = MAKEFOURCC('U', 'Y', 'V', 'Y'), 88 | D3DFMT_R8G8_B8G8 = MAKEFOURCC('R', 'G', 'B', 'G'), 89 | D3DFMT_YUY2 = MAKEFOURCC('Y', 'U', 'Y', '2'), 90 | D3DFMT_G8R8_G8B8 = MAKEFOURCC('G', 'R', 'G', 'B'), 91 | D3DFMT_DXT1 = MAKEFOURCC('D', 'X', 'T', '1'), 92 | D3DFMT_DXT2 = MAKEFOURCC('D', 'X', 'T', '2'), 93 | D3DFMT_DXT3 = MAKEFOURCC('D', 'X', 'T', '3'), 94 | D3DFMT_DXT4 = MAKEFOURCC('D', 'X', 'T', '4'), 95 | D3DFMT_DXT5 = MAKEFOURCC('D', 'X', 'T', '5'), 96 | 97 | D3DFMT_D16_LOCKABLE = 70, 98 | D3DFMT_D32 = 71, 99 | D3DFMT_D15S1 = 73, 100 | D3DFMT_D24S8 = 75, 101 | D3DFMT_D24X8 = 77, 102 | D3DFMT_D24X4S4 = 79, 103 | D3DFMT_D16 = 80, 104 | 105 | D3DFMT_D32F_LOCKABLE = 82, 106 | D3DFMT_D24FS8 = 83, 107 | 108 | #if !defined(D3D_DISABLE_9EX) 109 | D3DFMT_D32_LOCKABLE = 84, 110 | D3DFMT_S8_LOCKABLE = 85, 111 | #endif // !D3D_DISABLE_9EX 112 | 113 | D3DFMT_L16 = 81, 114 | 115 | D3DFMT_VERTEXDATA =100, 116 | D3DFMT_INDEX16 =101, 117 | D3DFMT_INDEX32 =102, 118 | 119 | D3DFMT_Q16W16V16U16 =110, 120 | 121 | D3DFMT_MULTI2_ARGB8 = MAKEFOURCC('M','E','T','1'), 122 | 123 | D3DFMT_R16F = 111, 124 | D3DFMT_G16R16F = 112, 125 | D3DFMT_A16B16G16R16F = 113, 126 | 127 | D3DFMT_R32F = 114, 128 | D3DFMT_G32R32F = 115, 129 | D3DFMT_A32B32G32R32F = 116, 130 | 131 | D3DFMT_CxV8U8 = 117, 132 | 133 | #if !defined(D3D_DISABLE_9EX) 134 | D3DFMT_A1 = 118, 135 | D3DFMT_A2B10G10R10_XR_BIAS = 119, 136 | D3DFMT_BINARYBUFFER = 199, 137 | #endif // !D3D_DISABLE_9EX 138 | 139 | D3DFMT_FORCE_DWORD =0x7fffffff 140 | } D3DFORMAT; 141 | 142 | /** 143 | * Defines the levels of full-scene multisampling that the device can apply. 144 | */ 145 | typedef enum D3DMULTISAMPLE_TYPE { 146 | D3DMULTISAMPLE_NONE = 0, 147 | D3DMULTISAMPLE_NONMASKABLE = 1, 148 | D3DMULTISAMPLE_2_SAMPLES = 2, 149 | D3DMULTISAMPLE_3_SAMPLES = 3, 150 | D3DMULTISAMPLE_4_SAMPLES = 4, 151 | D3DMULTISAMPLE_5_SAMPLES = 5, 152 | D3DMULTISAMPLE_6_SAMPLES = 6, 153 | D3DMULTISAMPLE_7_SAMPLES = 7, 154 | D3DMULTISAMPLE_8_SAMPLES = 8, 155 | D3DMULTISAMPLE_9_SAMPLES = 9, 156 | D3DMULTISAMPLE_10_SAMPLES = 10, 157 | D3DMULTISAMPLE_11_SAMPLES = 11, 158 | D3DMULTISAMPLE_12_SAMPLES = 12, 159 | D3DMULTISAMPLE_13_SAMPLES = 13, 160 | D3DMULTISAMPLE_14_SAMPLES = 14, 161 | D3DMULTISAMPLE_15_SAMPLES = 15, 162 | D3DMULTISAMPLE_16_SAMPLES = 16, 163 | D3DMULTISAMPLE_FORCE_DWORD = 0xffffffff 164 | } D3DMULTISAMPLE_TYPE, *LPD3DMULTISAMPLE_TYPE; 165 | 166 | /** 167 | * Defines swap effects 168 | */ 169 | typedef enum D3DSWAPEFFECT { 170 | D3DSWAPEFFECT_DISCARD = 1, 171 | D3DSWAPEFFECT_FLIP = 2, 172 | D3DSWAPEFFECT_COPY = 3, 173 | D3DSWAPEFFECT_OVERLAY = 4, 174 | D3DSWAPEFFECT_FLIPEX = 5, 175 | D3DSWAPEFFECT_FORCE_DWORD = 0xFFFFFFFF 176 | } D3DSWAPEFFECT, *LPD3DSWAPEFFECT; 177 | 178 | /** 179 | * Describes the presentation parameters. 180 | */ 181 | struct D3DPRESENT_PARAMETERS { 182 | UINT BackBufferWidth; 183 | UINT BackBufferHeight; 184 | D3DFORMAT BackBufferFormat; 185 | UINT BackBufferCount; 186 | D3DMULTISAMPLE_TYPE MultiSampleType; 187 | DWORD MultiSampleQuality; 188 | D3DSWAPEFFECT SwapEffect; 189 | HWND hDeviceWindow; 190 | BOOL Windowed; 191 | BOOL EnableAutoDepthStencil; 192 | D3DFORMAT AutoDepthStencilFormat; 193 | DWORD Flags; 194 | UINT FullScreen_RefreshRateInHz; 195 | UINT PresentationInterval; 196 | }; 197 | typedef struct D3DPRESENT_PARAMETERS D3DPRESENT_PARAMETERS, *LPD3DPRESENT_PARAMETERS; 198 | 199 | struct IDirect3DDevice9 { 200 | IDirect3DDevice9(); 201 | 202 | virtual HRESULT QueryInterface(REFIID riid, void** ppvObj); 203 | virtual ULONG AddRef(); 204 | virtual ULONG Release(); 205 | 206 | HRESULT Clear(DWORD Count, const void/*D3DRECT*/ *pRects, DWORD Flags, int/*D3DCOLOR*/ Color, float Z, DWORD Stencil); 207 | 208 | // Define other methods required by IDirect3D9 interface 209 | 210 | private:ULONG refCount; 211 | }; 212 | typedef struct IDirect3DDevice9 *LPDIRECT3DDEVICE9, *PDIRECT3DDEVICE9; 213 | 214 | /** 215 | * Defines device types 216 | */ 217 | typedef enum D3DDEVTYPE { 218 | D3DDEVTYPE_HAL = 1, 219 | D3DDEVTYPE_NULLREF = 4, 220 | D3DDEVTYPE_REF = 2, 221 | D3DDEVTYPE_SW = 3, 222 | D3DDEVTYPE_FORCE_DWORD = 0xffffffff 223 | } D3DDEVTYPE, *LPD3DDEVTYPE; 224 | 225 | struct IDirect3D9 : public IUnknown { 226 | IDirect3D9(UINT SDKVersion); 227 | 228 | HRESULT QueryInterface(REFIID riid, void** ppvObj); 229 | ULONG AddRef(); 230 | ULONG Release(); 231 | 232 | HRESULT CreateDevice( 233 | UINT Adapter, 234 | D3DDEVTYPE DeviceType, 235 | HWND hFocusWindow, 236 | DWORD BehaviorFlags, 237 | D3DPRESENT_PARAMETERS *pPresentationParameters, 238 | IDirect3DDevice9 **ppReturnedDeviceInterface 239 | ); 240 | 241 | private: 242 | DWORD m_cRef; 243 | 244 | // Define other methods required by IDirect3D9 interface 245 | }; 246 | typedef struct IDirect3D9 *LPDIRECT3D9, *PDIRECT3D9; 247 | IDirect3D9* Direct3DCreate9(UINT SDKVersion); 248 | 249 | #endif -------------------------------------------------------------------------------- /prod_include/objbase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #define STDMETHODCALLTYPE syscall(SYS_gettid); 6 | struct IID { 7 | unsigned long Data1; 8 | unsigned short Data2; 9 | unsigned short Data3; 10 | unsigned char Data4[8]; 11 | }; 12 | typedef const IID* REFIID; 13 | -------------------------------------------------------------------------------- /prod_include/opendx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | 5 | struct OpenDX_ConfigOption { 6 | const char* name; 7 | char* value; 8 | }; 9 | 10 | /// @brief OpenDX configuration options from the opendx.conf file 11 | struct OpenDX_Config { 12 | /// @brief the preferred graphics card set by configuration 13 | OpenDX_ConfigOption preferred_card; 14 | /// @brief Experimental: ensure that our fb is the "master" framebuffer (the fb that owns the display) 15 | OpenDX_ConfigOption experimental_force_master; 16 | } OpenDX_Config; 17 | 18 | /** 19 | * @brief OpenDX utility class 20 | */ 21 | class OpenDX { 22 | public: 23 | OpenDX(int argc, char* argv[],int (*WinMain)(HINSTANCE, HINSTANCE, LPSTR, int) = nullptr); 24 | OpenDX(int (*WinMain)(HINSTANCE, HINSTANCE, LPSTR, int) = nullptr); 25 | int getReturnCode(); 26 | static char* getPreferredGraphics(); 27 | private: 28 | int winMain_r = 0; 29 | void loadConfig(); 30 | }; -------------------------------------------------------------------------------- /prod_include/unknwn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | struct IUnknown { 8 | HRESULT (*QueryInterface) (REFIID riid, void **ppvObject); 9 | ULONG (*AddRef) (); 10 | ULONG (*Release) (); 11 | }; 12 | -------------------------------------------------------------------------------- /prod_include/winbase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | inline LONG InterlockedIncrement(LONG volatile *p) 5 | { 6 | return __sync_add_and_fetch(p, 1); 7 | } 8 | 9 | #define ZeroMemory RtlZeroMemory 10 | VOID WINAPI RtlZeroMemory(LPVOID dest, SIZE_T size); -------------------------------------------------------------------------------- /prod_include/windef.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | /* 5 | * ref: https://learn.microsoft.com/en-us/windows/win32/api/windef/ns-windef-point 6 | */ 7 | typedef struct tagPOINT { 8 | LONG x; 9 | LONG y; 10 | } POINT, *PPOINT, *NPPOINT, *LPPOINT; -------------------------------------------------------------------------------- /prod_include/windows.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file only provides types for 3 | * Compatibility propourses regarding 4 | * OpenDX. It's not intended to rewrite 5 | * the entire Windows API and you should 6 | * not use MSVC if you want compatibility 7 | * with other platforms. 8 | * 9 | * Part of: libopendx.so 10 | */ 11 | 12 | #pragma once 13 | //does it really goes here? 14 | #include 15 | #include 16 | 17 | #if defined(__GNUC__) 18 | #define __stdcall __attribute__((stdcall)) 19 | #endif 20 | #define WINAPI __stdcall 21 | #define __int64 long long 22 | 23 | //windows types: 24 | #define WCHAR wchar_t 25 | #define TCHAR char 26 | #define UINT unsigned int 27 | #define ULONG unsigned long 28 | #define ULONG_PTR unsigned long 29 | #define LONG long 30 | #define BOOL bool 31 | #define BYTE unsigned char 32 | #define LPSTR char* 33 | #define LPCSTR const char* 34 | #define LPCTSTR const char* 35 | #define LPCWSTR const char* 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #define DWORD unsigned long 43 | #define HWND GtkWidget* 44 | #define HMENU void* 45 | #define HINSTANCE void* 46 | #define LPVOID void* 47 | 48 | #define LONG_PTR __int64 49 | #define LPARAM LONG_PTR 50 | #define WPARAM unsigned __int64 51 | 52 | #include 53 | #include -------------------------------------------------------------------------------- /prod_include/winerror.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #define HRESULT LONG 5 | 6 | //https://learn.microsoft.com/en-us/windows/win32/seccrypto/common-hresult-values 7 | #define S_OK 0 8 | #define E_NOTIMPL 0x80004001 9 | #define E_NOINTERFACE 0x80004002 10 | #define E_POINTER 0x80004003 11 | #define E_ABORT 0x80004004 12 | #define E_FAIL 0x80004005 13 | #define E_UNEXPECTED 0x8000FFFF 14 | #define E_ACCESSDENIED 0x80070005 15 | #define E_HANDLE 0x80070006 16 | #define E_OUTOFMEMORY 0x8007000E 17 | #define E_INVALIDARG 0x80070057 -------------------------------------------------------------------------------- /prod_include/winnt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define VOID void 4 | #define LPVOID void* 5 | -------------------------------------------------------------------------------- /prod_include/winuser.h: -------------------------------------------------------------------------------- 1 | /** 2 | * From "libopendx.so" 3 | */ 4 | #pragma once 5 | #include 6 | 7 | /* 8 | * MSG 9 | * ref: https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-msg 10 | */ 11 | typedef struct tagMSG { 12 | HWND hwnd; 13 | UINT message; 14 | WPARAM wParam; 15 | LPARAM lParam; 16 | DWORD time; 17 | POINT pt; 18 | DWORD lPrivate; 19 | } MSG, *PMSG, *NPMSG, *LPMSG; 20 | 21 | #define WM_QUIT 0x0012 22 | 23 | /** 24 | * Extended Window Styles 25 | * ref: https://learn.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles 26 | */ 27 | #define WS_EX_ACCEPTFILES 0x00000010L 28 | #define WS_EX_APPWINDOW 0x00040000L 29 | #define WS_EX_CLIENTEDGE 0x00000200L 30 | #define WS_EX_COMPOSITED 0x02000000L 31 | #define WS_EX_CONTEXTHELP 0x00000400L 32 | #define WS_EX_CONTROLPARENT 0x00010000L 33 | #define WS_EX_DLGMODALFRAME 0x00000001L 34 | #define WS_EX_LAYERED 0x00080000 35 | #define WS_EX_LAYOUTRTL 0x00400000L 36 | #define WS_EX_LEFT 0x00000000L 37 | #define WS_EX_LEFTSCROLLBAR 0x00004000L 38 | #define WS_EX_LTRREADING 0x00000000L 39 | #define WS_EX_MDICHILD 0x00000040L 40 | #define WS_EX_NOACTIVATE 0x08000000L 41 | #define WS_EX_NOINHERITLAYOUT 0x00100000L 42 | #define WS_EX_NOPARENTNOTIFY 0x00000004L 43 | #define WS_EX_NOREDIRECTIONBITMAP 0x00200000L 44 | #define WS_EX_RIGHT 0x00001000L 45 | #define WS_EX_RIGHTSCROLLBAR 0x00000000L 46 | #define WS_EX_RTLREADING 0x00002000L 47 | #define WS_EX_STATICEDGE 0x00020000L 48 | #define WS_EX_TOOLWINDOW 0x00000080L 49 | #define WS_EX_TOPMOST 0x00000008L 50 | #define WS_EX_TRANSPARENT 0x00000020L 51 | #define WS_EX_WINDOWEDGE 0x00000100L 52 | #define WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE) 53 | #define WS_EX_PALETTEWINDOW (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST) 54 | 55 | /* 56 | * Window Styles 57 | * ref: https://learn.microsoft.com/en-us/windows/win32/winmsg/window-styles 58 | */ 59 | #define WS_BORDER 0x00800000L 60 | #define WS_CAPTION 0x00C00000L 61 | #define WS_CHILD 0x40000000L 62 | #define WS_CHILDWINDOW 0x40000000L 63 | #define WS_CLIPCHILDREN 0x02000000L 64 | #define WS_CLIPSIBLINGS 0x04000000L 65 | #define WS_DISABLED 0x08000000L 66 | #define WS_DLGFRAME 0x00400000L 67 | #define WS_GROUP 0x00020000L 68 | #define WS_HSCROLL 0x00100000L 69 | #define WS_ICONIC 0x20000000L 70 | #define WS_MAXIMIZE 0x01000000L 71 | #define WS_MAXIMIZEBOX 0x00010000L 72 | #define WS_MINIMIZE 0x20000000L 73 | #define WS_MINIMIZEBOX 0x00020000L 74 | #define WS_OVERLAPPED 0x00000000L 75 | #define WS_POPUP 0x80000000L 76 | #define WS_SIZEBOX 0x00040000L 77 | #define WS_SYSMENU 0x00080000L 78 | #define WS_TABSTOP 0x00010000L 79 | #define WS_THICKFRAME 0x00040000L 80 | #define WS_TILED 0x00000000L 81 | #define WS_VISIBLE 0x10000000L 82 | #define WS_VSCROLL 0x00200000L 83 | #define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX) 84 | #define WS_POPUPWINDOW (WS_POPUP | WS_BORDER | WS_SYSMENU) 85 | #define WS_TILEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX) 86 | 87 | HWND CreateWindowExA( 88 | DWORD extStyle, 89 | LPCSTR className, //optional 90 | LPCSTR title, //optional 91 | DWORD style, 92 | int x, //ignored. It's the user responsability to set the window position. (GTK4) 93 | int y, //ignored. It's the user responsability to set the window position. (GTK4) 94 | int width, 95 | int height, 96 | HWND parent, //optional 97 | HMENU menu, //optional 98 | HINSTANCE instance, //optional (Windows ignores it) 99 | LPVOID param //optional 100 | ); 101 | 102 | BOOL ShowWindow(HWND window, int nCmdShow); 103 | BOOL DestroyWindow(HWND window); 104 | 105 | BOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg); 106 | #define CreateWindowExW CreateWindowExA 107 | #define PeekMessageW PeekMessageA 108 | #define PM_NOREMOVE 0x0000 109 | #define PM_REMOVE 0x0001 110 | #define PM_NOYIELD 0x0002 111 | 112 | // https://www.codeproject.com/Answers/136442/Differences-Between-CreateWindow-and-CreateWindowE#answer3 113 | #define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ 114 | CreateWindowExA(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) 115 | #define CreateWindowW(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ 116 | CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) 117 | 118 | //TODO: check if it's needed in a linux environment 119 | #if UNICODE 120 | #define CreateWindow CreateWindowW 121 | #define PeekMessage PeekMessageW 122 | #else 123 | #define CreateWindow CreateWindowA 124 | #define PeekMessage PeekMessageA 125 | #endif -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | # Run dxdiag from build directory 2 | cd build/opendx 3 | ./bin/sample -------------------------------------------------------------------------------- /setpath.sh: -------------------------------------------------------------------------------- 1 | #set lib and bin path 2 | export PATH=$PATH:./build/opendx/bin 3 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./build/opendx/lib -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This target is "sample" and it is an executable. 2 | # The executable is built from the source file "basic_window.cpp". 3 | pkg_check_modules(GTK4 REQUIRED gtk4) 4 | 5 | include_directories(${GTK4_INCLUDE_DIRS}) 6 | link_directories(${GTK4_LIBRARY_DIRS}) 7 | 8 | add_executable(sample tests/basic_window.cpp) 9 | 10 | #link libraries from build path (build/opendx/libs) 11 | target_link_libraries(sample opendx) 12 | target_link_libraries(sample d3d9) 13 | -------------------------------------------------------------------------------- /tests/basic_window.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Windows API codes were commented to focus 3 | * on what's important: OpenDX. 4 | * 5 | * Code that doesn't work is also commented and will be gradually 6 | * fixed. This is a work in progress. 7 | */ 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | /** 18 | * OpenDX can convert MSVC's WinMain, but 19 | * it's not recommended as every other platform 20 | * uses main() and it's not portable. 21 | */ 22 | int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { 23 | // Create the window 24 | HWND hWnd = CreateWindow( 25 | "DX9 Window", "DX9 Window", 26 | WS_OVERLAPPEDWINDOW | WS_VISIBLE, 27 | 0, 0, 640, 480, NULL, NULL, hInstance, NULL 28 | ); 29 | 30 | // Create the Direct3D device 31 | LPDIRECT3D9 pD3D = Direct3DCreate9(D3D_SDK_VERSION); 32 | LPDIRECT3DDEVICE9 pDevice = NULL; 33 | D3DPRESENT_PARAMETERS pp; 34 | 35 | ZeroMemory(&pp, sizeof(pp)); 36 | pp.Windowed = TRUE; 37 | pp.SwapEffect = D3DSWAPEFFECT_DISCARD; 38 | pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &pp, &pDevice); 39 | 40 | // Enter the message loop 41 | MSG msg; 42 | ZeroMemory(&msg, sizeof(msg)); 43 | 44 | while (msg.message != WM_QUIT) { 45 | if (PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE)) { 46 | //TranslateMessage(&msg); 47 | //DispatchMessage(&msg); 48 | } else { 49 | // Render the scene 50 | /*pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0); 51 | pDevice->BeginScene(); 52 | pDevice->EndScene(); 53 | pDevice->Present(NULL, NULL, NULL, NULL);*/ 54 | } 55 | } 56 | 57 | // Clean up 58 | //pDevice->Release(); //causes a segfault 59 | //pD3D->Release(); 60 | DestroyWindow(hWnd); 61 | //return msg.wParam; 62 | 63 | return 0; 64 | } 65 | 66 | //Linux's main or MinGW's main: 67 | int main(int argc, char* argv[]) { 68 | //If you want to use WinMain (please dont) 69 | //you can pass it as a parameter: 70 | OpenDX odx(argc, argv,WinMain); //or OpenDX odx(); 71 | 72 | return odx.getReturnCode(); // 0 if WinMain is not passed. 73 | } 74 | -------------------------------------------------------------------------------- /tools/dxdiag/README.md: -------------------------------------------------------------------------------- 1 | # OpenDX - dxdiag 2 | ![](../../img/print.png) 3 | This is a sub-project of OpenDX. The Open Source alternative to Microsoft's DirectX SDK for Linux devices. 4 | 5 | ## Improvements over Microsoft's dxdiag 6 | * Fixes various bugs from the original dxdiag (e.g outdated date information, layout issues, etc.) 7 | * Uses native Linux APIs to gather information about the system. 8 | * Faster initialisation and execution 9 | * Compatible with GTK themes -------------------------------------------------------------------------------- /tools/dxdiag/layout/MainWindow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace MainWindow { 5 | const std::string ui = 6 | #include "MainWindow.ui" 7 | ; 8 | } 9 | -------------------------------------------------------------------------------- /tools/dxdiag/layout/MainWindow.ui: -------------------------------------------------------------------------------- 1 | R"XML( 2 | 3 | 4 | 5 | 720 6 | 480 7 | 8 | 9 | vertical 10 | 11 | 12 | 1 13 | 1 14 | 15 | 16 | 17 | 18 | 5 19 | 5 20 | 5 21 | vertical 22 | 23 | 24 | This tool reports detailed information about the DirectX components and drivers installed on your system. 25 | 26 | 27 | If you know what area is causing the problem, click on the apropriate tab above. Otherwise, you can use the "Next Page" button below to visit each page in sequence. 28 | 29 | 30 | 1 31 | 32 | 33 | 34 | 35 | 1 36 | 37 | 38 | 1 39 | 40 | 41 | 42 | 43 | 5 44 | 5 45 | 5 46 | 5 47 | vertical 48 | 2 49 | 5 50 | 1 51 | 52 | 53 | end 54 | Current Date/Time: 55 | right 56 | 1 57 | 58 | 0 59 | 0 60 | 61 | 62 | 63 | 64 | 65 | start 66 | Nullsday, Nul 00, 0000, 0:00:00 AM 67 | 1 68 | 69 | 1 70 | 0 71 | 72 | 73 | 74 | 75 | 76 | end 77 | Computer Name: 78 | right 79 | 1 80 | 81 | 0 82 | 1 83 | 84 | 85 | 86 | 87 | 88 | start 89 | null 90 | 1 91 | 92 | 1 93 | 1 94 | 95 | 96 | 97 | 98 | 99 | end 100 | Operating System: 101 | right 102 | 1 103 | 104 | 0 105 | 2 106 | 107 | 108 | 109 | 110 | 111 | start 112 | Nullbuntu 64-bit (23.04, kernel 0) 113 | 1 114 | 115 | 1 116 | 2 117 | 118 | 119 | 120 | 121 | 122 | end 123 | Language: 124 | right 125 | 1 126 | 127 | 0 128 | 3 129 | 130 | 131 | 132 | 133 | 134 | start 135 | Null (Regional Setting: Null) 136 | 1 137 | 138 | 1 139 | 3 140 | 141 | 142 | 143 | 144 | 145 | end 146 | System Manufacturer: 147 | right 148 | 1 149 | 150 | 0 151 | 4 152 | 153 | 154 | 155 | 156 | 157 | start 158 | Unknown 159 | 1 160 | 161 | 1 162 | 4 163 | 164 | 165 | 166 | 167 | 168 | end 169 | System Model: 170 | right 171 | 1 172 | 173 | 0 174 | 5 175 | 176 | 177 | 178 | 179 | 180 | start 181 | Unknown 182 | 1 183 | 184 | 1 185 | 5 186 | 187 | 188 | 189 | 190 | 191 | end 192 | BIOS: 193 | right 194 | 1 195 | 196 | 0 197 | 6 198 | 199 | 200 | 201 | 202 | 203 | start 204 | Null (0) 205 | 1 206 | 207 | 1 208 | 6 209 | 210 | 211 | 212 | 213 | 214 | end 215 | Processor: 216 | right 217 | 1 218 | 219 | 0 220 | 7 221 | 222 | 223 | 224 | 225 | 226 | start 227 | Intel(R) Celeron(TM) N0000 CPU @ 0GHz (0 CPUs), ~(0GHz) 228 | 1 229 | 230 | 1 231 | 7 232 | 233 | 234 | 235 | 236 | 237 | end 238 | Memory: 239 | right 240 | 1 241 | 242 | 0 243 | 8 244 | 245 | 246 | 247 | 248 | 249 | start 250 | 0MB RAM 251 | 1 252 | 253 | 1 254 | 8 255 | 256 | 257 | 258 | 259 | 260 | end 261 | Page/Swap File: 262 | right 263 | 1 264 | 265 | 0 266 | 9 267 | 268 | 269 | 270 | 271 | 272 | start 273 | 0MB used, 0MB available 274 | 1 275 | 276 | 1 277 | 9 278 | 279 | 280 | 281 | 282 | 283 | end 284 | DirectX Version: 285 | right 286 | 1 287 | 288 | 0 289 | 10 290 | 291 | 292 | 293 | 294 | 295 | start 296 | DirectX 0 297 | 1 298 | 299 | 1 300 | 10 301 | 302 | 303 | 304 | 305 | 306 | end 307 | OpenDX Version: 308 | right 309 | 1 310 | 311 | 0 312 | 11 313 | 314 | 315 | 316 | 317 | 318 | start 319 | 0.0.0 (About the OpenDX Project) 320 | 1 321 | 1 322 | 323 | 1 324 | 11 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | System Information 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | System 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 5 355 | 5 356 | 5 357 | 5 358 | 5 359 | 360 | 361 | Help 362 | 1 363 | 1 364 | 365 | 366 | 367 | 368 | 1 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | Next Page 377 | 1 378 | 1 379 | 380 | 381 | 382 | 383 | Save All Information... 384 | 1 385 | 1 386 | 387 | 388 | 389 | 390 | Exit 391 | 1 392 | 1 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | )XML" -------------------------------------------------------------------------------- /tools/dxdiag/locale/de_DE.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "en_US.hpp" 4 | 5 | /** 6 | * TODO Complete with project://include/types/Translation.hpp 7 | */ 8 | Translation_t Translation_deDE() { 9 | Translation_t r; 10 | 11 | //Common texts 12 | r.yes = (char*) "Ja"; 13 | r.no = (char*) "Nein"; 14 | r.not_available = (char*) "Nicht verfügbar"; 15 | r.enabled = (char*) "An"; 16 | 17 | //Tab names 18 | r.tab_system = (char*) "System"; 19 | r.tab_display = (char*) "Anzeige"; 20 | r.tab_sound = (char*) "Sound"; 21 | r.tab_input = (char*) "Eingabe"; 22 | 23 | //Buttons 24 | r.btn_help = (char*) "Hilfe"; 25 | r.btn_next = (char*) "Nächste Seite"; 26 | r.btn_save = (char*) "Alle Informationen speichern..."; 27 | r.btn_exit = (char*) "Beenden"; 28 | 29 | //Tab system 30 | r.system_description = (char*) "Dieses Programm gibt detaillierte Informationen über die DirectX-Komponenten und -Treiber dieses Computers an.\n\nWählen Sie die entsprechende Registerkarte oben, wenn Sie den Bereich des Problems bereits kennen. Klicken Sie andernfalls auf \"Nächste Seite\", um alle Seiten nacheinander zu durchsuchen."; 31 | r.system_info_label = (char*) "Systeminformation"; 32 | r.system_info_currentDate = (char*) "Aktuelles Datum/Zeit"; 33 | r.system_info_pcName = (char*) "Computername"; 34 | r.system_info_os = (char*) "Betriebssystem"; 35 | r.system_info_language = (char*) "Sprache"; 36 | r.system_info_manufacturer = (char*) "Systemhersteller"; 37 | r.system_info_model = (char*) "Systemmodell"; 38 | r.system_info_bios = (char*) "BIOS"; 39 | r.system_info_processor = (char*) "Prozessor"; 40 | r.system_info_memory = (char*) "Speicher"; 41 | r.system_info_pageFile = (char*) "Auslagerungsdatei"; 42 | r.system_info_directxVersion = (char*) "DirectX-Version"; 43 | r.system_info_opendxVersion = (char*) "OpenDX-Version"; 44 | 45 | //Tab Display 46 | r.display_device_label = (char*) "Gerät"; 47 | r.display_device_manufacturer = (char*) "Hersteller"; 48 | r.display_device_chipType = (char*) "Chiptyp"; 49 | r.display_device_dacType = (char*) "DAC-Typ"; 50 | r.display_device_type = (char*) "Gerätetyp"; 51 | r.display_device_mem = (char*) "Gesamtspeicher ca."; 52 | r.display_device_videoMem = (char*) "Anzeigespeicher (VRAM)"; 53 | r.display_device_sharedMem = (char*) "Gemeinsam genutzter Speicherbereich"; 54 | r.display_device_currDisplayMode = (char*) "Aktueller Anzeigemodus"; 55 | r.display_device_monitor = (char*) "Monitor"; 56 | r.display_driver_label = (char*) "Treiber"; 57 | r.display_driver_mainDriver = (char*) "Haupttreiber"; 58 | r.display_driver_version = (char*) "Version"; 59 | r.display_driver_date = (char*) "Datum"; 60 | r.display_driver_whqlLogo = (char*) "Mit WHQL-Logo"; 61 | r.display_driver_d3dDdi = (char*) "Direct3D-DDI"; 62 | r.display_driver_featureLevels = (char*) "Funktionsebenen"; 63 | r.display_driver_model = (char*) "Treibermodell"; 64 | r.display_features_label = (char*) "DirectX-Features"; 65 | r.display_features_ddAccel = (char*) "DirectDraw-Beschleunigung"; 66 | r.display_features_d3dAccel = (char*) "Direct3D-Beschleunigung"; 67 | r.display_features_agpAccel = (char*) "AGP-Oberflächenbeschleunigung"; 68 | r.display_notes_label = (char*) "Hinweise"; 69 | 70 | //Tab Sound 71 | r.sound_device_label = (char*) "Gerät"; 72 | r.sound_device_name = (char*) "Name"; 73 | r.sound_device_hardwareId = (char*) "Hardware-ID"; 74 | r.sound_device_manufacturerId = (char*) "Herstellerkennung"; 75 | r.sound_device_productId = (char*) "Produktkennung"; 76 | r.sound_device_type = (char*) "Typ"; 77 | r.sound_device_default = (char*) "Standardgerät"; 78 | r.sound_driver_label = (char*) "Treiber"; 79 | r.sound_driver_name = (char*) "Name"; 80 | r.sound_driver_version = (char*) "Version"; 81 | r.sound_driver_date = (char*) "Datum"; 82 | r.sound_driver_whqlLogo = (char*) "Mit WHQL-Logo"; 83 | r.sound_driver_otherFiles = (char*) "Andere Dateien"; 84 | r.sound_driver_provider = (char*) "Anbieter"; 85 | r.sound_notes_label = (char*) "Hinweise"; 86 | 87 | return r; 88 | } -------------------------------------------------------------------------------- /tools/dxdiag/locale/en_US.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | /** 5 | * TODO Complete with project://include/types/Translation.hpp 6 | */ 7 | Translation_t Translation_enUS() { 8 | Translation_t r; 9 | 10 | //Common texts 11 | r.yes = (char*) "Yes"; 12 | r.no = (char*) "No"; 13 | r.not_available = (char*) "Not Available"; 14 | r.enabled = (char*) "Enabled"; 15 | 16 | //Tab names 17 | r.tab_system = (char*) "System"; 18 | r.tab_display = (char*) "Display"; 19 | r.tab_sound = (char*) "Sound"; 20 | r.tab_input = (char*) "Input"; 21 | 22 | //Buttons 23 | r.btn_help = (char*) "Help"; 24 | r.btn_next = (char*) "Next"; 25 | r.btn_save = (char*) "Save"; 26 | r.btn_exit = (char*) "Exit"; 27 | 28 | //Tab System 29 | r.system_description = (char*) "This tool reports detailed information about the OpenDX components and drivers installed on your system.\n\nIf you know what area is causing the problem, click on the apropriate tab above. Otherwise, you can yse the \"Next Page\" button below to visit each page in sequence."; 30 | r.system_info_label = (char*) "System Information"; 31 | r.system_info_currentDate = (char*) "Current Date/Time"; 32 | r.system_info_pcName = (char*) "Computer Name"; 33 | r.system_info_os = (char*) "Operating System"; 34 | r.system_info_language = (char*) "Language"; 35 | r.system_info_manufacturer = (char*) "System Manufacturer"; 36 | r.system_info_model = (char*) "System Model"; 37 | r.system_info_bios = (char*) "BIOS"; 38 | r.system_info_processor = (char*) "Processor"; 39 | r.system_info_memory = (char*) "Memory"; 40 | r.system_info_pageFile = (char*) "Page file"; 41 | r.system_info_directxVersion = (char*) "DirectX Version"; 42 | r.system_info_opendxVersion = (char*) "OpenDX Version"; 43 | 44 | // Tab Display X 45 | 46 | r.display_device_label = (char*) "Device"; 47 | r.display_device_manufacturer = (char*)"Manufacturer"; 48 | r.display_device_chipType = (char*)"Chip Type"; 49 | r.display_device_dacType = (char*)"DAC Type"; 50 | r.display_device_type = (char*)"Device Type"; 51 | r.display_device_mem = (char*)"Total Memory"; 52 | r.display_device_videoMem = (char*)"Video Memory"; 53 | r.display_device_sharedMem = (char*)"Shared Memory"; 54 | r.display_device_currDisplayMode = (char*)"Current Display Mode"; 55 | r.display_device_monitor = (char*)"Monitor"; 56 | r.display_driver_label = (char*)"Drivers"; 57 | r.display_driver_mainDriver = (char*)"Main Driver"; 58 | r.display_driver_version = (char*)"Version"; 59 | r.display_driver_date = (char*)"Date"; 60 | r.display_driver_whqlLogo = (char*)"WHQL Logo"; 61 | r.display_driver_d3dDdi = (char*)"Direct3D DDI"; 62 | r.display_driver_featureLevels = (char*)"Feature"; 63 | r.display_driver_model = (char*)"Model"; 64 | r.display_features_ddAccel = (char*) "DD Accel"; 65 | r.display_features_d3dAccel = (char*)"D3D Accel"; 66 | r.display_features_agpAccel = (char*)"AGP Accel"; 67 | r.display_notes_label = (char*)"Notes"; 68 | 69 | // Tab Sound 70 | 71 | r.sound_device_label = (char*) "Device"; 72 | r.sound_device_name = (char*) "Device Name"; 73 | r.sound_device_hardwareId = (char*)"Hardware ID"; 74 | r.sound_device_manufacturerId = (char*)"Manufacturer ID"; 75 | r.sound_device_productId = (char*)"Product ID"; 76 | r.sound_device_type = (char*)"Type"; 77 | r.sound_device_default = (char*)"Default Device"; 78 | r.sound_driver_label = (char*)"Drivers"; 79 | r.sound_driver_name = (char*)"Name"; 80 | r.sound_driver_version = (char*)"Version"; 81 | r.sound_driver_date = (char*)"Date"; 82 | r.sound_driver_whqlLogo = (char*)"WHQL Logo"; 83 | r.sound_driver_otherFiles = (char*)"Other Files"; 84 | r.sound_driver_provider = (char*)"Provider"; 85 | r.sound_notes_label = (char*)"Notes"; 86 | 87 | 88 | 89 | return r; 90 | } 91 | -------------------------------------------------------------------------------- /tools/dxdiag/locale/es_ES.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "en_US.hpp" 4 | 5 | /** 6 | * TODO Complete with @see project://include/types/Translation.hpp 7 | */ 8 | Translation_t Translation_esES() { 9 | Translation_t r = Translation_enUS(); 10 | 11 | //Common texts 12 | r.yes = (char*) "Sí"; 13 | r.no = (char*) "No"; 14 | r.not_available = (char*) "No disponible"; 15 | r.enabled = (char*) "Habilitado"; 16 | 17 | //Tab names 18 | r.tab_system = (char*) "Sistema"; 19 | r.tab_display = (char*) "Pantalla"; 20 | r.tab_sound = (char*) "Sonido"; 21 | r.tab_input = (char*) "Entrada"; 22 | 23 | //Buttons 24 | r.btn_help = (char*) "Ayuda"; 25 | r.btn_next = (char*) "Siguiente"; 26 | r.btn_save = (char*) "Guardar"; 27 | r.btn_exit = (char*) "Salir"; 28 | 29 | //Tab System 30 | r.system_description = (char*) "Esta herramienta informa de información detallada sobre los componentes y controladores OpenDX instalados en su sistema.\n\nSi sabe qué área está causando el problema, haga clic en la pestaña correspondiente arriba. De lo contrario, puede usar el botón \"Página siguiente\" a continuación para visitar cada página en secuencia."; 31 | r.system_info_label = (char*) "Información del sistema"; 32 | r.system_info_currentDate = (char*) "Fecha y hora actuales"; 33 | r.system_info_pcName = (char*) "Nombre del ordenador"; 34 | r.system_info_os = (char*) "Sistema operativo"; 35 | r.system_info_language = (char*) "Idioma"; 36 | r.system_info_manufacturer = (char*) "Fabricante del sistema"; 37 | r.system_info_model = (char*) "Modelo del sistema"; 38 | r.system_info_bios = (char*) "BIOS"; 39 | r.system_info_processor = (char*) "Procesador"; 40 | r.system_info_memory = (char*) "Memoria"; 41 | r.system_info_pageFile = (char*) "Archivo de paginación"; 42 | r.system_info_directxVersion = (char*) "Versión de DirectX"; 43 | r.system_info_opendxVersion = (char*) "Versión de OpenDX"; 44 | 45 | //Tab Display 46 | r.display_device_label = (char*) "Etiqueta del dispositivo de visualización"; 47 | r.display_device_manufacturer = (char*) "Fabricante del dispositivo de visualización"; 48 | r.display_device_chipType = (char*) "Tipo de chip del dispositivo de visualización"; 49 | r.display_device_dacType = (char*) "Tipo de DAC del dispositivo de visualización"; 50 | r.display_device_type = (char*) "Tipo de dispositivo de visualización"; 51 | r.display_device_mem = (char*) "Memoria del dispositivo de visualización"; 52 | r.display_device_videoMem = (char*) "Memoria de vídeo del dispositivo de visualización"; 53 | r.display_device_sharedMem = (char*) "Memoria compartida del dispositivo de visualización"; 54 | r.display_device_currDisplayMode = (char*) "Modo de visualización actual del dispositivo de visualización"; 55 | r.display_device_monitor = (char*) "Monitor del dispositivo de visualización"; 56 | r.display_driver_label = (char*) "Etiqueta del controlador de visualización"; 57 | r.display_driver_mainDriver = (char*) "Controlador principal del controlador de visualización"; 58 | r.display_driver_version = (char*) "Versión del controlador de visualización"; 59 | r.display_driver_date = (char*) "Fecha del controlador de visualización"; 60 | r.display_driver_whqlLogo = (char*) "Logotipo WHQL del controlador de visualización"; 61 | r.display_driver_d3dDdi = (char*) "D3D DDI del controlador de visualización"; 62 | r.display_driver_featureLevels = (char*) "Niveles de características del controlador de visualización"; 63 | r.display_driver_model = (char*) "Modelo del controlador de visualización"; 64 | r.display_features_label = (char*) "Etiqueta de las características de visualización"; 65 | r.display_features_ddAccel = (char*) "Aceleración DD de las características de visualización"; 66 | r.display_features_d3dAccel = (char*) "Aceleración D3D de las características de visualización"; 67 | r.display_features_agpAccel = (char*) "Aceleración AGP de las características de visualización"; 68 | r.display_notes_label = (char*) "Etiqueta de las notas de visualización"; 69 | 70 | //Tab Sound 71 | r.sound_device_label = (char*) "Etiqueta del dispositivo de sonido"; 72 | r.sound_device_name = (char*) "Nombre del dispositivo de sonido"; 73 | r.sound_device_hardwareId = (char*) "ID de hardware del dispositivo de sonido"; 74 | r.sound_device_manufacturerId = (char*) "ID de fabricante del dispositivo de sonido"; 75 | r.sound_device_productId = (char*) "ID de producto del dispositivo de sonido"; 76 | r.sound_device_type = (char*) "Tipo de dispositivo de sonido"; 77 | r.sound_device_default = (char*) "Dispositivo de sonido predeterminado"; 78 | r.sound_driver_label = (char*) "Etiqueta del controlador de sonido"; 79 | r.sound_driver_name = (char*) "Nombre del controlador de sonido"; 80 | r.sound_driver_version = (char*) "Versión del controlador de sonido"; 81 | r.sound_driver_date = (char*) "Fecha del controlador de sonido"; 82 | r.sound_driver_whqlLogo = (char*) "Logotipo WHQL del controlador de sonido"; 83 | r.sound_driver_otherFiles = (char*) "Otros archivos del controlador de sonido"; 84 | r.sound_driver_provider = (char*) "Proveedor del controlador de sonido"; 85 | r.sound_notes_label = (char*) "Etiqueta de las notas de sonido"; 86 | 87 | return r; 88 | } 89 | -------------------------------------------------------------------------------- /tools/dxdiag/locale/it_IT.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | /** 5 | * TODO Complete with project://include/types/Translation.hpp 6 | */ 7 | Translation_t Translation_itIT() { 8 | Translation_t r; 9 | 10 | //Common texts 11 | r.yes = (char*) "Si"; 12 | r.no = (char*) "No"; 13 | r.not_available = (char*) "Non Disponibile"; 14 | r.enabled = (char*) "Abilitato"; 15 | 16 | //Tab names 17 | r.tab_system = (char*) "Sistema"; 18 | r.tab_display = (char*) "Schermo"; 19 | r.tab_sound = (char*) "Audio"; 20 | r.tab_input = (char*) "Input"; 21 | 22 | //Buttons 23 | r.btn_help = (char*) "Aiuto"; 24 | r.btn_next = (char*) "Sucessiva"; 25 | r.btn_save = (char*) "Salva"; 26 | r.btn_exit = (char*) "Esci"; 27 | 28 | //Tab System 29 | r.system_description = (char*) "Questo strumento riporta informazioni dettagliate sui componenti e sui driver OpenDX installati sul tuo sistema.\n\nSe sai quale area causa il problema, fai clic sulla scheda appropriata sopra. Altrimenti puoi usare il pulsante \"Pagina successiva\" qui sotto per visitare ogni pagina in sequenza."; 30 | r.system_info_label = (char*) "Informazioni di sistema"; 31 | r.system_info_currentDate = (char*) "Data/ora corrente"; 32 | r.system_info_pcName = (char*) "Nome del computer"; 33 | r.system_info_os = (char*) "Systema Operativo"; 34 | r.system_info_language = (char*) "Lingua"; 35 | r.system_info_manufacturer = (char*) "Produttore del sistema"; 36 | r.system_info_model = (char*) "Modello del sistema"; 37 | r.system_info_bios = (char*) "BIOS"; 38 | r.system_info_processor = (char*) "Processore"; 39 | r.system_info_memory = (char*) "Memoria"; 40 | r.system_info_pageFile = (char*) "Page file"; 41 | r.system_info_directxVersion = (char*) "Versione DirectX"; 42 | r.system_info_opendxVersion = (char*) "Versione OpenDX"; 43 | 44 | //Tab Display 45 | r.display_device_label = (char*) "Visualizza l'etichetta del dispositivo"; 46 | r.display_device_manufacturer = (char*) "Produttore del dispositivo"; 47 | r.display_device_chipType = (char*) "Visualizza il tipo di chip del dispositivo"; 48 | r.display_device_dacType = (char*) "Tipo di DAC del dispositivo"; 49 | r.display_device_type = (char*) "Tipo di dispositivo"; 50 | r.display_device_mem = (char*) "Memoria del dispositivo"; 51 | r.display_device_videoMem = (char*) "Memoria vídeo del dispositivo"; 52 | r.display_device_sharedMem = (char*) "Memoria del dispositivo condivisa"; 53 | r.display_device_currDisplayMode = (char*) "Modalità di visualizzazione corrente del dispositivo"; 54 | r.display_device_monitor = (char*) "Visualizza il monitor del dispositivo"; 55 | r.display_driver_label = (char*) "Visualizza l'etichetta del controller"; 56 | r.display_driver_mainDriver = (char*) "Controller principale del controller video"; 57 | r.display_driver_version = (char*) "Visualizza la versione del driver"; 58 | r.display_driver_date = (char*) "Visualizza la data del controller"; 59 | r.display_driver_whqlLogo = (char*) "Visualizza il logo WHQL del controller"; 60 | r.display_driver_d3dDdi = (char*) "Driver video D3D DDI"; 61 | r.display_driver_featureLevels = (char*) "Livelli di funzionalità del controller video"; 62 | r.display_driver_model = (char*) "Modello del controller video"; 63 | r.display_features_label = (char*) "Etichetta delle funzioni di visualizzazione"; 64 | r.display_features_ddAccel = (char*) "Accelerazione DD delle funzionalità di visualizzazione"; 65 | r.display_features_d3dAccel = (char*) "Accelerazione D3D delle funzionalità di visualizzazione"; 66 | r.display_features_agpAccel = (char*) "Accelerazione AGP delle funzionalità di visualizzazione"; 67 | r.display_notes_label = (char*) "Visualizza etichetta note"; 68 | 69 | //Tab Sound 70 | r.sound_device_label = (char*) "Etichetta del dispositivo audio"; 71 | r.sound_device_name = (char*) "Nome del dispositivo audio"; 72 | r.sound_device_hardwareId = (char*) "ID hardware del dispositivo audio"; 73 | r.sound_device_manufacturerId = (char*) "ID del produttore del dispositivo audio"; 74 | r.sound_device_productId = (char*) "ID prodotto del dispositivo audio"; 75 | r.sound_device_type = (char*) "Tipo di dispositivo audio"; 76 | r.sound_device_default = (char*) "Dispositivo audio predefinito"; 77 | r.sound_driver_label = (char*) "Etichetta del driver audio"; 78 | r.sound_driver_name = (char*) "Nome del driver audio"; 79 | r.sound_driver_version = (char*) "Versione del driver audio"; 80 | r.sound_driver_date = (char*) "Data del driver audio"; 81 | r.sound_driver_whqlLogo = (char*) "Logo WHQL del controller audio"; 82 | r.sound_driver_otherFiles = (char*) "Altri file dei driver audio"; 83 | r.sound_driver_provider = (char*) "Fornitore di driver audio"; 84 | r.sound_notes_label = (char*) "Etichetta della nota sonora"; 85 | 86 | return r; 87 | } 88 | -------------------------------------------------------------------------------- /tools/dxdiag/locale/pt_BR.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "en_US.hpp" 4 | 5 | /** 6 | * TODO Completar 7 | */ 8 | Translation_t Translation_ptBR() { 9 | Translation_t r = Translation_enUS(); 10 | 11 | //Common texts 12 | r.yes = (char*) "Sim"; 13 | r.no = (char*) "Não"; 14 | r.not_available = (char*) "Indisponível"; 15 | r.enabled = (char*) "Habilitado"; 16 | 17 | //Tab names 18 | r.tab_system = (char*) "Sistema"; 19 | r.tab_display = (char*) "Exibição"; 20 | r.tab_sound = (char*) "Som"; 21 | r.tab_input = (char*) "Entrada"; 22 | 23 | //Buttons 24 | r.btn_help = (char*) "Ajuda"; 25 | r.btn_next = (char*) "Próximo"; 26 | r.btn_save = (char*) "Salvar"; 27 | r.btn_exit = (char*) "Sair"; 28 | 29 | return r; 30 | } 31 | -------------------------------------------------------------------------------- /tools/dxdiag/locale/tr_TR.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EduApps-CDG/OpenDX/6a8b51491f3b0d5973837bc274ef7f57e5ea3552/tools/dxdiag/locale/tr_TR.hpp -------------------------------------------------------------------------------- /tools/dxdiag/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include //GTK4 4 | 5 | #include 6 | #include "layout/MainWindow.hpp" 7 | #include "src/SystemTab.hpp" 8 | 9 | //DirectX files: 10 | #include 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | #if DEBUG 15 | printf("Application started!\n\n"); 16 | #endif 17 | 18 | //initializes GTK screen 19 | gtk_init(); 20 | const gchar* glade_string = MainWindow::ui.c_str(); 21 | GtkBuilder* builder = gtk_builder_new_from_string(glade_string, -1); 22 | GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "main_window")); 23 | 24 | //setup events and show the screen: 25 | new SystemTab(builder); 26 | gtk_widget_show(GTK_WIDGET(window)); 27 | 28 | while (g_list_model_get_n_items (gtk_window_get_toplevels ()) > 0) 29 | g_main_context_iteration (NULL, TRUE); 30 | 31 | g_object_unref(builder); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /tools/dxdiag/src/SystemTab.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | #include "../locale/en_US.hpp" 19 | #include "../locale/pt_BR.hpp" 20 | #include "../locale/es_ES.hpp" 21 | 22 | class SystemTab { 23 | /** 24 | * Set the text from "date_val"to the actual date/time. 25 | */ 26 | public:static gboolean updateTime(GtkLabel* label) { 27 | time_t t = time(NULL); 28 | struct tm* time = localtime(&t); 29 | gchar str_time[40]; 30 | 31 | strftime(str_time, sizeof(str_time), "%A, %b %d, %Y, %I:%M:%S %p", time); 32 | gtk_label_set_text(label, str_time); 33 | 34 | gtk_widget_queue_draw(GTK_WIDGET(label)); 35 | gtk_widget_queue_draw(gtk_widget_get_parent(GTK_WIDGET(label))); 36 | gtk_widget_show(GTK_WIDGET(label)); 37 | 38 | return G_SOURCE_CONTINUE; 39 | } 40 | 41 | /** 42 | * set a timeout event every 500ms to set the actual date/time 43 | */ 44 | public:static gboolean onRealizeTime(GtkLabel* label) { 45 | std::cout << "SystemTab::onRealizeTime()\n"; 46 | 47 | g_timeout_add (500, (GSourceFunc) SystemTab::updateTime, label); 48 | return FALSE; 49 | } 50 | 51 | /** 52 | * Set the text from "pc_val" to the unix hostname. 53 | */ 54 | public:static gboolean setHostname(GtkLabel* label) { 55 | char hostname[1024]; 56 | gethostname(hostname, sizeof hostname); 57 | 58 | 59 | gtk_label_set_text(label, hostname); 60 | 61 | gtk_widget_queue_draw(GTK_WIDGET(label)); 62 | gtk_widget_queue_draw(gtk_widget_get_parent(GTK_WIDGET(label))); 63 | gtk_widget_show(GTK_WIDGET(label)); 64 | 65 | return FALSE; 66 | } 67 | 68 | public:static std::string exec(const char* cmd) { 69 | std::vector buffer(1024); 70 | std::string result; 71 | FILE* pipe = popen(cmd, "r"); 72 | 73 | if (!pipe) throw std::runtime_error("popen() failed!"); 74 | 75 | while (fgets(buffer.data(), buffer.size(), pipe) != nullptr) { 76 | result += buffer.data(); 77 | } 78 | 79 | pclose(pipe); 80 | return result; 81 | } 82 | 83 | public:static gboolean setOperatingSystem(GtkLabel* label) { 84 | std::string distro = exec("lsb_release -i | awk '{print $3}'"); 85 | std::string distro_version = exec("lsb_release -r | awk '{print $2}'"); 86 | std::string kernel_version = exec("uname -r"); 87 | std::string arch = exec("uname -m | grep -q 64 && echo 64-bit || echo 32-bit"); 88 | 89 | // Trim the string values 90 | //distro.erase(std::remove(distro.begin(), distro.c_str() '\n'), distro.end()); 91 | //distro_version.erase(std::remove(distro_version.begin(), distro_version.end(), '\n'), distro_version.end()); 92 | //kernel_version.erase(std::remove(kernel_version.begin(), kernel_version.end(), '\n'), kernel_version.end()); 93 | //arch.erase(std::remove(arch.begin(), arch.end(), '\n'), arch.end()); 94 | 95 | std::string os_info = distro + " " + arch + " (" + distro_version + ", kernel " + kernel_version + ")"; 96 | os_info = std::regex_replace(os_info, std::regex("\n"), ""); 97 | 98 | // Convert the string to const gchar* 99 | const gchar* text = os_info.c_str(); 100 | 101 | gtk_label_set_text(label, text); 102 | gtk_widget_queue_draw(GTK_WIDGET(label)); 103 | gtk_widget_queue_draw(gtk_widget_get_parent(GTK_WIDGET(label))); 104 | gtk_widget_show(GTK_WIDGET(label)); 105 | 106 | return FALSE; 107 | } 108 | 109 | public:static gboolean setLanguage(GtkLabel* label) { 110 | char buffer[128]; 111 | std::string locale = setlocale(LC_CTYPE, NULL); 112 | std::string lang, region; 113 | 114 | // get the language and region from the locale 115 | lang = locale.substr(0, locale.find("_")); 116 | region = locale.substr(locale.find("_") + 1); 117 | region.erase(region.size() - 1, 1); 118 | region = region.substr(0, region.find(".")); 119 | 120 | // Return the formatted string 121 | std::string str = lang + " (Regional Setting: " + region + ")"; 122 | const gchar* text = str.c_str(); 123 | 124 | gtk_label_set_text(label, text); 125 | gtk_widget_queue_draw(GTK_WIDGET(label)); 126 | gtk_widget_queue_draw(gtk_widget_get_parent(GTK_WIDGET(label))); 127 | gtk_widget_show(GTK_WIDGET(label)); 128 | 129 | return FALSE; 130 | } 131 | 132 | public:static gboolean setManufacturer(GtkLabel* label) { 133 | std::ifstream file("/sys/class/dmi/id/sys_vendor"); 134 | std::string manufacturer; 135 | 136 | if (file.is_open()) { 137 | std::getline(file, manufacturer); 138 | } 139 | 140 | const gchar* text = manufacturer.c_str(); 141 | 142 | gtk_label_set_text(label, text); 143 | gtk_widget_queue_draw(GTK_WIDGET(label)); 144 | gtk_widget_queue_draw(gtk_widget_get_parent(GTK_WIDGET(label))); 145 | gtk_widget_show(GTK_WIDGET(label)); 146 | 147 | return FALSE; 148 | } 149 | 150 | public:static gboolean setModel(GtkLabel* label) { 151 | std::ifstream file("/sys/class/dmi/id/product_name"); 152 | std::string model; 153 | 154 | if (file.is_open()) { 155 | std::getline(file, model); 156 | } 157 | 158 | const gchar* text = model.c_str(); 159 | 160 | gtk_label_set_text(label, text); 161 | gtk_widget_queue_draw(GTK_WIDGET(label)); 162 | gtk_widget_queue_draw(gtk_widget_get_parent(GTK_WIDGET(label))); 163 | gtk_widget_show(GTK_WIDGET(label)); 164 | 165 | return FALSE; 166 | } 167 | 168 | public:static gboolean setBIOS(GtkLabel* label) { 169 | std::ifstream file("/sys/class/dmi/id/bios_version"); 170 | std::string bios; 171 | 172 | if (file.is_open()) { 173 | std::getline(file, bios); 174 | } 175 | 176 | const gchar* text = bios.c_str(); 177 | 178 | gtk_label_set_text(label, text); 179 | gtk_widget_queue_draw(GTK_WIDGET(label)); 180 | gtk_widget_queue_draw(gtk_widget_get_parent(GTK_WIDGET(label))); 181 | gtk_widget_show(GTK_WIDGET(label)); 182 | 183 | return FALSE; 184 | } 185 | 186 | public:static std::string getCpuModelName() { 187 | std::ifstream file("/proc/cpuinfo"); 188 | std::string line; 189 | 190 | while (std::getline(file, line)) { 191 | if (line.find("model name") != std::string::npos) { 192 | return line.substr(line.find(":") + 2); 193 | } 194 | } 195 | 196 | return "Unknown"; 197 | } 198 | 199 | public:static int getCpuCoreCount() { 200 | std::ifstream file("/proc/cpuinfo"); 201 | std::string line; 202 | int core_count = 0; 203 | 204 | while (std::getline(file, line)) { 205 | if (line.find("processor") != std::string::npos) { 206 | ++core_count; 207 | } 208 | } 209 | 210 | return core_count; 211 | } 212 | 213 | public:static double getCpuFrequency() { 214 | std::ifstream file("/proc/cpuinfo"); 215 | std::string line; 216 | double frequency = 0.0; 217 | 218 | while (std::getline(file, line)) { 219 | if (line.find("cpu MHz") != std::string::npos) { 220 | frequency += std::stod(line.substr(line.find(":") + 1)); 221 | } 222 | } 223 | 224 | return frequency; 225 | } 226 | 227 | public:static std::string getCpuInfo() { 228 | int core_count = SystemTab::getCpuCoreCount(); 229 | double frequency = SystemTab::getCpuFrequency() / 1000; 230 | std::string model_name = SystemTab::getCpuModelName(); 231 | 232 | std::ostringstream frequency_stream; 233 | frequency_stream << std::fixed << std::setprecision(2) << frequency / core_count; 234 | std::string formatted_frequency = frequency_stream.str(); 235 | 236 | return model_name + " (" + std::to_string(core_count) + " CPUs), ~" + formatted_frequency + "GHz"; 237 | } 238 | 239 | public:static gboolean setCPU(GtkLabel* label) { 240 | std::string cpu = SystemTab::getCpuInfo(); 241 | const gchar* text = cpu.c_str(); 242 | 243 | gtk_label_set_text(label, text); 244 | gtk_widget_queue_draw(GTK_WIDGET(label)); 245 | gtk_widget_queue_draw(gtk_widget_get_parent(GTK_WIDGET(label))); 246 | // gtk_widget_show(GTK_WIDGET(label)); 247 | return FALSE; 248 | } 249 | 250 | public:static gboolean setRAM(GtkLabel* label) { 251 | std::ifstream file("/proc/meminfo"); 252 | std::string line; 253 | std::string ram = "0MB RAM"; 254 | 255 | while (std::getline(file, line)) { 256 | if (line.find("MemTotal") != std::string::npos) { 257 | int mb = std::stoi(line.substr(line.find(":") + 1)) / 1024; 258 | ram = std::to_string(mb) + "MB RAM"; 259 | } 260 | } 261 | 262 | const gchar* text = ram.c_str(); 263 | 264 | gtk_label_set_text(label, text); 265 | gtk_widget_queue_draw(GTK_WIDGET(label)); 266 | gtk_widget_queue_draw(gtk_widget_get_parent(GTK_WIDGET(label))); 267 | gtk_widget_show(GTK_WIDGET(label)); 268 | 269 | return FALSE; 270 | } 271 | 272 | public:static gboolean updateSwap(GtkLabel* label) { 273 | struct sysinfo info; 274 | sysinfo(&info); 275 | 276 | const int used = (info.totalswap - info.freeswap) / (1024 * 1024); 277 | const int available = info.freeswap / (1024 * 1024); 278 | std::string swap = std::to_string(used) + "MB used, " + std::to_string(available) + "MB available"; 279 | 280 | const gchar* text = swap.c_str(); 281 | 282 | gtk_label_set_text(label, text); 283 | gtk_widget_queue_draw(GTK_WIDGET(label)); 284 | gtk_widget_queue_draw(gtk_widget_get_parent(GTK_WIDGET(label))); 285 | gtk_widget_show(GTK_WIDGET(label)); 286 | 287 | return FALSE; 288 | } 289 | 290 | public:static gboolean setSwap(GtkLabel* label) { 291 | g_timeout_add(500, (GSourceFunc) SystemTab::updateSwap, label); 292 | return FALSE; 293 | } 294 | 295 | /** 296 | * setup IDs and it's events 297 | */ 298 | public:SystemTab(GtkBuilder* builder) { 299 | std::cout << "SystemTab::setup()\n"; 300 | 301 | this->setupLang(builder); 302 | this->setupSignals(builder); 303 | } 304 | 305 | private:void setupLang(GtkBuilder* builder) { 306 | //get system locale 307 | const char* locale = setlocale(LC_CTYPE, NULL); 308 | Translation_t lang; 309 | 310 | //instantiate Translation_{locale}() from tools/dxdiag/locale/{locale}.hpp 311 | if ( 312 | strcmp(locale, "pt_BR.UTF-8") == 0 || 313 | strcmp(locale, "pt_PT.UTF-8") == 0 314 | ) { 315 | lang = Translation_ptBR(); // >:) 316 | } else if (strcmp(locale, "es_ES.UTF-8")) { 317 | lang = Translation_esES(); 318 | } else { 319 | lang = Translation_enUS(); 320 | } 321 | 322 | //set texts 323 | GtkLabel* tab_system = GTK_LABEL(gtk_builder_get_object(builder, "tab_system_txt")); 324 | gtk_label_set_text(tab_system, lang.tab_system); 325 | GtkLabel* system_description = GTK_LABEL(gtk_builder_get_object(builder, "system_description")); 326 | gtk_label_set_text(system_description, lang.system_description); 327 | GtkLabel* system_info_label = GTK_LABEL(gtk_builder_get_object(builder, "system_info_label")); 328 | gtk_label_set_text(system_info_label, lang.system_info_label); 329 | GtkLabel* system_info_currentDate = GTK_LABEL(gtk_builder_get_object(builder, "system_info_currentDate")); 330 | gtk_label_set_text(system_info_currentDate, lang.system_info_currentDate); 331 | GtkLabel* system_info_pcName = GTK_LABEL(gtk_builder_get_object(builder, "system_info_pcName")); 332 | gtk_label_set_text(system_info_pcName, lang.system_info_pcName); 333 | GtkLabel* system_info_os = GTK_LABEL(gtk_builder_get_object(builder, "system_info_os")); 334 | gtk_label_set_text(system_info_os, lang.system_info_os); 335 | GtkLabel* system_info_language = GTK_LABEL(gtk_builder_get_object(builder, "system_info_language")); 336 | gtk_label_set_text(system_info_language, lang.system_info_language); 337 | GtkLabel* system_info_manufacturer = GTK_LABEL(gtk_builder_get_object(builder, "system_info_manufacturer")); 338 | gtk_label_set_text(system_info_manufacturer, lang.system_info_manufacturer); 339 | GtkLabel* system_info_model = GTK_LABEL(gtk_builder_get_object(builder, "system_info_model")); 340 | gtk_label_set_text(system_info_model, lang.system_info_model); 341 | GtkLabel* system_info_bios = GTK_LABEL(gtk_builder_get_object(builder, "system_info_bios")); 342 | gtk_label_set_text(system_info_bios, lang.system_info_bios); 343 | GtkLabel* system_info_processor = GTK_LABEL(gtk_builder_get_object(builder, "system_info_processor")); 344 | gtk_label_set_text(system_info_processor, lang.system_info_processor); 345 | GtkLabel* system_info_memory = GTK_LABEL(gtk_builder_get_object(builder, "system_info_memory")); 346 | gtk_label_set_text(system_info_memory, lang.system_info_memory); 347 | GtkLabel* system_info_pageFile = GTK_LABEL(gtk_builder_get_object(builder, "system_info_pageFile")); 348 | gtk_label_set_text(system_info_pageFile, lang.system_info_pageFile); 349 | GtkLabel* system_info_directxVersion = GTK_LABEL(gtk_builder_get_object(builder, "system_info_directxVersion")); 350 | gtk_label_set_text(system_info_directxVersion, lang.system_info_directxVersion); 351 | GtkLabel* system_info_opendxVersion = GTK_LABEL(gtk_builder_get_object(builder, "system_info_opendxVersion")); 352 | gtk_label_set_text(system_info_opendxVersion, lang.system_info_opendxVersion); 353 | } 354 | 355 | private:void setupSignals(GtkBuilder* builder) { 356 | GtkLabel* date_val = GTK_LABEL(gtk_builder_get_object(builder, "date_val")); 357 | g_signal_connect (date_val, "realize", G_CALLBACK (SystemTab::onRealizeTime), NULL); 358 | GtkLabel* pc_val = GTK_LABEL(gtk_builder_get_object(builder, "pc_val")); 359 | g_signal_connect (pc_val, "realize", G_CALLBACK (SystemTab::setHostname), NULL); 360 | GtkLabel* os_val = GTK_LABEL(gtk_builder_get_object(builder, "os_val")); 361 | g_signal_connect (os_val, "realize", G_CALLBACK (SystemTab::setOperatingSystem), NULL); 362 | GtkLabel* lang_val = GTK_LABEL(gtk_builder_get_object(builder, "lang_val")); 363 | g_signal_connect (lang_val, "realize", G_CALLBACK (SystemTab::setLanguage), NULL); 364 | GtkLabel* pcman_val = GTK_LABEL(gtk_builder_get_object(builder, "pcman_val")); 365 | g_signal_connect (pcman_val, "realize", G_CALLBACK (SystemTab::setManufacturer), NULL); 366 | GtkLabel* pcmod_val = GTK_LABEL(gtk_builder_get_object(builder, "pcmod_val")); 367 | g_signal_connect (pcmod_val, "realize", G_CALLBACK (SystemTab::setModel), NULL); 368 | GtkLabel* bios_val = GTK_LABEL(gtk_builder_get_object(builder, "bios_val")); 369 | g_signal_connect (bios_val, "realize", G_CALLBACK (SystemTab::setBIOS), NULL); 370 | GtkLabel* cpu_val = GTK_LABEL(gtk_builder_get_object(builder, "cpu_val")); 371 | g_signal_connect (cpu_val, "realize", G_CALLBACK (SystemTab::setCPU), NULL); 372 | GtkLabel* ram_val = GTK_LABEL(gtk_builder_get_object(builder, "ram_val")); 373 | g_signal_connect (ram_val, "realize", G_CALLBACK (SystemTab::setRAM), NULL); 374 | GtkLabel* swap_val = GTK_LABEL(gtk_builder_get_object(builder, "swap_val")); 375 | g_signal_connect (swap_val, "realize", G_CALLBACK (SystemTab::setSwap), NULL); 376 | } 377 | }; 378 | -------------------------------------------------------------------------------- /tools/dxdiag/src/utils/.DXUtils.hpp.kate-swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EduApps-CDG/OpenDX/6a8b51491f3b0d5973837bc274ef7f57e5ea3552/tools/dxdiag/src/utils/.DXUtils.hpp.kate-swp -------------------------------------------------------------------------------- /tools/dxdiag/src/utils/DXUtils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace DXUtils { 5 | char* getDirectXVersion() { 6 | // TODO: check for direct x version somehow. 7 | } 8 | } 9 | --------------------------------------------------------------------------------