PDA

View Full Version : Error Help : Convert Parameter



sklim
08-25-2010, 10:43 AM
Below is something about my code. I cant solve the error.. Hope to get help from you all.. Thanks.. :)

[B]#define GridSize 63

struct TGLCoord
{
float x,y,z;
};
TGLCoord Vertex [GridSize];
TGLCoord Normals [GridSize];

for (j=0;j<GridSize-1;j++)
{
glBegin(GL_QUAD_STRIP);
for (i=0;i<GridSize;i++)
{
glNormal3fv(&amp;Normals[i, j+1]);
glVertex3fv(&amp;Vertex[i, j+1]);
glNormal3fv(&amp;Normals[i, j]);
glVertex3fv(&amp;Vertex[i, j]);
}
glEnd();
}

error C2664: 'glNormal3fv' : cannot convert parameter 1 from 'TGLCoord *' to 'const GLfloat *'

trinitrotoluene
08-25-2010, 11:26 AM
In which language you are programing ? If you are programming in C then &amp;Normal[i].x should be okay. Remark: You define a 1D array TGLCoord Normals [GridSize]; and try to access it like a 2D array => Normals[i, j+1]. I think this is valid in C# but in C you must write Normals[i][j+1]. So try something like this :


#define GridSize 63

struct TGLCoord
{
float x,y,z;
};
TGLCoord Vertex [GridSize][GridSize];
TGLCoord Normals [GridSize][GridSize];

for (j=0;j<(GridSize-1);j++)
{
glBegin(GL_QUAD_STRIP);
for (i=0;i<GridSize;i++)
{
glNormal3fv(&amp;(Normals[i][j+1].x));
glVertex3fv(&amp;(Vertex[i][j+1].x));
glNormal3fv(&amp;(Normals[i][j].x));
glVertex3fv(&amp;(Vertex[i][j].x));
}
glEnd();
}


Here I suppose a grid of 63x63.

sklim
08-25-2010, 11:29 AM
Firstly, thanks for trinitrotoluene replied..
My language here is C++.. Is it same as the solution for language C??

trinitrotoluene
08-25-2010, 11:31 AM
My language here is C++.. Is it same as the solution for language C?? Yes.

sklim
08-25-2010, 11:33 AM
Ok.. I try now.. Thanks for your suggestion.. I will come back if got any error and don't understand.. Again, thanks for trinitrotoluene.. You are smart..

sklim
08-25-2010, 12:16 PM
trinitrotoluene, it works now.. really thanks a lot for your help.. *touch*

sklim
09-08-2010, 10:00 PM
hey, even it works now, but still nothing to appear/show in GL_QUAD_STRIP? i had try to change it become a triangle (GL_TRIANGLES), and it is appears. Can anyone let me know why. Thanks..