cnjinhao / nana

a modern C++ GUI library
https://nana.acemind.cn
Boost Software License 1.0
2.29k stars 331 forks source link

Integrate nana with Directx #672

Open edgarbernal5 opened 1 year ago

edgarbernal5 commented 1 year ago

Hi! I want to know if nana supports DirectX graphics api, so far I've seen examples of using with OpenGL, not sure if will work.

I have a ScenePanel that has a widget where at the end will be used as a surface. I must have the size of the widget in order to create a swap chain, I cannot be able to! Every time I get the size returns x=0, y=0. Here is the code:

ScenePanel::ScenePanel(nana::window window, bool visible) : nana::panel(window, nana::rectangle(), visible) { m_place.bind(*this); m_renderWidget.create(m_place.window_handle());

m_renderWidget.show();
auto wh = reinterpret_cast<HWND>(m_renderWidget.handle());
m_place.div("margin=20 <view>");
m_place["view"] << m_renderWidget;
m_place.collocate();

auto renderSize = m_renderWidget.size();

SurfaceWindowParameters parameters;
parameters.Width = renderSize.width;
parameters.Height = renderSize.height;
parameters.WindowHandle = wh;

Surface surface(GetDevice(), parameters);
surface.Initialize();

}

Somewhere in the main window I have this: m_place->dock("pane1", "f1");

Anyone has struggled with that situation? Thanks for you time!! I'd really appreciate this!

edgarbernal5 commented 5 months ago

Finally I managed to get it run! Later I'll post a tutorial with github demo project.