glBindTexture problem

How do I use glBindTexture? - all the source code I can find is hopelessly unreadable and the OpenGL help file I have skips over most of it conveniantly. Simple examples preferred with some doc. if poss

I did have the same problem, months ago.
The fact is I was missing the meaning of the specs about binding texture objects.
In short, OGL drivers maintain several distinct objects (data structures), which hold texture data + parameters.
Binding works by associating a ‘name’(actually an integer value) to each texture object; each time you have to make a particular object active, you simply set the binding to the name you had.
Ok, now I will come up with an example.
Here, for clarity, I use exclusively 2D textures, that is GL_TEXTURE_2D as the target.

Initialization

unsigned texture_handle; // holds the name

//-- allocate a name
glGenTextures(1, &texture_handle);

//-- bind the named object to the target
// this will make the object’s data available // to all the operations on the associated target
glBindTexture(GL_TEXTURE_2D, texture_handle);

//-- set parameters
glTexParameterf(GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER,
GL_LINEAR);
// … other params …

glTexImage(GL_TEXTURE_2D,
0, // no mipmap LoD
4, // components
width,
height,
0, // no border
GL_RGBA,
GL_UNSIGNED_BYTE,
ptr_unsigned_char_tex_data);
);

Rendering of scene

//-- bind the named object
// this recalls all stored states for the object
glBindTexture(GL_TEXTURE_2D, texture_handle);
glEnable(GL_TEXTURE_2D);

// now subsequent operations that need
// texturing data will fetch the previously
// stored info from the bound object

//… draw geometry, specifying TexCoords

// the binding remains current until you call
// glBindTexture with another name

// when you don’t need anymore texturing, you
// simply disable it.
glDisable(GL_TEXTURE_2D);

That’s it. Have a try!

What does the “1” mean?
glGenTextures(1, &texture_handle);

In the tutorials I’ve read the texture_handle was a kind of GLuint? What kind of data is it (I’d think just a kind of integer) But how can that store a texture?
Is it possible to generate a texture from something like an arry of byte in which I place the RGB values for each pixel, it seems a lot easier than all the other stuff I read to me. And when yes how?
Thanx!

What about reading the docs ?
Choose your flavor :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc02_3p6b .asp
http://www.3dlabs.com/support/developer/GLmanpages/glgentextures.htm
http://pyopengl.sourceforge.net/documentation/manual/glGenTextures.3G.html

glGenTextures( n, *textures);
n: The number of texture names to be generated.
textures: A pointer to the first element of an array in which the generated texture names are stored.

You can see an OpenGL ‘name’ as an ID, an SQL key, it is a number that identifies a unique object (texture, display list, etc).

To specify actual texels data, read the above post about glTexImage, and the reference docs as well.