problem when changing a texture

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

problem when changing a texture

Postby sunnychu220 » Tue Apr 14, 2009 4:06 am

hi everyone:

In my program, I want to change the bitmap of a texture on a key event, but when I call following function to change the texture, nothing happen. has anyone encountered this problem before? Or when the surfaceview is created, texture can't be changed???

private void loadTexture1(int tex,int picid, GL10 gl)
{
Log.d(LOG_TAG, "TriangleRenderer enter loadTexture1()");

Bitmap bitmap;

gl.glBindTexture(GL10.GL_TEXTURE_2D, tex);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_NEAREST);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,GL10.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,GL10.GL_CLAMP_TO_EDGE);
gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,GL10.GL_REPLACE);

InputStream is = mContext.getResources().openRawResource(picid);
try {
bitmap = BitmapFactory.decodeStream(is);
} finally {
try {
is.close();
} catch(IOException e) {
// Ignore.
}
}
GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
bitmap.recycle();

}
sunnychu220
Freshman
Freshman
 
Posts: 5
Joined: Thu Jan 15, 2009 7:52 am

Top

Postby wiederke » Tue Apr 14, 2009 2:40 pm

Hi,

check out if the rendering thread is executing your code. If another thread is executing your code nothing will happen.


Cheers,

Torsten
wiederke
Experienced Developer
Experienced Developer
 
Posts: 72
Joined: Mon Mar 02, 2009 6:46 pm
Location: Germany

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 6 guests