Changeset e165b85 in opengl-game
- Timestamp:
- May 18, 2018, 11:04:10 PM (7 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 14ff67c
- Parents:
- cffca4d
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
color.vert
rcffca4d re165b85 2 2 3 3 uniform mat4 model, view, proj; 4 5 layout (std140) uniform shader_data { 6 mat4 model_mat; 7 }; 4 8 5 9 layout(location = 0) in vec3 vertex_position; -
new-game.cpp
rcffca4d re165b85 395 395 GLsizeiptr points_buffer_size = 0; 396 396 GLsizeiptr textures_buffer_size = 0; 397 GLsizeiptr ubo_buffer_size = 0; 397 398 398 399 for (obj_it = objects.begin(); obj_it != objects.end(); obj_it++) { 399 400 points_buffer_size += obj_it->points.size() * sizeof(GLfloat); 400 401 textures_buffer_size += obj_it->texcoords.size() * sizeof(GLfloat); 402 ubo_buffer_size += 16 * sizeof(GLfloat); 401 403 } 402 404 … … 455 457 offset += obj_it->normals.size() * sizeof(GLfloat); 456 458 } 459 460 /* 461 GLuint ubo = 0; 462 glGenBuffers(1, &ubo); 463 464 //glBindBuffer(GL_UNIFORM_BUFFER, ubo); 465 //glBufferData(GL_UNIFORM_BUFFER, ubo_buffer_size/2, NULL, GL_DYNAMIC_DRAW); 466 467 offset = 0; 468 for (obj_it = objects.begin(); obj_it != objects.end(); obj_it++) { 469 //glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(obj_it->model_mat), value_ptr(obj_it->model_mat)); 470 //glBufferSubData(GL_UNIFORM_BUFFER, offset, sizeof(obj_it->model_mat), value_ptr(objects[0].model_mat)); 471 offset += 16 * sizeof(GLfloat); 472 } 473 //glBindBuffer(GL_UNIFORM_BUFFER, 0); 474 */ 457 475 458 476 GLuint vao = 0; … … 523 541 GLuint view_test_loc = glGetUniformLocation(color_sp, "view"); 524 542 GLuint proj_test_loc = glGetUniformLocation(color_sp, "proj"); 543 GLuint ub_index = glGetUniformBlockIndex(color_sp, "shader_data"); 544 cout << "UBO index: " << ub_index << endl; 525 545 526 546 GLuint model_mat_loc = glGetUniformLocation(texture_sp, "model"); … … 529 549 530 550 glUseProgram(color_sp); 531 glUniformMatrix4fv(model_test_loc, 1, GL_FALSE, value_ptr(objects[0].model_mat));532 551 glUniformMatrix4fv(view_test_loc, 1, GL_FALSE, value_ptr(view_mat)); 533 552 glUniformMatrix4fv(proj_test_loc, 1, GL_FALSE, value_ptr(proj_mat)); 534 553 554 //glUniformBlockBinding(color_sp, ub_index, 0); 555 535 556 glUseProgram(texture_sp); 536 glUniformMatrix4fv(model_mat_loc, 1, GL_FALSE, value_ptr(objects[1].model_mat));537 557 glUniformMatrix4fv(view_mat_loc, 1, GL_FALSE, value_ptr(view_mat)); 538 558 glUniformMatrix4fv(proj_mat_loc, 1, GL_FALSE, value_ptr(proj_mat));
Note:
See TracChangeset
for help on using the changeset viewer.