Sign in to follow this  

[RESOLVED]GLuint arrays -- possible?

This topic is 4208 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i'm trying to write a function that will use DevIL (formerly known as openil) to load a texture and bind it to a GLuint from a GLuint array. however, when i compile and run this program (i'm using dev-c++ 4.9.9.2 if that makes any difference) it crashes before starting. is it even possible to create a GLuint array? and if so, how do you access the different array elements? the thing is, when i don't try to use the "index" variable to acces the array element and instead hard code it, "Texture[0]" versus "Texture[index]" when index is 0, it works. the function declaration and the GLuint array:
void TESTLOADTEXTURES(char *name, int index);
GLuint Texture[2];



the function definition:
void TESTLOADTEXTURES(char *name, int index)
{
  ILuint ImageName;
  ilGenImages(1, &ImageName);
  ilBindImage(ImageName);
  ilLoadImage(name);
  Texture[index] = ilutGLBindMipmaps();
  ilDeleteImages(1, &ImageName);
}



the function calls:
  TESTLOADTEXTURES("blah.png", 0);
  TESTLOADTEXTURES("grass.png", 1);



i have tried to test it using one call, but it doesn't work then either. it only works when i don't use the "index" variable as the array index. i have tried to find info online about creating GLuint arrays, but so far haven't been too successful. [Edited by - supercat1 on June 11, 2006 1:58:53 PM]

Share this post


Link to post
Share on other sites
GLuint array is very much possible. What you might be doing wrong is using OpenIL/DevIL incorrectly. Have you tried to trace back once the program crashes which will give you an indication of whats going wrong.

Share this post


Link to post
Share on other sites
Quote:
Original post by ivarbug
GLuint is equivalent to unsigned int.

a line from gl.h
*** Source Snippet Removed ***

There are no such guarantees in the specification though. Looking in gl.h just tells you want your implementation typedefs GLuint to, nothing more.

Share this post


Link to post
Share on other sites
yeah, i got the "GLuint is an int" from other sources, but for some reason i still had trouble accessing the array. at least that is what i think it was because when i used a GLuint variable named Texture1 and Texture2 instead of Texture[0] and Texture[1] it would work (but that of course was then hard coded and not too flexible). having said that though, i did figure out a method that would work -- and for anyone else (probably not many others in my place) that has the issue or wants to see my solution, here it is:


// the declarations (notice, there is no longer a function for assigning textures)
GLuint Texture[2];
char* texturefilenames[2];

// the actual texture creating and assignments
texturefilenames[0] = "grass.png";
texturefilenames[1] = "blah.png";
for(int i = 0; i < 2; i++)
{
cout << "Loading texture " << i << endl;
glBindTexture(1, Texture[i]);
Texture[i] = ilutGLLoadImage(texturefilenames[i]);
}



the reason there is an array of char*'s is because i want to be able to load textures without knowing the file names before compilation. so the idea is there will be function that opens a file that has all the texture file names. we'll see how that goes (probably gonna be another post about "help me i can't figure this out" and then when it isn't 3am i'll get it).

thanks for the help though!

Share this post


Link to post
Share on other sites

This topic is 4208 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this