i have nothing to display out when function drawWater call in the DrawGlScene. Is it my GL_QUAD_STRIP problem??
[b]
#define GridSize 63
HDC hDC=NULL; // Private GDI Device Context
HGLRC hRC=NULL; // Permanent Rendering Context
HWND hWnd=NULL; // Holds Our Window Handle
HINSTANCE hInstance; // Holds The Instance Of The Application
bool keys[256]; // Array Used For The Keyboard Routine
bool active=TRUE; // Window Active Flag Set To TRUE By Default
bool fullscreen=FALSE; // Fullscreen Flag Set To Fullscreen Mode By Default
GLuint texture[1];
struct TGLCoord
{
float x,y,z;
};
TGLCoord Vertex [GridSize][GridSize];
TGLCoord Normals [GridSize][GridSize];
float Viscosity;
float Position [GridSize][GridSize];
float Velocity [GridSize][GridSize];
float xAngle, yAngle;
int DrawWater ()
{
int i,j;
float vLength;
for (i=2;i<GridSize-2;i++) //Calculate new velocity
{
for (j=2;j<GridSize-2;j++)
{
Velocity[i][j] = Velocity[i][j] + (Position[i][j] -
(4*(Position[i-1][j] + Position[i+1][j] + Position[i][j-1] + Position[i][j+1]) + // left, right, above, below
Position[i-1][j-1] + Position[i+1][j-1] + Position[i-1][j+1] + Position[i+1][j+1])/25) / 7; // diagonally across
}
}
for (i=2;i<GridSize-2;i++) //Calculate new ripple position
{
for (j=2;j<GridSize-2;j++)
{
Position[i][j] = Position[i][j] - Velocity[i][j];
Velocity[i][j] = Velocity[j][j] * Viscosity;
}
}
for (i=0;i<GridSize;i++) //Calculate new vertex coordianates
{
for (j=0;j<GridSize;j++)
{
Vertex[i][j].x = (i - GridSize/2)/GridSize*5;
Vertex[i][j].y = (Position[i][j] / 1024)/GridSize*3;
Vertex[i][j].z = (j - GridSize/2)/GridSize*5;
}
}
for (i=0;i<GridSize;i++) //Calculate new vertex normals
{
for (j=0;j<GridSize;j++)
{
if (0<i<GridSize && 0<j<GridSize)
{
Normals[i][j].x = Position[i+1][j] - Position[i-1][j];
Normals[i][j].y = 2048;
Normals[i][j].z = Position[i][j+1] - Position[i][j-1];
vLength = sqrt (Normals[i][j].x*Normals[i][j].x + Normals[i][j].y*Normals[i][j].y + Normals[i][j].z*Normals[i][j].z);
if (!vLength)
{
Normals[i][j].x = Normals[i][j].x / vLength;
Normals[i][j].y = Normals[i][j].y / vLength;
Normals[i][j].z = Normals[i][j].z / vLength;
}
}
else
{
Normals[i][j].x = 0;
Normals[i][j].y = 1;
Normals[i][j].z = 0;
}
}
}
glBindTexture(GL_TEXTURE_2D, texture[0]); //Draw water texture
for (j=0;j<GridSize-1;j++)
{
glBegin(GL_QUAD_STRIP);
for (i=0;i<GridSize;i++)
{
glNormal3fv(&Normals([i][j+1]));
glVertex3fv(&(Vertex[i][j+1].x));
glNormal3fv(&(Normals[i][j].x));
glVertex3fv(&(Vertex[i][j].x));
}
glEnd();
}
return TRUE;
}
int DrawGLScene(GLvoid) // Here’s Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity();
glTranslatef(0.0,0.2,-4.5);
// glColor3f(0.85, 1, 0.85);
DrawWater;
return TRUE;
}[/b][color:#3333FF][/b][/color][/color]