Can someone take a look at what I have and these errors to tell me what I am doing wrong? Sorry its a lot but i cant figure out what im doing wrong. Any help would be greatly appreciated Im new to the whole programming thing. My .h files are at the bottom so you can see what is in the cam and what not.
camera.c:45:38: error: expected ‘)’ before ‘pixel_dim’
camera.c:45:51: error: expected ‘)’ before ‘(’ token
Code:
cam->pixmap=malloc(sizeof(irgb_t * (pixel_dim->x)( pixel_dim->y)));
camera.c:96:58: error: request for member ‘view_point’ in something not a structure or union
Code:
else if(strcmp(attrib_name, "viewpoint")==0) {
count= fscanf(in,"%d %d %d", &cam.view_point.x, &cam.view_point.y,&cam.view_point.z);
camera.c:155:5: error: request for member ‘x’ in something not a structure or union
camera.c:165:1: error: incompatible type for argument 2 of ‘vec_diff’
Code:
void camera_getdir(camera_t *cam, int x, int y, vec_t *uvec) { assert(cam->cookie == CAM_COOKIE);
// convert pixel coordinates to world screen coordinates
uvec.x=cam->world_dim[0] * x /(cam->pixel_dim[x]-1);
uvec.y=cam->world_dim[1] * y /(cam->pixel_dim[y]-1);
uvec.z=0.0;
// compute vector from viewpoint to world screen coordinates
// don't forget about the vector functions from your vector.c file
uvec=vec_diff(uvec,cam->view_point,uvec);
camera.c:190:4: error: request for member ‘r’ in something not a structure or unioncamera.c:191:4: error: request for member ‘g’ in something not a structure or union
camera.c:192:4: error: request for member ‘b’ in something not a structure or union
camera.c:194:10: error: invalid operands to binary > (have ‘drgb_t’ and ‘int’)
camera.c:196:7: error: incompatible types when assigning to type ‘drgb_t’ from type ‘int’
camera.c:199:15: error: invalid operands to binary < (have ‘drgb_t’ and ‘int’)
camera.c:201:7: error: incompatible types when assigning to type ‘drgb_t’ from type ‘int’
Code:
void camera_store_pixel(camera_t *cam, int x, int y, drgb_t *pix) { assert(cam->cookie == CAM_COOKIE);
double row=0.0;
double col=0.0;
int i=0;
irgb_t ipix;
// scale and clamp pix values to integer values; formula given in notes
pix.r *255 +0.5;
pix.g *255 +0.5;
pix.b *255 +0.5;
//if greater then 255 make it 255 if less the 0 make it 0
if(pix[i]>255)
{
pix[i]=255;
i++;
}
else if(pix[i]<0)
{
pix[i]=0;
i++;
}
Here is my ray.h file and part of my vector one that is used in my program
Code:
typedef struct camera_type
{
int cookie;
char name[NAME_LEN];
int pixel_dim[2]; /* Projection screen size in pixels */
double world_dim[2]; /* Screen size in world coords */
vec_t view_point; /* Viewpt Loc in world coords */
irgb_t *pixmap; /* Build image here */
} camera_t;
Code:
void vec_diff(
vec_t *v1, /* subtrahend */
vec_t *v2, /* minuend */
vec_t *v3) /* result */
{
v3->x = v2->x - v1->x;
v3->y = v2->y - v1->y;
v3->z = v2->z - v1->z;
}