PDA

View Full Version : Qt4 QGLwidget::renderPixmap don't render texture



Glandelf
2nd May 2012, 13:44
Hello everybody,

I don't succeed in finding solution in following problem:

I know renderPixmap use initializeGL(), resizeGL(), and paintGL() in a new context.
So I do test with only one triangle textured. the list is creat with it's texture in initializeGL()
Result is good in window OpenGL but when I use renderPixmap, I got my triangle without image texture.

Here example code use in initializeGL() :


void ViewerOGL::initializeGL(){
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Efface en noir
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST ); // Autorise le test de profondeur
glDepthFunc(GL_LEQUAL);
glFrontFace(GL_CCW ); // Normale dans le sens horaire
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glShadeModel(GL_SMOOTH); // Autorise anti-aliasing
glEnable(GL_CULL_FACE ); // Face arriere cache
glEnable(GL_LIGHT0); // Active la 1ere lampe
glEnable(GL_COLOR_MATERIAL); // Autorise les materiaux
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); // Autorise l'affichage

glNewList(1, GL_COMPILE);
QImage img("C:\\test.png");
QImage tex;
tex = QGLWidget::convertToGLFormat(img);
GLuint nuId;
glGenTextures(1, &nuId); // ID OpenGL sur la texture
glBindTexture(GL_TEXTURE_2D, nuId);
glTexImage2D(GL_TEXTURE_2D, 0, 4, tex.width(), tex.height(), 0, GL_RGBA,GL_UNSIGNED_BYTE, tex.bits());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glEnable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLES);
glTexCoord2f(0, 0);
glNormal3f(0, 0, 1);
glVertex3f(0, 0, 0);
glTexCoord2f(1, 0);
glNormal3f(0, 0, 1);
glVertex3f(200, 0, 0);
glTexCoord2f(0.5, 1);
glNormal3f(0, 0, 1);
glVertex3f(100, 200, 0);
glEnd();
glDisable(GL_TEXTURE_2D);
glEndList();
}


Perhaps I forget an Enable, but which ?
Tanks for help :)

Glandelf
5th May 2012, 20:20
Hello everybody :)

Nobody got an idea ? Bad day for me. It's for job, not for fun...
But I find a new element.
RenderPixmap is ok with texture, if source image not bigger than 1024 x 1024.
But my source textures make at least 4096 x 4096, as well as my picture of exit. So I can't make a copy of screen.
Is someone knowing how push over this fence ?
Or another way to catch my goal ?

Pleeeaaase ! :)