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


Ignore:
Timestamp:
Jan 31, 2019, 5:34:43 AM (6 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
7a55b49
Parents:
39ac76d (diff), bebfd5c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'WIP' of medievaltech.com:opengl-game into WIP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • new-game.cpp

    r39ac76d rae0c7f4  
    587587      model_mat_idx_vbo);
    588588
     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 of
     594      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 querying
     597      the block index using the block name (glGetUniformBlockIndex). This is similar to how you need to use
     598      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 particular
     602      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 to
     605      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 say
     608      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 back
     612      GL_INVALID_INDEX, then you know that the global uniform block isn't used in that program. Otherwise you get
     613      back a block index.
     614
     615      If you got a valid block index, then you call glUniformBlockBinding(program, uniformBlockIndex, 8). Remember
     616      that 8 is the uniform buffer context slot that we selected earlier. This causes this particular program to
     617      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
    589623   GLuint ub_binding_point = 0;
    590624
     
    803837                  removeObjectFromScene(*objects[i], ubo);
    804838               }
    805                // MARKER: Continue code review from here
    806839               if (((Asteroid*)objects[i])->hp <= 0) {
    807840                  // TODO: Optimize this so I don't recalculate the camera rotation every time
Note: See TracChangeset for help on using the changeset viewer.