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

Thread: glColorPointer() not painting vertex color in interleaved VBO

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2013
    Posts
    20

    glColorPointer() not painting vertex color in interleaved VBO

    I am using (Python and PyOpenGL) interleaved VBO (vertex, normal, color) in the form:
    Code :
    Vx1, Vy1, Vz1, Nx1, Ny1, Nz1, R1, G1, B1, A1, Vx2...
    VBO is generated with:
    Code :
    self.vbo_id = glGenBuffers (1)
    glBindBuffer(GL_ARRAY_BUFFER, self.vbo_id)
     
    #    upload data to VBO
    data = model_loader.Model_loader(filename = "geometry.STL")
     
    vertices = data.vertices
    normals = data.normals
     
    self.N_vertices = len(vertices)
     
    alpha = 1
    color = np.array([[0.1, 0.1, 0.1, alpha]], dtype='float32')
    colors = np.repeat(color, self.N_vertices, axis=0)
     
    VBO_data = VBO_reshape.create_VBO_array(data.vertices, data.normals, colors, GL_primitive_type = "triangle", interleaved_type = "true")
    VBO_size_bytes = arrays.ArrayDatatype.arrayByteCount(VBO_data)
     
    glBufferData(GL_ARRAY_BUFFER,
    			 VBO_size_bytes,
    			 VBO_data, #vertices
    			 GL_STATIC_DRAW)
     
    glBindBuffer(GL_ARRAY_BUFFER, self.vbo_id)
    Geometry from VBO is drawn with the code:
    Code :
    v_pointer = ctypes.c_void_p(0)
    n_pointer = ctypes.c_void_p(12)  
    c_pointer = ctypes.c_void_p(24)
     
    v_stride = 40
    n_stride = 40
    c_stride = 40
     
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, self.vbo_id)
     
    glEnableClientState(GL_VERTEX_ARRAY)
    glVertexPointer(3, 
    				GL_FLOAT, 
    				v_stride, 
    				v_pointer)
     
    glEnableClientState(GL_NORMAL_ARRAY)
    glNormalPointer(GL_FLOAT,
    				n_stride,
    				n_pointer)
     
    glEnableClientState(GL_COLOR_ARRAY)
    glColorPointer(4,
    			   GL_FLOAT,  
    			   c_stride,
    			   c_pointer)
     
    glDrawArrays(GL_TRIANGLES,
    			 0,
    			 self.N_vertices)
     
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) # reset
     
    glDisableClientState(GL_COLOR_ARRAY)
    glDisableClientState(GL_NORMAL_ARRAY)
    glDisableClientState(GL_VERTEX_ARRAY)
    Normals are taken from the VBO correctly as the surfaces have shadows as can be seen from figure below. But I have problems with painting the each vertex (of triangle) with it's own color although each vertex is assigned the different color. Any ideas where is the problem? Are function calls glDrawArrays and glColorPointer compatible?
    Click image for larger version. 

Name:	Screenshot 2013-12-10 13.41.20.jpg 
Views:	74 
Size:	5.8 KB 
ID:	1198

  2. #2
    Junior Member Newbie
    Join Date
    Nov 2013
    Posts
    20
    Problem solved
    I had to disable lighting and lights.

Posting Permissions

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