Android 在OpenGl 2.0中删除纹理
我正在开发一个android应用程序,当使用vuforia SDK检测到图像目标时,它会增强3D模型。同时增加了9个三维模型。我已经使用GLES20.glGenTextures(1,textureHandle,0)方法加载了纹理。所以我调用了下面的方法九次,并将纹理id的整数值存储在整数数组中Android 在OpenGl 2.0中删除纹理,android,opengl-es,opengl-es-2.0,vuforia,Android,Opengl Es,Opengl Es 2.0,Vuforia,我正在开发一个android应用程序,当使用vuforia SDK检测到图像目标时,它会增强3D模型。同时增加了9个三维模型。我已经使用GLES20.glGenTextures(1,textureHandle,0)方法加载了纹理。所以我调用了下面的方法九次,并将纹理id的整数值存储在整数数组中 public static int loadTexture(Bitmap bitmap) { final int[] textureHandle = new int[1]; GLES2
public static int loadTexture(Bitmap bitmap)
{
final int[] textureHandle = new int[1];
GLES20.glGenTextures(1, textureHandle, 0);
if (textureHandle[0] != 0)
{
isaugmented1 = false;
android.graphics.Matrix matrix = new android.graphics.Matrix();
bitmap = Bitmap.createBitmap(bitmap,0,0,bitmap.getWidth(),bitmap.getHeight(),matrix,true);
// Bind to the texture in OpenGL
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureHandle[0]);
// Set filtering
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
// Load the bitmap into the bound texture.
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
// Recycle the bitmap, since its data has been loaded into OpenGL.
bitmap = null;
}
if (textureHandle[0] == 0)
{
throw new RuntimeException("Error loading texture.");
}
return textureHandle[0];
}
现在我想删除所有九个纹理,所以我调用了
GLES20.glDeleteTextures(1, temphandler, 0)
方法,如下面代码中所述。但结果只有最后一个纹理被删除。我想删除存储的所有纹理
public void deleteTexture()
{
if(mosaicHandler!=null){
if(mosaicHandler.length>0)
{
Log.e("deleting", "texture");
for(int i = 0; i<mosaicHandler.length;i++)
{
Log.e("deletingTexture", i+"");
int [] temphandler = new int[1];
temphandler[0] = mosaicHandler[i];
GLES20.glDeleteTextures(1, temphandler, 0);
}
}
}
}
public void deleteTexture()
{
if(马赛克处理程序!=null){
如果(mosaicHandler.length>0)
{
Log.e(“删除”、“纹理”);
为了(inti=0;i一次删除多个纹理,只需遵循OpenGLAPI
谢谢你的回复!!我已经试过了..但不适合我!!你怎么知道纹理没有被删除?