need help in drawing rectangles nd triangles

hello every one
im try to make a rectabgle and triangle by clicking on the icons of rectangle and triangle
here is my code if any one can help


#include<stdio.h>
#include<conio.h>
#include<glut.h>

int s,t;
int screenHeight=800, screenWidth = 600;
void display()
{
	glClear(GL_COLOR_BUFFER_BIT );     //Screen clear karnay k lia
	
	glColor3f(1.0,1.0,0.30); // current pen color
    	
	glRecti(500,0,600,800); // panel
	
	glColor3f(0.0,0.0,0.0);
	glRecti(510,600,570,700);//Rectangle
	

	glBegin(GL_POLYGON);         //for triangle
			 
	        glVertex2f(510,440);    //points for triangle  left
		       
			glVertex2f(570,440);		//right
			glVertex2f(540,540);       //top
			     
			glEnd();	       // yahan tak
		
		
	glColor3f(1.0,0.0,0.0);
	glRecti(520,350,560,380);
    
	glColor3f(0.0,1.0,0.0);
	glRecti(520,280,560,310);
	
	glColor3f(0.0,0.0,1.0);
	glRecti(520,250,560,220);
	
	glColor3f(0.0,0.0,0.0);

	glBegin(GL_LINES);
		glVertex2i(500,410);
		glVertex2i(600,410);
		glEnd();

	
	glFlush();           //Graphics show k lia
}
void myInit()
{
	int screenHeight=800, screenWidth = 600;

	glMatrixMode( GL_PROJECTION ); 
	
	glLoadIdentity();
	
	gluOrtho2D(0,screenWidth,0,screenHeight);
}

void myMouse(int button,int state,int x,int y)
{
 if(button==GLUT_LEFT_BUTTON) 
  { 
	  if(x>510&&x<570 && y>screenHeight-600&&y<screenHeight-700)//if square
	  {
	/*s=1;//for square
	glColor3f(0.0,0.0,0.0);
	glRecti(250,350,350,450);
    glFlush(); 
	  }
 
	  
   if(510<=x<=570 && screenHeight-440<=y<=screenHeight-540)//if triangle
   {
	/*t=1;//for triangle
	glColor3f(0.0,0.0,0.0);
	glBegin(GL_POLYGON);
		glVertex2f(250,350);
		glVertex2f(330,350);
		glVertex2f(285,450);
		glEnd();
		
		glFlush();*/
   }
  
 }
	
}

void processMenuEvents(int option)
{
/*	switch(option)
	{
	case 1:
		if(s==1)
		{
	glColor3f(1.0,0.0,0.0);
	glRecti(250,350,350,450);
	glFlush();
		}
		if(t==1)
		{
			glColor3f(1.0,0.0,0.0);
	glBegin(GL_POLYGON);
		glVertex2f(250,350);
		glVertex2f(350,350);
		glVertex2f(275,400);
		glEnd();
		glFlush();
		}
		break;
	case 2:
	if(s==1)
		{
	glColor3f(0.0,1.0,0.0);
	glRecti(250,350,350,450);
	glFlush();
		}
		if(t==1)
		{
			glColor3f(0.0,1.0,0.0);
	glBegin(GL_POLYGON);
		glVertex2f(250,350);
		glVertex2f(350,350);
		glVertex2f(275,400);
		glEnd();
		glFlush();
		}
		break;
	case 3:
		if(s==1)
		{
	glColor3f(0.0,0.0,1.0);
	glRecti(250,350,350,450);
	glFlush();
		}
		if(t==1)
		{
			glColor3f(0.0,0.0,1.0);
	glBegin(GL_POLYGON);
		glVertex2f(250,350);
		glVertex2f(350,350);
		glVertex2f(275,400);
		glEnd();
		glFlush();
		}
		break;
	}*/
}
void main()
{
	int screenHeight =800, screenWidth =600;
	
   
	glutInitWindowPosition(0,0);
     	 glutInitWindowSize(screenHeight,screenWidth); //window ka size    
	
	
	glutCreateWindow("Window");

     myInit();
	
	//glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE);// color scheme rgb ha or double buffer use ho rhe han
	
	glClearColor(1.0,1.0,1.0,1.0);       //windows background color

        glutDisplayFunc(display);     //for displaying object
	
       glutMouseFunc(myMouse); 
		glutCreateMenu(processMenuEvents);
		glutAddMenuEntry("Red",1);
		glutAddMenuEntry("Green",2);
		glutAddMenuEntry("Blue",3);
		glutAttachMenu(GLUT_RIGHT_BUTTON);

	
	glutMainLoop();
	
	getch();
}


You do not load the model view matrix

Help with what ? You don’t say what the problem is.

problem is that i want that every time rectangle should be draw when i click on the rectangle(Square) created by me on right side
but i click where ever on screen rectangle is drawn
main problem is there i think
"void myMouse(int button,int state,int x,int y)
{
if(button==GLUT_LEFT_BUTTON)
{
if(x>510&&x<570 && y>screenHeight-600&&y<screenHeight-700)//if square
{
/*s=1;//for square
glColor3f(0.0,0.0,0.0);
glRecti(250,350,350,450);
glFlush();
}

if(510<=x<=570 && screenHeight-440<=y<=screenHeight-540)//if triangle
{
/*t=1;//for triangle
glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2f(250,350);
glVertex2f(330,350);
glVertex2f(285,450);
glEnd();

	glFlush();*/

}

}

}
"

Can you draw a picture of what you are trying to do because your words are not helping much.
Include position of what you are trying to draw and where.

actual im applying this if condition and its not working right
if(x>510&&x<570 && y>screenHeight-600&&y<screenHeight-700)//if square
its has check condition for square
if mouse is clicked on these coordinates square should be drawn but this is not hapening
i clicked wherever in window…this if coditions get true
i dont know why because accordingto my knowledge its right
plz help me quickly
its my assignment

You start off the thread with one thing and endup asking questions about another. Pehaps you need to spend a little more time actually thinking things through before rushing a post here.

Typical of your problems is this line

if(x>510&&x<570 && y>screenHeight-600&&y<screenHeight-700)//if square

This is nonsene. If we use 800 as the value to screenheight, your condition statement is:

if Y > 800-600 and Y < 800-700…

which simplifys to:

if Y > 200 and Y < 100 …

which is never going to work.

If you know you are checking for a rectangular region then surely you should be able to spot that kind of mistake. How? By taking your time over the code, debugging and testing phases. Additionally take your time when posting questions.