Changeset a9d191a in opengl-game for new-game.cpp
- Timestamp:
- Apr 12, 2019, 3:22:33 PM (6 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 14e6918
- Parents:
- c4c205e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
new-game.cpp
rc4c205e ra9d191a 261 261 void renderSceneGui(map<string, vector<UIValue>> valueLists); 262 262 263 void initGuiValueLists(map<string, vector<UIValue>> valueLists); 263 264 void renderGuiValueList(vector<UIValue>& values); 264 265 … … 308 309 SceneObject* objExplosion; 309 310 SceneObject* objFirst; 311 312 map<string, vector<UIValue>> valueLists; 310 313 311 314 /* … … 589 592 initModelGroupAttribs(modelGroups[TYPE_LASER]); 590 593 591 glBindBuffer(GL_ARRAY_BUFFER, points_vbo);592 glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);593 modelGroups[TYPE_LASER].attribs["vertex_position"].buffer = points_vbo;594 595 glBindBuffer(GL_ARRAY_BUFFER, texcoords_vbo);596 glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, NULL);597 modelGroups[TYPE_LASER].attribs["vt"].buffer = texcoords_vbo;598 599 glBindBuffer(GL_ARRAY_BUFFER, model_mat_idx_vbo);600 glVertexAttribIPointer(2, 1, GL_UNSIGNED_INT, 0, NULL);601 modelGroups[TYPE_LASER].attribs["ubo_index"].buffer = model_mat_idx_vbo;602 603 594 modelGroups[TYPE_EXPLOSION] = createModelGroup( 604 595 loadShaderProgram("./explosion.vert", "./explosion.frag")); … … 606 597 607 598 // The last parameter (offset) is only used for populating the buffers since the distance 608 // between each item is needed there. However, th at code isn't run for explosions right now anyway,609 // so I may as well pass in 0 here.599 // between each item is needed there. However, the explosion vbos are populated using different 600 // code anyway and don't use that argument, so I may as well pass in 0 here. 610 601 defineModelGroupAttrib(modelGroups[TYPE_EXPLOSION], "v_i", ATTRIB_POINT_VARYING, 611 602 3, GL_FLOAT, 0); … … 783 774 State curState = STATE_MAIN_MENU; 784 775 785 map<string, vector<UIValue>> valueLists; 786 787 valueLists["stats value list"] = vector<UIValue>(); 776 initGuiValueLists(valueLists); 777 788 778 valueLists["stats value list"].push_back(UIValue(UIVALUE_INT, "Score", &score)); 789 779 valueLists["stats value list"].push_back(UIValue(UIVALUE_DOUBLE, "FPS", &fps)); 790 791 valueLists["debug value list"] = vector<UIValue>();792 793 //valueLists["debug value list"].push_back(UIValue(UIVALUE_INT, "Buffer offset", &bufferOffset));794 780 795 781 while (!glfwWindowShouldClose(window) && isRunning) { … … 2291 2277 smg->vboCapacity = shaderCounts[smg->shaderProgram] * 2; 2292 2278 2279 AttribInfo* attrib; 2280 2293 2281 if (modelGroupIt->first == TYPE_SHIP) { 2294 int numPoints = shaderCounts[smg->shaderProgram];2295 AttribInfo* attrib;2296 2297 2282 attrib = &smg->attribs["vertex_position"]; 2298 2283 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2299 glBufferData(GL_ARRAY_BUFFER, numPoints* GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW);2284 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2300 2285 2301 2286 attrib = &smg->attribs["vertex_color"]; 2302 2287 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2303 glBufferData(GL_ARRAY_BUFFER, numPoints* GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW);2288 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2304 2289 2305 2290 attrib = &smg->attribs["vertex_normal"]; 2306 2291 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2307 glBufferData(GL_ARRAY_BUFFER, numPoints* GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW);2292 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2308 2293 2309 2294 attrib = &smg->attribs["ubo_index"]; 2310 2295 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2311 glBufferData(GL_ARRAY_BUFFER, numPoints * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2296 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2297 } else if (modelGroupIt->first == TYPE_LASER) { 2298 attrib = &smg->attribs["vertex_position"]; 2299 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2300 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2301 2302 attrib = &smg->attribs["vt"]; 2303 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2304 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2305 2306 attrib = &smg->attribs["ubo_index"]; 2307 glBindBuffer(GL_ARRAY_BUFFER, attrib->buffer); 2308 glBufferData(GL_ARRAY_BUFFER, smg->vboCapacity * GLsizeof(attrib->type) * attrib->size, NULL, GL_DYNAMIC_DRAW); 2312 2309 } 2313 2310 } … … 2344 2341 BufferInfo* bufferInfo = &shaderBufferInfo[modelGroups[obj.type].shaderProgram]; 2345 2342 2346 if (obj.type == TYPE_SHIP ) {2343 if (obj.type == TYPE_SHIP || obj.type == TYPE_LASER) { 2347 2344 obj.vertex_vbo_offset = modelGroups[obj.type].numPoints; 2348 2345 } else { … … 2574 2571 glBindVertexArray(modelGroups[TYPE_LASER].vao); 2575 2572 2576 glDrawArrays(GL_TRIANGLES, shaderBufferInfo[modelGroups[TYPE_LASER].shaderProgram].vbo_base, modelGroups[TYPE_LASER].numPoints);2573 glDrawArrays(GL_TRIANGLES, 0, modelGroups[TYPE_LASER].numPoints); 2577 2574 2578 2575 glUseProgram(modelGroups[TYPE_EXPLOSION].shaderProgram); … … 2699 2696 } 2700 2697 2698 void initGuiValueLists(map<string, vector<UIValue>> valueLists) { 2699 valueLists["stats value list"] = vector<UIValue>(); 2700 valueLists["debug value list"] = vector<UIValue>(); 2701 } 2702 2701 2703 void renderGuiValueList(vector<UIValue>& values) { 2702 2704 float maxWidth = 0.0f;
Note:
See TracChangeset
for help on using the changeset viewer.