Jump to content
  • Advertisement
Sign in to follow this  
Braden

My sphere is not appearing on the screen. T.T

This topic is 5011 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

Outdated code paste... Look for newer paste at bottom. [Edited by - Braden on March 4, 2005 10:53:52 AM]

Share this post


Link to post
Share on other sites
Advertisement
glLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ)

in a nutshell, the "eye" is the camera pos, the "center" is the position of what you're looking and "up" is the up direction :) This way you should simply set your camera to look at the sphere position :)

Share this post


Link to post
Share on other sites
Here is what I have now which is different:

...
glLoadIdentity();
glLookAt(0,0,0,0,0,-10,0,2,0);
...
glTranslatef(0,0,-5);
gluSphere(quadratic,5.0f,32,32);
...

I still can't see my sphere though. Thanks for the glLookAt() explanation. I am pretty sure I am looking at the area where the sphere /should/ be now (if it were there) ;)

Braden

Share this post


Link to post
Share on other sites
The gluLookAt is fine, but the last three would be 0,1,0 though I don't think that would cause the problem. You have ... between the gluLookAt and the glTranslate. What is in there. BTW it is gluLookAt, not glLookAt:) I think maybe the translation isn't starting from the origin. In reality, this gluLookAt is kind of useless because the camera when you glLoadIdentity defaults to the same position/view, pos(0,0,0) looking down z axis(0,0,-10).

Share this post


Link to post
Share on other sites

Here is my code:

void loadInterface(void)
{
glShadeModel(GL_SMOOTH);
glClearColor(0.2f,0.5f,1.0f,1.0f);
glClearDepth(1.0f);
glClearDepth(1.0f);
glClearStencil(0);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_TEXTURE_RECTANGLE_ARB);

glLightfv(GL_LIGHT1,GL_AMBIENT,LightAmbient);
glLightfv(GL_LIGHT1,GL_DIFFUSE,LightDiffuse);
glLightfv(GL_LIGHT1,GL_POSITION,LightPosition);
glEnable(GL_LIGHT1);
glEnable(GL_LIGHTING);

quadratic=gluNewQuadric();
gluQuadricNormals(quadratic,GLU_SMOOTH);
gluQuadricTexture(quadratic,GL_TRUE);

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

progloc=5;
}

void drawInterface(void)
{
glViewport(0,0,gwidth,gheight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f,(GLfloat)gwidth/(GLfloat)gheight,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0,0,0,0,0,-10,0,2,0);
//glBindTexture(GL_TEXTURE_RECTANGLE_ARB,textures[10].texID);
glColor4f(1.0f,1.0f,1.0f,0.4f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);

//glTranslatef(0,0,-10);
gluSphere(quadratic,5.0f,32,32);

glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_BLEND);

//gluLookAt(-10,-10,0,0,0,0,0,1,0);
SwapBuffers(hDC);
}

I still don't see the sphere. =(

Share this post


Link to post
Share on other sites
Quote:
Original post by Braden
...
gluLookAt(0,0,0,0,0,-10,0,2,0);
...
//glTranslatef(0,0,-10);
gluSphere(quadratic,5.0f,32,32);
...


Try uncommenting that translate. gluSphere() draws the sphere at the origin, which is where your camera is positioned, so you are inside it. If you have back-face culling on you won't see the inside of the sphere.

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!