Hi guys, I'm trying to display some "native" OpenGL inside a custom QML item using Qt 5.0.2 on a Linux x86_64 with a Nvidia 9600M GT (driver v295.40). I have a custom QQuickPaintedItem with a overloaded paint where I use painter->beginNativePainting() and a shader program:
Vertex shader: uniform highp mat4 projectionMatrix; uniform highp mat4 modelViewMatrix; void main(void) { gl_Position = projectionMatrix * modelViewMatrix * gl_Vertex; gl_FrontColor = gl_Color; gl_TexCoord[0] = gl_MultiTexCoord0; } Fragment shader: uniform highp sampler2D diffuseTexture; void main(void) { gl_FragColor = texture2D(diffuseTexture, gl_TexCoord[0].st); //gl_FragColor = gl_Color; // Display the mesh in white -> OK //gl_FragColor = vec4(gl_TexCoord[0].st, 0.0, 1.0); // Display the correct coord -> OK } I have a mesh class used to load a mesh using Assimp. At the moment I only load a simple cube.obj. The rendering code is the following: void Mesh::render() { if(mData->hasDiffuse) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, mData->diffuse); } glEnableVertexAttribArray(SimpleGameEngine::sAttrLocVertex); glEnableVertexAttribArray(SimpleGameEngine::sAttrLocTex0); glBindBuffer(GL_ARRAY_BUFFER, mData->vertexBuffer); glVertexAttribPointer(SimpleGameEngine::sAttrLocVertex, 3, GL_FLOAT, GL_FALSE, 0, NULL); glBindBuffer(GL_ARRAY_BUFFER, mData->texBuffer); glVertexAttribPointer(SimpleGameEngine::sAttrLocTex0, 2, GL_FLOAT, GL_FALSE, 0, NULL); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mData->faceBuffer); glDrawElements(GL_TRIANGLES, mData->faceNum * 3,GL_UNSIGNED_INT, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); glDisableVertexAttribArray(SimpleGameEngine::sAttrLocTex0); glDisableVertexAttribArray(SimpleGameEngine::sAttrLocVertex); if(mData->hasDiffuse) { glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); } } My texture is loaded using the following code: void Mesh::setDiffuseTexture(const QImage &image) { if(image.isNull()) qFatal("Invalid image"); QImage texture = QGLWidget::convertToGLFormat(image); if(texture.isNull()) qFatal("Invalid texture"); glGenTextures(1, &mData->diffuse); glBindTexture(GL_TEXTURE_2D, mData->diffuse); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texture.width(), texture.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, texture.bits()); glBindTexture(GL_TEXTURE_2D, 0); mData->hasDiffuse = true; } Everything works. But as soon as I add the texture my cube turns black. I already try with a procedural 4x4 checker texture and it didn't work either. Any help will be appreciated. Olivier. _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest