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?
    Screenshot 2013-12-10 13.41.20.jpg

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

Similar Threads

  1. Replies: 0
    Last Post: 12-08-2012, 02:29 PM
  2. VBO - non interleaved {vertex, color, texCoord, n}
    By imported_Budric in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 12-09-2011, 08:41 AM
  3. glColorPointer drawing only in black color
    By igrekun in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 08-28-2011, 01:44 PM
  4. glColorPointer with monochrome color data.
    By JCipriani2 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-03-2008, 02:45 PM
  5. glColorPointer and color format
    By imported_Asgard in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-08-2002, 03:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean