Changeset 14e6918 in opengl-game


Ignore:
Timestamp:
Apr 12, 2019, 3:43:15 PM (6 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
f97e638
Parents:
a9d191a
Message:

Switch to the new model group rendering algorithm for TYPE_ASTEROID objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • new-game.cpp

    ra9d191a r14e6918  
    556556   initModelGroupAttribs(modelGroups[TYPE_ASTEROID]);
    557557
    558    glBindBuffer(GL_ARRAY_BUFFER, points_vbo);
    559    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
    560    modelGroups[TYPE_ASTEROID].attribs["vertex_position"].buffer = points_vbo;
    561 
    562    glBindBuffer(GL_ARRAY_BUFFER, colors_vbo);
    563    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, NULL);
    564    modelGroups[TYPE_ASTEROID].attribs["vertex_color"].buffer = colors_vbo;
    565 
    566    glBindBuffer(GL_ARRAY_BUFFER, normals_vbo);
    567    glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, NULL);
    568    modelGroups[TYPE_ASTEROID].attribs["vertex_normal"].buffer = normals_vbo;
    569 
    570    glBindBuffer(GL_ARRAY_BUFFER, model_mat_idx_vbo);
    571    glVertexAttribIPointer(3, 1, GL_UNSIGNED_INT, 0, NULL);
    572    modelGroups[TYPE_ASTEROID].attribs["ubo_index"].buffer = model_mat_idx_vbo;
    573 
    574558   modelGroups[TYPE_LASER] = createModelGroup(
    575559      loadShaderProgram("./laser.vert", "./laser.frag"));
     
    22952279         glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer);
    22962280         glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW);
     2281      } else if (modelGroupIt->first == TYPE_ASTEROID) {
     2282         attrib = &smg->attribs["vertex_position"];
     2283         glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer);
     2284         glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW);
     2285
     2286         attrib = &smg->attribs["vertex_color"];
     2287         glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer);
     2288         glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW);
     2289
     2290         attrib = &smg->attribs["vertex_normal"];
     2291         glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer);
     2292         glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW);
     2293
     2294         attrib = &smg->attribs["ubo_index"];
     2295         glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer);
     2296         glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW);
    22972297      } else if (modelGroupIt->first == TYPE_LASER) {
    22982298         attrib = &smg->attribs["vertex_position"];
     
    23412341   BufferInfo* bufferInfo = &shaderBufferInfo[modelGroups[obj.type].shaderProgram];
    23422342
    2343    if (obj.type == TYPE_SHIP || obj.type == TYPE_LASER) {
     2343   if (obj.type == TYPE_SHIP || obj.type == TYPE_ASTEROID || obj.type == TYPE_LASER) {
    23442344      obj.vertex_vbo_offset = modelGroups[obj.type].numPoints;
    23452345   } else {
     
    25642564   glBindVertexArray(modelGroups[TYPE_ASTEROID].vao);
    25652565
    2566    glDrawArrays(GL_TRIANGLES, shaderBufferInfo[modelGroups[TYPE_ASTEROID].shaderProgram].vbo_base, modelGroups[TYPE_ASTEROID].numPoints);
     2566   glDrawArrays(GL_TRIANGLES, 0, modelGroups[TYPE_ASTEROID].numPoints);
    25672567
    25682568   glEnable(GL_BLEND);
Note: See TracChangeset for help on using the changeset viewer.