Subject: Another excellent question reg'd sp4 (This message is being sent to CPSC 215 Students and TA's) >> Dr. Westall, >> >> I'm having complications with my map_pix_to_world function. I'm >> using a method similar to the one in your notes on page 61: >> >> map_pix_to_world(proj_t proj*, int x, int y, double *world) >> >> However, the one defined in rayhdrs.h is as follows: >> >> map_pix_to_world(int x, int y, double *world) >> >> Do I need to change my function so that it doesn't take proj_t >> *proj as a parameter or is this an issue with rayhdrs.h? Thank >> you for you time. This little dilemma is one that is commonly encountered in C programming -- whether to trade off good design principles for a bit of extra performance. The notes reflect good design. The sample "rayhdrs.h" came from my own raytracer in which I decided to try to make it run a bit faster. There is no "right" answer here and either way is fine. The only thing that is not fine here is compiler warnings! So if you use the notes approach you MUST change rayhdrs.h. If you use the Westall implementation approach you obviously still need access to the proj_t data structure that defines the projection. So how do you do that? The way I did it was to define static proj_t *proj = NULL; // static variable where we keep proj ptr at the top of my projection.c module outside the body of all functions... Some might say eeeewwwwwwwwweee "global variable". But because its static its global ONLY to the functions in projection.c --- more on this later in the course. Anyhow, in projection_init() I do proj = malloc(sizeof(proj_t)); but I DON"T create a local variable named proj in projection_init. Thus when map_pix...() later refers to proj (it also DOESN"T declare a local proj) it will get the value safely stored there by projection_init() mw