• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1225

# 3D Cilinder

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 ,

fcco
0
fcco
1 Solution

Commented:
Hi fcco,

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

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

Sunnycoder
0

Commented:
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

Commented:
If your using GLU then there are simple functions built in that allow some decent control:

// global variable

// 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

Author Commented:
Thanks, that is what i was looking for!

regards,

fcco
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.