Changeset 7280257 in opengl-game
- Timestamp:
- Apr 25, 2018, 12:39:01 AM (7 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 05e43cf
- Parents:
- baa5848
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
color.vert
rbaa5848 r7280257 1 1 #version 410 2 3 layout (std140) uniform model_block {4 mat4 M;5 };6 2 7 3 uniform mat4 model, view, proj; -
new-game.cpp
rbaa5848 r7280257 307 307 vec3(points2[15], points2[16], points2[17]), 308 308 }; 309 310 int ubo_id = 0;311 GLuint ubo = 0;312 glGenBuffers(1, &ubo);313 glBindBuffer(GL_UNIFORM_BUFFER, ubo);314 glBufferData(GL_ARRAY_BUFFER, sizeof(float)*16*2, NULL, GL_STATIC_DRAW);315 316 glBindBufferBase(GL_UNIFORM_BUFFER, ubo_id, ubo);317 glBufferSubData(GL_UNIFORM_BUFFER, 0, sizeof(float) * 16, value_ptr(objects[0].model_mat));318 glBufferSubData(GL_UNIFORM_BUFFER, sizeof(float) * 16, sizeof(float) * 16, value_ptr(objects[1].model_mat));319 309 320 310 GLuint points_vbo = 0; … … 396 386 GLuint shader_program2 = loadShaderProgram("./texture.vert", "./texture.frag"); 397 387 398 GLuint ub_index = glGetUniformBlockIndex(shader_program, "model_block");399 glUniformBlockBinding(shader_program, ub_index, ubo_id);400 401 GLuint ub_index2 = glGetUniformBlockIndex(shader_program2, "model_block");402 glUniformBlockBinding(shader_program2, ub_index2, ubo_id);403 404 cout << "Uniform Buffer Debugging" << endl;405 cout << "ubo: " << ubo << endl;406 cout << "ub_index: " << ub_index << endl;407 cout << "ub_index2: " << ub_index2 << endl;408 409 388 float speed = 1.0f; 410 389 float last_position = 0.0f; … … 453 432 glUniformMatrix4fv(proj_test_loc, 1, GL_FALSE, value_ptr(proj_mat)); 454 433 455 glBindBufferRange(GL_UNIFORM_BUFFER, ub_index, ubo, 0, sizeof(float) * 16);456 457 434 glUseProgram(shader_program2); 458 435 glUniformMatrix4fv(model_mat_loc, 1, GL_FALSE, value_ptr(objects[1].model_mat)); 459 436 glUniformMatrix4fv(view_mat_loc, 1, GL_FALSE, value_ptr(view_mat)); 460 437 glUniformMatrix4fv(proj_mat_loc, 1, GL_FALSE, value_ptr(proj_mat)); 461 462 glBindBufferRange(GL_UNIFORM_BUFFER, ub_index2, ubo, sizeof(float) * 16, sizeof(float) * 16);463 438 464 439 objects[0].shader_program = shader_program; -
opengl-notes.txt
rbaa5848 r7280257 40 40 41 41 Camera position = (0, 0, 0) 42 43 44 BUFFER FUNCTIONS 45 ----------------- 46 47 glGenBuffers creates a buffer 48 glBindBuffer sets the currently active buffer 49 glBufferData populates the buffer with data 50 51 glGenVertexArrays creates a vao 52 glBindVertexArray sets the currently active vao 53 glEnableVertexAttribArray sets the active index in the vao 54 glVertexAttribPointer determines the layout of a buffer in a VAO 55 -The last params (often NULL), specifies the offset in the buffer -
texture.vert
rbaa5848 r7280257 1 1 #version 410 2 3 layout (std140) uniform model_block {4 mat4 M;5 };6 2 7 3 uniform mat4 model, view, proj;
Note:
See TracChangeset
for help on using the changeset viewer.