Thread: Cone/Cylinder source

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    8

    Cone/Cylinder source

    Hi,

    I am looking for some source code in C to draw a cylinder and cone using OpenGL (without GLU routines).

    Can someone help?

    Many thanks!

  2. #2
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    869
    Wouldn't the obvious be to look at the GLU routines source and see how it's done?

  3. #3
    ---
    Join Date
    May 2004
    Posts
    1,379
    are glu sources available? I suppose you can download the Mesa source but I'm not sure if that includes the glu library or not (I suppose it would).

  4. #4
    Registered User
    Join Date
    Sep 2005
    Posts
    8
    I had a quick look but could not find the source for this. I thought it would be easier if someone had the snippet of code I needed.

    Thanks anyway

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    What are you really looking for - the basic math which describes the surface of those objects?

  6. #6
    Registered User
    Join Date
    Sep 2005
    Posts
    8
    I have actualy found what I was looking for.

    For the cylinder's side for instance:
    Code:
    float hl = length * 0.5f;
    float a = 0.0f;
    float step = Math::TWO_PI / (float)numSteps;
    
    glBegin(GL_TRIANGLE_STRIP);
    for (int i = 0; i < numSteps; ++i)
    {
        float x = Math::Cos(a) * radius;
        float y = Math::Sin(a) * radius;
        glVertex3f(x,y,-hl);
        glVertex3f(x,y, hl);
    
        a += step;
    }
    glEnd();

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to build, run Boland C++ 6 source file via VS2005?
    By userpingz in forum C++ Programming
    Replies: 2
    Last Post: 05-21-2009, 03:25 AM
  2. Debug into Source
    By lehe in forum C++ Programming
    Replies: 4
    Last Post: 02-18-2009, 10:45 AM
  3. Open Source Licenses
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 10-10-2006, 08:53 PM
  4. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM