2

テクスチャのデータソースとしてバイト配列を保持するAndroidアプリのクラスがあります。フレームバッファを使用して、そのテクスチャにいくつかのものをレンダリングしてから、画面にテクスチャをレンダリングします。これは完全に機能します。

ただし、これは151のテクスチャでのみ実行できます。インスタンス#152は次のエラーを生成します:

:0: PVRSRVAllocDeviceMem: Error 1 returned
:0: ComputeFrameBufferCompleteness: Can't create render surface.

コードスニペット(コンストラクター)は次のとおりです。

// Texture image bytes
   imgBuf=ByteBuffer.allocateDirect(TEXEL_X*TEXEL_Y*3);
   imgBuf.position(0);

// Fill the texture with an arbitrary color, so we see something
   byte col=(byte)(System.nanoTime()%255);
   for (int ii=0; ii<imgBuf.capacity(); ii+=3)
   {  imgBuf.put(col);
      imgBuf.put((byte)(col*3%255));
      imgBuf.put((byte)(col*7%255));
   }
   imgBuf.rewind();

// Generate the texture
   GLES20.glGenTextures(1,textureID,0);
   GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,textureID[0]);

   GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_S,
    GLES20.GL_CLAMP_TO_EDGE);
   GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
    GLES20.GL_CLAMP_TO_EDGE);

   GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
    GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_LINEAR);

   GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MAG_FILTER,
    GLES20.GL_LINEAR);

// Associate a two-dimensional texture image with the byte buffer
   GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D,0,GLES20.GL_RGB,TEXEL_X,
    TEXEL_Y,0,GLES20.GL_RGB,GLES20.GL_UNSIGNED_BYTE,imgBuf);

   GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,0);

// Get framebuffer for later rendering to this texture
   GLES20.glGenFramebuffers(1,frameBufID,0);

そしてここに問題があります(テクスチャにレンダリング)

この部分を省略した場合、そのようなテクスチャを何百も表示することはうまくいきますが、テクスチャに何もレンダリングできません:(保持すると、151のテクスチャでうまく機能します。

// Bind frame buffer and specify texture as color attachment
   GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,frameBufID[0]);
   GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,textureID[0],0);

// Check status
   int status=GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
   Log.i(TAG,texNum+":"+status);

// Render some stuff on the texture
// ......
// (It does not matter. The status check fails even without rendering anything here)

   GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,0,0);
   GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0);

誰かがこれに光を当てることができることを願っています。ありがとう、Ru

4

1 に答える 1