opengl-3d-vision-bridge icon indicating copy to clipboard operation
opengl-3d-vision-bridge copied to clipboard

Compiling under Windows with MinGW

Open runnerpack opened this issue 9 years ago • 15 comments

I recently got 3D Vision working on my setup, and I'm so excited to finally be able to write stereoscopic games and apps without MS' bloated dev tools! I can't thank you enough for developing this!

However, I'm having trouble compiling the demo in Windows (7; 64-bit). My MinGW/MSYS installation is using gcc 4.5.2. I have all of the requisite libraries (although possibly not the right versions), and I've modified your build script to point to them. I'm using the June 2010 version of DXSDK, SDL2 2.0.4, and I just downloaded NVAPI a few minutes ago (it's R367, I believe). Here's the error output. Here's what I did to your build script. Any help you can provide will be much appreciated.

runnerpack avatar Sep 17 '16 14:09 runnerpack

Are you sure you're using g++ instead of gcc to compile?

tliron avatar Sep 17 '16 17:09 tliron

Yes (as you can see in the attached build.sh script). I've tracked down most of the errors as being the result of Nvidia using a Microsoft-specific thing called "SAL". There is what looks like the beginnings of an attempt to work around this in MinGW (sal.h), but it's not working. I've been trying to modify that to work, but it seems like a hopeless, uphill battle... If only I could get the version of NVAPI you used (or the latest, pre-SAL version) :disappointed:

runnerpack avatar Sep 17 '16 18:09 runnerpack

It does seem that at this moment R331 is no longer available on NVIDIA's site. The earliest version is R352. Perhaps you can try that oldest one and move forward to see when the break was introduced.

If that fails, contact me privately and I will be able to send you the R331 copy I have, just so you can get things to work.

But obviously we would want this to work with the latest version. I would be immensely happy if you could help with this! Yes, it looks like an uphill battle, but I'm sure it solvable with some patchery/hackery. Don't give up hope, this whole project was an exercise in beating one's head against the wall.

tliron avatar Sep 17 '16 18:09 tliron

R352 gives the same errors :disappointed: I have two ideas for how to proceed:

  1. Work from the other end and see if there's a newer/different version of gcc that can deal with the SAL (and other MS-specific) stuff - possibly helping to create such a version.
  2. Take the R331 version you have and the latest version, use diff to make a patch, then manually edit the patch to remove all of the SAL stuff (well, you did say "patchery/hackery", right? :wink:)

runnerpack avatar Sep 17 '16 23:09 runnerpack

https://dl.dropboxusercontent.com/u/122806/nvidia-331.zip

Please keep me posted on progress!

tliron avatar Sep 17 '16 23:09 tliron

Comparing the two, I see that they both actually have built-in code to disable the SAL stuff, but you have to define "__NVAPI_EMPTY_SAL", so I added that to the build script and got much further. It started giving me grief about two main()s being defined, and that led me to realize that I was using an older version of mingw. I had to convert the build script to a batch file to use the newer version, and now I'm having trouble compiling ~~your custom OpenGL bindings~~ EDIT: oops, it's actually the 3D Vision wrapper itself that isn't working. Here's the error.

runnerpack avatar Sep 18 '16 01:09 runnerpack

Okay, I commented that line out just to get it to continue, and I got the two main()s thing again; removed "-lmingw32" and that fixed it. Now, I get these weird things

runnerpack avatar Sep 18 '16 01:09 runnerpack

Progress! I used R331, and it compiled with only the ".drective" warnings! However... the resulting exe crashes after the window is created :disappointed: Here's what is spits out:

Welcome to the OpenGL / 3D Vision bridge demo!
Creating OpenGL/Direct3D bridge...
 We are in windowed mode
 Window size: 800, 600
 Linked to WGL API
 WGL NV_DX_interop supported on this platform
 This operating system uses WDDM (it's Windows Vista or later)
 Activated Direct3D 9Ex (WDDM)

runnerpack avatar Sep 18 '16 01:09 runnerpack

You can safely ignore those .drective warnings.

Well, looks like you're very close! It's hard for me to help from here, our setups are too different (I don't even have easy access to Windows right now; I use MinGW on Linux and cross-compile). But I promise you that this does work. :) Persist and I'm sure you'll be able to crack it.

tliron avatar Sep 18 '16 05:09 tliron

Actually, I could use some help with the QueryInterface() line I had to comment out. Even if the lack of it isn't the source of the crash bug, I'd still like to have whatever functionality it's there to provide.

So far, I've only found reference to such a construct compiling fine in MSVC, but not gcc (and why), but you and I are both using gcc, so why does it compile for you and not for me? (It doesn't help that I'm only vaguely aware of what an "interface" even is or what "querying" one does).

runnerpack avatar Sep 18 '16 14:09 runnerpack

Update: it's crashing at opengl_3dv.c line 219 - the call to GetAdapterDisplayMode().

runnerpack avatar Sep 18 '16 20:09 runnerpack

Hm, this is a rather simple call to get the display format. I really can't imagine what would go wrong! Could be that the ABI changed somehow?

tliron avatar Sep 19 '16 15:09 tliron

Would it be possible to use SDL to get the display format?

runnerpack avatar Sep 21 '16 00:09 runnerpack

Actually, since this seems to be the first call to the DX9 API, I imagine that there is a more core problem here, and that even if this gets solved the rest of the calls will fail...

tliron avatar Sep 21 '16 01:09 tliron

I tend to agree, and I'm becoming more and more convinced that the line I had to comment out would be returning an error message that shows there's either something fundamentally broken about my system (which is unlikely, because DirectX games and applications run fine), something wrong with the SDK files, something weird GCC is doing with them, or some other problem. Do you remember what version of GCC you originally cross-compiled this with?

runnerpack avatar Sep 21 '16 23:09 runnerpack