PDA

View Full Version : somthing about sky and glusphere



beginner620824
03-01-2003, 02:49 AM
What's the advantage and disadvantage to draw the sky using gluSphere compared to using GL_STRIP_TRIANGLE?
I found if i rotate the sphere around its center it doesn't look like it is rotating because the texture on it is still. Is there a way to make a gluSphere "rotating" around itself?

Thanks

shinpaughp
03-01-2003, 04:33 PM
Show your code where you apply the texture to the sphere along with your transformations.

[This message has been edited by shinpaughp (edited 03-01-2003).]

Miguel_dup1
03-01-2003, 05:30 PM
gluSphere is too slow... Try a sky dome or a sky box. I use a combination os both...

I have some samples on my site you can download.
http://cheo.resnet.wayne.edu/miguel/

beginner620824
03-01-2003, 07:28 PM
Originally posted by shinpaughp:
Show your code where you apply the texture to the sphere along with your transformations.

[This message has been edited by shinpaughp (edited 03-01-2003).]

HI,
The transformation/rotation has no problem since i replaced the ball with other shape such as a cylinder, it works as expected.

Below is a cut from my Loadtexture() which is a part of initializatoin
glBindTexture(GL_TEXTURE_2D, texture[i]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[i]->sizeX, TextureImage[i]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[i]->data);

.......
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
glBlendFunc(GL_SRC_ALPHA,GL_ONE); // Set The Blending Function For Translucency
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black
glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); obj=gluNewQuadric();
gluQuadricNormals(obj, GLU_SMOOTH);
gluQuadricTexture(obj, GL_TRUE);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);


then in my render loop i call glBindTexture(GL_TEXTURE_2D, texture[7]) before call gluSphere(); (7 is one of my texture).

shinpaughp
03-01-2003, 08:20 PM
Well, I certainly agree with Mancha about slowness of gluSphere for drawing sky, especially since only a small part will actually be visible. I was more curious why you couldn't get your texture to rotate with gluSphere. Below is simple sample and texture will rotate with sphere. Not that you need it now.




GLUquadric* quadsphere = gluNewQuadric();
glRotatef(angle1, 0.01, 1.0, 0.0);
glTranslatef(250.0, 0.0, 0.0);
glRotatef(angle2*2, 0.03, 1.0, 0.0);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, texName[0]);
gluQuadricTexture(quadsphere, GL_TRUE);
gluSphere(quadsphere, 2.0, 15, 15);
gluQuadricTexture(quadsphere, GL_FALSE);
glDisable(GL_TEXTURE_2D);

shinpaughp
03-02-2003, 03:29 PM
The problem is that you were trying to duplicate effort, which also caused problems.

Make these changes within InitGL:




{
obj=gluNewQuadric();
// gluQuadricNormals(obj, GLU_SMOOTH);//commented out
// gluQuadricTexture(obj, GL_TRUE);//commented out
// glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);//commented out
// glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);//commented out
}


and thses changes within DrawGLScene




glPushMatrix();
// glEnable(GL_TEXTURE_GEN_S);//commented out
// glEnable(GL_TEXTURE_GEN_T);//commented out
glTranslatef(0,0.3,0);//*/xpos,ypos,zpos); if to xpos, the sky will follow you, you never break the sky
//glRotatef(-90,0,0,1);
glRotatef(sky_rotate_angle,0,1,0);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, texture[7]);
gluQuadricTexture(obj, GL_TRUE);//added this
gluSphere(obj,0.3,300,300);//// change 0.3 to something bigger to make it a sky
gluQuadricTexture(obj, GL_FALSE);//added this
//gluCylinder(obj,0.3,0,.4,32,32);
// glDisable(GL_TEXTURE_GEN_S);//commented out
// glDisable(GL_TEXTURE_GEN_T);//commented out
glPopMatrix();


where appropriate. You should then be able to see your sphere with sky texture rotating in the middle of the room. Also, appears to be faster.


[This message has been edited by shinpaughp (edited 03-02-2003).]

beginner620824
03-03-2003, 04:44 AM
HI shinpaughp:

Thank you very much. It works!
I am making a skydome by a downloaded program exe and src. That program uses 600 as the radius to call the Dome and works well. But when my program calls it with only 100, a black hole apears on the far end of the ball (if greater, the whole ball is invisible). The hole becomes smaller and finally goes to 0 as i approach it.
I guss this is because opl cull off something which is considered too far. But what makes the difference of these two programs? It seems to me the dimension in ogl is relative, but i read the 2 src throughly and didn't find any declaration of such thing. Could you once again give me a hand?

Best regards, liuya

Miguel_dup1
03-03-2003, 05:05 AM
Try looking at my code in the link above...


Originally posted by beginner620824:
HI shinpaughp:

Thank you very much. It works!
I am making a skydome by a downloaded program exe and src. That program uses 600 as the radius to call the Dome and works well. But when my program calls it with only 100, a black hole apears on the far end of the ball (if greater, the whole ball is invisible). The hole becomes smaller and finally goes to 0 as i approach it.
I guss this is because opl cull off something which is considered too far. But what makes the difference of these two programs? It seems to me the dimension in ogl is relative, but i read the 2 src throughly and didn't find any declaration of such thing. Could you once again give me a hand?

Best regards, liuya

shinpaughp
03-03-2003, 07:11 AM
In the set up of projection (glFrustum, glOrtho, gluPerspective) there are near and far parameters. The far parameter is too small and causing the hole.

But, you should definitely take a look at Mancha's web site. Very realistic terrain and sky! And, for a skybox, probably much much better way.