Generate plane mesh only once

Hi,

I’m trying to generate a plane using 100 x 100 planes, and tesselate then on a big plane so that I can change its own texture, but I must generate the same mesh everytime I want to send it to glVertex, so sending 100 x 100 vertices everytime is very slow, is there nay other way to generate the texture only once and the send it everytime?

this is what I’m using:

DrawMultiRect2D(X, Y, Width, Height: Double);
var
  X2, 
  Y2: Double;
  x2, y2: Integer;
begin
  X1 = Width / 2;
  Y1 = Height / 2;

  glEnable(GL_TEXTURE_2D);

  for y2 = -50 to 50 do
  for x2 = -50 to 50 do
  begin
    glBindTexture(GL_TEXTURE_2D, 1);
    glBegin(GL_QUADS);
      glTexCoord2f(0, 0); glVertex2f((x2)*X1,      (y2)*Y1);
      glTexCoord2f(1, 0); glVertex2f((x2)*X1 + X1, (y2)*Y1);
      glTexCoord2f(1, 1); glVertex2f((x2)*X1 + X1, (y2)*Y1 + Y1);
      glTexCoord2f(0, 1); glVertex2f((x2)*X1,      (y2)*Y1 + Y1);
    glEnd();
  end;

  glDisable(GL_TEXTURE_2D);
end;

is there any other way?

Yes, read up on Vertex Buffer Objects (VBO). These are used to store vertex properties (position, normal, tex coords, etc.) in GPU memory.

A similar (but older and slower) thing is Vertex Arrays, there the data is not copied to GPU memory, but instead you store the vertex properties in arrays in main memory.

Thanks, but how can I use VBO?
I’m starting to use this, can you give me any example for use it?

thks again

See:

in particular, after reading this, see the examples link at the bottom.

Thanks, but using VBO is much faster than using a list of all the vertices in memory?

And does VBO let me change the each vertex position anytime?

I din’t understand the diference between GL_DYNAMIC_COPY and GL_DYNAMIC_READ , wich one send the structure to the Memory?

thks again for the link

Can be. Depends. The key idea behind VBOs sometimes being faster is that they exist on the GPU or in driver-managed CPU memory – i.e. closer to where they’ll be needed in the GPU pipeline than client arrays (which exist in user-managed CPU memory, which aren’t necessarily even aligned properly).

And does VBO let me change the each vertex position anytime?

Yes. And if you change them efficiently, then these changes will pipeline very well and not slow down rendering much.

I din’t understand the diference between GL_DYNAMIC_COPY and GL_DYNAMIC_READ , wich one send the structure to the Memory?

See pg. 11 in this PDF:

or search down to “one of nine enumerated values” in this extension spec:

or look in section 2.9.2 in the OpenGL spec:

Easy way to find in the latter: search for “stream copy” no quotes, and use a space instead of an underscore. Skip the first match and go to the second.