Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL textures: why does order matter?
    primarykey
    data
    text
    <p>I am trying to setup a simple function which will make it a lot easier for me to texture map geometry in OpenGL, but for some reason when I'm trying to make a skybox, I am getting a white box instead of the texture mapped geometry. I think that the problemed code lies within the following:</p> <pre><code>void MapTexture (char *File, int TextNum) { if (!TextureImage[TextNum]){ TextureImage[TextNum]=auxDIBImageLoad(File); glGenTextures(1, &amp;texture[TextNum]); glBindTexture(GL_TEXTURE_2D, texture[TextNum]); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[TextNum]-&gt;sizeX, TextureImage[TextNum]-&gt;sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[TextNum]-&gt;data); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); } glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture[TextNum]); //glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[TextNum]-&gt;sizeX, TextureImage[TextNum]-&gt;sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[TextNum]-&gt;data); //glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); } </code></pre> <p>The big thing I don't understand is for some reason the <code>glBindTexture()</code> must come between <code>glGenTextures()</code> and <code>glTexImage2D</code>. If I place it anywhere else, it screws everything up. What could be causing this problem? Sorry if it's something simple, I'm brand new to openGL.</p> <p>Below is a screenshot of the whitebox I am talking about: <img src="https://i.stack.imgur.com/V8OdQ.png" alt="enter image description here"></p> <p>+++++++++++++++++++++++++++++++ EDIT +++++++++++++++++++++++++++++++</p> <p>After playing around with the code a bit more, i realized that if I added <code>glTexImage2D()</code> and <code>glTexParameteri()</code>after the last <code>glBindTexture()</code> then all the textures load. Why is it that without these two lines most textures would load, and yet there are a few that would not, and why do I have to call glTexImage() for every frame, but only for a few textures? </p>
    singulars
    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.
 

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