Click here to Skip to main content
15,844,498 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi ,guys,
I am making a program on LINUX , with MONO as GUI and OpenGL/X11/C++ as renderer . The connection between them is P/Invoke.
Worrying about effeciency , I decide not to use CSharp wrapper of OpenGL directly.So the structure is like this :
C++
--------------------------------------------------
                  MONO  C#  GUI

                 / CSharp proxy class
                /
      P/Invoke {
                \
                 \ C++ interface class

                 X11/C++ & OpenGL/C++
-------------------------------------------------

The P/Invoke layer just map functions like :
Init(..) , Update(..) , Render(..) , LoadModel(..)
RemoveModel(..)....

NOT the tiny functions like : glColor(..) , glVertex(..)...

Which sounds good.
The only problem is that , I must pass the MONO window handle(or ptr or so so..) to the renderer system .
X11/C++ can create its own window by calling XCreateWindow(..) , but I already have a window ...
Only I know is that , my mono is bases on X11 , which is comptable with my openGL/C++ layer.
So how to do that ?
THX.
Posted
Comments
Mike Kuchma 1-Dec-12 6:17am    
You can get handle : Form.Handle (or Control.Handle) and pass it further
gxsheng 1-Dec-12 9:19am    
Yes , it is easy to pass handle to the C++ layer, but how to use it ?
A window created with C++ function (XCreateWindow(...)) can be easily manipulated with a handle which is type of 'Window' :
Window wnd = XCreateWindow(...);
then call
glXMakeCurrent( dis , wnd , ctx );
and glXSwapBuffers ( m_dis, wnd );
things will go right.
If I just have a handle from CSharp layer(uint_ptr) , how to get a correspond 'Window' variable?
It there a glx* function which can do this ?
Mike Kuchma 3-Dec-12 10:08am    
In windows i can use it as parent handle for creating windows in native code.
Also you can just create a separate window via pinvoke call (not embedded in form), and update it with timer or else.
P.S. I also had similar problem, i used sfml for this.
Richard MacCutchan 1-Dec-12 6:26am    
If you are worried about efficiency then why are you using C# in the first place? If that is your concern then you should be using C++ for all your coding.
gxsheng 1-Dec-12 9:08am    
I want a crossplatform/popular/simple/easy extensible/niubee GUI , which can not be easily found in C++.
GTK / QT / wgl will take me months to study ...
The most important is that I use DOTNET for over 3 years , I do not want to use an unfamiliar GUI lib.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900