Changeset fe5e3ca in opengl-game
- Timestamp:
- Jan 11, 2019, 4:10:11 PM (6 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 646f3f2, c5fb958
- Parents:
- 8fbd34f
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
explosion.vert
r8fbd34f rfe5e3ca 1 1 #version 410 core 2 2 3 // TODO: Pass the explosion center in as a uniform 3 #define MAX_NUM_OBJECTS 1024 4 5 uniform mat4 view, proj; 6 uniform mat4 model_mat; 7 8 /* 9 layout (std140) uniform models { 10 mat4 model_mats[MAX_NUM_OBJECTS]; 11 }; 12 */ 4 13 5 14 uniform float explosion_start_time; … … 8 17 layout (location = 0) in vec3 v_i; // initial velocity 9 18 layout (location = 1) in float start_time; 19 //layout(location = 2) in uint ubo_index; 10 20 11 21 out float opacity; … … 33 43 p += normalize(v_i) * mod(t, duration) / duration * 0.3; // allow time to loop around so particle emitter keeps going 34 44 35 gl_Position = vec4(p, 1.0); 45 //gl_Position = proj * view * model_mats[0] * vec4(p, 1.0); 46 gl_Position = proj * view * model_mat * vec4(p, 1.0); 36 47 gl_PointSize = 15.0; // size in pixels 37 48 } -
new-game.cpp
r8fbd34f rfe5e3ca 157 157 GLuint* model_mat_idx_vbo); 158 158 159 GLuint initializeParticleEffectBuffers( );159 GLuint initializeParticleEffectBuffers(vec3 origin, mat4 proj, mat4 view, GLuint explosion_sp); 160 160 161 161 void populateBuffers(vector<SceneObject*>& objects, … … 565 565 glVertexAttribIPointer(2, 1, GL_UNSIGNED_INT, 0, 0); 566 566 567 GLuint explosion_vao = initializeParticleEffectBuffers();568 569 567 float cam_speed = 1.0f; 570 568 float cam_yaw_speed = 60.0f*ONE_DEG_IN_RAD; … … 598 596 }; 599 597 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); 600 600 601 601 GLuint ub_binding_point = 0; … … 1912 1912 } 1913 1913 1914 GLuint initializeParticleEffectBuffers() { 1914 GLuint initializeParticleEffectBuffers(vec3 origin, mat4 proj, mat4 view, GLuint explosion_sp) { 1915 //unsigned int num_explosions = 1; 1916 1915 1917 float vv[EXPLOSION_PARTICLE_COUNT * 3]; // initial velocities vec3 1916 1918 float vt[EXPLOSION_PARTICLE_COUNT]; // initial times … … 1927 1929 vv[i*3 + 2] = 0.0f; 1928 1930 } 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 */ 1929 1956 1930 1957 GLuint velocity_vbo;
Note:
See TracChangeset
for help on using the changeset viewer.