Like Tree1Likes
  • 1 Post By Salem

arg list syntax error

This is a discussion on arg list syntax error within the General Discussions forums, part of the Community Boards category; arg list syntax error. The error occurred in the program at arg list int get_coeff(wcpt3 pt1 ,wcpt3 pt2,wcpt3 pt3)(z-buffer method). ...

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    2

    arg list syntax error

    arg list syntax error.
    The error occurred in the program at arg list int get_coeff(wcpt3 pt1
    ,wcpt3 pt2,wcpt3 pt3)(z-buffer method).
    i got the code from this link.
    Computer Graphics - Sinha and Udai - Google Books
    i wish to get c code for visible surface method.(back face or depth buffer(z-buffer) or scan line method)

    Code:
    #include<stdio.h>
    #include<conio.h>
    #include<graphics.h>
    #define TRUE 1
    #define FALSE 0
    
    
    struct wcpt3{
    	float x,y,z;
    	}nan;
    struct plane{
    	float A,B,C,D;
    	};
    
    
    int get_coeff(wcpt3 pt1
    ,wcpt3 pt2,wcpt3 pt3)
    {
    plane temp;
    temp.A=(pt2.z-pt3.z)*(pt1.y-pt2.y)-(pt1.z-pt2.z)*(pt2.y-pt3.y);
    temp.B=(pt2.x-pt3.x)*(pt1.z-pt2.z)-(pt1.x-pt2.x)*(pt2.z-pt3.z);
    temp.C=(pt2.y-pt3.y)*(pt1.x-pt2.x)-(pt1.y-pt2.y)*(pt2.x-pt3.x);
    temp.D=-pt1.x*(pt2.y*pt3.z-pt2.z*pt3.y)+pt1.y*(pt2.x*pt3.z-pt2.z*pt3.x)-pt1.z*(pt2.x*pt3.y-pt2.y*pt3.x);
    return temp;
    }
    
    
    float depth(plane surface, float x, float y)
    {
    	float z=0;
    	if(surface.C!=0)
    		z=(-surface.A*x-surface.B*y-surface.D)/surface.C;
    	return Z;
    }
    
    
    int side_check(wcpt3 ptA, wcpt3 ptB, wcpt3 ptC, float X,float y)
    {
    float fxyC,fxy;
    fxyC=ptC.x*(ptA.y-ptB.y)-ptC.y*(ptA.x-ptB.x)-ptA.x*(ptA.y*ptB.y)+ptA.y*(ptA.x-ptB.x);
    fxy=x*(ptA.y-ptB.y)-y*(ptA.x-ptB.x)-ptA.x*(ptA.y-ptB.y)+ptA.y*(ptA.x-ptB.x);
    if((fxyC<0)&&(fxy<0))||((fxyC>0)&&(fxy>0)))
    return TRUE;
    else
    return FALSE;
    }
    
    
    int inside_triangle_check(wcpt3 pt1,wcpt3 pt2, wcpt3 pt3,flat x,float y)
    {
    int check=side_check(pt1,pt2,pt3,x,y)&&side_check(pt2,pt3,pt1,x,y)&&side_check(pt3,pt1,pt2,x,y);
    
    
    if(check==TRUE)
    return TRUE;
    else
    return FALSE;
    }
    void main(void)
    {
    	int gd=DETECT,gm;
    	initgraph(&gd,&gm,"");
    	wcpt3 ptA,ptB,ptC,ptD;
    	plane surface[10];
    	int clr_background=BLACK,clr,numsurf,colorxy[4],surf_clr[10];
    	float depth_background=0,depthxy[4],x,y,z;
    	ptA.x=200; ptA.y=200; ptA.z=200;
    	ptB.x=600; ptB.y=200; ptB.z=200;
    	ptC.x=400; ptC.y=200; ptC.z=600;
    	ptD.x=400; ptD.y=400; ptD.z=400;
    
    
    	surface[0]=get_coeff(ptA,ptC,ptD);
    	surf_clr[0]=BLUE;
    	surface[1]=get_coeff(ptC,ptB,ptD);
    	surf_clr[1]=GREEN;
    	surface[2]=get_coeff(ptB,ptA,ptD);
    	surf_clr[2]=CYAN;
    	surface[3]=get_coeff(ptA,ptC,ptB);
    	surf_clr[3]=RED;
    	for(x= 0;x<getmaxy();x++)
    	{
    		for(numsurf=0; numsurf<4;numsurf++)
    		{
    			depth[numsurf]=depth_background;
    			colorxy[numsurf]=clr_background;
    		}
    	if(inside_triangle_check(ptA,ptC,ptD,x,y)==TRUE)
    		depthxy[0]=depth(surface[0],x,y);
    	if(inside_triangle_check(ptC,ptB,ptD,x,y)==TRUE)
    		depthxy[1]=depth(surface[1],x,y);
    	if(inside_triangle_check(ptA,ptB,ptD,x,y)==TRUE)
    		depthxy[2]=depth(surface[2],x,y);
    
    
    	if(inside_triangle_check(ptA,ptc,ptB,x,y)==TRUE;
    		depthxy[3]=depth(surface[3]x,y);
    	z=depth_background;
    	clr=clr_background;
    	for(numsurf=0;numsurf<4;numsurf++)
    	{
    		if(deprhxy[numsurf]>z)
    		{
    			z=depthxy[numsurf];
    			clr=surf_clr[numsurf];
    		}
    	}
    	putpixel(x,y,clr);
    
    
    }
    getch();
    }
    
    
    
    
    
    
    
    
    
    With regards,
    Tamasa.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,849
    I guess your link is useless to anyone outside India.

    Also, you're learning using TurboC, which sets you back about 25 years from the state of the art. If you're serious about learning modern graphics, you need to find a book which doesn't use TC as the reference compiler.

    Another nail in the coffin for this book is the fact that the author doesn't know the difference between C and C++.
    Whist it superficially looks like C, the use of structs comes from C++.

    float depth(plane surface, float x, float y)
    C++ automatically creates the typename for each struct.

    In C, you would either have to do this.
    float depth(struct plane surface, float x, float y)

    Or do this
    Code:
    typedef struct plane{
        float A,B,C,D;
        } plane;
    This code is utterly pointless
    Code:
    if(check==TRUE)
    return TRUE;
    else
    return FALSE;
    You may as well just say
    return check;

    Likewise, where you're testing what are essentially boolean functions with
    if ( foo() == TRUE )
    you can just as easily say
    if ( foo() )
    memcpy likes this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    >>Also, you're learning using TurboC, which sets you back about 25 years from the state of the art. If you're serious about learning modern graphics, you need to find a book which doesn't use TC as the reference compiler.

    If you want to learn auto-mobile engineering in India, do you have to purchase your own hand-crank to start the cars or is it provided as part of the course?

  4. #4
    Registered User
    Join Date
    Sep 2012
    Posts
    2
    Thank you!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. std::map initializer list syntax ?
    By manasij7479 in forum C++ Programming
    Replies: 1
    Last Post: 08-21-2011, 06:40 AM
  2. Error "in function 'main' syntax error before 'int' Help Please
    By blackhat11907 in forum C Programming
    Replies: 5
    Last Post: 08-20-2011, 08:05 PM
  3. GCC compiler giving syntax error before 'double' error
    By dragonmint in forum Linux Programming
    Replies: 4
    Last Post: 06-02-2007, 06:38 PM
  4. template list syntax error
    By ichijoji in forum C++ Programming
    Replies: 1
    Last Post: 05-19-2004, 06:44 PM
  5. Linked list part 2 (Syntax error free version)
    By davidvoyage200 in forum C++ Programming
    Replies: 1
    Last Post: 03-16-2003, 10:07 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21