Hi, there, I am looking for how to use the vtkWin32OpenGLDXRenderWindow class, and I found a test case from the VTK official code site:
Rendering/OpenGL2/Testing/Cxx/TestWin32OpenGLDXRenderWindow.cxx
But when I follow the example to create the test code, I always get the following error message:
ERROR: In vtkWin32OpenGLDXRenderWindow.cxx, line 164
vtkWin32OpenGLDXRenderWindow (00000205C715E2F0): wglDXRegisterObjectNV failed in RegisterSharedTexture().
Here is my test code (Just copied from the official test case)
#define vtkRenderingContext2D_AUTOINIT 1(vtkRenderingContextOpenGL2)
#define vtkRenderingCore_AUTOINIT 3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL2)
#define vtkRenderingOpenGL2_AUTOINIT 1(vtkRenderingGL2PSOpenGL2)
#include <vtkOpenGLFramebufferObject.h>
#include <vtkTextureObject.h>
#include <vtkWin32OpenGLDXRenderWindow.h>
int main(int, char*[])
{
// Use VTK to create a window handle for the D3D swapchain.
vtkNew<vtkWin32OpenGLRenderWindow> d3dWindow;
d3dWindow->SetSize(400, 400);
d3dWindow->Initialize();
// Create an hidden OpenGL-D3D render window to render in shared texture.
vtkNew<vtkWin32OpenGLDXRenderWindow> renderWindow;
renderWindow->ShowWindowOff();
// Make sure VTK framebuffers are created to register shared texture
renderWindow->Render();
// Register VTK's render framebuffer as shared OpenGL-D3D texture.
const auto handle = renderWindow->GetRenderFramebuffer()->GetColorAttachmentAsTextureObject(0)->GetHandle();
renderWindow->RegisterSharedTexture(handle);
//
return 0;
}