| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -47,11 +47,11 @@ static const Vertex vertices[3] = | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}; | 
					 | 
					 | 
					 | 
					}; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					static const char* vertex_shader_text = | 
					 | 
					 | 
					 | 
					static const char* vertex_shader_text = | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"#version 110\n" | 
					 | 
					 | 
					 | 
					"#version 330\n" | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"uniform mat4 MVP;\n" | 
					 | 
					 | 
					 | 
					"uniform mat4 MVP;\n" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"attribute vec3 vCol;\n" | 
					 | 
					 | 
					 | 
					"in vec3 vCol;\n" | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"attribute vec2 vPos;\n" | 
					 | 
					 | 
					 | 
					"in vec2 vPos;\n" | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"varying vec3 color;\n" | 
					 | 
					 | 
					 | 
					"out vec3 color;\n" | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"void main()\n" | 
					 | 
					 | 
					 | 
					"void main()\n" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"{\n" | 
					 | 
					 | 
					 | 
					"{\n" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"    gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n" | 
					 | 
					 | 
					 | 
					"    gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n" | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -59,11 +59,12 @@ static const char* vertex_shader_text = | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"}\n"; | 
					 | 
					 | 
					 | 
					"}\n"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					static const char* fragment_shader_text = | 
					 | 
					 | 
					 | 
					static const char* fragment_shader_text = | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"#version 110\n" | 
					 | 
					 | 
					 | 
					"#version 330\n" | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"varying vec3 color;\n" | 
					 | 
					 | 
					 | 
					"in vec3 color;\n" | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					"out vec4 fragment;\n" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"void main()\n" | 
					 | 
					 | 
					 | 
					"void main()\n" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"{\n" | 
					 | 
					 | 
					 | 
					"{\n" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"    gl_FragColor = vec4(color, 1.0);\n" | 
					 | 
					 | 
					 | 
					"    fragment = vec4(color, 1.0);\n" | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					"}\n"; | 
					 | 
					 | 
					 | 
					"}\n"; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					static void error_callback(int error, const char* description) | 
					 | 
					 | 
					 | 
					static void error_callback(int error, const char* description) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -84,8 +85,9 @@ int main(void) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (!glfwInit()) | 
					 | 
					 | 
					 | 
					    if (!glfwInit()) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        exit(EXIT_FAILURE); | 
					 | 
					 | 
					 | 
					        exit(EXIT_FAILURE); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); | 
					 | 
					 | 
					 | 
					    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); | 
					 | 
					 | 
					 | 
					    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    GLFWwindow* window = glfwCreateWindow(640, 480, "OpenGL Triangle", NULL, NULL); | 
					 | 
					 | 
					 | 
					    GLFWwindow* window = glfwCreateWindow(640, 480, "OpenGL Triangle", NULL, NULL); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (!window) | 
					 | 
					 | 
					 | 
					    if (!window) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -124,6 +126,9 @@ int main(void) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const GLint vpos_location = glGetAttribLocation(program, "vPos"); | 
					 | 
					 | 
					 | 
					    const GLint vpos_location = glGetAttribLocation(program, "vPos"); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const GLint vcol_location = glGetAttribLocation(program, "vCol"); | 
					 | 
					 | 
					 | 
					    const GLint vcol_location = glGetAttribLocation(program, "vCol"); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    GLuint vertex_array; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    glGenVertexArrays(1, &vertex_array); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    glBindVertexArray(vertex_array); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    glEnableVertexAttribArray(vpos_location); | 
					 | 
					 | 
					 | 
					    glEnableVertexAttribArray(vpos_location); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE, | 
					 | 
					 | 
					 | 
					    glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                          sizeof(Vertex), (void*) offsetof(Vertex, pos)); | 
					 | 
					 | 
					 | 
					                          sizeof(Vertex), (void*) offsetof(Vertex, pos)); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -148,6 +153,7 @@ int main(void) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        glUseProgram(program); | 
					 | 
					 | 
					 | 
					        glUseProgram(program); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) mvp); | 
					 | 
					 | 
					 | 
					        glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) mvp); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        glBindVertexArray(vertex_array); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        glDrawArrays(GL_TRIANGLES, 0, 3); | 
					 | 
					 | 
					 | 
					        glDrawArrays(GL_TRIANGLES, 0, 3); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        glfwSwapBuffers(window); | 
					 | 
					 | 
					 | 
					        glfwSwapBuffers(window); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |