Helllo,I have a piece of code and i m trying to understand it.The code is to draw a grid and deform it according to a particular function.i.e the sincModify().I am getting the error too less parameters which is because there are no parameters in sincModify in the main().Can anyone help me out by telling what is to be done because i didnt get the whole program
//////////////code//////
#include<GL/glut.h>
#include<math.h>
#define Q_UNUSED
static void sincModify(double pt[3],const double bounds[4])
{
double r=sqrt(pt[0]pt[0]+pt[1]pt[1]);
const double pi=3.1415;
pt[2]=-sin(pir)/pir;
Q_UNUSED(bounds);
}
double* computePointCoordinates(int PointIndex,int xPoint,int yPoint,double xSpace,double ySpace)
{
static double pt[3];
double width=xSpace*(xPoint-1);
double height=ySpace*(yPoint-1);
double minX=-width/2;
double minY=-height/2;
pt[0]=minX+xSpace*(PointIndex%xPoint);
pt[1]=minY+ySpace*(PointIndex/yPoint);
pt[2]=0;
return pt;
}
void computePointCoordinates(int PointIndex,int xPoint,int yPoint,double xSpace,double ySpace,double pt[3])
{
double tmp=computePointCoordinates(PointIndex,xPoint,yPoint,xSpace,ySpace);
pt[0]=tmp[0];
pt[1]=tmp[1];
pt[2]=tmp[2];
}
void renderGrid(int xPoint,int yPoint,double xSpace,double ySpace,void deformFunction(double pt[3],const double bounds[4]))
{
double bounds[4];
int nrQuads=(xPoint-1)(yPoint-1);
if(deformFunction)
{
double width=xSpace(xPoint-1);
double height=ySpace*(yPoint-1);
bounds[0]=-width/2;
bounds[1]=-height/2;
bounds[2]=width;
bounds[3]=height;
}
glBegin(GL_TRIANGLES);
for(int i=0;i<nrQuads;i++)
{
int k=i+i/(xPoint-1);
int a=k;
int b=k+1;
int c=k+1+xPoint;
int d=k+xPoint;
double apt[3],bpt[3],cpt[3],dpt[3];
computePointCoordinates(a,xPoint,yPoint,xSpace,ySpace,apt);
computePointCoordinates(b,xPoint,yPoint,xSpace,ySpace,bpt);
computePointCoordinates(c,xPoint,yPoint,xSpace,ySpace,cpt);
computePointCoordinates(d,xPoint,yPoint,xSpace,ySpace,dpt);
if(deformFunction)
{
deformFunction(apt,bounds);
deformFunction(bpt,bounds);
deformFunction(cpt,bounds);
deformFunction(dpt,bounds);
}
glVertex3dv(apt);
glVertex3dv(cpt);
glVertex3dv(dpt);
glVertex3dv(apt);
glVertex3dv(bpt);
glVertex3dv(cpt);
}
glEnd();
}
void renderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(0.0,0.0,0.0);
renderGrid(50,50,0.06,0.06,sincModify());
glutSwapBuffers();
}
void myInit()
{
glClearColor(1.0,1.0,1.0,1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-2.00,-2.00,-2.00,-2.00,-2.00,-2.00);
glMatrixMode(GL_MODELVIEW);
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
glPointSize(8);
}
int main(int argc,char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(0,0);
glutInitWindowSize(600,600);
glutCreateWindow(“Grid Tutorial”);
glutDisplayFunc(renderScene);
myInit();
glutMainLoop();
}