Changeset dd9771c in opengl-game for new-game.cpp
- Timestamp:
- Feb 11, 2019, 4:20:35 AM (6 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- a0eb547
- Parents:
- b62c109
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
new-game.cpp
rb62c109 rdd9771c 66 66 mat4 model_mat, model_base, model_transform; 67 67 mat4 translate_mat; // beginning of doing what's mentioned above 68 GLuint shader_program;69 68 unsigned int num_points; 70 69 GLuint vertex_vbo_offset; … … 202 201 203 202 // TODO: instead of using these methods, create constructors for these 204 SceneObject* createShip( GLuint shader);205 Asteroid* createAsteroid(vec3 pos , GLuint shader);206 Laser* createLaser(vec3 start, vec3 end, vec3 color, GLfloat width , GLuint laser_sp);207 SceneObject* createExplosion( GLuint shader);203 SceneObject* createShip(); 204 Asteroid* createAsteroid(vec3 pos); 205 Laser* createLaser(vec3 start, vec3 end, vec3 color, GLfloat width); 206 SceneObject* createExplosion(); 208 207 209 208 void translateLaser(Laser* laser, const vec3& translation, GLuint ubo); … … 479 478 480 479 // player ship 481 SceneObject* ship = createShip( modelGroups[TYPE_SHIP].shaderProgram);480 SceneObject* ship = createShip(); 482 481 objects.push_back(ship); 483 482 … … 750 749 elapsed_seconds_spawn += elapsed_seconds; 751 750 if (elapsed_seconds_spawn > 0.5f) { 752 SceneObject* obj = createAsteroid(vec3(getRandomNum(-1.3f, 1.3f), -1.2f, getRandomNum(-5.5f, -4.5f)) , modelGroups[TYPE_ASTEROID].shaderProgram);751 SceneObject* obj = createAsteroid(vec3(getRandomNum(-1.3f, 1.3f), -1.2f, getRandomNum(-5.5f, -4.5f))); 753 752 addObjectToScene(obj, shaderBufferInfo, modelGroups, 754 753 points_vbo, … … 807 806 vec3 offset(objects[0]->model_transform * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 808 807 809 leftLaser = createLaser(vec3(-0.21f, -1.19f, 1.76f)+offset, vec3(-0.21f, -1.19f, -3.0f)+offset, 810 vec3(0.0f, 1.0f, 0.0f), 0.03f, modelGroups[TYPE_LASER].shaderProgram); 808 leftLaser = createLaser( 809 vec3(-0.21f, -1.19f, 1.76f)+offset, 810 vec3(-0.21f, -1.19f, -3.0f)+offset, 811 vec3(0.0f, 1.0f, 0.0f), 0.03f); 811 812 addObjectToScene(leftLaser, shaderBufferInfo, modelGroups, 812 813 points_vbo, … … 823 824 vec3 offset(objects[0]->model_transform * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 824 825 825 rightLaser = createLaser(vec3(0.21f, -1.19f, 1.76f) + offset, vec3(0.21f, -1.19f, -3.0f) + offset, 826 vec3(0.0f, 1.0f, 0.0f), 0.03f, modelGroups[TYPE_LASER].shaderProgram); 826 rightLaser = createLaser( 827 vec3(0.21f, -1.19f, 1.76f) + offset, 828 vec3(0.21f, -1.19f, -3.0f) + offset, 829 vec3(0.0f, 1.0f, 0.0f), 0.03f); 827 830 addObjectToScene(rightLaser, shaderBufferInfo, modelGroups, 828 831 points_vbo, … … 1329 1332 objects.push_back(obj); 1330 1333 1331 BufferInfo* bufferInfo = &shaderBufferInfo[ obj->shader_program];1334 BufferInfo* bufferInfo = &shaderBufferInfo[modelGroups[obj->type].shaderProgram]; 1332 1335 1333 1336 // Check if the buffers aren't large enough to fit the new object and, if so, call … … 1425 1428 } 1426 1429 1427 SceneObject* createShip( GLuint shader) {1430 SceneObject* createShip() { 1428 1431 SceneObject* ship = new SceneObject(); 1429 1432 1430 1433 ship->type = TYPE_SHIP; 1431 ship->shader_program = shader;1432 1434 1433 1435 ship->points = { … … 1822 1824 */ 1823 1825 // TODO: Make the color parameter have an effect 1824 Laser* createLaser(vec3 start, vec3 end, vec3 color, GLfloat width , GLuint laser_sp) {1826 Laser* createLaser(vec3 start, vec3 end, vec3 color, GLfloat width) { 1825 1827 Laser* obj = new Laser(); 1826 1828 obj->type = TYPE_LASER; 1827 1829 obj->targetAsteroid = NULL; 1828 obj->shader_program = laser_sp;1829 1830 1830 1831 vec3 ray = end - start; … … 2001 2002 glVertexAttribPointer(1, 1, GL_FLOAT, GL_FALSE, 0, NULL); 2002 2003 2003 objExplosion = createExplosion( modelGroups[TYPE_EXPLOSION].shaderProgram);2004 objExplosion = createExplosion(); 2004 2005 addObjectToScene(objExplosion, shaderBufferInfo, modelGroups, 2005 2006 points_vbo, … … 2049 2050 num_objects++; 2050 2051 2051 shaderCounts[ (*it)->shader_program] += (*it)->num_points;2052 shaderUboCounts[ (*it)->shader_program]++;2052 shaderCounts[modelGroups[(*it)->type].shaderProgram] += (*it)->num_points; 2053 shaderUboCounts[modelGroups[(*it)->type].shaderProgram]++; 2053 2054 2054 2055 it++; … … 2131 2132 GLuint ubo, 2132 2133 GLuint model_mat_idx_vbo) { 2133 BufferInfo* bufferInfo = &shaderBufferInfo[ obj.shader_program];2134 BufferInfo* bufferInfo = &shaderBufferInfo[modelGroups[obj.type].shaderProgram]; 2134 2135 2135 2136 obj.vertex_vbo_offset = bufferInfo->vbo_base + modelGroups[obj.type].numPoints; … … 2470 2471 } 2471 2472 2472 Asteroid* createAsteroid(vec3 pos , GLuint shader) {2473 Asteroid* createAsteroid(vec3 pos) { 2473 2474 Asteroid* obj = new Asteroid(); 2474 2475 obj->type = TYPE_ASTEROID; 2475 obj->shader_program = shader;2476 2476 obj->hp = 10.0f; 2477 2477 … … 2593 2593 } 2594 2594 2595 SceneObject* createExplosion( GLuint shader) {2595 SceneObject* createExplosion() { 2596 2596 SceneObject* obj = new SceneObject(); 2597 2597 obj->type = TYPE_EXPLOSION; 2598 obj->shader_program = shader;2599 2598 2600 2599 obj->points = {};
Note:
See TracChangeset
for help on using the changeset viewer.