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 7 of 7

Thread: 2D - 20000 Polylines - blinking

  1. #1
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    12

    2D - 20000 Polylines - blinking

    I have 20000 polylines to draw, when I make PAN, these redraw are blinking...

    I use vector and glVertexPointer(3, GL_DOUBLE, 0, data());

    What is the best way to do it?

    I'm using glortho with gltranslated.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Mar 2012
    Posts
    129
    You probably are not double-buffering. How you enable it depends on your windowing system.

  3. #3
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    450
    Use double buffering to reduce flicker as cireneikual said.

    To increase performance make sure your data uses single-precision floats and change GL_DOUBLE to GL_SINGLE too, since most hardware will need to perform this conversion otherwise. If the data is static, or doesn't change often then using VBOs can save re-submitting the same data to the GPU every time. Also, make sure your data() call isn't doing more work than it needs to.

  4. #4
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by Dan Bartlett View Post
    To increase performance make sure your data uses single-precision floats and change GL_DOUBLE to GL_SINGLE too
    There isn't a "GL_SINGLE"; for single-precision floats, use GL_FLOAT.

  5. #5
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    12
    Quote Originally Posted by Dan Bartlett View Post
    Use double buffering to reduce flicker as cireneikual said.

    To increase performance make sure your data uses single-precision floats and change GL_DOUBLE to GL_SINGLE too, since most hardware will need to perform this conversion otherwise. If the data is static, or doesn't change often then using VBOs can save re-submitting the same data to the GPU every time. Also, make sure your data() call isn't doing more work than it needs to.
    Hi Dan...

    I'm using opengl with MFC, yes, is double buffered. I change double to float, but doesn't makes diference...

    How to use VBO with opengl 1.1? (MFC default)

    This is my aproximetely "structure".

    Code :
    struct POINT
    {
    double x;
    double y;
    double z;
    }
    vector <POINT> test;
     
    //include a lot of vertex
     
    glVertexPointer(3, GL_DOUBLE, 0, test.data());
    glDrawArrays(GL_LINE_STRIP,0,test.size());

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    How to use VBO with opengl 1.1? (MFC default)

    MFC has nothing to do with OpenGL. How are you initializing OpenGL? You can use any version of OpenGL your driver supports inside MFC.

  7. #7
    Member Regular Contributor
    Join Date
    Aug 2008
    Posts
    450
    You will need to load the OpenGL functions used for buffer objects either yourself or using a loading library (recommended). There are quite a few tutorials out there for using buffer objects especially vertex buffer objects (VBOs).

    A good tutorial on modern OpenGL usage is here, with the page introducing buffer objects here. Another tutorial can be found here, with the page about buffer objects here.

    If you're not ready for modern OpenGL (as shaders/VAOs/generic attributes/ etc. all need to be understood before you can start drawing triangles), here's a couple of older tutorials from Google: http://www.songho.ca/opengl/gl_vbo.html http://www.ozone3d.net/tutorials/opengl_vbo.php

    A simple adaptation of your code to use VBOs would look something like this (untested):
    Code :
    struct POINT
    {
    GLfloat x;
    GLfloat y;
    GLfloat z;
    }
    vector <POINT> test;
    ...
    // create a single VBO + load data to it
    GLuint vbo1;
    glGenBuffers(1, &vbo1);
    glBindBuffer(GL_ARRAY_BUFFER, vbo1);
    glBufferData(GL_ARRAY_BUFFER, test.size() * sizeof(POINT), data(), GL_STATIC_DRAW);
     
    // the combination of the buffer object currently bound to GL_ARRAY_BUFFER & glVertexPointer tells OpenGL
    // that the vertex data should be retrieved from offset 0 in vbo1, rather than from a client-side vertex array.
    glBindBuffer(GL_ARRAY_BUFFER, vbo1);
    glVertexPointer(3, GL_FLOAT, sizeof(POINT), BUFFER_OFFSET(0));
    //glColorPointer(...);
    //glNormalPointer(...)
     
    glEnableClientState(GL_VERTEX_ARRAY);
    glDrawArrays(GL_LINE_STRIP, 0, test.size());
     
    // unbind/disable
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glDisableClientState(GL_VERTEX_ARRAY);

Tags for this Thread

Posting Permissions

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