Results 1 to 3 of 3

Thread: problem with glwidget and VBO.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default problem with glwidget and VBO.

    Hi, I have a strange problem with glwidget and Vertex Buffer Object. Here is my simple code:

    obj struct (a part of):

    Qt Code:
    1. float *vertexy;
    2. GLuint vertex_buf;
    3. float *normalne;
    4. GLuint norm_buf;
    5. float *textury;
    6. GLuint tex_buf;
    To copy to clipboard, switch view to plain text mode 

    t_obj.rozmiar is a size of 3d object (no. of polys)

    Loading VBO :

    Qt Code:
    1. glEnableClientState(GL_VERTEX_ARRAY);
    2. glGenBuffersARB(1, &t_obj.vertex_buf);
    3. glBindBufferARB(GL_ARRAY_BUFFER_ARB, t_obj.vertex_buf);
    4. glBufferDataARB(GL_ARRAY_BUFFER_ARB, (t_obj.rozmiar*3*3)*sizeof(float),t_obj.vertexy, GL_STATIC_DRAW_ARB);
    5.  
    6. glEnableClientState(GL_NORMAL_ARRAY);
    7. glGenBuffersARB(1, &t_obj.norm_buf);
    8. glBindBufferARB(GL_ARRAY_BUFFER, t_obj.norm_buf);
    9. glBufferDataARB(GL_ARRAY_BUFFER_ARB, (t_obj.rozmiar*3*3)*sizeof(float),t_obj.normalne, GL_STATIC_DRAW_ARB);
    10.  
    11. glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    12. glGenBuffersARB(1, &t_obj.tex_buf);
    13. glBindBufferARB(GL_ARRAY_BUFFER, t_obj.tex_buf);
    14. glBufferDataARB(GL_ARRAY_BUFFER, (t_obj.rozmiar*3*3)*sizeof(float), t_obj.textury, GL_STATIC_DRAW_ARB);
    To copy to clipboard, switch view to plain text mode 

    and drawing :

    Qt Code:
    1. glEnableClientState(GL_VERTEX_ARRAY);
    2.  
    3. glBindBufferARB( GL_ARRAY_BUFFER_ARB, obj.vertex_buf );
    4. glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );
    5.  
    6. glEnableClientState(GL_NORMAL_ARRAY);
    7. glBindBufferARB(GL_ARRAY_BUFFER, obj.norm_buf);
    8. glNormalPointer(GL_FLOAT,0, (char *) NULL );
    9.  
    10. glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    11. glBindBufferARB(GL_ARRAY_BUFFER, obj.tex_buf);
    12. glTexCoordPointer(3, GL_FLOAT, 0, (char *) NULL );
    13.  
    14. glDrawArrays(GL_TRIANGLES, 0, obj.rozmiar*3);
    15.  
    16. glDisableClientState( GL_VERTEX_ARRAY );
    To copy to clipboard, switch view to plain text mode 

    This code works perfect in "normal" opengl application (without QT). With QT and glwidget i have a clear screen. What am I Doing Wrong?

    Rufjan

  2. #2
    Join Date
    Dec 2009
    Posts
    1

    Default Re: problem with glwidget and VBO.

    Hi,

    I have the same problem with a segmentation fault on the glDrawArrays(). How can test if my BufferDataARB is empty please ?

    Thank's for your attention and sorry for my english.
    Bye

  3. #3
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: problem with glwidget and VBO.

    DO NOT use BufferDataARB() functions. These function are obsoleted.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.