{
glWidget.makeCurrent();
GLuint texture = glWidget.bindTexture(filename);
if (!texture)
// Determine the size of the DDS image
GLint width, height;
glBindTexture(GL_TEXTURE_2D, texture);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
if (width == 0 || height == 0)
if (!pbuffer.makeCurrent())
pbuffer.
drawTexture(QRectF(-1,
-1,
2,
2), texture
);
return pbuffer.toImage();
}
QImage readDDSFile(const QString &filename)
{
QGLWidget glWidget;
glWidget.makeCurrent();
GLuint texture = glWidget.bindTexture(filename);
if (!texture)
return QImage();
// Determine the size of the DDS image
GLint width, height;
glBindTexture(GL_TEXTURE_2D, texture);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
if (width == 0 || height == 0)
return QImage();
QGLPixelBuffer pbuffer(QSize(width, height), glWidget.format(), &glWidget);
if (!pbuffer.makeCurrent())
return QImage();
pbuffer.drawTexture(QRectF(-1, -1, 2, 2), texture);
return pbuffer.toImage();
}
To copy to clipboard, switch view to plain text mode
For information on the supported formats see
Bookmarks