Court is now in session
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
void cameraLookAt(camera_t *camera,
|
||||
float x, float y, float z, float targetX, float targetY, float targetZ
|
||||
) {
|
||||
glm_mat4_identity(camera->view);
|
||||
glm_lookat(
|
||||
(vec3){ x, y, z },
|
||||
(vec3){ targetX, targetY, targetZ },
|
||||
@ -22,6 +23,7 @@ void cameraLook(camera_t *camera,
|
||||
float x, float y, float z,
|
||||
float pitch, float yaw, float roll
|
||||
) {
|
||||
glm_mat4_identity(camera->view);
|
||||
glm_look(
|
||||
(vec3){ x, y, z },
|
||||
(vec3){ pitch, yaw, roll },
|
||||
@ -33,11 +35,13 @@ void cameraLook(camera_t *camera,
|
||||
void cameraPerspective(camera_t *camera,
|
||||
float fov, float aspect, float near, float far
|
||||
) {
|
||||
glm_perspective(fov, aspect, near, far, camera->projection);
|
||||
glm_mat4_identity(camera->projection);
|
||||
glm_perspective(mathDeg2Rad(fov), aspect, near, far, camera->projection);
|
||||
}
|
||||
|
||||
void cameraOrtho(camera_t *camera,
|
||||
float left, float right, float bottom, float top, float near, float far
|
||||
) {
|
||||
glm_mat4_identity(camera->projection);
|
||||
glm_ortho(left, right, bottom, top, near, far, camera->projection);
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
#include <dawn/dawn.h>
|
||||
#include "../util/math.h"
|
||||
|
||||
/**
|
||||
* Make a camera look at a position in world space while itself being positioned
|
||||
@ -42,7 +43,7 @@ void cameraLook(camera_t *camera,
|
||||
* Make a camera's projection be a 3D Perspective view.
|
||||
*
|
||||
* @param camera The camera to project.
|
||||
* @param fov The field of view of the camera.
|
||||
* @param fov The field of view of the camera (in degrees).
|
||||
* @param aspect The aspect ratio of the camera (w / h)
|
||||
* @param near The near plane clip.
|
||||
* @param far the far plane clip.
|
||||
|
@ -11,6 +11,10 @@ framebuffer_t * frameBufferCreate(int32_t w, int32_t h) {
|
||||
framebuffer_t *fb = malloc(sizeof(framebuffer_t));
|
||||
if(fb == NULL) return NULL;
|
||||
|
||||
// At least one pixel
|
||||
if(w <= 0) w = 1;
|
||||
if(h <= 0) h = 1;
|
||||
|
||||
// Create Color Attachment texture.
|
||||
fb->texture = textureCreate(w, h, NULL);
|
||||
if(fb->texture == NULL) {
|
||||
|
@ -103,8 +103,8 @@ void shaderUse(shader_t *shader) {
|
||||
}
|
||||
|
||||
void shaderUseCamera(shader_t *shader, camera_t *camera) {
|
||||
glUniformMatrix4fv(shader->uniView, 1, GL_FALSE, (float*)camera->view);
|
||||
glUniformMatrix4fv(shader->uniProj, 1, GL_FALSE, (float*)camera->projection);
|
||||
glUniformMatrix4fv(shader->uniView, 1, GL_FALSE, camera->view[0]);
|
||||
glUniformMatrix4fv(shader->uniProj, 1, GL_FALSE, camera->projection[0]);
|
||||
}
|
||||
|
||||
void shaderUseTexture(shader_t *shader, texture_t *texture) {
|
||||
@ -131,11 +131,13 @@ void shaderUsePosition(shader_t *shader,
|
||||
//Rotation, we do each axis individually
|
||||
axis[0] = 1, axis[1] = 0, axis[2] = 0;
|
||||
glm_rotate(MATRIX_POSITION, pitch, axis);
|
||||
|
||||
axis[0] = 0, axis[1] = 1;
|
||||
glm_rotate(MATRIX_POSITION, yaw, axis);
|
||||
|
||||
axis[1] = 0, axis[2] = 1;
|
||||
glm_rotate(MATRIX_POSITION, roll, axis);
|
||||
|
||||
//Send to the shader.
|
||||
glUniformMatrix4fv(shader->uniModl, 1, GL_FALSE, (float*)MATRIX_POSITION);
|
||||
glUniformMatrix4fv(shader->uniModl, 1, GL_FALSE, MATRIX_POSITION[0]);
|
||||
}
|
Reference in New Issue
Block a user