Note that there are some explanatory texts on larger screens.

plurals
  1. POopenGL texturing shows only red component of texture
    primarykey
    data
    text
    <p>I am trying to texture map an image to a single polygon. My image is being read correctly, but only the red plane of the image is being textured.</p> <p>I am doing this within a QGLWidget </p> <p>I have checked the image after it is read, and it's components are being read correctly--ie, I get valid values for the green and blue planes.</p> <p>Here is the code</p> <p><code> </p> <pre><code>QImageReader *theReader = new QImageReader(); theReader-&gt;setFileName(imageFileName); QImage theImageRead = theReader-&gt;read(); if(theImageRead.isNull()) { validTile = NOT_VALID_IMAGE_FILE; return; } else { int newW = 1; int newH = 1; while(newW &lt; theImageRead.width()) { newW *= 2; } while(newH &lt; theImageRead.height()) { newH *= 2; } theImageRead = theImageRead.scaled(newW, newH, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); // values checked in theImageRead are OK here glGenTextures(1,&amp;textureObject); theTextureImage = QGLWidget::convertToGLFormat(theImageRead); // values checked in theTextureImage are OK here glBindTexture(GL_TEXTURE_2D, textureObject); glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,newW, newH, 0, GL_RGBA, GL_UNSIGNED_BYTE,theTextureImage.bits() ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); glFlush(); validTile = VALID_TEXTURE; return; } </code></pre> <p></p> <p>then I draw like this:</p> <p><code></p> <pre>{ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,textureTiles[tN]-&gt;getTextureObject() ); glBegin(GL_QUADS); glTexCoord2f(0.0,0.0); glVertex2f(textureTiles[tN]-&gt;lowerLeft.x(), textureTiles[tN]-&gt;lowerLeft.y()); glTexCoord2f(1.0,0.0); glVertex2f(textureTiles[tN]-&gt;lowerRight.x(), textureTiles[tN]-&gt;lowerRight.y()); glTexCoord2f(1.0,1.0); glVertex2f(textureTiles[tN]-&gt;upperRight.x(), textureTiles[tN]-&gt;upperRight.y()); glTexCoord2f(0.0,1.0); glVertex2f(textureTiles[tN]-&gt;upperLeft.x(), textureTiles[tN]-&gt;upperLeft.y()); glEnd(); glDisable(GL_TEXTURE_2D); } </code></pre> <p></code></p> <p>Does anybody see anything that would cause my texture to be interpreded as if it is values of (r,0,0,1)? (r,g,b,a)?</p> <p>QT 4.7.1, Ubuntu 10.04, openGl 2.something or other</p> <p>thanks in advance for any help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload