The glGenTextures function generates texture names.

void glGenTextures(
  GLsizei n,
  GLuint *textures


The number of texture names to be generated.
A pointer to the first element of an array in which the generated texture names are stored.


The glGenTextures function returns n texture names in the textures parameter. The texture names are not necessarily a contiguous set of integers, however, none of the returned names can have been in use immediately prior to calling the glGenTextures function. The generated textures assume the dimensionality of the texture target to which they are first bound with the glBindTexture function. Texture names returned by glGenTextures are not returned by subsequent calls to glGenTextures unless they are first deleted by calling glDeleteTextures.

You cannot include glGenTextures in display lists.

Note  The glGenTextures function is only available in OpenGL version 1.1 or later.

The following function retrieves information related to glGenTextures:


Error Codes

The following are the error codes generated and their conditions.

Error code Condition
GL_INVALID_VALUE n was a negative value.
GL_INVALID_OPERATION glGenTextures was called between a call to glBegin and the corresponding call to glEnd.


  Windows NT/2000: Requires Windows NT 4.0 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in Gl.h.
  Library: Use Opengl32.lib.

See Also

glBegin, glBindTexture, glDeleteTextures, glEnd, glGet, glGetTexParameter, glIsTexture, glTexImage1D, glTexImage2D, glTexParameter


Community Additions