You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
702 B

  1. #include "scene.h"
  2. #include "utils.h"
  3. #include "model.h"
  4. glm::mat4 viewMatrix, projectionMatrix;
  5. glm::vec3 cameraPos(4.0f, 3.0f, 4.0f);
  6. Model model;
  7. void Init()
  8. {
  9. model.Init("Res/Cube.obj");
  10. model.mShader->Init("Res/rgbcube.vs", "Res/rgbcube.fs");
  11. model.SetPosition(0.0f, 0.0f, 0.0f);
  12. viewMatrix = glm::lookAt(cameraPos, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
  13. }
  14. void SetViewPortSize(float width, float height)
  15. {
  16. projectionMatrix = glm::perspective(50.0f, width/height, 0.1f, 1000.0f);
  17. }
  18. void Draw()
  19. {
  20. glClearColor(0.0f,0.0f,0.0f,1.0f);
  21. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  22. model.Draw(viewMatrix, projectionMatrix, cameraPos.x, cameraPos.y, cameraPos.z);
  23. }