Changes in / [ae0c7f4:39ac76d] in opengl-game
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
new-game.cpp
rae0c7f4 r39ac76d 587 587 model_mat_idx_vbo); 588 588 589 /* TODO: Fix the UBO binding code based on the following forum post (in order to support multiple ubos):590 591 No, you're misunderstanding how this works. UBO binding works exactly like texture object binding.592 593 The OpenGL context has a number of slots for binding UBOs. There are GL_MAX_UNIFORM_BUFFER_BINDINGS number of594 slots for UBO binding.595 596 Uniform Blocks in a program can be set to use one of the slots in the context. You do this by first querying597 the block index using the block name (glGetUniformBlockIndex). This is similar to how you need to use598 glGetUniformLocation in order to set a uniform's value with glUniform. Block indices, like uniform locations,599 are specific to a program.600 601 Once you have the block index, you use glUniformBlockBinding to set that specific program to use a particular602 uniform buffer slot in the context.603 604 Let's say you have a global UBO that you want to use for every program. To make using it easier, you want to605 bind it just once.606 607 So first, you pick a uniform buffer slot in the context, one that always will refer to this UBO. Let's say608 you pick slot 8.609 610 When you build a program object that may use this global uniform buffer, what you do is quite simple. First,611 after linking the program, call glGetUniformBlockIndex(program, "NameOfGlobalUniformBlock"). If you get back612 GL_INVALID_INDEX, then you know that the global uniform block isn't used in that program. Otherwise you get613 back a block index.614 615 If you got a valid block index, then you call glUniformBlockBinding(program, uniformBlockIndex, 8). Remember616 that 8 is the uniform buffer context slot that we selected earlier. This causes this particular program to617 use uniform buffer slot #8 to find the buffer for "NameOfGlobalUniformBlock".618 619 Finally, to set the actual buffer in the context, call glBindBufferRange(GL_UNIFORM_BUFFER, 8,620 bufferObjectName, offset, size);621 */622 623 589 GLuint ub_binding_point = 0; 624 590 … … 837 803 removeObjectFromScene(*objects[i], ubo); 838 804 } 805 // MARKER: Continue code review from here 839 806 if (((Asteroid*)objects[i])->hp <= 0) { 840 807 // TODO: Optimize this so I don't recalculate the camera rotation every time
Note:
See TracChangeset
for help on using the changeset viewer.