views:

49

answers:

1

I have drawn a sphere and I am able to rotate it using java and opengl libraries for an android application. This part works perfectly. Now I am trying to texture a globe image onto the sphere. The image covers the entire sphere but then the continents are compressed and appear as a single line. What do I have to do to get the image properly textured on to my sphere?

For implementing the texture I am using the following code

gl.glEnable(GL10.GL_TEXTURE_2D);
texturesBuffer = IntBuffer.allocate(1);

gl.glGenTextures(1, texturesBuffer);

Bitmap texture = SphereTexture.getTexture(mContext,R.drawable.earth);

gl.glBindTexture(GL10.GL_TEXTURE_2D, texturesBuffer.get(0));
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, texture, 0);

texture.recycle();

public static Bitmap getTexture(Context context, int resourceId) {

    Bitmap bitmap = null;
    try {
        bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId);
        return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),  bitmap.getHeight(), yFlipMatrix, false);
    }
    finally {
        if (bitmap != null) {
            bitmap.recycle();
        }
    }
 }
A: 

You can do that by XOR the color on both the sides of the line with the color on the otherside taking pixel by pixel.

Nageswara Rao V

Nageswara Rao
I am sorry, I am extremely new to this. Could you please elaborate a bit.
Evelyn Jeba