From 8dd15da0d9b71346f5dec44c4d7ff5b4fa7d257c Mon Sep 17 00:00:00 2001 From: Amritansh Singhal <33527566+Eerie16@users.noreply.github.com> Date: Thu, 31 Oct 2019 21:46:32 +0530 Subject: [PATCH] Used glutKeyboardFunc instead of menu for switching algos --- .../Curve Geneartion/hermiteBezier.cpp | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/ComputerGraphics/Curve Geneartion/hermiteBezier.cpp b/ComputerGraphics/Curve Geneartion/hermiteBezier.cpp index ac68bfb..c140566 100644 --- a/ComputerGraphics/Curve Geneartion/hermiteBezier.cpp +++ b/ComputerGraphics/Curve Geneartion/hermiteBezier.cpp @@ -211,21 +211,6 @@ void myDisplay() glFlush(); } -void mainMenu(int id) -{ - typeMode = id; - if (typeMode > 7) exit(0); - glutPostRedisplay(); -} - -void createMenu() -{ - glutCreateMenu(mainMenu); - glutAddMenuEntry("Control Polygon",1); - glutAddMenuEntry("Cubic Bezier Form (OpenGL)", 5); - glutAddMenuEntry("Exit",8); - glutAttachMenu(GLUT_RIGHT_BUTTON); -} void init() { @@ -291,6 +276,22 @@ void reshape(int w, int h) ww = w; wh = h; } +void myKey(unsigned char key,int x,int y) { + + if(key=='h') { + glFlush(); + // CyrusBeck(); + typeMode=1; + // bezier(); + glutPostRedisplay(); + } + if(key=='b'){ + glFlush(); + typeMode=2; + // hermite(); + glutPostRedisplay(); + } +} int main(int argc, char **argv) @@ -306,10 +307,12 @@ int main(int argc, char **argv) glutMouseFunc(myPick); glutMotionFunc(myMouseMove); glutReshapeFunc(reshape); + glutKeyboardFunc(myKey); + init(); - createMenu(); +// createMenu(); glutMainLoop(); return 0; -} \ No newline at end of file +}