Results 1 to 2 of 2

Thread: Qt5 and OpenGL

  1. #1
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Qt5 and OpenGL

    Hello forum,


    I am having the following compilation error:

    Qt Code:
    1. Model.cpp:233: error: 'glGenerateMipmap' was not declared in this scope
    2. glGenerateMipmap(GL_TEXTURE_2D);
    3. ^
    To copy to clipboard, switch view to plain text mode 

    I have a Model class with a member function to generate texture object.


    Qt Code:
    1. GLint Model::TextureFromFile(const char* path, string directory, bool gamma)
    2. {
    3. //Generate texture ID and load texture data
    4. string filename = string(path);
    5. filename = directory + '/' + filename;
    6. GLuint textureID;
    7. glGenTextures(1, &textureID);
    8. int width,height;
    9. unsigned char* image = SOIL_load_image(filename.c_str(), &width, &height, 0, SOIL_LOAD_RGB);
    10. // Assign texture to ID
    11. glBindTexture(GL_TEXTURE_2D, textureID);
    12. glTexImage2D(GL_TEXTURE_2D, 0, gamma ? GL_SRGB : GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
    13. glTexParameteri(GL_TEXTURE_2D,GL_GENERATE_MIPMAP,GL_TRUE);
    14.  
    15. glGenerateMipmap(GL_TEXTURE_2D);
    16.  
    17. // Parameters
    18. glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
    19. glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
    20. glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR );
    21. glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    22. glBindTexture(GL_TEXTURE_2D, 0);
    23. SOIL_free_image_data(image);
    24. return textureID;
    25. }
    To copy to clipboard, switch view to plain text mode 

    rest of the gl functions do not end up with the compilation error. Any idea ?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,330
    Thanks
    317
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt5 and OpenGL

    If you're compiling on Windows using Microsoft's OpenGL headers, then it looks like this function is not included in the core, but rather as an extension. See this stackoverflow post. You'll probably need to download and install glew or a similar extension library.

Similar Threads

  1. Replies: 2
    Last Post: 5th July 2017, 13:28
  2. Replies: 0
    Last Post: 17th May 2015, 18:03
  3. Conversion from opengl to opengl es2 (Shapefile rendering)?
    By swapan_gh in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 5th December 2013, 06:59
  4. converting GLUT/OpenGL to Qt/OpenGL - displaying issue
    By yoti13 in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2012, 00:45
  5. Replies: 0
    Last Post: 6th December 2009, 00:41

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
  •  
Qt is a trademark of The Qt Company.