I\'m trying to create a textureLoader class for my openGL project and I can\'t initialize an array of textures inside of my class constructor because the the array won\'t accept
Your second options is close, you can get at the underlying array of the vector by calling .data()
myConstructor(int num)
{
std::vector textures(num);
glGenTextures(num, textures.data());
}
Assuming glGenTextures
has a signature like
void glGenTextures(int, GLuint*)
I don't know much about this function, but be careful who owns that array. The vector
will fall out of scope after your constructor so I'm hoping that glGenTextures
will copy whatever it needs. Otherwise if the array needs to persist
myConstructor(int num)
{
GLuint* textures = new GLuint[num];
glGenTextures(num, textures);
}
But then I'm not sure who is supposed to clean up that memory.