View Full Version : cpp and opengl
08-21-2003, 04:28 AM
so far i was using c in combination with opengl. to open a new window i used glut and its callback mechanism.
now i want to work with objects and therefore i have to port my code to c++.
can someone pleases tell me how to do this. especially what to do with the callback routines.
i was very glad to see some sourcecode.
thx in advance, floww
08-21-2003, 05:47 AM
There's no straightforward recipe for porting your C code to C++ objects. Do you know anything about C++? If not, I'd suggest picking up a copy of /Accelerated C++/ by Koenig and Moo.
08-21-2003, 05:50 AM
For callback functions you will still need to use global functions, or static method functions. Normal member functions use a different calling convention due to the need to pass a "this" pointer to the function. This makes it so that they are not usable for standard callback mechanisms.
08-21-2003, 07:17 AM
The Qt tool-kit (http://www.trolltech.com/products/qt/) has OpenGL support: http://doc.trolltech.com/3.2/opengl.html
I have used Qt for a few weeks and my productivity is roughly doubled as compared to when I wrote in MFC.
My application has an internal object-oriented API to wrap around API-specific or OS-specific things.
In case of the window creation, do you want to wrap it using glut or win32?
I gone for pure win32 and the best I could figure out was to pass a pointer to the WndProc func (after a portability typedef'ing). I guess you can do the same with glut callbacks but they will take up more namespace.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.