Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6851913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:18:21+00:00 2026-05-27T01:18:21+00:00

I´m trying to make a dynamic point cloud visualizer. The points are updated every

  • 0

I´m trying to make a dynamic point cloud visualizer. The points are updated every frame with Kinect Sensor. To grab the frames I´m using OpenCV and GLUT to display.
The OpenCV API returns a 640 x 480 (float *), for the points xyz position , and a 640 x 480 (int *) for the rgb color data.
To get the maximum performance, I´m trying to use Vertex Buffer Object in stream mode instead of a simple Vertex Array. I´m being able to render it with Vertex Array, but nothing is being rendered with my VBO implementation. I tryied a bunch of different orders in the declarations, but i can’t find what I’m missing. Can someone try to point me to the right direction? Here is the simpflified code: (I´ve rewrited the wrong version as asked by Christian Rau, so you guys can understand my mistakes)

int main()
{
    //Delaring variables, inittiating glut, setting camera and checking the compatibility as http://www.songho.ca/opengl/gl_vbo.html
    glutDisplayFunc(displayCB);
    glutIdleFunc(displayCB); 
    ... 
    //Inittiating the vertex buffers
    if(vboSupported)
    {
        glGenBuffers(1, &vertex_buffer);
        glBindBuffer(GL_ARRAY_BUFFER_ARB, buffer);
        glBufferData(GL_ARRAY_BUFFER_ARB, (sizeof(GLfloat) * 640 * 480 * 3), 0, GL_STREAM_DRAW_ARB);
        glBufferSubData(GL_ARRAY_BUFFER_ARB, 0,  (sizeof(float) * 640 * 480 * 3), point_cloud.points_position); 

        glGenBuffers(2, &color_buffer);
        glBindBuffer(GL_ARRAY_BUFFER_ARB, buffer);
        glBufferData(GL_ARRAY_BUFFER_ARB, (sizeof(GLbyte) * 640 * 480 * 3), 0, GL_STREAM_DRAW_ARB);
        glBufferSubData(GL_ARRAY_BUFFER_ARB, 0,  (sizeof(char) * 640 * 480 * 3), point_cloud.points_color); 
    }
    //glutMainLoop(), cleaning memory, ending main
    ..
}

//Updating the screen
void displayCB()
{
    point_cloud.update();

    // clear buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    // save the initial ModelView matrix before modifying ModelView matrix
    glPushMatrix();

        glBindBuffer(GL_ARRAY_BUFFER_ARB, color_buffer);
        glBufferSubData(GL_ARRAY_BUFFER_ARB, 0,  (sizeof(char) * 640 * 480 * 3), point_cloud.points_color); 
        glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);

        glBindBuffer(GL_ARRAY_BUFFER_ARB, vertex_buffer);
        glBufferSubData(GL_ARRAY_BUFFER_ARB, 0,  (sizeof(float) * 640 * 480 * 3), point_cloud.points_position); 
        glVertexPointer(3, GL_FLOAT, 0, 0));

        // enable vertex arrays
        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);

        glDrawArrays(GL_POINT, 0, 640*480);

        glDisableClientState(GL_VERTEX_ARRAY);  // disable vertex arrays
        glDisableClientState(GL_COLOR_ARRAY);

        glBindBuffer(GL_ARRAY_BUFFER_ARB, 0);

    glPopMatrix();

    glutSwapBuffers();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:18:22+00:00Added an answer on May 27, 2026 at 1:18 am

    PS: The program is up and running, but I can’t see any improvement in the average performance when compared to the Vertex Array version. Is that alright?
    THE PROBLEM WAS SOLVED. I´ve done three alterations:

    1 - I though that glGenBuffers first parameter was the number that
    would be associated to the buffer, instead, its the number of
    buffers that would be allocated. This doesn't matter anyway, because
    now I'm using a single buffer and adding all the data to it. Didn't
    solved the problem, but was going in the right way.
    
    2 - There are two ways of being able to use OpenGL VBO functions.
    First, you can bind the ARB  version functions by yourself OR you
    can add glew.h and use glewInit() after starting an OpenGL context.
    The second option is a LOT cleaner and I changed my code so I don't
    use the ARB versions anymore. Still didn't solved the problem.
    
    3 - Christian Rau asked me for glErrors in the code, so, I wrote it
    after each OpenGL operation in displayCB. After glDrawArrays I got
    an 0x00500 error, that means there is an invalid enum, so I noticed
    I was using GL_POINT as parameter to glDrawArrays, instead of
    GL_POINTS, so silly that makes me want to kill myself.
    

    The final code:

    //EDIT: Added glew.h as a header and I´m not using the ARB version anymore
    #include <glew.h>
    
        int main()
        {
            //Declaring variables, initiating glut, setting camera and checking the compatibility as http://www.songho.ca/opengl/gl_vbo.html
            glutDisplayFunc(displayCB);
            glutIdleFunc(displayCB); 
            ...
    
            //EDIT: IS VERY IMPORTANT TO ADD IT AS SOON AS YOU START AN OPENGL CONTEXT.
            initGlew();
    
            //Inittiating the vertex buffers
            if(vboSupported)
            {
               //EDIT: I was using two buffers, one for color and another for the vertex. I changed the code so I use  a single buffer now.
               //EDIT: Notice that I'm not using the ARB version of the functions anymore.
                glGenBuffers(1, &buffer);
                glBindBuffer(GL_ARRAY_BUFFER_ARB, buffer);
                glBufferData(GL_ARRAY_BUFFER_ARB, (sizeof(GLfloat) * 640 * 480 * 3) + (sizeof(GLbyte) * 640 * 480 * 3), 0, GL_STREAM_DRAW_ARB);
            }
            //glutMainLoop(), cleaning memory, ending main
            ..
        }
    
        //Updating the screen
        void displayCB()
        {
            point_cloud.update();
    
            // clear buffer
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    
            // save the initial ModelView matrix before modifying ModelView matrix
            glPushMatrix();
    
                glBindBuffer(GL_ARRAY_BUFFER_ARB, buffer);
                glBufferSubData(GL_ARRAY_BUFFER_ARB, 0,  (sizeof(char) * 640 * 480 * 3), point_cloud.points_color); 
                glBufferSubData(GL_ARRAY_BUFFER_ARB, (sizeof(char) * 640 * 480 * 3), (sizeof(float) * 640 * 480 * 3), point_cloud.points_position);
    
                // enable vertex arrays
                glEnableClientState(GL_VERTEX_ARRAY);
                glEnableClientState(GL_COLOR_ARRAY);
    
                glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);
                //EDIT: Added the right offset at the vertex pointer position
                glVertexPointer(3, GL_FLOAT, 0, (void*)(sizeof(char) * 640 * 480 * 3));
    
                //EDIT: Was using GL_POINT instead of GL_POINTS
                glDrawArrays(GL_POINTS, 0, 640*480);
    
                glDisableClientState(GL_VERTEX_ARRAY);  // disable vertex arrays
                glDisableClientState(GL_COLOR_ARRAY);
    
                glBindBuffer(GL_ARRAY_BUFFER_ARB, 0);
    
            glPopMatrix();
    
            glutSwapBuffers();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a dynamic PDF form using Adobe LiveCycle designer and have
I'm trying to make a dynamic chart using HighCharts, but as it seems to
I'm trying to make a text effect where on every frame the textfield increases
I'm trying to make a dynamic image gallery from and xml. From my tutorials,
I'm trying to make a dynamic regex that matches a person's name. It works
I'm trying to make a dynamic array in C# but I get an annoying
I'm trying to make a clean url for a blog on a dynamic website,
I'm trying to make a time with Time.local which in my code is dynamic.
Im trying to make dynamic column list that will be 4 columns total (PHP).
I'm trying to make has_many relation with dynamic class_name attribute class Category < ActiveRecord::Base

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.