Hi,
I have a problem with texture loading with OpenGL. I am trying to load and convert an image in opengl format, but the convertion crash, and i get back an assertion :
It seems to be a problem of depth of an image.
{
textpath
= QDir::currentPath()+"/"+MESHES_PATH
+file;
if(QFile::exists(textpath
)) { temp.load(textpath);
temp.
convertToFormat(QImage::Format_RGB32);
if(image.load(textpath),"JPG") {
cout << "success to load : " << textpath.toStdString() << endl;
cout << "after convertion" << endl;
init();
}
}
else
cout << "Warning : La texture " << file.toStdString() << " n'existe pas dans : "
<<
(QDir::currentPath().
toStdString()+"/"+MESHES_PATH
) << endl;
}
void Texture::init()
{
// Generates 1 id and write it on ID
glGenTextures(1, &ID);
// Bind texture
glBindTexture(GL_TEXTURE_2D, ID);
// Send pixels to GC
glTexImage2D(GL_TEXTURE_2D, 0, 3, image.width(), image.height(), 0, format, GL_UNSIGNED_BYTE, image.bits());
// Filters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// Unbind
glBindTexture(GL_TEXTURE_2D, 0);
}
void Texture::load(QString file)
{
textpath = QDir::currentPath()+"/"+MESHES_PATH+file;
if(QFile::exists(textpath)) {
QImage temp;
temp.load(textpath);
temp.convertToFormat(QImage::Format_RGB32);
if(image.load(textpath),"JPG") {
cout << "success to load : " << textpath.toStdString() << endl;
image = QGLWidget::convertToGLFormat(temp);
cout << "after convertion" << endl;
init();
}
}
else
cout << "Warning : La texture " << file.toStdString() << " n'existe pas dans : "
<< (QDir::currentPath().toStdString()+"/"+MESHES_PATH) << endl;
}
void Texture::init()
{
// Generates 1 id and write it on ID
glGenTextures(1, &ID);
// Bind texture
glBindTexture(GL_TEXTURE_2D, ID);
// Send pixels to GC
glTexImage2D(GL_TEXTURE_2D, 0, 3, image.width(), image.height(), 0, format, GL_UNSIGNED_BYTE, image.bits());
// Filters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// Unbind
glBindTexture(GL_TEXTURE_2D, 0);
}
To copy to clipboard, switch view to plain text mode
I call the load(...) function and aI have the next assertion on the ligne 12 when I call : QGLWidget::convertToGLFormat(temp)
ASSERT: "dst.depth() == 32" in file c:\ndk_buildrepos\qt-desktop\src\opengl\qgl.cpp, line 2207
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
ASSERT: "dst.depth() == 32" in file c:\ndk_buildrepos\qt-desktop\src\opengl\qgl.cpp, line 2207
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
To copy to clipboard, switch view to plain text mode
and I knwo that my image is successfully loaded :
success to load : C:/Users/.........../resources/mesh/cube.jpg
success to load : C:/Users/.........../resources/mesh/cube.jpg
To copy to clipboard, switch view to plain text mode
My variable format is defined like this :
GLuint format;
format = GL_RGB;
GLuint format;
format = GL_RGB;
To copy to clipboard, switch view to plain text mode
I don't see how to solve this problem. :/
Thanks a lot,
Az
Bookmarks