// 중간생략…
GLuint SetSquareData()
 // Vertice Positions
 squareVertices.push_back(glm::vec3(-0.75f, -0.75f, 0.0f));
 squareVertices.push_back(glm::vec3(0.75f, -0.75f, 0.0f));
 squareVertices.push_back(glm::vec3(0.75f, 0.75f, 0.0f));
 squareVertices.push_back(glm::vec3(-0.75f, 0.75f, 0.0f));
 // Vertices Textures
 squareTextureCoords.push_back(glm::vec2(0.0f, 0.0f));
 squareTextureCoords.push_back(glm::vec2(1.0f, 0.0f));
 squareTextureCoords.push_back(glm::vec2(1.0f, 1.0f));
 squareTextureCoords.push_back(glm::vec2(0.0f, 1.0f));

 // Vertice Indices

 // VAO
 GLuint vao;
 glGenVertexArrays(1, &vao);

 // VBO
 GLuint vbo[2];
 glGenBuffers(2, &vbo[0]);
 glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
 glBufferData(GL_ARRAY_BUFFER, 4*sizeof(glm::vec3), &squareVertices[0], GL_STATIC_DRAW);
 glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
 glBindBuffer(GL_ARRAY_BUFFER, vbo[1]);
 glBufferData(GL_ARRAY_BUFFER, 4*sizeof(glm::vec2), &squareTextureCoords[0], GL_STATIC_DRAW);
 glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, 0);

 // IBO
 GLuint ibo;
 glGenBuffers(1, &ibo);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6*sizeof(int), &squareIndices[0], GL_STATIC_DRAW);


 return vao;

#version 330

// Input vertex data
layout (location = 0) in vec3 vPosition; // vertex position (in model space)
layout (location = 1) in vec2 vTexCoord; // texture coordinate (in model space)

// Output data will be interpolated for each fragment.
out vec2 TexCoordPass;

// Values that stay constant for the whole mesh.
uniform mat4 gMVP;

void main()
 // Output position of the vertex, in clip space : gMVP * position
 gl_Position =  gMVP * vec4(vPosition,1);

 TexCoordPass = vTexCoord;

#version 330

// Interpolated values from the vertex shaders
in vec2 TexCoordPass;

// Ouput data
out vec4 Color;

// Values that stay constant for the whole mesh.
uniform sampler2D gTextureSampler;

void main()
 // Output color = color of the texture at the specified UV
 Color = texture2D(gTextureSampler, TexCoordPass);


사용자 삽입 이미지
Ambient/Diffuse/Specular (From left to right: diffuse; ambient; diffuse + ambient; diffuse+ambient+specular) from lighthouse3d.com

사용자 삽입 이미지Light sources (From left to right: directional; point; and spotlights) from lighthouse3d.com