PDA

View Full Version : How to posistion a gluSphere



IMK123
11-27-2007, 05:50 AM
Hello,
I am just starting coding opengl in Windows and I have drawn some lines (a 3d axis)moved/posistion it, rotated it and view it form different posistion and all seems to be working fine. So I moved on to drawing object and have started with a Sphere, this comes up in the middle view window just fine. But what I cant figure out is how I posistion/move it in 3d space..
Help please IMK


void COGLPLOT_1View::DrawSphere( float X, float Y, float Z )
{
glPushMatrix();


glRotatef( X, 1.0f, 0.0f, 0.0f);
glRotatef( Y, 0.0f, 1.0f, 0.0f);
glRotatef( Z, 0.0f, 0.0f, 1.0f);


glLineWidth( 3.0 );
glColor3f( 1, 1, 1);

glBegin( GL_LINE_LOOP );/// don't workglPointSize( 0.0 );
GLUquadricObj *quadric;
quadric = gluNewQuadric();

gluQuadricDrawStyle(quadric, GLU_FILL );
gluSphere( quadric , .5 , 36 , 18 );

gluDeleteQuadric(quadric);
glEndList();

glEnd();


glPopMatrix();

}

Zengar
11-27-2007, 07:21 AM
look into glTranslate

Also, your code is really messed up. First off all, you don't need the glBegin/glEnd pair, glu functions work without it (actually I am surprised you see something on the screen). Then, wha tis glEndList doing there?

IMK123
11-27-2007, 08:43 AM
Zengar Many thanks for the reply,
Well yes the code is a mess and what you see is me trying understanding opengl and trying to get stuff to draw from snippets I have found on the web and in some poor examples.
If you would like to help I would appreciate it...
Do you know if there is a good tutorial on the web, one that is based on practical exapmple rather than the theory?

Again many thanks IMK

k_szczech
11-27-2007, 10:09 AM
Tutorials:
http://nehe.gamedev.net/
Lessons 2-11 should be enough for now.

Advice:
Don't skip lessons :)

Trying to jump ahead of your actual knowledge leads to confusion which leads to loss of time.
That's exactly what happened to you - you ended up with a code you don't fully understand :)
If you use a book, it's important to read all of it. Don't skip first chapter only because there's no code there. First two chapters usually contain things that are very important and will allow you to learn other things at least 2x faster. So don't go straight to coding.

Ryman
03-22-2009, 10:16 AM
Tutorials:
http://nehe.gamedev.net/
Lessons 2-11 should be enough for now.

Advice:
Don't skip lessons :)

Trying to jump ahead of your actual knowledge leads to confusion which leads to loss of time.
That's exactly what happened to you - you ended up with a code you don't fully understand :)
If you use a book, it's important to read all of it. Don't skip first chapter only because there's no code there. First two chapters usually contain things that are very important and will allow you to learn other things at least 2x faster. So don't go straight to coding.

How about saying something that's relevant to his topic instead of directing him to the site everyone in the world knows about when they enter into OpenGL? Your attitude comes off smug and no, reading books from page-to-page does not get you anywhere. Studying and actually having a real world experience with the object are two incredibly different subjects. You waste time just sitting at your home reading a book thoroughly, only to find that you had not retained information at the slightest.

This is why I believe you are inexperienced and this forum's "ranking system" is purely out of wack. You are not by any means knowledgeable of OpenGL nor have you showed any of it.

Let this be a lesson to you, don't post blatant information just to get your forum post count higher. The poster above you deserves much more recognition.Punk.

ZbuffeR
03-22-2009, 11:30 AM
Thanks Ryman, you made a fool of yourself, and made me laugh :)

I just hope you are trolling, as you completely contradict yourself.
k_szczech did post relevant information, and that is not your case.