: Summary here is some questions that need to be paid to the texture map in OpenGL. It is not a complete teach you how to use textured textures in OpenGL, because you already have good information for us to choose, such as , . In the OpenGL API, there is no function of the load image file to get the function of pixel information, but these pixel information is necessary when defining the texture. In many cases, we need to write a function of loading the picture file to get pixel information. Below is the code to read the BMP file, get the code of pixel information: // In this code, it has been simplified, and the BMP image is a true color image of 24b char * loadBMPFF (const char * filename) {ifstream fileStream; fileStream. open (filename, fstream :: binary); // Note: The open mode must be specified fstream :: binary, or an error occurs BITMAPFILEHEADER header; fileStream.read ((char *) & header, sizeof (BITMAPFILEHEADER)); BITMAPINFO info; fileStream. Read ((char *) & info, header.bfoffbits-sizeof (BitmapfileHeader); int size = (info.bmiheader.biwidth * 3 3) & ~ 3) * info.bmiheader.biheight; Pixeldata = new char [size ]; FILESTREAM.READ (Pixeldata, size); Return Pixeldata;} When the above function is successful, the return value is a pointer to pixel information, which can be used as the last parameter of the glteximage2d () function. When using BMP images as a texture image, specifically, because the color space order of BMP is BGR, not a common RGB, the value of the Format parameter in GLTEXIMAGE2D () should be GL_BGR_EXT, not GL_RGB. Texture image size, (Including Width and Height, but these two values can be different), must be 2 N-powered forms, and the maximum and minimum values of the dimensions have certain limits. The maximum value is related to the specific OpenGL implementation, the minimum is not less than 64 * 64. Texture coordinates issue.