OpenGLを使用して透明なBGRAイメージ(テキストオーバーレイ)を移動して回転させたい。ここで私が使用したコードスニペットは次のとおりです。OpenGL:テクスチャのコピー中にアルファチャンネルが255に設定されているのはなぜですか?
glViewport(0, 0, iWidth, iHeight); // Reset The Current Viewport
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &arTex[0].iName);
glBindTexture(GL_TEXTURE_2D, arTex[0].iName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, 4, imf.iWidth, imf.iHeight, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, ib.GetData());
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Note: Transparent alpha value
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-dAspectCanvas/2.0, dAspectCanvas/2.0, -0.5, 0.5, -1.0, 1.0); // Note: Using (-1.0; 1.0) for Z-planes
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScaled(Motion.Scale.GetValue(dPosition), Motion.Scale.GetValue(dPosition), 1.0);
glTranslated(Motion.OffsetX.GetValue(dPosition) * dAspectCanvas, Motion.OffsetY.GetValue(dPosition), 0.0);
glRotated(Motion.Rotation.GetValue(dPosition), 0.0, 0.0, 1.0);
glTranslated(Motion.PositionX.GetValue(dPosition) * dAspectCanvas, Motion.PositionY.GetValue(dPosition), 1.0);
// Rotating and moving
glBindTexture(GL_TEXTURE_2D, arTex[iTexIndex].iName); // has to be called outside glBegin/glEnd scope
glBegin(GL_TRIANGLE_STRIP); // "Many OpenGL applications avoid quads altogether because of their inherent rasterization problems"
glTexCoord2d(rcTextureIntersection.left, rcTextureIntersection.top);
glVertex2d(rcVertexIntersection.left, rcVertexIntersection.top);
glTexCoord2d(rcTextureIntersection.right, rcTextureIntersection.top);
glVertex2d(rcVertexIntersection.right, rcVertexIntersection.top);
glTexCoord2d(rcTextureIntersection.left, rcTextureIntersection.bottom);
glVertex2d(rcVertexIntersection.left, rcVertexIntersection.bottom);
glTexCoord2d(rcTextureIntersection.right, rcTextureIntersection.bottom);
glVertex2d(rcVertexIntersection.right, rcVertexIntersection.bottom);
glEnd();
glDisable(GL_TEXTURE_2D);
glFlush();
glReadBuffer(GL_BACK);
glReadPixels(0, 0, imf.iWidth, imf.iHeight, GL_BGRA_EXT, GL_UNSIGNED_BYTE, ibOut.GetData());
でも何でも、私はglTexImage2Dにしてみてください、私の透明黒画像が完全に不透明黒画像となります。入力BGRAイメージには、0,0,0,0,0,0のバイトが含まれます。回転後、出力イメージには0,0,0,255,0,0,0,255,0が含まれます。 Aは常に255に設定されており、私は理由を理解できません。
"回転後、出力イメージには0,0,0,255,0,0,0,255,0 ..."が含まれています。OpenGLコンテキストを作成したとき、フレームバッファにアルファその中に? –