• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Making Polygons in XCode using Glut?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making Polygons in XCode using Glut?


  • Subject: Making Polygons in XCode using Glut?
  • From: li cheng <email@hidden>
  • Date: Fri, 02 Nov 2012 03:04:40 +0400


So in my computer class i am having trouble making a code for Glut using X Code. This project is on creating a polygon with you entering the points. Here is the brief summary he gives us:

In this assignment you are going to get input from the console for the points of a polygon and then draw the polygon using GLUT. The user will first enter the number of points for the polygon. You will then have a loop for the user to enter the x and y values for each of the points. Then you will draw the polygon.
Overview

The points will be stored in an array. A Point has x and y values. Create a Point using a struct

struct Point{
float x, y;
};

Here are some other variables you will need:

Point p; // p is of data type Point
Point points[10]; // Array of up to 10 Points
int numPoints = 0; // keep track of how many point are entered

You will need to use cin and cout in main to get input from the console (see your other programs for how to do this).

Store the points by calling addPoints(x, y);

void addPoints(float x1, float y1)
{
p.x = x1;
p.y = y1;
points[numPoints] = p;
numPoints++;
}

You use p.x and p.y to reference the x and y points of p. points[ ] is the array of points. In-between the [ ] is the index for the array. In this case we are using numPoints which starts at 0 and gets incremented ++ each time a new point is added.

The rest is just creating a draw(Point startingP, Point endingP) function that is called numPoints times from the Display function were you pass the starting and ending point of the line. Inside the draw function you will need to draw the line.

Can someone please tell me a step by step process in which I can complete the lab, or give me the code and explain it? Thanks so much!


--
С уважением
Михаил
Поиск товаров

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Making Polygons in XCode using Glut?
      • From: Crispin Bennett <email@hidden>
  • Prev by Date: Re: Generating NSManagedObject code
  • Next by Date: Re: Making Polygons in XCode using Glut?
  • Previous by thread: "member access into incomplete type"
  • Next by thread: Re: Making Polygons in XCode using Glut?
  • Index(es):
    • Date
    • Thread