Introduce Camera.h/cpp defining abstract Camera, FPSCamera, OrbitCamera. Update engine.h to include Camera and window size fields. Implement cameraUpdate in engine.cpp handling mouse movement and key input. Add framebuffer size and scroll callbacks for viewport resizing and zoom. Remove legacy loop files (cube, rainbowWindow, rbgTriangle). Adjust main.cpp formatting. Update onCreate to load objects with textures and transforms. Modify onUpdate to use Camera's view/projection matrices instead of hardcoded values.
29 lines
694 B
C++
29 lines
694 B
C++
#include "engine.h"
|
|
#include <GL/gl.h>
|
|
#include "loops.h"
|
|
#include <iostream>
|
|
|
|
void djalim::OpenGlEngine::onUpdate(){
|
|
showFps();
|
|
|
|
shaderProgram.use();
|
|
shaderProgram.setUniform("ourTexture", 0);
|
|
|
|
glm::mat4 model(1.0), view(1.0), projection(1.0);
|
|
|
|
// Create the View matrix
|
|
view = Camera.getViewMatrix();
|
|
|
|
// Create the projection matrix
|
|
projection = glm::perspective(glm::radians(Camera.getFOV()), (float)windowWidth / (float)windowHeight, 0.1f, 200.0f);
|
|
|
|
// Matrice de Projection
|
|
shaderProgram.setUniform("projection", projection);
|
|
shaderProgram.setUniform("view", view);
|
|
|
|
draw((objects["cube"]).get());
|
|
draw((objects["mimikyu"]).get());
|
|
|
|
|
|
}
|