Mipmap Generation

by Mike » Wed, 15 Jul 2009 00:26:53 GMT


Sponsored Links
 I've created a simple heightmap renderer for Android, and am at the
point where I'd like to apply textures to the terrain. I've had
success with applying a simple texture but there is an unbearable
amount of texture aliasing visible, I guess because there are no
mipmaps for the texture. I could not find any way of automatically
generating mipmaps as all the usual OpenGL methods seem to be
unsupported.

Have any of you figured out how to generate mipmaps on Android? Do we
need to write our own implementation to to it?

Thanks,
Mike

--~--~---------~--~----~------------~-------~--~----~



Mipmap Generation

by Mike » Wed, 15 Jul 2009 04:08:55 GMT


 Well I've come up with a solution, but I'd still like to hear from
others if you have a better way of doing it.

private int loadTexture(GL10 gl, Bitmap bmp)
{
        int level = 0;
        int size = bmp.getHeight();

        int[] textures = new int[1];
        gl.glGenTextures(1, textures, 0);
        int textureId = textures[0];

        gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);

        while(size >= 1)
        {
                GLUtils.texImage2D(GL10.GL_TEXTURE_2D, level, bmp, 0);

                if(size == 1)
                        break;

                level++;
                size /= 2;
                Bitmap bmp2 = Bitmap.createScaledBitmap(bmp, size, size, true);
                bmp.recycle();
                bmp = bmp2;
        }

        return textureId;
}



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Mipmap Generation

by Nightwolf » Sat, 25 Jul 2009 00:30:56 GMT


 In texture loading function please try the following

gl.glGenTextures(1, texID, 0);

gl.glBindTexture(GL10.GL_TEXTURE_2D, texID[0]);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,
GL10.GL_LINEAR_MIPMAP_LINEAR);




--~--~---------~--~----~------------~-------~--~----~



Mipmap Generation

by nea » Fri, 31 Jul 2009 03:05:45 GMT


 Hi

I am also currently trying to get MipMaps to work and eventually this
is the thread that pops up several times in the search ^^'.

The problem I have with your posted solution, it does not work for me.
As soon as I try it your way I do not get any texture at all. It just
stays white. What could be the problem, as it should be the normal way
to to MipMaps by adding the new images to the according level. But as
soon as I add a second level it stays white. I define
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,
GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,
GL10.GL_LINEAR_MIPMAP_NEAREST);

before, but still it won't work.

Does anybody has a solution or a hint what could help here?

Thanks in advance.

Regards





--~--~---------~--~----~------------~-------~--~----~



Mipmap Generation

by Ante » Sat, 05 Sep 2009 00:49:51 GMT


 Hi Mike.

This works in the emulator:
if(gl instanceof GL11)
{
    gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP,
GL11.GL_TRUE);
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
}

Though, this doesnt help if your device doesnt support the GL11
implementation.

I tried your mip mapping function but without success. You wouldnt
happen to have a working example?

Best regards,
Ante




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Service operation

I do a ((Context)thingy).bindService(...) from within the onCreate
callback of an Activity.  I've observed that the onServiceConnected()
callback of my associated ServiceConnection does not execute
immediately, but rather, is delayed until after the Activity resumes,
or more precisely, after return from the onResume() callback of the
Activity.

I discovered this the hard way (through a null pointer exception)
because I was unable to use the Service (I call a method in the
Service to start a Thread) immediately upon return from the bindService
() call.

I assume this is normal behavior, but I don't understand why, and I
further assume that there is a good reason for it and that I would
benefit from understanding it.

I'm guessing that maybe the Service isn't eligible to run because
there are fewer than 1 processes bound that are in an active state.
(?)  But once it starts, if I then start the Thread within, it
continues to completion of its task, even if the Activity calls
unbindService() and terminates first!  I don't mind that behavior
(it's what I want to happen), but I want to know whether I can
generally rely on it.  I'm seeking some wisdom from the forum.  Please
help me clear my fog on all these points.

TIA

2. Prolonged touching (>30s) in one area causes onTouchEvent to stop registering?

I'm trying to do something in my app where you have to hold your
finger on the screen for more than 30 seconds. After about 30 seconds,
it stops sending onTouchEvents for that part of the screen, almost
like a "dead zone."

Tested on a motorola droid, and is there any way to stop this from
happening?

3. Windows Driver for Nexus One so that Adb can detect the phone

4. set imageView

5. Suggestion: Math floating point library for Android

6. Elliptic Curve cryptography in Androi

7. Help me!! The fb0 no space left on device..