Declaration

Hi,

I draw a textured cube . I have one .cpp file in which i wrote all the code(code for textures and the cube code).I want to separate the code to 2 .cpp files.
In the first the texture loader and texture declarations and in the second the draw cube code. I separate the codes but when i run this two .cpp files it shows me the error for undeclared undentifier in the draw-cube .cpp file which is logical.
How i connect this two .cpp files ?

Plz help…

the tuxture loader .cpp

         
GLuint loadTextureSkybox1     (Image* imageSky1) {
	GLuint textureIdSky1;
	glGenTextures(1, &textureIdSky1); //Make room for our texture
	glBindTexture(GL_TEXTURE_2D, textureIdSky1); //Tell OpenGL which texture to edit
	//Map the image to the texture
	
	glTexImage2D(GL_TEXTURE_2D,                //Always GL_TEXTURE_2D
				 0,                            //0 for now
				 GL_RGB,                       //Format OpenGL uses for image
				 imageSky1->width, imageSky1->height,  //Width and height
				 0,                            //The border of the image
				 GL_RGB, //GL_RGB, because pixels are stored in RGB format
				 GL_UNSIGNED_BYTE, //GL_UNSIGNED_BYTE, because pixels are stored
				                   //as unsigned numbers
				 imageSky1->pixels);               //The actual pixel data
	return textureIdSky1; //Returns the id of the texture
}




GLuint _textureIdSky1;
GLUquadric *quadSky1;


void LoadBMP()
{
	quadSky1 = gluNewQuadric();
    Image* imageSky1 = loadBMP("up.bmp");
    _textureIdSky1 = loadTextureSkybox1(imageSky1);
	delete imageSky1;
}

the draw-cube with the load-texture parameters


	glBindTexture(GL_TEXTURE_2D, _textureIdSky1);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	SkyBoxT();

This obviously can’t be the entire contents of the two files? What do you mean by “running two .cpp files”? What does the compile log look like? What is undeclared?

It appears to me that the main issue is not OpenGL® related but rather a lack of in-depth understanding of the programming language you are using, or specifically, how the code is compiled and how the C++ compiler & linker work together.

It might be more appropriate to read up on those C++ related topics and/or consult a C++ community board.

Other than that there is little additional advice to give without at least a compile log.

Anyhow:

In C++, an identifier is one of the following:

[ul]
[li] Object or variable name[/li][li]Class, structure, or union name[/li][li]Enumerated type name[/li][li]Member of a class, structure, union, or enumeration[/li][li]Function or class-member function[/li][li]typedef name[/li][li]Label name[/li][li]Macro name[/li][li]Macro parameter[/li][/ul]

The compiler complains about undefined identifiers when you are using something that obviously is an identifyer, but the compiler has never seen it being defined before. You are probably using some method or function or whatever in one file, but it is in the other file. You need to declare it, so the compiler knows that it exists externally when compiling a source file (C++ files are compiled as individual translation units). The declarations are normally written in header files, which are then incldued by both source files.