Hi, I have a strange problem with glwidget and Vertex Buffer Object. Here is my simple code:
obj struct (a part of):
float *vertexy;
GLuint vertex_buf;
float *normalne;
GLuint norm_buf;
float *textury;
GLuint tex_buf;
float *vertexy;
GLuint vertex_buf;
float *normalne;
GLuint norm_buf;
float *textury;
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 :
glEnableClientState(GL_VERTEX_ARRAY);
glGenBuffersARB(1, &t_obj.vertex_buf);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, t_obj.vertex_buf);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, (t_obj.rozmiar*3*3)*sizeof(float),t_obj.vertexy, GL_STATIC_DRAW_ARB);
glEnableClientState(GL_NORMAL_ARRAY);
glGenBuffersARB(1, &t_obj.norm_buf);
glBindBufferARB(GL_ARRAY_BUFFER, t_obj.norm_buf);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, (t_obj.rozmiar*3*3)*sizeof(float),t_obj.normalne, GL_STATIC_DRAW_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glGenBuffersARB(1, &t_obj.tex_buf);
glBindBufferARB(GL_ARRAY_BUFFER, t_obj.tex_buf);
glBufferDataARB(GL_ARRAY_BUFFER, (t_obj.rozmiar*3*3)*sizeof(float), t_obj.textury, GL_STATIC_DRAW_ARB);
glEnableClientState(GL_VERTEX_ARRAY);
glGenBuffersARB(1, &t_obj.vertex_buf);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, t_obj.vertex_buf);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, (t_obj.rozmiar*3*3)*sizeof(float),t_obj.vertexy, GL_STATIC_DRAW_ARB);
glEnableClientState(GL_NORMAL_ARRAY);
glGenBuffersARB(1, &t_obj.norm_buf);
glBindBufferARB(GL_ARRAY_BUFFER, t_obj.norm_buf);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, (t_obj.rozmiar*3*3)*sizeof(float),t_obj.normalne, GL_STATIC_DRAW_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glGenBuffersARB(1, &t_obj.tex_buf);
glBindBufferARB(GL_ARRAY_BUFFER, t_obj.tex_buf);
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 :
glEnableClientState(GL_VERTEX_ARRAY);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, obj.vertex_buf );
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );
glEnableClientState(GL_NORMAL_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER, obj.norm_buf);
glNormalPointer(GL_FLOAT,0, (char *) NULL );
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER, obj.tex_buf);
glTexCoordPointer(3, GL_FLOAT, 0, (char *) NULL );
glDrawArrays(GL_TRIANGLES, 0, obj.rozmiar*3);
glDisableClientState( GL_VERTEX_ARRAY );
glEnableClientState(GL_VERTEX_ARRAY);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, obj.vertex_buf );
glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );
glEnableClientState(GL_NORMAL_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER, obj.norm_buf);
glNormalPointer(GL_FLOAT,0, (char *) NULL );
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER, obj.tex_buf);
glTexCoordPointer(3, GL_FLOAT, 0, (char *) NULL );
glDrawArrays(GL_TRIANGLES, 0, obj.rozmiar*3);
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
Bookmarks