Changeset 8819:d96627c142a7 in orange


Ignore:
Timestamp:
08/29/11 00:27:11 (3 years ago)
Author:
matejd <matejd@…>
Branch:
default
Convert:
79ac8130dec2858383cd48945540aa191f4109da
Message:

Added draw_data_solid as performance optimization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orangeqt/plot3d.cpp

    r8814 r8819  
    244244void Plot3D::draw_data_solid() 
    245245{ 
    246     // TODO 
    247 } 
    248  
    249 void Plot3D::draw_data(GLuint shader_id, float alpha_value) 
    250 { 
    251246    if (!vbos_generated) 
    252247        return; 
    253248 
    254     // Draw opaque selected examples first. 
    255249    glBindBuffer(GL_ARRAY_BUFFER, vbo_selected_id); 
    256250    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(0)); 
     
    273267    glDisableVertexAttribArray(4); 
    274268 
    275     // Draw transparent unselected examples (triangles and then edges). 
    276     glUniform2f(glGetUniformLocation(shader_id, "alpha_value"), alpha_value-0.6, alpha_value-0.6); 
    277  
    278269    glBindBuffer(GL_ARRAY_BUFFER, vbo_unselected_id); 
    279270    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(0)); 
     
    296287    glDisableVertexAttribArray(4); 
    297288 
     289    glBindBuffer(GL_ARRAY_BUFFER, 0); 
     290} 
     291 
     292void Plot3D::draw_data(GLuint shader_id, float alpha_value) 
     293{ 
     294    if (!vbos_generated) 
     295        return; 
     296 
     297    // Draw opaque selected examples first. 
     298    glEnable(GL_DEPTH_TEST); 
     299    glDepthMask(GL_TRUE); 
     300    glBindBuffer(GL_ARRAY_BUFFER, vbo_selected_id); 
     301    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(0)); 
     302    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(3*4)); 
     303    glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(6*4)); 
     304    glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(9*4)); 
     305    glVertexAttribPointer(4, 1, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(12*4)); 
     306    glEnableVertexAttribArray(0); 
     307    glEnableVertexAttribArray(1); 
     308    glEnableVertexAttribArray(2); 
     309    glEnableVertexAttribArray(3); 
     310    glEnableVertexAttribArray(4); 
     311 
     312    glDrawArrays(GL_TRIANGLES, 0, num_selected_vertices); 
     313 
     314    glDisableVertexAttribArray(0); 
     315    glDisableVertexAttribArray(1); 
     316    glDisableVertexAttribArray(2); 
     317    glDisableVertexAttribArray(3); 
     318    glDisableVertexAttribArray(4); 
     319 
     320    // Draw transparent unselected examples (triangles and then edges). 
     321    glUniform2f(glGetUniformLocation(shader_id, "alpha_value"), alpha_value-0.6, alpha_value-0.6); 
     322 
     323    glDepthMask(GL_FALSE); 
     324    glBindBuffer(GL_ARRAY_BUFFER, vbo_unselected_id); 
     325    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(0)); 
     326    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(3*4)); 
     327    glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(6*4)); 
     328    glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(9*4)); 
     329    glVertexAttribPointer(4, 1, GL_FLOAT, GL_FALSE, 13*4, BUFFER_OFFSET(12*4)); 
     330    glEnableVertexAttribArray(0); 
     331    glEnableVertexAttribArray(1); 
     332    glEnableVertexAttribArray(2); 
     333    glEnableVertexAttribArray(3); 
     334    glEnableVertexAttribArray(4); 
     335 
     336    glDrawArrays(GL_TRIANGLES, 0, num_unselected_vertices); 
     337 
     338    glDisableVertexAttribArray(0); 
     339    glDisableVertexAttribArray(1); 
     340    glDisableVertexAttribArray(2); 
     341    glDisableVertexAttribArray(3); 
     342    glDisableVertexAttribArray(4); 
     343 
    298344    // Edges 
     345    glDepthMask(GL_TRUE); 
    299346    glUniform2f(glGetUniformLocation(shader_id, "alpha_value"), alpha_value, alpha_value); 
    300347 
Note: See TracChangeset for help on using the changeset viewer.