Changeset e3ca955 in opengl-game for new-game.cpp


Ignore:
Timestamp:
May 26, 2018, 8:19:03 PM (6 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
0d5c100
Parents:
f9a242b
Message:

Change the rendering algorithm to draw the selected objects, then draw all objects, including redrawing selected objects. This lets me draw all objects that use a certain shader at once, without worrying about which ones are selected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • new-game.cpp

    rf9a242b re3ca955  
    955955                  SceneObject* selectedObject) {
    956956
    957    vector<int> colored_objs, selected_objs, textured_objs, static_colored_objs, static_textured_objs;
     957   vector<int> colored_objs, selected_objs, textured_objs;
    958958
    959959   // group scene objects by shader and vbo
     
    961961      if (selectedObject == &objects[i]) {
    962962         selected_objs.push_back(i);
    963       } else if (objects[i].shader_program == color_sp) {
     963      }
     964      if (objects[i].shader_program == color_sp) {
    964965         colored_objs.push_back(i);
    965966      } else if (objects[i].shader_program == texture_sp) {
     
    973974   glBindVertexArray(vao1);
    974975
     976   glBindBuffer(GL_ARRAY_BUFFER, selected_colors_vbo);
     977   glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
     978
     979   for (it = selected_objs.begin(); it != selected_objs.end(); it++) {
     980      glDrawArrays(GL_TRIANGLES, objects[*it].vertex_vbo_offset, objects[*it].num_points);
     981   }
     982
    975983   glBindBuffer(GL_ARRAY_BUFFER, colors_vbo);
    976984   glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
    977985
    978986   for (it = colored_objs.begin(); it != colored_objs.end(); it++) {
    979       glDrawArrays(GL_TRIANGLES, objects[*it].vertex_vbo_offset, objects[*it].num_points);
    980    }
    981 
    982    glBindBuffer(GL_ARRAY_BUFFER, selected_colors_vbo);
    983    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0);
    984 
    985    for (it = selected_objs.begin(); it != selected_objs.end(); it++) {
    986987      glDrawArrays(GL_TRIANGLES, objects[*it].vertex_vbo_offset, objects[*it].num_points);
    987988   }
Note: See TracChangeset for help on using the changeset viewer.