What is the contents of an array that is created on the stack, but has no values put in it? Like this:
int array[4]
cout << array[2];
I ask this because I have always seen in OpenGL when textures are generated, it is done like this:
GLuint textures[4];
glGenTextures(4, &textures[0]);
glBindTexture(GL_TEXTURE_2D, textures[2]);
What is the deal with this?
Thanks.
The contents could be anything. Often it’s something left there by a previous function, but no guarantees are made.
glGenTexturesfills in its second argument, which is passed by pointer. Nothing is using the uninitialized value. Just liketextures[0] = 0;, it’s overwriting whatever garbage was present.