Menu

Working Code Awhile Cant Get Work Glut Wondering Anything Fix Include Include Graph1h Usin Q43887613

Write a C++ program that draws a polyline. A polyline is defined as: A series of conected line segments that are treated as a

C++ Graphics

Have been working on this code for awhile and cant get it towork with Glut. Wondering if there is anything I can fix

#include <iostream>
#include “graph1.h”

using namespace std;

//Add Function Prototypes Here
int getNoPoints();
void getPoints(int x[], int y[], int no_points);
void drawPolyLine(int x[], int y[], int no_points);

int main()
{
   //Variable Declaration/Initialization
   int no_points = 0;
   const int MAX_POINTS = 10;
   int x[MAX_POINTS];
   int y[MAX_POINTS];

   //Display Graphics Window
   displayGraphics();

   //Prompt for the number of points
   no_points = getNoPoints();

   //Prompt for the data for the points
   getPoints(x, y, no_points);

   //Draw the polyline
   drawPolyLine(x, y, no_points);

   return 0;
}

//Function Stubs Follows
int getNoPoints()
{
   //Declare local variables
   int no_points = 0;
   //Prompt for the number of points
   cout << “Please Enter Number of Points “;
   cin >> no_points;
   //Return the number of points
   return 0;
}

void getPoints(int x[], int y[], int no_points)
{
   //Declare local variables

   //Using a for-loop, prompt for the coordinates ofeach point and store in arrays x and y
   for (int i = 0; i < no_points; i++)
   {
       cout << “Please EnterCordinates for point” <<i+1;
       cin >> x[i] >>y[i];
   }
}

void drawPolyLine(int x[], int y[], int no_points)
{
   //Declare local variables
   int circle;
   int line;
   int drawCircle(int radius, int center_x, intcenter_y);
   int drawLine(int x1, int y1, int x2, int y2, intwidth);

   //Use 1 for-loop for drawing the red circle on eachpoint
   for (int p = 0; p < no_points; p++)
   {
       circle = drawCircle(5, x[p],y[p]);
       setColor(circle, 255, 0, 0);
   }

   //Use a second for-loop for drawing the lines -remember there is always one less line than there are points!
   for (int w = 0; w < no_points – 1; w++)
   {
       line = drawLine(x[w], y[w], x[w +1], y[w + 1], 1); //std function to draw line
   }
}

Write a C++ program that draws a polyline. A polyline is defined as: A series of conected line segments that are treated as a single object A polyline has the following properties: 1. The number of points are one greater the number of line segments 2. Each point is also an endpoint of a segment. This program will prompt the user for the following data: 1. Prompt the user for the number of points the polyline contains. 2. Prompts the user for the x/y coordinates for the each point Example for the data input prompts are shown below: Enter # of points: 6 Enter x/y coord for Point #1: 10 25 Enter x/y coord for Point #2: 50 65 Enter x/y coord for Point #3: 100 175 Enter x/y coord for Point #4: 200 235 Enter x/y coord for Point #5: 300 275 Enter x/y coord for Point #6: 450 395 Your program will store the x/y coordinates in parallel arrays and then draw a red circle (radius of 5) centered on each point. Your program will then draw a yellow line between each point. An example of each point is shown below: C++ Graphics Show transcribed image text Write a C++ program that draws a polyline. A polyline is defined as: A series of conected line segments that are treated as a single object A polyline has the following properties: 1. The number of points are one greater the number of line segments 2. Each point is also an endpoint of a segment. This program will prompt the user for the following data: 1. Prompt the user for the number of points the polyline contains. 2. Prompts the user for the x/y coordinates for the each point Example for the data input prompts are shown below: Enter # of points: 6 Enter x/y coord for Point #1: 10 25 Enter x/y coord for Point #2: 50 65 Enter x/y coord for Point #3: 100 175 Enter x/y coord for Point #4: 200 235 Enter x/y coord for Point #5: 300 275 Enter x/y coord for Point #6: 450 395 Your program will store the x/y coordinates in parallel arrays and then draw a red circle (radius of 5) centered on each point. Your program will then draw a yellow line between each point. An example of each point is shown below:
C++ Graphics

Expert Answer


Answer to Have been working on this code for awhile and cant get it to work with Glut. Wondering if there is anything I can fix #i…

OR