Crashes after 3rd glGenTextures

Edit: Damn I meant its glTexImage2D in the subject.

I use 3 textures, all 512x512 RGB. Heres the code

GLvoid Opengl_Init(GLvoid)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glShadeModel(GL_FLAT);
glLineWidth(2.5);

glGenTextures(1, &StartupTex_Name);
glBindTexture(GL_TEXTURE_2D, StartupTex_Name);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, startscreen);

glGenTextures(2, &MainmenuTex_Name);
glBindTexture(GL_TEXTURE_2D, MainmenuTex_Name);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, mainmenu);

glGenTextures(3, &HelpTex_Name);
glBindTexture(GL_TEXTURE_2D, HelpTex_Name);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, helpscreen);

}

Now it crashes on the last glTexImage2D (helpscreen) though I cant see how! The pointer helpscreen does contain the bitmap, I tested it by outputting them.
So can anyone help me?

[This message has been edited by blood.angel (edited 07-06-2003).]

do you have declarations like this:

GLuint startscreen;
GLuint mainmenu[2];
GLuint helpscreen[3];

because you are generating 1 texture name and storing it at address &startscreen, 2 names at &mainmenu and 3 names at &helpscreen… i think this is your mistake. if not, are startscreen, mainmenu and helpscreen arrays of GLuint? are you using drivers compatible with your os? are you sure you haven’t corrupted something before? and so on…

[This message has been edited by miko (edited 07-06-2003).]

I had it working when helpscreen, startscreen and mainmenu were arrays (eg GLubyte helpscreen[512][512][3]) but I thought that was not elegant and wanted to change them to GLubyte* calloc(5125123, sizeof(GLubyte)) allocated arrays instead.

Now its stumped me why it doesnt work. Ive forced the three to output what they store to .raw files before the above listed function and all three are perfect.

[This message has been edited by blood.angel (edited 07-06-2003).]

[This message has been edited by blood.angel (edited 07-06-2003).]

Nevermind, I went back to test them again. Somehow the pics ares getting passed back from the reading function.

Stil, pretty weird why the error shows up here though.

Ignore my last post.
IT DOES PASS the textures properly.
So Im back at still having the problem.

Can you pass (Glubyte *) arrays to glTexImage2D in the first place?

Originally posted by miko:
[b]do you have declarations like this:

GLuint startscreen;
GLuint mainmenu[2];
GLuint helpscreen[3];

because you are generating 1 texture name and storing it at address &startscreen, 2 names at &mainmenu and 3 names at &helpscreen… i think this is your mistake. if not, are startscreen, mainmenu and helpscreen arrays of GLuint? are you using drivers compatible with your os? are you sure you haven’t corrupted something before? and so on…

[This message has been edited by miko (edited 07-06-2003).][/b]

Thanks that was it!
From reading the red book I thought it meant you could state the number for its label. Its a bit vague explaining it IMO.

And its weird that it worked when the bitmaps were stored in 3D arrays.
Thanks again.

yup… next time i will not post at 3am i wanted this

// startup screen will be covered by single texture
GLuint StartupTex_Name;
// i will need 2 textures for mainmenu
GLuint MainmenuTex_Name[2];
// help will be veeeery big it will require 3 textures
GLuint HelpTex_Name[3];

but i assume this is not the think you wanted to do. i assume you wanted a single texture for startup, menu and help. you should solve it like this:

GLuint temp[3], StartupTex_Name,
MainmenuTex_Name,
HelpTex_Name;
unsigned char startscreen[5125123];
unsigned char mainmenu[5125123];
unsigned char helpscreen[5125123];

/*
fill startscreen, mainmenu and helpscreen with some data
*/

glGenTextures(3, &temp);
StartupTex_Name = temp[0];
MainmenuTex_Name = temp[1];
HelpTex_Name = temp[2];

glBindTexture(GL_TEXTURE_2D,StartupTex_Name);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, startscreen);

glBindTexture(GL_TEXTURE_2D, MainmenuTex_Name);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, mainmenu);

glBindTexture(GL_TEXTURE_2D, HelpTex_Name);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, helpscreen);

or

glGenTextures(1, &StartupTex_Name);
glBindTexture(GL_TEXTURE_2D, StartupTex_Name);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, startscreen);

glGenTextures(1, &MainmenuTex_Name);
glBindTexture(GL_TEXTURE_2D, MainmenuTex_Name);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, mainmenu);
glGenTextures(1, &HelpTex_Name);
glBindTexture(GL_TEXTURE_2D, HelpTex_Name);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, helpscreen);

this is all what i tried to say but… i screwed it up and i hope it’s clear now

[This message has been edited by miko (edited 07-06-2003).]