Search code examples
qtopengl-estexture2d

Qt openGL es2 glBindTexture failed when picture size is large


I use Qt 4.7 whith openGL es2 , the hardwar is powervr ,sdk is sgx 4.8

glBindTexture( GL_TEXTURE_2D, bindTexture(m_myPixmapOfPic, GL_TEXTURE_2D));

When picture size is 512*256, it works well.When picture is 768*512, shows black which means failed.I try to find interface and increase the size of buffer of texture.But Qt doesnot support such interface.OpenGL es2 interfaces also do not mention this problem.

   QVector<QVector3D> vertices.append
   QVector<QVector2D> texCoords.append

glBindTexture( GL_TEXTURE_2D, bindTexture(m_myPixmapOfPic, GL_TEXTURE_2D));

GLSL:gl_FragColor = texture2D(texture, v_texcoord) //simple bind

Solution

  • This is not due to buffer size. You may need to specify a power-of-two (ie 2^n - 2,4,16,32,64,128,256, 512, 1024 etc) sized image as texture. Alternatively the HW needs to support extensions for NON-power of two.