cleanup and bug fix
This commit is contained in:
parent
8350b85aa1
commit
6e69a543f0
@ -10,6 +10,7 @@ public:
|
||||
void setRotate(float yaw, float pitch);
|
||||
glm::mat4 getView();
|
||||
glm::mat4 getProjection();
|
||||
float aspect;
|
||||
|
||||
private:
|
||||
void update();
|
||||
@ -20,6 +21,5 @@ private:
|
||||
float yaw;
|
||||
float pitch;
|
||||
float fov;
|
||||
float aspect;
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -3,8 +3,8 @@
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
|
||||
Camera::Camera(glm::vec3 pos, float yaw, float pitch, float fov, float aspect)
|
||||
: up(glm::vec3(0, 1, 0)), pos(pos), yaw(yaw), pitch(pitch), fov(fov),
|
||||
aspect(aspect) {
|
||||
: aspect(aspect), up(glm::vec3(0, 1, 0)), pos(pos), yaw(yaw), pitch(pitch),
|
||||
fov(fov) {
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -2,9 +2,8 @@
|
||||
#include "camera.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <cassert>
|
||||
#include <glm/ext/matrix_transform.hpp>
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <shader.hpp>
|
||||
#include <shapes.h>
|
||||
#include <texture.hpp>
|
||||
@ -62,7 +61,9 @@ int main(void) {
|
||||
|
||||
Camera *cam =
|
||||
new Camera(glm::vec3(0.0, 0.0, 5.0), -90.0f, 0.0f, 45.0, 800.0 / 600);
|
||||
glfwSetWindowUserPointer(window, cam);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
@ -74,7 +75,6 @@ int main(void) {
|
||||
shaderProgram->setMat4("projection", cam->getProjection());
|
||||
|
||||
glBindVertexArray(VAO);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
for (unsigned int i = 0; i < 10; i++) {
|
||||
if (i % 2 == 0) {
|
||||
@ -113,4 +113,7 @@ void processInput(GLFWwindow *window) {
|
||||
void framebuffer_size_callback(GLFWwindow *window, int width, int height) {
|
||||
UNUSED(window);
|
||||
glViewport(0, 0, width, height);
|
||||
Camera *cam = (Camera *)glfwGetWindowUserPointer(window);
|
||||
if (cam)
|
||||
cam->aspect = (float)width/height;
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ Texture::Texture(GLenum type, const char *path) : type(type) {
|
||||
stbi_image_free(data);
|
||||
};
|
||||
|
||||
Texture::~Texture() {}
|
||||
Texture::~Texture() {glDeleteTextures(1, &ID);}
|
||||
|
||||
void Texture::bind(GLenum texture) {
|
||||
glActiveTexture(texture);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user