Results 1 to 3 of 3

Thread: OGL C++ to D3D VB?

  1. #1

    Thread Starter
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049

    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.

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    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.

  3. #3

    Thread Starter
    Frenzied Member Devion's Avatar
    Join Date
    Sep 2000
    Location
    The Netherlands
    Posts
    1,049
    Thanks, thats exactly what I needed to know

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width