View Full Version : using command line?

05-01-2005, 07:39 AM
how do i use the command line for input?
lets say typing in "1" would draw a cone and typing in "2" would draw a triangle.

I dont see how it is done using glmainloop() since that puts the event into a loop therefore not listening to the command line...

what do i use?

05-01-2005, 08:06 AM

What Programming language are you using first off

05-01-2005, 09:14 AM
If you are using OpenGL then before your glMainLoop command use the glutKeyboard command.

The syntax is keyboard(unsigned char key, int mx, int my)

key = the key you press
mx = mouse x position
my = mouse y position

this works if you are using glut if you are using win api then I am pretty sure you put your if statements in you main function.

here is the code if you are still a little confused

void keys(unsigned char key, int x, int y)

case '1':
set option to draw cone

case '2':
set option to draw triangle

thats it..

hope this helps

05-02-2005, 01:15 AM

if you want to use the command line before you start the prog
ex. if you want to type in
myprog.exe t(for triangle) or r(for rectrangle), then you should use the argc, argv arrays provided by C.

#include <everything_you_need.h>

main(int argc, char *argv[]){

switch (argv[1]){
case 't':
/* write here the triangle functions*/
case 'r':
/*write here the rectrangle functions*/

this method should only be used if you wish to give the statements in the command line