Texture not appearing

Hello everybody, i’m new in this forum.
I’ve started OpenGL (using c++) about 2 weeks ago. I pretty much like using windows api.

I’m making a program where it checks all the files in a directory and saves their path in a dynamic array : char *nameTextures
And the total number of textures found is:
int totalTextures;

Then I would like to bind for example the first Texture on a Quad.

Here’s the part of my code where i’m trying to load all the textures using their path.
(I took a code from NeHe’s tutorial and changed some parts of it)

int x,counter=0;
AUX_RGBImageRec *TextureImage[totalTextures];
	
texture = (GLuint*)malloc(sizeof(GLuint)*totalTextures);
if( texture==NULL ) return 0;
	
memset(TextureImage,0,sizeof(void *)*totalTextures);

for(x=0;x<totalTextures;x++)
{
	char filename[MAX_PATH];
	strcpy(filename,nameTextures+x*MAX_PATH);
	TextureImage[x]=auxDIBImageLoad(filename);
	if( TextureImage[x] ) counter++;
	
}

if( counter==totalTextures )
{
	STATUS=1;
	glGenTextures(totalTextures, texture);
		
	for(x=0;x<totalTextures;x++)
	{
		glPixelStorei(GL_UNPACK_ALIGNMENT,4);
		glBindTexture(GL_TEXTURE_2D, texture[x]);
		showNum("sizeX",TextureImage[x]->sizeX);
		showNum("sizeY",TextureImage[x]->sizeY);
		glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[x]->sizeX, TextureImage[x]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[x]->data);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
		glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
	}
}
for(x=0;x<totalTextures;x++)
{
	if(TextureImage[x])
	{
		if(TextureImage[x]->data)
		{
			free(TextureImage[x]->data);
		}
		free(TextureImage[x]);
	}
}

then here’s the part where i try to draw a white triangle and a quad which is supposed to have a texture on it.

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glBegin(GL_TRIANGLES);
	glColor3f(1.0f,1.0f,1.0f);
	glVertex3f(-5.0f,-15.0f,-30.0f);
	glVertex3f(5.0f,-15.0f,-30.0f);
	glVertex3f(0.0f,-10.0f,-30.0f);
glEnd();
glTranslatef(0.0f,0.0f,-5.0f);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glBegin(GL_QUADS);
	glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
	glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	
	glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);		
	glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	
glEnd();

What i get is:

a white triangle at the bottom of the screen (OK)
a white square in the middle of the screen (NOT OK)

could someone tell me if i’ve made mistakes and help me correct them?
thanks

try :

glDisable(GL_TEXTURE2D);
<triangle stuff>

glEnable(GL_TEXTURE2D);
<quad stuff>

Please be sure you have correctly loaded the bmpfile into texture object.

OK my problem is solved.
In fact, i tried using your solutions but unfortunately none of them made the texture appear.

The problem was:
I was loading the textures before the GL context was created (at the beginning of the MAIN).
I don’t really know if that’s the cause but loading all my textures after creating the GL context solved everything.

Thanks for your time and solutions!

you’re right, before you can use any gl* function, a valid context has to be created and made current.