为什么不向我显示图形?我得到的只是一个白色方块。图片大小为512x512。
public void loadGLTexture(GL10 gl) {
imageData = ByteBuffer.allocate(mPicture512.length).order(ByteOrder.nativeOrder());
imageData.put(mPicture512);
imageData.position(0);
// generate one texture pointer
gl.glGenTextures(1, textures, 0);
// ...and bind it to our array
//Bitmap bitmap = getBitmap(mContext);
//bitmap.getPixels(pixels, offset, stride, x, y, width, height)
// create nearest filtered texture
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);
gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, 512, 512, 0,GL10.GL_RGBA, GL10.GL_BYTE, imageData);ps。我知道我可以这样做,它工作,但由于这是一个性能关键的应用程序,我不想第一次创建位图的开销。
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);发布于 2012-07-05 21:54:34
问题是,我加载的位图PNG有标题,而不是原始图片。
发布于 2012-07-05 01:23:20
glTexParameter修改每纹理状态。最小/最大过滤器设置是在绑定纹理之前调用的,因此它对纹理没有影响。
因此,您的纹理仍然使用最小过滤器的默认min,并且不会正确显示。
发布于 2012-07-05 01:16:11
为什么不以不同的方式将图片上传到OpenGL?
BitmapFactory.Options options = new BitmapFactory.Options();
options.inScaled = false;
Bitmap bitmap = BitmapFactory.decodeStream(activity.getAssets().open(fileName));
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);https://stackoverflow.com/questions/11331216
复制相似问题