Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Locking a VBO in OpenGL

  1. #11

    Locking a VBO in OpenGL

    Hmm... you should try and set a breakpoint somewhere. Step through your code and pinpoint the exact location of the bug.

    I could help you fix this, but i need you to get Online (MSN). :razz:
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #12

    Locking a VBO in OpenGL

    Quote Originally Posted by Brainer
    Still the same. I even tried glDrawArrays instead, but I still get that god-damn AV. :?
    Could you paste your array declaration and code where pointers (both vertex and index buffers) are set to VBO.

  3. #13

    Locking a VBO in OpenGL

    Quote Originally Posted by chronozphere
    I could help you fix this, but i need you to get Online (MSN). :razz:
    I'm online all the time, but I'm using an offline mode.

    User137, I'm not sure what you mean, I'm posting this:
    [pascal]
    { TBVertexBufforOGL }

    { .: BUsageToOGLUsage :. }
    function BUsageToOGLUsage(const Usage: TBUsage): GLuint; inline;
    begin
    case Usage of
    BUSAGE_RENDERTARGET: Result := GL_STATIC_DRAW_ARB;
    BUSAGE_DYNAMIC: Result := GL_DYNAMIC_DRAW_ARB;
    BUSAGE_WRITEONLY: Result := GL_WRITE_ONLY_ARB;
    end;
    end;

    procedure TBVertexBufforOGL.CreateVertexBuffor(Size, SizeVertex: Integer;
    FVF: DWORD; Pool: TBPOOL; Usage: TBUsage);
    begin
    glGenBuffersARB(1, @VBuffor);

    glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBuffor);
    glBufferDataARB(GL_ARRAY_BUFFER_ARB, Size * SizeVertex, nil,
    BUsageToOGLUsage(Usage));

    FSizeVertex := SizeVertex;
    end;

    destructor TBVertexBufforOGL.Destroy;
    begin
    UnInit();

    inherited Destroy();
    end;

    function BUFFER_OFFSET(I: Cardinal): Pointer;
    var
    Ptr: Pointer absolute I;
    begin
    Result := Ptr;
    end;

    function TBVertexBufforOGL.Lock(Start, Count: DWORD): Pointer;
    begin
    Result := glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_READ_ONLY_ARB);
    end;

    procedure TBVertexBufforOGL.Render(Typ: TBShapetype; Count: DWORD);
    var
    TheType: GLuint;
    begin
    glEnableClientState(GL_VERTEX_ARRAY);
    glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBuffor);
    case Typ of
    BPOINTLIST: TheType := GL_POINTS;
    BLINELIST: TheType := GL_LINES;
    BLINESTRIP: TheType := GL_LINE_STRIP;
    BTRIANGLELIST: TheType := GL_TRIANGLES;
    BTRIANGLESTRIP: TheType := GL_TRIANGLE_STRIP;
    BTRIANGLEFAN: TheType := GL_TRIANGLE_FAN;
    end;
    glDrawArrays(TheType, 0, Count);
    glDisableClientState(GL_VERTEX_ARRAY);
    end;

    procedure TBVertexBufforOGL.UnInit;
    begin
    glDeleteBuffersARB(1, @VBuffor);
    end;

    procedure TBVertexBufforOGL.UnLock;
    begin
    glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
    end;
    [/pascal]

Page 2 of 2 FirstFirst 12

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
  •