SHARE
TWEET

Untitled

a guest Feb 17th, 2017 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. glm::mat4 Projection = glm::perspective(80.0f, 4.0f / 3.0f, 0.1f, 100.0f);
  2.     glm::mat4 View  = glm::lookAt(
  3.                                 glm::vec3(0, 0, 50), // Camera is at (0,0,10), in World Space
  4.         glm::vec3(0, 0, 0), // look at the origin
  5.         glm::vec3(0, 1, 0)  // pointing up( 0,-1,0 will be upside-down));
  6.         );
  7.    
  8.    
  9.     glUseProgram(programObject);
  10.  
  11.     //////////////////////////////////////////////////////
  12.     glBindBuffer(GL_ARRAY_BUFFER, vbo);
  13.    
  14.     glEnableVertexAttribArray(positionLoc);
  15.     glVertexAttribPointer(positionLoc, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat) , nullptr);
  16.    
  17.     glBindTexture(GL_TEXTURE_2D, texture);
  18.     glEnableVertexAttribArray(texCoordLoc);
  19.     glVertexAttribPointer(texCoordLoc, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (void *)(sizeof(float) * 3));
  20.    
  21.     glUniform1i(samplerLoc, 0);
  22.  
  23.     //glDrawElements(GL_TRIANGLE_STRIP, sizeof(TheCubeVertices), GL_UNSIGNED_BYTE, (void*) 0);
  24.     GLuint MVPos = glGetUniformLocation(programObject, "MVP");
  25.     glm::mat4 tmp = glm::mat4(1.0);
  26.    
  27.  
  28.     for (int i = 0; i < 2000; ++i)
  29.     {
  30.            
  31.         tmp = glm::translate(mTranslation, glm::vec3(0.5f * i - 50, 0, 0));
  32.         //mTranslation = glm::translate(mTranslation, glm::vec3(2.f, 0, 0));
  33.         transform = tmp * mRotation * mScale;
  34.         glm::mat4 MVP = Projection * View * transform;
  35.         glUniformMatrix4fv(MVPos, 1, false, glm::value_ptr(MVP));
  36.        
  37.         glDrawArrays(GL_TRIANGLES, 0, 36);
  38.     }
RAW Paste Data
Top