Click here to Skip to main content
13,254,077 members (54,181 online)
Rate this:
Please Sign up or sign in to vote.
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 :
                      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(..)

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 ?
Posted 30-Nov-12 20:03pm
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.
gxsheng 1-Dec-12 9:10am
The C++ render cycle runs in independent thread , the speed can be much higher than GUI cycle.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171114.1 | Last Updated 1 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100