the problem if am pressing 'a' key iwant point render in display screen but it is not work
why i dont know some body tell me about codeproject to solution this problem
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <cstdlib>
#include <glut.h>
#include <iostream>
void createMenu(void);
void menu(int value);
float translateX = 0,translateY = 0;
static int win;
static int menyid;
static int transformation;
static int objectcolor;
static int Backgroundcolor;
static int val = 0;
GLsizei wh =720;
GLsizei ww = 900 ;
bool Point=false;
void drawLine()
{
glPointSize(5);
glTranslatef(translateX, translateY, 0);
glColor3f(1.0,0.0,1.0);
glLineWidth(6);
glBegin(GL_LINES);
glVertex2f(600.0,20.0);
glVertex2f(30.0,20.0);
glEnd();
glFlush();
}
void display(void)
{
glClearColor (1.0, 1.0, 1.0, 1.0);
glClear (GL_COLOR_BUFFER_BIT);
glLoadIdentity();
drawLine();
glPointSize(10);
glColor3f(1.0,0.0,1.0);
if(Point)
{
glPointSize(10);
glColor3f(1.0,0.0,1.0);
glBegin(GL_POINTS);
glVertex2f(55.0,60.0);
glEnd();
glFlush();
}
glFlush();
}
void reshape(int w, int h)
{
glViewport(0,0,(GLsizei)w,(GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D ( 0.0, (GLdouble)ww, 0.0, (GLdouble)wh ); glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void keypress (unsigned char key, int x, int y)
{
int modifiers = glutGetModifiers();
switch (key)
{
case 'a':
case 27:
Point=true;
glutPostRedisplay();
break;
}
}
void specialfun(int k, int x, int y)
{
if (k == GLUT_KEY_LEFT)
translateX -=1; else if (k == GLUT_KEY_RIGHT) translateX +=1;
else if (k == GLUT_KEY_UP)
translateY +=1; else if (k == GLUT_KEY_DOWN)
translateY -=1; glutPostRedisplay();
}
void spindisplay(void)
{
glutPostRedisplay();
}
void createMenu(void){
transformation = glutCreateMenu(menu);
glutAddMenuEntry("scaling", 1);
glutAddMenuEntry("rotation", 2);
objectcolor = glutCreateMenu(menu);
glutAddMenuEntry("yellow", 3);
glutAddMenuEntry("black", 4);
Backgroundcolor = glutCreateMenu(menu);
glutAddMenuEntry("red", 3);
glutAddMenuEntry("blue", 4);
menyid = glutCreateMenu(menu);
glutAddSubMenu("Transformation", transformation);
glutAddSubMenu("Object color", objectcolor);
glutAddSubMenu("Background color", Backgroundcolor);
glutAddMenuEntry("Quit", 0);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
void menu(int value){
if(value == 0){
exit(0);
glutDestroyWindow(win);
}else{
val=value;
}
glutPostRedisplay();
}
int main(int argc, char **argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(800,768);
glutInitWindowPosition(0,0);
createMenu();
glutCreateWindow("ASSIGNMENT2");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keypress);
glutSpecialFunc(specialfun);
createMenu();
glutAttachMenu (GLUT_RIGHT_BUTTON);
glutMainLoop();
}