More cubes
This commit is contained in:
parent
b06cf47480
commit
8f7ca3ae38
31
src/main.cpp
31
src/main.cpp
@ -14,6 +14,19 @@
|
||||
void processInput(GLFWwindow *window);
|
||||
void framebuffer_size_callback(GLFWwindow *window, int width, int height);
|
||||
|
||||
glm::vec3 cubePositions[] = {
|
||||
glm::vec3( 0.0f, 0.0f, 0.0f),
|
||||
glm::vec3( 2.0f, 5.0f, -15.0f),
|
||||
glm::vec3(-1.5f, -2.2f, -2.5f),
|
||||
glm::vec3(-3.8f, -2.0f, -12.3f),
|
||||
glm::vec3( 2.4f, -0.4f, -3.5f),
|
||||
glm::vec3(-1.7f, 3.0f, -7.5f),
|
||||
glm::vec3( 1.3f, -2.0f, -2.5f),
|
||||
glm::vec3( 1.5f, 2.0f, -2.5f),
|
||||
glm::vec3( 1.5f, 0.2f, -1.5f),
|
||||
glm::vec3(-1.3f, 1.0f, -1.5f)
|
||||
};
|
||||
|
||||
int main(void) {
|
||||
int tmp = 0;
|
||||
|
||||
@ -84,10 +97,8 @@ int main(void) {
|
||||
stbi_image_free(data);
|
||||
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
glm::mat4 model = glm::mat4(1.0f); /*move model*/
|
||||
glm::mat4 view = glm::mat4(1.0f); /*move camera*/
|
||||
view = glm::translate(view, glm::vec3(0.0f, 0.0f, -3.0f));
|
||||
model = glm::rotate(model, (float)glfwGetTime()*glm::radians(55.0f), glm::vec3(1.0f, 0.5f, 0.0f));
|
||||
glm::mat4 projection = glm::perspective(glm::radians(45.0f), 800.0f / 600.0f, 0.1f, 100.0f); /*camera settings*/
|
||||
|
||||
processInput(window);
|
||||
@ -97,15 +108,27 @@ int main(void) {
|
||||
|
||||
shaderProgram->use();
|
||||
shaderProgram->setInt("Tex0",0);
|
||||
shaderProgram->setMat4("model",model);
|
||||
shaderProgram->setMat4("view",view);
|
||||
shaderProgram->setMat4("projection",projection);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glBindVertexArray(VAO);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
for(unsigned int i = 0; i < 10; i++)
|
||||
{
|
||||
glm::mat4 model = glm::mat4(1.0f);
|
||||
model = glm::translate(model, cubePositions[i]);
|
||||
float angle = 20.0f * i;
|
||||
model = glm::rotate(model, glm::radians(angle),
|
||||
glm::vec3(1.0f, 0.3f, 0.5f));
|
||||
model = glm::rotate(model, (float)glfwGetTime() * glm::radians(55.0f),
|
||||
glm::vec3(1.0f, 0.5f, 0.0f));
|
||||
shaderProgram->setMat4("model", model);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
}
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
//glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||
glfwSwapBuffers(window);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user