Jump to content
  • Advertisement
Sign in to follow this  
aqing99

OpenGL What's wrong with it? Thanks

This topic is 5160 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I built a program with OPENGL to draw three circles on three planes ,XOY-plane, XOZ-plane and YOZ-plane.However, the result of running program is that only a circle was drawed ,which is on XOY-plane.where are other two circles? some wrong with my program? Thank you for giving some advices to me !! My program as follows: void CBall::DrawBall() { GLUquadricObj* qobj=gluNewQuadric(); gluQuadricDrawstyle(qobj,GLU_LINE); gluQuadricNormals(qobj,GLU_NONE); gluDisk(qobj,m_radius,m_radius,24,1); //m_radius = 1.0f gluDeleteQuadric(qobj); } void CBall::DrawContaintor() { glColor3f(0,.75f,0); //Circle on XOY-plane DrawBall(); //Circle on XOZ-plane glPushMatrix(); glRotated(90,1.0,0.0,0.0); DrawBall(); glPopMatrix(); //Circle on YOZ-plane glPushMatrix(); glRotated(90,0.0,1.0,0.0); DrawBall(); glPopMatrix(); } CMyView::OnDraw() { ......... CBall myBall; .......... myBall.DrawContaintor(); .......... } Thank you very much!!

Share this post


Link to post
Share on other sites
Advertisement
You've drawn the 3 circles on top of each other. Try translating as well as rotating.

ie

glPushMatrix();
glTranslatef(...); //do this
glRotated(90,1.0,0.0,0.0);
DrawBall();
glPopMatrix();

Share this post


Link to post
Share on other sites
glTranslatef is ok in my program,but glRotate is wrong.
modified as follows:

glPushMatrix();

DrawBall();

glRotatef(10.0,1.0f,0.0f,0.0f);

DrawBall();
glPopMatrix();
the result of running program is the same as :
glPushMatrix();

DrawBall();

glTranslatef(0.0f,1.0f,0.0f);

DrawBall();
glPopMatrix();

So strange!!

Share this post


Link to post
Share on other sites
Ignore my answer. I thought you'd just rotated your circle on its axis. I should get some sleep before answering programming questions [smile]. Your original code does look OK to me, so possibly the problem is elsewhere.

BTW, you might want to try glDisable(GL_CULL_FACE) if you haven't already. It's possible backface culling has rendered your circles invisible.

Share this post


Link to post
Share on other sites
Hello,

I didnt read the code THAT good ill admit, but where exactly are you setting your camera. If you are setting your camera facing DIRECTLY at one of the circles, and the other 2 circles are PERFECTLY rotated, you will be seeing the edge of the circle (its not a shere) and thus will seem invisiable (no thickness). If thats the case, try rotating the camera around a bit or allowing freeform camera.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!