[Android Opengl es 2.0 ] Texture Setting.
///
// Load texture from resource
//
private int loadTexture ( InputStream is ,int texId)
{
/*
* Create our texture. This has to be done each time the
* surface is created.
*/
int[] textures = new int[1];
if(texId == 0)
GLES20.glGenTextures(1, textures, 0);
else
textures[0] = texId;
int mTextureID = textures[0];
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureID);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
GLES20.GL_NEAREST);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER,
GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
GLES20.GL_REPEAT);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
GLES20.GL_REPEAT);
Bitmap bitmap;
try {
bitmap = BitmapFactory.decodeStream(is);
bitmap = Bitmap.createScaledBitmap(bitmap, getMinPowerByTwo(bitmap.getWidth()),getMinPowerByTwo(bitmap.getHeight()),false);
} finally {
try {
is.close();
} catch(IOException e) {
// Ignore.
}
}
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
bitmap.recycle();
return mTextureID;
}
전,, Buffer로 꼭 넣어야만 Opengl es 2.0 에서 Bitmap을 Texture에 넣을 수 있는줄 알았습니다.
http://gogorchg.tistory.com/entry/Android-Opengl-es-20-LiveWallpaper-%EC%97%90%EC%84%9C-%EC%82%AC%EC%9A%A9-%EC%8B%9C-onSurfaceCreated-%EB%AC%B8%EC%A0%9C
하지만, 위 소스 같이 예전 opengl es 1.1에서 했던 형태로 해도 문제가 없습니다.
잘못된 정보를 알려드려 죄송합니다. ;;;;