Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gluSphere Texture Mapping

451 views
Skip to first unread message

mchristyuk

unread,
Aug 1, 2007, 5:41:04 AM8/1/07
to
Hi all,

I have what seems a simple problem that is driving me up the wall.. if
anyone out there has some suggestions I would really appreciate it.

I am using JOGL and would like to create a pseudo-atmosphere on a
planet.

My planet is a texture mapped sphere and looks fine.

My "atmosphere" is a nother sphere slightly larger than the planet
sphere.

My plan was to texture map the INSIDE of the atmosphere sphere with a
cloud texture.. therefore when I am on the ground and look up I see
blue sky and clouds.

I have managed to texture map the clouds on to the sphere.. however
when ever I "enter" that sphere I can not see the inside of the
sphere... and hence no textures... everything only appears on the
outside of the sphere.

I have tried all combinations of culling, clockwise/counter clockwise
faces, depth tests on and off, Quadric orientation and modes.. but
nothing seems to help.. all I manage to do is change what happens on
the outside of the sphere... nothing I seem to do shows the inside of
the sphere...

Help!

Cheers

Mark

jbwest

unread,
Aug 1, 2007, 10:01:02 AM8/1/07
to

"mchristyuk" <mark.ch...@gmail.com> wrote in message
news:1185961264....@22g2000hsm.googlegroups.com...

turn off culling, make sire you are using FRONT_AND_BACK gl.glMaterial.

glusphere may force culling, I don't know.

jbw


fungus

unread,
Aug 1, 2007, 11:12:32 PM8/1/07
to
On Aug 1, 11:41 am, mchristyuk <mark.christ...@gmail.com> wrote:
>
> I have managed to texture map the clouds on to the sphere.. however
> when ever I "enter" that sphere I can not see the inside of the
> sphere... and hence no textures... everything only appears on the
> outside of the sphere.

glDisable(GL_CULL_FACE)

--
<\___/>
/ O O \
\_____/ FTB. Remove my socks for email address.

mchristyuk

unread,
Aug 2, 2007, 3:03:10 AM8/2/07
to
Hi Guys,

Thanks for those answers.. however I have tried all of them and
they're not making any difference to the internals of my sphere.

The code I have at the moment is:

gl.glEnable(GL.GL_TEXTURE_2D);
gl.glDisable(GL.GL_DEPTH_TEST);

double radius = dc.getGlobe().getEquatorialRadius()+2000000;

gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
glu.gluQuadricOrientation(quadric,GLU.GLU_INSIDE);
texture.bind();
gl.glFrontFace(GL.GL_CW);
glu.gluQuadricTexture(quadric,true);
gl.glDisable(GL.GL_CULL_FACE);
glu.gluSphere(quadric,radius,300,300);
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glDisable(GL.GL_TEXTURE_2D);
gl.glFrontFace(GL.GL_CCW);

This is held in a display list.. which I wouldn't have thought would
make much difference...

Cheers

Mark

vampi...@gmail.com

unread,
Aug 2, 2007, 7:38:43 PM8/2/07
to
I have this C++ and hopefully it is the same as Java.

sphere = gluNewQuadric();
gluQuadricTexture(sphere, GL_TRUE);
gluQuadricOrientation(sphere, GLU_INSIDE);

CULL_FACE shouldn't be the problem.

I also think there is a way that you can have it be both inside and
outside. (don't quote me on that, you might have to draw 2 spheres)

Hope this helps

vampi...@gmail.com

unread,
Aug 2, 2007, 7:49:47 PM8/2/07
to
And later on I use...

glDisable(GL_DEPTH_TEST);

glPushMatrix();
glTranslatef(x, y, z);
glRotatef(-90, 1, 0, 0);

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 15);

gluSphere(sphere, 80, 10, 10);

glDisable(GL_TEXTURE_2D);

glPopMatrix();

glEnable(GL_DEPTH_TEST);


I don't know if this will help because it looks like you are doing
basically same thing. (Not sure if function order will matter or not)


The only other thing I can think to give you is my opengl environment
set up.

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA ,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);

glDisable (GL_LIGHTING);
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);

glDisable(GL_DITHER);

mchristyuk

unread,
Aug 6, 2007, 12:02:24 PM8/6/07
to
Hi,

Thanks for the feedback. I think the problem may be external to my
code.. I'm writing my OpenGL layer inside another OpenGL application..
and whilst everything else is behaving normally I have a sneaking
suspicion that the parent app is mucking the OpenGL states
somewhere..

Cheers

Mark

Jason.M....@gmail.com

unread,
Sep 20, 2007, 1:36:06 AM9/20/07
to
I need to map a 2d image onto a sphere in JOGL, any ideas on how to do
this?

jbwest

unread,
Sep 20, 2007, 9:28:48 PM9/20/07
to

<Jason.M....@gmail.com> wrote in message
news:1190266566.1...@k79g2000hse.googlegroups.com...

>I need to map a 2d image onto a sphere in JOGL, any ideas on how to do
> this?
>
[snip...]
>
>

It's all about putting the right texture coordinates on the vertices that
make up the sphere.

for 2d textures with [i,j] coordinates at every vertex;

The "poles" -- all the vertices there -- will have a J texture coordinate
of [0 or 1] (approximately -- you need to deal with texel centering).

The vertices around the "equator" will have a J of 0.5

Get it ?

The X coordinates start a approximately 0 at the "prime meridian" and go all
the way aroudn the globe to approx 1 at the end (duplicating the coordinates
at the "prime meridian").

I'll leave edge effects and correct centering ot texels to you.

You should easily be able to use automatic texture coordinate generation, if
your project permits it.

jbw


Jason.M....@gmail.com

unread,
Sep 23, 2007, 11:37:39 PM9/23/07
to
On Sep 20, 8:28 pm, "jbwest" <jbw...@comcast.net> wrote:
> <Jason.M.Brews...@gmail.com> wrote in message

JBW, I have figured out what I needed, and can easily map an image to
my sphere now. The weird thing is, I can't get the sphere to rotate
though, I always look at the sphere from a distance, i.e. I keep it at
origin, and translate back from it.

I looked at some samples, is this the correct logic to rotate a sphere
in JOGL?
I use an Animator that calls display continually
in display method.....
z++;
gl.glEnable(GL_TEXTURE_GEN_S);
gl.glEnable(GL_TEXTURE_GEN_T);

gl.glBindTexture(.....)
gl.glPushMatrix();
gl.glRotatef(z,1.0f,0.0f,0.0f);

I print out z, and it is continually incrementing, but the sphere
never actually rotates, any reason why it is not rotating?

thanks
JB

Jason.M....@gmail.com

unread,
Sep 23, 2007, 11:38:46 PM9/23/07
to
> drawSphere();
0 new messages