// Generate texture-meta-data for the texture. glGenTextures(1, &this->ImageTexture.at(CurrentTexture)); // Bind with our texture, then transfer the pixel-data from the surface to the texture and // set some wrap and scaling attributes. glBindTexture(GL_TEXTURE_2D, this->ImageTexture.at(CurrentTexture)); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ImageSurface->w, ImageSurface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ImageSurface->pixels); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Create a List to hold the precompiled ImageQuad. this->ImageList.push_back(glGenLists(1)); int CurrentList = this->ImageList.size() - 1; // Create list-item for the current sprite. glNewList(this->ImageList.at(CurrentList), GL_COMPILE); // Bind to the current texture glBindTexture(GL_TEXTURE_2D, this->ImageTexture.at(CurrentTexture)); // Draw a rectangle (Quad = four points) // Counter-clockwise to have the polygon face the camera // Clockwise to have the polygon face away from the camera glBegin(GL_QUADS); // Top Left glTexCoord2f(0, 0); glVertex2i(0, 0); // Bottom Left glTexCoord2f(0, 1); glVertex2i(0, ImageSurface->h); // Bottom Right glTexCoord2f(1, 1); glVertex2i(ImageSurface->w, ImageSurface->h); // Top Right glTexCoord2f(1, 0); glVertex2i(ImageSurface->w, 0); // Finish the GL command glEnd(); // Finish the Compiled List-item. glEndList();