[android-developers] problem with GL_CLAMP_TO_EDGE
hello guys,
I cannot guarantee my texture size be a power of two, therefore, i'm
using GL_CLAMP_TO_EDGE,
but when i call glTexImage2D, or glutil.teximage2d, i always get the
Opengl Error Code 1281 Invalid Value.
this same setting seems to work on iphone.
does this mean that android only supports power of two texture maps?
if i hard code the bitmap size to be power of two, then my program
will work. otherwise the texture map is black.
see, this is how i set the texture map, it is exactly the same as the
official sample.
thanks
Log.d("Ball Texture","textureID "+textureID+"; lengthx "+lengthx+";
lengthy "+lengthy);
//lengthx=64;
//lengthy=64;
if(textureID==0)
{
int[] textures = new int[1];
gl.glGenTextures(1,textures,0 );
textureID=textures[0];
}
gl.glBindTexture(GL10.GL_TEXTURE_2D, textureID);
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_NEAREST);
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);
Log.d("opengl error 1", "error code "+gl.glGetError());
Bitmap bitmap=Bitmap.createBitmap(lengthx, lengthy,
Bitmap.Config.RGB_565);
Canvas mCanvas=new Canvas(bitmap);
//mCanvas.drawColor(Color.BLUE);
Path path=new Path();
int pointnum=(int) (pointSet.length*0.5);
// Log.d("point cound:",pointnum+";");
path.moveTo(pointSet[0], pointSet[1]);
for(int i=1;i<pointnum;++i)
{
// Log.d("point: ",pointSet[i*2]+";"+pointSet[i*2+1]);
path.lineTo(pointSet[i*2], pointSet[i*2+1]);
}
path.close();
// mC
mCanvas.drawPath(path, ballPaint);
//(lengthx*0.5f, lengthy*0.5f, 30.0f,ballPaint);
ByteBuffer dst ;
dst=ByteBuffer.allocate(bitmap.getHeight()*bitmap.getWidth()*4);
bitmap.copyPixelsToBuffer(dst);
gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGB, lengthx,
lengthy, 0, GL10.GL_RGB, GL10.GL_UNSIGNED_BYTE,dst );
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home