Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-20974

bindTexture methods

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P4: Low
    • None
    • 4.7.3
    • GUI: OpenGL
    • None
    • Windows, but applies to all with supporting QGLWidget

    Description

      Hi Experts,

      I think that the bindTexture method used by Qt to work with textures is confusing. For instance, we have:
      @GLuint bindTexture ( const QImage & image, GLenum target, GLint format, BindOptions options )
      GLuint bindTexture ( const QString & fileName )
      GLuint bindTexture ( const QImage & image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA )
      GLuint bindTexture ( const QPixmap & pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA )
      GLuint bindTexture ( const QPixmap & pixmap, GLenum target, GLint format, BindOptions options )@

      OpenGL uses the generated GLuint from these methods (with hidden genTextures) to identify the textures we want to bind. These bindTextures are actually createTexture methods. It should be interesting to create a QGLTexture class that receives a QImage in the creation, together with its GL parameters. Then, you would have a bind() method, setTexture method, etc...

      The way it is, it seems that bindTexture is a bindTexture used by OpenGL, when it is not/should not be, since the texture is already loaded in the graphic card. Some time ago, I also used the Qt framework, but discovered that the texture GLuint m_name generated was changing constantly for a single image, i.e. its behavior was not actually bind texture, so I gave up the Qt strategy and created my own texture class to store stuff and make things simpler.
      The solution I found was to create a Texture class that receives the bytes of a QImage and stores relevant texture information there.

      To me the bindTexture method is missing a GLuint overload, since we don't actually need the QImage after the texture is loaded. All of the bindings return a GLuint, but there is no method such as:
      @GLuint bindTexture ( GLuint name, BindOptions options )@

      I believe this will ultimately result in what I did, i.e. a QGLTexture class, since it will be weird not to store some texture config parameters (data in the GPU, name, target, other parameters, etc... instead of repeating them everytime). That is, first we create the texture, THEN we use it. As a result, some of these proposed bindTexture methods will eventually become createTexture...

      Well that is my overall idea about the bindTexture in Qt. I believe there is space for improvement there.

      I have this Texture class I mentioned, if someone is interested, please contact me.

      Very Best Regards,
      VitorAMJ

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            vitor_mj Vitor Augusto Machado Jorge
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes