shineworld 68 Posted March 3 Hi all. Recently I've been using VTK to manage 3D Views. Unfortunately, I've found only info on how to use it with QT Pyside6 with QVTKRenderWindowInteractor. I will hope to use DelphiVCL (my first choice) or DelphiFMX + VTK. Do you have any idea on how to use VTK in a TForm or any other Windows-based window object? Share this post Link to post
DelphiUdIT 132 Posted March 3 I don't know VTK, but I don't think that is a revolutionary approach to "surface" drawing. In the web nothing about Pascal, Delphi or FPC related is available. Surely it's needed a handle to a graphic window. And should be a function that assign this. Start from here. If there is something about "C" or "MFC" sample, will be available usefull info. Share this post Link to post
JonRobertson 39 Posted March 3 I have not heard of VTK and decided to take a peak. The documentation references examples using MFC and C++ Builder. However, the Win32 folder is no longer present in the Examples\GUI folder in their git repo. Searching the history of the repo, the C++ Builder examples were removed five years ago. I suspect getting support for using VTK in Delphi will be challenging, since the group stopped supporting C++ Builder years ago. That said, the old code is available via git history. For example, vtkBorlandRenderWindow.cpp. This snippet is from GetRenderWindow: // Stuff the renderwindow into our window FRenderWindow = vtkWin32OpenGLRenderWindow::New(); FRenderWindow->AddObserver( vtkCommand::AbortCheckEvent, FAbortCallback); FRenderWindow->SetParentId(Parent->Handle); Without a deep dive into the source, it appears VTK is using OpenGL for rendering and setting the OpenGL's window parent to a form. If I wanted to use VTK from Delphi, I would attempt: Use a supported open source C++ compiler to build the C++ source to either OBJ or LIB. There are multiple OBJ file formats. Delphi can link with OMF86 or COFF for 32-bit and ELF or COFF for 64-bit. See Link object file (Delphi) for more details. Translate the VTK headers to Pascal, which will be a challenge. From what little I have read, VTK appears to use features only available in newer versions of C++. There are some open source projects for converting headers, although they may not be able to convert the VTK headers. The second one specifically does not convert C++ headers. I included it because it uses libclang, which I suspect would provide a better translation for the "pure C" portions of headers. https://github.com/yunkot/HeaderParser https://github.com/neslib/Chet There are others. Search engines are your friends. ;) Well, most of the time. Another alternative is Python4Delphi, since VTK can be used from Python and appears to actively support use from Python. An advantage of this approach is the ability to "prototype" using standalone Python and then incorporate into a Delphi app via Python4Delphi. You have likely seen Pyscripter's posts in this forum. https://github.com/pyscripter/python4delphi Share this post Link to post
shineworld 68 Posted March 3 Yes, maybe I explained myself wrongly. I am using Python + VTK + QT. VTK is a very good Python library for working with 3D scenes. QT is terrible for me and I love DelphiVCL e DelphiFMX UI for Python. Unfortunately, to do the rest of the interface, I had to switch from Python4Delphi (DelphiVCL or DelphiFMX) to QT precisely because there is a lack of coverage to OpenGL in them, and however, found no way to integrate VTK to DelphiVCL/DelphiFM. So I was asking if anyone had already done this or could point me to how to create a VTK component that would appear in an area of a Python DelphiVCL TForm, as in the example in the picture below. Share this post Link to post
DelphiUdIT 132 Posted March 3 2 hours ago, shineworld said: I am using Python + VTK + QT. LOL, I miss we are in a P4D section, sorry. I cannot help you , I never used Python4Delphi. Share this post Link to post
stijnsanders 35 Posted March 3 I have never done much 3D (which I regret), I haven't done any Vulkan, but I just happen to remember something from when I was trying to port the old pixelcity to Delphi, that the wglCreateContext and wglMakeCurrent calls are used for more than only OpenGL. Could it be that they are the key to get Vulkan working with VCL? Share this post Link to post
JonRobertson 39 Posted March 3 2 hours ago, DelphiUdIT said: LOL, I miss we are in a P4D section, sorry. Same LOL here. My first reply would have been much shorter had I paid attention to the forum. One of the dangers of reading from Recent Activity, I suppose. Share this post Link to post
shineworld 68 Posted March 4 Perhaps the solution is to watch what VTK do with tkinter to implement the vtkTkRenderWindowInteractor. I will study and try to do a close thing with a compatible DelphiVCL Windows based component. https://github.com/Kitware/VTK/blob/master/Wrapping/Python/vtkmodules/tk/vtkTkRenderWindowInteractor.py Share this post Link to post