AndEngineのブレンドテスト

2013年7月10日水曜日

andEngine androidアプリ開発

t f B! P L
AndEngineではOpenGLを使っているので、OpenGL関連の描画機能があったりします

そのうちの一つで気になっていたのが
.setBlendFunctionの機能です

以下がテストコードと結果の画像





static int sTileWidth=80; // タイルの幅
static int sTileHeight=80; // タイルの高さ 


  // 指定なし
  Rectangle tile = new Rectangle(0*sTileWidth+1,0*sTileHeight+1,sTileWidth-2,sTileHeight-2,getBaseActivity().getVertexBufferObjectManager());
  tile.setColor(Color.RED);
  tile.setAlpha(0.5f);
  attachChild(tile);
  
  // アルファブレンド
  Rectangle tile2 = new Rectangle(0*sTileWidth+1,1*sTileHeight+1,sTileWidth-2,sTileHeight-2,getBaseActivity().getVertexBufferObjectManager());
  tile2.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
  tile2.setColor(Color.RED);
  tile2.setAlpha(0.5f);
  attachChild(tile2);
  
  // 反転
  Rectangle tile3 = new Rectangle(0*sTileWidth+1,2*sTileHeight+1,sTileWidth-2,sTileHeight-2,getBaseActivity().getVertexBufferObjectManager());
  tile3.setBlendFunction(GL10.GL_ONE_MINUS_DST_COLOR, GL10.GL_ZERO);
  tile3.setColor(Color.RED);
  tile3.setAlpha(0.5f);
  attachChild(tile3);
  
  // 加算
  Rectangle tile4 = new Rectangle(0*sTileWidth+1,3*sTileHeight+1,sTileWidth-2,sTileHeight-2,getBaseActivity().getVertexBufferObjectManager());
  tile4.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE);
  tile4.setColor(Color.RED);
  tile4.setAlpha(0.5f);
  attachChild(tile4);
  
  // 加算+アルファ
  Rectangle tile5 = new Rectangle(0*sTileWidth+1,4*sTileHeight+1,sTileWidth-2,sTileHeight-2,getBaseActivity().getVertexBufferObjectManager());
  tile5.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
  tile5.setColor(Color.RED);
  tile5.setAlpha(0.5f);
  attachChild(tile5);
  
  // スクリーン
  Rectangle tile6 = new Rectangle(0*sTileWidth+1,5*sTileHeight+1,sTileWidth-2,sTileHeight-2,getBaseActivity().getVertexBufferObjectManager());
  tile6.setBlendFunction(GL10.GL_ONE_MINUS_DST_COLOR, GL10.GL_ONE);
  tile6.setColor(Color.RED);
  tile6.setAlpha(0.5f);
  attachChild(tile6);
  
  // 乗算
  Rectangle tile7 = new Rectangle(0*sTileWidth+1,6*sTileHeight+1,sTileWidth-2,sTileHeight-2,getBaseActivity().getVertexBufferObjectManager());
  tile7.setBlendFunction(GL10.GL_ZERO, GL10.GL_SRC_COLOR);
  tile7.setColor(Color.RED);
  tile7.setAlpha(0.5f);
  attachChild(tile7);

Translate

このブログを検索

  • ()
  • ()
もっと見る

QooQ