Как наложить текстуры на квад для того, чтобы текстурировать куб?

Недавно я изучал OpenGL, и я поднялся на сцену, где я хочу текстурировать вещи. Я думал, что начну с текстурирования простого куба. В настоящее время у меня есть этот код, и я полностью понимаю, как он работает:

#include <glut.h>

#define WINDOW_WIDTH 400
#define WINDOW_HEIGHT 400


float angle = 30.0f;

void Draw() {

  glLoadIdentity(); //Reset the drawing perspective
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clears the buffers

  //Add positioned light
  GLfloat lightColor0[] = {0.5f, 0.5f, 0.5f, 1.0f}; //Color intensity
  GLfloat lightPos0[] = {0.0f, 0.0f, 0.0f, 1.0f}; //Positioned at..
  glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0); //Set our light colour
  glLightfv(GL_LIGHT0, GL_POSITION, lightPos0); //Set our light position

  glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 200);

  glRotatef(angle,1.0f,1.0f,1.0f); //Rotate around the origin
  glScalef(0.4f, 0.4f, 0.4f); //Scale the shape down
  glBegin(GL_QUADS); //Start drawing a Quad
  glColor3f(1.0f,0.0f,0.0f); //Set the colour to Red
  glVertex3f( 1.0f, 1.0f,-1.0f); //Top right of the quad (Top Face)
  glVertex3f(-1.0f, 1.0f,-1.0f); //Top left of the quad (Top Face)
  glVertex3f(-1.0f, 1.0f, 1.0f); //Bottom left of the quad (Top Face)
  glVertex3f( 1.0f, 1.0f, 1.0f); //Bottom right of the quad (Top Face)
  glVertex3f( 1.0f,-1.0f, 1.0f); //Top right of the quad (Bottom Face)
  glVertex3f(-1.0f,-1.0f, 1.0f); //Top left of the quad (Bottom Face)
  glVertex3f(-1.0f,-1.0f,-1.0f); //Bottom left of the quad (Bottom Face)
  glVertex3f( 1.0f,-1.0f,-1.0f); //Bottom right of the quad (Bottom Face)
  glVertex3f( 1.0f, 1.0f, 1.0f); //Top right of the quad (Front Face)
  glVertex3f(-1.0f, 1.0f, 1.0f); //Top left of the quad (Front Face)
  glVertex3f(-1.0f,-1.0f, 1.0f); //Bottom left of the quad (Front Face)
  glVertex3f( 1.0f,-1.0f, 1.0f); //Bottom right of the quad (Front Face)
  glVertex3f( 1.0f,-1.0f,-1.0f); //Top right of the quad (Back Face)
  glVertex3f(-1.0f,-1.0f,-1.0f); //Top left of the quad (Back Face)
  glVertex3f(-1.0f, 1.0f,-1.0f); //Bottom left of the quad (Back Face)
  glVertex3f( 1.0f, 1.0f,-1.0f); //Bottom right of the quad (Back Face)
  glVertex3f(-1.0f, 1.0f, 1.0f); //Top right of the quad (Left Face)
  glVertex3f(-1.0f, 1.0f,-1.0f); //Top left of the quad (Left Face)
  glVertex3f(-1.0f,-1.0f,-1.0f); //Bottom left of the quad (Left Face)
  glVertex3f(-1.0f,-1.0f, 1.0f); //Bottom right of the quad (Left Face)
  glVertex3f( 1.0f, 1.0f,-1.0f); //Top right of the quad (Right Face)
  glVertex3f( 1.0f, 1.0f, 1.0f); //Top left of the quad (Right Face)
  glVertex3f( 1.0f,-1.0f, 1.0f); //Bottom left of the quad (Right Face)
  glVertex3f( 1.0f,-1.0f,-1.0f); //Bottom right of the quad (Right Face)
  glEnd(); //Finished Drawing The Quad
  glutSwapBuffers(); //Send the 3D scene to the screen
}

void Update(int value){ //Our update function
  angle+=0.5f; //Increase the angle by 5

  if(angle>360){ //If the angle is greater than 360
    angle=0; //Set the angle to 0
  }

  glutPostRedisplay(); //Tell it that the scene has changed
  glutTimerFunc(25,Update,0); //Call "Update" again in another 25ms
}

void Initialize() {
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_COLOR_MATERIAL);
  glEnable(GL_LIGHTING); //Enable lighting
  glEnable(GL_LIGHT0); //Enable light No. 0
  glEnable(GL_NORMALIZE); //Automatically "normalize" normals
  glShadeModel(GL_SMOOTH); //Enable smooth shading (nice effect)  

  glClearColor(0.0, 0.0, 0.0, 0.0); //Background RGBA
  glMatrixMode(GL_MODELVIEW); //MODELVIEW view
  glLoadIdentity(); //Start at origin
  glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); //Set the scale
  //X axis = 0 to 1. Y = 0 to 1. Z = -1 to 1.
}

int main() {
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); //The display mode
  glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT); //Window Size
  glutInitWindowPosition(200, 200); //Window Position
  glutCreateWindow("Lighting!"); //Creates a window with the name "Lighting!"
  Initialize(); //Call our initialize function.
  glutDisplayFunc(Draw); //"Draw" then refresh the window
  glutTimerFunc(25,Update,0); //Call "Update" 25ms after program starts
  glutMainLoop(); //Process events etc. Also keeps the window open.
  return 0; //End the program
}

Однако после прочтения многих, МНОГО текстурных руководств (я имею в виду буквально все те, которые я мог найти в Интернете); Я все еще не понимаю, как бы добавить его в эту программу. Я знаю, что мне нужно загрузить текстуру (как-то), а затем связать ее с помощью функции glBindTexture, прежде чем я начну рисовать куб, но я думаю, что есть что-то еще, что мне нужно сделать в промежутке (и я не знаю, как загрузить изображение правильно тоже).

Ответы на вопрос(5)

Ваш ответ на вопрос