Я хочу переместить и повернуть прозрачное изображение BGRA (наложение текста) с помощью OpenGL.Вот фрагмент кода, который я использую:
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, 255, 0, 0, 0, 255, 0 .... Aустановлен на 255 все время, и я не могу понять, почему.