A
anne001
This site gives the c code from robot.c in its
robot-framework-1.3.tar.gz file
http://yallara.cs.rmit.edu.au/~aholkner/Interactive3D/
and this site gives a ruby code for the same program in robot.rb in its
folder sample in version 0.32g
http://www2.giganet.net/~yoshi/
The c program is structured as follows:
void init(void)
void display(void)
void reshape (int w, int h)
void keyboard (unsigned char key, int x, int y)
int main(int argc, char** argv)
{ ...
/* Tell GLUT to create and display the window, with the given title
*/
glutCreateWindow("Robot Arm Demo");
/* Call our own init function to set up the background color and
shading
* model. */
init ();
/* Tell GLUT where each of our functions are. We are passing in the
name
* of each function, which it will then call as required. */
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
/* All initialisation is finished, tell GLUT to run the application
forever
* (or until we tell it to quit) */
glutMainLoop();
....}
and the ruby program is set up as
def init
display = Proc.new {
reshape = Proc.new {|w, h|
keyboard = Proc.new {|key, x, y|
...
GLUT.CreateWindow($0);
init();
GLUT.DisplayFunc(display);
GLUT.ReshapeFunc(reshape);
GLUT.KeyboardFunc(keyboard);
GLUT.MainLoop();
....
I was surprised to find that robot.rb is a litteral translation of
robot.c. No objects talking to each other here!
On the other hand, GLUT has a function ReshapeFunc which requires a
function, and so reshape is going to be a function, etc, so there may
not be a lot of room for ruby like programming.
Is it the case here, that because it is calling opengl and GLUT code,
the structure is going to have to be "C" like, and not "Object OOP"
like? Or is there a way of writing robot.rb a more ruby like way?
robot-framework-1.3.tar.gz file
http://yallara.cs.rmit.edu.au/~aholkner/Interactive3D/
and this site gives a ruby code for the same program in robot.rb in its
folder sample in version 0.32g
http://www2.giganet.net/~yoshi/
The c program is structured as follows:
void init(void)
void display(void)
void reshape (int w, int h)
void keyboard (unsigned char key, int x, int y)
int main(int argc, char** argv)
{ ...
/* Tell GLUT to create and display the window, with the given title
*/
glutCreateWindow("Robot Arm Demo");
/* Call our own init function to set up the background color and
shading
* model. */
init ();
/* Tell GLUT where each of our functions are. We are passing in the
name
* of each function, which it will then call as required. */
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
/* All initialisation is finished, tell GLUT to run the application
forever
* (or until we tell it to quit) */
glutMainLoop();
....}
and the ruby program is set up as
def init
display = Proc.new {
reshape = Proc.new {|w, h|
keyboard = Proc.new {|key, x, y|
...
GLUT.CreateWindow($0);
init();
GLUT.DisplayFunc(display);
GLUT.ReshapeFunc(reshape);
GLUT.KeyboardFunc(keyboard);
GLUT.MainLoop();
....
I was surprised to find that robot.rb is a litteral translation of
robot.c. No objects talking to each other here!
On the other hand, GLUT has a function ReshapeFunc which requires a
function, and so reshape is going to be a function, etc, so there may
not be a lot of room for ruby like programming.
Is it the case here, that because it is calling opengl and GLUT code,
the structure is going to have to be "C" like, and not "Object OOP"
like? Or is there a way of writing robot.rb a more ruby like way?