src/camera.c

changeset 186
e9bb4d4f88a8
parent 121
ede9a9e92ff9
equal deleted inserted replaced
185:7f0653d43a0d 186:e9bb4d4f88a8
29 #include "ascension/context.h" 29 #include "ascension/context.h"
30 #include "ascension/camera.h" 30 #include "ascension/camera.h"
31 31
32 void asc_camera_init_(AscCamera *camera, struct asc_camera_init_args args) { 32 void asc_camera_init_(AscCamera *camera, struct asc_camera_init_args args) {
33 if (args.type == ASC_CAMERA_ORTHO) { 33 if (args.type == ASC_CAMERA_ORTHO) {
34 asc_recti rect = args.ortho.rect; 34 asc_rect rect = args.ortho.rect;
35 if (rect.size.width <= 0 || rect.size.height <= 0) { 35 if (rect.size.width <= 0 || rect.size.height <= 0) {
36 rect.size.width = 1; 36 rect.size.width = 1;
37 rect.size.height = 1; 37 rect.size.height = 1;
38 } 38 }
39 asc_camera_ortho(camera, rect); 39 asc_camera_ortho(camera, rect);
48 camera->projection_update_func = args.projection_update_func; 48 camera->projection_update_func = args.projection_update_func;
49 camera->viewport_clear = args.viewport_clear; 49 camera->viewport_clear = args.viewport_clear;
50 camera->clear_color = asc_col_itof(asc_context.ink); 50 camera->clear_color = asc_col_itof(asc_context.ink);
51 } 51 }
52 52
53 void asc_camera_ortho(AscCamera *camera, asc_recti rect) { 53 void asc_camera_ortho(AscCamera *camera, asc_rect rect) {
54 asc_mat4f_unit(camera->view); 54 asc_mat4f_unit(camera->view);
55 float left = (float) rect.pos.x; 55 float left = (float) rect.pos.x;
56 float right = left + (float) rect.size.width; 56 float right = left + (float) rect.size.width;
57 float top = (float) rect.pos.y; 57 float top = (float) rect.pos.y;
58 float bottom = top + (float) rect.size.height; 58 float bottom = top + (float) rect.size.height;

mercurial