27 lines
783 B
C
27 lines
783 B
C
#include "camera.h"
|
|
#include "../lib/raymath.h"
|
|
|
|
Camera createCamera(int32 width, int32 height) {
|
|
return (Camera){
|
|
.view = (Matrix){0},
|
|
.proj = MatrixPerspective(DEG2RAD * 45.0f, (real32)width/(real32)height, 0.1f, 100.0f),
|
|
.pos = (RLVector3){0},
|
|
.up = (RLVector3){0,1,0},
|
|
};
|
|
}
|
|
|
|
void cameraSetAspect(Camera *c, int32 width, int32 height) {
|
|
real32 aspectRatio = (real32)width/(real32)height;
|
|
c->proj = MatrixPerspective(DEG2RAD * 45.0f, aspectRatio, 0.1f, 100.0f);
|
|
}
|
|
|
|
void cameraLookAt(Camera *c, float x, float y, float z) {
|
|
c->target = (RLVector3){x, y, z};
|
|
c->view = MatrixLookAt(c->pos, c->target, c->up);
|
|
}
|
|
|
|
void cameraSetUp(Camera *c, real32 up_x, real32 up_y, real32 up_z) {
|
|
c->up = (RLVector3){up_x, up_y, up_z};
|
|
}
|
|
|