Solved

3D Cilinder

Posted on 2004-04-26
4
1,211 Views
Last Modified: 2013-12-06
Hi all,

i'm starting with opengl, i would like to draw a 3d cilinder or cube, has anyone a good example about how this is done??

a good resource/starting page would be ok also ,

thanks in advance,

fcco
0
Comment
Question by:fcco
4 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10918176
Hi fcco,

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=05

I highly recommend these tutorials
http://nehe.gamedev.net/

Sunnycoder
0
 

Expert Comment

by:Aeken
ID: 11087064
hi, fcco,

u mean that u wan code that generated using open GL library or any openGL code that can generate cube and cylinder?
0
 
LVL 1

Accepted Solution

by:
greg_pendlebury earned 50 total points
ID: 11255031
If your using GLU then there are simple functions built in that allow some decent control:

// global variable
GLUquadricObj *quad;

// in your init code
quad = gluNewQuadric();

// To draw a cyclinder
gluCylinder(quad, BASE_WIDTH, TOP_WIDTH, HEIGHT, SLICES, STACKS);

The numbers you choose for slices and stacks reflect how close to a true cyclinder you get. (imagine them as slices of pie around the centre).
SLICES = 3 is a triangular prism
SLICES = 4 is a rectangular prism, or a cube if HEIGHT = BASE_WIDTH = TOP_WIDTH
etc...

higher number of slices gets you closer to a true circular cross section.

Stacks is head up the side of the cylinder. Depending on your shading model you could get a way with having quite a low number here because it won't be curved.

You can play around with your shape by altering BASE_WIDTH and TOP_WIDTH to make frustrams, and pyramids and such.
0
 
LVL 2

Author Comment

by:fcco
ID: 11257747
Thanks, that is what i was looking for!

regards,

fcco
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question