After spending some time with this, transferring an QImage to an ITexture works fine but I cannot get the transparency to work on the ITexture.
Here are the two functions if anyone could make sense of where my issue is.
The font is being drawn correctly but no transparency at all.
Thanks in advance...
void MainWindow::on_singerShow_clicked(bool checked)
{
int currentItem = ui->singerList->currentRow();
if ( currentItem >= 0 && iWind )
{
if ( checked )
{
QString text = ui->singerList->item(currentItem)->text();
QImage temp(singerIWidth,singerIHeight,QImage::Format_ARGB32);
temp.fill( 0 );
QPainter paint;
paint.begin(&temp);
QFont font(ui->singerFont->font());
font.setPointSize( ui->singerSize->value() );
font.setBold( ui->singerBold->isChecked() );
QString fStr = ui->singerFrontColour->currentText();
QString sStr = ui->singerShadowColour->currentText();
paint.setFont( font );
paint.setPen( sStr );
paint.drawText(QRect(6,6,singerIWidth,singerIHeight),
Qt::AlignCenter, text);
paint.setPen( fStr );
paint.drawText(QRect(0,0,singerIWidth,singerIHeight),
Qt::AlignCenter, text);
paint.end();
iWind->setSinger(checked, &temp);
}
else
{
iWind->setSinger(checked, 0);
}
}
}
and
void IrrlichtWindow::setSinger(bool checked, QImage *img)
{
// a straight forward memcpy because both QImage and ITexture
// are exactly the same size and format
if ( checked )
{
void *src = (void*)img->bits();
void *dst = singerTexture->lock();
memcpy( dst, src, singerIWidth * singerIHeight * 4 );
singerTexture->unlock();
singer->setMaterialTexture(0, singerTexture);
singer->setVisible(true);
singer->setMaterialFlag(video::EMF_BLEND_OPERATION,
video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF);
}
else
{
singer->setVisible(false);
}
}