저는 안드로이드 애플리케이션에서 텍스처를로드하고 쉐이더에서 텍스처를 전달하는 방법에 대한 자습서를 온라인에서 읽고 있습니다. 이 방법을 찾았습니다컨텍스트 클래스를 사용하는 방법 android
public static int loadTexture(final Context context, final int resourceId)
{
final int[] textureHandle = new int[1];
GLES20.glGenTextures(1, textureHandle, 0);
if (textureHandle[0] != 0)
{
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inScaled = false; // No pre-scaling
// Read in the resource
final Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId, options);
// 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.recycle();
}
if (textureHandle[0] == 0)
{
throw new RuntimeException("Error loading texture.");
}
return textureHandle[0];
}
어떻게 사용합니까? 이 메서드를 호출 할 때 매개 변수로 무엇을 넣을 까? 반환하는 정수는 무엇입니까? OpenGL에 대한 내 지식에서 반환하는 int는 많은 텍스처를로드 할 경우 텍스처의 "숫자"라고 가정합니다. 텍스처 핸들을 사용하면됩니다. 그러나 나머지는 어떨까요 ???
질문에 더 나은 제목을주십시오. 이것은 너무 일반적입니다. – Snicolas
존경한다면, 당신이 Context를 이해하지 못하고 resourceID가 어떻게 사용되는지 알지 못한다면, 진행하기 전에 안드로이드 기본 사항에 대해 더 배워야합니다. – Simon