# Nothing Display

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&lt;GridSize-2;i++)			//Calculate new velocity
{
for (j=2;j&lt;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&lt;GridSize-2;i++)			//Calculate new ripple position
{
for (j=2;j&lt;GridSize-2;j++)
{
Position[i][j] = Position[i][j] - Velocity[i][j];
Velocity[i][j] = Velocity[j][j] * Viscosity;
}
}

for (i=0;i&lt;GridSize;i++)			//Calculate new vertex coordianates
{
for (j=0;j&lt;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&lt;GridSize;i++)			//Calculate new vertex normals
{
for (j=0;j&lt;GridSize;j++)
{
if (0&lt;i&lt;GridSize && 0&lt;j&lt;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&lt;GridSize-1;j++)
{
for (i=0;i&lt;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
glTranslatef(0.0,0.2,-4.5);
// glColor3f(0.85, 1, 0.85);
DrawWater;

``````return TRUE;
``````

}[/b][color:#3333FF][/b][/color][/color]

Try DrawWater();

DrawWater() cannot also… I don think this is the problem… i think is about the content in between glBegin(GL_QUAD_STRIP) and glEnd.

Try to insert some debugging code. As for example, draw the quads as untextured wireframes, for example.

Normal triangle can, only what i want cannot…

glVertex3fv(&(Vertex[i][j+1].x));
glNormal3fv(&(Normals[i][j].x));
glVertex3fv(&(Vertex[i][j].x));

Should be

glVertex3fv(&(Vertex[i][j+1]));
glNormal3fv(&(Normals[i][j]));
glVertex3fv(&(Vertex[i][j]));

EDIT:

Sorry, I meant

glVertex3fv(&(Vertex[i][j+1].x), &(Vertex[i][j+1].y), &(Vertex[i][j+1].z));

etc…

glVertex3fv takes a pointer to {x,y,z}, we need to know more about the vertex structure hes using. try changing the vertex/normal structure to something like:

``````
typedef struct vertex {
GLfloat xyz[2];
} vertex;

``````

implementation:

``````
vertex vert[] = {{0,0,0},
{0,1,0},
{1,1,0},
{1,0,0}}; // x,y,z
glVertex3fv(&vert[0]);
glVertex3fv(&vert[1]);
glVertex3fv(&vert[2]);
glVertex3fv(&vert[3]);
glEnd();

``````

Do the same with your normals.

Sorry, got error… Function glVertex3fv does not take 3 arguments… And i display one by ones also nothing out.

It takes one pointer to GLfloat {x,y,z}…

you could do: glVertex3f(&Vertex[i][j+1].x, &Vertex[i][j+1].y, &Vertex[i][j+1].z);

== OR ==

glVertex3fv(&vertex[i][j+1]);
^ BUT you would have to change the vertex structure to something like

``````
typedef struct vertex {
GLfloat xyz[2];
} vertex;

``````

However, this is mainly a problem with you C coding skills, not your knowledge of the OpenGL library…

Error occured…

error C2664: ‘glVertex3fv’ : cannot convert parameter 1 from ‘vertex *’ to ‘const GLfloat *’

SionFly,
Are you using MS Visual Studio, I’m using the Express Edition 2008 and it will show errors if the loop counter isn’t initialized, I find this happens a lot in older code:

``````
for(i = 0: i < 5;++i)
{
//loop statements
}

``````

``````
for( int i = 0; i <5:++i)
{
//loop statements
}

``````

glVertex3f(x,y,z)
glvertex3fv(array)

Make sure you have initialized your arrays.
While calculating new vertex positions: The line

if (0<i<GridSize && 0<j<GridSize)

compiles fine but will not give you the expected result. You should use

if (0 < i && i < GridSize-1 && 0 < j && j < GridSize-1)