Quantcast
Channel: AMD Developer Forums: Message List - OpenGL & Vulkan
Viewing all articles
Browse latest Browse all 631

Re: Re: Re: glMapBuffer and secondary thread problem

$
0
0

You cannot use mapped buffer as source for glDraw* calls in OpenGL 3.3 (version "330" is specified in Your GLSL code). Change Your code to:

 

        // Map buffer before update

        float* data = (float*) glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY | GL_MAP_UNSYNCHRONIZED_BIT); 

        for (unsigned i = 0; i < 300; i+=3{

            data[i] = ((rand() % 2001) * 0.001f) - 1.0f; 

            data[i+1] = ((rand() % 2001) * 0.001f) - 1.0f; 

            data[i+2] = 0.0f; 

        } 

        // Unmap buffer before use

        glUnmapBuffer(GL_ARRAY_BUFFER);


        glClear(GL_COLOR_BUFFER_BIT); 

        glDrawArrays(GL_POINTS,0,100); 

      ...

 

Also notice that Your memcpy() call, just copies 300 bytes instead of copying 300*sizeof(float) which is also incorrect.

If You still want to update buffers and use them for glDraw* calls at the same time, You have to use ARB_buffer_storage extension of OpenGL 4.4 (e.g. create and map buffer with GL_MAP_PERSISTENT_BIT flag).

 

Regards,

Leon.


Viewing all articles
Browse latest Browse all 631

Trending Articles