Integrating glut code
by Robert Stewart · in Torque Game Engine · 10/10/2005 (2:13 pm) · 5 replies
I'm fairly new to the whole glut thing. I have this code, what would be the best way to put this in Torque.
int main( int argc, char **argv )
{
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB );
glutInitWindowSize( 512, 512 );
glutCreateWindow( "Dispersion" );
init_opengl();
glut_helpers_initialize();
cb.keyboard_function = keyboard;
cb.idle_function = idle;
camera.configure_buttons(1);
camera.set_camera_mode(false);
camera.dolly.dolly[2] = -1.5;
object.configure_buttons(1);
object.dolly.dolly[2] = 0.0;
object.disable();
camera.enable();
glut_add_interactor(&cb);
glut_add_interactor(&camera);
glut_add_interactor(&object);
glut_add_interactor(&reshaper);
glut_idle(1);
glutCreateMenu( menu );
glutAddMenuEntry( "Increase refraction index [+]", '+');
glutAddMenuEntry( "Decrease refraction index [-]", '-');
glutAddMenuEntry( "Increase dispersion []]", ']');
glutAddMenuEntry( "Decrease dispersion [[]", '[');
glutAddMenuEntry( "Move object [o]", 'o');
glutAddMenuEntry( "Move camera [c]", 'c');
glutAddMenuEntry( "Toggle wireframe [w]", 'w' );
glutAddMenuEntry( "Toggle deformation [d]", 'd' );
glutAddMenuEntry( "Toggle camera spin [space]", ' ' );
glutAddMenuEntry( "Toggle fps display [f]", 'f' );
glutAddMenuEntry( "Reset [r]", 'r' );
glutAddMenuEntry( "Quit [esc]", 27 );
glutAttachMenu( GLUT_RIGHT_BUTTON) ;
b[' '] = true;
glutDisplayFunc( display );
glutMainLoop();
return 0;
}Anyway this is how I tried doing it, it compiles with TGE. So how would I enable glut with tge? and just use the TGE window.About the author
#2
that I am sure are not defined in . When I was compiling the torque, it bumped into heaps of re-definition errors, which were caused by some fatal conflicts with .
Ben, can you continue clarifying it as above?
If the intergration of into torque has to be done, how would we deal with it to clear up the conflicts with gl.h or glu.h, etc?
MANY THANKS to any pointer~
06/05/2006 (4:02 am)
I have got the same problem here. I have been really desperately wanting to use some functions in the Ben, can you continue clarifying it as above?
If the intergration of
MANY THANKS to any pointer~
#3
Since Torque already handles all window/GUI creation and rendering as well as message handling, GLUT is going to collide hard with Torque. Trying to integrate it with Torque will most likely be about as much fun as sticking your head in a vat of acid. Don't do it. =)
As for pulling some individual functions in, I really believe you'd be better off writing your own versions...
06/06/2006 (12:47 pm)
GLUT has its own application framework and was only intended for use as a learning tool or for simple demo code. (I've always avoided it because I feel it is a crutch -- OpenGL isn't THAT hard to figure out...)Since Torque already handles all window/GUI creation and rendering as well as message handling, GLUT is going to collide hard with Torque. Trying to integrate it with Torque will most likely be about as much fun as sticking your head in a vat of acid. Don't do it. =)
As for pulling some individual functions in, I really believe you'd be better off writing your own versions...
#4
Now that it's become clear that we ought to avoid using glut, I think more focus should be stuck on the opengl2d3d.cc. Is opengl2d3d a complete wrapper of most used opengl functions?
Moreover, I have been trying to find out the function that Torque uses to creating the OpenGL window in the source code, but really ended up with no any clue. GLUT uses glut_init() to create its own opengl window for scenegraph rendering but Torque does not use glut. I am desperate to know where Torque hides it as I plan to include camera video as the backgroupd of the opengl window with sky and fog swithed off.
Please give me some ideas. Thanks.
06/06/2006 (10:00 pm)
Thanks a lot, Kevin, for detailing it. Now that it's become clear that we ought to avoid using glut, I think more focus should be stuck on the opengl2d3d.cc. Is opengl2d3d a complete wrapper of most used opengl functions?
Moreover, I have been trying to find out the function that Torque uses to creating the OpenGL window in the source code, but really ended up with no any clue. GLUT uses glut_init() to create its own opengl window for scenegraph rendering but Torque does not use glut. I am desperate to know where Torque hides it as I plan to include camera video as the backgroupd of the opengl window with sky and fog swithed off.
Please give me some ideas. Thanks.
#5
First a disclaimer: I am not a Torque engine guru by any stretch of the imagination! Keep that in mind! =)
I'm not entirely sure what you're trying to implement, but it kinda sounds like something that you'd want a custom render control for. Take a look at fxRenderObject and see if that helps (or at least points you in the right direction).
Good luck!
Edit: I'm really curious now... Someone with more engine experience, please tell us more about opengl2D3D: Where did it come from? How does it interface with Torque? Thanks!
06/07/2006 (2:47 pm)
@Dane:First a disclaimer: I am not a Torque engine guru by any stretch of the imagination! Keep that in mind! =)
Quote:Is opengl2d3d a complete wrapper of most used opengl functions?If you browse through the source for the opengl2D3D library, you'll find that this is old old stuff. If I recall my history correctly, this is likely based on the Direct3D OpenGL wrapper that someone at Microsoft wrote to replace the 3DFX OpenGL implementation for glQuake. I can't say if it's "complete" since back then it only supported a subset of OpenGL functions and only version 1.1 at that. At any rate, I don't think it will be helpful to focus on it. *shrug*
I'm not entirely sure what you're trying to implement, but it kinda sounds like something that you'd want a custom render control for. Take a look at fxRenderObject and see if that helps (or at least points you in the right direction).
Good luck!
Edit: I'm really curious now... Someone with more engine experience, please tell us more about opengl2D3D: Where did it come from? How does it interface with Torque? Thanks!
Associate Kyle Carter