Ville Krumlinde
Ville Krumlinde

Reputation: 7131

Sharing a texture between direct3d and opengl?

I know mixing OpenGL and DirectX is not recommended but I'm trying to build a bridge between two different applications that use separate graphics API:s and I'm hoping there is a technique for sharing data, specifically textures.

I have a texture that is created in Direct3D like this:

d3_device-> CreateTexture(width, height,
  1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,
  &texture, NULL);

Is there any way I can use this texture from OpenGL without taking a roundtrip through system memory?

Upvotes: 4

Views: 5659

Answers (5)

Goeffrey
Goeffrey

Reputation: 116

YES. As previously posted (see below) there should exists at least one solution. I found two possible solutions:

  1. On nvidia cards a new extension was integrated in the 256 dirvers. see http://developer.download.nvidia.com/opengl/specs/WGL_NV_DX_interop.txt

  2. DXGI is the driving force to composite all windows in Vista and Windows 7. see msdn.microsoft.com/en-us/library/ee913554.aspx

I have not yet made experience with either solution, but I hope I will find some time to test one of them. But for me the first one seems to be the easier one.


[I think it should be possible. In recent windows version (Vista and 7) one can see a preview of any window content in the taskbar (whether its GDI, Direct3D, or OpenGL). To my knowledge OpenGL preview was not supported in earlier windows versions. So at least in the newer version there should be a possibility to couple or share render contexts even between different processes... This is also true for other modern platforms which share render contexts system wide to make different rendering effects.]

Upvotes: 9

WinCloud
WinCloud

Reputation: 193

It's possible now.

Use ANGLE OpenGL API instead native OpenGL.

You can share direct3d texture with EGL_ANGLE_d3d_texture_client_buffere extension. https://github.com/microsoft/angle/wiki/Interop-with-other-DirectX-code#demo

Upvotes: 1

tibur
tibur

Reputation: 11636

I don't think it's possible without downloading the data into host memory and re-uploading it into device memory.

Upvotes: 0

goger
goger

Reputation: 593

No.

Think of it like sharing an image in photoshop and another image viewer. You would need a memory management library that those two applications shared.

Upvotes: -4

Peter Parker
Peter Parker

Reputation: 29735

I think it is not possible. As both have different models of a texture.

You cannot access the texture memory directly without either directX or openGL.

Otherway around: If it is possible, you should be able to retrieve the texture address, its pitch, width and other (hardware dependant) memory layout informations and create a dummytexture in the other system and push the retrieved data into your just created texture object. This is not possible

Obviously, this will not work on any descend hardware, and if so it would not be very portable.

Upvotes: 0

Related Questions