【问题标题】:How to Display Different images on each face of cube in opengl (android)?如何在opengl(android)中立方体的每个面上显示不同的图像?
【发布时间】:2012-09-07 10:21:00
【问题描述】:

我正在制作一个3D立方体,我可以为每张脸分配一张图像,但我想为每张脸分配不同的图像。我使用NeHe Port作为参考,所以对于一张图像的功能是::

 public static Bitmap getTextureFromBitmapResource(Context context, int resourceId)
{
    Bitmap bitmap = null;
    try
    {
        bitmap = BitmapFactory.decodeResource(context.getResources(), resourceId);
        return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), yFlipMatrix, false);
    } finally
    {
        if (bitmap != null)
        {
            bitmap.recycle();
        }
    }
}

我在我的渲染器中这样调用这个函数::

Bitmap texture = getTextureFromBitmapResource(context, R.drawable.img1);

但我只能为每张脸设置一个图像。我想为每张脸设置不同的图像。我尝试制作一组​​图像,然后将其传递给这个函数,但没有成功。

【问题讨论】:

    标签: android graphics opengl-es 3d cube


    【解决方案1】:

    Texture arrays(如果您指的是)应该可以工作,但这取决于您在着色器中计算层的方式。

    否则,您必须单独绘制每个面并每次都绑定正确的纹理,或者使用cubemap

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-31
      • 2020-04-08
      • 1970-01-01
      • 2020-03-15
      • 1970-01-01
      • 2014-12-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多