Results 1 to 2 of 2

Thread: Qt4 QGLwidget::renderPixmap don't render texture

  1. #1
    Join Date
    May 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt4 QGLwidget::renderPixmap don't render texture

    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() :
    Qt Code:
    1. void ViewerOGL::initializeGL(){
    2. glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Efface en noir
    3. glClearDepth(1.0f);
    4. glEnable(GL_DEPTH_TEST ); // Autorise le test de profondeur
    5. glDepthFunc(GL_LEQUAL);
    6. glFrontFace(GL_CCW ); // Normale dans le sens horaire
    7. glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    8. glShadeModel(GL_SMOOTH); // Autorise anti-aliasing
    9. glEnable(GL_CULL_FACE ); // Face arriere cache
    10. glEnable(GL_LIGHT0); // Active la 1ere lampe
    11. glEnable(GL_COLOR_MATERIAL); // Autorise les materiaux
    12. glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); // Autorise l'affichage
    13.  
    14. glNewList(1, GL_COMPILE);
    15. QImage img("C:\\test.png");
    16. QImage tex;
    17. tex = QGLWidget::convertToGLFormat(img);
    18. GLuint nuId;
    19. glGenTextures(1, &nuId); // ID OpenGL sur la texture
    20. glBindTexture(GL_TEXTURE_2D, nuId);
    21. glTexImage2D(GL_TEXTURE_2D, 0, 4, tex.width(), tex.height(), 0, GL_RGBA,GL_UNSIGNED_BYTE, tex.bits());
    22. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    23. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    24. glEnable(GL_TEXTURE_2D);
    25. glBegin(GL_TRIANGLES);
    26. glTexCoord2f(0, 0);
    27. glNormal3f(0, 0, 1);
    28. glVertex3f(0, 0, 0);
    29. glTexCoord2f(1, 0);
    30. glNormal3f(0, 0, 1);
    31. glVertex3f(200, 0, 0);
    32. glTexCoord2f(0.5, 1);
    33. glNormal3f(0, 0, 1);
    34. glVertex3f(100, 200, 0);
    35. glEnd();
    36. glDisable(GL_TEXTURE_2D);
    37. glEndList();
    38. }
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    May 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt4 QGLwidget::renderPixmap don't render texture

    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 !

Similar Threads

  1. QGLWidget renderPixmap and alpha channel
    By omega in forum Newbie
    Replies: 1
    Last Post: 12th September 2015, 02:55
  2. QGLWidget render or QGraphicsView with GL viewport render
    By QTInfinity in forum Qt Programming
    Replies: 2
    Last Post: 28th November 2011, 12:34
  3. OpenGL render to texture
    By Nicuvëo in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2011, 13:07
  4. Texture in QGLWidget
    By showhand in forum Qt Programming
    Replies: 5
    Last Post: 28th October 2006, 09:47
  5. renderPixmap and texture
    By techno in forum Qt Programming
    Replies: 1
    Last Post: 2nd March 2006, 13:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.