Solved

3D Cilinder

Posted on 2004-04-26
4
1,214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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 …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

688 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