Results 1 to 10 of 16

Thread: Optimize drawing 10.000 2D-lines with VBO?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Thanks for giving me tips. I have been playing with it all day again and this is what I have at the moment (but still nothing is drawn)
    (is from: http://www.ozone3d.net/tutorials/opengl_vbo_p2.php, my translation from C++ to Delphi). I checked it with your tutorial and did not see any strange things. My viewwindow is set up from (0,0) - (1024,76

    Code:
    var
      vc: Integer;
      ColorSize, PositionSize : Integer;
    const
      BufferSize = 2;
      POSITION_OBJECT = 0;
      COLOR_OBJECT = 1;
    var
      BufferName: array [0..BufferSize-1] of GLuint;
    begin
    
      glGenBuffersARB := wglGetProcAddress('glGenBuffersARB');
      glBindBufferARB := wglGetProcAddress('glBindBufferARB');
      glBufferDataARB := wglGetProcAddress('glBufferDataARB');
      glDeleteBuffersARB := wglGetProcAddress('glDeleteBuffersARB');
    
      PositionSize := length(VertexBuffer) * SizeOf(TVertex2f);
      ColorSize := length(ColorBuffer) * SizeOf(TColor3f);
    
      vc := Length(VertexBuffer);
    
      // allocate a new buffer
      glGenBuffersARB(1, @BufferName[COLOR_OBJECT]);
      // bind the buffer object to use
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferName[COLOR_OBJECT]);
      glBufferDataARB(GL_ARRAY_BUFFER_ARB, ColorSize, @ColorBuffer[0], GL_STREAM_DRAW);
      glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);
    
      glGenBuffersARB(1, @BufferName[POSITION_OBJECT]);
      glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferName[POSITION_OBJECT]);
      glBufferDataARB(GL_ARRAY_BUFFER_ARB, PositionSize, @VertexBuffer[0], GL_STREAM_DRAW);
      glVertexPointer(2, GL_FLOAT, 0, 0);
    
      glEnableClientState(GL_VERTEX_ARRAY);
      glEnableClientState(GL_COLOR_ARRAY);
    
      glDrawArrays(GL_TRIANGLES, 0, vc);
    
      glDisableClientState(GL_VERTEX_ARRAY);
      glDisableClientState(GL_COLOR_ARRAY);
    with data:
    Code:
    type
      TVertex2f = record
        X, Y: TPositionType;
      end;
    
      TColor3f = record
       R, G, B: GLubyte;
      end;
    
    const
      VertexBuffer: array [0..5] of TVertex2f = (
        (X : 0; Y : 0;),
        (X : 200; Y : 0;),
        (X : 200; Y : 200;),
        (X : 200; Y : 200;),
        (X : 0;  Y : 200;),
        (X : 0; Y : 0;)
      );
      ColorBuffer: array [0..5] of TColor3f = (
        (R : 255; G : 0; B : 0),
        (R : 255; G : 255; B : 0),
        (R : 0; G : 255; B : 0),
        (R : 0; G : 255; B : 0),
        (R : 0; G : 0; B : 255),
        (R : 255; G : 0; B : 0)
      );
    Last edited by WhatJac3; 23-09-2010 at 09:47 PM. Reason: additional information

Bookmarks

Posting Permissions

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