Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: glMapBufferRange() ...dynamic drawing?

  1. #1
    Intern Contributor
    Join Date
    Jul 2013
    Posts
    68

    glMapBufferRange() ...dynamic drawing?

    Hi All,
    I've got an app that works well on static data, and it's time to try to work on data click'ed in and dragged by the mouse. I've made the assumption that glMapBufferRange would fit the purpose, and setting the buffer to DYNAMIC_DRAW. I did have a few lucky attempts at start, but I'm fairing worse and worse. I start out with an array-buffer with 100 dummy position-data .. not starting at 0 - and use glDrawRangeElementBaseVertex for drawing Point & Lines. Further I have a struct composed of the arguments for the draw-call (start, end, indices* & baseVertex). All in all, there's quite a number of possibillities to foul up when adding the complexities of taking the input from mouse-click and mouse-drag.
    First, Would my approach be appropriate .. using glMapBufferRange?
    My C/C++ experience grows, but it's not where I would like it to be. That makes me suspicious on how I deal with writing the input to glMapBufferRange. The short example in "OpenGl Superbible" (or was it the other?) uses something like this: (I'm not home at my code)
    GLfloat* positions;
    positions = glMapBufferRange(ARRAY-BUFFER, offset, length, access-mask);
    if(positions !=(GLfloat*)NULL){
    for i=0->8{
    positions[3*i + 2]*=2.0 ;//changes the z-value of 9 vectors of the array
    ....
    }
    }
    where all input and indexing is in 'GLfloat' and not basic mashine-units (byte/char?) as the specs 'says'.
    I uses glMapBufferRange to read the data that I've written, and can see, that it's not proper.
    I did have some proper data written at some time, but still without having it propagate all the way to the screen as points and lines (So, I've added glFlush() & glFinish() to the data-writing) .. I'll have to assume that the parameters to glDrawRangeElementBaseVertex() has fooled me once again ;O/.
    Anyway, basic mashine-units could have something to do with 32/64-bit. The setup is using 32bit libs, but it's a 64bit mashine.
    Using char-indexing (an offset of 4 between two GLfloat-reads/writes) worked, some of the way, didn't it? Or am I just ready for a sanity-check.

    Does anyone have a suspicion on where I foul up .. or maybe a whole other approach to 'click-in' visual data by the mouse?

  2. #2
    Intern Contributor
    Join Date
    Jul 2013
    Posts
    68
    hi all,
    ok, fixed it! glMapBufferRange() takes byte-offsets and length, but the (GLfloat*)positions takes ... floats

Posting Permissions

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