-
OGL C++ to D3D VB?
Who knows how I can translate this to VB D3D Code?
It's quite confusing for someone who never coded OpenGL :)
to quote my friend who's busy with it:.
"Can you tell me how i could convert this GL rendercode to D3D triangle Strip or triangle list."
Code:
for ( int j = 0; j < WATERY; j++ )
{
glBegin( GL_QUAD_STRIP );
for ( int i = 0; i < WATERX; i++ )
{
int x = i&(WATERX-1);
int y = j&(WATERY-1);
int y1 = (j+1)&(WATERY-1);
glNormal3fv( (float*)&waterNormal[ x + y * WATERX ] );
glTexCoord2f( i * 0.3f, j * 0.3f );
glVertex3f( (float)( i-WATERX/2 ),
waterHeight[ x + y * WATERX ],
(float)( j-WATERY/2 ) );
glNormal3fv( (float*)&waterNormal[ x + y1 * WATERX ] );
glTexCoord2f( i * 0.3f, j * 0.3f + 0.3f );
glVertex3f( (float)( i-WATERX/2 ),
waterHeight[ x + y1 * WATERX ],
(float)( j+1-WATERY/2 ) );
}
glEnd();
}
Thanks if someone knows how to translate this.
-
Basically this generates the vertices in the strip.
glBegin() - Vertex Buffer Lock() call
glEnd() - Vertex buffer Unlock() call (in VB this is where you would set the vertex data with whatever function that is...
glNormal3fv() - set the normal for this vertex (in this case, its reading the normal from an array)
glTexCoord2f() - set the texture coordinates for this vertex
glVertex3f() - set the position for this vertex (in this case, reading the height value from an array)
The & operator is the VB And operator. Beyond that, its just a nested for loop.
Z.
-
Thanks, thats exactly what I needed to know :)