What's wrong with it? Thanks
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!!
You've drawn the 3 circles on top of each other. Try translating as well as rotating.
ie
ie
glPushMatrix();glTranslatef(...); //do thisglRotated(90,1.0,0.0,0.0);DrawBall();glPopMatrix();
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!!
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!!
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement