Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: I need help for simple code

  1. #1
    Newbie Newbie
    Join Date
    May 2017
    Posts
    2

    Exclamation 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 ..

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,726
    And what is your actual problem?

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    Posts
    1,726
    Quote Originally Posted by d7om_5757 View Post
    i need an OpenGL program that draws many colored objects in response to user input from keyboard.
    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.

  4. #4
    Newbie Newbie
    Join Date
    May 2017
    Posts
    2
    yes , I have tried to write this code myself and this is what I wrote I need simple help I am a beginner

    Code cpp:
    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
    Last edited by Dark Photon; 05-12-2017 at 08:30 AM.

  5. #5
    Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    388
    Quote Originally Posted by d7om_5757 View Post
    yes , I have tried to write this code myself and this is what I wrote I need simple help I am a beginner

    Code cpp:
    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
    So what happens when you try to run this code?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •