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


Ignore:
Timestamp:
Jan 11, 2019, 4:10:11 PM (6 years ago)
Author:
dportnoy15 <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
646f3f2, c5fb958
Parents:
8fbd34f
Message:

Apply the model, view, and projection matrices to explosions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • new-game.cpp

    r8fbd34f rfe5e3ca  
    157157                  GLuint* model_mat_idx_vbo);
    158158
    159 GLuint initializeParticleEffectBuffers();
     159GLuint initializeParticleEffectBuffers(vec3 origin, mat4 proj, mat4 view, GLuint explosion_sp);
    160160
    161161void populateBuffers(vector<SceneObject*>& objects,
     
    565565   glVertexAttribIPointer(2, 1, GL_UNSIGNED_INT, 0, 0);
    566566
    567    GLuint explosion_vao = initializeParticleEffectBuffers();
    568 
    569567   float cam_speed = 1.0f;
    570568   float cam_yaw_speed = 60.0f*ONE_DEG_IN_RAD;
     
    598596   };
    599597   proj_mat = make_mat4(proj_arr);
     598
     599   GLuint explosion_vao = initializeParticleEffectBuffers(vec3(0.0f, -1.2f, 0.65f), proj_mat, view_mat, explosion_sp);
    600600
    601601   GLuint ub_binding_point = 0;
     
    19121912}
    19131913
    1914 GLuint initializeParticleEffectBuffers() {
     1914GLuint initializeParticleEffectBuffers(vec3 origin, mat4 proj, mat4 view, GLuint explosion_sp) {
     1915   //unsigned int num_explosions = 1;
     1916
    19151917   float vv[EXPLOSION_PARTICLE_COUNT * 3]; // initial velocities vec3
    19161918   float vt[EXPLOSION_PARTICLE_COUNT]; // initial times
     
    19271929      vv[i*3 + 2] = 0.0f;
    19281930   }
     1931
     1932   mat4 model_mat = translate(mat4(1.0f), origin);
     1933
     1934   glUseProgram(explosion_sp);
     1935
     1936   GLuint proj_mat_loc = glGetUniformLocation(explosion_sp, "proj");
     1937   GLuint view_mat_loc = glGetUniformLocation(explosion_sp, "view");
     1938
     1939   glUniformMatrix4fv(proj_mat_loc, 1, GL_FALSE, value_ptr(proj));
     1940   glUniformMatrix4fv(view_mat_loc, 1, GL_FALSE, value_ptr(view));
     1941
     1942   GLuint model_mat_loc = glGetUniformLocation(explosion_sp, "model_mat");
     1943
     1944   glUniformMatrix4fv(model_mat_loc, 1, GL_FALSE, value_ptr(model_mat));
     1945
     1946   /*
     1947   GLuint model_ubo = 0;
     1948   glGenBuffers(1, &model_ubo);
     1949
     1950   glBindBuffer(GL_UNIFORM_BUFFER, model_ubo);
     1951   glBufferData(GL_UNIFORM_BUFFER, num_explosions * sizeof(mat4), NULL, GL_DYNAMIC_DRAW);
     1952
     1953   //glBindBuffer(GL_UNIFORM_BUFFER, ubo);
     1954   glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(mat4), value_ptr(model_mat));
     1955   */
    19291956
    19301957   GLuint velocity_vbo;
Note: See TracChangeset for help on using the changeset viewer.