diff options
Diffstat (limited to 'src/spirt.c')
-rw-r--r-- | src/spirt.c | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/src/spirt.c b/src/spirt.c index 612c36e..4103bff 100644 --- a/src/spirt.c +++ b/src/spirt.c @@ -13,6 +13,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "camera.h" #include "util.h" #include "util_cl.h" @@ -44,13 +45,6 @@ struct opts { long devidx; }; -struct camera { - cl_float3 centre; - cl_float3 pixel_delta_u; - cl_float3 pixel_delta_v; - cl_float3 corner00; -}; - static float *kernel_render(struct kernel_context *runtime, size_t image_width, size_t image_height, struct camera cam); @@ -217,7 +211,7 @@ get_args(int argc, char *argv[]) char flag; if (argv[0][2]) - die("arg_parse: Invalid flag '%s'\n", argv[0]); + die("get_args: Invalid flag '%s'\n", argv[0]); flag = argv[0][1]; argv++, argc--; @@ -238,13 +232,13 @@ get_args(int argc, char *argv[]) case '-': goto end_flags; default: - die("arg_parse: Unknown flag '-%c'\n", flag); + die("get_args: Unknown flag '-%c'\n", flag); } } end_flags: if (argc > 0) - die("arg_parse: Unexpected argument\n"); + die("get_args: Unexpected argument\n"); return opts; } @@ -257,7 +251,6 @@ main(int argc, char *argv[]) struct kernel_context runtime; float *h_canvas; struct camera cam; - float focal_length, viewport_width, viewport_height; Image img; Texture2D texture; @@ -266,32 +259,7 @@ main(int argc, char *argv[]) runtime = kernel_context_init(opts.platidx, opts.devidx); - focal_length = 1.0f; - viewport_height = 2.0f; - viewport_width = - viewport_height * ((float)opts.width / (float)opts.height); - - cam.centre.s[0] = 0.0f; - cam.centre.s[1] = 0.0f; - cam.centre.s[2] = 0.0f; - - cam.pixel_delta_u.s[0] = viewport_width / (float)opts.width; - cam.pixel_delta_u.s[1] = 0.0f; - cam.pixel_delta_u.s[2] = 0.0f; - - cam.pixel_delta_v.s[0] = 0.0f; - cam.pixel_delta_v.s[1] = -viewport_height / (float)opts.height; - cam.pixel_delta_v.s[2] = 0.0f; - - cam.corner00.s[0] = - cam.centre.s[0] - viewport_width / 2.0f + - 0.5f * (cam.pixel_delta_u.s[0] + cam.pixel_delta_v.s[0]); - cam.corner00.s[1] = - cam.centre.s[1] + viewport_height / 2.0f + - 0.5f * (cam.pixel_delta_u.s[1] + cam.pixel_delta_v.s[1]); - cam.corner00.s[2] = - cam.centre.s[2] - focal_length + - 0.5f * (cam.pixel_delta_u.s[2] + cam.pixel_delta_v.s[2]); + cam = camera_init(opts.width, opts.height, 1.0f); h_canvas = kernel_render(&runtime, opts.width, opts.height, cam); |