| 28 #include "ascension/error.h" |
28 #include "ascension/error.h" |
| 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 memset(camera, 0, sizeof(AscCamera)); |
| 33 if (args.type == ASC_CAMERA_ORTHO) { |
34 if (args.type == ASC_CAMERA_ORTHO) { |
| 34 asc_rect rect = args.ortho.rect; |
35 asc_rect rect = args.ortho.rect; |
| 35 if (rect.size.width <= 0 || rect.size.height <= 0) { |
36 if (rect.size.width <= 0 || rect.size.height <= 0) { |
| 36 rect.size.width = 1; |
37 rect.size.width = 1; |
| 37 rect.size.height = 1; |
38 rect.size.height = 1; |
| 39 asc_camera_ortho(camera, rect); |
40 asc_camera_ortho(camera, rect); |
| 40 } else if (args.type == ASC_CAMERA_PERSPECTIVE) { |
41 } else if (args.type == ASC_CAMERA_PERSPECTIVE) { |
| 41 // TODO: implement |
42 // TODO: implement |
| 42 asc_wprintf("Camera type PERSPECTIVE is not yet implemented."); |
43 asc_wprintf("Camera type PERSPECTIVE is not yet implemented."); |
| 43 } else { |
44 } else { |
| 44 // at least zero all the bytes (law of the least surprise) |
45 asc_error("Illegal argument for asc_camera_init(): type = %d", args.type); |
| 45 memset(camera, 0, sizeof(AscCamera)); |
|
| 46 } |
46 } |
| 47 camera->viewport_update_func = args.viewport_update_func; |
47 camera->viewport_update_func = args.viewport_update_func; |
| 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 = args.clear_color; |
50 camera->clear_color = args.clear_color; |