I need help for simple code

Hi everyone,

i need an OpenGL program that draws many colored objects in response to user input from keyboard.

The following objects are:

If the user input “l”, ot “L” à Draw Line, Color RED.
If the user input “t”, ot “T” à Draw Triangle, Color BLUE.
If the user input “p”, ot “P” à Draw a polyline, Color Orange, select its vertex by MOUSE (number of vertex = 6)

please help me as soon as you can , thank you …

And what is your actual problem?

Can you not write one yourself? Have you even tried to write one yourself? Nobody’s going to write one for you, you know. You’ll have to demonstrate that you’re at least capable of being self-sufficient here.

yes , I have tried to write this code myself and this is what I wrote I need simple help I am a beginner


void myKeyboard(unsigned char theKey, int mouseX, int mouseY)
{
      GLint x = mouseX;
  GLint y = screenHeight - mouseY; // flip the y value as always
      switch(theKey)
  {
          case ‘I’ or ‘L’:
              drawLine(x1, y1, x2, y2);
            setLine(x1, y1, x2, y2, 1.0, 0.0, 0.0);

              break;
      
          case ‘I’ or ‘L’:
              float vertices[] = {
                    x1f,  y1f, // Vertex 1 (X, Y)
                    x2f,  y2f, // Vertex 2 (X, Y)
                    x3f,  y3f  // Vertex 3 (X, Y)
                 };

              glUniform3f(uniColor, 1.0f, 0.0f, 0.0f);
             
              break;

         
                 
          default: 
            break;             
    }
}

Is it true or not and want code for number 3

thanks for help

[QUOTE=d7om_5757;1287041]yes , I have tried to write this code myself and this is what I wrote I need simple help I am a beginner


void myKeyboard(unsigned char theKey, int mouseX, int mouseY)
{
      GLint x = mouseX;
  GLint y = screenHeight - mouseY; // flip the y value as always
      switch(theKey)
  {
          case ‘I’ or ‘L’:
              drawLine(x1, y1, x2, y2);
            setLine(x1, y1, x2, y2, 1.0, 0.0, 0.0);

              break;
      
          case ‘I’ or ‘L’:
              float vertices[] = {
                    x1f,  y1f, // Vertex 1 (X, Y)
                    x2f,  y2f, // Vertex 2 (X, Y)
                    x3f,  y3f  // Vertex 3 (X, Y)
                 };

              glUniform3f(uniColor, 1.0f, 0.0f, 0.0f);
             
              break;
                 
          default: 
            break;             
    }
}

Is it true or not and want code for number 3

thanks for help[/QUOTE]

So what happens when you try to run this code?