PDA

View Full Version : Modular implementation of graphics capabilities



alexbcg
05-18-2014, 01:20 PM
Hi,

I am working on a program which simulates the interactions of gas molecules in a box. The algorithms work well but it is time to work on a graphical output.

The code has several classes and I have written code which seems correct for all of them. For example, the system class "has" an instance of the class box and an instance of the class particle as private attributes. The opengl code to draw a box is implemented in the draw method for the box class and the code to draw a particle is implemented in the particle class, the system class then calls all these methods in the right order to draw the scene.
The "graphics" class also has a few methods to manage keyboard events and window resizing.
All this code worked fine when nothing was modular (so the opengl code is good) but the nature of the assignment was to get us to practice object orientated concepts.

My problem arises when I try to use glut to use these functions in the main (an instance of System in the form of systeme and an instance of Graphisme in the form of graphisme have already been created).


glutDisplayFunc(systeme.dessine());
glutKeyboardFunc(graphisme.gestionClavier();
glutReshapeFunc(graphisme.gestionFenetre());
glutTimerFunc(25, systeme.evolue(),0);
glutMainLoop();

the evolue() method advances the system by a time interval dt, detects collisions and calculates new positions/speeds of particles.
The gestionClavier() and gestionFenetre() methods are already a problem even before building the project because they require arguments anyway (a constant char for gestionClavier (keyboard management) and width&length for gestionFenetre (window resize management) which I cannot really give.

On the first error (for the first line of code copied here) I get "No matching function for call to "glutDisplayFunc"... what can I do to get things to work!??

Many Thanks

Alex