Results 1 to 3 of 3

Thread: OpenGL Texture ConvertiontoGLFormat

  1. #1
    Join Date
    Apr 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default OpenGL Texture ConvertiontoGLFormat

    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.

    Qt Code:
    1. void Texture::load(QString file)
    2. {
    3. textpath = QDir::currentPath()+"/"+MESHES_PATH+file;
    4.  
    5. if(QFile::exists(textpath)) {
    6. QImage temp;
    7. temp.load(textpath);
    8. temp.convertToFormat(QImage::Format_RGB32);
    9. if(image.load(textpath),"JPG") {
    10.  
    11. cout << "success to load : " << textpath.toStdString() << endl;
    12. image = QGLWidget::convertToGLFormat(temp);
    13. cout << "after convertion" << endl;
    14. init();
    15. }
    16. }
    17. else
    18. cout << "Warning : La texture " << file.toStdString() << " n'existe pas dans : "
    19. << (QDir::currentPath().toStdString()+"/"+MESHES_PATH) << endl;
    20. }
    21.  
    22. void Texture::init()
    23. {
    24. // Generates 1 id and write it on ID
    25. glGenTextures(1, &ID);
    26.  
    27. // Bind texture
    28. glBindTexture(GL_TEXTURE_2D, ID);
    29.  
    30. // Send pixels to GC
    31. glTexImage2D(GL_TEXTURE_2D, 0, 3, image.width(), image.height(), 0, format, GL_UNSIGNED_BYTE, image.bits());
    32.  
    33. // Filters
    34. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    35. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    36.  
    37. // Unbind
    38. glBindTexture(GL_TEXTURE_2D, 0);
    39. }
    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)

    Qt Code:
    1. ASSERT: "dst.depth() == 32" in file c:\ndk_buildrepos\qt-desktop\src\opengl\qgl.cpp, line 2207
    2. Invalid parameter passed to C runtime function.
    3. 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 :
    Qt Code:
    1. 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 :
    Qt Code:
    1. GLuint format;
    2. 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
    Last edited by 0_Azerty_0; 22nd May 2013 at 14:13.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: OpenGL Texture ConvertiontoGLFormat

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:


  4. #3
    Join Date
    Apr 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: OpenGL Texture ConvertiontoGLFormat

    Hi, I just had to have an image in the Png format. If not, it doesnt work. Thanks

Similar Threads

  1. OpenGL Texture Loading Problem
    By Atomic_Sheep in forum Newbie
    Replies: 9
    Last Post: 23rd May 2013, 08:17
  2. Maximal texture size in OpenGL?
    By UweS in forum Qt Programming
    Replies: 3
    Last Post: 24th September 2011, 08:12
  3. OpenGL render to texture
    By Nicuvëo in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2011, 12:07
  4. OpenGL texture on QGraphicsScene background
    By Ovnan in forum Qt Programming
    Replies: 5
    Last Post: 11th July 2008, 10:39
  5. Texture in QGLWidget
    By showhand in forum Qt Programming
    Replies: 5
    Last Post: 28th October 2006, 08:47

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.