繁体   English   中英

如何在OpenGL ES中加载和绑定纹理?

[英]How to load and bind texture in OpenGL ES?

所以,我在res / drawable-hdpi(例如text.png)文件夹中有一个纹理,我如何加载这个纹理并用glBindTexture绑定它?

Bitmap img = BitmapFactory.decodeResource(context.getResources(), R.drawable.text);
int[] texId = new int[1];
GLES20.glGenTextures(1, texId, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texId[0]);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, img, 0);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
  1. 将资源解码为位图
  2. 生成纹理
  3. 绑定纹理
  4. 上传纹理
  5. 设置缩小过滤器以确保完整性

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM