PDA

View Full Version : Why is there a hole on my sphere?



Phil Huang
12-19-2004, 06:50 PM
The hole is where the light is directed at. When I rotate the coordinate, it seems I can see through the hole?! However if I switch froM GLU_FILL to GLU_LINE, it looks just fine. I didn't use any material or texture. Can anyone help?
void __fastcall TMain::CreateLight(GLfloat r, GLfloat g, GLfloat b)
{
m_lightAmb[0]=r; m_lightAmb[1]=g;
m_lightAmb[2]=b; m_lightAmb[3]=1.0f;

m_lightDif[0]=1.0f; m_lightDif[1]=1.0f;
m_lightDif[2]=1.0f; m_lightDif[3]=1.0f;

m_lightSpe[0]=0.8f; m_lightSpe[1]=0.8f;
m_lightSpe[2]=0.8f; m_lightSpe[3]=1.0f;

m_lightPos[0]=1.0f; m_lightPos[1]=.0f;
m_lightPos[2]=-1.0f; m_lightPos[3]=0.0f;

glLightfv(GL_LIGHT0,GL_AMBIENT,m_lightAmb);
glLightfv(GL_LIGHT0,GL_DIFFUSE,m_lightDif);
glLightfv(GL_LIGHT0,GL_SPECULAR,m_lightSpe);
glLightfv(GL_LIGHT0,GL_POSITION,m_lightPos);

glShadeModel(GL_SMOOTH);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
}

void __fastcall TMain::AddSphere()
{
GLUquadricObj* quadObj;
glNewList(Sphere,GL_COMPILE);
quadObj=gluNewQuadric();
gluQuadricDrawStyle(quadObj,GLU_LINE);
gluQuadricNormals(quadObj,GLU_SMOOTH);
gluSphere(quadObj,1,8,8);
glEndList();
}

SeskaPeel
12-20-2004, 12:18 AM
This is not an advanced question.
You should read the spec of glLightfv, and maybe you'll see that it expects to find an array of four floats.

SeskaPeel.

rgpc
12-20-2004, 05:02 AM
Originally posted by SeskaPeel:
This is not an advanced question.Seskapeel is correct - this shouldn't be in the advanced forum...



You should read the spec of glLightfv, and maybe you'll see that it expects to find an array of four floats.

SeskaPeel.You mean like [0], [1], [2] & [3]? As in the code provided? :p

SeskaPeel
12-20-2004, 06:53 AM
Seems like I misread some lines of code ...
I may have been answering too fast too :)

I'll have to apologize for that, and ask for more code, because all that's present here should work fine.

rpgc I hate you :p

SeskaPeel.

zeckensack
12-20-2004, 07:26 AM
If the sphere intersects the near clipping plane, it will be, well, clipped. Could be the problem here. Try reducing the radius.

rgpc
12-20-2004, 10:07 PM
Originally posted by SeskaPeel:
rpgc I hate you :p

SeskaPeel.You're welcome. :D