add basic models
This commit is contained in:
parent
56df882fab
commit
b696d1e4d1
@ -30,6 +30,8 @@ float lastX = (float)SCR_WIDTH / 2.0;
|
||||
float lastY = (float)SCR_HEIGHT / 2.0;
|
||||
bool firstMouse = true;
|
||||
|
||||
glm::vec3 backpackTranslate(1.0f);
|
||||
|
||||
// timing
|
||||
float deltaTime = 0.0f;
|
||||
float lastFrame = 0.0f;
|
||||
@ -39,7 +41,7 @@ float lastFrame = 0.0f;
|
||||
float angle = 0;
|
||||
|
||||
|
||||
int main()
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// glfw: initialize and configure
|
||||
// ------------------------------
|
||||
@ -86,6 +88,12 @@ int main()
|
||||
Shader shader("6.2.cubemaps.vert", "6.2.cubemaps.frag");
|
||||
Shader skyboxShader("6.2.skybox.vert", "6.2.skybox.frag");
|
||||
|
||||
Shader kniedeShader("9.2.geometry_shader.vert", "9.2.geometry_shader.frag");
|
||||
Model kniedeModel("../resources/objects/kniede/kniede.obj");
|
||||
|
||||
Shader backpackShader("9.2.geometry_shader.vert", "9.2.geometry_shader.frag");
|
||||
Model backpackModel("../resources/objects/backpack/backpack.obj");
|
||||
|
||||
// set up vertex data (and buffer(s)) and configure vertex attributes
|
||||
// ------------------------------------------------------------------
|
||||
float cubeVertices[] = {
|
||||
@ -201,7 +209,7 @@ int main()
|
||||
// load textures
|
||||
// -------------
|
||||
string dir = "../resources/textures/SaintsPetersBasilica/";
|
||||
|
||||
|
||||
vector<std::string> faces
|
||||
{
|
||||
dir + "posx.jpg",
|
||||
@ -269,6 +277,24 @@ int main()
|
||||
|
||||
glBindVertexArray(0);
|
||||
|
||||
model = glm::translate(glm::mat4(1.0f), glm::vec3(10, -5, 9));
|
||||
model = glm::rotate(model, glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||
model = glm::rotate(model, glm::radians((float)glfwGetTime() * 8), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
kniedeShader.use();
|
||||
kniedeShader.setMat4("model", model);
|
||||
kniedeShader.setMat4("view", view);
|
||||
kniedeShader.setMat4("projection", projection);
|
||||
kniedeModel.Draw(kniedeShader);
|
||||
|
||||
model = glm::translate(glm::mat4(1.0f), glm::vec3(15, -4, 9));
|
||||
model = glm::translate(model, backpackTranslate);
|
||||
backpackShader.use();
|
||||
backpackShader.setMat4("model", model);
|
||||
backpackShader.setMat4("view", view);
|
||||
backpackShader.setMat4("projection", projection);
|
||||
backpackModel.Draw(backpackShader);
|
||||
|
||||
|
||||
// draw skybox as last
|
||||
glDepthFunc(GL_LEQUAL); // change depth function so depth test passes when values are equal to depth buffer's content
|
||||
skyboxShader.use();
|
||||
@ -315,6 +341,19 @@ void processInput(GLFWwindow *window)
|
||||
camera.ProcessKeyboard(LEFT, deltaTime);
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
|
||||
camera.ProcessKeyboard(RIGHT, deltaTime);
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS)
|
||||
backpackTranslate.x += 0.2f;
|
||||
if (glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS)
|
||||
backpackTranslate.x -= 0.2f;
|
||||
if (glfwGetKey(window, GLFW_KEY_DOWN) == GLFW_PRESS)
|
||||
backpackTranslate.y -= 0.2f;
|
||||
if (glfwGetKey(window, GLFW_KEY_UP) == GLFW_PRESS)
|
||||
backpackTranslate.y += 0.2f;
|
||||
if (glfwGetKey(window, GLFW_KEY_X) == GLFW_PRESS)
|
||||
backpackTranslate.z += 0.1f;
|
||||
if (glfwGetKey(window, GLFW_KEY_Z) == GLFW_PRESS)
|
||||
backpackTranslate.z -= 0.1f;
|
||||
}
|
||||
|
||||
// glfw: whenever the window size changed (by OS or user resize) this callback function executes
|
||||
|
Loading…
Reference in New Issue
Block a user