ok I''m getting some wierd crash messages some of the time only when I am changing the mesh in real time.

It''s telling me that its doing an invalid floating point operation on the lines i''ll point out. However If I''m not changing the matix, it works....Can someone plz point out to me what the problem is?? I call it with this line:

t=(clock()-initTime)/CLK_TCK; //i initialize the clock farther up.

recalc( matrix, t, centers );

CreatePlane( 2.0, matrix, 2.0, 7, 7 );

The matrix is an array of 49. I''m pretty sure im not over running the bounds of my array, because I''ve tried increasing it...nada.

I''m trying to create a plane with a certain amount of vertices so I can animate it. SHould I be doing something differently to achieve this end?

void CreatePlane( float width, float *height, float length, int widthseg, int lengthseg )

{

int i=0;

float xstep=width/widthseg; // <------ crashes at this line

float zstep=length/lengthseg; // <------ and this one too

float initwidth=width;

float initlength=length;

glBindTexture(GL_TEXTURE_2D, g_Texture[0]);

glBegin (GL_QUADS); // This is our BEGIN to draw

for (float length=initlength/(-2); length<=((initlength/2)-zstep); length+=zstep )

for(float width=initwidth/(-2); width<= ((initwidth/2)-xstep); width+=xstep)

{

// Display the top left vertice

glTexCoord2f(0.0f, 1.0f);

glVertex3f(width, height

*, length);*

// Display the bottom left vertice

glTexCoord2f(0.0f, 0.0f);

glVertex3f(width, height[i+row], length+zstep);

// Display the bottom right vertice

glTexCoord2f(1.0f, 0.0f);

glVertex3f(width+xstep, height[i+row+1], length+zstep);

// Display the top right vertice

glTexCoord2f(1.0f, 1.0f);

glVertex3f(width+xstep, height[i+1], length);

i++;

}

glEnd(); // This is the END of drawing

}

/////////////////////////////Here is that mesh changing function

const int MAXSIZE=49;

int row =sqrt(MAXSIZE);

const float xscale=1.0;

const float yscale=1.0;

void recalc( float * matrix, float time, DATA *centers )

{

float dis;

float h;

int i=0;

clear( matrix ); //resets it to zero

while ( centers[i].startTime>=0 )

{

for (int point=0; point
{

dis=sqrt( pow( ((point % row)-(centers[i].center % row ))*xscale , 2)

+ pow( ((point /row )-(centers[i].center/row))*yscale, 2) );

if ( (time-centers[i].startTime-dis) > 0 )

{

h=-3*sin(5*( time-centers[i].startTime)- dis ) * float (exp( double( (-time-centers[i].startTime)/5.0 ) ) );

matrix[point]+=h;

}

}

i++;

}

}

the centers bit is just an array of structures that can keep track of the center points of the waves, and when they start. I''ve tested this function may times; it works. But as soon as I try to use it in ogl, the program crashes

Thanks for any help you give....

Norbs

// Display the bottom left vertice

glTexCoord2f(0.0f, 0.0f);

glVertex3f(width, height[i+row], length+zstep);

// Display the bottom right vertice

glTexCoord2f(1.0f, 0.0f);

glVertex3f(width+xstep, height[i+row+1], length+zstep);

// Display the top right vertice

glTexCoord2f(1.0f, 1.0f);

glVertex3f(width+xstep, height[i+1], length);

i++;

}

glEnd(); // This is the END of drawing

}

/////////////////////////////Here is that mesh changing function

const int MAXSIZE=49;

int row =sqrt(MAXSIZE);

const float xscale=1.0;

const float yscale=1.0;

void recalc( float * matrix, float time, DATA *centers )

{

float dis;

float h;

int i=0;

clear( matrix ); //resets it to zero

while ( centers[i].startTime>=0 )

{

for (int point=0; point

dis=sqrt( pow( ((point % row)-(centers[i].center % row ))*xscale , 2)

+ pow( ((point /row )-(centers[i].center/row))*yscale, 2) );

if ( (time-centers[i].startTime-dis) > 0 )

{

h=-3*sin(5*( time-centers[i].startTime)- dis ) * float (exp( double( (-time-centers[i].startTime)/5.0 ) ) );

matrix[point]+=h;

}

}

i++;

}

}

the centers bit is just an array of structures that can keep track of the center points of the waves, and when they start. I''ve tested this function may times; it works. But as soon as I try to use it in ogl, the program crashes

Thanks for any help you give....

Norbs