I setup a callback with the letter 'c' trouble with if stateme

using letter 'c' to specify a clipping region - callback

Page 1 of 1

1 Replies - 527 Views - Last Post: 27 January 2009 - 02:56 AM Rate Topic: -----

#1 wartech  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 203
  • Joined: 16-October 06

I setup a callback with the letter 'c' trouble with if stateme

Posted 26 January 2009 - 11:55 PM

Hi Everyone,
I am working with OpenGL and am having a problem with my processC function. I do not know how to setup the case statement. If the letter 'c' is pressed I need clip100() to execute. If the letter 'c' is pressed again and clip100() has already executed I need to execute clip50(). Basically i need the clipping region to be adjusted each time i press 'c'. Can someone please help me get this straight. I am not sure if I am using the glutKeyboardFunc correct.

//function to perform an action when the letter 'c' key is pressed
void processC(unsigned char key, int x, int y) 
{
	switch(key)
	{
		case 'c' :
			clip100();	//clips region
				case NOT SURE WHAT GOES HERE :
					   clip50();	//clips region		 
	}		
}




//Main.cpp

glutKeyboardFunc(processC);



This post has been edited by wartech: 27 January 2009 - 01:01 AM


Is This A Good Question/Topic? 0
  • +

Replies To: I setup a callback with the letter 'c' trouble with if stateme

#2 martin_bg  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 23
  • Joined: 20-March 08

Re: I setup a callback with the letter 'c' trouble with if stateme

Posted 27 January 2009 - 02:56 AM

Hello,

Try adding a status variable. something like:

unsigned int stat = 0;

.....

switch(key) {
  case 'c':
	  switch(stat) {
		case 0:
		  clip100();
		  stat = 1;
		break;
		case 1:
		  clip50();
		  stat = 2;
		break;
		...
	  }
  break;
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1