Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat am I doing wrong that I can't render an image/texture properly in OpenGL?
    primarykey
    data
    text
    <p>I'm trying to render an image to the window. Super simple (or so I thought). No matter what I do, I always get this purple square. Some tidbits of my code:</p> <pre><code>// load image from file, called one time on load: glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); glEnable(GL_DEPTH_TEST); RgbImage theTexMap( filename ); glGenTextures(1, &amp;textureID); glBindTexture(GL_TEXTURE_2D, textureID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, theTexMap.GetNumCols(), theTexMap.GetNumRows(), 0, GL_RGB, GL_UNSIGNED_BYTE, theTexMap.ImageData() ); // render quad and texture, called inside glutDisplayFunc callback glEnable(GL_TEXTURE_2D); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBegin(GL_QUADS); glTexCoord2f(0.0, 0.0); glVertex3f(-50.0, -50.0, 0.0); glTexCoord2f(0.0, 1.0); glVertex3f(-50.0, 50.0, 0.0); glTexCoord2f(1.0, 1.0); glVertex3f(50.0, 50.0, 0.0); glTexCoord2f(1.0, 0.0); glVertex3f(50.0, -50.0, 0.0); glEnd(); glFlush(); glDisable(GL_TEXTURE_2D); </code></pre> <p>I'm cutting out a lot of code because I'm attempting to extend an example from third party library (ARToolkit). There's a lot more code in there than needs displaying here.</p> <p>Any ideas for a mistake I might be making that would display the quad, but not render the texture/image?</p> <p><img src="https://i.stack.imgur.com/o7clU.png" alt="alt text"></p>
    singulars
    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