Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is this array selection causing such a glitchy phenomenon?
    primarykey
    data
    text
    <p>I was loading a image in openGl with the Glaux library when I came across a very strange phenomenon with a array. Some example of what I tried and if they succeeded or not are below. The curFreeId variable is global. The extra variables I created to test with are local to the function.</p> <p>Since when does this effect the flow of code.</p> <pre><code> unsigned int curFreeId = 0; modStruct-&gt;t[ i ].gluId = curFreeId; glGenTextures(1, &amp;glTextureList[curFreeId]); glBindTexture(GL_TEXTURE_2D, glTextureList[curFreeId]); </code></pre> <p>vs</p> <pre><code> modStruct-&gt;t[ i ].gluId = 0; glGenTextures(1, &amp;glTextureList[0]); glBindTexture(GL_TEXTURE_2D, glTextureList[0]); </code></pre> <p>The first code will not work. The second will. Does anyone have any clue why this happens?</p> <p>EDIT: Strangely enough, this also works correctly.</p> <pre><code>unsigned int curFreeId = 0; modStruct-&gt;t[ i ].gluId = curFreeId; glGenTextures(1, &amp;glTextureList[0]); glBindTexture(GL_TEXTURE_2D, glTextureList[curFreeId]); </code></pre> <p>and so does this.</p> <pre><code>unsigned int curFreeId = 0; modStruct-&gt;t[ i ].gluId = curFreeId; glGenTextures(1, &amp;glTextureList[curFreeId]); glBindTexture(GL_TEXTURE_2D, glTextureList[0]); </code></pre> <p>Continuing on with some testing. I came across even more curious results.</p> <p>This works</p> <pre><code> unsigned int curFreeId = 0; unsigned int curid = 0; modStruct-&gt;t[ i ].gluId = curFreeId; glGenTextures(1, &amp;glTextureList[curid]); glBindTexture(GL_TEXTURE_2D, glTextureList[curFreeId]); </code></pre> <p>But this does not...</p> <pre><code> unsigned int curFreeId = 0; unsigned int curid = curFreeId; modStruct-&gt;t[ i ].gluId = curFreeId; glGenTextures(1, &amp;glTextureList[curid]); glBindTexture(GL_TEXTURE_2D, glTextureList[curFreeId]); </code></pre> <p>But this does...</p> <pre><code> unsigned int curFreeId = 0; unsigned int curid = curFreeId = 0; modStruct-&gt;t[ i ].gluId = curFreeId; glGenTextures(1, &amp;glTextureList[curid]); glBindTexture(GL_TEXTURE_2D, glTextureList[curFreeId]); </code></pre> <p>What is the world... Is this some glitch of some sort?</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