DirectX support

Forums: 

Is there any plan to support even the DirectX Visualization? Developing another dll for rendering such as TKDirectX instead of only TKOpenGL?
I need to integrate the OpenCascade view into WPF application, as with DirectX and Direct3D rendering it is possible to avoid the airpsace issue, I'd like to have this kind of rendering even with OpenCascade.

Sergey Anikin's picture

Dear mach22,

First of all, I apologize that your message did not appear on the forum for some time, due to some purely technical problems!

To answer your question about Direct3D rendering in OCCT, I would like to say the following:

  • Implementing a Direct3D renderer in OCCT in addition to the OpenGL one looks technically interesting - e.g. from the WPF developers' point of view. We considered such a possibility several times internally in the past
  • However, apart from resolving the specific "airspace issue" you have mentioned, we do not see any more or less significant benefits that would justify such large-scale development
  • Direct3D renderer would become platform-specific, while the OpenGL one is not
  • From maintenance point of view, having two renderers is also extra work, as the number of bugs would be doubled more or less.

Due to the above, we currently tend to target the third-party 3D visualization libraries, instead of implementing new in-house 3D renderers.

However, we would be happy to help you in the frames of OCCT customer support services, if you are interested in Direct3D rendering in your OCCT-based application!

Best regards,
Sergey

Nikolai's picture

Hi Sergey
Could you expand a little what you mean by "tend to target the third-party 3D visualization libraries, instead of implementing new in-house 3D renderers"? Is it already planned? How soon? Which libraries are you looking at?

Best regards
Nick

Sergey Anikin's picture

Hello Nick,

We are considering connection to VTK toolkit.

Best regards,
Sergey

Nikolai's picture

Sergey,
I think a third party rendering engine is the right way to go. Rendering technology develops very fast. It looks like a different business. I saw huge engines. OCCT's strength on the other hand is in geometry and modelling. This changes slowly.
It would be great if you could make better modularity between geometry and renderer. It should be relatively easy to change the default renderer. It would only make OCCT more valuable. Some people might need fast animation. Some might need a ray tracer for presentations.
I do not think it should be a runtime switch. Instead it simply should be clear how to modify the code to compile another OCCT/Renderer adaptor
Thanks
Nick

Paul, Le's picture

It seems to me that VTK is a very powerfull MESH visualisation toolkit,
but a geometry viewer produce a TESSELATION not a triangular mesh.

When you visualize a mesh you can modifiy/simplify it this is what you wan to see.
When you visualize a geometry the tesselation must/should be dynamic.

Do you know other geometry viewer component?

Sergey Anikin's picture

Hello letexier,

Some people need to show both CAD geometry and meshes in their new or existing applications based on VTK. And possibility to display OCCT shapes in a VTK 3D view is important for this audience.

Best regards,
Sergey

Shockwave's picture

I'd like to try a way for using VTK for rendering, is there any plan to integrate it in the OCCT Release? Which is the right way for extending OCCT rendering for providind a different way for rendering? It could be implemented using VTK, DirectX, or another rendering Engine.
Could you add a sample for implementing such extension? Or describe which are the main functions to be implemented? I think I must create another dll like TKOpenGl.dll and implement all the functions contained? Which is the simpler way for doing it? Is there a simple interface to implement for using another rendering engine? Could you add a guide for this or a sample?
It will be very usefull if you'd provide another alternative rendering way, adding for example a rendering with VTK.

Sergey Anikin's picture

Dear mach22,

Thinking about smoother integration of an OCCT 3D view into a WPF application, have you ever considered rendering an OpenGL scene to a frame buffer object (FBO) and then drawing its content onto a WPF control? This looks really a reasonable alternative to a separate Direct3D renderer, and it should resolve the airspace issue - certainly, at the cost of redundant frame buffer copying.

Best regards,
Sergey

Shockwave's picture

Normally I create a WNT_Window passing the Handle of the control where render, which could be the right way for having the frame buffer using the visualization package?

Sergey Anikin's picture

Dear mach22,

Please, refer to chapter 5.2.9 of the OCCT Visualization User's Guide, creating a virtual 3D window might be what you need.

Best regards,
Sergey

Paul, Le's picture

Maybe you can use both worlds instead of choosing one.
It seems to me that's the way the ANGLE projet - Almost Native Graphics Layer Engine (OpenGL binding on D3Dx) - use to performs webGL on windows inside firefox is right.

Of course ANGLE is OpenGL/ES not OpenGL... maybe you can add ANGLE what OCCT needs.

But the real question should be; Why don't you use OpenGL on Windows?
All harware vendors deliver good OpenGL specific implementation!

I also remark that, just between the rendering layer and the geometry viewer, there is the tesselator.
Is the recent OpenGL tesselator usable by OCCT (D3D have also a tesselator)?

Sergey Anikin's picture

Dear letexier,

Does this topic answer your last question?

Shockwave's picture

You could add support for DirectX rendering using the OpenGL extension WGL_NV_DX_interop and WGL_NV_DX_interop2, this was developed by NVIDIA and now is supported even from the other vendors like AMD and Intel, so it's quite standard right now for the new graphic cards. As you can see from http://delphigl.de/glcapsviewer/listreports.php

This will add the way for rendering using DirectX with very low cost.
The rendering system made with OpenGl remain the same, but it will be possible to redirect the output to DirectX target as reported in this sample

https://sites.google.com/site/snippetsanddriblits/OpenglDxInterop

Sergey Anikin's picture

Hello mach22,

Thanks a lot for the interesting link and for reviving this discussion in general!

We need to think how to take advantage of this feature, however...
The solution is quite platform-dependent, and we need to have very strong reasons to implement it.

Are you absolutely sure that DirectX rendering would improve OCCT usability under Windows?
Can you please post some references here to prove your point of view?

And sample situations where Windows users (or at least you personally) could benefit from DirectX support would probably put more light on your continuous efforts in this area. Well, integration with WPF is an example, but there are some alternative solutions that do not require any changes in OCCT.

Shockwave's picture

I need to make UI composition with graphical components strong integrated with graphic area, like many cad developed new version with complex UI WPF composition using different controls, ViewCube, Dinamic input, Marking Menus, HUD for display infos and make decision and interaction, complex tree controls in overlay integrated with the cad graphic area.
Using WindowsFormsHost or HwndHost there is the airspace problem, for WPF the graphic area is a totally black hole, it's not possible to make transparent controls over it, not possible to apply effetcs or transitions and have fully integration with the WPF UI Composition.
Even when I open other modal windows on top of the graphic area I have rendering problems, as they are rendered behind, and I need to stop the redraw of graphic area.
I have tried to made a gray fade for the application when I need to disable editing but this prevent HwndHost working over it.
Now I use a Overlay transparent window over the graphic area to place some transparent controls as in this sample
http://blogs.msdn.com/b/pantal/archive/2007/07/31/managed-directx-intero...
but there are syn problems if you use different regions with navigations, and the windows from time to time have rendering problems and this not solve the problem to have effects or transitions. And I think I have performance issue as there are unneded redraw of graphic area.
Using DirectX rendering it could be possible to render with Direct3D and have fully integration with WPF as shown in this article
http://www.ogre3d.org/tikiwiki/Mogre+and+WPF (with different samples)
As the WGL_NV_DX_interop extension seem to be supported now from all major Graphic vendors I think it could be approved soon like a OpenGL standard, from the sample it seem it need a little work to make this works, so it could be an alternative for rendering target on Windows OS. Than you could provide with your package a WPF control that embed this 2 different way:
1) Direct3D based control using DirectX interop for rendering
2) HwndHost control with transparent Overlay Dialog on it

Andrey BETENEV's picture

Hello mach22,

When we developed WPF sample in OCCT, we have discussed (though did not had time to try) one more possibility: to render 3d scene into an off-screen buffer and then map it as bitmap to the WPF window. Do you think it would be feasible?

Andrey

Sergey Anikin's picture

Just to make things simple and clear for everybody, it should be noted that the purpose of WGL_NV_DX_interop/WGL_NV_DX_interop2 extensions is to access DirectX resources (such as vertex buffers and textures) from OpenGL. This becomes important if you have to mix OpenGl and DirectX rendering in an application, and this is obviously not the case either for OCCT or for your application.

Of course, this can be also used to send OpenGL rendering results to DirectX - but...what is the difference between this - and simply rendering to a pixmap and drawing it on a window?
Do we really need DirectX for that? This is the question.

Shockwave's picture

How will you render to a window without using old windowsforms technology without WindowsformHost and HwndHost ??? Of course without creating a new image at every frame and copy all the pixels with great performance problems ?!?!
If you produce only old windowsform style application there is no matter to go further with this discussion.
As is very difficult to create an extension to OpenCascade for rendering with another graphic engine, I think that probably I'll go using another library instead of OpenCascade, or I'll search for a better solution by my own and as you don't see any benefit in it I will not share with you, thanks.

Sergey Anikin's picture

Hello mach22,

Obviously, there is some misunderstanding between us.
My only concern was to double-check that DirectX is really a reasonable solution for embedding OCCT 3D viewer into a WPF application.
I admit that we might lack some experience in this particular area, and this is exactly the reason why I started this discussion. Your opinion is really important and helpful for us!

And certainly you are completely free to share the results of your development or not.
In case if you still want to contribute to OCCT development, can you please report an OCCT Mantis issue for this improvement and follow the contribution workflow?

Kirill Gavrilov's picture

It sounds quite feasible solution if Direct3D and WPF work together well.
OCCT itself requires only minor changes of access level to the fields in OpenGl_FrameBuffer class.

No need to support D3D itself in OCCT - this can be done at application level using WGL_NV_DX_interop extension. Application creates offscreen window, inherits class from OpenGl_FrameBuffer, assigns it to the view for rendering and takes care about D3D part / buffer lock / redraw calls.

Although sounds too overcomplicated to workaround design issues of Microsoft product...

Sergey Anikin's picture

I am pleased to announce a patch for OCCT Mantis issue 24699 that demonstrates how to use OpengL-Direct3D interoperability feature to render the OCCT scene to a Direct3D context in a WPF application:
http://git.dev.opencascade.org/gitweb/?p=occt.git;a=shortlog;h=refs/head...

Thanks to mach22 for the idea!

Everybody is welcome to test the patch and give feedback!

Note that we failed to use this feature with Intel graphics, while it seems to work with more or less up-to-date AMD and NVIDIA hardware.

Shockwave's picture

Can you add a snapshot with *.h files ready to build without using WOK like the snapshot of the version 6.7.2?

When will you include all *.h files in all source code to eliminate the need to use WOK?

Andrey BETENEV's picture

Hello,

When alls CDL are converted to HXX, WOK will not be needed anymore, and snapshot from Git can be used directly for building OCCT.

Andrey

Shockwave's picture

Could you post a snapshot of the branch to test this DirectX funcionality as I can't make the WOK generation working even if I have followed all the steps reported on the guide, it says the the src group is empty.
Thanks

Andrey BETENEV's picture

Hello,

I suppose you can use snapshot of sources of current master (opencascade-6.7.2-dev.tar.gz) to build OCCT, and then use sample from Git branch CR24699_5 (it does not require WOK). I guess you will also need DirectX SDK installed, and tune your environment properly to build the sample.

Andrey