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


Ignore:
Timestamp:
Mar 22, 2019, 5:15:59 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
b05e2b5
Parents:
b220f78
Message:

Move the generation of the explosion shader vbos to where all the other "global" vbos are generated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • new-game.cpp

    rb220f78 rde53394  
    200200                  GLuint* texcoords_vbo,
    201201                  GLuint* normals_vbo,
     202                  GLuint* time_vbo,
     203                  GLuint* velocity_vbo,
    202204                  GLuint* ubo,
    203205                  GLuint* model_mat_idx_vbo);
     
    210212                  GLuint texcoords_vbo,
    211213                  GLuint normals_vbo,
     214                  GLuint time_vbo,
     215                  GLuint velocity_vbo,
    212216                  GLuint ubo,
    213217                  GLuint model_mat_idx_vbo);
     
    482486   GLfloat curTime, prevTime, elapsedTime;
    483487
    484    GLuint points_vbo, colors_vbo, texcoords_vbo, normals_vbo, ubo, model_mat_idx_vbo;
     488   GLuint
     489    points_vbo,
     490    colors_vbo,
     491    texcoords_vbo,
     492    normals_vbo,
     493    time_vbo,
     494    velocity_vbo,
     495    ubo,
     496    model_mat_idx_vbo;
    485497
    486498   initializeBuffers(
     
    489501      &texcoords_vbo,
    490502      &normals_vbo,
     503      &time_vbo,
     504      &velocity_vbo,
    491505      &ubo,
    492506      &model_mat_idx_vbo);
     
    625639  initModelGroupAttribs(modelGroups[TYPE_EXPLOSION]);
    626640
     641   glBindBuffer(GL_ARRAY_BUFFER, velocity_vbo);
     642   glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
     643
     644   glBindBuffer(GL_ARRAY_BUFFER, time_vbo);
     645   glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 0, NULL);
     646
    627647   cam_pos = vec3(0.0f, 0.0f, 2.0f);
    628648   float cam_yaw = 0.0f * 2.0f * 3.14159f / 360.0f;
     
    683703      texcoords_vbo,
    684704      normals_vbo,
     705      time_vbo,
     706      velocity_vbo,
    685707      ubo,
    686708      model_mat_idx_vbo);
     
    21152137                  GLuint* texcoords_vbo,
    21162138                  GLuint* normals_vbo,
     2139                  GLuint* time_vbo,
     2140                  GLuint* velocity_vbo,
    21172141                  GLuint* ubo,
    21182142                  GLuint* model_mat_idx_vbo) {
     
    21282152   *normals_vbo = 0;
    21292153   glGenBuffers(1, normals_vbo);
     2154
     2155   *velocity_vbo = 0;
     2156   glGenBuffers(1, velocity_vbo);
     2157
     2158   *time_vbo = 0;
     2159   glGenBuffers(1, time_vbo);
    21302160
    21312161   *ubo = 0;
     
    21432173                  GLuint texcoords_vbo,
    21442174                  GLuint normals_vbo,
     2175                  GLuint time_vbo,
     2176                  GLuint velocity_vbo,
    21452177                  GLuint ubo,
    21462178                  GLuint model_mat_idx_vbo) {
     
    21682200   bindUniformData(modelGroups[TYPE_EXPLOSION].attribs["model_mat"], value_ptr(model_mat));
    21692201
    2170    GLuint velocity_vbo;
    2171    glGenBuffers(1, &velocity_vbo);
    2172 
    2173    GLuint time_vbo;
    2174    glGenBuffers(1, &time_vbo);
    2175 
    2176    glBindVertexArray(modelGroups[TYPE_EXPLOSION].vao);
    2177 
    2178    // the glBufferData and glVertexAttribPointer need to stay here while the corresponding arrays
     2202   // the glBufferData calls need to stay here while the corresponding arrays
    21792203   // are local to this function. Once they're made part of the explosion object, I might be able
    21802204   // to move this code out of here
     
    21822206   glBindBuffer(GL_ARRAY_BUFFER, velocity_vbo);
    21832207   glBufferData(GL_ARRAY_BUFFER, sizeof(vv), vv, GL_STATIC_DRAW);
    2184    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
    21852208
    21862209   glBindBuffer(GL_ARRAY_BUFFER, time_vbo);
    21872210   glBufferData(GL_ARRAY_BUFFER, sizeof(vt), vt, GL_STATIC_DRAW);
    2188    glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 0, NULL);
    21892211
    21902212   objExplosion = createExplosion();
Note: See TracChangeset for help on using the changeset viewer.