Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8091811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:09:05+00:00 2026-06-05T20:09:05+00:00

I want to add the option when the menu is called with the right

  • 0

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;
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:09:06+00:00Added an answer on June 5, 2026 at 8:09 pm

    As far as I know, you’ll need to handle it yourself.

    Use the glutKeyboardFunc to get keyboard input, and use glutBitmapCharater to print text to the window.

    So you can keep a global bool changingColor which you can switch to true when 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:

    std::string colorInput;
    
    void keyboard(unsigned char key, int x, int y) {
        if (changingColor) {
            colorInput += key;
        }
     }
    

    And in your rendering function, something like:

    if (changingColor) {
        glRasterPos3f(x, y, z);
        for (auto it = colorInput.begin(); it != colorInput.end(); ++it) {
            glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, *it);
        }
    }
    
    1. glutBitmapCharacter
    2. glutKeyboardFunc
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to add some options when a user presses the menu button, i
I want to add an option to the finder context menu that calls hg
I want to refresh the option menu each time it is called, I have
When selected, a context menu option brings up an AlertDialog. I want the user
i want to add customs icons to my option menu, like that : How
I want to add option menu on my Dialog . I try this .But
I want to add my own sub menu option under the help menu of
On web page I display list of comments, I want to add an option
I have a form and I want to add a select location option. How
I want add label to every row in tableview at right side of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.