constant中的initTexture

public static int initTexture(int drawbleId, Resources resources){
	int[] textures= new int[1];
	GLES20.glGenTextures(1, textures,0);
	int textureId=textures[0];
	GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
	GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_LINEAR);
	GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,GLES20.GL_LINEAR);
	GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_REPEAT);
	GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_REPEAT);

		InputStream is=resources.openRawResource(drawbleId);
		Bitmap bitmapTmp;
		
		try{
			bitmapTmp=BitmapFactory.decodeStream(is);
		
		}
	finally{
		try{  is.close(); }
		catch(Exception e){
			e.printStackTrace();
			
		}
	}
	GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,0,bitmapTmp,0);
	bitmapTmp.recycle();
	return textureId;
	
}

posted @ 2015-06-10 20:48  Anzhongliu  阅读(228)  评论(0编辑  收藏  举报