I am a bit confused with the texture manipulation methods. 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 )@
When OpenGL uses a number (from glGenTex...) to identify what textures we want to bind. To me should be more interesting to create a texture object that receives a QImage in the creation only.
It is weird to pass bytes over and over again, once 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 (not sure if this is true today). That is, the texture seems to be created everytime we use the QImage... doesn't seem fast or smart. EDIT: Am I missing something?
The solution I found was to create a Texture class that receives the bytes of a QImage.
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 QTexture class, since it will be weird not to store some texture config parameters (name, target, repeat, 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 become createTexture...
Well that is my overall idea about the bindTexture in Qt. I believe there is space for improvement there.
EDIT: Does anyone do something different when using GL textures in Qt?
Very Best Regards,
Posted suggestion on JIRA: "QTBUG-20974":https://bugreports.qt.nokia.com/browse/QTBUG-20974