Directx support on linux

Is it possible to develop DirectX apps in Linux?

More out of interest than anything else, but can you compile a DirectX app under linux? Obviously there’s no official SDK, but I was thinking it might be possible with wine. Presumably wine has an implementation of the DirectX interface in order to run games? Is it possible to link against that? (edit: This is called winelib) Failing that, maybe a mingw cross compiler with the app running under wine. Half answered my own question here, but wondered if anyone had heard of anything like this being done?

9 Answers 9

I’ve had some luck with this. I’ve managed to compile this simple Direct3D example.

I used winelib for this (wine-dev package on Ubuntu). Thanks to alastair for pointing me to winelib.

I modified the source slightly to convert the wchars to chars (1 on line 52, 2 on line 55, by removing the L before the string literals). There may be a way around this, but this got it up and running.

I then compiled the source with the following:

wineg++ -ld3d9 -ld3dx9 triangle.cpp 

This generates an a.out.exe.so binary, as well as an a.out script to run it under wine.

If this is not about porting but creating, you should really consider OpenGL as this API is as powerful as DirectX and much easier to port to Mac or Linux.

I don’t know your requirements so better mention it.

You can’t link against wine as it’s essentially a call interdictor/translator rather than a set of libraries you can hook into. If linux is important go OpenGL/SDL/OpenAL.

I believe(I’ve never tried this) you can can compile Linux binarys against winelib. So it works just like a Linux executable, but with the windows libraries.

go to the directory with the source and type in:

winemaker --lower-uppercase -icomdlg32 -ishell32 -ishlwapi -iuser32 -igdi32 -iadvapi32 -ld3d9 . make wine yourexecutable.exe.so 
main.c:95:5: error: ‘struct IDirect3D9’ has no member named ‘CreateDevice’ 

make sure you have named your file main.cpp and not main.c.

There is currently no way to compile DirectX code to directly target Linux. You would build your application like you normally would, then run it using a compatibility layer like Wine/Cedega.

you can compile a directx apps in linux, but not launching it straight away. if you use a crosscompilator that makes windows exe and point to the windows sdk and directx sdk.

Although this question is dated, I decided to updated on it, because it keeps popping up for me as the first suggestion for this particular problem.

As the previous answers already suggested you can compile against winelib. However, there are yet another two solutions.

The first solution would be either to use the MinGW provided for your distributions. MinGW is a ‘cross-compiler’, that compiles either from macOS or linux to windows and has support for DirectX. Note, that C++ libraries compiled with MinGW are not compatible with the MSVC compiler’s ABI, thus cannot be consumed. However, the resulting binaries can be executed using Wine.

Читайте также:  Просмотр открытых файлов linux

The second solution would be to use clang as a cross compiler. Clang usually includes the Compiler and Linker needed for Windows out of the box. However, it’ll require you to include provide the headers and libraries yourself. On the other hand, libraries compiled this way are compatible with MSVC and, thus, can be consumed by it.

Side note: Latter allows you to setup an CI server using linux (I did so on a raspberry pi), which creates compatible binaries for end users.

Источник

unixforum.org

Установка DirectX в wine ЭЛЕМЕНТАРНО! (накопал у себя)

Установка DirectX в wine ЭЛЕМЕНТАРНО!

Сообщение STROGOS » 09.01.2010 21:20

Все знают, что для многих современных игр требуется DirectX 9. Под виндой его поставить не составляет труда, но вот под убунтой это несколько дольше. Есть один простой ход, который может облегчить вам жизнь:

Для установки DirectX нам понадобится winetricks, скачаем его командой:

chmod +x winetricks
Перенесём его куда надо:

sudo mv winetricks /usr/bin
Теперь он скачает и установит последнюю версию directx9, командой:

winetricks directx9
На этом всё) Теперь игры требующие directx9 должны запускаться и работать нормально.

Re: Установка DirectX в wine ЭЛЕМЕНТАРНО!

Сообщение Sekta-N » 10.01.2010 03:22

rm_ Сообщения: 3340 Статус: It’s the GNU Age ОС: Debian Контактная информация:

Re: Установка DirectX в wine ЭЛЕМЕНТАРНО!

Сообщение rm_ » 10.01.2010 05:43

Если серьёзнее, Wine и так уже эмулирует его весь, плюс даже немножечко из DirectX 10.
Ставить виндовый нужно лишь в единицах «крайних случаев», в остальном он принесёт одни только проблемы.

Re: Установка DirectX в wine ЭЛЕМЕНТАРНО!

Сообщение stampoon » 10.01.2010 10:44

Ставить виндовый нужно лишь в единицах «крайних случаев», в остальном он принесёт одни только проблемы.

Re: Установка DirectX в wine ЭЛЕМЕНТАРНО!

Сообщение MMouXe » 11.01.2010 18:14

Обычно wine’вского директикса вполне хватает, а после установки МС’го, как уже было замечено выше, вы можете поиметь проблем. Так что устанавливайте DirectX от MS лишь в крайнем случае.

1) Сделать резервную копию предыдущих настроек wine (каталог ~/.wine), оригинал удалить или переименовать.
2) Создать стандартные настройки командой winecfg.
3) Скопировать библиотеки mscoree.dll и streamci.dll в ~/.wine/drive_c/windows/system32/
4) Из каталога ~/.wine/drive_c/windows/system32/ удалить файлы:
d3d8.dll,d3d9.dll,ddraw.dll,dsound.dll,dsound.vxd,quartz.dll,dxdiagn.dll
5) Отредактировать файл ~/.wine/user.reg , вставив в конец файла:
[Software\\Wine\\DllOverrides] 1196330736
«d3d8″=»native»
«d3d9″=»native»
«d3dim»=»native»
«d3dx8″=»native»
«d3dxof»=»native»
«dciman32″=»native»
«ddrawex»=»native»
«devenum»=»native»
«dinput»=»native»
«dinput8″=»native»
«dmband»=»native»
«dmcompos»=»native»
«dmime»=»native»
«dmloader»=»native»
«dmscript»=»native»
«dmstyle»=»native»
«dmsynth»=»native»
«dmusic»=»native»
«dplay»=»native»
«dplayx»=»native»
«dpnaddr»=»native»
«dpnet»=»native»
«dpnhpast»=»native»
«dswave»=»native»
«dxdiagn»=»native»
«mscoree»=»native»
«quartz»=»native»
«streamci»=»native»
6) Установить DirectX (стандартный дистрибутив для windows).
7) Запустить снова конфигуратор winecfg, вкладка Библиотеки, и для библиотек:
d3d8,d3d9,ddrawex,dinput,dinput8
выбрать Редактировать и выставить для них порядок загрузки «Встроенная (wine)».
8) Провести тесты DirectX, перейдя в каталог ~/.wine/drive_c/windows/system32/ и выполнив wine dxdiag.exe .
Если не запускается, тогда копируем файлы dxdiag.exe,dxdiagn.dll в ~/.wine/drive_c/windows/system32/ .

Нужные библиотеки и файлы ищите в каталогах виндов, либо в интернете.

Источник

Why is there no DirectX API for Linux?

Upon considering the driver side implementation for DirectX API on windows systems for modern video cards I was wondering why this implementation is not available on non-windows system, most notably linux. Since there is an obvious absence of this functionality I can only assume there is a good reason which I am blind to, but in my primitive understanding I simply see the DirectX calls as no more than function entry points on the hardware device. And for the record I am not referring to a compatibility layer (most notably WINE, a project I am amazed by every single day) but a library making direct hardware calls. Is it possible to create an open source version of directx? Would it be possible but obscenely difficult?

Читайте также:  Linux mint моргает экран

There is no «absence of this functionality». Linux provides other, non-Microsoft non-proprietary graphics APIs.

@BenVoigt You’ve entirely missed the point of the question. He’s not asking about accelerated 3D graphics rendering functionality, which Linux does have, but about DirectX functionality, which it doesn’t.

Because DirectX is proprietary software licensed by Microsoft. Why would Microsoft make this available on a non Windows operating system and in the process give reasons to potential customers to not use their os? There could be reasons like that in the future, but I sincerely doubt it.

7 Answers 7

AFAIK, the DirectX contains 3 parts

  • Vendor driver (provide low level API defined by DX)
  • DirectX library (use low level API defined by DX to access hardware, provide DirectX API)
  • Software (use DirectX API, ex. game)

There are no driver providing the low level API defined by DX on linux, so even it is possible to provide the DirectX library, but it won’t work without proper vendor driver, and I can’t see if there is any vendor is going to create one for their hardware platform.

Why not just use OpenGL? It supports all the functionality that DirectX does. Do you have a specific reason to use DirectX? As for a reason, Microsoft made DirectX and I guess they didn’t see any need to allow it to run on Linux.

You can run DirectX games in Linux using Wine. You can program XNA on Linux using MonoGame. But all of these use OpenGL to provide hardware-accelerated rendering. AFAIK, OpenGL has been (and probably will be) the only option on Linux for the foreseeable future.

Is it possible to write your own DirectX implementation? Sure — but it involves writing drivers, proprietary knowledge and probably too much cost for anyone to REALLY benefit from it.

EDIT: These days, DXVK is a very real and performant way to run DirectX applications on Linux.

The question comes from a usability standpoint, not so much a development one. If the gaming industry is using DirectX, then I would like to know what impediments there are for the gaming industry to port existing games to linux. Using the exact same hardware, I can run a game natively in one OS, but not the other, so in my naivete I would like to imagine it’s as simple as writing the API layer and then passing everything off to the drivers. Obviously this does not exist so my understanding is wrong, I just want some clarification.

Читайте также:  Кали линукс подключить вай фай

DirectX is a suit of API’s:

  • Direct3D (drawing 3D graphics)
  • DirectX Graphics Infrastructure (enumerating adapters and monitors and managing swap chains)
  • Direct2D (drawing 2D graphics)
  • DirectWrite (fonts)
  • DirectCompute (GPU Computing)
  • DirectSound3D (playback of 3D sounds)
  • DirectX Media (DirectAnimation for 2D/3D web animation, DirectShow for multimedia playback and streaming media, DirectX Transform for web interactivity, and Direct3D Retained Mode for higher level 3D graphics)
  • DirectX Diagnostics (tool for diagnosing and generating reports on components related to DirectX, such as audio, video, and input drivers)
  • DirectX Media Objects (support for streaming objects such as encoders, decoders, and effects)
  • DirectSetup (installation of DirectX components, and the detection of the current DirectX version)

DirectX components deprecated, but still supported

As you can see many parts of the DirectX suit of API’s would need to be rewritten with functionality for Drivers written for Linux. Also some parts of the DirectX suit are likely going to make calls to the Windows OS and that code would have to rewritten for a Linux machine without infringement of the copy-written parts of either DirectX or the Windows OS.

Yes you could write a open source API suit which does the same kind of thing as DirectX for Linux, however without a great knowledge of sound and graphic drivers/support by their manufactures for Linux, it would be a very hard task to do.

However if you question was more of a «Can I get/write something to be able to run games and programs made with DirectX to run on Linux?» in it’s meaning, in short no due to more likely copyright infringement.

Your question is wrong in 2019. DXVK is an implementation of D3D11 and D3D10 implementation for Linux using Vulkan and Wine

Also mesa has native Direct3D 9 implementation but in my knowledge, no one uses it except wine

The work to create a port for DirectX would create the same problems as you encounter in WINE. It will never be the same as on Windows. Derived from that principle you would have to look into OpenGL and related multi-platform libraries.

At this very moment WINE would be your closest medium if you want to accomplish something with DirectX code you already have. Then again, I’m not sure in what manner Visual Studio or plain typing would get you closer yo a fluent environment. The WINE libraries aren’t that far from native, but there always exists emulation, what is acceptable to a certain point in my honest opinion.

If I look at how superbly Final Fantasy XIV ran on full settings on my iMac (2011) I think it’s not that bad to rely on WINE’s implementation. The game exactly rendered as on Bootcamp (Windows) on my iMac.

If you really want to make work on this front you could try to ask WINE Devs at their forums or mailing lists how you could maybe use the implementation of their DirectX compatibility only and use that in your project. Where you maybe can call libraries instead of requesting DirectX through Windows-emulated system calls.

Edit: I fully agree with user956030’s answer too.

Источник

Оцените статью
Adblock
detector