Changeset c55614a in opengl-game for new-game.cpp
- Timestamp:
- May 8, 2019, 1:21:45 AM (6 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- e6bc0f4
- Parents:
- 7e10667
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
new-game.cpp
r7e10667 rc55614a 609 609 (Also, I bookmarked a great explanation of this under ) 610 610 611 CHECK MY OpenGL BOOKMARK CALLED "Learn OpenGL: Advanced GLSL" 612 611 613 No, you're misunderstanding how this works. UBO binding works exactly like texture object binding. 612 614 … … 2099 2101 smg->vboCapacity = shaderCounts[smg->shaderProgram] * 2; 2100 2102 2101 AttribInfo* attrib; 2102 2103 if (modelGroupIt->first == TYPE_SHIP) { 2104 attrib = &smg->attribs["vertex_position"]; 2105 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2106 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2107 2108 attrib = &smg->attribs["vertex_color"]; 2109 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2110 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2111 2112 attrib = &smg->attribs["vertex_normal"]; 2113 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2114 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2115 2116 attrib = &smg->attribs["ubo_index"]; 2117 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2118 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2119 } else if (modelGroupIt->first == TYPE_ASTEROID) { 2120 attrib = &smg->attribs["vertex_position"]; 2121 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2122 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2123 2124 attrib = &smg->attribs["vertex_color"]; 2125 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2126 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2127 2128 attrib = &smg->attribs["vertex_normal"]; 2129 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2130 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2131 2132 attrib = &smg->attribs["ubo_index"]; 2133 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2134 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2135 } else if (modelGroupIt->first == TYPE_LASER) { 2136 attrib = &smg->attribs["vertex_position"]; 2137 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2138 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2139 2140 attrib = &smg->attribs["vt"]; 2141 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2142 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2143 2144 attrib = &smg->attribs["ubo_index"]; 2145 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2146 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2147 } else if (modelGroupIt->first == TYPE_EXPLOSION) { 2148 attrib = &smg->attribs["v_i"]; 2149 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2150 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2151 2152 attrib = &smg->attribs["start_time"]; 2153 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2154 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2155 2156 attrib = &smg->attribs["ubo_index"]; 2157 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2158 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2103 map<string, AttribInfo>::iterator attrIt; 2104 for (attrIt = smg->attribs.begin(); attrIt != smg->attribs.end(); attrIt++) { 2105 if (attrIt->second.attribType != ATTRIB_UNIFORM) { 2106 glBindBuffer(GL_ARRAY_BUFFER, attrIt->second.buffer); 2107 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrIt->second.type) * attrIt->second.size, NULL, GL_DYNAMIC_DRAW); 2108 } 2159 2109 } 2160 2110 }
Note:
See TracChangeset
for help on using the changeset viewer.