I want to add the option when the menu is called with the right click on mouse to change the values of a colour by user input.
I tried cin>> RED1; but it doesn’t identify cin.
I have no clue how to make this work except by giving a fixed value to change the colours. How can I achieve user input on this case?
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#define _USE_MATH_DEFINES
#include <cmath>
#include <gl/glut.h>
GLfloat angle = 0.0;
static int RED1 = 1, GREEN1 = 3, BLUE1 = 0, RED2 = 2, GREEN2 = 2, BLUE2 = 1;
static int MENUsub, Face1, Face2, i, LINES;
static int SELECIONA = 2, f = 0, VALOR = 0, SOLID = 0, LINE = 1;
static double NoFaces = 32, ihc, cordX = 1, cordY = 1, cordZ = 1;
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
}
void creatMENU(void)
{
Face1 = glutCreateMenu(MENU);
glutAddMenuEntry("Change Colour Values", 1);
MENUsub = glutCreateMenu(MENU);
glutAddSubMenu("Face 1", Face1);
glutAddMenuEntry("Sair", 0);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
void MENU (int OPT)
{
if(OPT == 0)
{
exit(0);
}
else
{
switch(OPT);
{
case 1 :
//cin>> RED1;
RED1 = 2;
break;
}
}
}
As far as I know, you’ll need to handle it yourself.
Use the
glutKeyboardFuncto get keyboard input, and useglutBitmapCharaterto print text to the window.So you can keep a global bool
changingColorwhich you can switch totruewhen the menu item is selected. You can then render the input using a rectangle or something. You might have a keyboard function that looks a little like this:And in your rendering function, something like: