25 * POSSIBILITY OF SUCH DAMAGE. |
25 * POSSIBILITY OF SUCH DAMAGE. |
26 */ |
26 */ |
27 |
27 |
28 #include "ascension/camera.h" |
28 #include "ascension/camera.h" |
29 |
29 |
30 static void asc_camera_update_ortho(AscCamera *camera) { |
30 void asc_camera_ortho(AscCamera *camera, asc_recti rect) { |
31 float left = (float) camera->rect.pos.x; |
31 asc_mat4f_unit(camera->view); |
32 float right = left + (float) camera->rect.size.width; |
32 float left = (float) rect.pos.x; |
33 float top = (float) camera->rect.pos.y; |
33 float right = left + (float) rect.size.width; |
34 float bottom = top + (float) camera->rect.size.height; |
34 float top = (float) rect.pos.y; |
|
35 float bottom = top + (float) rect.size.height; |
35 asc_mat4f_ortho(camera->projection, left, right, bottom, top, -1, 1); |
36 asc_mat4f_ortho(camera->projection, left, right, bottom, top, -1, 1); |
36 } |
37 } |
37 |
|
38 void asc_camera_ortho(AscCamera *camera, asc_recti rect) { |
|
39 asc_mat4f_unit(camera->view); |
|
40 camera->update = asc_camera_update_ortho; |
|
41 camera->rect = rect; |
|
42 } |
|
43 |
|
44 void asc_camera_disable(AscCamera *camera) { |
|
45 camera->update = NULL; |
|
46 } |
|