void tetrahedron(int n) { divide_triangle(v[0], v[1], v[2], n); divide_triangle(v[3], v[2], v[1], n); divide_triangle(v[0], v[3], v[1], n); divide_triangle(v[0], v[3], v[2], n); }
/* triangle subdivision using vertex numbers righthand rule applied to create outward pointing faces */ void divide_triangle(point3 a, point3 b, point3 c, int m) { point3 v1, v2, v3; int j; if (m > 0) { for (j = 0; j < 3; j++) v1[j] = a[j] + b[j]; Normal(v1); for(j = 0; j < 3; j++) v2[j] = a[j] + c[j]; Normal(v2); for (j = 0; j < 3; j++) v3[j] = b[j] + c[j]; Normal(v3); divide_triangle(a, v1, v2, m-1); divide_triangle(c, v2, v3, m-1); divide_triangle(b, v3, v1, m-1); divide_triangle(v1, v3, v2, m-1); } else { /* draw triangle at end of recursion */ triangle(a, b, c); } }
std::vector< vec4 > LitSphereMesh::divide_triangle(vec4 a, vec4 b, vec4 c, int n) { std::vector< vec4 > vertices; vec4 v1, v2, v3; // recurse if(n > 0) { v1 = unit(a + b); v2 = unit(a + c); v3 = unit(b + c); std::vector< vec4 > t; t = divide_triangle(a ,v2, v1, n-1); vertices.insert( vertices.end(), t.begin(), t.end() ); t = divide_triangle(c ,v3, v2, n-1); vertices.insert( vertices.end(), t.begin(), t.end() ); t = divide_triangle(b ,v1, v3, n-1); vertices.insert( vertices.end(), t.begin(), t.end() ); t = divide_triangle(v1 ,v2, v3, n-1); vertices.insert( vertices.end(), t.begin(), t.end() ); return vertices; } // end recursion else { // just create a triangle and return it std::vector< vec4 > t; t.push_back(a); t.push_back(b); t.push_back(c); //t = triangle(a, b, c); vertices.insert( vertices.end(), t.begin(), t.end() ); return vertices; } }
void divide_triangle(point3 a,point3 b,point3 c, int m){ point3 v1,v2,v3; if(m>0){ for(int j=0;j<3;j++){ v1[j]=a[j]+b[j]; } normal(v1); for(int j=0;j<3;j++){ v2[j]=a[j]+c[j]; } normal(v2); for(int j=0;j<3;j++){ v3[j]=c[j]+b[j]; } normal(v3); divide_triangle(a,v1,v2,m-1); divide_triangle(c,v2,v3,m-1); divide_triangle(b,v3,v1,m-1); divide_triangle(v1,v3,v2,m-1); } else { triangle(a,b,c); } };
void square(int r) { glColor3fv(colors[current_color]); divide_triangle(vertices[0], vertices[1], vertices[3], r); divide_triangle(vertices[1], vertices[2], vertices[3], r); }
void tetrahedron(int m) /* Apply triangle subdivision to faces of tetrahedron */ { divide_triangle(v[0], v[1], v[2], m); divide_triangle(v[3], v[2], v[1], m); divide_triangle(v[0], v[3], v[1], m); divide_triangle(v[0], v[2], v[3], m); }
void tetrahedron(int count) { vec4 v[4] = { vec4(0.0, 0.0, 1.0, 1.0), vec4(0.0, 0.942809, -0.333333, 1.0), vec4(-0.816497, -0.471405, -0.333333, 1.0), vec4(0.816497, -0.471405, -0.333333, 1.0) }; divide_triangle(v[0], v[1], v[2], count); divide_triangle(v[3], v[2], v[1], count); divide_triangle(v[0], v[3], v[1], count); divide_triangle(v[0], v[2], v[3], count); }
void tetrahedron(int m) { glColor3f(1.0,0.0,0.0); divide_triangle(v[0],v[1],v[2],m); glColor3f(0.0,1.0,0.0); divide_triangle(v[3],v[2],v[1],m); glColor3f(0.0,0.0,1.0); divide_triangle(v[0],v[3],v[1],m); glColor3f(0.0,0.0,0.0); divide_triangle(v[0],v[2],v[3],m); }
void tetrahedron(int m) { glColor3fv(palette[color]); divide_triangle(v[0],v[1],v[2],m); glColor3fv(palette[color+6]); divide_triangle(v[3],v[2],v[1],m); glColor3fv(palette[color+12]); divide_triangle(v[0],v[3],v[1],m); glColor3fv(palette[color+18]); divide_triangle(v[0],v[2],v[3],m); }
void divide_triangle(vec4 a, vec4 b, vec4 c, int n) { vec4 v1, v2, v3; if(n>0) { v1 = unit(a + b); v2 = unit(a + c); v3 = unit(b + c); divide_triangle(a , v2, v1, n-1); divide_triangle(c , v3, v2, n-1); divide_triangle(b , v1, v3, n-1); divide_triangle(v1, v2, v3, n-1); } else triangle(a, b, c); }
void divide_triangle(const vec4& a, const vec4& b, const vec4& c, int count) { if (count > 0) { vec4 v1 = unit(a + b); vec4 v2 = unit(a + c); vec4 v3 = unit(b + c); divide_triangle(a, v1, v2, count - 1); divide_triangle(c, v2, v3, count - 1); divide_triangle(b, v3, v1, count - 1); divide_triangle(v1, v3, v2, count - 1); } else { triangle(a, b, c); } }
void LitSphereMesh::init(int n) { std::vector< vec4 > vertices; // 4 points on a tetrahedron vec4 v[4]= { vec4(0.0, 0.0, 1.0, 1.0), vec4(0.0, 0.942809, -0.333333, 1.0), vec4(-0.816497, -0.471405, -0.333333, 1.0), vec4(0.816497, -0.471405, -0.333333, 1.0) }; // recursive subdivision, add to vertex list std::vector< vec4 > t; t = divide_triangle(v[0], v[1], v[2] , n); vertices.insert( vertices.end(), t.begin(), t.end() ); t = divide_triangle(v[3], v[2], v[1], n ); vertices.insert( vertices.end(), t.begin(), t.end() ); t = divide_triangle(v[0], v[3], v[1], n ); vertices.insert( vertices.end(), t.begin(), t.end() ); t = divide_triangle(v[0], v[2], v[3], n ); vertices.insert( vertices.end(), t.begin(), t.end() ); // put sphere vertices in buffer glGenBuffers(1, &bufferId_vertices); glBindBuffer(GL_ARRAY_BUFFER, bufferId_vertices); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices[0]) * vertices.size(), &vertices.front(), GL_STATIC_DRAW); vertexStride = sizeof(vertices[0]); drawNum = vertices.size(); // create lines to visualize normals std::vector< vec3 > visualizeNormals; for (int i = 0; i < vertices.size(); i++) { vec4 v4 = vertices[i]; vec3 v(v4.x, v4.y, v4.z); visualizeNormals.push_back(v); visualizeNormals.push_back(v + (0.3 * v)); } visualizeNormalsDrawNum = visualizeNormals.size(); // load into normal visualization buffer glGenBuffers(1, &bufferId_visualizeNormals); glBindBuffer(GL_ARRAY_BUFFER, bufferId_visualizeNormals); glBufferData(GL_ARRAY_BUFFER, sizeof(visualizeNormals[0]) * visualizeNormals.size(), &visualizeNormals.front(), GL_STATIC_DRAW); std::cout << "Init sphere with " << n << " subdivisions resulting in " << vertices.size() << " vertices." << std::endl; }
void divide_triangle(vec *corners, std::vector<triangle> &indices, std::vector<vec> &vertices, int depth){ // Creating the triangle vertices.push_back(corners[0]); vertices.push_back(corners[1]); vertices.push_back(corners[2]); triangle temp_tri; temp_tri.ab = vertices.size() - 3; temp_tri.bc = vertices.size() - 2; temp_tri.ca = vertices.size() - 1; indices.push_back(temp_tri); vec temp_corners[3]; //std::cout << vertices.size() << '\t' << indices.size() << '\n'; //print(corners[0]); //print(corners[1]); //print(corners[2]); //std::cout << temp_tri.ab << '\t' << temp_tri.bc << '\t' // << temp_tri.ca << '\n'; if (depth > 0){ // Top triangle temp_corners[0] = corners[0]; temp_corners[1] = (corners[0] + corners[1]) / 2.0; temp_corners[2] = (corners[0] + corners[2]) / 2.0; divide_triangle(temp_corners, indices, vertices, depth - 1); // bottom left temp_corners[0] = corners[1]; temp_corners[1] = (corners[1] + corners[0]) / 2.0; temp_corners[2] = (corners[1] + corners[2]) / 2.0; divide_triangle(temp_corners, indices, vertices, depth - 1); // bottom center temp_corners[0] = (corners[1] + corners[2]) / 2.0; temp_corners[1] = (corners[0] + corners[1]) / 2.0; temp_corners[2] = (corners[0] + corners[2]) / 2.0; divide_triangle(temp_corners, indices, vertices, depth - 1); // bottom right temp_corners[0] = corners[2]; temp_corners[1] = (corners[2] + corners[1]) / 2.0; temp_corners[2] = (corners[2] + corners[0]) / 2.0; divide_triangle(temp_corners, indices, vertices, depth - 1); } }
void tetrahedron( int m) { /* Apply triangle subdivision to faces of tetrahedron */ glColor3f(1.0,0.0,0.0); divide_triangle(v[0], v[1], v[2], m); glColor3f(0.0,1.0,0.0); divide_triangle(v[3], v[2], v[1], m); glColor3f(0.0,0.0,1.0); divide_triangle(v[0], v[3], v[1], m); glColor3f(0.0,0.0,0.0); divide_triangle(v[0], v[2], v[3], m); }
void display1() { float v[4][3]={{0,1,0},{.5,-.5,0},{-.5,-.5,0},{0,0,1}}; glClearColor(1,1,1,1); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1,0,0); divide_triangle(v[0],v[1],v[2],n); glColor3f(0,1,0); divide_triangle(v[3],v[2],v[0],n); glColor3f(0,0,1); divide_triangle(v[3],v[0],v[1],n); glColor3f(1,0,1); divide_triangle(v[3],v[1],v[2],n); glFlush(); }
void Planet::tetrahedron( int count, shader s ) { point4 v[4] = { vec4( 0.0, 0.0, 1.0, 1.0 ), vec4( 0.0, 0.942809, -0.333333, 1.0 ), vec4( -0.816497, -0.471405, -0.333333, 1.0 ), vec4( 0.816497, -0.471405, -0.333333, 1.0 ) }; divide_triangle( v[0], v[1], v[2], count, s ); divide_triangle( v[3], v[2], v[1], count, s ); divide_triangle( v[0], v[3], v[1], count, s ); divide_triangle( v[0], v[2], v[3], count, s ); }
void Sphere::divide_triangle( const point4& a, const point4& b, const point4& c, int count ) { if ( count > 0 ) { point4 v1 = unit( a + b ); point4 v2 = unit( a + c ); point4 v3 = unit( b + c ); divide_triangle( a, v1, v2, count - 1 ); divide_triangle( c, v2, v3, count - 1 ); divide_triangle( b, v3, v1, count - 1 ); divide_triangle( v1, v3, v2, count - 1 ); } else { triangle( a, b, c ); } }
void divide_triangle(point a,point b,point c,int m) { point v1,v2,v3; int j; if(m>0) { for(j=0;j<3;j++) v1[j]=(a[j]+b[j])/2; for(j=0;j<3;j++) v2[j]=(a[j]+c[j])/2; for(j=0;j<3;j++) v3[j]=(b[j]+c[j])/2; divide_triangle(a,v1,v2,m-1); divide_triangle(c,v2,v3,m-1); divide_triangle(b,v3,v1,m-1); } else (triangle(a,b,c)); }
void Planet::divide_triangle( const point4& a, const point4& b, const point4& c, int count, shader s ) { if ( count > 0 ) { point4 v1 = unit( a + b ); point4 v2 = unit( a + c ); point4 v3 = unit( b + c ); divide_triangle( a, v1, v2, count - 1, s ); divide_triangle( c, v2, v3, count - 1, s ); divide_triangle( b, v3, v1, count - 1, s ); divide_triangle( v1, v3, v2, count - 1, s ); } else { triangle( a, b, c, s ); } }
void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_TRIANGLES); divide_triangle(v[0], v[1], v[2], n); glEnd(); glFlush(); }
void divide_triangle(GLfloat *a, GLfloat *b, GLfloat *c, int m) { /* triangle subdivision using vertex numbers */ GLfloat v0[2], v1[2], v2[2]; int j; if(m>0) { for(j=0; j<2; j++) v0[j]=(a[j]+b[j])/2; for(j=0; j<2; j++) v1[j]=(a[j]+c[j])/2; for(j=0; j<2; j++) v2[j]=(b[j]+c[j])/2; divide_triangle(a, v0, v1, m-1); divide_triangle(c, v1, v2, m-1); divide_triangle(b, v2, v0, m-1); } else triangle(a,b,c); /* draw triangle at end of recursion */ }
void divide_triangle(point a, point b, point c, int m) { /* triangle subdivision using vertex numbers righthand rule applied to create outward pointing faces */ point v1, v2, v3; int j; if(m>0) { for(j=0; j<3; j++) v1[j]=(a[j]+b[j])/2; for(j=0; j<3; j++) v2[j]=(a[j]+c[j])/2; for(j=0; j<3; j++) v3[j]=(b[j]+c[j])/2; divide_triangle(a, v1, v2, m-1); divide_triangle(c, v2, v3, m-1); divide_triangle(b, v3, v1, m-1); } else(triangle(a,b,c)); /* draw triangle at end of recursion */ }
void divide_triangle(float *a,float *b,float *c,int n) { float ab[3],bc[3],ac[3]; int j; if(n>0) { for(j=0;j<3;j++) { ab[j]=(a[j]+b[j])/2; bc[j]=(b[j]+c[j])/2; ac[j]=(a[j]+c[j])/2; } divide_triangle(a,ab,ac,n-1); divide_triangle(ab,b,bc,n-1); divide_triangle(ac,bc,c,n-1); } else triangle(a,b,c); }
void divide_triangle(point a, point b, point c, int r) { point v1, v2, v3; int j; if (r > 0) { for (j = 0; j < 3; j++) v1[j] = (a[j] + b[j])/2.0; for (j = 0; j < 3; j++) v2[j] = (a[j] + c[j])/2.0; for (j = 0; j < 3; j++) v3[j] = (b[j] + c[j])/2.0; divide_triangle(a, v1, v2, r - 1); divide_triangle(c, v2, v3, r - 1); divide_triangle(b, v3, v1, r - 1); divide_triangle(v1, v3, v2, r - 1); } else { triangle(a, b, c); } }
void divide_triangle(point3 a, point3 b, point3 c, int depth) { point3 v1, v2, v3; int j; if (depth == 0){ triangle(a, b, c); /* draw triangle at end of recursion */ return; } for (j = 0; j < 3; j++) v1[j] = a[j] + b[j]; normalize(v1); for (j = 0; j < 3; j++) v2[j] = a[j] + c[j]; normalize(v2); for (j = 0; j < 3; j++) v3[j] = b[j] + c[j]; normalize(v3); divide_triangle(a, v1, v2, depth - 1); divide_triangle(c, v2, v3, depth - 1); divide_triangle(b, v3, v1, depth - 1); divide_triangle(v1, v3, v2, depth - 1); }
void draw_pyramid() { glPushMatrix(); divide_triangle(vertices[4], vertices[5], vertices[6], 2); glPopMatrix(); glPushMatrix(); glRotatef(90.0, 0, 1, 0); divide_triangle(vertices[4], vertices[5], vertices[6], 2); glPopMatrix(); glPushMatrix(); glRotatef(180.0, 0, 1, 0); divide_triangle(vertices[4], vertices[5], vertices[6], 2); glPopMatrix(); glPushMatrix(); glRotatef(270.0, 0, 1, 0); divide_triangle(vertices[4], vertices[5], vertices[6], 2); glPopMatrix(); }
void Sphere::generateSphere(int count) { divide_triangle( v[0], v[1], v[2], count ); divide_triangle( v[3], v[2], v[1], count ); divide_triangle( v[0], v[3], v[1], count ); divide_triangle( v[0], v[2], v[3], count ); // Normals for (int i = 0; i < numVertices; i++) { normals[i] = point3(points[i].x, points[i].y, points[i].z); } // TexCoords double u, v; for (int i = 0; i < numVertices; i++) { v = 10*(0.5 - asin(points[i].y)/M_PI) ; //0~10 u = 10*(0.5*(atan2(points[i].z,points[i].x)/M_PI + 1)); //0~10 tex_coords[i] = point2(u,v); } Index = 0; }
void HW1b::divide_triangle(vec2 a, vec2 b, vec2 c, int k){ if (k>0) { float midab1 = (a.x() + b.x()) / 2.0; float midab2 = (a.y() + b.y()) / 2.0; float midac1 = (a.x() + c.x()) / 2.0; float midac2 = (a.y() + c.y()) / 2.0; float midbc1 = (b.x() + c.x()) / 2.0; float midbc2 = (b.y() + c.y()) / 2.0; vec2 tema; tema.setX(midab1); tema.setY(midab2); vec2 temb; temb.setX(midac1); temb.setY(midac2); vec2 temc; temc.setX(midbc1); temc.setY(midbc2); divide_triangle(a, tema, temb, k - 1); divide_triangle(c, temb, temc, k - 1); divide_triangle(b, temc, tema, k - 1); divide_triangle(tema, temb, temc, k-1); } else triangle(a, b, c); }
void HW1b::initPoint(){ vec2 p2[] = { vec2(-0.9, -0.4), vec2(0.0, 0.75), vec2(0.9, -0.4) }; divide_triangle(p2[0], p2[1], p2[2], m_subdivide); }
int main(){ std::string vertex_string = read_shader("vertex.glsl"); std::string fragment_string = read_shader("fragment.glsl"); const GLchar* vertexShaderSource = vertex_string.c_str(); const GLchar* fragmentShaderSource = fragment_string.c_str(); // Initializing glfw for window generation glfwInit(); // Setting window variables glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_RESIZABLE, GL_FALSE); // Generating window instance GLFWwindow *window = glfwCreateWindow(800, 600, "Hello World", nullptr, nullptr); if (window == nullptr){ std::cout << "Window could not be created!" << '\n'; glfwTerminate(); return(-1); } glfwMakeContextCurrent(window); // GLEW manages function pointers for OpenGL // GL_TRUE gives us a more modern GLEW to work with glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK){ std::cout << "Failed to initialize GLEW" << '\n'; } // Setting viewport up so OpenGL knows what to draw to and where int width, height; glfwGetFramebufferSize(window, &width, &height); // Read from LL to UR // Here, we map -1 < x < 1 in x and y to 800 x 600 glViewport(0,0,width,height); // Registering closing callback function // glfwPollEvents later should be waiting for key callbacks glfwSetKeyCallback(window, key_callback); // Building / compiling shader program GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertexShader, 1, &vertexShaderSource, NULL); glCompileShader(vertexShader); // Check for errors GLint success; GLchar infoLog[512]; glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &success); if (!success){ glGetShaderInfoLog(vertexShader, 512, NULL, infoLog); std::cout << "ERROR: vertex shader compilation failed!" << '\n'; } // Now the same for the Fragment shader GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL); glCompileShader(fragmentShader); // Check for fragment shader errors glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &success); if (!success){ glGetShaderInfoLog(fragmentShader, 512, NULL, infoLog); std::cout << "ERROR: fragment shader compilation failed!" << '\n'; } // Now to link the shaders together GLuint shaderProgram = glCreateProgram(); glAttachShader(shaderProgram, vertexShader); glAttachShader(shaderProgram, fragmentShader); glLinkProgram(shaderProgram); // Checking for linking errors glGetProgramiv(shaderProgram, GL_LINK_STATUS, &success); if (!success){ glGetProgramInfoLog(shaderProgram, 512, NULL, infoLog); std::cout << "ERROR: program linking failed!" << '\n'; } // Removing shaders after program is built glDeleteShader(vertexShader); glDeleteShader(fragmentShader); // Rendering a triangle.. first, we need to define the vertices // Note: GL assumes 3 dimensions, and likely parses the vertices by groups // of three. int max_depth = 4; std::vector<vec> vertices; vertices.reserve(3 * pow(4,max_depth)); std::vector<triangle> indices; indices.reserve(pow(4,max_depth)); //create_triangle_vertex(vertices, indices, 4096); //std::vector<vec> init_corners(3); vec init_corners[3]; init_corners[0] = vec(0,1,0); init_corners[1] = vec(-1,-1,-1); init_corners[2] = vec(1,-1,1); divide_triangle(init_corners, indices, vertices, max_depth); // Now to request space on the GPU with Vertex Buffer Objects (VBO) // VAO is Vertex Array Object // Buffer has a unique ID GLuint VBO, VAO, EBO; glGenVertexArrays(1, &VAO); glGenBuffers(1, &VBO); glGenBuffers(1, &EBO); // Binding VAO first glBindVertexArray(VAO); // Specify the type of buffer: glBindBuffer(GL_ARRAY_BUFFER, VBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); // Now to do the copying // GL_STATIC_DRAW: No changes in vertices expected // GL_DYNAMIC_DRAW: Regular changes expected // GL_STREAM_DRAW: Changes expected every step glBufferData(GL_ARRAY_BUFFER, vertices.size() * 3 * sizeof(float), vertices.data(), GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * 3 * sizeof(int), indices.data(), GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat), (GLvoid*)0); glEnableVertexAttribArray(0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); glBindBuffer(GL_ARRAY_BUFFER, VBO); glBindVertexArray(0); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // Called a "game loop" continues until window needs to close while (!glfwWindowShouldClose(window)) { glfwPollEvents(); // Render // Clear the color buffer glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); // Using the program we created glUseProgram(shaderProgram); // Create transformations glm::mat4 model; glm::mat4 view; glm::mat4 projection; model = glm::rotate(model, -55.0f, glm::vec3(1.0f, 0.0f, 0.0f)); view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f)); projection = glm::perspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 100.0f); // Get their uniform location GLint modelLoc = glGetUniformLocation(shaderProgram, "model"); GLint viewLoc = glGetUniformLocation(shaderProgram, "view"); GLint projLoc = glGetUniformLocation(shaderProgram, "projection"); // Pass them to the shaders glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view)); glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projection)); // Draw container glBindVertexArray(VAO); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); glBindVertexArray(0); // Swap the screen buffers glfwSwapBuffers(window); } /* while (!glfwWindowShouldClose(window)){ glfwPollEvents(); // Setting window color and such: glClearColor(0.2f, 0.3f, 0.3f, 0.5f); glClear(GL_COLOR_BUFFER_BIT); // Using the program we created glUseProgram(shaderProgram); glm:: mat4 view, projection, model; model = glm::rotate(model, 55.0f, glm::vec3(1.0f, 0.0f, 0.0f)); projection = glm::perspective(55.0f, (float)width / (float)height, 0.1f, 100.0f); view = glm::translate(view, glm::vec3(0.0f, 0.0f, 3.0f)); GLint modelLoc = glGetUniformLocation(shaderProgram, "model"); glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); GLint viewLoc = glGetUniformLocation(shaderProgram, "view"); glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view)); GLint projLoc = glGetUniformLocation(shaderProgram, "projection"); glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(projection)); glBindVertexArray(VAO); //glDrawArrays(GL_TRIANGLES, 0, 3); glDrawElements(GL_TRIANGLES, indices.size() * 3, GL_UNSIGNED_INT, 0); glBindVertexArray(0); glfwSwapBuffers(window); } */ // termination glDeleteVertexArrays(1, &VAO); glDeleteBuffers(1, &VBO); glDeleteBuffers(1, &EBO); glfwTerminate(); }