1

I am playing on nana library for gui.

I also have to use opengl, But there is one example for opengl, which is for windows. Link

I am using ubuntu linux. above example call reinterpret_cast<HWND>(fm.native_handle());

I finally have found it.

The root window attaches to the OS/Windowing system native window, native_handle returns the handle of native window. In a certain system, the native_window_type can be converted into system native handle type.

auto reinterpret_cast<HWND>(root_widget.native_handle()); //Windows
auto reinterpret_cast<Window>(root_widget.native_handle()); //Linux/X11

I may get hint between HWND, Window.

If I use Window(X11), can I implement to opengl on nana library?

rawwar
  • 4,834
  • 9
  • 32
  • 57
geeeek
  • 375
  • 2
  • 13

1 Answers1

2

To create an app that uses OpenGL you need, very very simplified, at least four things:

  • A pixel format, describing colors-size, Z-buffer size, multisampling, etc. In Windows you need wglChoosePixelFormatARB. In Linux, glXChooseFBConfig.
  • A context. In Windows wglCreateContextAttribsARB requires a HDC and in Linux glXCreateContextAttribsARB a Display, which is not the same as a window.
  • How to set the context as current.
  • How to "swap buffers".

You can learn more here and here.
If you find documentation on these matters for OpenGL version < 3.2, please don't use it. Stick to "modern" OpenGL.

The issue with nana is that the example you linked seems to work well for Windows (but old OGL). Nothing is told about Linux. I think you should dig into the source code of nana searching for what it returns on native_handle(). Better you prefer to ask in its forum.

The above functions I showed are not directly available, you must query their function pointers.
And many of modern OGL functions require also to retrieve their function pointers. See the wiki

Ripi2
  • 7,031
  • 1
  • 17
  • 33