Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1.     while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && glfwWindowShouldClose(window) == 0)
  2.     {
  3.         glClear(GL_COLOR_BUFFER_BIT);
  4.  
  5.         glUseProgram(ProgramID);
  6.         glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
  7.  
  8.         glBindBuffer(GL_ARRAY_BUFFER, instanceVBO);
  9.         glBufferData(GL_ARRAY_BUFFER, sizeof(offsets), offsets, GL_DYNAMIC_DRAW);
  10.         glEnableVertexAttribArray(1);
  11.         glVertexAttribPointer(1, 3, GL_FLOAT, false, 0, nullptr);
  12.         glVertexAttribDivisor(1, 1);
  13.        
  14.         offsets[0].y += SPEED;
  15.  
  16.         glDrawArraysInstanced(GL_TRIANGLES, 0, 12 * 3, sizeof(offsets) / sizeof(offsets[0]));
  17.  
  18.         glfwSwapBuffers(window);
  19.         glfwPollEvents();
  20.     }
  21.  
  22. /*
  23. #version 330 core
  24.  
  25. layout(location = 0) in vec3 modelspace;
  26. layout(location = 1) in vec3 offsets;
  27.  
  28. uniform mat4 MVP;
  29.  
  30. void main()
  31. {
  32.     gl_Position = MVP * vec4(modelspace.x + offsets.x, modelspace.y + offsets.y, modelspace.z + offsets.z, 1.0);
  33. }
  34. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement